Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1244819 > unrolled thread
| Started by | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| First post | 2015-10-12 17:30 +0200 |
| Last post | 2015-10-13 17:10 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH 07/25] scsi: hisi_sas: add ioremap for device HW Arnd Bergmann <arnd@arndb.de> - 2015-10-12 17:30 +0200
Re: [PATCH 07/25] scsi: hisi_sas: add ioremap for device HW zhangfei <zhangfei.gao@linaro.org> - 2015-10-13 11:50 +0200
Re: [PATCH 07/25] scsi: hisi_sas: add ioremap for device HW Arnd Bergmann <arnd@arndb.de> - 2015-10-13 14:30 +0200
Re: [PATCH 07/25] scsi: hisi_sas: add ioremap for device HW zhangfei <zhangfei.gao@linaro.org> - 2015-10-13 17:10 +0200
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2015-10-12 17:30 +0200 |
| Subject | Re: [PATCH 07/25] scsi: hisi_sas: add ioremap for device HW |
| Message-ID | <qiNd1-2Xu-35@gated-at.bofh.it> |
On Monday 12 October 2015 23:20:19 John Garry wrote:
> +int hisi_sas_ioremap(struct hisi_hba *hisi_hba)
> +{
> + struct platform_device *pdev = hisi_hba->pdev;
> + struct device *dev = &pdev->dev;
> + struct resource *res;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + hisi_hba->regs = devm_ioremap(dev,
> + res->start,
> + resource_size(res));
> + if (!hisi_hba->regs)
> + return -ENOMEM;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> + hisi_hba->ctrl_regs = devm_ioremap(dev,
> + res->start,
> + resource_size(res));
> + if (!hisi_hba->ctrl_regs)
> + return -ENOMEM;
> +
> + return 0;
> +}
>
> static const struct of_device_id sas_of_match[] = {
>
Better use devm_ioremap_resource() here, which registers the resource so they
are checked for conflicts and listed in /proc/iomem.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | zhangfei <zhangfei.gao@linaro.org> |
|---|---|
| Date | 2015-10-13 11:50 +0200 |
| Message-ID | <qj4nw-2GQ-9@gated-at.bofh.it> |
| In reply to | #1244819 |
On 10/12/2015 11:21 PM, Arnd Bergmann wrote:
> On Monday 12 October 2015 23:20:19 John Garry wrote:
>> +int hisi_sas_ioremap(struct hisi_hba *hisi_hba)
>> +{
>> + struct platform_device *pdev = hisi_hba->pdev;
>> + struct device *dev = &pdev->dev;
>> + struct resource *res;
>> +
>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> + hisi_hba->regs = devm_ioremap(dev,
>> + res->start,
>> + resource_size(res));
>> + if (!hisi_hba->regs)
>> + return -ENOMEM;
>> +
>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>> + hisi_hba->ctrl_regs = devm_ioremap(dev,
>> + res->start,
>> + resource_size(res));
>> + if (!hisi_hba->ctrl_regs)
>> + return -ENOMEM;
>> +
>> + return 0;
>> +}
>>
>> static const struct of_device_id sas_of_match[] = {
>>
>
> Better use devm_ioremap_resource() here, which registers the resource so they
> are checked for conflicts and listed in /proc/iomem.
>
Yes, hisi_hba->regs can use devm_ioremap_resource.
However ctrl_regs have to use devm_ioremap, since the address are
sharing among different nodes, unfortunately, and devm_ioremap_resource
will fail.
Thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2015-10-13 14:30 +0200 |
| Message-ID | <qj6Sl-6ug-9@gated-at.bofh.it> |
| In reply to | #1245513 |
On Tuesday 13 October 2015 17:47:02 zhangfei wrote:
> On 10/12/2015 11:21 PM, Arnd Bergmann wrote:
> > On Monday 12 October 2015 23:20:19 John Garry wrote:
> >> +int hisi_sas_ioremap(struct hisi_hba *hisi_hba)
> >> +{
> >> + struct platform_device *pdev = hisi_hba->pdev;
> >> + struct device *dev = &pdev->dev;
> >> + struct resource *res;
> >> +
> >> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >> + hisi_hba->regs = devm_ioremap(dev,
> >> + res->start,
> >> + resource_size(res));
> >> + if (!hisi_hba->regs)
> >> + return -ENOMEM;
> >> +
> >> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> >> + hisi_hba->ctrl_regs = devm_ioremap(dev,
> >> + res->start,
> >> + resource_size(res));
> >> + if (!hisi_hba->ctrl_regs)
> >> + return -ENOMEM;
> >> +
> >> + return 0;
> >> +}
> >>
> >> static const struct of_device_id sas_of_match[] = {
> >>
> >
> > Better use devm_ioremap_resource() here, which registers the resource so they
> > are checked for conflicts and listed in /proc/iomem.
> >
>
> Yes, hisi_hba->regs can use devm_ioremap_resource.
>
> However ctrl_regs have to use devm_ioremap, since the address are
> sharing among different nodes, unfortunately, and devm_ioremap_resource
> will fail.
This sounds like it should be fixed in the DT binding then, to ensure
that the ranges don't overlap.
Mapping the same register region multiple times is generally considered
a bad idea because the drivers that map them often don't have global
locks that serialize the access, so it's better to have code in place
that ensures that they are distinct.
What is the purpose of the ctrl_regs region, and why is it shared
across multiple devices?
Are all users of these registers in the same driver?
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | zhangfei <zhangfei.gao@linaro.org> |
|---|---|
| Date | 2015-10-13 17:10 +0200 |
| Message-ID | <qj9nb-1L9-1@gated-at.bofh.it> |
| In reply to | #1245667 |
On 10/13/2015 08:20 PM, Arnd Bergmann wrote:
> On Tuesday 13 October 2015 17:47:02 zhangfei wrote:
>> On 10/12/2015 11:21 PM, Arnd Bergmann wrote:
>>> On Monday 12 October 2015 23:20:19 John Garry wrote:
>>>> +int hisi_sas_ioremap(struct hisi_hba *hisi_hba)
>>>> +{
>>>> + struct platform_device *pdev = hisi_hba->pdev;
>>>> + struct device *dev = &pdev->dev;
>>>> + struct resource *res;
>>>> +
>>>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>> + hisi_hba->regs = devm_ioremap(dev,
>>>> + res->start,
>>>> + resource_size(res));
>>>> + if (!hisi_hba->regs)
>>>> + return -ENOMEM;
>>>> +
>>>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>>>> + hisi_hba->ctrl_regs = devm_ioremap(dev,
>>>> + res->start,
>>>> + resource_size(res));
>>>> + if (!hisi_hba->ctrl_regs)
>>>> + return -ENOMEM;
>>>> +
>>>> + return 0;
>>>> +}
>>>>
>>>> static const struct of_device_id sas_of_match[] = {
>>>>
>>>
>>> Better use devm_ioremap_resource() here, which registers the resource so they
>>> are checked for conflicts and listed in /proc/iomem.
>>>
>>
>> Yes, hisi_hba->regs can use devm_ioremap_resource.
>>
>> However ctrl_regs have to use devm_ioremap, since the address are
>> sharing among different nodes, unfortunately, and devm_ioremap_resource
>> will fail.
>
> This sounds like it should be fixed in the DT binding then, to ensure
> that the ranges don't overlap.
>
> Mapping the same register region multiple times is generally considered
> a bad idea because the drivers that map them often don't have global
> locks that serialize the access, so it's better to have code in place
> that ensures that they are distinct.
>
> What is the purpose of the ctrl_regs region, and why is it shared
> across multiple devices?
>
> Are all users of these registers in the same driver?
>
We are considering using syscon for ctrl_regs.
Thanks Arnd.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web