From: "Jan Beulich" Subject: [PATCH] VT-d: replace another fixmap use with ioremap() Date: Tue, 03 Jun 2014 15:08:04 +0100 Message-ID: <538DF2E402000078000176D4@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB48667D4.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WrpNq-0002VK-Eg for xen-devel@lists.xenproject.org; Tue, 03 Jun 2014 14:08:10 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Yang Z Zhang , Kevin Tian List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartB48667D4.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline ... 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 --- 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; =20 if ( !is_cantiga_b3 && !is_snb_gfx ) return; @@ -125,16 +125,10 @@ static void __init map_igd_reg(void) if ( igd_reg_va ) return; =20 - /* get IGD mmio address in PCI BAR */ - igd_mmio =3D ((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 =3D (igd_mmio & IGD_BAR_MASK) + 0x2000; - - /* ioremap this physical page */ - set_fixmap_nocache(FIX_IGD_MMIO, igd_reg); - igd_reg_va =3D (u8 *)fix_to_virt(FIX_IGD_MMIO); + igd_mmio =3D pci_conf_read32(0, 0, IGD_DEV, 0, PCI_BASE_ADDRESS_1); + igd_mmio <<=3D 32; + igd_mmio +=3D pci_conf_read32(0, 0, IGD_DEV, 0, PCI_BASE_ADDRESS_0); + igd_reg_va =3D ioremap(igd_mmio & IGD_BAR_MASK, 0x3000); } =20 /* @@ -152,12 +146,10 @@ static int cantiga_vtd_ops_preamble(stru return 0; =20 /* - * 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); } =20 /* @@ -179,11 +171,11 @@ static void snb_vtd_ops_preamble(struct=20 if ( !igd_reg_va ) return; =20 - *((volatile u32 *)(igd_reg_va + 0x54)) =3D 0x000FFFFF; - *((volatile u32 *)(igd_reg_va + 0x700)) =3D 0; + *(volatile u32 *)(igd_reg_va + 0x2054) =3D 0x000FFFFF; + *(volatile u32 *)(igd_reg_va + 0x2700) =3D 0; =20 start_time =3D NOW(); - while ( (*((volatile u32 *)(igd_reg_va + 0x2AC)) & 0xF) !=3D 0 ) + while ( (*(volatile u32 *)(igd_reg_va + 0x22AC) & 0xF) !=3D 0 ) { if ( NOW() > start_time + DMAR_OPERATION_TIMEOUT ) { @@ -194,7 +186,7 @@ static void snb_vtd_ops_preamble(struct=20 cpu_relax(); } =20 - *((volatile u32*)(igd_reg_va + 0x50)) =3D 0x10001; + *(volatile u32 *)(igd_reg_va + 0x2050) =3D 0x10001; } =20 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; =20 - *((volatile u32 *)(igd_reg_va + 0x54)) =3D 0xA; - *((volatile u32 *)(igd_reg_va + 0x50)) =3D 0x10000; + *(volatile u32 *)(igd_reg_va + 0x2054) =3D 0xA; + *(volatile u32 *)(igd_reg_va + 0x2050) =3D 0x10000; } =20 /* --- 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 =3D FIX_APEI_RANGE_BASE + FIX_APEI_RANGE_MAX -1, - FIX_IGD_MMIO, FIX_EFI_MPF, __end_of_fixed_addresses }; --=__PartB48667D4.1__= Content-Type: text/plain; name="VT-d-ioremap-IGD-MMIO.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="VT-d-ioremap-IGD-MMIO.patch" VT-d: replace another fixmap use with ioremap()=0A=0A... making the code = more generic and limiting address space consumption=0A(however small it = might be) to just those machines that need this=0Amapping (this is an = erratum workaround after all).=0A=0AAt the same time properly map the full = needed range from the base=0Aaddress instead of just the third page and = fix some formatting.=0A=0ASigned-off-by: Jan Beulich =0A= =0A--- a/xen/drivers/passthrough/vtd/quirks.c=0A+++ b/xen/drivers/passthrou= gh/vtd/quirks.c=0A@@ -117,7 +117,7 @@ static void __init snb_errata_init(vo= id)=0A */=0A static void __init map_igd_reg(void)=0A {=0A- u64 = igd_mmio, igd_reg;=0A+ u64 igd_mmio;=0A =0A if ( !is_cantiga_b3 && = !is_snb_gfx )=0A return;=0A@@ -125,16 +125,10 @@ static void = __init map_igd_reg(void)=0A if ( igd_reg_va )=0A return;=0A = =0A- /* get IGD mmio address in PCI BAR */=0A- igd_mmio =3D = ((u64)pci_conf_read32(0, 0, IGD_DEV, 0, 0x14) << 32) +=0A- = pci_conf_read32(0, 0, IGD_DEV, 0, 0x10);=0A-=0A- /* offset of IGD = regster we want to access is in 0x2000 range */=0A- igd_reg =3D = (igd_mmio & IGD_BAR_MASK) + 0x2000;=0A-=0A- /* ioremap this physical = page */=0A- set_fixmap_nocache(FIX_IGD_MMIO, igd_reg);=0A- igd_reg_va= =3D (u8 *)fix_to_virt(FIX_IGD_MMIO);=0A+ igd_mmio =3D pci_conf_read32= (0, 0, IGD_DEV, 0, PCI_BASE_ADDRESS_1);=0A+ igd_mmio <<=3D 32;=0A+ = igd_mmio +=3D pci_conf_read32(0, 0, IGD_DEV, 0, PCI_BASE_ADDRESS_0);=0A+ = igd_reg_va =3D ioremap(igd_mmio & IGD_BAR_MASK, 0x3000);=0A }=0A =0A = /*=0A@@ -152,12 +146,10 @@ static int cantiga_vtd_ops_preamble(stru=0A = return 0;=0A =0A /*=0A- * read IGD register at IGD MMIO + = 0x20A4 to force IGD=0A- * to exit low power state. Since map_igd_reg()= =0A- * already mapped page starting 0x2000, we just need to=0A- * = add page offset 0x0A4 to virtual address base.=0A+ * Read IGD register = at IGD MMIO + 0x20A4 to force IGD=0A+ * to exit low power state.=0A = */=0A- return ( *((volatile int *)(igd_reg_va + 0x0A4)) );=0A+ = return *(volatile int *)(igd_reg_va + 0x20A4);=0A }=0A =0A /*=0A@@ -179,11 = +171,11 @@ static void snb_vtd_ops_preamble(struct =0A if ( !igd_reg_va= )=0A return;=0A =0A- *((volatile u32 *)(igd_reg_va + 0x54)) = =3D 0x000FFFFF;=0A- *((volatile u32 *)(igd_reg_va + 0x700)) =3D 0;=0A+ = *(volatile u32 *)(igd_reg_va + 0x2054) =3D 0x000FFFFF;=0A+ *(volatile = u32 *)(igd_reg_va + 0x2700) =3D 0;=0A =0A start_time =3D NOW();=0A- = while ( (*((volatile u32 *)(igd_reg_va + 0x2AC)) & 0xF) !=3D 0 )=0A+ = while ( (*(volatile u32 *)(igd_reg_va + 0x22AC) & 0xF) !=3D 0 )=0A = {=0A if ( NOW() > start_time + DMAR_OPERATION_TIMEOUT )=0A = {=0A@@ -194,7 +186,7 @@ static void snb_vtd_ops_preamble(struct =0A = cpu_relax();=0A }=0A =0A- *((volatile u32*)(igd_reg_va + 0x50)) = =3D 0x10001;=0A+ *(volatile u32 *)(igd_reg_va + 0x2050) =3D 0x10001;=0A = }=0A =0A static void snb_vtd_ops_postamble(struct iommu* iommu)=0A@@ = -208,8 +200,8 @@ static void snb_vtd_ops_postamble(struct=0A if ( = !igd_reg_va )=0A return;=0A =0A- *((volatile u32 *)(igd_reg_va = + 0x54)) =3D 0xA;=0A- *((volatile u32 *)(igd_reg_va + 0x50)) =3D = 0x10000;=0A+ *(volatile u32 *)(igd_reg_va + 0x2054) =3D 0xA;=0A+ = *(volatile u32 *)(igd_reg_va + 0x2050) =3D 0x10000;=0A }=0A =0A /*=0A--- = a/xen/include/asm-x86/fixmap.h=0A+++ b/xen/include/asm-x86/fixmap.h=0A@@ = -62,7 +62,6 @@ enum fixed_addresses {=0A FIX_TBOOT_MAP_ADDRESS,=0A = FIX_APEI_RANGE_BASE,=0A FIX_APEI_RANGE_END =3D FIX_APEI_RANGE_BASE + = FIX_APEI_RANGE_MAX -1,=0A- FIX_IGD_MMIO,=0A FIX_EFI_MPF,=0A = __end_of_fixed_addresses=0A };=0A --=__PartB48667D4.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartB48667D4.1__=--