* [PATCH net] mscc: Register poll timeout should be wall time not attempts
@ 2018-12-20 9:08 Steen Hegelund
2018-12-20 10:29 ` Alexandre Belloni
2018-12-20 10:31 ` Andrew Lunn
0 siblings, 2 replies; 5+ messages in thread
From: Steen Hegelund @ 2018-12-20 9:08 UTC (permalink / raw)
To: netdev, davem; +Cc: alexandre.belloni, Steen Hegelund
When doing indirect access in the Ocelot chip, a command is setup,
issued and then we need to poll until the result is ready. The polling
timeout is specified in milliseconds in the datasheet and not in
register access attempts.
Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
---
drivers/net/ethernet/mscc/ocelot.c | 55 +++++++++++++++---------------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index 3238b9ee42f3..debe74e4a041 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -15,6 +15,7 @@
#include <linux/netdevice.h>
#include <linux/phy.h>
#include <linux/skbuff.h>
+#include <linux/iopoll.h>
#include <net/arp.h>
#include <net/netevent.h>
#include <net/rtnetlink.h>
@@ -22,6 +23,9 @@
#include "ocelot.h"
+#define TABLE_UPDATE_SLEEP_US 10
+#define TABLE_UPDATE_TIMEOUT_US 100000
+
/* MAC table entry types.
* ENTRYTYPE_NORMAL is subject to aging.
* ENTRYTYPE_LOCKED is not subject to aging.
@@ -41,23 +45,20 @@ struct ocelot_mact_entry {
enum macaccess_entry_type type;
};
-static inline int ocelot_mact_wait_for_completion(struct ocelot *ocelot)
+static inline u32 ocelot_mact_read_macaccess(struct ocelot *ocelot)
{
- unsigned int val, timeout = 10;
-
- /* Wait for the issued mac table command to be completed, or timeout.
- * When the command read from ANA_TABLES_MACACCESS is
- * MACACCESS_CMD_IDLE, the issued command completed successfully.
- */
- do {
- val = ocelot_read(ocelot, ANA_TABLES_MACACCESS);
- val &= ANA_TABLES_MACACCESS_MAC_TABLE_CMD_M;
- } while (val != MACACCESS_CMD_IDLE && timeout--);
+ return ocelot_read(ocelot, ANA_TABLES_MACACCESS);
+}
- if (!timeout)
- return -ETIMEDOUT;
+static inline int ocelot_mact_wait_for_completion(struct ocelot *ocelot)
+{
+ u32 val;
- return 0;
+ return readx_poll_timeout(ocelot_mact_read_macaccess,
+ ocelot, val,
+ (val & ANA_TABLES_MACACCESS_MAC_TABLE_CMD_M) ==
+ MACACCESS_CMD_IDLE,
+ TABLE_UPDATE_SLEEP_US, TABLE_UPDATE_TIMEOUT_US);
}
static void ocelot_mact_select(struct ocelot *ocelot,
@@ -129,23 +130,21 @@ static void ocelot_mact_init(struct ocelot *ocelot)
ocelot_write(ocelot, MACACCESS_CMD_INIT, ANA_TABLES_MACACCESS);
}
-static inline int ocelot_vlant_wait_for_completion(struct ocelot *ocelot)
+static inline u32 ocelot_vlant_read_vlanaccess(struct ocelot *ocelot)
{
- unsigned int val, timeout = 10;
-
- /* Wait for the issued vlan table command to be completed, or timeout.
- * When the command read from ANA_TABLES_VLANACCESS is
- * VLANACCESS_CMD_IDLE, the issued command completed successfully.
- */
- do {
- val = ocelot_read(ocelot, ANA_TABLES_VLANACCESS);
- val &= ANA_TABLES_VLANACCESS_VLAN_TBL_CMD_M;
- } while (val != ANA_TABLES_VLANACCESS_CMD_IDLE && timeout--);
+ return ocelot_read(ocelot, ANA_TABLES_VLANACCESS);
+}
- if (!timeout)
- return -ETIMEDOUT;
+static inline int ocelot_vlant_wait_for_completion(struct ocelot *ocelot)
+{
+ u32 val;
- return 0;
+ return readx_poll_timeout(ocelot_vlant_read_vlanaccess,
+ ocelot,
+ val,
+ (val & ANA_TABLES_VLANACCESS_VLAN_TBL_CMD_M) ==
+ ANA_TABLES_VLANACCESS_CMD_IDLE,
+ TABLE_UPDATE_SLEEP_US, TABLE_UPDATE_TIMEOUT_US);
}
static int ocelot_vlant_set_mask(struct ocelot *ocelot, u16 vid, u32 mask)
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net] mscc: Register poll timeout should be wall time not attempts
2018-12-20 9:08 [PATCH net] mscc: Register poll timeout should be wall time not attempts Steen Hegelund
@ 2018-12-20 10:29 ` Alexandre Belloni
2018-12-20 10:31 ` Andrew Lunn
1 sibling, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2018-12-20 10:29 UTC (permalink / raw)
To: Steen Hegelund; +Cc: netdev, davem
On 20/12/2018 10:08:16+0100, Steen Hegelund wrote:
> When doing indirect access in the Ocelot chip, a command is setup,
> issued and then we need to poll until the result is ready. The polling
> timeout is specified in milliseconds in the datasheet and not in
> register access attempts.
>
> Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
> drivers/net/ethernet/mscc/ocelot.c | 55 +++++++++++++++---------------
> 1 file changed, 27 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
> index 3238b9ee42f3..debe74e4a041 100644
> --- a/drivers/net/ethernet/mscc/ocelot.c
> +++ b/drivers/net/ethernet/mscc/ocelot.c
> @@ -15,6 +15,7 @@
> #include <linux/netdevice.h>
> #include <linux/phy.h>
> #include <linux/skbuff.h>
> +#include <linux/iopoll.h>
> #include <net/arp.h>
> #include <net/netevent.h>
> #include <net/rtnetlink.h>
> @@ -22,6 +23,9 @@
>
> #include "ocelot.h"
>
> +#define TABLE_UPDATE_SLEEP_US 10
> +#define TABLE_UPDATE_TIMEOUT_US 100000
> +
> /* MAC table entry types.
> * ENTRYTYPE_NORMAL is subject to aging.
> * ENTRYTYPE_LOCKED is not subject to aging.
> @@ -41,23 +45,20 @@ struct ocelot_mact_entry {
> enum macaccess_entry_type type;
> };
>
> -static inline int ocelot_mact_wait_for_completion(struct ocelot *ocelot)
> +static inline u32 ocelot_mact_read_macaccess(struct ocelot *ocelot)
> {
> - unsigned int val, timeout = 10;
> -
> - /* Wait for the issued mac table command to be completed, or timeout.
> - * When the command read from ANA_TABLES_MACACCESS is
> - * MACACCESS_CMD_IDLE, the issued command completed successfully.
> - */
> - do {
> - val = ocelot_read(ocelot, ANA_TABLES_MACACCESS);
> - val &= ANA_TABLES_MACACCESS_MAC_TABLE_CMD_M;
> - } while (val != MACACCESS_CMD_IDLE && timeout--);
> + return ocelot_read(ocelot, ANA_TABLES_MACACCESS);
> +}
>
> - if (!timeout)
> - return -ETIMEDOUT;
> +static inline int ocelot_mact_wait_for_completion(struct ocelot *ocelot)
> +{
> + u32 val;
>
> - return 0;
> + return readx_poll_timeout(ocelot_mact_read_macaccess,
> + ocelot, val,
> + (val & ANA_TABLES_MACACCESS_MAC_TABLE_CMD_M) ==
> + MACACCESS_CMD_IDLE,
> + TABLE_UPDATE_SLEEP_US, TABLE_UPDATE_TIMEOUT_US);
> }
>
> static void ocelot_mact_select(struct ocelot *ocelot,
> @@ -129,23 +130,21 @@ static void ocelot_mact_init(struct ocelot *ocelot)
> ocelot_write(ocelot, MACACCESS_CMD_INIT, ANA_TABLES_MACACCESS);
> }
>
> -static inline int ocelot_vlant_wait_for_completion(struct ocelot *ocelot)
> +static inline u32 ocelot_vlant_read_vlanaccess(struct ocelot *ocelot)
> {
> - unsigned int val, timeout = 10;
> -
> - /* Wait for the issued vlan table command to be completed, or timeout.
> - * When the command read from ANA_TABLES_VLANACCESS is
> - * VLANACCESS_CMD_IDLE, the issued command completed successfully.
> - */
> - do {
> - val = ocelot_read(ocelot, ANA_TABLES_VLANACCESS);
> - val &= ANA_TABLES_VLANACCESS_VLAN_TBL_CMD_M;
> - } while (val != ANA_TABLES_VLANACCESS_CMD_IDLE && timeout--);
> + return ocelot_read(ocelot, ANA_TABLES_VLANACCESS);
> +}
>
> - if (!timeout)
> - return -ETIMEDOUT;
> +static inline int ocelot_vlant_wait_for_completion(struct ocelot *ocelot)
> +{
> + u32 val;
>
> - return 0;
> + return readx_poll_timeout(ocelot_vlant_read_vlanaccess,
> + ocelot,
> + val,
> + (val & ANA_TABLES_VLANACCESS_VLAN_TBL_CMD_M) ==
> + ANA_TABLES_VLANACCESS_CMD_IDLE,
> + TABLE_UPDATE_SLEEP_US, TABLE_UPDATE_TIMEOUT_US);
> }
>
> static int ocelot_vlant_set_mask(struct ocelot *ocelot, u16 vid, u32 mask)
> --
> 2.20.1
>
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] mscc: Register poll timeout should be wall time not attempts
2018-12-20 9:08 [PATCH net] mscc: Register poll timeout should be wall time not attempts Steen Hegelund
2018-12-20 10:29 ` Alexandre Belloni
@ 2018-12-20 10:31 ` Andrew Lunn
2018-12-20 11:11 ` Steen Hegelund
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2018-12-20 10:31 UTC (permalink / raw)
To: Steen Hegelund; +Cc: netdev, davem, alexandre.belloni
On Thu, Dec 20, 2018 at 10:08:16AM +0100, Steen Hegelund wrote:
> When doing indirect access in the Ocelot chip, a command is setup,
> issued and then we need to poll until the result is ready. The polling
> timeout is specified in milliseconds in the datasheet and not in
> register access attempts.
>
> Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
Hi Steen
Have you seen real issues with this code? You have marked this for
net, indicating it is a bug fix. If it is a real fix, please provide a
fixes: tag.
Thanks
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] mscc: Register poll timeout should be wall time not attempts
2018-12-20 10:31 ` Andrew Lunn
@ 2018-12-20 11:11 ` Steen Hegelund
2018-12-20 11:31 ` Andrew Lunn
0 siblings, 1 reply; 5+ messages in thread
From: Steen Hegelund @ 2018-12-20 11:11 UTC (permalink / raw)
To: Andrew Lunn; +Cc: netdev
The 12/20/2018 11:31, Andrew Lunn wrote:
> On Thu, Dec 20, 2018 at 10:08:16AM +0100, Steen Hegelund wrote:
> > When doing indirect access in the Ocelot chip, a command is setup,
> > issued and then we need to poll until the result is ready. The polling
> > timeout is specified in milliseconds in the datasheet and not in
> > register access attempts.
> >
> > Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
>
> Hi Steen
>
> Have you seen real issues with this code? You have marked this for
> net, indicating it is a bug fix. If it is a real fix, please provide a
> fixes: tag.
>
> Thanks
> Andrew
Hi Andrew,
It is not a bug on the currently supported platform, but we observed
that the code does not work properly on other platforms that we want to
support as the timing requirements there are different. So maybe this
is rather an improvement than a fix...
Should this rather go to net-next?
--
BR
Steen
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] mscc: Register poll timeout should be wall time not attempts
2018-12-20 11:11 ` Steen Hegelund
@ 2018-12-20 11:31 ` Andrew Lunn
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2018-12-20 11:31 UTC (permalink / raw)
To: netdev
On Thu, Dec 20, 2018 at 12:11:50PM +0100, Steen Hegelund wrote:
> The 12/20/2018 11:31, Andrew Lunn wrote:
> > On Thu, Dec 20, 2018 at 10:08:16AM +0100, Steen Hegelund wrote:
> > > When doing indirect access in the Ocelot chip, a command is setup,
> > > issued and then we need to poll until the result is ready. The polling
> > > timeout is specified in milliseconds in the datasheet and not in
> > > register access attempts.
> > >
> > > Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
> >
> > Hi Steen
> >
> > Have you seen real issues with this code? You have marked this for
> > net, indicating it is a bug fix. If it is a real fix, please provide a
> > fixes: tag.
> >
> > Thanks
> > Andrew
>
> Hi Andrew,
>
> It is not a bug on the currently supported platform, but we observed
> that the code does not work properly on other platforms that we want to
> support as the timing requirements there are different. So maybe this
> is rather an improvement than a fix...
>
> Should this rather go to net-next?
The requirements for stable are listed here:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
net-next seems a better fit.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-12-20 11:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-20 9:08 [PATCH net] mscc: Register poll timeout should be wall time not attempts Steen Hegelund
2018-12-20 10:29 ` Alexandre Belloni
2018-12-20 10:31 ` Andrew Lunn
2018-12-20 11:11 ` Steen Hegelund
2018-12-20 11:31 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).