mbox series

[v10,00/10] iommu: I/O page faults for SMMUv3

Message ID 20210121123623.2060416-1-jean-philippe@linaro.org
Headers show
Series iommu: I/O page faults for SMMUv3 | expand

Message

Jean-Philippe Brucker Jan. 21, 2021, 12:36 p.m. UTC
Add stall support to the SMMUv3, along with a common I/O Page Fault
handler.

Changes since v9 [1]:
* Style changes suggested by Jonathan
* Fixes to patch 10 pointed out by Robin
* In patch 10, don't register the mm fault handler when enabling
  IOMMU_DEV_FEAT_IOPF, because that feature only indicates that a device
  driver wants to use PRI or stall. After enabling it, drivers may
  register their own IOPF handler (see discussion on v9 patch 03).
  Instead register the mm handler when enabling IOMMU_DEV_FEAT_SVA.

[1] https://lore.kernel.org/linux-iommu/20210108145217.2254447-1-jean-philippe@linaro.org/

Jean-Philippe Brucker (10):
  iommu: Fix comment for struct iommu_fwspec
  iommu/arm-smmu-v3: Use device properties for pasid-num-bits
  iommu: Separate IOMMU_DEV_FEAT_IOPF from IOMMU_DEV_FEAT_SVA
  iommu/vt-d: Support IOMMU_DEV_FEAT_IOPF
  uacce: Enable IOMMU_DEV_FEAT_IOPF
  iommu: Add a page fault handler
  iommu/arm-smmu-v3: Maintain a SID->device structure
  dt-bindings: document stall property for IOMMU masters
  ACPI/IORT: Enable stall support for platform devices
  iommu/arm-smmu-v3: Add stall support for platform devices

 drivers/iommu/Makefile                        |   1 +
 .../devicetree/bindings/iommu/iommu.txt       |  18 +
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h   |  56 ++-
 drivers/iommu/iommu-sva-lib.h                 |  53 ++
 include/linux/iommu.h                         |  26 +-
 drivers/acpi/arm64/iort.c                     |  15 +-
 .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c   |  59 ++-
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c   | 347 +++++++++++--
 drivers/iommu/intel/iommu.c                   |  11 +-
 drivers/iommu/io-pgfault.c                    | 461 ++++++++++++++++++
 drivers/iommu/of_iommu.c                      |   5 -
 drivers/misc/uacce/uacce.c                    |  39 +-
 12 files changed, 1018 insertions(+), 73 deletions(-)
 create mode 100644 drivers/iommu/io-pgfault.c

-- 
2.30.0

Comments

Jonathan Cameron Jan. 21, 2021, 6:57 p.m. UTC | #1
On Thu, 21 Jan 2021 13:36:23 +0100
Jean-Philippe Brucker <jean-philippe@linaro.org> wrote:

> Copy the "Stall supported" bit, that tells whether a named component

> supports stall, into the dma-can-stall device property.

> 

> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>


FWIW given how simple this is :
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


> ---

>  drivers/acpi/arm64/iort.c | 4 +++-

>  1 file changed, 3 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c

> index c9a8bbb74b09..42820d7eb869 100644

> --- a/drivers/acpi/arm64/iort.c

> +++ b/drivers/acpi/arm64/iort.c

> @@ -968,13 +968,15 @@ static int iort_pci_iommu_init(struct pci_dev *pdev, u16 alias, void *data)

>  static void iort_named_component_init(struct device *dev,

>  				      struct acpi_iort_node *node)

>  {

> -	struct property_entry props[2] = {};

> +	struct property_entry props[3] = {};

>  	struct acpi_iort_named_component *nc;

>  

>  	nc = (struct acpi_iort_named_component *)node->node_data;

>  	props[0] = PROPERTY_ENTRY_U32("pasid-num-bits",

>  				      FIELD_GET(ACPI_IORT_NC_PASID_BITS,

>  						nc->node_flags));

> +	if (nc->node_flags & ACPI_IORT_NC_STALL_SUPPORTED)

> +		props[1] = PROPERTY_ENTRY_BOOL("dma-can-stall");

>  

>  	if (device_add_properties(dev, props))

>  		dev_warn(dev, "Could not add device properties\n");
Baolu Lu Jan. 22, 2021, 1:54 a.m. UTC | #2
Hi Jean,

On 1/21/21 8:36 PM, Jean-Philippe Brucker wrote:
> Allow drivers to query and enable IOMMU_DEV_FEAT_IOPF, which amounts to
> checking whether PRI is enabled.
> 
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>

Best regards,
baolu

> ---
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: Lu Baolu <baolu.lu@linux.intel.com>
> ---
>   drivers/iommu/intel/iommu.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index f665322a0991..c777bd94df5d 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -5330,6 +5330,8 @@ static int siov_find_pci_dvsec(struct pci_dev *pdev)
>   static bool
>   intel_iommu_dev_has_feat(struct device *dev, enum iommu_dev_features feat)
>   {
> +	struct device_domain_info *info = get_domain_info(dev);
> +
>   	if (feat == IOMMU_DEV_FEAT_AUX) {
>   		int ret;
>   
> @@ -5344,13 +5346,13 @@ intel_iommu_dev_has_feat(struct device *dev, enum iommu_dev_features feat)
>   		return !!siov_find_pci_dvsec(to_pci_dev(dev));
>   	}
>   
> -	if (feat == IOMMU_DEV_FEAT_SVA) {
> -		struct device_domain_info *info = get_domain_info(dev);
> +	if (feat == IOMMU_DEV_FEAT_IOPF)
> +		return info && info->pri_supported;
>   
> +	if (feat == IOMMU_DEV_FEAT_SVA)
>   		return info && (info->iommu->flags & VTD_FLAG_SVM_CAPABLE) &&
>   			info->pasid_supported && info->pri_supported &&
>   			info->ats_supported;
> -	}
>   
>   	return false;
>   }
> @@ -5361,6 +5363,9 @@ intel_iommu_dev_enable_feat(struct device *dev, enum iommu_dev_features feat)
>   	if (feat == IOMMU_DEV_FEAT_AUX)
>   		return intel_iommu_enable_auxd(dev);
>   
> +	if (feat == IOMMU_DEV_FEAT_IOPF)
> +		return intel_iommu_dev_has_feat(dev, feat) ? 0 : -ENODEV;
> +
>   	if (feat == IOMMU_DEV_FEAT_SVA) {
>   		struct device_domain_info *info = get_domain_info(dev);
>   
>