diff mbox

[v2,3/3] irqchip/gicv3-its: Handle OF device tree "msi-map" properties.

Message ID 1442966406-13198-4-git-send-email-ddaney.cavm@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Daney Sept. 23, 2015, midnight UTC
From: David Daney <david.daney@cavium.com>

Call of_msi_map_rid() to handle mapping of the requester id.

Signed-off-by: David Daney <david.daney@cavium.com>
---
 drivers/irqchip/irq-gic-v3-its-pci-msi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Marc Zyngier Sept. 23, 2015, 5:01 p.m. UTC | #1
On Tue, 22 Sep 2015 17:00:06 -0700
David Daney <ddaney.cavm@gmail.com> wrote:

> From: David Daney <david.daney@cavium.com>
> 
> Call of_msi_map_rid() to handle mapping of the requester id.
> 
> Signed-off-by: David Daney <david.daney@cavium.com>
> ---
>  drivers/irqchip/irq-gic-v3-its-pci-msi.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
> index cf351c6..8b1c938 100644
> --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c
> +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
> @@ -86,7 +86,8 @@ static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev,
>  	pci_for_each_dma_alias(pdev, its_get_pci_alias, &dev_alias);
>  
>  	/* ITS specific DeviceID, as the core ITS ignores dev. */
> -	info->scratchpad[0].ul = dev_alias.dev_id;
> +	info->scratchpad[0].ul = of_msi_map_rid(dev, domain->of_node,
> +						dev_alias.dev_id);
>  
>  	return msi_info->ops->msi_prepare(domain->parent,
>  					  dev, dev_alias.count, info);

I really wonder if that shouldn't be part of the pci_for_each_dma_alias
call. It would make a lot more sense for this functionality to be an
integral part of the core code, and would probably make the integration
of _IORT (which has the exact same requirements) a bit easier.

Thoughts?

	M.
David Daney Sept. 23, 2015, 5:08 p.m. UTC | #2
On 09/23/2015 10:01 AM, Marc Zyngier wrote:
> On Tue, 22 Sep 2015 17:00:06 -0700
> David Daney <ddaney.cavm@gmail.com> wrote:
>
>> From: David Daney <david.daney@cavium.com>
>>
>> Call of_msi_map_rid() to handle mapping of the requester id.
>>
>> Signed-off-by: David Daney <david.daney@cavium.com>
>> ---
>>   drivers/irqchip/irq-gic-v3-its-pci-msi.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
>> index cf351c6..8b1c938 100644
>> --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c
>> +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
>> @@ -86,7 +86,8 @@ static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev,
>>   	pci_for_each_dma_alias(pdev, its_get_pci_alias, &dev_alias);
>>
>>   	/* ITS specific DeviceID, as the core ITS ignores dev. */
>> -	info->scratchpad[0].ul = dev_alias.dev_id;
>> +	info->scratchpad[0].ul = of_msi_map_rid(dev, domain->of_node,
>> +						dev_alias.dev_id);
>>
>>   	return msi_info->ops->msi_prepare(domain->parent,
>>   					  dev, dev_alias.count, info);
>
> I really wonder if that shouldn't be part of the pci_for_each_dma_alias
> call. It would make a lot more sense for this functionality to be an
> integral part of the core code, and would probably make the integration
> of _IORT (which has the exact same requirements) a bit easier.
>
> Thoughts?
>

I am a proponent of pushing things like this as far into the core code 
as possible.  So, from that point of view, I think it would probably be 
a good idea.

I can prepare a patch that does that, but it would also be nice hear 
from other maintainers and get their thoughts on this.


> 	M.
>
Will Deacon Sept. 23, 2015, 5:52 p.m. UTC | #3
On Wed, Sep 23, 2015 at 06:08:39PM +0100, David Daney wrote:
> On 09/23/2015 10:01 AM, Marc Zyngier wrote:
> > On Tue, 22 Sep 2015 17:00:06 -0700
> > David Daney <ddaney.cavm@gmail.com> wrote:
> >
> >> From: David Daney <david.daney@cavium.com>
> >>
> >> Call of_msi_map_rid() to handle mapping of the requester id.
> >>
> >> Signed-off-by: David Daney <david.daney@cavium.com>
> >> ---
> >>   drivers/irqchip/irq-gic-v3-its-pci-msi.c | 3 ++-
> >>   1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
> >> index cf351c6..8b1c938 100644
> >> --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c
> >> +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
> >> @@ -86,7 +86,8 @@ static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev,
> >>   	pci_for_each_dma_alias(pdev, its_get_pci_alias, &dev_alias);
> >>
> >>   	/* ITS specific DeviceID, as the core ITS ignores dev. */
> >> -	info->scratchpad[0].ul = dev_alias.dev_id;
> >> +	info->scratchpad[0].ul = of_msi_map_rid(dev, domain->of_node,
> >> +						dev_alias.dev_id);
> >>
> >>   	return msi_info->ops->msi_prepare(domain->parent,
> >>   					  dev, dev_alias.count, info);
> >
> > I really wonder if that shouldn't be part of the pci_for_each_dma_alias
> > call. It would make a lot more sense for this functionality to be an
> > integral part of the core code, and would probably make the integration
> > of _IORT (which has the exact same requirements) a bit easier.
> >
> > Thoughts?
> >
> 
> I am a proponent of pushing things like this as far into the core code 
> as possible.  So, from that point of view, I think it would probably be 
> a good idea.
> 
> I can prepare a patch that does that, but it would also be nice hear 
> from other maintainers and get their thoughts on this.

Hmm, we use pci_for_each_dma_alias in the SMMU drivers to get the SID,
so I'm not sure that using the MSI mapping is necessarily the right thing
to do there. Maybe we should instead have dma_alias_to_msi_id helpers or
something?

Will
Marc Zyngier Sept. 23, 2015, 6:18 p.m. UTC | #4
On Wed, 23 Sep 2015 18:52:59 +0100
Will Deacon <will.deacon@arm.com> wrote:

> On Wed, Sep 23, 2015 at 06:08:39PM +0100, David Daney wrote:
> > On 09/23/2015 10:01 AM, Marc Zyngier wrote:
> > > On Tue, 22 Sep 2015 17:00:06 -0700
> > > David Daney <ddaney.cavm@gmail.com> wrote:
> > >
> > >> From: David Daney <david.daney@cavium.com>
> > >>
> > >> Call of_msi_map_rid() to handle mapping of the requester id.
> > >>
> > >> Signed-off-by: David Daney <david.daney@cavium.com>
> > >> ---
> > >>   drivers/irqchip/irq-gic-v3-its-pci-msi.c | 3 ++-
> > >>   1 file changed, 2 insertions(+), 1 deletion(-)
> > >>
> > >> diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
> > >> index cf351c6..8b1c938 100644
> > >> --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c
> > >> +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
> > >> @@ -86,7 +86,8 @@ static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev,
> > >>   	pci_for_each_dma_alias(pdev, its_get_pci_alias, &dev_alias);
> > >>
> > >>   	/* ITS specific DeviceID, as the core ITS ignores dev. */
> > >> -	info->scratchpad[0].ul = dev_alias.dev_id;
> > >> +	info->scratchpad[0].ul = of_msi_map_rid(dev, domain->of_node,
> > >> +						dev_alias.dev_id);
> > >>
> > >>   	return msi_info->ops->msi_prepare(domain->parent,
> > >>   					  dev, dev_alias.count, info);
> > >
> > > I really wonder if that shouldn't be part of the pci_for_each_dma_alias
> > > call. It would make a lot more sense for this functionality to be an
> > > integral part of the core code, and would probably make the integration
> > > of _IORT (which has the exact same requirements) a bit easier.
> > >
> > > Thoughts?
> > >
> > 
> > I am a proponent of pushing things like this as far into the core code 
> > as possible.  So, from that point of view, I think it would probably be 
> > a good idea.
> > 
> > I can prepare a patch that does that, but it would also be nice hear 
> > from other maintainers and get their thoughts on this.
> 
> Hmm, we use pci_for_each_dma_alias in the SMMU drivers to get the SID,
> so I'm not sure that using the MSI mapping is necessarily the right thing
> to do there. Maybe we should instead have dma_alias_to_msi_id helpers or
> something?

Yes, that's probably a sensible solution.

	M.
Robin Murphy Sept. 23, 2015, 7:23 p.m. UTC | #5
On 23/09/15 19:18, Marc Zyngier wrote:
> On Wed, 23 Sep 2015 18:52:59 +0100
> Will Deacon <will.deacon@arm.com> wrote:
>
>> On Wed, Sep 23, 2015 at 06:08:39PM +0100, David Daney wrote:
>>> On 09/23/2015 10:01 AM, Marc Zyngier wrote:
>>>> On Tue, 22 Sep 2015 17:00:06 -0700
>>>> David Daney <ddaney.cavm@gmail.com> wrote:
>>>>
>>>>> From: David Daney <david.daney@cavium.com>
>>>>>
>>>>> Call of_msi_map_rid() to handle mapping of the requester id.
>>>>>
>>>>> Signed-off-by: David Daney <david.daney@cavium.com>
>>>>> ---
>>>>>    drivers/irqchip/irq-gic-v3-its-pci-msi.c | 3 ++-
>>>>>    1 file changed, 2 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
>>>>> index cf351c6..8b1c938 100644
>>>>> --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c
>>>>> +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
>>>>> @@ -86,7 +86,8 @@ static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev,
>>>>>    	pci_for_each_dma_alias(pdev, its_get_pci_alias, &dev_alias);
>>>>>
>>>>>    	/* ITS specific DeviceID, as the core ITS ignores dev. */
>>>>> -	info->scratchpad[0].ul = dev_alias.dev_id;
>>>>> +	info->scratchpad[0].ul = of_msi_map_rid(dev, domain->of_node,
>>>>> +						dev_alias.dev_id);
>>>>>
>>>>>    	return msi_info->ops->msi_prepare(domain->parent,
>>>>>    					  dev, dev_alias.count, info);
>>>>
>>>> I really wonder if that shouldn't be part of the pci_for_each_dma_alias
>>>> call. It would make a lot more sense for this functionality to be an
>>>> integral part of the core code, and would probably make the integration
>>>> of _IORT (which has the exact same requirements) a bit easier.
>>>>
>>>> Thoughts?
>>>>
>>>
>>> I am a proponent of pushing things like this as far into the core code
>>> as possible.  So, from that point of view, I think it would probably be
>>> a good idea.
>>>
>>> I can prepare a patch that does that, but it would also be nice hear
>>> from other maintainers and get their thoughts on this.
>>
>> Hmm, we use pci_for_each_dma_alias in the SMMU drivers to get the SID,
>> so I'm not sure that using the MSI mapping is necessarily the right thing
>> to do there. Maybe we should instead have dma_alias_to_msi_id helpers or
>> something?
>
> Yes, that's probably a sensible solution.

Seconded; take a look at all the additional bus-walking 
iommu_group_get_for_pci_dev does between the call to 
pci_for_each_dma_alias and the group = iommu_group_alloc() line - I'd 
say it's only at the latter point, when there are no aliases found on 
the PCI side, that it would then need to check the external RID-SID 
mapping to see if there is any further aliasing downstream of the root 
complex (and possibly liaise with the IOMMU driver to retrieve an 
appropriate group, but let's worry about that bit later).

Robin.

>
> 	M.
>
diff mbox

Patch

diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
index cf351c6..8b1c938 100644
--- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c
+++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
@@ -86,7 +86,8 @@  static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev,
 	pci_for_each_dma_alias(pdev, its_get_pci_alias, &dev_alias);
 
 	/* ITS specific DeviceID, as the core ITS ignores dev. */
-	info->scratchpad[0].ul = dev_alias.dev_id;
+	info->scratchpad[0].ul = of_msi_map_rid(dev, domain->of_node,
+						dev_alias.dev_id);
 
 	return msi_info->ops->msi_prepare(domain->parent,
 					  dev, dev_alias.count, info);