Date: Mon, 12 Apr 2021 13:36:16 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 56cbd386fbae - main - qlnxr: Properly initialize the Linux device structure Message-ID: <202104121336.13CDaGm1029030@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=56cbd386fbaefc009541870ee013b2ff8d096bfc commit 56cbd386fbaefc009541870ee013b2ff8d096bfc Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2021-04-12 13:32:08 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2021-04-12 13:32:08 +0000 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 --- sys/dev/qlnx/qlnxr/qlnxr_def.h | 2 +- sys/dev/qlnx/qlnxr/qlnxr_os.c | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/sys/dev/qlnx/qlnxr/qlnxr_def.h b/sys/dev/qlnx/qlnxr/qlnxr_def.h index 04f911e792a8..9bc663e2a8d0 100644 --- a/sys/dev/qlnx/qlnxr/qlnxr_def.h +++ b/sys/dev/qlnx/qlnxr/qlnxr_def.h @@ -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; diff --git a/sys/dev/qlnx/qlnxr/qlnxr_os.c b/sys/dev/qlnx/qlnxr/qlnxr_os.c index b6b56f58f166..62c0f2091d2f 100644 --- a/sys/dev/qlnx/qlnxr/qlnxr_os.c +++ b/sys/dev/qlnx/qlnxr/qlnxr_os.c @@ -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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104121336.13CDaGm1029030>