Message ID | 20210514210015.18142-3-ansuelsmth@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 2ad255f2faaffb3af786031fba2e7955454b558a |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Multiple improvement to qca8k stability | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | fail | Series longer than 15 patches |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 7 of 7 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | WARNING: line length of 82 exceeds 80 columns |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
On Fri, May 14, 2021 at 10:59:52PM +0200, Ansuel Smith wrote: > Use iopoll macro instead of while loop. > > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> > Reviewed-by: Andrew Lunn <andrew@lunn.ch> This doesn't look quite right to me. > static int > qca8k_busy_wait(struct qca8k_priv *priv, u32 reg, u32 mask) > { > - unsigned long timeout; > - > - timeout = jiffies + msecs_to_jiffies(20); > + u32 val; val is unsigned here. > + /* Check if qca8k_read has failed for a different reason > + * before returning -ETIMEDOUT > + */ > + if (ret < 0 && val < 0) but here you are checking it for a negative number - this will always be false, making the conditional code unreachable. Either the test is wrong, or the type of val is wrong. Please resolve.
On Fri, May 14, 2021 at 11:52:25PM +0100, Russell King (Oracle) wrote: > On Fri, May 14, 2021 at 10:59:52PM +0200, Ansuel Smith wrote: > > Use iopoll macro instead of while loop. > > > > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> > > Reviewed-by: Andrew Lunn <andrew@lunn.ch> > > This doesn't look quite right to me. > > > static int > > qca8k_busy_wait(struct qca8k_priv *priv, u32 reg, u32 mask) > > { > > - unsigned long timeout; > > - > > - timeout = jiffies + msecs_to_jiffies(20); > > + u32 val; > > val is unsigned here. > > > + /* Check if qca8k_read has failed for a different reason > > + * before returning -ETIMEDOUT > > + */ > > + if (ret < 0 && val < 0) > > but here you are checking it for a negative number - this will always be > false, making the conditional code unreachable. Either the test is wrong, > or the type of val is wrong. Please resolve. > I know this is wrong and I will fix. Anyway I tested this and I checked if with u32 a negative value was actually provided and to my surprise the value was correctly returned. Any idea why? > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index 0b295da6c356..25fa7084e820 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -262,21 +262,20 @@ static struct regmap_config qca8k_regmap_config = { static int qca8k_busy_wait(struct qca8k_priv *priv, u32 reg, u32 mask) { - unsigned long timeout; - - timeout = jiffies + msecs_to_jiffies(20); + u32 val; + int ret; - /* loop until the busy flag has cleared */ - do { - u32 val = qca8k_read(priv, reg); - int busy = val & mask; + ret = read_poll_timeout(qca8k_read, val, !(val & mask), + 0, QCA8K_BUSY_WAIT_TIMEOUT * USEC_PER_MSEC, false, + priv, reg); - if (!busy) - break; - cond_resched(); - } while (!time_after_eq(jiffies, timeout)); + /* Check if qca8k_read has failed for a different reason + * before returning -ETIMEDOUT + */ + if (ret < 0 && val < 0) + return val; - return time_after_eq(jiffies, timeout); + return ret; } static void diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h index 7ca4b93e0bb5..86c585b7ec4a 100644 --- a/drivers/net/dsa/qca8k.h +++ b/drivers/net/dsa/qca8k.h @@ -18,6 +18,8 @@ #define PHY_ID_QCA8337 0x004dd036 #define QCA8K_ID_QCA8337 0x13 +#define QCA8K_BUSY_WAIT_TIMEOUT 20 + #define QCA8K_NUM_FDB_RECORDS 2048 #define QCA8K_CPU_PORT 0