All of lore.kernel.org
 help / color / mirror / Atom feed
From: Suman Anna <s-anna@ti.com>
To: Robin Murphy <robin.murphy@arm.com>, <hch@lst.de>,
	<joro@8bytes.org>, <linux@armlinux.org.uk>
Cc: <will@kernel.org>, <inki.dae@samsung.com>,
	<sw0312.kim@samsung.com>, <kyungmin.park@samsung.com>,
	<m.szyprowski@samsung.com>, <agross@kernel.org>,
	<bjorn.andersson@linaro.org>, <thierry.reding@gmail.com>,
	<jonathanh@nvidia.com>, <vdumpa@nvidia.com>, <digetx@gmail.com>,
	<matthias.bgg@gmail.com>, <yong.wu@mediatek.com>,
	<geert+renesas@glider.be>, <magnus.damm@gmail.com>,
	<t-kristo@ti.com>, <laurent.pinchart@ideasonboard.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<iommu@lists.linux-foundation.org>,
	<linux-samsung-soc@vger.kernel.org>,
	<linux-tegra@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>,
	<dri-devel@lists.freedesktop.org>, <linux-media@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 11/18] iommu/omap: Add IOMMU_DOMAIN_DMA support
Date: Mon, 24 Aug 2020 16:39:52 -0500	[thread overview]
Message-ID: <c98765ad-e824-a54c-7cf8-c245dbf960d3@ti.com> (raw)
In-Reply-To: <5ac3788f9f61f7698cfa9c5924d62714e230f678.1597931876.git.robin.murphy@arm.com>

Hi Robin,

On 8/20/20 10:08 AM, Robin Murphy wrote:
> Now that arch/arm is wired up for default domains and iommu-dma,
> implement the corresponding driver-side support for DMA domains.
> 
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  drivers/iommu/omap-iommu.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
> index 71f29c0927fc..ea25c2fe0418 100644
> --- a/drivers/iommu/omap-iommu.c
> +++ b/drivers/iommu/omap-iommu.c
> @@ -9,6 +9,7 @@
>   *		Paul Mundt and Toshihiro Kobayashi
>   */
>  
> +#include <linux/dma-iommu.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/err.h>
>  #include <linux/slab.h>
> @@ -1574,13 +1575,19 @@ static struct iommu_domain *omap_iommu_domain_alloc(unsigned type)
>  {
>  	struct omap_iommu_domain *omap_domain;
>  
> -	if (type != IOMMU_DOMAIN_UNMANAGED)
> +	if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA)
>  		return NULL;
>  
>  	omap_domain = kzalloc(sizeof(*omap_domain), GFP_KERNEL);
>  	if (!omap_domain)
>  		return NULL;
>  
> +	if (type == IOMMU_DOMAIN_DMA &&
> +	    iommu_get_dma_cookie(&omap_domain->domain)) {
> +		kfree(omap_domain);
> +		return NULL;
> +	}
> +
>  	spin_lock_init(&omap_domain->lock);
>  
>  	omap_domain->domain.geometry.aperture_start = 0;
> @@ -1601,6 +1608,7 @@ static void omap_iommu_domain_free(struct iommu_domain *domain)
>  	if (omap_domain->dev)
>  		_omap_iommu_detach_dev(omap_domain, omap_domain->dev);
>  
> +	iommu_put_dma_cookie(&omap_domain->domain);
>  	kfree(omap_domain);
>  }
>  
> @@ -1736,6 +1744,17 @@ static struct iommu_group *omap_iommu_device_group(struct device *dev)
>  	return group;
>  }
>  
> +static int omap_iommu_of_xlate(struct device *dev,
> +			       struct of_phandle_args *args)
> +{
> +	/*
> +	 * Logically, some of the housekeeping from _omap_iommu_add_device()
> +	 * should probably move here, but the minimum we *need* is simply to
> +	 * cooperate with of_iommu at all to let iommu-dma work.
> +	 */
> +	return 0;
> +}
> +

I have tested this series, and it is breaking the OMAP remoteproc functionality.
We definitely need some more plumbing. I am currently getting MMU faults and
also the DMA allocated addresses are not coming from the device-specific CMA
pools (opposite of what Sakari has reported with OMAP3 ISP). Just removing the
of_xlate gets me back the expected allocations, and no MMU faults, but I don't
see any valid traces.

The MMU devices that the OMAP IOMMU driver deals with are not traditional
bus-level IOMMU devices, but local MMU devices that are present within a remote
processor sub-system or hardware accelerator (eg: OMAP3 ISP). The usage is also
slightly different between remoteprocs and OMAP3 ISP. The former uses the CMA
pools and iommu_map/unmap API (UNMANAGED iommu domain), as the allocated regions
need to be mapped using specific device addresses adhering to the firmware
linker map, while OMAP3 ISP uses it like a traditional DMA pool.

regards
Suman

>  static const struct iommu_ops omap_iommu_ops = {
>  	.domain_alloc	= omap_iommu_domain_alloc,
>  	.domain_free	= omap_iommu_domain_free,
> @@ -1747,6 +1766,7 @@ static const struct iommu_ops omap_iommu_ops = {
>  	.probe_device	= omap_iommu_probe_device,
>  	.release_device	= omap_iommu_release_device,
>  	.device_group	= omap_iommu_device_group,
> +	.of_xlate	= omap_iommu_of_xlate,
>  	.pgsize_bitmap	= OMAP_IOMMU_PGSIZES,
>  };
>  
> 


WARNING: multiple messages have this Message-ID (diff)
From: Suman Anna via iommu <iommu@lists.linux-foundation.org>
To: Robin Murphy <robin.murphy@arm.com>, <hch@lst.de>,
	<joro@8bytes.org>, <linux@armlinux.org.uk>
Cc: geert+renesas@glider.be, dri-devel@lists.freedesktop.org,
	matthias.bgg@gmail.com, thierry.reding@gmail.com,
	laurent.pinchart@ideasonboard.com, digetx@gmail.com,
	will@kernel.org, linux-samsung-soc@vger.kernel.org,
	magnus.damm@gmail.com, kyungmin.park@samsung.com,
	jonathanh@nvidia.com, agross@kernel.org,
	linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	inki.dae@samsung.com, linux-mediatek@lists.infradead.org,
	linux-tegra@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, sw0312.kim@samsung.com,
	linux-kernel@vger.kernel.org, t-kristo@ti.com,
	iommu@lists.linux-foundation.org
Subject: Re: [PATCH 11/18] iommu/omap: Add IOMMU_DOMAIN_DMA support
Date: Mon, 24 Aug 2020 16:39:52 -0500	[thread overview]
Message-ID: <c98765ad-e824-a54c-7cf8-c245dbf960d3@ti.com> (raw)
In-Reply-To: <5ac3788f9f61f7698cfa9c5924d62714e230f678.1597931876.git.robin.murphy@arm.com>

Hi Robin,

On 8/20/20 10:08 AM, Robin Murphy wrote:
> Now that arch/arm is wired up for default domains and iommu-dma,
> implement the corresponding driver-side support for DMA domains.
> 
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  drivers/iommu/omap-iommu.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
> index 71f29c0927fc..ea25c2fe0418 100644
> --- a/drivers/iommu/omap-iommu.c
> +++ b/drivers/iommu/omap-iommu.c
> @@ -9,6 +9,7 @@
>   *		Paul Mundt and Toshihiro Kobayashi
>   */
>  
> +#include <linux/dma-iommu.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/err.h>
>  #include <linux/slab.h>
> @@ -1574,13 +1575,19 @@ static struct iommu_domain *omap_iommu_domain_alloc(unsigned type)
>  {
>  	struct omap_iommu_domain *omap_domain;
>  
> -	if (type != IOMMU_DOMAIN_UNMANAGED)
> +	if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA)
>  		return NULL;
>  
>  	omap_domain = kzalloc(sizeof(*omap_domain), GFP_KERNEL);
>  	if (!omap_domain)
>  		return NULL;
>  
> +	if (type == IOMMU_DOMAIN_DMA &&
> +	    iommu_get_dma_cookie(&omap_domain->domain)) {
> +		kfree(omap_domain);
> +		return NULL;
> +	}
> +
>  	spin_lock_init(&omap_domain->lock);
>  
>  	omap_domain->domain.geometry.aperture_start = 0;
> @@ -1601,6 +1608,7 @@ static void omap_iommu_domain_free(struct iommu_domain *domain)
>  	if (omap_domain->dev)
>  		_omap_iommu_detach_dev(omap_domain, omap_domain->dev);
>  
> +	iommu_put_dma_cookie(&omap_domain->domain);
>  	kfree(omap_domain);
>  }
>  
> @@ -1736,6 +1744,17 @@ static struct iommu_group *omap_iommu_device_group(struct device *dev)
>  	return group;
>  }
>  
> +static int omap_iommu_of_xlate(struct device *dev,
> +			       struct of_phandle_args *args)
> +{
> +	/*
> +	 * Logically, some of the housekeeping from _omap_iommu_add_device()
> +	 * should probably move here, but the minimum we *need* is simply to
> +	 * cooperate with of_iommu at all to let iommu-dma work.
> +	 */
> +	return 0;
> +}
> +

I have tested this series, and it is breaking the OMAP remoteproc functionality.
We definitely need some more plumbing. I am currently getting MMU faults and
also the DMA allocated addresses are not coming from the device-specific CMA
pools (opposite of what Sakari has reported with OMAP3 ISP). Just removing the
of_xlate gets me back the expected allocations, and no MMU faults, but I don't
see any valid traces.

The MMU devices that the OMAP IOMMU driver deals with are not traditional
bus-level IOMMU devices, but local MMU devices that are present within a remote
processor sub-system or hardware accelerator (eg: OMAP3 ISP). The usage is also
slightly different between remoteprocs and OMAP3 ISP. The former uses the CMA
pools and iommu_map/unmap API (UNMANAGED iommu domain), as the allocated regions
need to be mapped using specific device addresses adhering to the firmware
linker map, while OMAP3 ISP uses it like a traditional DMA pool.

regards
Suman

>  static const struct iommu_ops omap_iommu_ops = {
>  	.domain_alloc	= omap_iommu_domain_alloc,
>  	.domain_free	= omap_iommu_domain_free,
> @@ -1747,6 +1766,7 @@ static const struct iommu_ops omap_iommu_ops = {
>  	.probe_device	= omap_iommu_probe_device,
>  	.release_device	= omap_iommu_release_device,
>  	.device_group	= omap_iommu_device_group,
> +	.of_xlate	= omap_iommu_of_xlate,
>  	.pgsize_bitmap	= OMAP_IOMMU_PGSIZES,
>  };
>  
> 

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

WARNING: multiple messages have this Message-ID (diff)
From: Suman Anna <s-anna@ti.com>
To: Robin Murphy <robin.murphy@arm.com>, <hch@lst.de>,
	<joro@8bytes.org>, <linux@armlinux.org.uk>
Cc: geert+renesas@glider.be, dri-devel@lists.freedesktop.org,
	bjorn.andersson@linaro.org, matthias.bgg@gmail.com,
	thierry.reding@gmail.com, laurent.pinchart@ideasonboard.com,
	digetx@gmail.com, will@kernel.org, m.szyprowski@samsung.com,
	linux-samsung-soc@vger.kernel.org, magnus.damm@gmail.com,
	kyungmin.park@samsung.com, jonathanh@nvidia.com,
	agross@kernel.org, yong.wu@mediatek.com,
	linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	inki.dae@samsung.com, vdumpa@nvidia.com,
	linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, sw0312.kim@samsung.com,
	linux-kernel@vger.kernel.org, t-kristo@ti.com,
	iommu@lists.linux-foundation.org
Subject: Re: [PATCH 11/18] iommu/omap: Add IOMMU_DOMAIN_DMA support
Date: Mon, 24 Aug 2020 16:39:52 -0500	[thread overview]
Message-ID: <c98765ad-e824-a54c-7cf8-c245dbf960d3@ti.com> (raw)
In-Reply-To: <5ac3788f9f61f7698cfa9c5924d62714e230f678.1597931876.git.robin.murphy@arm.com>

Hi Robin,

On 8/20/20 10:08 AM, Robin Murphy wrote:
> Now that arch/arm is wired up for default domains and iommu-dma,
> implement the corresponding driver-side support for DMA domains.
> 
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  drivers/iommu/omap-iommu.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
> index 71f29c0927fc..ea25c2fe0418 100644
> --- a/drivers/iommu/omap-iommu.c
> +++ b/drivers/iommu/omap-iommu.c
> @@ -9,6 +9,7 @@
>   *		Paul Mundt and Toshihiro Kobayashi
>   */
>  
> +#include <linux/dma-iommu.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/err.h>
>  #include <linux/slab.h>
> @@ -1574,13 +1575,19 @@ static struct iommu_domain *omap_iommu_domain_alloc(unsigned type)
>  {
>  	struct omap_iommu_domain *omap_domain;
>  
> -	if (type != IOMMU_DOMAIN_UNMANAGED)
> +	if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA)
>  		return NULL;
>  
>  	omap_domain = kzalloc(sizeof(*omap_domain), GFP_KERNEL);
>  	if (!omap_domain)
>  		return NULL;
>  
> +	if (type == IOMMU_DOMAIN_DMA &&
> +	    iommu_get_dma_cookie(&omap_domain->domain)) {
> +		kfree(omap_domain);
> +		return NULL;
> +	}
> +
>  	spin_lock_init(&omap_domain->lock);
>  
>  	omap_domain->domain.geometry.aperture_start = 0;
> @@ -1601,6 +1608,7 @@ static void omap_iommu_domain_free(struct iommu_domain *domain)
>  	if (omap_domain->dev)
>  		_omap_iommu_detach_dev(omap_domain, omap_domain->dev);
>  
> +	iommu_put_dma_cookie(&omap_domain->domain);
>  	kfree(omap_domain);
>  }
>  
> @@ -1736,6 +1744,17 @@ static struct iommu_group *omap_iommu_device_group(struct device *dev)
>  	return group;
>  }
>  
> +static int omap_iommu_of_xlate(struct device *dev,
> +			       struct of_phandle_args *args)
> +{
> +	/*
> +	 * Logically, some of the housekeeping from _omap_iommu_add_device()
> +	 * should probably move here, but the minimum we *need* is simply to
> +	 * cooperate with of_iommu at all to let iommu-dma work.
> +	 */
> +	return 0;
> +}
> +

I have tested this series, and it is breaking the OMAP remoteproc functionality.
We definitely need some more plumbing. I am currently getting MMU faults and
also the DMA allocated addresses are not coming from the device-specific CMA
pools (opposite of what Sakari has reported with OMAP3 ISP). Just removing the
of_xlate gets me back the expected allocations, and no MMU faults, but I don't
see any valid traces.

The MMU devices that the OMAP IOMMU driver deals with are not traditional
bus-level IOMMU devices, but local MMU devices that are present within a remote
processor sub-system or hardware accelerator (eg: OMAP3 ISP). The usage is also
slightly different between remoteprocs and OMAP3 ISP. The former uses the CMA
pools and iommu_map/unmap API (UNMANAGED iommu domain), as the allocated regions
need to be mapped using specific device addresses adhering to the firmware
linker map, while OMAP3 ISP uses it like a traditional DMA pool.

regards
Suman

>  static const struct iommu_ops omap_iommu_ops = {
>  	.domain_alloc	= omap_iommu_domain_alloc,
>  	.domain_free	= omap_iommu_domain_free,
> @@ -1747,6 +1766,7 @@ static const struct iommu_ops omap_iommu_ops = {
>  	.probe_device	= omap_iommu_probe_device,
>  	.release_device	= omap_iommu_release_device,
>  	.device_group	= omap_iommu_device_group,
> +	.of_xlate	= omap_iommu_of_xlate,
>  	.pgsize_bitmap	= OMAP_IOMMU_PGSIZES,
>  };
>  
> 


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

WARNING: multiple messages have this Message-ID (diff)
From: Suman Anna <s-anna@ti.com>
To: Robin Murphy <robin.murphy@arm.com>, <hch@lst.de>,
	<joro@8bytes.org>, <linux@armlinux.org.uk>
Cc: geert+renesas@glider.be, dri-devel@lists.freedesktop.org,
	bjorn.andersson@linaro.org, matthias.bgg@gmail.com,
	thierry.reding@gmail.com, laurent.pinchart@ideasonboard.com,
	digetx@gmail.com, will@kernel.org, m.szyprowski@samsung.com,
	linux-samsung-soc@vger.kernel.org, magnus.damm@gmail.com,
	kyungmin.park@samsung.com, jonathanh@nvidia.com,
	agross@kernel.org, yong.wu@mediatek.com,
	linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	inki.dae@samsung.com, linux-mediatek@lists.infradead.org,
	linux-tegra@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, sw0312.kim@samsung.com,
	linux-kernel@vger.kernel.org, t-kristo@ti.com,
	iommu@lists.linux-foundation.org
Subject: Re: [PATCH 11/18] iommu/omap: Add IOMMU_DOMAIN_DMA support
Date: Mon, 24 Aug 2020 16:39:52 -0500	[thread overview]
Message-ID: <c98765ad-e824-a54c-7cf8-c245dbf960d3@ti.com> (raw)
In-Reply-To: <5ac3788f9f61f7698cfa9c5924d62714e230f678.1597931876.git.robin.murphy@arm.com>

Hi Robin,

On 8/20/20 10:08 AM, Robin Murphy wrote:
> Now that arch/arm is wired up for default domains and iommu-dma,
> implement the corresponding driver-side support for DMA domains.
> 
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  drivers/iommu/omap-iommu.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
> index 71f29c0927fc..ea25c2fe0418 100644
> --- a/drivers/iommu/omap-iommu.c
> +++ b/drivers/iommu/omap-iommu.c
> @@ -9,6 +9,7 @@
>   *		Paul Mundt and Toshihiro Kobayashi
>   */
>  
> +#include <linux/dma-iommu.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/err.h>
>  #include <linux/slab.h>
> @@ -1574,13 +1575,19 @@ static struct iommu_domain *omap_iommu_domain_alloc(unsigned type)
>  {
>  	struct omap_iommu_domain *omap_domain;
>  
> -	if (type != IOMMU_DOMAIN_UNMANAGED)
> +	if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA)
>  		return NULL;
>  
>  	omap_domain = kzalloc(sizeof(*omap_domain), GFP_KERNEL);
>  	if (!omap_domain)
>  		return NULL;
>  
> +	if (type == IOMMU_DOMAIN_DMA &&
> +	    iommu_get_dma_cookie(&omap_domain->domain)) {
> +		kfree(omap_domain);
> +		return NULL;
> +	}
> +
>  	spin_lock_init(&omap_domain->lock);
>  
>  	omap_domain->domain.geometry.aperture_start = 0;
> @@ -1601,6 +1608,7 @@ static void omap_iommu_domain_free(struct iommu_domain *domain)
>  	if (omap_domain->dev)
>  		_omap_iommu_detach_dev(omap_domain, omap_domain->dev);
>  
> +	iommu_put_dma_cookie(&omap_domain->domain);
>  	kfree(omap_domain);
>  }
>  
> @@ -1736,6 +1744,17 @@ static struct iommu_group *omap_iommu_device_group(struct device *dev)
>  	return group;
>  }
>  
> +static int omap_iommu_of_xlate(struct device *dev,
> +			       struct of_phandle_args *args)
> +{
> +	/*
> +	 * Logically, some of the housekeeping from _omap_iommu_add_device()
> +	 * should probably move here, but the minimum we *need* is simply to
> +	 * cooperate with of_iommu at all to let iommu-dma work.
> +	 */
> +	return 0;
> +}
> +

I have tested this series, and it is breaking the OMAP remoteproc functionality.
We definitely need some more plumbing. I am currently getting MMU faults and
also the DMA allocated addresses are not coming from the device-specific CMA
pools (opposite of what Sakari has reported with OMAP3 ISP). Just removing the
of_xlate gets me back the expected allocations, and no MMU faults, but I don't
see any valid traces.

The MMU devices that the OMAP IOMMU driver deals with are not traditional
bus-level IOMMU devices, but local MMU devices that are present within a remote
processor sub-system or hardware accelerator (eg: OMAP3 ISP). The usage is also
slightly different between remoteprocs and OMAP3 ISP. The former uses the CMA
pools and iommu_map/unmap API (UNMANAGED iommu domain), as the allocated regions
need to be mapped using specific device addresses adhering to the firmware
linker map, while OMAP3 ISP uses it like a traditional DMA pool.

regards
Suman

>  static const struct iommu_ops omap_iommu_ops = {
>  	.domain_alloc	= omap_iommu_domain_alloc,
>  	.domain_free	= omap_iommu_domain_free,
> @@ -1747,6 +1766,7 @@ static const struct iommu_ops omap_iommu_ops = {
>  	.probe_device	= omap_iommu_probe_device,
>  	.release_device	= omap_iommu_release_device,
>  	.device_group	= omap_iommu_device_group,
> +	.of_xlate	= omap_iommu_of_xlate,
>  	.pgsize_bitmap	= OMAP_IOMMU_PGSIZES,
>  };
>  
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Suman Anna <s-anna@ti.com>
To: Robin Murphy <robin.murphy@arm.com>, <hch@lst.de>,
	<joro@8bytes.org>, <linux@armlinux.org.uk>
Cc: geert+renesas@glider.be, dri-devel@lists.freedesktop.org,
	bjorn.andersson@linaro.org, matthias.bgg@gmail.com,
	thierry.reding@gmail.com, laurent.pinchart@ideasonboard.com,
	digetx@gmail.com, will@kernel.org, m.szyprowski@samsung.com,
	linux-samsung-soc@vger.kernel.org, magnus.damm@gmail.com,
	kyungmin.park@samsung.com, jonathanh@nvidia.com,
	agross@kernel.org, yong.wu@mediatek.com,
	linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	vdumpa@nvidia.com, linux-mediatek@lists.infradead.org,
	linux-tegra@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, sw0312.kim@samsung.com,
	linux-kernel@vger.kernel.org, t-kristo@ti.com,
	iommu@lists.linux-foundation.org
Subject: Re: [PATCH 11/18] iommu/omap: Add IOMMU_DOMAIN_DMA support
Date: Mon, 24 Aug 2020 16:39:52 -0500	[thread overview]
Message-ID: <c98765ad-e824-a54c-7cf8-c245dbf960d3@ti.com> (raw)
In-Reply-To: <5ac3788f9f61f7698cfa9c5924d62714e230f678.1597931876.git.robin.murphy@arm.com>

Hi Robin,

On 8/20/20 10:08 AM, Robin Murphy wrote:
> Now that arch/arm is wired up for default domains and iommu-dma,
> implement the corresponding driver-side support for DMA domains.
> 
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  drivers/iommu/omap-iommu.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
> index 71f29c0927fc..ea25c2fe0418 100644
> --- a/drivers/iommu/omap-iommu.c
> +++ b/drivers/iommu/omap-iommu.c
> @@ -9,6 +9,7 @@
>   *		Paul Mundt and Toshihiro Kobayashi
>   */
>  
> +#include <linux/dma-iommu.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/err.h>
>  #include <linux/slab.h>
> @@ -1574,13 +1575,19 @@ static struct iommu_domain *omap_iommu_domain_alloc(unsigned type)
>  {
>  	struct omap_iommu_domain *omap_domain;
>  
> -	if (type != IOMMU_DOMAIN_UNMANAGED)
> +	if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA)
>  		return NULL;
>  
>  	omap_domain = kzalloc(sizeof(*omap_domain), GFP_KERNEL);
>  	if (!omap_domain)
>  		return NULL;
>  
> +	if (type == IOMMU_DOMAIN_DMA &&
> +	    iommu_get_dma_cookie(&omap_domain->domain)) {
> +		kfree(omap_domain);
> +		return NULL;
> +	}
> +
>  	spin_lock_init(&omap_domain->lock);
>  
>  	omap_domain->domain.geometry.aperture_start = 0;
> @@ -1601,6 +1608,7 @@ static void omap_iommu_domain_free(struct iommu_domain *domain)
>  	if (omap_domain->dev)
>  		_omap_iommu_detach_dev(omap_domain, omap_domain->dev);
>  
> +	iommu_put_dma_cookie(&omap_domain->domain);
>  	kfree(omap_domain);
>  }
>  
> @@ -1736,6 +1744,17 @@ static struct iommu_group *omap_iommu_device_group(struct device *dev)
>  	return group;
>  }
>  
> +static int omap_iommu_of_xlate(struct device *dev,
> +			       struct of_phandle_args *args)
> +{
> +	/*
> +	 * Logically, some of the housekeeping from _omap_iommu_add_device()
> +	 * should probably move here, but the minimum we *need* is simply to
> +	 * cooperate with of_iommu at all to let iommu-dma work.
> +	 */
> +	return 0;
> +}
> +

I have tested this series, and it is breaking the OMAP remoteproc functionality.
We definitely need some more plumbing. I am currently getting MMU faults and
also the DMA allocated addresses are not coming from the device-specific CMA
pools (opposite of what Sakari has reported with OMAP3 ISP). Just removing the
of_xlate gets me back the expected allocations, and no MMU faults, but I don't
see any valid traces.

The MMU devices that the OMAP IOMMU driver deals with are not traditional
bus-level IOMMU devices, but local MMU devices that are present within a remote
processor sub-system or hardware accelerator (eg: OMAP3 ISP). The usage is also
slightly different between remoteprocs and OMAP3 ISP. The former uses the CMA
pools and iommu_map/unmap API (UNMANAGED iommu domain), as the allocated regions
need to be mapped using specific device addresses adhering to the firmware
linker map, while OMAP3 ISP uses it like a traditional DMA pool.

regards
Suman

>  static const struct iommu_ops omap_iommu_ops = {
>  	.domain_alloc	= omap_iommu_domain_alloc,
>  	.domain_free	= omap_iommu_domain_free,
> @@ -1747,6 +1766,7 @@ static const struct iommu_ops omap_iommu_ops = {
>  	.probe_device	= omap_iommu_probe_device,
>  	.release_device	= omap_iommu_release_device,
>  	.device_group	= omap_iommu_device_group,
> +	.of_xlate	= omap_iommu_of_xlate,
>  	.pgsize_bitmap	= OMAP_IOMMU_PGSIZES,
>  };
>  
> 

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

  reply	other threads:[~2020-08-24 21:40 UTC|newest]

Thread overview: 250+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200820150857eucas1p18f5f2ad87703a68b6ed20a090f7c1c57@eucas1p1.samsung.com>
2020-08-20 15:08 ` [PATCH 00/18] Convert arch/arm to use iommu-dma Robin Murphy
2020-08-20 15:08   ` Robin Murphy
2020-08-20 15:08   ` Robin Murphy
2020-08-20 15:08   ` Robin Murphy
2020-08-20 15:08   ` Robin Murphy
2020-08-20 15:08   ` [PATCH 01/18] ARM/dma-mapping: Drop .dma_supported for IOMMU ops Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08   ` [PATCH 02/18] ARM/dma-mapping: Consolidate IOMMU ops callbacks Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08   ` [PATCH 03/18] ARM/dma-mapping: Merge IOMMU ops Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08   ` [PATCH 04/18] iommu/dma: Add temporary hacks for arch/arm Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08   ` [PATCH 05/18] ARM/dma-mapping: Switch to iommu_dma_ops Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-09-28 11:32     ` Marek Szyprowski
2020-09-28 11:32       ` Marek Szyprowski
2020-09-28 11:32       ` Marek Szyprowski
2020-09-28 11:32       ` Marek Szyprowski
2020-09-28 11:32       ` Marek Szyprowski
2020-08-20 15:08   ` [PATCH 06/18] ARM/dma-mapping: Support IOMMU default domains Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08   ` [PATCH 07/18] iommu/arm-smmu: Remove arch/arm workaround Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-21  8:07     ` Will Deacon
2020-08-21  8:07       ` Will Deacon
2020-08-21  8:07       ` Will Deacon
2020-08-21  8:07       ` Will Deacon
2020-08-21  8:07       ` Will Deacon
2020-08-20 15:08   ` [PATCH 08/18] iommu/renesas: " Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08   ` [PATCH 09/18] iommu/mediatek-v1: Add IOMMU_DOMAIN_DMA support Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-29  9:54     ` Yong Wu
2020-08-29  9:54       ` Yong Wu
2020-08-29  9:54       ` Yong Wu
2020-08-29  9:54       ` Yong Wu
2020-08-29  9:54       ` Yong Wu
2020-08-20 15:08   ` [PATCH 10/18] iommu/msm: " Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:55     ` Rob Clark
2020-08-20 15:55       ` Rob Clark
2020-08-20 15:55       ` Rob Clark
2020-08-20 15:55       ` Rob Clark
2020-08-20 15:55       ` Rob Clark
2020-08-20 16:58       ` Robin Murphy
2020-08-20 16:58         ` Robin Murphy
2020-08-20 16:58         ` Robin Murphy
2020-08-20 16:58         ` Robin Murphy
2020-08-20 16:58         ` Robin Murphy
2020-08-20 17:05         ` Rob Clark
2020-08-20 17:05           ` Rob Clark
2020-08-20 17:05           ` Rob Clark
2020-08-20 17:05           ` Rob Clark
2020-08-20 17:05           ` Rob Clark
2020-08-20 15:08   ` [PATCH 11/18] iommu/omap: " Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-24 21:39     ` Suman Anna [this message]
2020-08-24 21:39       ` Suman Anna
2020-08-24 21:39       ` Suman Anna
2020-08-24 21:39       ` Suman Anna
2020-08-24 21:39       ` Suman Anna via iommu
2020-08-20 15:08   ` [PATCH 12/18] iommu/tegra-gart: " Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 20:16     ` Dmitry Osipenko
2020-08-20 20:16       ` Dmitry Osipenko
2020-08-20 20:16       ` Dmitry Osipenko
2020-08-20 20:16       ` Dmitry Osipenko
2020-08-20 20:16       ` Dmitry Osipenko
2020-08-21  0:28       ` Robin Murphy
2020-08-21  0:28         ` Robin Murphy
2020-08-21  0:28         ` Robin Murphy
2020-08-21  0:28         ` Robin Murphy
2020-08-21  0:28         ` Robin Murphy
2020-08-23 21:42         ` Dmitry Osipenko
2020-08-23 21:42           ` Dmitry Osipenko
2020-08-23 21:42           ` Dmitry Osipenko
2020-08-23 21:42           ` Dmitry Osipenko
2020-08-23 21:42           ` Dmitry Osipenko
2020-08-20 15:08   ` [PATCH 13/18] iommu/tegra: " Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-27 15:45     ` Thierry Reding
2020-08-27 15:45       ` Thierry Reding
2020-08-27 15:45       ` Thierry Reding
2020-08-27 15:45       ` Thierry Reding
2020-08-27 15:45       ` Thierry Reding
2020-08-27 18:18       ` Robin Murphy
2020-08-27 18:18         ` Robin Murphy
2020-08-27 18:18         ` Robin Murphy
2020-08-27 18:18         ` Robin Murphy
2020-08-27 18:18         ` Robin Murphy
2020-08-20 15:08   ` [PATCH 14/18] drm/exynos: Consolidate IOMMU mapping code Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-09-18 14:30     ` Marek Szyprowski
2020-09-18 14:30       ` Marek Szyprowski
2020-09-18 14:30       ` Marek Szyprowski
2020-09-18 14:30       ` Marek Szyprowski
2020-09-18 14:30       ` Marek Szyprowski
2020-09-21  2:09     ` Inki Dae
2020-09-21  2:09       ` Inki Dae
2020-09-21  2:09       ` Inki Dae
2020-09-21  2:09       ` Inki Dae
2020-09-21  2:09       ` Inki Dae
2020-08-20 15:08   ` [PATCH 15/18] drm/nouveau/tegra: Clean up IOMMU workaround Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08   ` [PATCH 16/18] staging/media/tegra-vde: " Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 19:51     ` Dmitry Osipenko
2020-08-20 19:51       ` Dmitry Osipenko
2020-08-20 19:51       ` Dmitry Osipenko
2020-08-20 19:51       ` Dmitry Osipenko
2020-08-20 19:51       ` Dmitry Osipenko
2020-08-20 20:10       ` Dmitry Osipenko
2020-08-20 20:10         ` Dmitry Osipenko
2020-08-20 20:10         ` Dmitry Osipenko
2020-08-20 20:10         ` Dmitry Osipenko
2020-08-20 20:10         ` Dmitry Osipenko
2020-08-21  0:11       ` Robin Murphy
2020-08-21  0:11         ` Robin Murphy
2020-08-21  0:11         ` Robin Murphy
2020-08-21  0:11         ` Robin Murphy
2020-08-21  0:11         ` Robin Murphy
2020-08-23 21:34         ` Dmitry Osipenko
2020-08-23 21:34           ` Dmitry Osipenko
2020-08-23 21:34           ` Dmitry Osipenko
2020-08-23 21:34           ` Dmitry Osipenko
2020-08-23 21:34           ` Dmitry Osipenko
2020-08-24 14:01           ` Robin Murphy
2020-08-24 14:01             ` Robin Murphy
2020-08-24 14:01             ` Robin Murphy
2020-08-24 14:01             ` Robin Murphy
2020-08-24 14:01             ` Robin Murphy
2020-08-27  7:05             ` Dmitry Osipenko
2020-08-27  7:05               ` Dmitry Osipenko
2020-08-27  7:05               ` Dmitry Osipenko
2020-08-27  7:05               ` Dmitry Osipenko
2020-08-27  7:05               ` Dmitry Osipenko
2020-08-27 15:54               ` Thierry Reding
2020-08-27 15:54                 ` Thierry Reding
2020-08-27 15:54                 ` Thierry Reding
2020-08-27 15:54                 ` Thierry Reding
2020-08-27 15:54                 ` Thierry Reding
2020-08-30 19:44                 ` Dmitry Osipenko
2020-08-30 19:44                   ` Dmitry Osipenko
2020-08-30 19:44                   ` Dmitry Osipenko
2020-08-30 19:44                   ` Dmitry Osipenko
2020-08-30 19:44                   ` Dmitry Osipenko
2020-08-20 15:08   ` [PATCH 17/18] media/omap3isp: " Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 16:53     ` Sakari Ailus
2020-08-20 16:53       ` Sakari Ailus
2020-08-20 16:53       ` Sakari Ailus
2020-08-20 16:53       ` Sakari Ailus
2020-08-20 16:53       ` Sakari Ailus
2020-08-20 17:25       ` Robin Murphy
2020-08-20 17:25         ` Robin Murphy
2020-08-20 17:25         ` Robin Murphy
2020-08-20 17:25         ` Robin Murphy
2020-08-20 17:25         ` Robin Murphy
2020-08-20 19:55         ` Sakari Ailus
2020-08-20 19:55           ` Sakari Ailus
2020-08-20 19:55           ` Sakari Ailus
2020-08-20 19:55           ` Sakari Ailus
2020-08-20 19:55           ` Sakari Ailus
2020-08-20 23:01           ` Robin Murphy
2020-08-20 23:01             ` Robin Murphy
2020-08-20 23:01             ` Robin Murphy
2020-08-20 23:01             ` Robin Murphy
2020-08-20 23:01             ` Robin Murphy
2020-08-24 21:55             ` Suman Anna
2020-08-24 21:55               ` Suman Anna
2020-08-24 21:55               ` Suman Anna
2020-08-24 21:55               ` Suman Anna
2020-08-24 21:55               ` Suman Anna via iommu
2020-08-20 15:08   ` [PATCH 18/18] ARM/dma-mapping: Remove legacy dma-iommu API Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-20 15:08     ` Robin Murphy
2020-08-24 11:40   ` [PATCH 00/18] Convert arch/arm to use iommu-dma Marek Szyprowski
2020-08-24 11:40     ` Marek Szyprowski
2020-08-24 11:40     ` Marek Szyprowski
2020-08-24 11:40     ` Marek Szyprowski
2020-08-24 11:40     ` Marek Szyprowski
2020-09-18 15:13     ` Marek Szyprowski
2020-09-18 15:13       ` Marek Szyprowski
2020-09-18 15:13       ` Marek Szyprowski
2020-09-18 15:13       ` Marek Szyprowski
2020-09-18 15:13       ` Marek Szyprowski
2020-08-27 12:31   ` Aw: " Frank Wunderlich
2020-08-27 12:31     ` Frank Wunderlich
2020-08-27 12:31     ` Frank Wunderlich
2020-08-27 12:31     ` Frank Wunderlich
2020-08-27 12:31     ` Frank Wunderlich
2020-08-27 12:54     ` Matthias Brugger
2020-08-27 12:54       ` Matthias Brugger
2020-08-27 12:54       ` Matthias Brugger
2020-08-27 12:54       ` Matthias Brugger
2020-08-27 12:54       ` Matthias Brugger

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=c98765ad-e824-a54c-7cf8-c245dbf960d3@ti.com \
    --to=s-anna@ti.com \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=digetx@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=geert+renesas@glider.be \
    --cc=hch@lst.de \
    --cc=inki.dae@samsung.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jonathanh@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kyungmin.park@samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=m.szyprowski@samsung.com \
    --cc=magnus.damm@gmail.com \
    --cc=matthias.bgg@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=sw0312.kim@samsung.com \
    --cc=t-kristo@ti.com \
    --cc=thierry.reding@gmail.com \
    --cc=vdumpa@nvidia.com \
    --cc=will@kernel.org \
    --cc=yong.wu@mediatek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.