All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
To: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Joerg Roedel <joerg.roedel-5C7GfCeVMHo@public.gmane.org>,
	Thierry Reding
	<thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/3] iommu/tegra: smmu: Reserve SMMU reg regions precisely
Date: Mon, 23 Apr 2012 12:23:39 -0600	[thread overview]
Message-ID: <4F959E2B.5090109@wwwdotorg.org> (raw)
In-Reply-To: <1335182340-17237-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

On 04/23/2012 05:58 AM, Hiroshi DOYU wrote:
> SMMU register regions are located into 3 blocks discontiguously.
> 
> Get them and reserve each region respectively. This allows other
> module to use/reserve other register regions between SMMU register
> blocks.
> 
> Signed-off-by: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

This patch depends on the other series you sent which adds the Tegra AHB
driver, and modifies the SMMU driver to use it. At least you need to
mention the dependencies so e.g. these patches don't get applied without
the other series.

> @@ -875,9 +877,25 @@ static int tegra_smmu_probe(struct platform_device *pdev)
>  
>  	BUILD_BUG_ON(PAGE_SHIFT != SMMU_PAGE_SHIFT);
>  
> -	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	window = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> -	if (!regs || !window) {
> +	for (i = 0; i < ARRAY_SIZE(res); i++) {
> +		res[i] = platform_get_resource(pdev, IORESOURCE_MEM, i);
> +		if (!res[i])
> +			return -ENODEV;
> +
> +		res[i] = devm_request_mem_region(&pdev->dev, res[i]->start,
> +						 resource_size(res[i]),
> +						 dev_name(&pdev->dev));
> +		if (res[i])
> +			continue;
> +
> +		while (--i >= 0)
> +			devm_release_mem_region(&pdev->dev, res[i]->start,
> +						resource_size(res[i]));

The whole point of using the devm_* functions is that you no longer need
to write out all the error-handling and freeing code related to those
allocations. A similar comment applies to many other parts of this patch.

> +		return -EIO;
> +	}
> +
> +	window = platform_get_resource(pdev, IORESOURCE_MEM, 3);
> +	if (!window) {
>  		dev_err(dev, "No SMMU resources\n");
>  		return -ENODEV;
>  	}
> @@ -892,7 +910,8 @@ static int tegra_smmu_probe(struct platform_device *pdev)
>  	smmu->num_as = SMMU_NUM_ASIDS;
>  	smmu->iovmm_base = (unsigned long)window->start;
>  	smmu->page_count = resource_size(window) >> SMMU_PAGE_SHIFT;
> -	smmu->regs = devm_ioremap(dev, regs->start, resource_size(regs));
> +	smmu->regs = devm_ioremap(dev, res[0]->start,
> +				  res[2]->end - res[0]->start + 1);

So, you've retrieved 3 separate resources for the address space, but
only call ioremap once. That doesn't seem right; there should be a 1:1
relationship between the number of resources and ioremap calls. This is
only working because the SMMU driver isn't calling request_mem_region
for this whole range, and hence isn't conflicting with the
request_mem_region and ioremap callss that the AHB driver is (or rather,
should be) performing...

>  	smmu->as = devm_kzalloc(dev,
> -			sizeof(smmu->as[0]) * smmu->num_as, GFP_KERNEL);
> +				sizeof(smmu->as[0]) * smmu->num_as, GFP_KERNEL);

That looks unrelated.

WARNING: multiple messages have this Message-ID (diff)
From: Stephen Warren <swarren@wwwdotorg.org>
To: Hiroshi DOYU <hdoyu@nvidia.com>
Cc: linux-tegra@vger.kernel.org, Joerg Roedel <joerg.roedel@amd.com>,
	Thierry Reding <thierry.reding@avionic-design.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] iommu/tegra: smmu: Reserve SMMU reg regions precisely
Date: Mon, 23 Apr 2012 12:23:39 -0600	[thread overview]
Message-ID: <4F959E2B.5090109@wwwdotorg.org> (raw)
In-Reply-To: <1335182340-17237-1-git-send-email-hdoyu@nvidia.com>

On 04/23/2012 05:58 AM, Hiroshi DOYU wrote:
> SMMU register regions are located into 3 blocks discontiguously.
> 
> Get them and reserve each region respectively. This allows other
> module to use/reserve other register regions between SMMU register
> blocks.
> 
> Signed-off-by: Hiroshi DOYU <hdoyu@nvidia.com>

This patch depends on the other series you sent which adds the Tegra AHB
driver, and modifies the SMMU driver to use it. At least you need to
mention the dependencies so e.g. these patches don't get applied without
the other series.

> @@ -875,9 +877,25 @@ static int tegra_smmu_probe(struct platform_device *pdev)
>  
>  	BUILD_BUG_ON(PAGE_SHIFT != SMMU_PAGE_SHIFT);
>  
> -	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	window = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> -	if (!regs || !window) {
> +	for (i = 0; i < ARRAY_SIZE(res); i++) {
> +		res[i] = platform_get_resource(pdev, IORESOURCE_MEM, i);
> +		if (!res[i])
> +			return -ENODEV;
> +
> +		res[i] = devm_request_mem_region(&pdev->dev, res[i]->start,
> +						 resource_size(res[i]),
> +						 dev_name(&pdev->dev));
> +		if (res[i])
> +			continue;
> +
> +		while (--i >= 0)
> +			devm_release_mem_region(&pdev->dev, res[i]->start,
> +						resource_size(res[i]));

The whole point of using the devm_* functions is that you no longer need
to write out all the error-handling and freeing code related to those
allocations. A similar comment applies to many other parts of this patch.

> +		return -EIO;
> +	}
> +
> +	window = platform_get_resource(pdev, IORESOURCE_MEM, 3);
> +	if (!window) {
>  		dev_err(dev, "No SMMU resources\n");
>  		return -ENODEV;
>  	}
> @@ -892,7 +910,8 @@ static int tegra_smmu_probe(struct platform_device *pdev)
>  	smmu->num_as = SMMU_NUM_ASIDS;
>  	smmu->iovmm_base = (unsigned long)window->start;
>  	smmu->page_count = resource_size(window) >> SMMU_PAGE_SHIFT;
> -	smmu->regs = devm_ioremap(dev, regs->start, resource_size(regs));
> +	smmu->regs = devm_ioremap(dev, res[0]->start,
> +				  res[2]->end - res[0]->start + 1);

So, you've retrieved 3 separate resources for the address space, but
only call ioremap once. That doesn't seem right; there should be a 1:1
relationship between the number of resources and ioremap calls. This is
only working because the SMMU driver isn't calling request_mem_region
for this whole range, and hence isn't conflicting with the
request_mem_region and ioremap callss that the AHB driver is (or rather,
should be) performing...

>  	smmu->as = devm_kzalloc(dev,
> -			sizeof(smmu->as[0]) * smmu->num_as, GFP_KERNEL);
> +				sizeof(smmu->as[0]) * smmu->num_as, GFP_KERNEL);

That looks unrelated.

  parent reply	other threads:[~2012-04-23 18:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23 11:58 [PATCH 1/3] iommu/tegra: smmu: Reserve SMMU reg regions precisely Hiroshi DOYU
2012-04-23 11:58 ` Hiroshi DOYU
2012-04-23 11:58 ` [PATCH 2/3] iommu/tegra: smmu: Add device tree support for SMMU Hiroshi DOYU
2012-04-23 18:27   ` Stephen Warren
2012-04-24  8:59     ` Hiroshi Doyu
2012-04-24  8:59       ` Hiroshi Doyu
     [not found] ` <1335182340-17237-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-04-23 11:58   ` [PATCH 3/3] arm/dts: Tegra30: " Hiroshi DOYU
2012-04-23 11:58     ` Hiroshi DOYU
2012-04-23 11:58     ` Hiroshi DOYU
     [not found]     ` <1335182340-17237-3-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-04-24 19:34       ` Stephen Warren
2012-04-24 19:34         ` Stephen Warren
2012-04-24 19:34         ` Stephen Warren
2012-04-23 18:23   ` Stephen Warren [this message]
2012-04-23 18:23     ` [PATCH 1/3] iommu/tegra: smmu: Reserve SMMU reg regions precisely Stephen Warren

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=4F959E2B.5090109@wwwdotorg.org \
    --to=swarren-3lzwwm7+weoh9zmkesr00q@public.gmane.org \
    --cc=hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=joerg.roedel-5C7GfCeVMHo@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org \
    /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.