linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wan Zongshun <vincent.wan@amd.com>
To: Joerg Roedel <joro@8bytes.org>, <iommu@lists.linux-foundation.org>
Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>,
	Borislav Petkov <bp@suse.de>, Ray Huang <ray.huang@amd.com>,
	<vw@iommu.org>, <mcuos.com@gmail.com>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH V3 1/9] iommu/amd: Adding Extended Feature Register check for PC support
Date: Fri, 1 Apr 2016 09:05:57 -0400	[thread overview]
Message-ID: <1459515965-2865-2-git-send-email-vincent.wan@amd.com> (raw)
In-Reply-To: <1459515965-2865-1-git-send-email-vincent.wan@amd.com>

From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>

The IVHD header type 11h and 40h introduce the PCSup bit in
the EFR Register Image bit fileds. This should be used to
determine the IOMMU performance support instead of relying
on the PNCounters and PNBanks.

Note also that the PNCouters and PNBanks bits in the IOMMU
attributes field of IVHD headers type 11h are incorrectly
programmed on some systems.

So, we should not rely on it to determine the performance
counter/banks size. Instead, these values should be read
from the MMIO Offset 0030h IOMMU Extended Feature Register.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 drivers/iommu/amd_iommu_init.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index bf4959f..dff1e01 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -99,7 +99,11 @@ struct ivhd_header {
 	u64 mmio_phys;
 	u16 pci_seg;
 	u16 info;
-	u32 efr;
+	u32 efr_attr;
+
+	/* Following only valid on IVHD type 11h and 40h */
+	u64 efr_reg; /* Exact copy of MMIO_EXT_FEATURES */
+	u64 res;
 } __attribute__((packed));
 
 /*
@@ -1078,13 +1082,25 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
 	iommu->pci_seg = h->pci_seg;
 	iommu->mmio_phys = h->mmio_phys;
 
-	/* Check if IVHD EFR contains proper max banks/counters */
-	if ((h->efr != 0) &&
-	    ((h->efr & (0xF << 13)) != 0) &&
-	    ((h->efr & (0x3F << 17)) != 0)) {
-		iommu->mmio_phys_end = MMIO_REG_END_OFFSET;
-	} else {
-		iommu->mmio_phys_end = MMIO_CNTR_CONF_OFFSET;
+	switch (h->type) {
+	case 0x10:
+		/* Check if IVHD EFR contains proper max banks/counters */
+		if ((h->efr_attr != 0) &&
+		    ((h->efr_attr & (0xF << 13)) != 0) &&
+		    ((h->efr_attr & (0x3F << 17)) != 0))
+			iommu->mmio_phys_end = MMIO_REG_END_OFFSET;
+		else
+			iommu->mmio_phys_end = MMIO_CNTR_CONF_OFFSET;
+		break;
+	case 0x11:
+	case 0x40:
+		if (h->efr_reg & (1 << 9))
+			iommu->mmio_phys_end = MMIO_REG_END_OFFSET;
+		else
+			iommu->mmio_phys_end = MMIO_CNTR_CONF_OFFSET;
+		break;
+	default:
+		return -EINVAL;
 	}
 
 	iommu->mmio_base = iommu_map_mmio_space(iommu->mmio_phys,
-- 
1.9.1

  reply	other threads:[~2016-04-01  5:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-01 13:05 [PATCH V3 0/9] iommu/amd: enable ACPI hardware ID device support Wan Zongshun
2016-04-01 13:05 ` Wan Zongshun [this message]
2016-04-01 13:05 ` [PATCH V3 2/9] iommu/amd: Modify ivhd_header structure to support type 11h and 40h Wan Zongshun
2016-04-01 13:05 ` [PATCH V3 3/9] iommu/amd: Use the most comprehensive IVHD type that the driver can support Wan Zongshun
2016-04-01 13:06 ` [PATCH V3 4/9] iommu/amd: Add new map for storing IVHD dev entry type HID Wan Zongshun
2016-04-01 13:06 ` [PATCH V3 5/9] iommu/amd: Introduces ivrs_acpihid kernel parameter Wan Zongshun
2016-04-01 13:06 ` [PATCH V3 6/9] iommu/amd: Make call-sites of get_device_id aware of its return value Wan Zongshun
2016-04-01 13:06 ` [PATCH V3 7/9] iommu/amd: Add iommu support for ACPI HID devices Wan Zongshun
2016-04-01 13:06 ` [PATCH V3 8/9] iommu/amd: Manage iommu_group " Wan Zongshun
2016-04-01 13:06 ` [PATCH V3 9/9] iommu/amd: Set AMD iommu callbacks for amba bus Wan Zongshun
2016-04-07 11:30 ` [PATCH V3 0/9] iommu/amd: enable ACPI hardware ID device support Joerg Roedel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1459515965-2865-2-git-send-email-vincent.wan@amd.com \
    --to=vincent.wan@amd.com \
    --cc=Suravee.Suthikulpanit@amd.com \
    --cc=bp@suse.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcuos.com@gmail.com \
    --cc=ray.huang@amd.com \
    --cc=vw@iommu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).