diff mbox

net: mvmdio: fix interrupt timeout handling

Message ID 1387451589-15491-1-git-send-email-leigh@solinno.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Leigh Brown Dec. 19, 2013, 11:13 a.m. UTC
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(+)

Comments

Sebastian Hesselbarth Dec. 19, 2013, 11:33 a.m. UTC | #1
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);
>
Leigh Brown Dec. 19, 2013, 12:39 p.m. UTC | #2
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.
diff mbox

Patch

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