From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 8404B3E49C3 for ; Mon, 21 Sep 2026 14:18:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790000291; cv=none; b=qhiEtaMayIp0MBLTJ3l4/G263+0SsK2c/8Fc7ohubb53/r8quuIPnyVzUtQP32GzcnoOlJHbFAlpttJBnmtTbA0U8DUMpwdPVXv0/9ZMtlWY22C9LZURxA8CqsTM2zoBBG0SODxjpt/sLicDIbeOsqP+rS1uCkRiNrHFEr7GL2Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790000291; c=relaxed/simple; bh=y+Jolg8S/ulDL8ZDA8RerrFRQ4VpHHkqq5RHqZDewuM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cCC4e9PQ4j/tVNwV1x0uoizKBPDY+1tgQ8JAfKgNtE/2rkpu7QMbid9/kkW/5O+UeKB0lZLsHI/Z0AEjAcgqvCG1FgCAI3IWSTcYiRRtZxE7w3+jSSGi3Q/iIk6KoPtMfLMzELpIoks5427m33qdCOZIY11FdZZZSJHZC9ySO08= 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=FxwseNft; arc=none smtp.client-ip=192.198.163.11 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="FxwseNft" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790000289; x=1821536289; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=y+Jolg8S/ulDL8ZDA8RerrFRQ4VpHHkqq5RHqZDewuM=; b=FxwseNft1it9QXBuI+WrEuyzn/ao9mK0WgCkZrAU7Fl3UdJs7kwws1jI 2T17ID+9orB4pasYsHJ5gVl6WgXFrr2hZygljkTVCcKMV1KhiGvS1Kbvv 57+mXXF6Xv1sOLHBMIf03ScIy3t/sclI6NbahTvGxrr9ikJOdrelwDRaj 9h6Zonu5f6+Ipb7N09qAYlzzYnLxtbR12UjVfixAQBcuSbz4JUGtFUEIs VAUvLCU9MzTDNLwPyrHDGcJ4lfMfIt4nuMSvRy9KN5+JMg2yavp5MRpSe OJmIBtT4JLmMxFz1ZihPjTi8O/t2U7h7TXDEPuoTI5VB9ZtkDXvKSNQmr g==; X-CSE-ConnectionGUID: RrkVgcX9QvOOKKSP5fZHPA== X-CSE-MsgGUID: ogM+EM5AT+2m4vhQ3GKJ6Q== X-IronPort-AV: E=McAfee;i="6800,10657,11912"; a="101108343" X-IronPort-AV: E=Sophos;i="6.27,114,1787036400"; d="scan'208";a="101108343" Received: from fmviesa012.fm.intel.com ([10.60.135.152]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2026 07:18:08 -0700 X-CSE-ConnectionGUID: lLRk8SkbTRKMOWPtpL2fHQ== X-CSE-MsgGUID: 2yhXTPVPTCq/I8HgKnHrqg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,114,1787036400"; d="scan'208";a="3654364" Received: from ubuntu.igk.intel.com ([10.102.114.174]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2026 07:18: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 v8 1/8] PCI: vmd: Add vmd_bus_enumeration() helper function Date: Mon, 21 Sep 2026 16:43:07 +0000 Message-ID: <20260921164316.3860312-2-szymon.durawa@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260921164316.3860312-1-szymon.durawa@linux.intel.com> References: <20260921164316.3860312-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 241023ecf677..57d5e917dc45 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -905,6 +905,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; @@ -915,8 +963,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; bool vmd_in_guest; int ret; @@ -1047,45 +1093,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