diff mbox series

[net,V2,07/15] net/mlx5: Fix request_irqs error flow

Message ID 20201001195247.66636-8-saeed@kernel.org
State Changes Requested
Delegated to: David Miller
Headers show
Series [net,V2,01/15] net/mlx5: Don't allow health work when device is uninitialized | expand

Commit Message

Saeed Mahameed Oct. 1, 2020, 7:52 p.m. UTC
From: Maor Gottlieb <maorg@nvidia.com>

Fix error flow handling in request_irqs which try to free irq
that we failed to request.
It fixes the below trace.

WARNING: CPU: 1 PID: 7587 at kernel/irq/manage.c:1684 free_irq+0x4d/0x60
CPU: 1 PID: 7587 Comm: bash Tainted: G        W  OE    4.15.15-1.el7MELLANOXsmp-x86_64 #1
Hardware name: Advantech SKY-6200/SKY-6200, BIOS F2.00 08/06/2020
RIP: 0010:free_irq+0x4d/0x60
RSP: 0018:ffffc9000ef47af0 EFLAGS: 00010282
RAX: ffff88001476ae00 RBX: 0000000000000655 RCX: 0000000000000000
RDX: ffff88001476ae00 RSI: ffffc9000ef47ab8 RDI: ffff8800398bb478
RBP: ffff88001476a838 R08: ffff88001476ae00 R09: 000000000000156d
R10: 0000000000000000 R11: 0000000000000004 R12: ffff88001476a838
R13: 0000000000000006 R14: ffff88001476a888 R15: 00000000ffffffe4
FS:  00007efeadd32740(0000) GS:ffff88047fc40000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fc9cc010008 CR3: 00000001a2380004 CR4: 00000000007606e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
 mlx5_irq_table_create+0x38d/0x400 [mlx5_core]
 ? atomic_notifier_chain_register+0x50/0x60
 mlx5_load_one+0x7ee/0x1130 [mlx5_core]
 init_one+0x4c9/0x650 [mlx5_core]
 pci_device_probe+0xb8/0x120
 driver_probe_device+0x2a1/0x470
 ? driver_allows_async_probing+0x30/0x30
 bus_for_each_drv+0x54/0x80
 __device_attach+0xa3/0x100
 pci_bus_add_device+0x4a/0x90
 pci_iov_add_virtfn+0x2dc/0x2f0
 pci_enable_sriov+0x32e/0x420
 mlx5_core_sriov_configure+0x61/0x1b0 [mlx5_core]
 ? kstrtoll+0x22/0x70
 num_vf_store+0x4b/0x70 [mlx5_core]
 kernfs_fop_write+0x102/0x180
 __vfs_write+0x26/0x140
 ? rcu_all_qs+0x5/0x80
 ? _cond_resched+0x15/0x30
 ? __sb_start_write+0x41/0x80
 vfs_write+0xad/0x1a0
 SyS_write+0x42/0x90
 do_syscall_64+0x60/0x110
 entry_SYSCALL_64_after_hwframe+0x3d/0xa2

Fixes: 24163189da48 ("net/mlx5: Separate IRQ request/free from EQ life cycle")
Signed-off-by: Maor Gottlieb <maorg@nvidia.com>
Reviewed-by: Eran Ben Elisha <eranbe@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jakub Kicinski Oct. 1, 2020, 11:24 p.m. UTC | #1
On Thu,  1 Oct 2020 12:52:39 -0700 saeed@kernel.org wrote:
> -	for (; i >= 0; i--) {
> +	for (--i; i >= 0; i--) {

while (i--)
Saeed Mahameed Oct. 2, 2020, 5:05 p.m. UTC | #2
On Thu, 2020-10-01 at 16:24 -0700, Jakub Kicinski wrote:
> On Thu,  1 Oct 2020 12:52:39 -0700 saeed@kernel.org wrote:
> > -	for (; i >= 0; i--) {
> > +	for (--i; i >= 0; i--) {
> 
> while (i--)

while(--i)

I like this, less characters to maintain :)
Mark Bloch Oct. 2, 2020, 5:19 p.m. UTC | #3
On 10/2/2020 10:05, Saeed Mahameed wrote:
> On Thu, 2020-10-01 at 16:24 -0700, Jakub Kicinski wrote:
>> On Thu,  1 Oct 2020 12:52:39 -0700 saeed@kernel.org wrote:
>>> -	for (; i >= 0; i--) {
>>> +	for (--i; i >= 0; i--) {
>>
>> while (i--)
> 
> while(--i)

It has to be: while (i--)
Case of i=0,

> 
> I like this, less characters to maintain :)
> 

Mark
Saeed Mahameed Oct. 2, 2020, 5:27 p.m. UTC | #4
On Fri, 2020-10-02 at 10:19 -0700, Mark Bloch wrote:
> 
> On 10/2/2020 10:05, Saeed Mahameed wrote:
> > On Thu, 2020-10-01 at 16:24 -0700, Jakub Kicinski wrote:
> > > On Thu,  1 Oct 2020 12:52:39 -0700 saeed@kernel.org wrote:
> > > > -	for (; i >= 0; i--) {
> > > > +	for (--i; i >= 0; i--) {
> > > 
> > > while (i--)
> > 
> > while(--i)
> 
> It has to be: while (i--)
> Case of i=0,
> 

woops !

while (i--) it is. 

Thanks Mark.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
index 373981a659c7..ef26a0a6f890 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
@@ -115,7 +115,7 @@  static int request_irqs(struct mlx5_core_dev *dev, int nvec)
 	return 0;
 
 err_request_irq:
-	for (; i >= 0; i--) {
+	for (--i; i >= 0; i--) {
 		struct mlx5_irq *irq = mlx5_irq_get(dev, i);
 		int irqn = pci_irq_vector(dev->pdev, i);