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: 9725119 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 490CC60387 for ; Sat, 13 May 2017 10:09:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33E2628828 for ; Sat, 13 May 2017 10:09:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A433288CE; Sat, 13 May 2017 10:09:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A079C28828 for ; Sat, 13 May 2017 10:09:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Tc+z9dNi+SxS9DNSDNv9SR3PP/XZ6H1YDFPUD6M31QQ=; b=Yv6liPj1udtUDM fnLmHtcFAgH7S9YbQIqNkNHuMfaNT/BqdKYj1FT6S2odPJh2I2sAc0iwt6s7DAuL6XfSMIHJZUNJB WL527VSkQChZbxlf25Fcxa6Frp79k6biM4eAO/y1IZox7ltU4pWxWpuXhXKKgG6t1Sf099WXAdjhS IB/tVdMvAboJO4L9MfqJXW/n0dHdpvlE1Tm2Q5vfVxXbOL8ATUKzy9k5XclDFrEuIHRKGZODDEoF/ VoMd+Syj3M2u4K/r7tQFJiBRedjHGGgXXQR+AKG9RP2pd2ayN7dxKDF0eASLNEhCVMkmc/WvhjDSE FUbRgn43yciYj6MreAWQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d9TzD-0007AR-Vn; Sat, 13 May 2017 10:09:19 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d9TkE-0001tY-0T for linux-arm-kernel@bombadil.infradead.org; Sat, 13 May 2017 09:53:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nwaAE+sOxkuzJkfITnlHlo6M8186nnAVBZ6PvxR3tHw=; b=o+Cfbv/g/A2wHX7rtIjFJBeSI OrdtM5SowVmB/uBa74s4NpEFcXnlWH0Wokkfh60prDABKNdFRC2xmhiEQy8OKFnofCQWjVBtIoWP/ oEKIYwANQwFnON78pbrqtyFqp08y+dHzrFeT+qDYveZeILJiUy9IG2aIZU3VMetnycdBynBhJqi9I SF1/SqPlZiMY5N0nh9JU7kE/0L21w8/sc82vtg3XAgzs4BIvisQea+5kChdJbicl+viIjXDbwX3WF /XvyrrLKnOFsfT78NLgJ/BhXYLGlOwea2BFk+vXYWICYCBJYbcvg7+EslKv9Va8iuIpSDQUx+/Xmq N4pUITx0Q==; Received: from szxga01-in.huawei.com ([45.249.212.187]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d9Tk9-000143-BQ for linux-arm-kernel@lists.infradead.org; Sat, 13 May 2017 09:53:48 +0000 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: , , , , 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170513_105346_480449_5B1D73C3 X-CRM114-Status: GOOD ( 19.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, gabriele.paoloni@huawei.com, john.garry@huawei.com, linuxarm@huawei.com, shameer , linux-acpi@vger.kernel.org, iommu@lists.linux-foundation.org, wangzhou1@hisilicon.com, guohanjun@huawei.com, linux-arm-kernel@lists.infradead.org, devel@acpica.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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 { },