From nobody Fri Jan 31 16:03:10 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 4Yl0zg40ZHz5mQbh; Fri, 31 Jan 2025 16:03:11 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Yl0zf6Zrjz3hGk; Fri, 31 Jan 2025 16:03:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738339390; 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=K0w5OtCkn6NFT1m9b+h+JRTDAwicgCvBeUdu5ln0rZk=; b=DEb6a0RulT97AWhwcrEcSQGsaIGtav4eHe3dgX47AeohUy07D00ck7DMUOybTLdhty5+ki ONla0544XrXmTmnVgEbGE4oYVSioMooMJ6i/1hfr8+g+k/HKndY3zgElwQzSk5F0fQsDmv MrhNhwfjxtuvVVahWZsity5p6yC5HH+pk33NuroZV9boYmPwCH6MgrmcjK6Ym5Y/ipjHS6 1ETwGJ+9GNusTNSl48FItCtUZ52bXeY8xGbTUP+pFMIjUnxXe/kAjMSWQNEjsgQ7o0Gb7C DowI9hmyqtHc4YIauWURKw0K3IabMcYlov09oBFdiDY6D5vhPNfFx11xct+YIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738339390; 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=K0w5OtCkn6NFT1m9b+h+JRTDAwicgCvBeUdu5ln0rZk=; b=d/Ffh07GCCMSacPV6ymvppLf6M9/vDDSLjtyGh+yxNEYul4LpTjRM1Hy9pNxIMOhlu0kIA qReWBlpiR/gwn9+K9qDs/zJdKGFQZT1LMCdagvpIDvxc4kSzZkwtAUUTXIJam2G4+nuU8Z RSU0zgJA8hvBnW+/Z/QlSCYZA5AOQj3YZRGDPWeYlNMuR7G6cMycXOdhRNKLryNvgJ7nAo PqRahZtQbr/f5d8Nny791DQDE+uXelusF4CHFJciOFa0l3I6utPF1IuL02FKGqzp9hizeH vM8ia9UdAhBUGVaoajeUqD2qoW0lC0ck6TRqk3DsyTWOiu1bRQzgbO1v4vxo2Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1738339390; a=rsa-sha256; cv=none; b=dooiBLV53Q5YbU0t0jsaZcR+cVzukgliB1BAB/yaEDs81ZBrsgXu5aKWFay+YqJugm9P1r +CP0TmvNdz+lV0LxtcnG+k5JuIPempvwjBXYMr9o53IoOAn2KxbXIHkV92k+7nrDW9tiAM l86OgZTgUjHKBj3KeKeJReQaqbbraI6C2di0uah5kqxoSgEpdvfi8v87hb1kLgP8AS2JuR K0iCJrtvW92trzQQ+KIs8gQGrXOEK2DRlka0CMtkY1QiMh4yE7/g6gHyRu9YByovAleqQ6 QXQvw6m/1hS5T4ksaPQarOT3mDzA7az4fM3sGcuAGyAZsIxFqJPdNuHFjxKRkA== 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 4Yl0zf678Kz978; Fri, 31 Jan 2025 16:03:10 +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 50VG3A9W038460; Fri, 31 Jan 2025 16:03:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50VG3AAH038457; Fri, 31 Jan 2025 16:03:10 GMT (envelope-from git) Date: Fri, 31 Jan 2025 16:03:10 GMT Message-Id: <202501311603.50VG3AAH038457@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien?= =?utf-8?Q?P=C3=A9dron?= Subject: git: c118e4da1296 - main - pci: Add `pci_find_base_class_from()` 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: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c118e4da12969b98f52b3b6f35857c32541d7fa5 Auto-Submitted: auto-generated The branch main has been updated by dumbbell: URL: https://cgit.FreeBSD.org/src/commit/?id=c118e4da12969b98f52b3b6f35857c32541d7fa5 commit c118e4da12969b98f52b3b6f35857c32541d7fa5 Author: Jean-Sébastien Pédron AuthorDate: 2024-12-22 16:23:34 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2025-01-31 16:00:47 +0000 pci: Add `pci_find_base_class_from()` [Why] linuxkpi needs to export `pci_get_base_class()` for DRM drivers from Linux 6.7. [How] This new function searches a PCI device with the given base class and returns it, regardless of its subclass. The behavior is the same as `pci_find_class_from()` but the subclass is ignored. Reviewed by: manu Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48745 --- sys/dev/pci/pci.c | 21 +++++++++++++++++++++ sys/dev/pci/pcivar.h | 1 + 2 files changed, 22 insertions(+) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 30a95298a114..edebb718ec53 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -523,6 +523,27 @@ pci_find_class_from(uint8_t class, uint8_t subclass, device_t from) return (NULL); } +device_t +pci_find_base_class_from(uint8_t class, device_t from) +{ + struct pci_devinfo *dinfo; + bool found = false; + + STAILQ_FOREACH(dinfo, &pci_devq, pci_links) { + if (from != NULL && found == false) { + if (from != dinfo->cfg.dev) + continue; + found = true; + continue; + } + if (dinfo->cfg.baseclass == class) { + return (dinfo->cfg.dev); + } + } + + return (NULL); +} + static int pci_printf(pcicfgregs *cfg, const char *fmt, ...) { diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index c2c1f055def9..1c7b772afea9 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -670,6 +670,7 @@ device_t pci_find_dbsf(uint32_t, uint8_t, uint8_t, uint8_t); device_t pci_find_device(uint16_t, uint16_t); device_t pci_find_class(uint8_t class, uint8_t subclass); device_t pci_find_class_from(uint8_t class, uint8_t subclass, device_t devfrom); +device_t pci_find_base_class_from(uint8_t class, device_t devfrom); /* Can be used by drivers to manage the MSI-X table. */ int pci_pending_msix(device_t dev, u_int index);