From nobody Wed Jan 18 16:25:06 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NxrhM4PFdz2yJYC; Wed, 18 Jan 2023 16:25:07 +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 4NxrhL4zC2z3FXM; Wed, 18 Jan 2023 16:25:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674059106; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xxRiSTPY4RhRZIhxKXr34NlhXd8gsEXfXSrVdRABJVY=; b=aagI4HA+EwsSME+/QNEL5R4wXLx7SCze+ljEZeEshcpIqkl7/UDU6mfXJ/+qR34yFkoeTg eLXndN/DTG6EPUan+rGKKSHjEOydRCEARsXU//f4vINhIMJo0qhEtjeSaFM/t0eLurN6z0 W2XExixQVIrh1shSgRxpuh6WmsCG81TiC45NTzQq/HLlFfYQDRxFA5JDz9nloNncfntHCO 8T1tfiUSa/8D2UgYrss0jQ6ieQSzyslTqxKAj+a6qYIazB8T5gAylBcgqm23YXftw+Uo7q jpHjEv48lpy37S5+lv2AAHmrviVGugDLiP8G8S1uI10k20eAVwJIwlKKrOcngg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674059106; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xxRiSTPY4RhRZIhxKXr34NlhXd8gsEXfXSrVdRABJVY=; b=Q/T8zrhRgBmKWY4gNMcG6szIx3GzO6not9acEEUT7cDpK8Tcic9H2zWnnvHCLuLuAdiArh kTqdf5CiEjrKpcA/fY2pv62TrL2U8YK0BWzZWbg0BTfU1i/JU/UpG6JBcZ7d9G0N3iyS+E 5DMJseQIxzAvSZO9ymNqhkWY9xgHi49k8kEaHKXc+F1cAcYR/lwXFh3DPsQgCSO4hkhJcF TDBFmbIkKWjFLCCaYqC7SpyTVXQKfUcR3Yv+IBOTraYgxBKux/LM3ZIGWfI4WGiML2mxj7 YjDPeS6XhF9Glq+AWI7NDWqG4yBi0i+UBGK9uFBrOaEylzA9DHA2L8EYXrSYsg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674059106; a=rsa-sha256; cv=none; b=StfmCDdKmCMltlv8W+LbkhJO1Wi5pnXQ/u2v2tJZj1TwpsAfUqClDqxi+FzyyhOnBX+YNd fZ4YYB6yBPrmbi8YEbN5a1lq3WxrbTNKkb382MA6g6Y80Bedb0PoigB4tIevhuXhLpeVZL 2tVDqrFbbA3FaL5esCMNe6ml4N2lHe+bLh8j+UvMPWlcsRnqOgJd2g9akxFssSO/3E1hn3 KkPnZF/DPcl3nCvCDpRHGGF5Rt4JNb17AToyO350Vs8tPpxeqFBfBzjNtQPwJku0zQW6TY Cqxb1X31ZKNEzn5c2YYan0DdAAkxxWeKHN5etjAw4yflpUAfh3+DePI4DdMs2w== 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 4NxrhL4298zJB6; Wed, 18 Jan 2023 16:25:06 +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 30IGP6MM038330; Wed, 18 Jan 2023 16:25:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30IGP6qb038329; Wed, 18 Jan 2023 16:25:06 GMT (envelope-from git) Date: Wed, 18 Jan 2023 16:25:06 GMT Message-Id: <202301181625.30IGP6qb038329@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 0b0eb6b1e6a3 - stable/13 - LinuxKPI: pci: add [linuxkpi_]pci_get_device() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0b0eb6b1e6a30495e9bc5991e56ca0221a9730c8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=0b0eb6b1e6a30495e9bc5991e56ca0221a9730c8 commit 0b0eb6b1e6a30495e9bc5991e56ca0221a9730c8 Author: Bjoern A. Zeeb AuthorDate: 2022-12-02 22:14:09 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-01-18 13:26:51 +0000 LinuxKPI: pci: add [linuxkpi_]pci_get_device() Add a version of pci_get_device() as linuxkpi_pci_get_device() not (yet) supporting the last argument. Due to conflicts we cannot redefine it as we would normally do in LinuxKPI so drivers have to be adjusted. Differential Revision: https://reviews.freebsd.org/D37593 (cherry picked from commit 8f61992d7cc1108cebc1337451a15a0af420984c) --- sys/compat/linuxkpi/common/include/linux/pci.h | 14 ++++++++++++++ sys/compat/linuxkpi/common/src/linux_pci.c | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index f870b039254c..de041fa966ea 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -358,6 +358,7 @@ void lkpi_pci_devres_release(struct device *, void *); struct resource *_lkpi_pci_iomap(struct pci_dev *pdev, int bar, int mmio_size); struct pcim_iomap_devres *lkpi_pcim_iomap_devres_find(struct pci_dev *pdev); void lkpi_pcim_iomap_table_release(struct device *, void *); +struct pci_dev *lkpi_pci_get_device(uint16_t, uint16_t, struct pci_dev *); static inline bool dev_is_pci(struct device *dev) @@ -1579,6 +1580,19 @@ err: return (-EINVAL); } +/* + * We cannot simply re-define pci_get_device() as we would normally do + * and then hide it in linux_pci.c as too many semi-native drivers still + * inlucde linux/pci.h and run into the conflict with native PCI. Linux drivers + * using pci_get_device() need to be changed to call linuxkpi_pci_get_device(). + */ +static inline struct pci_dev * +linuxkpi_pci_get_device(uint16_t vendor, uint16_t device, struct pci_dev *odev) +{ + + return (lkpi_pci_get_device(vendor, device, odev)); +} + /* This is a FreeBSD extension so we can use bus_*(). */ static inline void linuxkpi_pcim_want_to_use_bus_functions(struct pci_dev *pdev) diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index a9c859d29623..54780adfda14 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -273,6 +273,23 @@ linux_pci_find(device_t dev, const struct pci_device_id **idp) return (NULL); } +struct pci_dev * +lkpi_pci_get_device(uint16_t vendor, uint16_t device, struct pci_dev *odev) +{ + struct pci_dev *pdev; + + KASSERT(odev == NULL, ("%s: odev argument not yet supported\n", __func__)); + + spin_lock(&pci_lock); + list_for_each_entry(pdev, &pci_devices, links) { + if (pdev->vendor == vendor && pdev->device == device) + break; + } + spin_unlock(&pci_lock); + + return (pdev); +} + static void lkpi_pci_dev_release(struct device *dev) {