All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] VMD: Document code for maintainability
@ 2016-03-02 22:31 Keith Busch
  2016-03-02 22:31 ` [PATCH 2/2] VMD: Set bus resource start to 0 Keith Busch
  2016-03-10 20:54 ` [PATCH 1/2] VMD: Document code for maintainability Bjorn Helgaas
  0 siblings, 2 replies; 3+ messages in thread
From: Keith Busch @ 2016-03-02 22:31 UTC (permalink / raw
  To: linux-pci, Bjorn Helgaas; +Cc: Jon Derrick, Keith Busch

This comments the less obvious portion of the code for setting up
memory windows, and the platform dependency for initializing the h/w
with appropriate resources.

Signed-off-by: Keith Busch <keith.busch@intel.com>
---
 arch/x86/pci/vmd.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/arch/x86/pci/vmd.c b/arch/x86/pci/vmd.c
index d57e480..68faa5e 100644
--- a/arch/x86/pci/vmd.c
+++ b/arch/x86/pci/vmd.c
@@ -532,6 +532,23 @@ static int vmd_enable_domain(struct vmd_dev *vmd)
 		.flags = IORESOURCE_BUS | IORESOURCE_PCI_FIXED,
 	};
 
+	/*
+	 * If the window is below 4GB, clear IORESOURCE_MEM_64 so we can
+	 * put 32-bit resources in the window.
+	 *
+	 * There's no hardware reason why a 64-bit window *couldn't*
+	 * contain a 32-bit resource, but pbus_size_mem() computes the
+	 * bridge window size assuming a 64-bit window will contain no
+	 * 32-bit resources.  __pci_assign_resource() enforces that
+	 * artificial restriction to make sure everything will fit.
+	 *
+	 * The only way we could use a 64-bit non-prefechable MEMBAR is
+	 * if its address is <4GB so that we can convert it to a 32-bit
+	 * resource. To be visible to the host OS, all VMD endpoints must
+	 * be initially configured by platform BIOS, which includes setting
+	 * up these resources. We can assume the device is configured
+	 * according to the platform needs.
+	 */
 	res = &vmd->dev->resource[VMD_MEMBAR1];
 	upper_bits = upper_32_bits(res->end);
 	flags = res->flags & ~IORESOURCE_SIZEALIGN;
-- 
2.7.2


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

* [PATCH 2/2] VMD: Set bus resource start to 0
  2016-03-02 22:31 [PATCH 1/2] VMD: Document code for maintainability Keith Busch
@ 2016-03-02 22:31 ` Keith Busch
  2016-03-10 20:54 ` [PATCH 1/2] VMD: Document code for maintainability Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2016-03-02 22:31 UTC (permalink / raw
  To: linux-pci, Bjorn Helgaas; +Cc: Jon Derrick, Keith Busch

The bus always starts at 0. Due to alignment and down-casting, this
happened to work before, but looked alarmingly incorrect in kernel logs.

Signed-off-by: Keith Busch <keith.busch@intel.com>
---
 arch/x86/pci/vmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/pci/vmd.c b/arch/x86/pci/vmd.c
index 68faa5e..f60ecaa 100644
--- a/arch/x86/pci/vmd.c
+++ b/arch/x86/pci/vmd.c
@@ -527,7 +527,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd)
 	res = &vmd->dev->resource[VMD_CFGBAR];
 	vmd->resources[0] = (struct resource) {
 		.name  = "VMD CFGBAR",
-		.start = res->start,
+		.start = 0,
 		.end   = (resource_size(res) >> 20) - 1,
 		.flags = IORESOURCE_BUS | IORESOURCE_PCI_FIXED,
 	};
-- 
2.7.2


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

* Re: [PATCH 1/2] VMD: Document code for maintainability
  2016-03-02 22:31 [PATCH 1/2] VMD: Document code for maintainability Keith Busch
  2016-03-02 22:31 ` [PATCH 2/2] VMD: Set bus resource start to 0 Keith Busch
@ 2016-03-10 20:54 ` Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2016-03-10 20:54 UTC (permalink / raw
  To: Keith Busch; +Cc: linux-pci, Bjorn Helgaas, Jon Derrick

On Wed, Mar 02, 2016 at 03:31:03PM -0700, Keith Busch wrote:
> This comments the less obvious portion of the code for setting up
> memory windows, and the platform dependency for initializing the h/w
> with appropriate resources.
> 
> Signed-off-by: Keith Busch <keith.busch@intel.com>

I applied both patches to pci/host-vmd for v4.6, thanks, Keith!

> ---
>  arch/x86/pci/vmd.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/arch/x86/pci/vmd.c b/arch/x86/pci/vmd.c
> index d57e480..68faa5e 100644
> --- a/arch/x86/pci/vmd.c
> +++ b/arch/x86/pci/vmd.c
> @@ -532,6 +532,23 @@ static int vmd_enable_domain(struct vmd_dev *vmd)
>  		.flags = IORESOURCE_BUS | IORESOURCE_PCI_FIXED,
>  	};
>  
> +	/*
> +	 * If the window is below 4GB, clear IORESOURCE_MEM_64 so we can
> +	 * put 32-bit resources in the window.
> +	 *
> +	 * There's no hardware reason why a 64-bit window *couldn't*
> +	 * contain a 32-bit resource, but pbus_size_mem() computes the
> +	 * bridge window size assuming a 64-bit window will contain no
> +	 * 32-bit resources.  __pci_assign_resource() enforces that
> +	 * artificial restriction to make sure everything will fit.
> +	 *
> +	 * The only way we could use a 64-bit non-prefechable MEMBAR is
> +	 * if its address is <4GB so that we can convert it to a 32-bit
> +	 * resource. To be visible to the host OS, all VMD endpoints must
> +	 * be initially configured by platform BIOS, which includes setting
> +	 * up these resources. We can assume the device is configured
> +	 * according to the platform needs.
> +	 */
>  	res = &vmd->dev->resource[VMD_MEMBAR1];
>  	upper_bits = upper_32_bits(res->end);
>  	flags = res->flags & ~IORESOURCE_SIZEALIGN;
> -- 
> 2.7.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2016-03-10 20:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-02 22:31 [PATCH 1/2] VMD: Document code for maintainability Keith Busch
2016-03-02 22:31 ` [PATCH 2/2] VMD: Set bus resource start to 0 Keith Busch
2016-03-10 20:54 ` [PATCH 1/2] VMD: Document code for maintainability Bjorn Helgaas

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.