From patchwork Sat May 13 09:47:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 99748 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp700543qge; Sat, 13 May 2017 02:53:54 -0700 (PDT) X-Received: by 10.98.57.212 with SMTP id u81mr9065037pfj.9.1494669234507; Sat, 13 May 2017 02:53:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494669234; cv=none; d=google.com; s=arc-20160816; b=G58HZT5j5L3p6B/mJ2GHsJxFLHp+2bzUvrEUYEO3x5Dnofd5LeZZ//8YM2PxI8rSNX 6Hehp57ZV1Uz5kIvpWyUR1pK4hsOdamwgqhgxxp3qTbzu1phL8Ks6GM9wTiGrm39jPRn bb2AgXa/3OkxyPhdgshhUAXaSfLfZnRce2XjqIAhlOcMGbskEOKStFxFvyQAAL+/y4Yv 8TSYb3hiNvi/8Ymr969PC29gnHbVWS4x6+v/dso6nK4SRALcs0HOhO9GAy+O3QW7zRjU d1lnzuDqRMJcteNrYmMaw/WlrdIokGdZdJTH7m92Eux0oEPKyIWrdhevlfIaUGeYeNFu lxsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=y2V1hB9MRJrBOp8GRgw7mDHjgVK2MIQwmY4rRsdTVd8=; b=wElGVj2pKfStr2BT5zu3t7sJOPDNdX5Zh0OAFmHGmNCzwopfe7lD9MDLs7yIlGYiGU a3ndWa3nrl78nJUY64pPo2+sDB5+9Y5C2SJkQsFg1/cv8JCwrJt/JQcl8UHnTuUJ49mV XqzlfR5fRfnQbJuzhLkrP3S2E2jyII/JaHYOIq82wIMReyl8MPkRuHVtRSH3a2leWIKw fjctKJ6fuwCs5dpicFfMujeMMeJZ4yv3YTh9Nbbjbz4lQLJnkq4VxoLzZK4inG16Qxu+ SXBU6thfAaWJCXWbGJqEQQAmhm/KGCOIZk2Xz/IVYEjbmJvF+hdWtwh1wXc8u/N+406Z opRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c26si5622017pfl.163.2017.05.13.02.53.54; Sat, 13 May 2017 02:53:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752741AbdEMJxx (ORCPT + 7 others); Sat, 13 May 2017 05:53:53 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:6289 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752699AbdEMJxw (ORCPT ); Sat, 13 May 2017 05:53:52 -0400 Received: from 172.30.72.55 (EHLO DGGEML404-HUB.china.huawei.com) ([172.30.72.55]) by dggrg01-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AOL14087; Sat, 13 May 2017 17:53:05 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.91.84) by DGGEML404-HUB.china.huawei.com (10.3.17.39) with Microsoft SMTP Server id 14.3.301.0; Sat, 13 May 2017 17:51:22 +0800 From: shameer To: , , , , CC: , , , , , , , , , , shameer Subject: [RFC v1 7/7] iommu/arm-smmu-v3: Enable ACPI based HiSilicon erratum 161010801 Date: Sat, 13 May 2017 10:47:31 +0100 Message-ID: <20170513094731.3676-8-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20170513094731.3676-1-shameerali.kolothum.thodi@huawei.com> References: <20170513094731.3676-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.91.84] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.5916D783.002F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 65e8041c8d29091637ee01567c3f9a69 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The HiSilicon erratum 161010801 describes the limitation of HiSilicon platforms Hip06/Hip07 to support the SMMU mappings for MSI transactions. On these platforms GICv3 ITS translator is presented with the deviceID by extending the MSI payload data to 64 bits to include the deviceID. Hence, the PCIe controller on this platforms has to differentiate the MSI payload against other DMA payload and has to modify the MSI payload. This basically makes it difficult for this platforms to have a SMMU translation for MSI. This patch implements a ACPI table based quirk to reserve the hw msi regions in the smmu-v3 driver which means these address regions will not be translated and will be excluded from iova allocations. ACPI CSRT vendor specific blobs are used to pass the reserve address region info on these platforms. HiSilicon CSRT table contains a resource group whose device Id matches with the SMMU device model id defined in the IORT spec. This SMMU group will not have the optional Resource group shared info. typedef struct { UINT32 Length; UINT32 VendorId; UINT32 SubvendorId; UINT16 DeviceId; ---->Set to IORT SMMU Model number. UINT16 SubdeviceId; UINT16 Revision; UINT8 Reserved[2]; UINT32 SharedInfoLength; ---->Set to zero. ACPI_CSRT_RESOURCE_DESCRIPTOR RsrcDesc; } ACPI_CSRT_RESOURCE_GROUP; The resource descriptor associated with this group will have the vendor specific section populated to represent the MSI region as below. typedef struct { UINT32 Length; UINT16 ResourceType; UINT16 ResourceSubtype; UINT32 UID; /* Vendor defined info */ UINT64 Base; -->Corresponding SMMU node base address. UINT64 MSIResvStart; -----> HW MSI reserve start address. UINT32 MSIResvLen; -------> HW MSI reserve len. } ACPI_CSRT_RESOURCE_DESCRIPTOR; Signed-off-by: shameer --- arch/arm64/Kconfig | 10 ++++++ drivers/iommu/arm-smmu-v3.c | 75 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 21d61ff..e7ebd97 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -516,6 +516,16 @@ config HISILICON_ERRATUM_161010701 CMD_PREFETCH_CFG. This will skip the prefetch cmd usage. If unsure, say Y. +config HISILICON_ERRATUM_161010801 + bool "HiSilicon erratum 161010801: Reserve HW MSI regions" + default y + help + On HiSilicon Hip06/Hip07 platforms, the SMMU v3 has to bypass the + GIC ITS doorbel msi address regions. This will make sure that ITS + doorbell address regions are reserved and excluded from iova + allocations. + + If unsure, say Y. endmenu diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index e7a8a50..a33e339 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -663,6 +663,73 @@ void erratum_skip_prefetch_cmd(struct arm_smmu_device *smmu, void *arg) smmu->options |= ARM_SMMU_OPT_SKIP_PREFETCH; } +#ifdef CONFIG_HISILICON_ERRATUM_161010801 +static void parse_hisi_csrt_msi(struct arm_smmu_device *smmu, + const struct acpi_iort_smmu_v3 *iort) + +{ + struct acpi_csrt_group *grp, *end; + struct acpi_table_csrt *csrt; + acpi_status status; + + status = acpi_get_table(ACPI_SIG_CSRT, 0, + (struct acpi_table_header **)&csrt); + if (ACPI_FAILURE(status)) { + dev_warn(smmu->dev, "HiSi CSRT table get failed: 0x%x\n", + status); + return; + } + + grp = (struct acpi_csrt_group *)(csrt + 1); + end = (struct acpi_csrt_group *)((void *)csrt + csrt->header.length); + + while (grp < end) { + if (grp->device_id == iort->model) { + /* + * We don't have the optional shared info for this grp + * and has only one resource descriptor with vendor + * defined msi region for this group. Go straight to + * vendor defined info. + */ + struct acpi_csrt_descriptor *desc = + (struct acpi_csrt_descriptor *)&grp[1]; + + /* + * HiSilicon CSRT vendor info. First 8 bytes gives smmu + * node base addr, next 8 bytes HW MSI reserve region + * addr and the remaining 4 byte the len. + */ + void *vendor = &desc[1]; + u64 base = (*(u64 *)vendor); + + if (base == iort->base_address && smmu->msi_region) { + /* Replace the default SW msi with HW msi */ + + smmu->msi_region->start = + *((u64 *)((u64 *)vendor+1)); + smmu->msi_region->length = + *((u32 *)((u64 *)vendor+2)); + smmu->msi_region->type = IOMMU_RESV_MSI; + dev_info(smmu->dev, + "HiSi msi addr 0x%pa size 0x%zx\n", + &smmu->msi_region->start, + smmu->msi_region->length); + return; + } + } + + grp = (struct acpi_csrt_group *)((void *)grp + grp->length); + } + +} +void erratum_hisi_resv_hw_msi(struct arm_smmu_device *smmu, void *arg) +{ + const struct acpi_iort_smmu_v3 *iort_smmu = arg; + + parse_hisi_csrt_msi(smmu, iort_smmu); +} +#endif + struct smmu_erratum_workaround { enum smmu_erratum_match_type match_type; const void *id; /* Indicate the Erratum ID */ @@ -686,6 +753,14 @@ static const struct smmu_erratum_workaround smmu_workarounds[] = { }, #endif +#ifdef CONFIG_HISILICON_ERRATUM_161010801 + { + .match_type = se_match_acpi_iort_model, + .id = (void *)ACPI_IORT_SMMU_HISILICON_HI161X, + .desc_str = "HiSilicon erratum 161010801", + .enable = erratum_hisi_resv_hw_msi, + }, +#endif { },