qlnxr: Properly initialize the Linux device structure

The driver needs to provide a LinuxKPI device structure to register
itself with the IB subsystem.  It was erroneously using a copy of its
FreeBSD device structure for this purpose.

Use linux_pci_attach_device() instead, following the example of the
Chelsio iwarp driver.  Also ensure that we don't leak the faked device
during detach.

Reviewed by:	hselasky
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29595
This commit is contained in:
Mark Johnston 2021-04-12 09:32:08 -04:00
parent 9771af4942
commit 56cbd386fb
2 changed files with 5 additions and 7 deletions

View File

@ -364,7 +364,7 @@ struct qlnxr_dev {
struct ecore_dev *cdev;
/* Added to extend Applications Support */
struct pci_dev *pdev;
struct pci_dev pdev;
uint32_t dp_module;
uint8_t dp_level;

View File

@ -257,7 +257,7 @@ qlnxr_register_device(qlnxr_dev_t *dev)
ibdev->post_recv = qlnxr_post_recv;
ibdev->process_mad = qlnxr_process_mad;
ibdev->dma_device = &dev->pdev->dev;
ibdev->dma_device = &dev->pdev.dev;
ibdev->get_link_layer = qlnxr_link_layer;
@ -1097,11 +1097,7 @@ qlnxr_add(void *eth_dev)
dev->ha = eth_dev;
dev->cdev = &ha->cdev;
/* Added to extend Application support */
dev->pdev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL);
dev->pdev->dev = *(dev->ha->pci_dev);
dev->pdev->device = pci_get_device(dev->ha->pci_dev);
dev->pdev->vendor = pci_get_vendor(dev->ha->pci_dev);
linux_pci_attach_device(dev->ha->pci_dev, NULL, NULL, &dev->pdev);
dev->rdma_ctx = &ha->cdev.hwfns[0];
dev->wq_multiplier = wq_multiplier;
@ -1210,6 +1206,8 @@ qlnxr_remove(void *eth_dev, void *qlnx_rdma_dev)
qlnxr_remove_sysfiles(dev);
ib_dealloc_device(&dev->ibdev);
linux_pci_detach_device(&dev->pdev);
QL_DPRINT12(ha, "exit ha = %p qlnx_rdma_dev = %p\n", ha, qlnx_rdma_dev);
return (0);
}