From: "Jan Beulich" Subject: [PATCH 3/4] IOMMU, AMD Family15h Model10-1Fh erratum 746 Workaround Date: Fri, 15 Feb 2013 16:21:30 +0000 Message-ID: <511E6E9A02000078000BED52@nat28.tlf.novell.com> References: <511E6CAD02000078000BED19@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartDDED9F9A.1__=" Return-path: In-Reply-To: <511E6CAD02000078000BED19@nat28.tlf.novell.com> 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: Boris Ostrovsky , suravee.suthikulpanit@amd.com, Sherry Hurwitz 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. --=__PartDDED9F9A.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The IOMMU may stop processing page translations due to a perceived lack of credits for writing upstream peripheral page service request (PPR) or event logs. If the L2B miscellaneous clock gating feature is enabled the IOMMU does not properly register credits after the log request has completed, leading to a potential system hang. BIOSes are supposed to disable L2B micellaneous clock gating by setting L2_L2B_CK_GATE_CONTROL[CKGateL2BMiscDisable](D0F2xF4_x90[2]) =3D 1b. This patch corrects that for those which do not enable this workaround. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Jan Beulich --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -792,6 +792,42 @@ static bool_t __init set_iommu_interrupt return 1; } =20 +/* + * Family15h Model 10h-1fh erratum 746 (IOMMU Logging May Stall Translatio= ns) + * Workaround: + * BIOS should disable L2B micellaneous clock gating by setting + * L2_L2B_CK_GATE_CONTROL[CKGateL2BMiscDisable](D0F2xF4_x90[2]) =3D = 1b + */ +static void amd_iommu_erratum_746_workaround(struct amd_iommu *iommu) +{ + u32 value; + u8 bus =3D PCI_BUS(iommu->bdf); + u8 dev =3D PCI_SLOT(iommu->bdf); + u8 func =3D PCI_FUNC(iommu->bdf); + + if ( (boot_cpu_data.x86 !=3D 0x15) || + (boot_cpu_data.x86_model < 0x10) || + (boot_cpu_data.x86_model > 0x1f) ) + return; + + pci_conf_write32(iommu->seg, bus, dev, func, 0xf0, 0x90); + value =3D pci_conf_read32(iommu->seg, bus, dev, func, 0xf4); + + if ( value & (1 << 2) ) + return; + + /* Select NB indirect register 0x90 and enable writing */ + pci_conf_write32(iommu->seg, bus, dev, func, 0xf0, 0x90 | (1 << 8)); + + pci_conf_write32(iommu->seg, bus, dev, func, 0xf4, value | (1 << 2)); + printk(XENLOG_INFO + "AMD-Vi: Applying erratum 746 workaround for IOMMU at = %04x:%02x:%02x.%u\n", + iommu->seg, bus, dev, func); + + /* Clear the enable writing bit */ + pci_conf_write32(iommu->seg, bus, dev, func, 0xf0, 0x90); +} + static void enable_iommu(struct amd_iommu *iommu) { unsigned long flags; @@ -805,6 +841,8 @@ static void enable_iommu(struct amd_iomm return; } =20 + amd_iommu_erratum_746_workaround(iommu); + register_iommu_dev_table_in_mmio_space(iommu); register_iommu_cmd_buffer_in_mmio_space(iommu); register_iommu_event_log_in_mmio_space(iommu); --=__PartDDED9F9A.1__= Content-Type: text/plain; name="AMD-IOMMU-erratum-746.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="AMD-IOMMU-erratum-746.patch" IOMMU, AMD Family15h Model10-1Fh erratum 746 Workaround=0A=0AThe IOMMU may = stop processing page translations due to a perceived lack=0Aof credits for = writing upstream peripheral page service request (PPR)=0Aor event logs. If = the L2B miscellaneous clock gating feature is enabled=0Athe IOMMU does not = properly register credits after the log request has=0Acompleted, leading = to a potential system hang.=0A=0ABIOSes are supposed to disable L2B = micellaneous clock gating by setting=0AL2_L2B_CK_GATE_CONTROL[CKGateL2BMisc= Disable](D0F2xF4_x90[2]) =3D 1b. This=0Apatch corrects that for those = which do not enable this workaround.=0A=0ASigned-off-by: Suravee Suthikulpa= nit =0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/drivers/passthrough/amd/iommu_init.c=0A+++ = b/xen/drivers/passthrough/amd/iommu_init.c=0A@@ -792,6 +792,42 @@ static = bool_t __init set_iommu_interrupt=0A return 1;=0A }=0A =0A+/*=0A+ * = Family15h Model 10h-1fh erratum 746 (IOMMU Logging May Stall Translations)= =0A+ * Workaround:=0A+ * BIOS should disable L2B micellaneous clock = gating by setting=0A+ * L2_L2B_CK_GATE_CONTROL[CKGateL2BMiscDisable](D0= F2xF4_x90[2]) =3D 1b=0A+ */=0A+static void amd_iommu_erratum_746_workaround= (struct amd_iommu *iommu)=0A+{=0A+ u32 value;=0A+ u8 bus =3D = PCI_BUS(iommu->bdf);=0A+ u8 dev =3D PCI_SLOT(iommu->bdf);=0A+ u8 = func =3D PCI_FUNC(iommu->bdf);=0A+=0A+ if ( (boot_cpu_data.x86 !=3D = 0x15) ||=0A+ (boot_cpu_data.x86_model < 0x10) ||=0A+ = (boot_cpu_data.x86_model > 0x1f) )=0A+ return;=0A+=0A+ pci_conf_w= rite32(iommu->seg, bus, dev, func, 0xf0, 0x90);=0A+ value =3D pci_conf_r= ead32(iommu->seg, bus, dev, func, 0xf4);=0A+=0A+ if ( value & (1 << 2) = )=0A+ return;=0A+=0A+ /* Select NB indirect register 0x90 and = enable writing */=0A+ pci_conf_write32(iommu->seg, bus, dev, func, = 0xf0, 0x90 | (1 << 8));=0A+=0A+ pci_conf_write32(iommu->seg, bus, dev, = func, 0xf4, value | (1 << 2));=0A+ printk(XENLOG_INFO=0A+ = "AMD-Vi: Applying erratum 746 workaround for IOMMU at %04x:%02x:%02x.%u\n",= =0A+ iommu->seg, bus, dev, func);=0A+=0A+ /* Clear the enable = writing bit */=0A+ pci_conf_write32(iommu->seg, bus, dev, func, 0xf0, = 0x90);=0A+}=0A+=0A static void enable_iommu(struct amd_iommu *iommu)=0A = {=0A unsigned long flags;=0A@@ -805,6 +841,8 @@ static void enable_iomm= u(struct amd_iomm=0A return;=0A }=0A =0A+ amd_iommu_erratum_= 746_workaround(iommu);=0A+=0A register_iommu_dev_table_in_mmio_space(io= mmu);=0A register_iommu_cmd_buffer_in_mmio_space(iommu);=0A = register_iommu_event_log_in_mmio_space(iommu);=0A --=__PartDDED9F9A.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 --=__PartDDED9F9A.1__=--