From: Robin Murphy <robin.murphy@arm.com> To: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>, will.deacon@arm.com Cc: lorenzo.pieralisi@arm.com, eric.auger@redhat.com, zhongmiao@hisilicon.com, okaya@kernel.org, joro@8bytes.org, rjw@rjwysocki.net, linux-acpi@vger.kernel.org, iommu@lists.linux-foundation.org, hanjun.guo@linaro.org, sudeep.holla@arm.com, linux-arm-kernel@lists.infradead.org, lenb@kernel.org Subject: Re: [PATCH v2 1/7] ACPI/IORT: Check ATS capability in root complex nodes Date: Mon, 15 Apr 2019 19:31:18 +0100 [thread overview] Message-ID: <c10c7adb-c7f6-f8c6-05cc-f4f143427a2d@arm.com> (raw) In-Reply-To: <20190409165245.26500-2-jean-philippe.brucker@arm.com> On 09/04/2019 17:52, Jean-Philippe Brucker wrote: > Root complex node in IORT has a bit telling whether it supports ATS or > not. Store this bit in the IOMMU fwspec when setting up a device, so it > can be accessed later by an IOMMU driver. Hmm, it doesn't feel quite right to store a copy of the same RC/SMMU integration property for every endpoint... It seems like it might be more logical to track this at the SMMU end, i.e. only allow ARM_SMMU_FEAT_ATS to be set if all RCs targeting that SMMU also support ATS. For the moment that seems sufficiently realistic, and unless some wacky topology ever actually shows up in silicon to complain, I'm inclined not to care too much about it being potentially overly restrictive. Furthermore, I'm now wondering whether it would make sense to push this into the PCI layer as well (or instead), i.e. hook into pci_init_ats() or pci_enable_ats() and it the device is untrusted or the topology doesn't support ATS, prevent the capability from ever being enabled at all, rather than trying to mitigate it later at the SMMU end. What do you reckon? > Use the negative version (NO_ATS) at the moment because it's not clear > if/how the bit needs to be integrated in other firmware descriptions. The > SMMU has a feature bit telling if it supports ATS, which might be > sufficient in most systems for deciding whether or not we should enable > the ATS capability in endpoints. I can fairly confidently guarantee that it won't. For instance, MMU-600 reports IDR0.ATS==1 because MMU-600 implements the SMMUv3 architectural ATS support. Actually making use of that support, though, still requires an RC capable of generating the appropriate DTI-ATS messages, and that a DTI interface is wired up correctly between the two. > Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com> > --- > drivers/acpi/arm64/iort.c | 11 +++++++++++ > include/linux/iommu.h | 4 ++++ > 2 files changed, 15 insertions(+) > > diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c > index e48894e002ba..7f2c1c9c6b38 100644 > --- a/drivers/acpi/arm64/iort.c > +++ b/drivers/acpi/arm64/iort.c > @@ -1028,6 +1028,14 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *dma_size) > dev_dbg(dev, "dma_pfn_offset(%#08llx)\n", offset); > } > > +static bool iort_pci_rc_supports_ats(struct acpi_iort_node *node) > +{ > + struct acpi_iort_root_complex *pci_rc; > + > + pci_rc = (struct acpi_iort_root_complex *)node->node_data; > + return pci_rc->ats_attribute & ACPI_IORT_ATS_SUPPORTED; > +} > + > /** > * iort_iommu_configure - Set-up IOMMU configuration for a device. > * > @@ -1063,6 +1071,9 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev) > info.node = node; > err = pci_for_each_dma_alias(to_pci_dev(dev), > iort_pci_iommu_init, &info); > + > + if (!err && !iort_pci_rc_supports_ats(node)) > + dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_NO_ATS; > } else { > int i = 0; > > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 3dbeb457fb16..ed6738c358ca 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -509,10 +509,14 @@ struct iommu_fwspec { > const struct iommu_ops *ops; > struct fwnode_handle *iommu_fwnode; > void *iommu_priv; > + u32 flags; > unsigned int num_ids; > u32 ids[1]; > }; > > +/* Firmware disabled ATS in the root complex */ More likely firmware is just describing how the hardware was built ;) Robin. > +#define IOMMU_FWSPEC_PCI_NO_ATS (1 << 0) > + > int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode, > const struct iommu_ops *ops); > void iommu_fwspec_free(struct device *dev); >
WARNING: multiple messages have this Message-ID (diff)
From: Robin Murphy <robin.murphy@arm.com> To: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>, will.deacon@arm.com Cc: zhongmiao@hisilicon.com, okaya@kernel.org, rjw@rjwysocki.net, linux-acpi@vger.kernel.org, iommu@lists.linux-foundation.org, sudeep.holla@arm.com, linux-arm-kernel@lists.infradead.org, lenb@kernel.org Subject: Re: [PATCH v2 1/7] ACPI/IORT: Check ATS capability in root complex nodes Date: Mon, 15 Apr 2019 19:31:18 +0100 [thread overview] Message-ID: <c10c7adb-c7f6-f8c6-05cc-f4f143427a2d@arm.com> (raw) Message-ID: <20190415183118.tv9NlWzYTL0i8Spux6OC1oSrTD7Qw5tq3EJ6BD5ePXI@z> (raw) In-Reply-To: <20190409165245.26500-2-jean-philippe.brucker@arm.com> On 09/04/2019 17:52, Jean-Philippe Brucker wrote: > Root complex node in IORT has a bit telling whether it supports ATS or > not. Store this bit in the IOMMU fwspec when setting up a device, so it > can be accessed later by an IOMMU driver. Hmm, it doesn't feel quite right to store a copy of the same RC/SMMU integration property for every endpoint... It seems like it might be more logical to track this at the SMMU end, i.e. only allow ARM_SMMU_FEAT_ATS to be set if all RCs targeting that SMMU also support ATS. For the moment that seems sufficiently realistic, and unless some wacky topology ever actually shows up in silicon to complain, I'm inclined not to care too much about it being potentially overly restrictive. Furthermore, I'm now wondering whether it would make sense to push this into the PCI layer as well (or instead), i.e. hook into pci_init_ats() or pci_enable_ats() and it the device is untrusted or the topology doesn't support ATS, prevent the capability from ever being enabled at all, rather than trying to mitigate it later at the SMMU end. What do you reckon? > Use the negative version (NO_ATS) at the moment because it's not clear > if/how the bit needs to be integrated in other firmware descriptions. The > SMMU has a feature bit telling if it supports ATS, which might be > sufficient in most systems for deciding whether or not we should enable > the ATS capability in endpoints. I can fairly confidently guarantee that it won't. For instance, MMU-600 reports IDR0.ATS==1 because MMU-600 implements the SMMUv3 architectural ATS support. Actually making use of that support, though, still requires an RC capable of generating the appropriate DTI-ATS messages, and that a DTI interface is wired up correctly between the two. > Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com> > --- > drivers/acpi/arm64/iort.c | 11 +++++++++++ > include/linux/iommu.h | 4 ++++ > 2 files changed, 15 insertions(+) > > diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c > index e48894e002ba..7f2c1c9c6b38 100644 > --- a/drivers/acpi/arm64/iort.c > +++ b/drivers/acpi/arm64/iort.c > @@ -1028,6 +1028,14 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *dma_size) > dev_dbg(dev, "dma_pfn_offset(%#08llx)\n", offset); > } > > +static bool iort_pci_rc_supports_ats(struct acpi_iort_node *node) > +{ > + struct acpi_iort_root_complex *pci_rc; > + > + pci_rc = (struct acpi_iort_root_complex *)node->node_data; > + return pci_rc->ats_attribute & ACPI_IORT_ATS_SUPPORTED; > +} > + > /** > * iort_iommu_configure - Set-up IOMMU configuration for a device. > * > @@ -1063,6 +1071,9 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev) > info.node = node; > err = pci_for_each_dma_alias(to_pci_dev(dev), > iort_pci_iommu_init, &info); > + > + if (!err && !iort_pci_rc_supports_ats(node)) > + dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_NO_ATS; > } else { > int i = 0; > > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 3dbeb457fb16..ed6738c358ca 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -509,10 +509,14 @@ struct iommu_fwspec { > const struct iommu_ops *ops; > struct fwnode_handle *iommu_fwnode; > void *iommu_priv; > + u32 flags; > unsigned int num_ids; > u32 ids[1]; > }; > > +/* Firmware disabled ATS in the root complex */ More likely firmware is just describing how the hardware was built ;) Robin. > +#define IOMMU_FWSPEC_PCI_NO_ATS (1 << 0) > + > int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode, > const struct iommu_ops *ops); > void iommu_fwspec_free(struct device *dev); > _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2019-04-15 18:31 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-09 16:52 [PATCH v2 0/7] Add PCI ATS support to Arm SMMUv3 Jean-Philippe Brucker 2019-04-09 16:52 ` Jean-Philippe Brucker [not found] ` <20190409165245.26500-1-jean-philippe.brucker-5wv7dgnIgG8@public.gmane.org> 2019-04-09 16:52 ` [PATCH v2 1/7] ACPI/IORT: Check ATS capability in root complex nodes Jean-Philippe Brucker 2019-04-09 16:52 ` Jean-Philippe Brucker [not found] ` <20190409165245.26500-2-jean-philippe.brucker-5wv7dgnIgG8@public.gmane.org> 2019-04-15 13:21 ` Will Deacon 2019-04-15 13:21 ` Will Deacon [not found] ` <20190415132108.GB15023-UDVVEH7NWB15pKCnmE3YQBJ8xKzm50AiAL8bYrjMMd8@public.gmane.org> 2019-04-15 18:00 ` Jean-Philippe Brucker 2019-04-15 18:00 ` Jean-Philippe Brucker 2019-04-15 18:31 ` Robin Murphy [this message] 2019-04-15 18:31 ` Robin Murphy [not found] ` <c10c7adb-c7f6-f8c6-05cc-f4f143427a2d-5wv7dgnIgG8@public.gmane.org> 2019-04-16 16:27 ` Jean-Philippe Brucker 2019-04-16 16:27 ` Jean-Philippe Brucker 2019-04-09 16:52 ` [PATCH v2 2/7] iommu/arm-smmu-v3: Rename arm_smmu_master_data to arm_smmu_master Jean-Philippe Brucker 2019-04-09 16:52 ` Jean-Philippe Brucker 2019-04-09 16:52 ` [PATCH v2 3/7] iommu/arm-smmu-v3: Store SteamIDs in master Jean-Philippe Brucker 2019-04-09 16:52 ` Jean-Philippe Brucker 2019-04-09 16:52 ` [PATCH v2 4/7] iommu/arm-smmu-v3: Add a master->domain pointer Jean-Philippe Brucker 2019-04-09 16:52 ` Jean-Philippe Brucker 2019-04-09 16:52 ` [PATCH v2 5/7] iommu/arm-smmu-v3: Link domains and devices Jean-Philippe Brucker 2019-04-09 16:52 ` Jean-Philippe Brucker 2019-04-09 16:52 ` [PATCH v2 6/7] iommu/arm-smmu-v3: Add support for PCI ATS Jean-Philippe Brucker 2019-04-09 16:52 ` Jean-Philippe Brucker [not found] ` <20190409165245.26500-7-jean-philippe.brucker-5wv7dgnIgG8@public.gmane.org> 2019-04-15 13:21 ` Will Deacon 2019-04-15 13:21 ` Will Deacon [not found] ` <20190415132121.GC15023-UDVVEH7NWB15pKCnmE3YQBJ8xKzm50AiAL8bYrjMMd8@public.gmane.org> 2019-04-15 18:00 ` Jean-Philippe Brucker 2019-04-15 18:00 ` Jean-Philippe Brucker [not found] ` <0b9b600f-60e0-0740-e1db-6b684bf5a195-5wv7dgnIgG8@public.gmane.org> 2019-04-16 10:00 ` Will Deacon 2019-04-16 10:00 ` Will Deacon 2019-04-09 16:52 ` [PATCH v2 7/7] iommu/arm-smmu-v3: Disable tagged pointers Jean-Philippe Brucker 2019-04-09 16:52 ` Jean-Philippe Brucker 2019-04-15 13:20 ` [PATCH v2 0/7] Add PCI ATS support to Arm SMMUv3 Will Deacon 2019-04-15 13:20 ` Will Deacon
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=c10c7adb-c7f6-f8c6-05cc-f4f143427a2d@arm.com \ --to=robin.murphy@arm.com \ --cc=eric.auger@redhat.com \ --cc=hanjun.guo@linaro.org \ --cc=iommu@lists.linux-foundation.org \ --cc=jean-philippe.brucker@arm.com \ --cc=joro@8bytes.org \ --cc=lenb@kernel.org \ --cc=linux-acpi@vger.kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=lorenzo.pieralisi@arm.com \ --cc=okaya@kernel.org \ --cc=rjw@rjwysocki.net \ --cc=sudeep.holla@arm.com \ --cc=will.deacon@arm.com \ --cc=zhongmiao@hisilicon.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: linkBe 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).