Re: [PATCH RFC 01/17] iommu: Remove struct iommu_ops *iommu from arch_setup_dma_ops()

2023-11-12 Thread Moritz Fischer
On Fri, Nov 03, 2023 at 01:44:46PM -0300, Jason Gunthorpe wrote:
> This is not being used to pass ops, it is just a way to tell if an
> iommu driver was probed. These days this can be detected directly via
> device_iommu_mapped(). Call device_iommu_mapped() in the two places that
> need to check it and remove the iommu parameter everywhere.
> 
> Signed-off-by: Jason Gunthorpe 

Reviewed-by: Moritz Fischer 
> ---
>  arch/arc/mm/dma.c   |  2 +-
>  arch/arm/mm/dma-mapping-nommu.c |  2 +-
>  arch/arm/mm/dma-mapping.c   | 10 +-
>  arch/arm64/mm/dma-mapping.c |  4 ++--
>  arch/mips/mm/dma-noncoherent.c  |  2 +-
>  arch/riscv/mm/dma-noncoherent.c |  2 +-
>  drivers/acpi/scan.c |  3 +--
>  drivers/hv/hv_common.c  |  2 +-
>  drivers/of/device.c |  2 +-
>  include/linux/dma-map-ops.h |  4 ++--
>  10 files changed, 16 insertions(+), 17 deletions(-)
> 
> diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c
> index 2a7fbbb83b7056..197707bc765889 100644
> --- a/arch/arc/mm/dma.c
> +++ b/arch/arc/mm/dma.c
> @@ -91,7 +91,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
>   * Plug in direct dma map ops.
>   */
>  void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
> - const struct iommu_ops *iommu, bool coherent)
> + bool coherent)
>  {
>   /*
>* IOC hardware snoops all DMA traffic keeping the caches consistent
> diff --git a/arch/arm/mm/dma-mapping-nommu.c b/arch/arm/mm/dma-mapping-nommu.c
> index cfd9c933d2f09c..b94850b579952a 100644
> --- a/arch/arm/mm/dma-mapping-nommu.c
> +++ b/arch/arm/mm/dma-mapping-nommu.c
> @@ -34,7 +34,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
>  }
>  
>  void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
> - const struct iommu_ops *iommu, bool coherent)
> + bool coherent)
>  {
>   if (IS_ENABLED(CONFIG_CPU_V7M)) {
>   /*
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index 5409225b4abc06..6c359a3af8d9c7 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1713,7 +1713,7 @@ void arm_iommu_detach_device(struct device *dev)
>  EXPORT_SYMBOL_GPL(arm_iommu_detach_device);
>  
>  static void arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 
> size,
> - const struct iommu_ops *iommu, bool 
> coherent)
> + bool coherent)
>  {
>   struct dma_iommu_mapping *mapping;
>  
> @@ -1748,7 +1748,7 @@ static void arm_teardown_iommu_dma_ops(struct device 
> *dev)
>  #else
>  
>  static void arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 
> size,
> - const struct iommu_ops *iommu, bool 
> coherent)
> + bool coherent)
>  {
>  }
>  
> @@ -1757,7 +1757,7 @@ static void arm_teardown_iommu_dma_ops(struct device 
> *dev) { }
>  #endif   /* CONFIG_ARM_DMA_USE_IOMMU */
>  
>  void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
> - const struct iommu_ops *iommu, bool coherent)
> + bool coherent)
>  {
>   /*
>* Due to legacy code that sets the ->dma_coherent flag from a bus
> @@ -1776,8 +1776,8 @@ void arch_setup_dma_ops(struct device *dev, u64 
> dma_base, u64 size,
>   if (dev->dma_ops)
>   return;
>  
> - if (iommu)
> - arm_setup_iommu_dma_ops(dev, dma_base, size, iommu, coherent);
> + if (device_iommu_mapped(dev))
> + arm_setup_iommu_dma_ops(dev, dma_base, size, coherent);
>  
>   xen_setup_dma_ops(dev);
>   dev->archdata.dma_ops_setup = true;
> diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
> index 3cb101e8cb29ba..61886e43e3a10f 100644
> --- a/arch/arm64/mm/dma-mapping.c
> +++ b/arch/arm64/mm/dma-mapping.c
> @@ -47,7 +47,7 @@ void arch_teardown_dma_ops(struct device *dev)
>  #endif
>  
>  void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
> - const struct iommu_ops *iommu, bool coherent)
> + bool coherent)
>  {
>   int cls = cache_line_size_of_cpu();
>  
> @@ -58,7 +58,7 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, 
> u64 size,
>  ARCH_DMA_MINALIGN, cls);
>  
>   dev->dma_coherent = coherent;
> - if (iommu)
> + if (device_iommu_mapped(dev))
>   iommu_setup_dma_ops(dev, dma_base, dma_base + size - 1);
>  
>   xen_setup_dma_ops(dev);
> diff --git

Re: [PATCH RFC 10/17] acpi: Do not use dev->iommu within acpi_iommu_configure()

2023-11-12 Thread Moritz Fischer
On Fri, Nov 03, 2023 at 01:44:55PM -0300, Jason Gunthorpe wrote:
> This call chain is using dev->iommu->fwspec to pass around the fwspec
> between the three parts (acpi_iommu_configure(), acpi_iommu_fwspec_init(),
> iommu_probe_device()).
> 
> However there is no locking around the accesses to dev->iommu, so this is
> all racy.
> 
> Allocate a clean, local, fwspec at the start of acpu_iommu_configure(),
Nit: s/acpu_iommu_configure/acpi_iommu_configure_id() ?
> pass it through all functions on the stack to fill it with data, and
> finally pass it into iommu_probe_device_fwspec() which will load it into
> dev->iommu under a lock.
> 
> Signed-off-by: Jason Gunthorpe 

Reviewed-by: Moritz Fischer 
> ---
>  drivers/acpi/arm64/iort.c | 39 -
>  drivers/acpi/scan.c   | 89 ++-
>  drivers/acpi/viot.c   | 44 ++-
>  drivers/iommu/iommu.c |  5 +--
>  include/acpi/acpi_bus.h   |  8 ++--
>  include/linux/acpi_iort.h |  3 +-
>  include/linux/acpi_viot.h |  5 ++-
>  include/linux/iommu.h |  2 +
>  8 files changed, 97 insertions(+), 98 deletions(-)
> 
> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
> index 6496ff5a6ba20d..accd01dcfe93f5 100644
> --- a/drivers/acpi/arm64/iort.c
> +++ b/drivers/acpi/arm64/iort.c
> @@ -1218,10 +1218,9 @@ static bool iort_pci_rc_supports_ats(struct 
> acpi_iort_node *node)
>   return pci_rc->ats_attribute & ACPI_IORT_ATS_SUPPORTED;
>  }
>  
> -static int iort_iommu_xlate(struct device *dev, struct acpi_iort_node *node,
> - u32 streamid)
> +static int iort_iommu_xlate(struct iommu_fwspec *fwspec, struct device *dev,
> + struct acpi_iort_node *node, u32 streamid)
>  {
> - const struct iommu_ops *ops;
>   struct fwnode_handle *iort_fwnode;
>  
>   if (!node)
> @@ -1239,17 +1238,14 @@ static int iort_iommu_xlate(struct device *dev, 
> struct acpi_iort_node *node,
>* in the kernel or not, defer the IOMMU configuration
>* or just abort it.
>*/
> - ops = iommu_ops_from_fwnode(iort_fwnode);
> - if (!ops)
> - return iort_iommu_driver_enabled(node->type) ?
> --EPROBE_DEFER : -ENODEV;
> -
> - return acpi_iommu_fwspec_init(dev, streamid, iort_fwnode, ops);
> + return acpi_iommu_fwspec_init(fwspec, dev, streamid, iort_fwnode,
> +   iort_iommu_driver_enabled(node->type));
>  }
>  
>  struct iort_pci_alias_info {
>   struct device *dev;
>   struct acpi_iort_node *node;
> + struct iommu_fwspec *fwspec;
>  };
>  
>  static int iort_pci_iommu_init(struct pci_dev *pdev, u16 alias, void *data)
> @@ -1260,7 +1256,7 @@ static int iort_pci_iommu_init(struct pci_dev *pdev, 
> u16 alias, void *data)
>  
>   parent = iort_node_map_id(info->node, alias, &streamid,
> IORT_IOMMU_TYPE);
> - return iort_iommu_xlate(info->dev, parent, streamid);
> + return iort_iommu_xlate(info->fwspec, info->dev, parent, streamid);
>  }
>  
>  static void iort_named_component_init(struct device *dev,
> @@ -1280,7 +1276,8 @@ static void iort_named_component_init(struct device 
> *dev,
>   dev_warn(dev, "Could not add device properties\n");
>  }
>  
> -static int iort_nc_iommu_map(struct device *dev, struct acpi_iort_node *node)
> +static int iort_nc_iommu_map(struct iommu_fwspec *fwspec, struct device *dev,
> +  struct acpi_iort_node *node)
>  {
>   struct acpi_iort_node *parent;
>   int err = -ENODEV, i = 0;
> @@ -1293,13 +1290,13 @@ static int iort_nc_iommu_map(struct device *dev, 
> struct acpi_iort_node *node)
>  i++);
>  
>   if (parent)
> - err = iort_iommu_xlate(dev, parent, streamid);
> + err = iort_iommu_xlate(fwspec, dev, parent, streamid);
>   } while (parent && !err);
>  
>   return err;
>  }
>  
> -static int iort_nc_iommu_map_id(struct device *dev,
> +static int iort_nc_iommu_map_id(struct iommu_fwspec *fwspec, struct device 
> *dev,
>   struct acpi_iort_node *node,
>   const u32 *in_id)
>  {
> @@ -1308,7 +1305,7 @@ static int iort_nc_iommu_map_id(struct device *dev,
>  
>   parent = iort_node_map_id(node, *in_id, &streamid, IORT_IOMMU_TYPE);
>   if (parent)
> - return iort_iommu_xlate(dev, parent, streamid);
> + return iort_iommu_xlate(fwspec, dev, parent, streamid);
>  
> 

Re: [PATCH v2 12/17] iommu: Make iommu_ops_from_fwnode() static

2023-11-16 Thread Moritz Fischer
On Wed, Nov 15, 2023 at 10:06:03AM -0400, Jason Gunthorpe wrote:
> There are no external callers now.
> 
> Signed-off-by: Jason Gunthorpe 
Reviewed-by: Moritz Fischer 
> ---
>  drivers/iommu/iommu.c | 3 ++-
>  include/linux/iommu.h | 7 ---
>  2 files changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 5af98cad06f9ef..ea6aede326131e 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -2928,7 +2928,8 @@ bool iommu_default_passthrough(void)
>  }
>  EXPORT_SYMBOL_GPL(iommu_default_passthrough);
>  
> -const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode)
> +static const struct iommu_ops *
> +iommu_ops_from_fwnode(struct fwnode_handle *fwnode)
>  {
>   const struct iommu_ops *ops = NULL;
>   struct iommu_device *iommu;
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> index 72ec71bd31a376..05c5ad6bad6339 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -831,7 +831,6 @@ static inline void iommu_fwspec_free(struct device *dev)
>   dev->iommu->fwspec = NULL;
>  }
>  int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids);
> -const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode);
>  int iommu_fwspec_append_ids(struct iommu_fwspec *fwspec, u32 *ids, int 
> num_ids);
>  
>  static inline struct iommu_fwspec *dev_iommu_fwspec_get(struct device *dev)
> @@ -1187,12 +1186,6 @@ static inline int iommu_fwspec_add_ids(struct device 
> *dev, u32 *ids,
>   return -ENODEV;
>  }
>  
> -static inline
> -const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode)
> -{
> - return NULL;
> -}
> -
>  static inline int
>  iommu_dev_enable_feature(struct device *dev, enum iommu_dev_features feat)
>  {
> -- 
> 2.42.0
> 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 03/10] iommu/of: Use -ENODEV consistently in of_iommu_configure()

2023-11-28 Thread Moritz Fischer

On Tue, Nov 28, 2023 at 08:47:59PM -0400, Jason Gunthorpe wrote:

Instead of returning 1 and trying to handle positive error codes just
stick to the convention of returning -ENODEV. Remove references to ops
from of_iommu_configure(), a NULL ops will already generate an error code.



There is no reason to check dev->bus, if err=0 at this point then the
called configure functions thought there was an iommu and we should try to
probe it. Remove it.



Reviewed-by: Jerry Snitselaar 
Tested-by: Hector Martin 
Signed-off-by: Jason Gunthorpe 
---
  drivers/iommu/of_iommu.c | 49 
  1 file changed, 15 insertions(+), 34 deletions(-)



diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c
index c6510d7e7b241b..164317bfb8a81f 100644
--- a/drivers/iommu/of_iommu.c
+++ b/drivers/iommu/of_iommu.c
@@ -17,8 +17,6 @@
  #include 
  #include 



-#define NO_IOMMU   1
-
  static int of_iommu_xlate(struct device *dev,
  struct of_phandle_args *iommu_spec)
  {
@@ -29,7 +27,7 @@ static int of_iommu_xlate(struct device *dev,
ops = iommu_ops_from_fwnode(fwnode);
if ((ops && !ops->of_xlate) ||
!of_device_is_available(iommu_spec->np))
-   return NO_IOMMU;
+   return -ENODEV;



ret = iommu_fwspec_init(dev, &iommu_spec->np->fwnode, ops);
if (ret)
@@ -61,7 +59,7 @@ static int of_iommu_configure_dev_id(struct device_node  
*master_np,

 "iommu-map-mask", &iommu_spec.np,
 iommu_spec.args);
if (err)
-   return err == -ENODEV ? NO_IOMMU : err;
+   return err;



err = of_iommu_xlate(dev, &iommu_spec);
of_node_put(iommu_spec.np);
@@ -72,7 +70,7 @@ static int of_iommu_configure_dev(struct device_node  
*master_np,

  struct device *dev)
  {
struct of_phandle_args iommu_spec;
-   int err = NO_IOMMU, idx = 0;
+   int err = -ENODEV, idx = 0;



while (!of_parse_phandle_with_args(master_np, "iommus",
   "#iommu-cells",
@@ -117,9 +115,8 @@ static int of_iommu_configure_device(struct  
device_node *master_np,

  int of_iommu_configure(struct device *dev, struct device_node *master_np,
   const u32 *id)
  {
-   const struct iommu_ops *ops = NULL;
struct iommu_fwspec *fwspec;
-   int err = NO_IOMMU;
+   int err;



if (!master_np)
return -ENODEV;
@@ -153,37 +150,21 @@ int of_iommu_configure(struct device *dev, struct  
device_node *master_np,

} else {
err = of_iommu_configure_device(master_np, dev, id);
}
-
-   /*
-* Two success conditions can be represented by non-negative err here:
-* >0 : there is no IOMMU, or one was unavailable for non-fatal reasons
-*  0 : we found an IOMMU, and dev->fwspec is initialised appropriately
-* <0 : any actual error
-*/
-   if (!err) {
-   /* The fwspec pointer changed, read it again */
-   fwspec = dev_iommu_fwspec_get(dev);
-   ops= fwspec->ops;
-   }
mutex_unlock(&iommu_probe_device_lock);



-   /*
-* If we have reason to believe the IOMMU driver missed the initial
-* probe for dev, replay it to get things in order.
-*/
-   if (!err && dev->bus)
-   err = iommu_probe_device(dev);
-
-   /* Ignore all other errors apart from EPROBE_DEFER */
-   if (err < 0) {
-   if (err == -EPROBE_DEFER)
-   return err;
-   dev_dbg(dev, "Adding to IOMMU failed: %pe\n", ERR_PTR(err));
+   if (err == -ENODEV || err == -EPROBE_DEFER)
return err;
-   }
-   if (!ops)
-   return -ENODEV;
+   if (err)
+   goto err_log;
+
+   err = iommu_probe_device(dev);
+   if (err)
+   goto err_log;
return 0;
+
+err_log:
+   dev_dbg(dev, "Adding to IOMMU failed: %pe\n", ERR_PTR(err));
+   return err;
  }



  static enum iommu_resv_type __maybe_unused
--
2.42.0



Reviewed-by: Moritz Fischer 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 04/10] iommu: Mark dev_iommu_get() with lockdep

2023-11-28 Thread Moritz Fischer

On Tue, Nov 28, 2023 at 08:48:00PM -0400, Jason Gunthorpe wrote:

Allocation of dev->iommu must be done under the
iommu_probe_device_lock. Mark this with lockdep to discourage future
mistakes.



Reviewed-by: Jerry Snitselaar 
Tested-by: Hector Martin 
Signed-off-by: Jason Gunthorpe 
---
  drivers/iommu/iommu.c | 2 ++
  1 file changed, 2 insertions(+)



diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 0d25468d53a68a..4323b6276e977f 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -334,6 +334,8 @@ static struct dev_iommu *dev_iommu_get(struct device  
*dev)

  {
struct dev_iommu *param = dev->iommu;



+   lockdep_assert_held(&iommu_probe_device_lock);
+
if (param)
return param;



--
2.42.0



Reviewed-by: Moritz Fischer 

Cheers,
Moritz

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 07/10] acpi: Do not return struct iommu_ops from acpi_iommu_configure_id()

2023-11-28 Thread Moritz Fischer

On Tue, Nov 28, 2023 at 08:48:03PM -0400, Jason Gunthorpe wrote:

Nothing needs this pointer. Return a normal error code with the usual
IOMMU semantic that ENODEV means 'there is no IOMMU driver'.



Acked-by: Rafael J. Wysocki 
Reviewed-by: Jerry Snitselaar 
Tested-by: Hector Martin 
Signed-off-by: Jason Gunthorpe 
---
  drivers/acpi/scan.c | 29 +
  1 file changed, 17 insertions(+), 12 deletions(-)



diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 444a0b3c72f2d8..340ba720c72129 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1562,8 +1562,7 @@ static inline const struct iommu_ops  
*acpi_iommu_fwspec_ops(struct device *dev)

return fwspec ? fwspec->ops : NULL;
  }


-static const struct iommu_ops *acpi_iommu_configure_id(struct device  
*dev,

-  const u32 *id_in)
+static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in)
  {
int err;
const struct iommu_ops *ops;
@@ -1577,7 +1576,7 @@ static const struct iommu_ops  
*acpi_iommu_configure_id(struct device *dev,

ops = acpi_iommu_fwspec_ops(dev);
if (ops) {
mutex_unlock(&iommu_probe_device_lock);
-   return ops;
+   return 0;
}



err = iort_iommu_configure_id(dev, id_in);
@@ -1594,12 +1593,14 @@ static const struct iommu_ops  
*acpi_iommu_configure_id(struct device *dev,



/* Ignore all other errors apart from EPROBE_DEFER */
if (err == -EPROBE_DEFER) {
-   return ERR_PTR(err);
+   return err;
} else if (err) {
dev_dbg(dev, "Adding to IOMMU failed: %d\n", err);
-   return NULL;
+   return -ENODEV;
}
-   return acpi_iommu_fwspec_ops(dev);
+   if (!acpi_iommu_fwspec_ops(dev))
+   return -ENODEV;
+   return 0;
  }



  #else /* !CONFIG_IOMMU_API */
@@ -1611,10 +1612,9 @@ int acpi_iommu_fwspec_init(struct device *dev, u32  
id,

return -ENODEV;
  }


-static const struct iommu_ops *acpi_iommu_configure_id(struct device  
*dev,

-  const u32 *id_in)
+static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in)
  {
-   return NULL;
+   return -ENODEV;
  }



  #endif /* !CONFIG_IOMMU_API */
@@ -1628,7 +1628,7 @@ static const struct iommu_ops  
*acpi_iommu_configure_id(struct device *dev,

  int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr,
  const u32 *input_id)
  {
-   const struct iommu_ops *iommu;
+   int ret;



if (attr == DEV_DMA_NOT_SUPPORTED) {
set_dma_ops(dev, &dma_dummy_ops);
@@ -1637,10 +1637,15 @@ int acpi_dma_configure_id(struct device *dev,  
enum dev_dma_attr attr,



acpi_arch_dma_setup(dev);



-   iommu = acpi_iommu_configure_id(dev, input_id);
-   if (PTR_ERR(iommu) == -EPROBE_DEFER)
+   ret = acpi_iommu_configure_id(dev, input_id);
+   if (ret == -EPROBE_DEFER)
return -EPROBE_DEFER;



+   /*
+* Historically this routine doesn't fail driver probing due to errors
+* in acpi_iommu_configure_id()
+*/
+
arch_setup_dma_ops(dev, 0, U64_MAX, attr == DEV_DMA_COHERENT);



return 0;
--
2.42.0



Reviewed-by: Moritz Fischer 

Cheers,
Moritz

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 09/10] ACPI: IORT: Cast from ULL to phys_addr_t

2023-11-28 Thread Moritz Fischer

On Tue, Nov 28, 2023 at 08:48:05PM -0400, Jason Gunthorpe wrote:

gcc on i386 (when compile testing) warns:


This is a weird test. The Makefile for drivers/acpi/arm64 is conditional
on CONFIG_ARM64. How does this happen?


8->8

obj-$(CONFIG_ARM64) += arm64/

8->8



  drivers/acpi/arm64/iort.c:2014:18: warning: implicit conversion  
from 'unsigned long long' to 'phys_addr_t' (aka 'unsigned int') changes  
value from 18446744073709551615 to 4294967295 [-Wconstant-conversion]
local_limit =  
DMA_BIT_MASK(ncomp->memory_address_limit);



Because DMA_BIT_MASK returns a large ULL constant. Explicitly truncate it
to phys_addr_t.



Signed-off-by: Jason Gunthorpe 
---
  drivers/acpi/arm64/iort.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)



diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index 6496ff5a6ba20d..bdaf9256870d92 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -2011,7 +2011,8 @@ phys_addr_t __init  
acpi_iort_dma_get_max_cpu_address(void)



case ACPI_IORT_NODE_NAMED_COMPONENT:
ncomp = (struct acpi_iort_named_component 
*)node->node_data;
-   local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
+   local_limit = (phys_addr_t)DMA_BIT_MASK(
+   ncomp->memory_address_limit);
limit = min_not_zero(limit, local_limit);
break;


@@ -2020,7 +2021,8 @@ phys_addr_t __init  
acpi_iort_dma_get_max_cpu_address(void)

break;



rc = (struct acpi_iort_root_complex *)node->node_data;
-   local_limit = DMA_BIT_MASK(rc->memory_address_limit);
+   local_limit = (phys_addr_t)DMA_BIT_MASK(
+   rc->memory_address_limit);
limit = min_not_zero(limit, local_limit);
break;
}
--
2.42.0



Cheers,
Moritz

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 10/10] ACPI: IORT: Allow COMPILE_TEST of IORT

2023-11-28 Thread Moritz Fischer

On Tue, Nov 28, 2023 at 08:48:06PM -0400, Jason Gunthorpe wrote:

The arm-smmu driver can COMPILE_TEST on x86, so expand this to also
enable the IORT code so it can be COMPILE_TEST'd too.



Signed-off-by: Jason Gunthorpe 
---
  drivers/acpi/Kconfig| 2 --
  drivers/acpi/Makefile   | 2 +-
  drivers/acpi/arm64/Kconfig  | 1 +
  drivers/acpi/arm64/Makefile | 2 +-
  drivers/iommu/Kconfig   | 1 +
  5 files changed, 4 insertions(+), 4 deletions(-)



diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index f819e760ff195a..3b7f77b227d13a 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -541,9 +541,7 @@ config ACPI_PFRUT
  To compile the drivers as modules, choose M here:
  the modules will be called pfr_update and pfr_telemetry.



-if ARM64
  source "drivers/acpi/arm64/Kconfig"
-endif



  config ACPI_PPTT
bool
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index eaa09bf52f1760..4e77ae37b80726 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -127,7 +127,7 @@ obj-y   += pmic/
  video-objs+= acpi_video.o video_detect.o
  obj-y += dptf/



-obj-$(CONFIG_ARM64)+= arm64/
+obj-y  += arm64/



  obj-$(CONFIG_ACPI_VIOT)   += viot.o



diff --git a/drivers/acpi/arm64/Kconfig b/drivers/acpi/arm64/Kconfig
index b3ed6212244c1e..537d49d8ace69e 100644
--- a/drivers/acpi/arm64/Kconfig
+++ b/drivers/acpi/arm64/Kconfig
@@ -11,6 +11,7 @@ config ACPI_GTDT



  config ACPI_AGDI
bool "Arm Generic Diagnostic Dump and Reset Device Interface"
+   depends on ARM64
depends on ARM_SDE_INTERFACE
help
  Arm Generic Diagnostic Dump and Reset Device Interface (AGDI) is
diff --git a/drivers/acpi/arm64/Makefile b/drivers/acpi/arm64/Makefile
index 143debc1ba4a9d..71d0e635599390 100644
--- a/drivers/acpi/arm64/Makefile
+++ b/drivers/acpi/arm64/Makefile
@@ -4,4 +4,4 @@ obj-$(CONFIG_ACPI_IORT) += iort.o
  obj-$(CONFIG_ACPI_GTDT)   += gtdt.o
  obj-$(CONFIG_ACPI_APMT)   += apmt.o
  obj-$(CONFIG_ARM_AMBA)+= amba.o
-obj-y  += dma.o init.o
+obj-$(CONFIG_ARM64)+= dma.o init.o
diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index 7673bb82945b6c..309378e76a9bc9 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -318,6 +318,7 @@ config ARM_SMMU
select IOMMU_API
select IOMMU_IO_PGTABLE_LPAE
select ARM_DMA_USE_IOMMU if ARM
+   select ACPI_IORT if ACPI
help
  Support for implementations of the ARM System MMU architecture
  versions 1 and 2.
--
2.42.0



Reviewed-by: Moritz Fischer 

Ok, now the previous patch makes sense :)

Cheers,
Moritz

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc