Skip to contentSkip to conversation

IB/usnic: Add Cisco VIC low-level hardware driver

bug report Dan Carpenter 1 participant 1 message Aug 4, 2021 InfiniBand

lore
Share & tools
lore
#0 lore raw

[ This is an ancient bug, but the bug is clear to see, but unfortunately
it's probably less easy to fix. - dan ]

Hello Upinder Malhi,

The patch e3cf00d0a87f: "IB/usnic: Add Cisco VIC low-level hardware driver" from Sep 10, 2013, leads to the following static checker warning:

	fs/kernfs/dir.c:476 kernfs_drain()
	warn: sleeping in atomic context

drivers/infiniband/hw/usnic/usnic_ib_verbs.c
190 if (usnic_ib_share_vf) {

   191                  /* Try to find resouces on a used vf which is in pd */
   192                  dev_list = usnic_uiom_get_dev_list(pd->umem_pd);
   193                  if (IS_ERR(dev_list))
   194                          return ERR_CAST(dev_list);
   195                  for (i = 0; dev_list[i]; i++) {
   196                          dev = dev_list[i];
   197                          vf = dev_get_drvdata(dev);
   198                          spin_lock(&vf->lock);
                                ^^^^^^^^^^^^^^^^^^^^^

We're holding a spin lock.

199 vnic = vf->vnic;
200 if (!usnic_vnic_check_room(vnic, res_spec)) {
201 usnic_dbg("Found used vnic %s from %s\n",
202 dev_name(&us_ibdev->ib_dev.dev),
203 pci_name(usnic_vnic_get_pdev(
204 vnic)));
205 qp_grp = usnic_ib_qp_grp_create(us_ibdev->ufdev,

                                                 ^^^^^^^^^^^^^^^^^^^^^^

The create function calls usnic_ib_sysfs_qpn_add() which does a kobject_init_and_add(). Unfortunately kobject allocations have many sleeps inside them so it can't be done while holding a spinlock.

Same thing for the other usnic_ib_qp_grp_create() later on in the same function.

   206                                                                  vf, pd,
   207                                                                  res_spec,
   208                                                                  trans_spec);
   209  
   210                                  spin_unlock(&vf->lock);
   211                                  goto qp_grp_check;
   212                          }
   213                          spin_unlock(&vf->lock);
   214  
   215                  }
   216                  usnic_uiom_free_dev_list(dev_list);
   217                  dev_list = NULL;

218 }

regards,
dan carpenter