From nobody Fri Sep 5 23:28:54 2025 X-Original-To: dev-commits-src-main@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 4cJXbp59Xnz66YlB; Fri, 05 Sep 2025 23:28:54 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cJXbp4RZCz40d0; Fri, 05 Sep 2025 23:28:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757114934; 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=ierpl8s0/NYGFCIU2ebi0HGnvgGo7LJtYNuJLdZwUl0=; b=p+n9hhmDsZu9dBRqUNPeuHtjG0YpQ4jSkdmjNNbdKlUKW6HbAz87FlgLuwrIdKqVYSUq4T +zV37dYw0FA0CSWg0S4RfaBQGqHD2CxW5jadHRFTCNyauJrdGF6mdZTH8Ik5M5ID/hY3Ex dmIQ7VyK5l41X3F+K9uwjAgyoZeAsAvezpO9f7i/nWuK2xW0KBdSLEigRO9/BmNrtij2cl 3pfV5C4X6IE//seziztUypwQoXJa72vQ13DnNVq02qGKU3xXmhlANumWEi4zmma0EVghcK OJ4hnts0bh20W426IjbAchWWRSmNCViiO1jzqQVcP/lgH7YwwenYATDuWKJ4NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757114934; 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=ierpl8s0/NYGFCIU2ebi0HGnvgGo7LJtYNuJLdZwUl0=; b=WlaCn+J6Gr0K66xzuE6r7NzWzOhkh72KATpb5VyaKIS6rbuBKVxgR1A8sT2KIMRLV2g65V P4PtTwE8Ojjr5KUKaAR9YAfDMSg/O6JiAIFl6jx4VpwM3cKaeFIGLbhqW9H11OOxOt9wKt fNk13jd/aaMvNw3uyeQoCVOwZfFB7YyeD+bxwYwLMO8hK1+HRJLunvN6g5mHyr77WR5HwN DYCyiuerz8dT+Os8lV28Dp6FiH9eMqxubxSLjskV9G/pM0+62WtghWGYNcM1wA/NR4PCgU 8RgERBBU6zvDo38lSSnRrfYPUAQ3QyjXuwqBP+Jj1fYnQUtqICGMv9VoWoRocw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757114934; a=rsa-sha256; cv=none; b=hy3CzG5YmdqPdmXR1x+4xpurTnnNr6x4VHDWQTT+4b0j6ldoIGjgf214ffl8ersG26QlH0 oU9AQfsCHdGAxtZT0ynxdcOemWULFew4O5O6/sMCv9wmoDn6y15iogma8QUSKrNmxFe7ZK HfRmZjCVPxS15YG3fJnnfT7no2XfEh4TaiGbxWlPB2wX9ecsg333IoQ2yX0msdafGjPTjk yy7jhBRpyUIhjv6y2Szo78PAvudJhRnAXpxFm14PaA6Y51EaDd/hlLCTshwx1HkZnJ0QYt ByfcvMKsQEm6exqDinwMyWSMkvaNWzht5z9QEm07VeYFmrHkrxU+OzvHAngcUg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cJXbp42rJz18Pv; Fri, 05 Sep 2025 23:28:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 585NSs9o029008; Fri, 5 Sep 2025 23:28:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 585NSs1h029005; Fri, 5 Sep 2025 23:28:54 GMT (envelope-from git) Date: Fri, 5 Sep 2025 23:28:54 GMT Message-Id: <202509052328.585NSs1h029005@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 910cf345d0ee - main - LinuxKPI: pci: implement for_each_pci_dev() and improve pci_get_device() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 910cf345d0ee9a5d72856a1ba35382eb4f0db951 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=910cf345d0ee9a5d72856a1ba35382eb4f0db951 commit 910cf345d0ee9a5d72856a1ba35382eb4f0db951 Author: Bjoern A. Zeeb AuthorDate: 2025-09-04 20:20:15 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-09-05 23:24:13 +0000 LinuxKPI: pci: implement for_each_pci_dev() and improve pci_get_device() Implement for_each_pci_dev() needed by a wireless driver update. For that also improve pci_get_device() and add the functionality to support the odev argument to start searching from that. Sponsored by: The FreeBSD Foundation (intially) MFC after: 3 days Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D52066 --- sys/compat/linuxkpi/common/include/linux/pci.h | 3 +++ sys/compat/linuxkpi/common/src/linux_pci.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 3fd4191b9917..df29af87f160 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -1445,6 +1445,9 @@ linuxkpi_pci_get_device(uint32_t vendor, uint32_t device, struct pci_dev *odev) return (lkpi_pci_get_device(vendor, device, odev)); } +#define for_each_pci_dev(_pdev) \ + while ((_pdev = linuxkpi_pci_get_device(PCI_ANY_ID, PCI_ANY_ID, _pdev)) != NULL) + /* 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 d5bbbea1eb2c..00d4a25e86ed 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -289,12 +289,18 @@ lkpi_pci_get_device(uint32_t vendor, uint32_t device, struct pci_dev *odev) { struct pci_dev *pdev, *found; - KASSERT(odev == NULL, ("%s: odev argument not yet supported\n", __func__)); - found = NULL; spin_lock(&pci_lock); list_for_each_entry(pdev, &pci_devices, links) { - if (pdev->vendor == vendor && pdev->device == device) { + /* Walk until we find odev. */ + if (odev != NULL) { + if (pdev == odev) + odev = NULL; + continue; + } + + if ((pdev->vendor == vendor || vendor == PCI_ANY_ID) && + (pdev->device == device || device == PCI_ANY_ID)) { found = pdev; break; }