All of lore.kernel.org
 help / color / mirror / Atom feed
* [BACKPORT v4.19] PCI: vmd: Fix config addressing when using bus offsets
@ 2019-10-15 23:06 Sushma Kalakota
  2019-10-16 18:29 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Sushma Kalakota @ 2019-10-15 23:06 UTC (permalink / raw)
  To: stable
  Cc: Jon Derrick, Keith Busch, Bjorn Helgaas, Lorenzo Pieralisi,
	Sushma Kalakota

From: Jon Derrick <jonathan.derrick@intel.com>

commit e3dffa4f6c3612dea337c9c59191bd418afc941b upstream

This is a backport due to feature dependencies preventing
the upstream patch from applying cleanly.

VMD maps child device config spaces to the VMD Config BAR linearly
regardless of the starting bus offset. Because of this, the config
address decode must ignore starting bus offsets when mapping the BDF to
the config space address.

Fixes: 2a5a9c9a20f9 ("PCI: vmd: Add offset to bus numbers if necessary")
Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Sushma Kalakota <sushmax.kalakota@intel.com>
---
 drivers/pci/controller/vmd.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index 52d4fa4161dc..65eaa6b61868 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -97,6 +97,7 @@ struct vmd_dev {
 	struct resource		resources[3];
 	struct irq_domain	*irq_domain;
 	struct pci_bus		*bus;
+	u8			busn_start;
 
 #ifdef CONFIG_X86_DEV_DMA_OPS
 	struct dma_map_ops	dma_ops;
@@ -468,7 +469,8 @@ static char __iomem *vmd_cfg_addr(struct vmd_dev *vmd, struct pci_bus *bus,
 				  unsigned int devfn, int reg, int len)
 {
 	char __iomem *addr = vmd->cfgbar +
-			     (bus->number << 20) + (devfn << 12) + reg;
+			     ((bus->number - vmd->busn_start) << 20) +
+			     (devfn << 12) + reg;
 
 	if ((addr - vmd->cfgbar) + len >=
 	    resource_size(&vmd->dev->resource[VMD_CFGBAR]))
@@ -591,7 +593,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
 	unsigned long flags;
 	LIST_HEAD(resources);
 	resource_size_t offset[2] = {0};
-	resource_size_t membar2_offset = 0x2000, busn_start = 0;
+	resource_size_t membar2_offset = 0x2000;
 
 	/*
 	 * Shadow registers may exist in certain VMD device ids which allow
@@ -633,14 +635,14 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
 		pci_read_config_dword(vmd->dev, PCI_REG_VMCONFIG, &vmconfig);
 		if (BUS_RESTRICT_CAP(vmcap) &&
 		    (BUS_RESTRICT_CFG(vmconfig) == 0x1))
-			busn_start = 128;
+			vmd->busn_start = 128;
 	}
 
 	res = &vmd->dev->resource[VMD_CFGBAR];
 	vmd->resources[0] = (struct resource) {
 		.name  = "VMD CFGBAR",
-		.start = busn_start,
-		.end   = busn_start + (resource_size(res) >> 20) - 1,
+		.start = vmd->busn_start,
+		.end   = vmd->busn_start + (resource_size(res) >> 20) - 1,
 		.flags = IORESOURCE_BUS | IORESOURCE_PCI_FIXED,
 	};
 
@@ -708,8 +710,8 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
 	pci_add_resource_offset(&resources, &vmd->resources[1], offset[0]);
 	pci_add_resource_offset(&resources, &vmd->resources[2], offset[1]);
 
-	vmd->bus = pci_create_root_bus(&vmd->dev->dev, busn_start, &vmd_ops,
-				       sd, &resources);
+	vmd->bus = pci_create_root_bus(&vmd->dev->dev, vmd->busn_start,
+					&vmd_ops, sd, &resources);
 	if (!vmd->bus) {
 		pci_free_resource_list(&resources);
 		irq_domain_remove(vmd->irq_domain);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [BACKPORT v4.19] PCI: vmd: Fix config addressing when using bus offsets
  2019-10-15 23:06 [BACKPORT v4.19] PCI: vmd: Fix config addressing when using bus offsets Sushma Kalakota
@ 2019-10-16 18:29 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2019-10-16 18:29 UTC (permalink / raw)
  To: Sushma Kalakota
  Cc: stable, Jon Derrick, Keith Busch, Bjorn Helgaas, Lorenzo Pieralisi

On Tue, Oct 15, 2019 at 05:06:07PM -0600, Sushma Kalakota wrote:
> From: Jon Derrick <jonathan.derrick@intel.com>
> 
> commit e3dffa4f6c3612dea337c9c59191bd418afc941b upstream
> 
> This is a backport due to feature dependencies preventing
> the upstream patch from applying cleanly.
> 
> VMD maps child device config spaces to the VMD Config BAR linearly
> regardless of the starting bus offset. Because of this, the config
> address decode must ignore starting bus offsets when mapping the BDF to
> the config space address.
> 
> Fixes: 2a5a9c9a20f9 ("PCI: vmd: Add offset to bus numbers if necessary")
> Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
> Signed-off-by: Sushma Kalakota <sushmax.kalakota@intel.com>
> ---
>  drivers/pci/controller/vmd.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)

Now queued up.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-16 18:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-15 23:06 [BACKPORT v4.19] PCI: vmd: Fix config addressing when using bus offsets Sushma Kalakota
2019-10-16 18:29 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.