* [PATCH net] sfc: fix calling of free_irq with 0 argument
@ 2014-05-06 12:49 Nikolay Aleksandrov
2014-05-06 15:34 ` Nikolay Aleksandrov
2014-05-07 19:39 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2014-05-06 12:49 UTC (permalink / raw)
To: netdev
Cc: Nikolay Aleksandrov, linux-net-drivers, Shradha Shah,
David S. Miller
If the sfc driver is in legacy interrupt mode (either explicitly by
using interrupt_mode module param or by falling back to it) it will
hit a warning at kernel/irq/manage.c because it will try to free irq 0
in efx_nic_fini_interrupt() since the MSI interrupts were freed always,
but in legacy irq mode they're == 0. So fix it by checking if we
actually have an interrupt allocated and only then free it.
CC: <linux-net-drivers@solarflare.com>
CC: Shradha Shah <sshah@solarflare.com>
CC: David S. Miller <davem@davemloft.net>
Reported-by: Zenghui Shi <zshi@redhat.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
---
There're other ways to fix this as well, but I chose this one as it follows
the logic in the code. Also I saw it used in a few places to check if
there's an IRQ allocated for that channel.
drivers/net/ethernet/sfc/nic.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c
index 32d969e857f7..cab627defbc3 100644
--- a/drivers/net/ethernet/sfc/nic.c
+++ b/drivers/net/ethernet/sfc/nic.c
@@ -158,7 +158,9 @@ void efx_nic_fini_interrupt(struct efx_nic *efx)
/* Disable MSI/MSI-X interrupts */
efx_for_each_channel(channel, efx)
- free_irq(channel->irq, &efx->msi_context[channel->channel]);
+ if (channel->irq)
+ free_irq(channel->irq,
+ &efx->msi_context[channel->channel]);
/* Disable legacy interrupt */
if (efx->legacy_irq)
--
1.8.5.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] sfc: fix calling of free_irq with 0 argument
2014-05-06 12:49 [PATCH net] sfc: fix calling of free_irq with 0 argument Nikolay Aleksandrov
@ 2014-05-06 15:34 ` Nikolay Aleksandrov
2014-05-07 19:39 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2014-05-06 15:34 UTC (permalink / raw)
To: netdev
Cc: Nikolay Aleksandrov, linux-net-drivers, Shradha Shah,
David S. Miller, Ben Hutchings
On 05/06/2014 02:49 PM, Nikolay Aleksandrov wrote:
> If the sfc driver is in legacy interrupt mode (either explicitly by
> using interrupt_mode module param or by falling back to it) it will
> hit a warning at kernel/irq/manage.c because it will try to free irq 0
> in efx_nic_fini_interrupt() since the MSI interrupts were freed always,
> but in legacy irq mode they're == 0. So fix it by checking if we
> actually have an interrupt allocated and only then free it.
>
> CC: <linux-net-drivers@solarflare.com>
> CC: Shradha Shah <sshah@solarflare.com>
> CC: David S. Miller <davem@davemloft.net>
>
> Reported-by: Zenghui Shi <zshi@redhat.com>
> Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
> ---
> There're other ways to fix this as well, but I chose this one as it follows
> the logic in the code. Also I saw it used in a few places to check if
> there's an IRQ allocated for that channel.
>
> drivers/net/ethernet/sfc/nic.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c
> index 32d969e857f7..cab627defbc3 100644
> --- a/drivers/net/ethernet/sfc/nic.c
> +++ b/drivers/net/ethernet/sfc/nic.c
> @@ -158,7 +158,9 @@ void efx_nic_fini_interrupt(struct efx_nic *efx)
>
> /* Disable MSI/MSI-X interrupts */
> efx_for_each_channel(channel, efx)
> - free_irq(channel->irq, &efx->msi_context[channel->channel]);
> + if (channel->irq)
> + free_irq(channel->irq,
> + &efx->msi_context[channel->channel]);
>
> /* Disable legacy interrupt */
> if (efx->legacy_irq)
>
And of course if I had looked deeper in the history of that function I would've
seen that the code was like that before commit
1899c111a535e43046b14ae13639747d9d2544d6 ("sfc: Fix IRQ cleanup in case of a
probe failure"). So including Ben on the CC list as he's the author of that commit.
Cheers,
Nik
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] sfc: fix calling of free_irq with 0 argument
2014-05-06 12:49 [PATCH net] sfc: fix calling of free_irq with 0 argument Nikolay Aleksandrov
2014-05-06 15:34 ` Nikolay Aleksandrov
@ 2014-05-07 19:39 ` David Miller
2014-05-07 19:45 ` Nikolay Aleksandrov
1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2014-05-07 19:39 UTC (permalink / raw)
To: nikolay; +Cc: netdev, linux-net-drivers, sshah
From: Nikolay Aleksandrov <nikolay@redhat.com>
Date: Tue, 6 May 2014 14:49:16 +0200
> If the sfc driver is in legacy interrupt mode (either explicitly by
> using interrupt_mode module param or by falling back to it) it will
> hit a warning at kernel/irq/manage.c because it will try to free irq 0
> in efx_nic_fini_interrupt() since the MSI interrupts were freed always,
> but in legacy irq mode they're == 0. So fix it by checking if we
> actually have an interrupt allocated and only then free it.
>
> CC: <linux-net-drivers@solarflare.com>
> CC: Shradha Shah <sshah@solarflare.com>
> CC: David S. Miller <davem@davemloft.net>
>
> Reported-by: Zenghui Shi <zshi@redhat.com>
> Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
> ---
> There're other ways to fix this as well, but I chose this one as it follows
> the logic in the code. Also I saw it used in a few places to check if
> there's an IRQ allocated for that channel.
Zero can be a valid interrupt on some systems.
This is a discussion that keeps popping up from time to time, and Linus
usually gets upset when someone adds a "!irq" test somewhere.
Why not just guard the efx_for_each_channel() loop with a top-level
test of whether we are using legacy interrupt mode? That will avoid
this issue entirely.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] sfc: fix calling of free_irq with 0 argument
2014-05-07 19:39 ` David Miller
@ 2014-05-07 19:45 ` Nikolay Aleksandrov
0 siblings, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2014-05-07 19:45 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, sshah
On 05/07/2014 09:39 PM, David Miller wrote:
> From: Nikolay Aleksandrov <nikolay@redhat.com>
> Date: Tue, 6 May 2014 14:49:16 +0200
>
>> If the sfc driver is in legacy interrupt mode (either explicitly by
>> using interrupt_mode module param or by falling back to it) it will
>> hit a warning at kernel/irq/manage.c because it will try to free irq 0
>> in efx_nic_fini_interrupt() since the MSI interrupts were freed always,
>> but in legacy irq mode they're == 0. So fix it by checking if we
>> actually have an interrupt allocated and only then free it.
>>
>> CC: <linux-net-drivers@solarflare.com>
>> CC: Shradha Shah <sshah@solarflare.com>
>> CC: David S. Miller <davem@davemloft.net>
>>
>> Reported-by: Zenghui Shi <zshi@redhat.com>
>> Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
>> ---
>> There're other ways to fix this as well, but I chose this one as it follows
>> the logic in the code. Also I saw it used in a few places to check if
>> there's an IRQ allocated for that channel.
>
> Zero can be a valid interrupt on some systems.
>
> This is a discussion that keeps popping up from time to time, and Linus
> usually gets upset when someone adds a "!irq" test somewhere.
>
> Why not just guard the efx_for_each_channel() loop with a top-level
> test of whether we are using legacy interrupt mode? That will avoid
> this issue entirely.
>
Yeah, that was my other solution - looking at the mode the card's in.
I'm fine both ways, like I said earlier I did it this way to be consistent
with the style used (it's used like that in other places, too).
And then I found out it's been like that before the commit I mentioned.
If the Solarflare folks are okay with it I can re-write the function to be
based on the mode used instead of checking for zero irq. I'll post an
adjusted patch after I get a chance to test it.
Nik
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-05-07 19:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-06 12:49 [PATCH net] sfc: fix calling of free_irq with 0 argument Nikolay Aleksandrov
2014-05-06 15:34 ` Nikolay Aleksandrov
2014-05-07 19:39 ` David Miller
2014-05-07 19:45 ` Nikolay Aleksandrov
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).