linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] VMD: Configuring bus settings
@ 2018-12-13 16:23 Jon Derrick
  2018-12-13 16:23 ` [PATCH] PCI/VMD: Configure MPS settings before adding devices Jon Derrick
  0 siblings, 1 reply; 6+ messages in thread
From: Jon Derrick @ 2018-12-13 16:23 UTC (permalink / raw)
  To: linux-pci; +Cc: Bjorn Helgaas, Lorenzo Pieralisi, Keith Busch, Jon Derrick

Hi Bjorn, Lorenzo, Keith,

This patch supercedes the previous MPS on rescan patch:
https://patchwork.kernel.org/patch/10671355/

The previous patch shouldn't have negatively effected already-added devices,
but it became clear that some devices required special MPS handling provided by
quirks, and thus wasn't safe to perform generically.

This patch instead open-codes pci_rescan_bus() in VMD and performs bus settings
prior to driver attach

Jon Derrick (1):
  PCI/VMD: Configure MPS settings before adding devices

 drivers/pci/controller/vmd.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

-- 
1.8.3.1


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

* [PATCH] PCI/VMD: Configure MPS settings before adding devices
  2018-12-13 16:23 [PATCH] VMD: Configuring bus settings Jon Derrick
@ 2018-12-13 16:23 ` Jon Derrick
  2018-12-14 14:44   ` Keith Busch
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jon Derrick @ 2018-12-13 16:23 UTC (permalink / raw)
  To: linux-pci; +Cc: Bjorn Helgaas, Lorenzo Pieralisi, Keith Busch, Jon Derrick

In order to provide the most performance and/or compatible settings,
ensure VMD root buses observe the pcie bus tuning settings by
configuring those settings prior to adding the devices to the pcie tree.

This patch open-codes pci_rescan_bus() and configures the buses prior to
adding devices and attaching drivers.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
---
 drivers/pci/controller/vmd.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index e50b0b5..818dda8 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -585,6 +585,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
 	LIST_HEAD(resources);
 	resource_size_t offset[2] = {0};
 	resource_size_t membar2_offset = 0x2000, busn_start = 0;
+	struct pci_bus *child;
 
 	/*
 	 * Shadow registers may exist in certain VMD device ids which allow
@@ -712,7 +713,19 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
 	vmd_attach_resources(vmd);
 	vmd_setup_dma_ops(vmd);
 	dev_set_msi_domain(&vmd->bus->dev, vmd->irq_domain);
-	pci_rescan_bus(vmd->bus);
+
+	pci_scan_child_bus(vmd->bus);
+	pci_assign_unassigned_bus_resources(vmd->bus);
+
+	/*
+	 * 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);
 
 	WARN(sysfs_create_link(&vmd->dev->dev.kobj, &vmd->bus->dev.kobj,
 			       "domain"), "Can't create symlink to domain\n");
-- 
1.8.3.1


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

* Re: [PATCH] PCI/VMD: Configure MPS settings before adding devices
  2018-12-13 16:23 ` [PATCH] PCI/VMD: Configure MPS settings before adding devices Jon Derrick
@ 2018-12-14 14:44   ` Keith Busch
  2019-01-14 17:56     ` Derrick, Jonathan
  2019-01-29 23:14   ` Bjorn Helgaas
  2019-01-30 11:15   ` Lorenzo Pieralisi
  2 siblings, 1 reply; 6+ messages in thread
From: Keith Busch @ 2018-12-14 14:44 UTC (permalink / raw)
  To: Jon Derrick; +Cc: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi

On Thu, Dec 13, 2018 at 09:23:42AM -0700, Jon Derrick wrote:
> In order to provide the most performance and/or compatible settings,
> ensure VMD root buses observe the pcie bus tuning settings by
> configuring those settings prior to adding the devices to the pcie tree.
> 
> This patch open-codes pci_rescan_bus() and configures the buses prior to
> adding devices and attaching drivers.
> 
> Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>

Makes sense.

Reviewed-by: Keith Busch <keith.busch@intel.com>

> ---
>  drivers/pci/controller/vmd.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
> index e50b0b5..818dda8 100644
> --- a/drivers/pci/controller/vmd.c
> +++ b/drivers/pci/controller/vmd.c
> @@ -585,6 +585,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
>  	LIST_HEAD(resources);
>  	resource_size_t offset[2] = {0};
>  	resource_size_t membar2_offset = 0x2000, busn_start = 0;
> +	struct pci_bus *child;
>  
>  	/*
>  	 * Shadow registers may exist in certain VMD device ids which allow
> @@ -712,7 +713,19 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
>  	vmd_attach_resources(vmd);
>  	vmd_setup_dma_ops(vmd);
>  	dev_set_msi_domain(&vmd->bus->dev, vmd->irq_domain);
> -	pci_rescan_bus(vmd->bus);
> +
> +	pci_scan_child_bus(vmd->bus);
> +	pci_assign_unassigned_bus_resources(vmd->bus);
> +
> +	/*
> +	 * 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);
>  
>  	WARN(sysfs_create_link(&vmd->dev->dev.kobj, &vmd->bus->dev.kobj,
>  			       "domain"), "Can't create symlink to domain\n");
> -- 
> 1.8.3.1
> 

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

* Re: [PATCH] PCI/VMD: Configure MPS settings before adding devices
  2018-12-14 14:44   ` Keith Busch
@ 2019-01-14 17:56     ` Derrick, Jonathan
  0 siblings, 0 replies; 6+ messages in thread
From: Derrick, Jonathan @ 2019-01-14 17:56 UTC (permalink / raw)
  To: Busch, Keith; +Cc: linux-pci, lorenzo.pieralisi, helgaas

[-- Attachment #1: Type: text/plain, Size: 2253 bytes --]

Ping?

On Fri, 2018-12-14 at 07:44 -0700, Keith Busch wrote:
> On Thu, Dec 13, 2018 at 09:23:42AM -0700, Jon Derrick wrote:
> > In order to provide the most performance and/or compatible
> > settings,
> > ensure VMD root buses observe the pcie bus tuning settings by
> > configuring those settings prior to adding the devices to the pcie
> > tree.
> > 
> > This patch open-codes pci_rescan_bus() and configures the buses
> > prior to
> > adding devices and attaching drivers.
> > 
> > Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
> 
> Makes sense.
> 
> Reviewed-by: Keith Busch <keith.busch@intel.com>
> 
> > ---
> >  drivers/pci/controller/vmd.c | 15 ++++++++++++++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/pci/controller/vmd.c
> > b/drivers/pci/controller/vmd.c
> > index e50b0b5..818dda8 100644
> > --- a/drivers/pci/controller/vmd.c
> > +++ b/drivers/pci/controller/vmd.c
> > @@ -585,6 +585,7 @@ static int vmd_enable_domain(struct vmd_dev
> > *vmd, unsigned long features)
> >  	LIST_HEAD(resources);
> >  	resource_size_t offset[2] = {0};
> >  	resource_size_t membar2_offset = 0x2000, busn_start = 0;
> > +	struct pci_bus *child;
> >  
> >  	/*
> >  	 * Shadow registers may exist in certain VMD device ids
> > which allow
> > @@ -712,7 +713,19 @@ static int vmd_enable_domain(struct vmd_dev
> > *vmd, unsigned long features)
> >  	vmd_attach_resources(vmd);
> >  	vmd_setup_dma_ops(vmd);
> >  	dev_set_msi_domain(&vmd->bus->dev, vmd->irq_domain);
> > -	pci_rescan_bus(vmd->bus);
> > +
> > +	pci_scan_child_bus(vmd->bus);
> > +	pci_assign_unassigned_bus_resources(vmd->bus);
> > +
> > +	/*
> > +	 * 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);
> >  
> >  	WARN(sysfs_create_link(&vmd->dev->dev.kobj, &vmd->bus-
> > >dev.kobj,
> >  			       "domain"), "Can't create symlink to
> > domain\n");
> > -- 
> > 1.8.3.1
> > 

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3278 bytes --]

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

* Re: [PATCH] PCI/VMD: Configure MPS settings before adding devices
  2018-12-13 16:23 ` [PATCH] PCI/VMD: Configure MPS settings before adding devices Jon Derrick
  2018-12-14 14:44   ` Keith Busch
@ 2019-01-29 23:14   ` Bjorn Helgaas
  2019-01-30 11:15   ` Lorenzo Pieralisi
  2 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2019-01-29 23:14 UTC (permalink / raw)
  To: Jon Derrick; +Cc: linux-pci, Lorenzo Pieralisi, Keith Busch

On Thu, Dec 13, 2018 at 09:23:42AM -0700, Jon Derrick wrote:
> In order to provide the most performance and/or compatible settings,
> ensure VMD root buses observe the pcie bus tuning settings by
> configuring those settings prior to adding the devices to the pcie tree.
> 
> This patch open-codes pci_rescan_bus() and configures the buses prior to
> adding devices and attaching drivers.
> 
> Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>

Sorry, Lorenzo takes care of drivers/pci/controller/*, but I had
mistakenly delegated this to myself, so it probably wasn't on his
radar.

My dream is that someday pcie_bus_configure_settings() will somehow be
done as part of enumeration and host bridge drivers won't need to care
about it, but that's obviously fanciful, so this looks fine to me.

> ---
>  drivers/pci/controller/vmd.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
> index e50b0b5..818dda8 100644
> --- a/drivers/pci/controller/vmd.c
> +++ b/drivers/pci/controller/vmd.c
> @@ -585,6 +585,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
>  	LIST_HEAD(resources);
>  	resource_size_t offset[2] = {0};
>  	resource_size_t membar2_offset = 0x2000, busn_start = 0;
> +	struct pci_bus *child;
>  
>  	/*
>  	 * Shadow registers may exist in certain VMD device ids which allow
> @@ -712,7 +713,19 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
>  	vmd_attach_resources(vmd);
>  	vmd_setup_dma_ops(vmd);
>  	dev_set_msi_domain(&vmd->bus->dev, vmd->irq_domain);
> -	pci_rescan_bus(vmd->bus);
> +
> +	pci_scan_child_bus(vmd->bus);
> +	pci_assign_unassigned_bus_resources(vmd->bus);
> +
> +	/*
> +	 * 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);
>  
>  	WARN(sysfs_create_link(&vmd->dev->dev.kobj, &vmd->bus->dev.kobj,
>  			       "domain"), "Can't create symlink to domain\n");
> -- 
> 1.8.3.1
> 

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

* Re: [PATCH] PCI/VMD: Configure MPS settings before adding devices
  2018-12-13 16:23 ` [PATCH] PCI/VMD: Configure MPS settings before adding devices Jon Derrick
  2018-12-14 14:44   ` Keith Busch
  2019-01-29 23:14   ` Bjorn Helgaas
@ 2019-01-30 11:15   ` Lorenzo Pieralisi
  2 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Pieralisi @ 2019-01-30 11:15 UTC (permalink / raw)
  To: Jon Derrick; +Cc: linux-pci, Bjorn Helgaas, Keith Busch

On Thu, Dec 13, 2018 at 09:23:42AM -0700, Jon Derrick wrote:
> In order to provide the most performance and/or compatible settings,
> ensure VMD root buses observe the pcie bus tuning settings by
> configuring those settings prior to adding the devices to the pcie tree.
> 
> This patch open-codes pci_rescan_bus() and configures the buses prior to
> adding devices and attaching drivers.
> 
> Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
> ---
>  drivers/pci/controller/vmd.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)

Applied to pci/vmd for v5.1, thanks and apologies for the delay.

Lorenzo

> diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
> index e50b0b5..818dda8 100644
> --- a/drivers/pci/controller/vmd.c
> +++ b/drivers/pci/controller/vmd.c
> @@ -585,6 +585,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
>  	LIST_HEAD(resources);
>  	resource_size_t offset[2] = {0};
>  	resource_size_t membar2_offset = 0x2000, busn_start = 0;
> +	struct pci_bus *child;
>  
>  	/*
>  	 * Shadow registers may exist in certain VMD device ids which allow
> @@ -712,7 +713,19 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
>  	vmd_attach_resources(vmd);
>  	vmd_setup_dma_ops(vmd);
>  	dev_set_msi_domain(&vmd->bus->dev, vmd->irq_domain);
> -	pci_rescan_bus(vmd->bus);
> +
> +	pci_scan_child_bus(vmd->bus);
> +	pci_assign_unassigned_bus_resources(vmd->bus);
> +
> +	/*
> +	 * 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);
>  
>  	WARN(sysfs_create_link(&vmd->dev->dev.kobj, &vmd->bus->dev.kobj,
>  			       "domain"), "Can't create symlink to domain\n");
> -- 
> 1.8.3.1
> 

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

end of thread, other threads:[~2019-01-30 11:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-13 16:23 [PATCH] VMD: Configuring bus settings Jon Derrick
2018-12-13 16:23 ` [PATCH] PCI/VMD: Configure MPS settings before adding devices Jon Derrick
2018-12-14 14:44   ` Keith Busch
2019-01-14 17:56     ` Derrick, Jonathan
2019-01-29 23:14   ` Bjorn Helgaas
2019-01-30 11:15   ` Lorenzo Pieralisi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).