From nobody Mon Jun 26 12:08:52 2023 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 4QqRTJ5TTKz4k6tD; Mon, 26 Jun 2023 12:08:52 +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 4QqRTJ4BkGz3jnX; Mon, 26 Jun 2023 12:08:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687781332; 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=Frss8uFL2JTLYyqqT6nKPxSYHrcmqTuKhqs1+S5ie1M=; b=jb6uLhfLq81pUJ69DJC0NrdNxgHskCu20tYOF+KSLb93F6mbrFREVG050Nb5wwtnI0OgL8 o4SxVqrUWo0/5A3hj+3HoO7eJNup/yamTk4ld3D5VMnMbtlg+FGQL37khlqyxQx9CHbTP6 zPh6XIQrw/HBfbgbYaML8eCfohczkg516Mcj1hrhPoAQalMBD4u+WabmhLwWY+M3fLeRnA GGUufNkaDr+rHKmMjkh9j9CG3gTvSHQ76IRTtWlwvU9z4nMtMcur9MgEimqrDX4D2vExZc bRexkqYvU70V0tejTj4Cg6eT/+tXL/UbeXulvqhT1WbfGhCzdBoV/V6iOaNFXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687781332; 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=Frss8uFL2JTLYyqqT6nKPxSYHrcmqTuKhqs1+S5ie1M=; b=P4jmcOa3VJiVSeRlp5hd1w6yue8gX37+EyFHZ8z96xLXW6LqCQ3AlyQoiDZUo0PRcOQYrU bH09Oz7XOASmeAP5v4/JfnvVK52pZFpVPfef4eSQ4kGcaiCyQFpC3V/vaDj+qLmhr4huwB tDQGhvbMQhDnq0dTX2wGMqn7z+m7Nt/WuhES1VNoR1HPXT7jpm6GLF/4hQN7Se32X1IzIA 3uQ3a4LG7LMzhjJEEfHJ4FjI2OjoxTfqywBfZsh6LBBTmfLhfsY1D/eHaG2/Ep21tPZ6Oc oxuXN72NLgaM5/WIK0nXbfkLm2IJrKWPFaNzKD/16sfzeIRXfootwXRuzkxLNg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687781332; a=rsa-sha256; cv=none; b=KB10tZLLx3cTPIQ+7GTJIbeVEvMsH1Tu3YQKm8ehYO3U2FcWHI76216GLMItIK6fLPX5QW B8lkTh6mxf/tq9aRqxtqiI0S6u6rYGsXvVDguCdaFmStKKXIru+TYyguhwJTxCGoRIEl0Q PLunlk5s7S6xqhpIHGj12wxhx1w02aSZHQk7XNyufF3hMGpJVSjn/NSH2EPw0ZoRUqDwUu PrUx6Ljq3LK4QRPPGxgSfQS7UyoPrpZshB4HcEKwykvPHCvjYf2U/lnxx/v35DBqSh3uX2 EEp8YxSAPWxhbxGuiVZxCzqJFCBDCxhHHF0EB4UqfS4nFPJaOQJIsos1LzqGfA== 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 4QqRTJ302bz18X1; Mon, 26 Jun 2023 12:08:52 +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 35QC8q4H083390; Mon, 26 Jun 2023 12:08:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35QC8qTp083389; Mon, 26 Jun 2023 12:08:52 GMT (envelope-from git) Date: Mon, 26 Jun 2023 12:08:52 GMT Message-Id: <202306261208.35QC8qTp083389@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: e7c58fc886ec - stable/13 - LinuxKPI: implement pci_rescan_bus() 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: e7c58fc886ec09fe16bb544a2a3b2e9fcfbc0008 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=e7c58fc886ec09fe16bb544a2a3b2e9fcfbc0008 commit e7c58fc886ec09fe16bb544a2a3b2e9fcfbc0008 Author: Bjoern A. Zeeb AuthorDate: 2023-05-16 20:59:30 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-06-26 09:19:42 +0000 LinuxKPI: implement pci_rescan_bus() Try to implement pci_rescan_bus(). pci_rescan_method() is already doing most of the job. We only have to do the count for the return value again ourselves. Sponsored by: The FreeBSD Foundation Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D40122 (cherry picked from commit 525dd4acaacc59b815131caccfdebc905d4d7bff) --- sys/compat/linuxkpi/common/include/linux/pci.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 55435f6b72bc..f3c495ff1a21 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -277,6 +277,7 @@ _Static_assert(sizeof(struct pci_driver) == __PCI_DRIVER_SIZE, struct pci_bus { struct pci_dev *self; + /* struct pci_bus *parent */ int domain; int number; }; @@ -1425,6 +1426,29 @@ pci_stop_and_remove_bus_device(struct pci_dev *pdev) { } +static inline int +pci_rescan_bus(struct pci_bus *pbus) +{ + device_t *devlist, parent; + int devcount, error; + + if (!device_is_attached(pbus->self->dev.bsddev)) + return (0); + /* pci_rescan_method() will work on the pcib (parent). */ + error = BUS_RESCAN(pbus->self->dev.bsddev); + if (error != 0) + return (0); + + parent = device_get_parent(pbus->self->dev.bsddev); + error = device_get_children(parent, &devlist, &devcount); + if (error != 0) + return (0); + if (devcount != 0) + free(devlist, M_TEMP); + + return (devcount); +} + /* * The following functions can be used to attach/detach the LinuxKPI's * PCI device runtime. The pci_driver and pci_device_id pointer is