From owner-dev-commits-src-branches@freebsd.org Mon Apr 19 13:09:19 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 03FCA5F1832; Mon, 19 Apr 2021 13:09:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FP6bL5mdTz3tjt; Mon, 19 Apr 2021 13:09:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9F8731FC8C; Mon, 19 Apr 2021 13:09:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13JD9Iiv005280; Mon, 19 Apr 2021 13:09:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13JD9Ij1005279; Mon, 19 Apr 2021 13:09:18 GMT (envelope-from git) Date: Mon, 19 Apr 2021 13:09:18 GMT Message-Id: <202104191309.13JD9Ij1005279@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 1d553a9e3a36 - stable/13 - qlnxr: Properly initialize the Linux device structure MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1d553a9e3a36760a5d366aad07c248570538435f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Apr 2021 13:09:19 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=1d553a9e3a36760a5d366aad07c248570538435f commit 1d553a9e3a36760a5d366aad07c248570538435f Author: Mark Johnston AuthorDate: 2021-04-12 13:32:08 +0000 Commit: Mark Johnston CommitDate: 2021-04-19 13:02:06 +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 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29595 (cherry picked from commit 56cbd386fbaefc009541870ee013b2ff8d096bfc) --- 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 b08eab8a6c46..0d8d33dd2686 100644 --- a/sys/dev/qlnx/qlnxr/qlnxr_def.h +++ b/sys/dev/qlnx/qlnxr/qlnxr_def.h @@ -365,7 +365,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); }