linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: mvmdio: fix interrupt timeout handling
@ 2013-12-19 11:13 Leigh Brown
  2013-12-19 11:33 ` Sebastian Hesselbarth
  0 siblings, 1 reply; 7+ messages in thread
From: Leigh Brown @ 2013-12-19 11:13 UTC (permalink / raw)
  To: linux-arm-kernel

orion_mdio_wait_ready uses wait_event_timeout to wait for the
SMI interrupt to fire.  wait_event_timeout waits for between
"timeout - 1" and "timeout" jiffies.  In this case a 1ms timeout
when HZ is 1000 results in a wait of 0 to 1 jiffies, causing
premature timeouts.

This fix ensures a minimum timeout of 2 jiffies, ensuring
wait_event_timeout will always wait at least 1 jiffie.

Issue reported by Nicolas Schichan.

Tested-by: Nicolas Schichan <nschichan@freebox.fr>
Signed-off-by: Leigh Brown <leigh@solinno.co.uk>
---
 drivers/net/ethernet/marvell/mvmdio.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 7354960..a42a750 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -92,6 +92,12 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
 			if (time_is_before_jiffies(end))
 				++timedout;
 	        } else {
+			/* wait_event_timeout does not guarantee a delay of at
+			 * least one whole jiffie, so timeout must be no less
+			 * than two.
+			 */
+			 if (timeout < 2)
+			 	timeout = 2;
 			wait_event_timeout(dev->smi_busy_wait,
 				           orion_mdio_smi_is_done(dev),
 				           timeout);
-- 
1.8.5.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] net: mvmdio: fix interrupt timeout handling
  2013-12-19 11:13 [PATCH] net: mvmdio: fix interrupt timeout handling Leigh Brown
@ 2013-12-19 11:33 ` Sebastian Hesselbarth
  2013-12-19 12:39   ` Leigh Brown
  2013-12-19 13:09   ` [PATCH v2] " Leigh Brown
  0 siblings, 2 replies; 7+ messages in thread
From: Sebastian Hesselbarth @ 2013-12-19 11:33 UTC (permalink / raw)
  To: linux-arm-kernel

On 12/19/13 12:13, Leigh Brown wrote:
> orion_mdio_wait_ready uses wait_event_timeout to wait for the
> SMI interrupt to fire.  wait_event_timeout waits for between
> "timeout - 1" and "timeout" jiffies.  In this case a 1ms timeout
> when HZ is 1000 results in a wait of 0 to 1 jiffies, causing
> premature timeouts.
>
> This fix ensures a minimum timeout of 2 jiffies, ensuring
> wait_event_timeout will always wait at least 1 jiffie.
>
> Issue reported by Nicolas Schichan.
>
> Tested-by: Nicolas Schichan <nschichan@freebox.fr>
> Signed-off-by: Leigh Brown <leigh@solinno.co.uk>
> ---
>   drivers/net/ethernet/marvell/mvmdio.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
> index 7354960..a42a750 100644
> --- a/drivers/net/ethernet/marvell/mvmdio.c
> +++ b/drivers/net/ethernet/marvell/mvmdio.c
> @@ -92,6 +92,12 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
>   			if (time_is_before_jiffies(end))
>   				++timedout;
>   	        } else {
> +			/* wait_event_timeout does not guarantee a delay of at
> +			 * least one whole jiffie, so timeout must be no less
> +			 * than two.
> +			 */
> +			 if (timeout < 2)
> +			 	timeout = 2;

Hi Leigh,

above two lines have a whitespace issue.

Sebastian

>   			wait_event_timeout(dev->smi_busy_wait,
>   				           orion_mdio_smi_is_done(dev),
>   				           timeout);
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] net: mvmdio: fix interrupt timeout handling
  2013-12-19 11:33 ` Sebastian Hesselbarth
@ 2013-12-19 12:39   ` Leigh Brown
  2013-12-19 13:09   ` [PATCH v2] " Leigh Brown
  1 sibling, 0 replies; 7+ messages in thread
From: Leigh Brown @ 2013-12-19 12:39 UTC (permalink / raw)
  To: linux-arm-kernel

On 2013-12-19 11:33, Sebastian Hesselbarth wrote:
>> +			 if (timeout < 2)
>> +			 	timeout = 2;
> 
> Hi Leigh,
> 
> above two lines have a whitespace issue.

Crap, you are correct.  I will fix it and send another patch.

Regards,

Leigh.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] net: mvmdio: fix interrupt timeout handling
  2013-12-19 11:33 ` Sebastian Hesselbarth
  2013-12-19 12:39   ` Leigh Brown
@ 2013-12-19 13:09   ` Leigh Brown
  2013-12-19 17:43     ` Jason Gunthorpe
  2013-12-20  0:21     ` David Miller
  1 sibling, 2 replies; 7+ messages in thread
From: Leigh Brown @ 2013-12-19 13:09 UTC (permalink / raw)
  To: linux-arm-kernel

This version corrects the whitespace issue.

orion_mdio_wait_ready uses wait_event_timeout to wait for the
SMI interrupt to fire.  wait_event_timeout waits for between
"timeout - 1" and "timeout" jiffies.  In this case a 1ms timeout
when HZ is 1000 results in a wait of 0 to 1 jiffies, causing
premature timeouts.

This fix ensures a minimum timeout of 2 jiffies, ensuring
wait_event_timeout will always wait at least 1 jiffie.

Issue reported by Nicolas Schichan.

Tested-by: Nicolas Schichan <nschichan@freebox.fr>
Signed-off-by: Leigh Brown <leigh@solinno.co.uk>
---
 drivers/net/ethernet/marvell/mvmdio.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 7354960..c4eeb69 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -92,6 +92,12 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
 			if (time_is_before_jiffies(end))
 				++timedout;
 	        } else {
+			/* wait_event_timeout does not guarantee a delay of at
+			 * least one whole jiffie, so timeout must be no less
+			 * than two.
+			 */
+			if (timeout < 2)
+				timeout = 2;
 			wait_event_timeout(dev->smi_busy_wait,
 				           orion_mdio_smi_is_done(dev),
 				           timeout);
-- 
1.8.5.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2] net: mvmdio: fix interrupt timeout handling
  2013-12-19 13:09   ` [PATCH v2] " Leigh Brown
@ 2013-12-19 17:43     ` Jason Gunthorpe
  2013-12-19 19:35       ` Leigh Brown
  2013-12-20  0:21     ` David Miller
  1 sibling, 1 reply; 7+ messages in thread
From: Jason Gunthorpe @ 2013-12-19 17:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Dec 19, 2013 at 01:09:48PM +0000, Leigh Brown wrote:
> This version corrects the whitespace issue.
> 
> orion_mdio_wait_ready uses wait_event_timeout to wait for the
> SMI interrupt to fire.  wait_event_timeout waits for between
> "timeout - 1" and "timeout" jiffies.  In this case a 1ms timeout
> when HZ is 1000 results in a wait of 0 to 1 jiffies, causing
> premature timeouts.
> 
> This fix ensures a minimum timeout of 2 jiffies, ensuring
> wait_event_timeout will always wait at least 1 jiffie.
> 
> Issue reported by Nicolas Schichan.
> 
> Tested-by: Nicolas Schichan <nschichan@freebox.fr>
> Signed-off-by: Leigh Brown <leigh@solinno.co.uk>
>  drivers/net/ethernet/marvell/mvmdio.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Leigh, I have just noticed a regression in 3.13-rc3 vs 3.10, on
kirkwood where 3.13 occasionally prints:

3 12/11 13:59:02 kernel: orion-mdio f1072004.mdio: Timeout: SMI busy for too long

Is that the same issue that this patch is addressing?

Regards,
Jason

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] net: mvmdio: fix interrupt timeout handling
  2013-12-19 17:43     ` Jason Gunthorpe
@ 2013-12-19 19:35       ` Leigh Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Leigh Brown @ 2013-12-19 19:35 UTC (permalink / raw)
  To: linux-arm-kernel

On 2013-12-19 17:43, Jason Gunthorpe wrote:
> On Thu, Dec 19, 2013 at 01:09:48PM +0000, Leigh Brown wrote:
>> This version corrects the whitespace issue.
>> 
>> orion_mdio_wait_ready uses wait_event_timeout to wait for the
>> SMI interrupt to fire.  wait_event_timeout waits for between
>> "timeout - 1" and "timeout" jiffies.  In this case a 1ms timeout
>> when HZ is 1000 results in a wait of 0 to 1 jiffies, causing
>> premature timeouts.
>> 
>> This fix ensures a minimum timeout of 2 jiffies, ensuring
>> wait_event_timeout will always wait at least 1 jiffie.
>> 
>> Issue reported by Nicolas Schichan.
>> 
>> Tested-by: Nicolas Schichan <nschichan@freebox.fr>
>> Signed-off-by: Leigh Brown <leigh@solinno.co.uk>
>>  drivers/net/ethernet/marvell/mvmdio.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
> 
> Leigh, I have just noticed a regression in 3.13-rc3 vs 3.10, on
> kirkwood where 3.13 occasionally prints:
> 
> 3 12/11 13:59:02 kernel: orion-mdio f1072004.mdio: Timeout: SMI busy
> for too long
> 
> Is that the same issue that this patch is addressing?

Yes, absolutely.

Regards,

Leigh.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] net: mvmdio: fix interrupt timeout handling
  2013-12-19 13:09   ` [PATCH v2] " Leigh Brown
  2013-12-19 17:43     ` Jason Gunthorpe
@ 2013-12-20  0:21     ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2013-12-20  0:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Leigh Brown <leigh@solinno.co.uk>
Date: Thu, 19 Dec 2013 13:09:48 +0000

> This version corrects the whitespace issue.
> 
> orion_mdio_wait_ready uses wait_event_timeout to wait for the
> SMI interrupt to fire.  wait_event_timeout waits for between
> "timeout - 1" and "timeout" jiffies.  In this case a 1ms timeout
> when HZ is 1000 results in a wait of 0 to 1 jiffies, causing
> premature timeouts.
> 
> This fix ensures a minimum timeout of 2 jiffies, ensuring
> wait_event_timeout will always wait at least 1 jiffie.
> 
> Issue reported by Nicolas Schichan.
> 
> Tested-by: Nicolas Schichan <nschichan@freebox.fr>
> Signed-off-by: Leigh Brown <leigh@solinno.co.uk>

Applied, and queued up for -stable.

I wonder how many other wait_event_timeout() users potentially have
this problem.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-12-20  0:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-19 11:13 [PATCH] net: mvmdio: fix interrupt timeout handling Leigh Brown
2013-12-19 11:33 ` Sebastian Hesselbarth
2013-12-19 12:39   ` Leigh Brown
2013-12-19 13:09   ` [PATCH v2] " Leigh Brown
2013-12-19 17:43     ` Jason Gunthorpe
2013-12-19 19:35       ` Leigh Brown
2013-12-20  0:21     ` David Miller

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).