From: nschichan@freebox.fr (Nicolas Schichan)
To: linux-arm-kernel@lists.infradead.org
Subject: Spurious timeouts in mvmdio
Date: Wed, 04 Dec 2013 12:40:24 +0100 [thread overview]
Message-ID: <529F14A8.3020109@freebox.fr> (raw)
In-Reply-To: <20131203234209.GW16735@n2100.arm.linux.org.uk>
On 12/04/2013 12:42 AM, Russell King - ARM Linux wrote:
>> This will make it correct when using interrupts but it will make the
>> loop wait one jiffie longer than it should when polling.
>
> Alternatively, code it like this instead.
>
> drivers/net/ethernet/marvell/mvmdio.c | 32 +++++++++++++++-----------------
> 1 files changed, 15 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
> index 7354960b583b..a6f59831fc5b 100644
> --- a/drivers/net/ethernet/marvell/mvmdio.c
> +++ b/drivers/net/ethernet/marvell/mvmdio.c
> @@ -76,31 +76,29 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
> {
> struct orion_mdio_dev *dev = bus->priv;
> unsigned long timeout = usecs_to_jiffies(MVMDIO_SMI_TIMEOUT);
> - unsigned long end = jiffies + timeout;
> - int timedout = 0;
>
> - while (1) {
> - if (orion_mdio_smi_is_done(dev))
> + if (dev->err_interrupt > 0) {
> + if (wait_event_timeout(dev->smi_busy_wait,
> + orion_mdio_smi_is_done(dev),
> + 1 + timeout))
> return 0;
> - else if (timedout)
> - break;
> + } else {
> + unsigned long end = jiffies + timeout;
>
> - if (dev->err_interrupt <= 0) {
> - usleep_range(MVMDIO_SMI_POLL_INTERVAL_MIN,
> - MVMDIO_SMI_POLL_INTERVAL_MAX);
> + while (1) {
> + if (orion_mdio_smi_is_done(dev))
> + return 0;
>
> if (time_is_before_jiffies(end))
> - ++timedout;
> - } else {
> - wait_event_timeout(dev->smi_busy_wait,
> - orion_mdio_smi_is_done(dev),
> - timeout);
> -
> - ++timedout;
> - }
> + break;
> +
> + usleep_range(MVMDIO_SMI_POLL_INTERVAL_MIN,
> + MVMDIO_SMI_POLL_INTERVAL_MAX);
> + }
> }
>
> dev_err(bus->parent, "Timeout: SMI busy for too long\n");
> +
> return -ETIMEDOUT;
> }
Hi Russell,
I have just tested your patch on MV88F6281 and MV88F6282 both in polling and
irq mode and it works just fine.
I had a similar patch almost ready to submit but you were faster than me.
Feel free to add my:
Tested-by: Nicolas Schichan <nschichan@freebox.fr>
Thanks,
--
Nicolas Schichan
Freebox SAS
WARNING: multiple messages have this Message-ID (diff)
From: Nicolas Schichan <nschichan@freebox.fr>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>,
Leigh Brown <leigh@solinno.co.uk>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Jason Cooper <jason@lakedaemon.net>,
netdev@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
Florian Fainelli <florian@openwrt.org>,
"David S. Miller" <davem@davemloft.net>,
linux-arm-kernel@lists.infradead.org
Subject: Re: Spurious timeouts in mvmdio
Date: Wed, 04 Dec 2013 12:40:24 +0100 [thread overview]
Message-ID: <529F14A8.3020109@freebox.fr> (raw)
In-Reply-To: <20131203234209.GW16735@n2100.arm.linux.org.uk>
On 12/04/2013 12:42 AM, Russell King - ARM Linux wrote:
>> This will make it correct when using interrupts but it will make the
>> loop wait one jiffie longer than it should when polling.
>
> Alternatively, code it like this instead.
>
> drivers/net/ethernet/marvell/mvmdio.c | 32 +++++++++++++++-----------------
> 1 files changed, 15 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
> index 7354960b583b..a6f59831fc5b 100644
> --- a/drivers/net/ethernet/marvell/mvmdio.c
> +++ b/drivers/net/ethernet/marvell/mvmdio.c
> @@ -76,31 +76,29 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
> {
> struct orion_mdio_dev *dev = bus->priv;
> unsigned long timeout = usecs_to_jiffies(MVMDIO_SMI_TIMEOUT);
> - unsigned long end = jiffies + timeout;
> - int timedout = 0;
>
> - while (1) {
> - if (orion_mdio_smi_is_done(dev))
> + if (dev->err_interrupt > 0) {
> + if (wait_event_timeout(dev->smi_busy_wait,
> + orion_mdio_smi_is_done(dev),
> + 1 + timeout))
> return 0;
> - else if (timedout)
> - break;
> + } else {
> + unsigned long end = jiffies + timeout;
>
> - if (dev->err_interrupt <= 0) {
> - usleep_range(MVMDIO_SMI_POLL_INTERVAL_MIN,
> - MVMDIO_SMI_POLL_INTERVAL_MAX);
> + while (1) {
> + if (orion_mdio_smi_is_done(dev))
> + return 0;
>
> if (time_is_before_jiffies(end))
> - ++timedout;
> - } else {
> - wait_event_timeout(dev->smi_busy_wait,
> - orion_mdio_smi_is_done(dev),
> - timeout);
> -
> - ++timedout;
> - }
> + break;
> +
> + usleep_range(MVMDIO_SMI_POLL_INTERVAL_MIN,
> + MVMDIO_SMI_POLL_INTERVAL_MAX);
> + }
> }
>
> dev_err(bus->parent, "Timeout: SMI busy for too long\n");
> +
> return -ETIMEDOUT;
> }
Hi Russell,
I have just tested your patch on MV88F6281 and MV88F6282 both in polling and
irq mode and it works just fine.
I had a similar patch almost ready to submit but you were faster than me.
Feel free to add my:
Tested-by: Nicolas Schichan <nschichan@freebox.fr>
Thanks,
--
Nicolas Schichan
Freebox SAS
next prev parent reply other threads:[~2013-12-04 11:40 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-02 15:15 Spurious timeouts in mvmdio Nicolas Schichan
2013-12-02 15:15 ` Nicolas Schichan
2013-12-03 12:23 ` Jason Cooper
2013-12-03 12:23 ` Jason Cooper
2013-12-03 12:40 ` Russell King - ARM Linux
2013-12-03 12:40 ` Russell King - ARM Linux
2013-12-03 13:43 ` Jason Cooper
2013-12-03 13:43 ` Jason Cooper
2013-12-03 18:48 ` Nicolas Schichan
2013-12-03 18:48 ` Nicolas Schichan
2013-12-03 20:57 ` Leigh Brown
2013-12-03 20:57 ` Leigh Brown
2013-12-03 22:45 ` Sebastian Hesselbarth
2013-12-03 22:45 ` Sebastian Hesselbarth
2013-12-03 23:20 ` Leigh Brown
2013-12-03 23:20 ` Leigh Brown
2013-12-03 23:17 ` Sebastian Hesselbarth
2013-12-03 23:17 ` Sebastian Hesselbarth
2013-12-03 23:38 ` Leigh Brown
2013-12-03 23:38 ` Leigh Brown
2013-12-03 23:42 ` Russell King - ARM Linux
2013-12-03 23:42 ` Russell King - ARM Linux
2013-12-04 11:40 ` Nicolas Schichan [this message]
2013-12-04 11:40 ` Nicolas Schichan
2013-12-16 18:07 ` Nicolas Schichan
2013-12-16 18:07 ` Nicolas Schichan
2013-12-16 18:28 ` Leigh Brown
2013-12-16 18:28 ` Leigh Brown
2013-12-17 13:49 ` Nicolas Schichan
2013-12-17 13:49 ` Nicolas Schichan
2013-12-16 18:48 ` Russell King - ARM Linux
2013-12-16 18:48 ` Russell King - ARM Linux
2013-12-03 23:45 ` Sebastian Hesselbarth
2013-12-03 23:45 ` Sebastian Hesselbarth
2013-12-03 23:45 ` Sebastian Hesselbarth
2013-12-03 13:16 ` [PATCH] net: mvmdio: fix wait_event_timeout() being called with a 1 jiffy timeout Nicolas Schichan
2013-12-03 13:16 ` Nicolas Schichan
2013-12-03 13:34 ` Russell King - ARM Linux
2013-12-03 13:34 ` Russell King - ARM Linux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=529F14A8.3020109@freebox.fr \
--to=nschichan@freebox.fr \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.