Re: [PATCH 2/2] iommu/omap: Fix iommu archdata name for DT-based devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Suman,

Thank you for the patch.

On Wednesday 03 September 2014 18:58:32 Suman Anna wrote:
> A device is tied to an iommu through its archdata field. The archdata
> is allocated on the fly for DT-based devices automatically through the
> .add_device iommu ops. The current logic incorrectly assigned the name
> of the IOMMU user device, instead of the name of the IOMMU device as
> required by the attach logic. Fix this issue so that DT-based devices
> can attach successfully to an IOMMU domain.
> 
> Signed-off-by: Suman Anna <s-anna@xxxxxx>
> ---
>  drivers/iommu/omap-iommu.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
> index f245d51..f47ac03 100644
> --- a/drivers/iommu/omap-iommu.c
> +++ b/drivers/iommu/omap-iommu.c
> @@ -26,6 +26,7 @@
>  #include <linux/of.h>
>  #include <linux/of_iommu.h>
>  #include <linux/of_irq.h>
> +#include <linux/of_platform.h>
> 
>  #include <asm/cacheflush.h>
> 
> @@ -1244,6 +1245,7 @@ static int omap_iommu_add_device(struct device *dev)
>  {
>  	struct omap_iommu_arch_data *arch_data;
>  	struct device_node *np;
> +	struct platform_device *pdev;
> 
>  	/*
>  	 * Allocate the archdata iommu structure for DT-based devices.
> @@ -1258,13 +1260,19 @@ static int omap_iommu_add_device(struct device *dev)
> if (!np)
>  		return 0;
> 
> +	pdev = of_find_device_by_node(np);
> +	if (WARN_ON(!pdev)) {
> +		of_node_put(np);
> +		return -EINVAL;
> +	}

I might be wrong, but I don't think there's a guarantee at this point that the 
IOMMU device is already instantiated :-/

Will Deacon has posted patches that rework the IOMMU core for better DT 
integration, have you seen them ?

> +
>  	arch_data = kzalloc(sizeof(*arch_data), GFP_KERNEL);
>  	if (!arch_data) {
>  		of_node_put(np);
>  		return -ENOMEM;
>  	}
> 
> -	arch_data->name = kstrdup(dev_name(dev), GFP_KERNEL);
> +	arch_data->name = kstrdup(dev_name(&pdev->dev), GFP_KERNEL);
>  	dev->archdata.iommu = arch_data;
> 
>  	of_node_put(np);

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux