All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] VT-d: replace another fixmap use with ioremap()
@ 2014-06-03 14:08 Jan Beulich
  2014-06-03 14:28 ` Andrew Cooper
  2014-06-03 15:50 ` Tian, Kevin
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Beulich @ 2014-06-03 14:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Yang Z Zhang, Kevin Tian

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

... making the code more generic and limiting address space consumption
(however small it might be) to just those machines that need this
mapping (this is an erratum workaround after all).

At the same time properly map the full needed range from the base
address instead of just the third page and fix some formatting.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/drivers/passthrough/vtd/quirks.c
+++ b/xen/drivers/passthrough/vtd/quirks.c
@@ -117,7 +117,7 @@ static void __init snb_errata_init(void)
  */
 static void __init map_igd_reg(void)
 {
-    u64 igd_mmio, igd_reg;
+    u64 igd_mmio;
 
     if ( !is_cantiga_b3 && !is_snb_gfx )
         return;
@@ -125,16 +125,10 @@ static void __init map_igd_reg(void)
     if ( igd_reg_va )
         return;
 
-    /* get IGD mmio address in PCI BAR */
-    igd_mmio = ((u64)pci_conf_read32(0, 0, IGD_DEV, 0, 0x14) << 32) +
-                     pci_conf_read32(0, 0, IGD_DEV, 0, 0x10);
-
-    /* offset of IGD regster we want to access is in 0x2000 range */
-    igd_reg = (igd_mmio & IGD_BAR_MASK) + 0x2000;
-
-    /* ioremap this physical page */
-    set_fixmap_nocache(FIX_IGD_MMIO, igd_reg);
-    igd_reg_va = (u8 *)fix_to_virt(FIX_IGD_MMIO);
+    igd_mmio   = pci_conf_read32(0, 0, IGD_DEV, 0, PCI_BASE_ADDRESS_1);
+    igd_mmio <<= 32;
+    igd_mmio  += pci_conf_read32(0, 0, IGD_DEV, 0, PCI_BASE_ADDRESS_0);
+    igd_reg_va = ioremap(igd_mmio & IGD_BAR_MASK, 0x3000);
 }
 
 /*
@@ -152,12 +146,10 @@ static int cantiga_vtd_ops_preamble(stru
         return 0;
 
     /*
-     * read IGD register at IGD MMIO + 0x20A4 to force IGD
-     * to exit low power state.  Since map_igd_reg()
-     * already mapped page starting 0x2000, we just need to
-     * add page offset 0x0A4 to virtual address base.
+     * Read IGD register at IGD MMIO + 0x20A4 to force IGD
+     * to exit low power state.
      */
-    return ( *((volatile int *)(igd_reg_va + 0x0A4)) );
+    return *(volatile int *)(igd_reg_va + 0x20A4);
 }
 
 /*
@@ -179,11 +171,11 @@ static void snb_vtd_ops_preamble(struct 
     if ( !igd_reg_va )
         return;
 
-    *((volatile u32 *)(igd_reg_va + 0x54)) = 0x000FFFFF;
-    *((volatile u32 *)(igd_reg_va + 0x700)) = 0;
+    *(volatile u32 *)(igd_reg_va + 0x2054) = 0x000FFFFF;
+    *(volatile u32 *)(igd_reg_va + 0x2700) = 0;
 
     start_time = NOW();
-    while ( (*((volatile u32 *)(igd_reg_va + 0x2AC)) & 0xF) != 0 )
+    while ( (*(volatile u32 *)(igd_reg_va + 0x22AC) & 0xF) != 0 )
     {
         if ( NOW() > start_time + DMAR_OPERATION_TIMEOUT )
         {
@@ -194,7 +186,7 @@ static void snb_vtd_ops_preamble(struct 
         cpu_relax();
     }
 
-    *((volatile u32*)(igd_reg_va + 0x50)) = 0x10001;
+    *(volatile u32 *)(igd_reg_va + 0x2050) = 0x10001;
 }
 
 static void snb_vtd_ops_postamble(struct iommu* iommu)
@@ -208,8 +200,8 @@ static void snb_vtd_ops_postamble(struct
     if ( !igd_reg_va )
         return;
 
-    *((volatile u32 *)(igd_reg_va + 0x54)) = 0xA;
-    *((volatile u32 *)(igd_reg_va + 0x50)) = 0x10000;
+    *(volatile u32 *)(igd_reg_va + 0x2054) = 0xA;
+    *(volatile u32 *)(igd_reg_va + 0x2050) = 0x10000;
 }
 
 /*
--- a/xen/include/asm-x86/fixmap.h
+++ b/xen/include/asm-x86/fixmap.h
@@ -62,7 +62,6 @@ enum fixed_addresses {
     FIX_TBOOT_MAP_ADDRESS,
     FIX_APEI_RANGE_BASE,
     FIX_APEI_RANGE_END = FIX_APEI_RANGE_BASE + FIX_APEI_RANGE_MAX -1,
-    FIX_IGD_MMIO,
     FIX_EFI_MPF,
     __end_of_fixed_addresses
 };




[-- Attachment #2: VT-d-ioremap-IGD-MMIO.patch --]
[-- Type: text/plain, Size: 3597 bytes --]

VT-d: replace another fixmap use with ioremap()

... making the code more generic and limiting address space consumption
(however small it might be) to just those machines that need this
mapping (this is an erratum workaround after all).

At the same time properly map the full needed range from the base
address instead of just the third page and fix some formatting.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/drivers/passthrough/vtd/quirks.c
+++ b/xen/drivers/passthrough/vtd/quirks.c
@@ -117,7 +117,7 @@ static void __init snb_errata_init(void)
  */
 static void __init map_igd_reg(void)
 {
-    u64 igd_mmio, igd_reg;
+    u64 igd_mmio;
 
     if ( !is_cantiga_b3 && !is_snb_gfx )
         return;
@@ -125,16 +125,10 @@ static void __init map_igd_reg(void)
     if ( igd_reg_va )
         return;
 
-    /* get IGD mmio address in PCI BAR */
-    igd_mmio = ((u64)pci_conf_read32(0, 0, IGD_DEV, 0, 0x14) << 32) +
-                     pci_conf_read32(0, 0, IGD_DEV, 0, 0x10);
-
-    /* offset of IGD regster we want to access is in 0x2000 range */
-    igd_reg = (igd_mmio & IGD_BAR_MASK) + 0x2000;
-
-    /* ioremap this physical page */
-    set_fixmap_nocache(FIX_IGD_MMIO, igd_reg);
-    igd_reg_va = (u8 *)fix_to_virt(FIX_IGD_MMIO);
+    igd_mmio   = pci_conf_read32(0, 0, IGD_DEV, 0, PCI_BASE_ADDRESS_1);
+    igd_mmio <<= 32;
+    igd_mmio  += pci_conf_read32(0, 0, IGD_DEV, 0, PCI_BASE_ADDRESS_0);
+    igd_reg_va = ioremap(igd_mmio & IGD_BAR_MASK, 0x3000);
 }
 
 /*
@@ -152,12 +146,10 @@ static int cantiga_vtd_ops_preamble(stru
         return 0;
 
     /*
-     * read IGD register at IGD MMIO + 0x20A4 to force IGD
-     * to exit low power state.  Since map_igd_reg()
-     * already mapped page starting 0x2000, we just need to
-     * add page offset 0x0A4 to virtual address base.
+     * Read IGD register at IGD MMIO + 0x20A4 to force IGD
+     * to exit low power state.
      */
-    return ( *((volatile int *)(igd_reg_va + 0x0A4)) );
+    return *(volatile int *)(igd_reg_va + 0x20A4);
 }
 
 /*
@@ -179,11 +171,11 @@ static void snb_vtd_ops_preamble(struct 
     if ( !igd_reg_va )
         return;
 
-    *((volatile u32 *)(igd_reg_va + 0x54)) = 0x000FFFFF;
-    *((volatile u32 *)(igd_reg_va + 0x700)) = 0;
+    *(volatile u32 *)(igd_reg_va + 0x2054) = 0x000FFFFF;
+    *(volatile u32 *)(igd_reg_va + 0x2700) = 0;
 
     start_time = NOW();
-    while ( (*((volatile u32 *)(igd_reg_va + 0x2AC)) & 0xF) != 0 )
+    while ( (*(volatile u32 *)(igd_reg_va + 0x22AC) & 0xF) != 0 )
     {
         if ( NOW() > start_time + DMAR_OPERATION_TIMEOUT )
         {
@@ -194,7 +186,7 @@ static void snb_vtd_ops_preamble(struct 
         cpu_relax();
     }
 
-    *((volatile u32*)(igd_reg_va + 0x50)) = 0x10001;
+    *(volatile u32 *)(igd_reg_va + 0x2050) = 0x10001;
 }
 
 static void snb_vtd_ops_postamble(struct iommu* iommu)
@@ -208,8 +200,8 @@ static void snb_vtd_ops_postamble(struct
     if ( !igd_reg_va )
         return;
 
-    *((volatile u32 *)(igd_reg_va + 0x54)) = 0xA;
-    *((volatile u32 *)(igd_reg_va + 0x50)) = 0x10000;
+    *(volatile u32 *)(igd_reg_va + 0x2054) = 0xA;
+    *(volatile u32 *)(igd_reg_va + 0x2050) = 0x10000;
 }
 
 /*
--- a/xen/include/asm-x86/fixmap.h
+++ b/xen/include/asm-x86/fixmap.h
@@ -62,7 +62,6 @@ enum fixed_addresses {
     FIX_TBOOT_MAP_ADDRESS,
     FIX_APEI_RANGE_BASE,
     FIX_APEI_RANGE_END = FIX_APEI_RANGE_BASE + FIX_APEI_RANGE_MAX -1,
-    FIX_IGD_MMIO,
     FIX_EFI_MPF,
     __end_of_fixed_addresses
 };

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PATCH] VT-d: replace another fixmap use with ioremap()
  2014-06-03 14:08 [PATCH] VT-d: replace another fixmap use with ioremap() Jan Beulich
@ 2014-06-03 14:28 ` Andrew Cooper
  2014-06-03 15:50 ` Tian, Kevin
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2014-06-03 14:28 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Yang Z Zhang, xen-devel, Kevin Tian


[-- Attachment #1.1: Type: text/plain, Size: 3885 bytes --]

On 03/06/14 15:08, Jan Beulich wrote:
> ... making the code more generic and limiting address space consumption
> (however small it might be) to just those machines that need this
> mapping (this is an erratum workaround after all).
>
> At the same time properly map the full needed range from the base
> address instead of just the third page and fix some formatting.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

>
> --- a/xen/drivers/passthrough/vtd/quirks.c
> +++ b/xen/drivers/passthrough/vtd/quirks.c
> @@ -117,7 +117,7 @@ static void __init snb_errata_init(void)
>   */
>  static void __init map_igd_reg(void)
>  {
> -    u64 igd_mmio, igd_reg;
> +    u64 igd_mmio;
>  
>      if ( !is_cantiga_b3 && !is_snb_gfx )
>          return;
> @@ -125,16 +125,10 @@ static void __init map_igd_reg(void)
>      if ( igd_reg_va )
>          return;
>  
> -    /* get IGD mmio address in PCI BAR */
> -    igd_mmio = ((u64)pci_conf_read32(0, 0, IGD_DEV, 0, 0x14) << 32) +
> -                     pci_conf_read32(0, 0, IGD_DEV, 0, 0x10);
> -
> -    /* offset of IGD regster we want to access is in 0x2000 range */
> -    igd_reg = (igd_mmio & IGD_BAR_MASK) + 0x2000;
> -
> -    /* ioremap this physical page */
> -    set_fixmap_nocache(FIX_IGD_MMIO, igd_reg);
> -    igd_reg_va = (u8 *)fix_to_virt(FIX_IGD_MMIO);
> +    igd_mmio   = pci_conf_read32(0, 0, IGD_DEV, 0, PCI_BASE_ADDRESS_1);
> +    igd_mmio <<= 32;
> +    igd_mmio  += pci_conf_read32(0, 0, IGD_DEV, 0, PCI_BASE_ADDRESS_0);
> +    igd_reg_va = ioremap(igd_mmio & IGD_BAR_MASK, 0x3000);
>  }
>  
>  /*
> @@ -152,12 +146,10 @@ static int cantiga_vtd_ops_preamble(stru
>          return 0;
>  
>      /*
> -     * read IGD register at IGD MMIO + 0x20A4 to force IGD
> -     * to exit low power state.  Since map_igd_reg()
> -     * already mapped page starting 0x2000, we just need to
> -     * add page offset 0x0A4 to virtual address base.
> +     * Read IGD register at IGD MMIO + 0x20A4 to force IGD
> +     * to exit low power state.
>       */
> -    return ( *((volatile int *)(igd_reg_va + 0x0A4)) );
> +    return *(volatile int *)(igd_reg_va + 0x20A4);
>  }
>  
>  /*
> @@ -179,11 +171,11 @@ static void snb_vtd_ops_preamble(struct 
>      if ( !igd_reg_va )
>          return;
>  
> -    *((volatile u32 *)(igd_reg_va + 0x54)) = 0x000FFFFF;
> -    *((volatile u32 *)(igd_reg_va + 0x700)) = 0;
> +    *(volatile u32 *)(igd_reg_va + 0x2054) = 0x000FFFFF;
> +    *(volatile u32 *)(igd_reg_va + 0x2700) = 0;
>  
>      start_time = NOW();
> -    while ( (*((volatile u32 *)(igd_reg_va + 0x2AC)) & 0xF) != 0 )
> +    while ( (*(volatile u32 *)(igd_reg_va + 0x22AC) & 0xF) != 0 )
>      {
>          if ( NOW() > start_time + DMAR_OPERATION_TIMEOUT )
>          {
> @@ -194,7 +186,7 @@ static void snb_vtd_ops_preamble(struct 
>          cpu_relax();
>      }
>  
> -    *((volatile u32*)(igd_reg_va + 0x50)) = 0x10001;
> +    *(volatile u32 *)(igd_reg_va + 0x2050) = 0x10001;
>  }
>  
>  static void snb_vtd_ops_postamble(struct iommu* iommu)
> @@ -208,8 +200,8 @@ static void snb_vtd_ops_postamble(struct
>      if ( !igd_reg_va )
>          return;
>  
> -    *((volatile u32 *)(igd_reg_va + 0x54)) = 0xA;
> -    *((volatile u32 *)(igd_reg_va + 0x50)) = 0x10000;
> +    *(volatile u32 *)(igd_reg_va + 0x2054) = 0xA;
> +    *(volatile u32 *)(igd_reg_va + 0x2050) = 0x10000;
>  }
>  
>  /*
> --- a/xen/include/asm-x86/fixmap.h
> +++ b/xen/include/asm-x86/fixmap.h
> @@ -62,7 +62,6 @@ enum fixed_addresses {
>      FIX_TBOOT_MAP_ADDRESS,
>      FIX_APEI_RANGE_BASE,
>      FIX_APEI_RANGE_END = FIX_APEI_RANGE_BASE + FIX_APEI_RANGE_MAX -1,
> -    FIX_IGD_MMIO,
>      FIX_EFI_MPF,
>      __end_of_fixed_addresses
>  };
>
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel


[-- Attachment #1.2: Type: text/html, Size: 4645 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PATCH] VT-d: replace another fixmap use with ioremap()
  2014-06-03 14:08 [PATCH] VT-d: replace another fixmap use with ioremap() Jan Beulich
  2014-06-03 14:28 ` Andrew Cooper
@ 2014-06-03 15:50 ` Tian, Kevin
  1 sibling, 0 replies; 3+ messages in thread
From: Tian, Kevin @ 2014-06-03 15:50 UTC (permalink / raw)
  To: Jan Beulich, xen-devel; +Cc: Zhang, Yang Z

> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: Tuesday, June 03, 2014 7:08 AM
> 
> ... making the code more generic and limiting address space consumption
> (however small it might be) to just those machines that need this
> mapping (this is an erratum workaround after all).
> 
> At the same time properly map the full needed range from the base
> address instead of just the third page and fix some formatting.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Kevin Tian <kevin.tian@intel.com>

> 
> --- a/xen/drivers/passthrough/vtd/quirks.c
> +++ b/xen/drivers/passthrough/vtd/quirks.c
> @@ -117,7 +117,7 @@ static void __init snb_errata_init(void)
>   */
>  static void __init map_igd_reg(void)
>  {
> -    u64 igd_mmio, igd_reg;
> +    u64 igd_mmio;
> 
>      if ( !is_cantiga_b3 && !is_snb_gfx )
>          return;
> @@ -125,16 +125,10 @@ static void __init map_igd_reg(void)
>      if ( igd_reg_va )
>          return;
> 
> -    /* get IGD mmio address in PCI BAR */
> -    igd_mmio = ((u64)pci_conf_read32(0, 0, IGD_DEV, 0, 0x14) << 32) +
> -                     pci_conf_read32(0, 0, IGD_DEV, 0, 0x10);
> -
> -    /* offset of IGD regster we want to access is in 0x2000 range */
> -    igd_reg = (igd_mmio & IGD_BAR_MASK) + 0x2000;
> -
> -    /* ioremap this physical page */
> -    set_fixmap_nocache(FIX_IGD_MMIO, igd_reg);
> -    igd_reg_va = (u8 *)fix_to_virt(FIX_IGD_MMIO);
> +    igd_mmio   = pci_conf_read32(0, 0, IGD_DEV, 0,
> PCI_BASE_ADDRESS_1);
> +    igd_mmio <<= 32;
> +    igd_mmio  += pci_conf_read32(0, 0, IGD_DEV, 0,
> PCI_BASE_ADDRESS_0);
> +    igd_reg_va = ioremap(igd_mmio & IGD_BAR_MASK, 0x3000);
>  }
> 
>  /*
> @@ -152,12 +146,10 @@ static int cantiga_vtd_ops_preamble(stru
>          return 0;
> 
>      /*
> -     * read IGD register at IGD MMIO + 0x20A4 to force IGD
> -     * to exit low power state.  Since map_igd_reg()
> -     * already mapped page starting 0x2000, we just need to
> -     * add page offset 0x0A4 to virtual address base.
> +     * Read IGD register at IGD MMIO + 0x20A4 to force IGD
> +     * to exit low power state.
>       */
> -    return ( *((volatile int *)(igd_reg_va + 0x0A4)) );
> +    return *(volatile int *)(igd_reg_va + 0x20A4);
>  }
> 
>  /*
> @@ -179,11 +171,11 @@ static void snb_vtd_ops_preamble(struct
>      if ( !igd_reg_va )
>          return;
> 
> -    *((volatile u32 *)(igd_reg_va + 0x54)) = 0x000FFFFF;
> -    *((volatile u32 *)(igd_reg_va + 0x700)) = 0;
> +    *(volatile u32 *)(igd_reg_va + 0x2054) = 0x000FFFFF;
> +    *(volatile u32 *)(igd_reg_va + 0x2700) = 0;
> 
>      start_time = NOW();
> -    while ( (*((volatile u32 *)(igd_reg_va + 0x2AC)) & 0xF) != 0 )
> +    while ( (*(volatile u32 *)(igd_reg_va + 0x22AC) & 0xF) != 0 )
>      {
>          if ( NOW() > start_time + DMAR_OPERATION_TIMEOUT )
>          {
> @@ -194,7 +186,7 @@ static void snb_vtd_ops_preamble(struct
>          cpu_relax();
>      }
> 
> -    *((volatile u32*)(igd_reg_va + 0x50)) = 0x10001;
> +    *(volatile u32 *)(igd_reg_va + 0x2050) = 0x10001;
>  }
> 
>  static void snb_vtd_ops_postamble(struct iommu* iommu)
> @@ -208,8 +200,8 @@ static void snb_vtd_ops_postamble(struct
>      if ( !igd_reg_va )
>          return;
> 
> -    *((volatile u32 *)(igd_reg_va + 0x54)) = 0xA;
> -    *((volatile u32 *)(igd_reg_va + 0x50)) = 0x10000;
> +    *(volatile u32 *)(igd_reg_va + 0x2054) = 0xA;
> +    *(volatile u32 *)(igd_reg_va + 0x2050) = 0x10000;
>  }
> 
>  /*
> --- a/xen/include/asm-x86/fixmap.h
> +++ b/xen/include/asm-x86/fixmap.h
> @@ -62,7 +62,6 @@ enum fixed_addresses {
>      FIX_TBOOT_MAP_ADDRESS,
>      FIX_APEI_RANGE_BASE,
>      FIX_APEI_RANGE_END = FIX_APEI_RANGE_BASE +
> FIX_APEI_RANGE_MAX -1,
> -    FIX_IGD_MMIO,
>      FIX_EFI_MPF,
>      __end_of_fixed_addresses
>  };
> 
> 

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

end of thread, other threads:[~2014-06-03 15:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-03 14:08 [PATCH] VT-d: replace another fixmap use with ioremap() Jan Beulich
2014-06-03 14:28 ` Andrew Cooper
2014-06-03 15:50 ` Tian, Kevin

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.