From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C12B93D9DCC for ; Wed, 2 Sep 2026 15:34:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788363251; cv=none; b=Q1pA7mopNtkk/ROyf7ij+sLO5EI7/8y1oMZa/sqfLN+T1NOKhG2cUjeOO8sx5apPkF6U3ds2P3wJQqShOmzBr6R/+pxHvPHUy1fuJjV3MHF+N6wLNXMzJtGxnVoJ8MZyVXScktF1cpLMjr52NQ/wpcQj0pB9NlMfV6pMQEJYM1E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788363251; c=relaxed/simple; bh=dr6vfVIIr15nkPY00xMblwWSrdPHorLrvBOMwa/YixI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a87hzPrkLXiUzHHeQ3Dt75FwYEdwIMIC8Yn/hC5Je9ArBu7AaJMPTxgldO6cJLTO8+MjVjDjyTp21lmOIdCL+NFC38WenRsUuQPGv/9SJVJppDiVh19Dl4hOBPL6x20hU4DcE6iN2OuLkHcVu+dnLydtDudEbv11mTvMlF1hq3Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=MR4Az9U3; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MR4Az9U3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1788363250; x=1819899250; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=dr6vfVIIr15nkPY00xMblwWSrdPHorLrvBOMwa/YixI=; b=MR4Az9U3MRhml0xA2EHxAiaw2W7rh/z60E+EggOOG/LuVVGVaKF5NEHo wsF68nCjVKThx55MV8xQR0BQunN47EEEDdKECPJ9/+E4tnM7G0RPVS+ic 8Pujm91mfFpSfgTAYhcYixFNM5wwO0CaE06xjweJ7He6LmMD0AF85kQqO mzIcDVd2z1vONGJ/RdGa0iUwYZDENHJfTd4Q/yKby2qedAdE7+Fsvmz67 /uR4lMsybMsDHnLHg0y/coGXIsDCLLT5tWbOMIL/J65Zrpj0FUygOQybA PDAOHlCyBs37kyh6VlywfXugkqanneAj7nOkCCiLy4AY/YsQxlXJ5edkY w==; X-CSE-ConnectionGUID: n5uq4MCpSVS37OdzEHP0dA== X-CSE-MsgGUID: hRkiXyCKQpKGg3i/3hZusw== X-IronPort-AV: E=McAfee;i="6800,10657,11894"; a="92646659" X-IronPort-AV: E=Sophos;i="6.25,258,1779174000"; d="scan'208";a="92646659" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2026 08:34:09 -0700 X-CSE-ConnectionGUID: eyplmz07SV6w7SusytCh1g== X-CSE-MsgGUID: oqtinJOMQTuWYMLpsrBSTg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,258,1779174000"; d="scan'208";a="271406742" Received: from ubuntu.igk.intel.com ([10.102.114.174]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2026 08:34:08 -0700 From: Szymon Durawa To: helgaas@kernel.org, nirmal.patel@linux.intel.com, szymon.durawa@linux.intel.com, djbw@kernel.org, linux-pci@vger.kernel.org, lukas@wunner.de Subject: [PATCH v7 1/8] PCI: vmd: Add vmd_bus_enumeration() helper function Date: Wed, 2 Sep 2026 17:58:37 +0000 Message-ID: <20260902175846.3497854-2-szymon.durawa@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260902175846.3497854-1-szymon.durawa@linux.intel.com> References: <20260902175846.3497854-1-szymon.durawa@linux.intel.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Move the vmd bus enumeration code to a new helper vmd_bus_enumeration(). No functional changes. Suggested-by: Nirmal Patel Signed-off-by: Szymon Durawa --- drivers/pci/controller/vmd.c | 89 ++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index f3b0e45232ef..c7d705fe2530 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -902,6 +902,54 @@ static int vmd_pm_enable_quirk(struct pci_dev *pdev, void *userdata) return 0; } +static void vmd_bus_enumeration(struct pci_bus *bus, unsigned long features) +{ + struct pci_bus *child; + struct pci_dev *dev; + int ret; + + vmd_acpi_begin(); + + pci_scan_child_bus(bus); + vmd_domain_reset(vmd_from_bus(bus)); + + /* + * When Intel VMD is enabled, the OS does not discover the Root Ports + * owned by Intel VMD within the MMCFG space. pci_reset_bus() applies + * a reset to the parent of the PCI device supplied as argument. This + * is why we pass a child device, so the reset can be triggered at + * the Intel bridge level and propagated to all the children in the + * hierarchy. + */ + list_for_each_entry(child, &bus->children, node) { + if (!list_empty(&child->devices)) { + dev = list_first_entry(&child->devices, struct pci_dev, + bus_list); + ret = pci_reset_bus(dev); + if (ret) + pci_warn(dev, "can't reset device: %d\n", ret); + + break; + } + } + + pci_assign_unassigned_bus_resources(bus); + + pci_walk_bus(bus, vmd_pm_enable_quirk, &features); + + /* + * VMD root buses are virtual and don't return true on pci_is_pcie() + * and will fail pcie_bus_configure_settings() early. It can instead be + * run on each of the real root ports. + */ + list_for_each_entry(child, &bus->children, node) + pcie_bus_configure_settings(child); + + pci_bus_add_devices(bus); + + vmd_acpi_end(); +} + static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) { struct pci_sysdata *sd = &vmd->sysdata; @@ -912,8 +960,6 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) resource_size_t offset[2] = {0}; resource_size_t membar2_offset = 0x2000; resource_size_t busn_end; - struct pci_bus *child; - struct pci_dev *dev; int ret; ret = vmd_prepare_offsets_and_bus(vmd, features, &membar2_offset, @@ -1038,45 +1084,8 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) WARN(sysfs_create_link(&vmd->dev->dev.kobj, &vmd->bus->dev.kobj, "domain"), "Can't create symlink to domain\n"); - vmd_acpi_begin(); - - pci_scan_child_bus(vmd->bus); - vmd_domain_reset(vmd); + vmd_bus_enumeration(vmd->bus, features); - /* When Intel VMD is enabled, the OS does not discover the Root Ports - * owned by Intel VMD within the MMCFG space. pci_reset_bus() applies - * a reset to the parent of the PCI device supplied as argument. This - * is why we pass a child device, so the reset can be triggered at - * the Intel bridge level and propagated to all the children in the - * hierarchy. - */ - list_for_each_entry(child, &vmd->bus->children, node) { - if (!list_empty(&child->devices)) { - dev = list_first_entry(&child->devices, - struct pci_dev, bus_list); - ret = pci_reset_bus(dev); - if (ret) - pci_warn(dev, "can't reset device: %d\n", ret); - - break; - } - } - - pci_assign_unassigned_bus_resources(vmd->bus); - - pci_walk_bus(vmd->bus, vmd_pm_enable_quirk, &features); - - /* - * VMD root buses are virtual and don't return true on pci_is_pcie() - * and will fail pcie_bus_configure_settings() early. It can instead be - * run on each of the real root ports. - */ - list_for_each_entry(child, &vmd->bus->children, node) - pcie_bus_configure_settings(child); - - pci_bus_add_devices(vmd->bus); - - vmd_acpi_end(); return 0; } -- 2.43.0