From: Robin Murphy <robin.murphy@arm.com>
To: shameer <shameerali.kolothum.thodi@huawei.com>,
will.deacon@arm.com, mark.rutland@arm.com,
lorenzo.pieralisi@arm.com, hanjun.guo@linaro.org
Cc: gabriele.paoloni@huawei.com, john.garry@huawei.com,
iommu@lists.linux-foundation.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org,
devel@acpica.org, linuxarm@huawei.com, wangzhou1@hisilicon.com,
guohanjun@huawei.com
Subject: Re: [RFC v1 7/7] iommu/arm-smmu-v3: Enable ACPI based HiSilicon erratum 161010801
Date: Tue, 16 May 2017 14:50:29 +0100 [thread overview]
Message-ID: <a4e62cb2-9eb6-99a0-3443-df77ae9af8f8@arm.com> (raw)
In-Reply-To: <20170513094731.3676-8-shameerali.kolothum.thodi@huawei.com>
On 13/05/17 10:47, shameer wrote:
> 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.
Lorenzo made a point that it might be relatively straightforward to just
follow the IORT mapping for the SMMU through to the ITS MADT entry and
pull the ITS geometry out of that. It would certainly be nicer to have
such a helper abstracted away in the IORT code than have to go parsing
vendor-specific tables directly in the SMMU driver. I reckon it might be
worth taking that idea a bit further to see how it looks.
> 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 <shameerali.kolothum.thodi@huawei.com>
> ---
> 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
I think you misspelled Documentation/arm64/silicon-errata.txt there ;)
Robin.
> @@ -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
> {
>
> },
>
next prev parent reply other threads:[~2017-05-16 13:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-13 9:47 [RFC v1 0/7] iommu/smmu-v3: Workaround for hisilicon 161010801 erratum(reserve HW MSI) shameer
2017-05-13 9:47 ` [RFC v1 1/7] iommu/arm-smmu-v3: Add erratum framework structures shameer
2017-05-13 9:47 ` [RFC v1 3/7] iommu/arm-smmu-v3: Replace the device tree binding for hisilicon broken prefetch cmd with erratum id shameer
2017-05-15 15:23 ` Rob Herring
2017-05-16 10:15 ` Shameerali Kolothum Thodi
2017-05-13 9:47 ` [RFC v1 4/7] iommu/arm-smmu-v3: Enable HiSilicon erratum 161010701 shameer
2017-05-16 13:13 ` Robin Murphy
[not found] ` <6d290334-cb68-5b20-a969-0cc6010922d5-5wv7dgnIgG8@public.gmane.org>
2017-05-16 13:46 ` Shameerali Kolothum Thodi
2017-05-13 9:47 ` [RFC v1 5/7] iommu/arm-smmu-v3: Enable ACPI based " shameer
[not found] ` <20170513094731.3676-1-shameerali.kolothum.thodi-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-05-13 9:47 ` [RFC v1 2/7] iommu/arm-smmu-v3: Add erratum framework functions shameer
2017-05-16 13:08 ` Robin Murphy
2017-05-16 13:45 ` Shameerali Kolothum Thodi
2017-05-13 9:47 ` [RFC v1 6/7] iommu/arm-smmu-v3: Rearrange msi resv alloc functions shameer
2017-05-16 13:27 ` Robin Murphy
[not found] ` <d2d90929-6e79-70a3-5c82-a25e67931b4a-5wv7dgnIgG8@public.gmane.org>
2017-05-16 13:54 ` Shameerali Kolothum Thodi
2017-05-13 9:47 ` [RFC v1 7/7] iommu/arm-smmu-v3: Enable ACPI based HiSilicon erratum 161010801 shameer
2017-05-16 13:50 ` Robin Murphy [this message]
2017-05-16 14:03 ` Shameerali Kolothum Thodi
[not found] ` <5FC3163CFD30C246ABAA99954A238FA838350A62-WFPaWmAhWqtUuCJht5byYAK1hpo4iccwjNknBlVQO8k@public.gmane.org>
2017-05-17 8:05 ` John Garry
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=a4e62cb2-9eb6-99a0-3443-df77ae9af8f8@arm.com \
--to=robin.murphy@arm.com \
--cc=devel@acpica.org \
--cc=devicetree@vger.kernel.org \
--cc=gabriele.paoloni@huawei.com \
--cc=guohanjun@huawei.com \
--cc=hanjun.guo@linaro.org \
--cc=iommu@lists.linux-foundation.org \
--cc=john.garry@huawei.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linuxarm@huawei.com \
--cc=lorenzo.pieralisi@arm.com \
--cc=mark.rutland@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=wangzhou1@hisilicon.com \
--cc=will.deacon@arm.com \
/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