From nobody Mon Sep 15 19:11:05 2025 X-Original-To: dev-commits-src-all@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 4cQZPj5V3yz67sYn; Mon, 15 Sep 2025 19:11:05 +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 4cQZPj4v2jz4FDk; Mon, 15 Sep 2025 19:11:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757963465; 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=byRJElEum4P/zcHOdwdkDgY2atPVe4RXpqg+J8RB9G8=; b=B2i6oKIe2JKx+pWx3Nhl7/Rz1dELv2Kfi/2qVUoSkoeCwLJqBMqyIrb+B2RmqBSPma98IR 8XqRMJGwVfVn6oq2H+H7pv5nYM+myd4TJsTWcuLASD2tCrZ/vlVFG3Gh5xrRX+GEcEPNdl SNWZYF6i78hXVm789T1KytCLzBZFSILwxQIEKwfXvgRugAAaMLBUCWrAWbSzU9C7mZ8Te6 lZcvQiPH7dLTgH277DSH46uUYe5VDdsrrM3PYhQLL+Yeb8oAJu1i3Dq2lB4/WThfNWg/o8 wowR5Y/TlAAdaJF1UnTYLEZxQuUjU0GfIo1k0w23iScvyIjQLXnn3PxokbWD3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757963465; 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=byRJElEum4P/zcHOdwdkDgY2atPVe4RXpqg+J8RB9G8=; b=g4C3tnz6Q95WAZjWuhJLNoqn8vUjlmnPvoNLhQ3C6oDlsTtlMu/DDss+gX6y2e1q6Q628X e92WISIF3IrHunzEJ85ftsuV7RqaGfJmsMc20FAuB85XXBcMijYXvd/vhdqLhjib+SfYOf 3dvXEC6qOvWaeIhLjSb+7a8BmfrEb5IQxOxEjmpoyWe56VRB1ujfHfuLt/9EjFiEN9IZjF c2pt9gzU/96lWctwwRYcrSCCsKEreZCiuEFFZ/hAoQWEpnWEykqeY4s1ZN/MF/zYYnMKsy tfEDSo7trZfWoKV+f/K5jhPGvVapFTC/F8Ld32Fln+RPaPg6f86vLt1CSAkDjw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757963465; a=rsa-sha256; cv=none; b=JYRIPa6ThHFLvsnjQNez0HfVdmo+Vu4NC9BTYYtUb2knoOe0Oun8RaTOe8K9CCdZGnUkzB 2JX9yZRAVhIfa8pZEdx05c4LLHs5UdgrQSj+gU1vOmZFynMdSYP69cMbumqshjuPyxCVTS rCVtBnbYscrCSL1GKUWuQtDFGWjoe2TA1GaHi7CW6PVfusYpnQjlTkzDLtKlYNEGNrSKdo cOEmAK3NgFZxIPZYPu3win8nRHNVS6FTKGeZ7/7RxXq97EnHEjJWMTCqwkTQUQ9ixz+txz 875g+2OWMMV5pJaAvYCTdAfsI+sl4KKK1NSSyeGSnqAvZN7j1bHyHncuYE8BJg== 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 4cQZPj4VPhz16s6; Mon, 15 Sep 2025 19:11:05 +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 58FJB5MS049590; Mon, 15 Sep 2025 19:11:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58FJB5xj049587; Mon, 15 Sep 2025 19:11:05 GMT (envelope-from git) Date: Mon, 15 Sep 2025 19:11:05 GMT Message-Id: <202509151911.58FJB5xj049587@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: 68f8fa4ada24 - stable/15 - LinuxKPI: pci: implement for_each_pci_dev() and improve pci_get_device() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/15 X-Git-Reftype: branch X-Git-Commit: 68f8fa4ada24aaf53a2d463b53259439dfb32146 Auto-Submitted: auto-generated The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=68f8fa4ada24aaf53a2d463b53259439dfb32146 commit 68f8fa4ada24aaf53a2d463b53259439dfb32146 Author: Bjoern A. Zeeb AuthorDate: 2025-09-04 20:20:15 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-09-15 14:50:49 +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) Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D52066 (cherry picked from commit 910cf345d0ee9a5d72856a1ba35382eb4f0db951) --- 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; }