From owner-dev-commits-src-all@freebsd.org Fri Jan 15 07:27:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BFE5B4DAF01; Fri, 15 Jan 2021 07:27:45 +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 4DHCSd4cWDz4XGk; Fri, 15 Jan 2021 07:27:45 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 7FF1E18C03; Fri, 15 Jan 2021 07:27:45 +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 10F7RjOs066812; Fri, 15 Jan 2021 07:27:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10F7Rj6t066811; Fri, 15 Jan 2021 07:27:45 GMT (envelope-from git) Date: Fri, 15 Jan 2021 07:27:45 GMT Message-Id: <202101150727.10F7Rj6t066811@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 0074d2118ac2 - stable/12 - linuxkpi: handle ARI MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 0074d2118ac24f23b43bc1923cc588dfebd73548 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jan 2021 07:27:45 -0000 The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0074d2118ac24f23b43bc1923cc588dfebd73548 commit 0074d2118ac24f23b43bc1923cc588dfebd73548 Author: Konstantin Belousov AuthorDate: 2021-01-04 21:41:12 +0000 Commit: Konstantin Belousov CommitDate: 2021-01-15 06:57:01 +0000 linuxkpi: handle ARI (cherry picked from commit de27805fee0bbe3b714615b1df4cf0b8ebbc39b9) --- sys/compat/linuxkpi/common/src/linux_pci.c | 21 +++++++++++++++------ sys/conf/kmod.mk | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index d3b64e07b980..e73b324c47fb 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include "pcib_if.h" + static device_probe_t linux_pci_probe; static device_attach_t linux_pci_attach; static device_detach_t linux_pci_detach; @@ -234,12 +236,16 @@ linux_pci_attach_device(device_t dev, struct pci_driver *pdrv, struct pci_bus *pbus; struct pci_devinfo *dinfo; device_t parent; + uintptr_t rid; int error; + bool isdrm; linux_set_current(curthread); - if (pdrv != NULL && pdrv->isdrm) { - parent = device_get_parent(dev); + parent = device_get_parent(dev); + isdrm = pdrv != NULL && pdrv->isdrm; + + if (isdrm) { dinfo = device_get_ivars(parent); device_set_ivars(dev, dinfo); } else { @@ -249,7 +255,11 @@ linux_pci_attach_device(device_t dev, struct pci_driver *pdrv, pdev->dev.parent = &linux_root_device; pdev->dev.bsddev = dev; INIT_LIST_HEAD(&pdev->dev.irqents); - pdev->devfn = PCI_DEVFN(pci_get_slot(dev), pci_get_function(dev)); + if (isdrm) + PCI_GET_ID(device_get_parent(parent), parent, PCI_ID_RID, &rid); + else + PCI_GET_ID(parent, dev, PCI_ID_RID, &rid); + pdev->devfn = rid; pdev->device = dinfo->cfg.device; pdev->vendor = dinfo->cfg.vendor; pdev->subsystem_vendor = dinfo->cfg.subvendor; @@ -474,9 +484,8 @@ pci_resource_start(struct pci_dev *pdev, int bar) if ((rle = linux_pci_get_bar(pdev, bar)) == NULL) return (0); - dev = pci_find_dbsf(pdev->bus->domain, pdev->bus->number, - PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); - MPASS(dev != NULL); + dev = pdev->pdrv != NULL && pdev->pdrv->isdrm ? + device_get_parent(pdev->dev.bsddev) : pdev->dev.bsddev; if (BUS_TRANSLATE_RESOURCE(dev, rle->type, rle->start, &newstart)) { device_printf(pdev->dev.bsddev, "translate of %#jx failed\n", (uintmax_t)rle->start); diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index fce55e529e29..610484ba7e36 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -113,6 +113,7 @@ LINUXKPI_GENSRCS+= \ device_if.h \ pci_if.h \ pci_iov_if.h \ + pcib_if.h \ vnode_if.h \ usb_if.h \ opt_usb.h \