Re: [PATCH v4 1/2] ARM: dma-mapping: Set proper DMA ops in arm_iommu_detach_device()

2018-07-02 Thread Russell King - ARM Linux
On Mon, Jul 02, 2018 at 01:53:17PM +0200, Thierry Reding wrote:
> On Wed, May 30, 2018 at 04:06:24PM +0200, Thierry Reding wrote:
> > From: Thierry Reding 
> > 
> > Instead of setting the DMA ops pointer to NULL, set the correct,
> > non-IOMMU ops depending on the device's coherency setting.
> > 
> > Signed-off-by: Thierry Reding 
> > ---
> > Changes in v4:
> > - new patch to fix existing arm_iommu_detach_device() to do what we need
> > 
> >  arch/arm/mm/dma-mapping.c | 12 ++--
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> Christoph, Russell,
> 
> could either of you provide an Acked-by for this? I think it makes the
> most sense for Ben to pick this up into the Nouveau tree along with
> patch 2/2.

Looks fine to me.

Acked-by: Russell King 

Thanks.

> 
> Thierry
> 
> > diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> > index af27f1c22d93..87a0037574e4 100644
> > --- a/arch/arm/mm/dma-mapping.c
> > +++ b/arch/arm/mm/dma-mapping.c
> > @@ -1151,6 +1151,11 @@ int arm_dma_supported(struct device *dev, u64 mask)
> > return __dma_supported(dev, mask, false);
> >  }
> >  
> > +static const struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
> > +{
> > +   return coherent ? _coherent_dma_ops : _dma_ops;
> > +}
> > +
> >  #ifdef CONFIG_ARM_DMA_USE_IOMMU
> >  
> >  static int __dma_info_to_prot(enum dma_data_direction dir, unsigned long 
> > attrs)
> > @@ -2296,7 +2301,7 @@ void arm_iommu_detach_device(struct device *dev)
> > iommu_detach_device(mapping->domain, dev);
> > kref_put(>kref, release_iommu_mapping);
> > to_dma_iommu_mapping(dev) = NULL;
> > -   set_dma_ops(dev, NULL);
> > +   set_dma_ops(dev, arm_get_dma_map_ops(dev->archdata.dma_coherent));
> >  
> > pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev));
> >  }
> > @@ -2357,11 +2362,6 @@ static void arm_teardown_iommu_dma_ops(struct device 
> > *dev) { }
> >  
> >  #endif /* CONFIG_ARM_DMA_USE_IOMMU */
> >  
> > -static const struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
> > -{
> > -   return coherent ? _coherent_dma_ops : _dma_ops;
> > -}
> > -
> >  void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
> > const struct iommu_ops *iommu, bool coherent)
> >  {
> > -- 
> > 2.17.0
> > 



-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v4 1/2] ARM: dma-mapping: Set proper DMA ops in arm_iommu_detach_device()

2018-07-02 Thread Christoph Hellwig
Looks good:

Acked-by: Christoph Hellwig 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v4 1/2] ARM: dma-mapping: Set proper DMA ops in arm_iommu_detach_device()

2018-07-02 Thread Thierry Reding
On Wed, May 30, 2018 at 04:06:24PM +0200, Thierry Reding wrote:
> From: Thierry Reding 
> 
> Instead of setting the DMA ops pointer to NULL, set the correct,
> non-IOMMU ops depending on the device's coherency setting.
> 
> Signed-off-by: Thierry Reding 
> ---
> Changes in v4:
> - new patch to fix existing arm_iommu_detach_device() to do what we need
> 
>  arch/arm/mm/dma-mapping.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)

Christoph, Russell,

could either of you provide an Acked-by for this? I think it makes the
most sense for Ben to pick this up into the Nouveau tree along with
patch 2/2.

Thierry

> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index af27f1c22d93..87a0037574e4 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1151,6 +1151,11 @@ int arm_dma_supported(struct device *dev, u64 mask)
>   return __dma_supported(dev, mask, false);
>  }
>  
> +static const struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
> +{
> + return coherent ? _coherent_dma_ops : _dma_ops;
> +}
> +
>  #ifdef CONFIG_ARM_DMA_USE_IOMMU
>  
>  static int __dma_info_to_prot(enum dma_data_direction dir, unsigned long 
> attrs)
> @@ -2296,7 +2301,7 @@ void arm_iommu_detach_device(struct device *dev)
>   iommu_detach_device(mapping->domain, dev);
>   kref_put(>kref, release_iommu_mapping);
>   to_dma_iommu_mapping(dev) = NULL;
> - set_dma_ops(dev, NULL);
> + set_dma_ops(dev, arm_get_dma_map_ops(dev->archdata.dma_coherent));
>  
>   pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev));
>  }
> @@ -2357,11 +2362,6 @@ static void arm_teardown_iommu_dma_ops(struct device 
> *dev) { }
>  
>  #endif   /* CONFIG_ARM_DMA_USE_IOMMU */
>  
> -static const struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
> -{
> - return coherent ? _coherent_dma_ops : _dma_ops;
> -}
> -
>  void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
>   const struct iommu_ops *iommu, bool coherent)
>  {
> -- 
> 2.17.0
> 


signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v4 1/2] ARM: dma-mapping: Set proper DMA ops in arm_iommu_detach_device()

2018-05-31 Thread Robin Murphy

On 30/05/18 15:06, Thierry Reding wrote:

From: Thierry Reding 

Instead of setting the DMA ops pointer to NULL, set the correct,
non-IOMMU ops depending on the device's coherency setting.


It looks like it's probably been 4 or 5 years since that became subtly 
wrong by virtue of the landscape changing around it, but it's clearly 
not enough of a problem to consider stable backports :)


Reviewed-by: Robin Murphy 


Signed-off-by: Thierry Reding 
---
Changes in v4:
- new patch to fix existing arm_iommu_detach_device() to do what we need

  arch/arm/mm/dma-mapping.c | 12 ++--
  1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index af27f1c22d93..87a0037574e4 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1151,6 +1151,11 @@ int arm_dma_supported(struct device *dev, u64 mask)
return __dma_supported(dev, mask, false);
  }
  
+static const struct dma_map_ops *arm_get_dma_map_ops(bool coherent)

+{
+   return coherent ? _coherent_dma_ops : _dma_ops;
+}
+
  #ifdef CONFIG_ARM_DMA_USE_IOMMU
  
  static int __dma_info_to_prot(enum dma_data_direction dir, unsigned long attrs)

@@ -2296,7 +2301,7 @@ void arm_iommu_detach_device(struct device *dev)
iommu_detach_device(mapping->domain, dev);
kref_put(>kref, release_iommu_mapping);
to_dma_iommu_mapping(dev) = NULL;
-   set_dma_ops(dev, NULL);
+   set_dma_ops(dev, arm_get_dma_map_ops(dev->archdata.dma_coherent));
  
  	pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev));

  }
@@ -2357,11 +2362,6 @@ static void arm_teardown_iommu_dma_ops(struct device 
*dev) { }
  
  #endif	/* CONFIG_ARM_DMA_USE_IOMMU */
  
-static const struct dma_map_ops *arm_get_dma_map_ops(bool coherent)

-{
-   return coherent ? _coherent_dma_ops : _dma_ops;
-}
-
  void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
const struct iommu_ops *iommu, bool coherent)
  {


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 1/2] ARM: dma-mapping: Set proper DMA ops in arm_iommu_detach_device()

2018-05-30 Thread Thierry Reding
From: Thierry Reding 

Instead of setting the DMA ops pointer to NULL, set the correct,
non-IOMMU ops depending on the device's coherency setting.

Signed-off-by: Thierry Reding 
---
Changes in v4:
- new patch to fix existing arm_iommu_detach_device() to do what we need

 arch/arm/mm/dma-mapping.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index af27f1c22d93..87a0037574e4 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1151,6 +1151,11 @@ int arm_dma_supported(struct device *dev, u64 mask)
return __dma_supported(dev, mask, false);
 }
 
+static const struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
+{
+   return coherent ? _coherent_dma_ops : _dma_ops;
+}
+
 #ifdef CONFIG_ARM_DMA_USE_IOMMU
 
 static int __dma_info_to_prot(enum dma_data_direction dir, unsigned long attrs)
@@ -2296,7 +2301,7 @@ void arm_iommu_detach_device(struct device *dev)
iommu_detach_device(mapping->domain, dev);
kref_put(>kref, release_iommu_mapping);
to_dma_iommu_mapping(dev) = NULL;
-   set_dma_ops(dev, NULL);
+   set_dma_ops(dev, arm_get_dma_map_ops(dev->archdata.dma_coherent));
 
pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev));
 }
@@ -2357,11 +2362,6 @@ static void arm_teardown_iommu_dma_ops(struct device 
*dev) { }
 
 #endif /* CONFIG_ARM_DMA_USE_IOMMU */
 
-static const struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
-{
-   return coherent ? _coherent_dma_ops : _dma_ops;
-}
-
 void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
const struct iommu_ops *iommu, bool coherent)
 {
-- 
2.17.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel