From nobody Fri Jan 13 00:41:51 2023 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 4NtN0H5Svyz2sgVf; Fri, 13 Jan 2023 00:41:51 +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 4NtN0H52C3z3Qs8; Fri, 13 Jan 2023 00:41:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673570511; 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=N1UZl0gYfuTSa2f0zEyZqodLIzqUkLridO5FUq6RzsM=; b=pgtffQ/dP3AoOHM/mVnVPNzP8YaKh13bQafbEUi5HYwhcfLmxhPQWXP9d6Yb2VkwHQnFS+ i//EPsChw/5v89CaMepui8AYzwuGFnORPIuVYS36OljWcKAaPxlzYq6DWT0EvTEeFeXYob 5MHm5V6FNNTvKiMpfAQ4n0spugaztAPwKrQsqKtJf0Kq7HeYzQCKshn/g00d1gaYwHQjyT mnSkfZT1qRR2IR61Wk/AfuVirssBXBo2esS+F3AjaZzVLmocDIDS6+kYy4Vfj6f8SMFGuW Plnvl3czL6tK0SzJToXCoVUEhaXfdgsML7DK4rCRUxSdLf0C6pOWnpuMJFrhHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673570511; 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=N1UZl0gYfuTSa2f0zEyZqodLIzqUkLridO5FUq6RzsM=; b=OGNfhjQSV8+F4hI5deOvhpR1OgMQwlPUi5dOKjuza0mFONOETaOoP3A36FrlGR7WeROvsZ mgo/HagB2LJPQx7+XvXuTwJLPw2RRKWkhMdiUallHtDZx7QCUCrB1Un9yzByZXmX1pdB3m al/W2qlARkB/3MyI5DDn+JW5Mw4E8ziQx12lCycbunciEMLAdKMqHTWJdSVmZlh7DoCK0T UzBYQKb/vCqQF1yOjpCkbDRzMI9GzJaj5OmzXq9fH5ly1tl23lgfTEobLIUf7dr3kvN8D3 ryMV/FObesrh/TReX3aDb+V/TVV+fwEX67c9PgMv6QMFZk9oD+e4ecSo8rqR/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673570511; a=rsa-sha256; cv=none; b=UcJqDTXAVsYIb6Z0CFFx7dRNw8XPMUHpQlSs8P4PTU9i9lZ99HK7VcIv50O0V5w3WbE7XE 9Pa6hGbicT689dLweMqsyqvbdsf/SuL5Trxiw9r0a7454WKEpWhk/yNDF9HCGAa/elXsHT aKOch4O53sR8aXAHTjqWouiRM/1fSaqNTQHKPB4CmAS4ZBI8w0RoQUeHYcJhzN/mBOEdj3 bYOvPpDhpHFFN4Z2EslYIfJcbJHYyMtLHOFcUHj7ERlEkntMTttlTsalN2z2T1sGN6ls4X pNtvR0qjbUvtC4NU/W5oa6qeqnXD+LFCxAlgoSCMoQ9NM/hBkoISulPwvIlLFQ== 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 4NtN0H44whznnJ; Fri, 13 Jan 2023 00:41:51 +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 30D0fpXq063712; Fri, 13 Jan 2023 00:41:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30D0fpOf063711; Fri, 13 Jan 2023 00:41:51 GMT (envelope-from git) Date: Fri, 13 Jan 2023 00:41:51 GMT Message-Id: <202301130041.30D0fpOf063711@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: 8f61992d7cc1 - main - LinuxKPI: pci: add [linuxkpi_]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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: 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: 8f61992d7cc1108cebc1337451a15a0af420984c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=8f61992d7cc1108cebc1337451a15a0af420984c commit 8f61992d7cc1108cebc1337451a15a0af420984c Author: Bjoern A. Zeeb AuthorDate: 2022-12-02 22:14:09 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-01-13 00:40:57 +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. MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D37593 --- 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 4b9f02497a59..cc9cb7da0b2a 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -344,6 +344,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) @@ -1584,6 +1585,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 9e79ec80b74f..57e431a7abcd 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -271,6 +271,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) {