From nobody Sun Mar 27 20:14:00 2022 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 1E6ED1A53483; Sun, 27 Mar 2022 20:14:03 +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 4KRRqY1f3Wz4nvB; Sun, 27 Mar 2022 20:14:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648412043; 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=G4U0kU91TTQVKoq2rtWcHhunUL4jq/E0IBeQvrTbL3k=; b=LnbvN29zwjtuM/XVC2Dv2ea683Fst/p1izYrfJvTxi2lvN0yM2ibsN3VjSDHaEjOq+JYiL nwECnRoelr1X6U4ymr4iwdl2Ix9hlJAFp+9OuWuNFpVbH4biiYPt3XkC4/wPVMaM1OPOQk 9MKZEEM8r+WGOLiAXzzYDq+oTXCCp/8xFrPb13Fmg/wP4Pq7FiUQHEnQ8JLKBSxlNwYPjc 8H094yBizw4R23jMxLTJXLPuVBJauGP7lzHZLpdHkP5HT/wE95QuwjCyhUjHvQTJF0CC73 FUEvLvk2HesUaOst9pGh86B3dyWcNT8mH61nRoFvN52tJJtL8YN6JavcKUxfAQ== 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 1AEB41BFBC; Sun, 27 Mar 2022 20:14:00 +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 22RKE08A037117; Sun, 27 Mar 2022 20:14:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22RKE0gJ037116; Sun, 27 Mar 2022 20:14:00 GMT (envelope-from git) Date: Sun, 27 Mar 2022 20:14:00 GMT Message-Id: <202203272014.22RKE0gJ037116@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: a94b233d5d71 - stable/13 - LinuxKPI: pci.h MODULE_DEVICE_TABLE to MODULE_PNP_INFO 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/13 X-Git-Reftype: branch X-Git-Commit: a94b233d5d718258e2e57e114aab00714441a79f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648412043; 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=G4U0kU91TTQVKoq2rtWcHhunUL4jq/E0IBeQvrTbL3k=; b=j7GnngHg7ycq5UbEjeQ7vbTRZ92NovwSpu3NUGvKYPX2R+Kz2pQzeAs/mXxfu4fkVaXSh6 iMj9J1eJleDMBXnGR/S1zY+iOrHiBHOPNORldklGxB9s+Q985K8nV6HtDVqMqmRczBQ1Tq v+GA8PII68T5WYnjfsW2kvY2TNl0DbjHxjOKygY7EgFY31L69C06iW+MvS/v2Wk75I+aCM Vxuf5vVZkhW1TGr8zUWWygkn7LxIN82cdf/tHZu19p9+BzbB/WArekbBZbR0zpZYs8gid/ Runk9bU5xVuT+EQISYcpM+VpHM0Yy2rSn8uNHTRLQ8aqWBG3dvrTih0Lz6/+Lg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648412043; a=rsa-sha256; cv=none; b=eFfoGOsuHIy9vd5Dc6Yw2AXpV9gE/A6CmD2VNJlohL7QPLsKxM5NB4g4l6QU1hdgZczNus iVDeivX0ASj5FuCnudXDN8gpFZFJBot68/asWAAE/h6e32SAfJsxRTkDvmjrbnW1owOOvQ gvDUN2IyAOx0pAkWeMVgoBaorJe5PsaEZGcJfwRwxBCS591Qjn+CirOYYgWBjAJXVL7xdz NjrwwjbcCmiKGmYPBOVFVUZ1LlxHF7YhKlzlFVNcLoy1Tv8xkY7TBxTzWFATCyWBe+aPb/ AZFfU1znSTyaCIFI3jOMn4yVxYB+CvbtpW5ycUunEkWYbJUUx4j/LfsnI+drOQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=a94b233d5d718258e2e57e114aab00714441a79f commit a94b233d5d718258e2e57e114aab00714441a79f Author: Bjoern A. Zeeb AuthorDate: 2022-03-04 00:06:34 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-03-27 18:08:08 +0000 LinuxKPI: pci.h MODULE_DEVICE_TABLE to MODULE_PNP_INFO Implement MODULE_PNP_INFO() support in LinuxKPI for the Linux MODULE_DEVICE_TABLE. This will allow us to auto-load LinuxKPI PCI drivers (drm-kmod do not currently as they attach to vgapci0 which in turn grabs the PCI to my understanding) and make any loading from loader or kld_list in rc.conf unnecessary; see devmatch(8) for more information. We need to ensure there is a DRIVER_MODULE() (or probably just a DECLARE_MODULE but that makes not much difference) before the MODULE_PNP_INFO (which we otherwise would not need). Sponsored by: The FreeBSD Foundation Reviewed by: imp, hselasky, manu Differential Revision: https://reviews.freebsd.org/D26651 (cherry picked from commit 5493c6277a264e91ea4bdc7e2d4ee69fe4210918) --- sys/compat/linuxkpi/common/include/linux/pci.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index df18c98a6278..361600a55397 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -69,7 +70,26 @@ struct pci_device_id { uintptr_t driver_data; }; -#define MODULE_DEVICE_TABLE(bus, table) +/* Linux has an empty element at the end of the ID table -> nitems() - 1. */ +#define MODULE_DEVICE_TABLE(_bus, _table) \ + \ +static device_method_t _ ## _bus ## _ ## _table ## _methods[] = { \ + DEVMETHOD_END \ +}; \ + \ +static driver_t _ ## _bus ## _ ## _table ## _driver = { \ + "lkpi_" #_bus #_table, \ + _ ## _bus ## _ ## _table ## _methods, \ + 0 \ +}; \ + \ +static devclass_t _ ## _bus ## _ ## _table ## _devclass; \ + \ +DRIVER_MODULE(lkpi_ ## _table, pci, _ ## _bus ## _ ## _table ## _driver,\ + _ ## _bus ## _ ## _table ## _devclass, 0, 0); \ + \ +MODULE_PNP_INFO("U32:vendor;U32:device;V32:subvendor;V32:subdevice", \ + _bus, lkpi_ ## _table, _table, nitems(_table) - 1) #define PCI_ANY_ID -1U