[17/20] platform-msi: Switch to the domain id aware MSI interfaces

Message ID 20221111132707.005001510@linutronix.de
State New
Headers
Series [01/20] genirq/msi: Move IRQ_DOMAIN_MSI_NOMASK_QUIRK to MSI flags |

Commit Message

Thomas Gleixner Nov. 11, 2022, 1:57 p.m. UTC
  From: Ahmed S. Darwish <darwi@linutronix.de>

Switch to the new domain id aware interfaces to phase out the previous
ones. No functional change.

Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/base/platform-msi.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Tian, Kevin Nov. 18, 2022, 8:53 a.m. UTC | #1
> From: Thomas Gleixner <tglx@linutronix.de>
> Sent: Friday, November 11, 2022 9:57 PM
> 
> From: Ahmed S. Darwish <darwi@linutronix.de>
> 
> Switch to the new domain id aware interfaces to phase out the previous
> ones. No functional change.
> 
> Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  drivers/base/platform-msi.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --- a/drivers/base/platform-msi.c
> +++ b/drivers/base/platform-msi.c
> @@ -213,7 +213,7 @@ int platform_msi_domain_alloc_irqs(struc
>  	if (err)
>  		return err;
> 
> -	err = msi_domain_alloc_irqs(dev->msi.domain, dev, nvec);
> +	err = msi_domain_alloc_irqs_range(dev, MSI_DEFAULT_DOMAIN, 0,
> nvec - 1);
>  	if (err)
>  		platform_msi_free_priv_data(dev);
> 

Out of curiosity. Why don't we provide an unlocked version of
msi_domain_alloc_irqs_all()?
  
Thomas Gleixner Nov. 18, 2022, 12:26 p.m. UTC | #2
On Fri, Nov 18 2022 at 08:53, Kevin Tian wrote:
>> From: Thomas Gleixner <tglx@linutronix.de>
>> 
>> -	err = msi_domain_alloc_irqs(dev->msi.domain, dev, nvec);
>> +	err = msi_domain_alloc_irqs_range(dev, MSI_DEFAULT_DOMAIN, 0,
>> nvec - 1);
>>  	if (err)
>>  		platform_msi_free_priv_data(dev);
>> 
>
> Out of curiosity. Why don't we provide an unlocked version of
> msi_domain_alloc_irqs_all()?

-ENOUSER
  
Tian, Kevin Nov. 21, 2022, 3:42 a.m. UTC | #3
> From: Thomas Gleixner <tglx@linutronix.de>
> Sent: Friday, November 18, 2022 8:27 PM
> 
> On Fri, Nov 18 2022 at 08:53, Kevin Tian wrote:
> >> From: Thomas Gleixner <tglx@linutronix.de>
> >>
> >> -	err = msi_domain_alloc_irqs(dev->msi.domain, dev, nvec);
> >> +	err = msi_domain_alloc_irqs_range(dev, MSI_DEFAULT_DOMAIN, 0,
> >> nvec - 1);
> >>  	if (err)
> >>  		platform_msi_free_priv_data(dev);
> >>
> >
> > Out of curiosity. Why don't we provide an unlocked version of
> > msi_domain_alloc_irqs_all()?
> 
> -ENOUSER

msi_domain_alloc_irqs() and msi_domain_alloc_irqs_descs_locked()
are a pair.

What I didn't get was why the unlocked invocation in this patch
is replaced by a range-based helper while the locked invocation
in previous patch16 was replaced by an all-based helper:

	if (domain && irq_domain_is_hierarchy(domain))
-		return msi_domain_alloc_irqs_descs_locked(domain, &dev->dev, nvec);
+		return msi_domain_alloc_irqs_all_locked(&dev->dev, MSI_DEFAULT_DOMAIN, nvec);

The reason could probably be marked out in the commit msg.
  
Thomas Gleixner Nov. 21, 2022, 10:34 a.m. UTC | #4
On Mon, Nov 21 2022 at 03:42, Kevin Tian wrote:
>> From: Thomas Gleixner <tglx@linutronix.de>
>> On Fri, Nov 18 2022 at 08:53, Kevin Tian wrote:
>> > Out of curiosity. Why don't we provide an unlocked version of
>> > msi_domain_alloc_irqs_all()?
>> 
>> -ENOUSER
>
> msi_domain_alloc_irqs() and msi_domain_alloc_irqs_descs_locked()
> are a pair.

Sure, but if there is no use case why should we provide the interface?

> What I didn't get was why the unlocked invocation in this patch
> is replaced by a range-based helper while the locked invocation
> in previous patch16 was replaced by an all-based helper:
>
> 	if (domain && irq_domain_is_hierarchy(domain))
> -		return msi_domain_alloc_irqs_descs_locked(domain, &dev->dev, nvec);
> +		return msi_domain_alloc_irqs_all_locked(&dev->dev, MSI_DEFAULT_DOMAIN, nvec);
>
> The reason could probably be marked out in the commit msg.

The point is that range based is obviously the better choice because
it's precise. Especially for domains which let the core code allocate
the MSI descriptors a precise range is required. The old interface was
kinda blury there.

In case of PCI/MSI[-X] the MSI descriptors are allocated by the PCI core
upfront and there are allocations which have gaps in the indices, so the
range is not well defined and we just keep using the existing scan all
mechanism.

Thanks,

        tglx
  

Patch

--- a/drivers/base/platform-msi.c
+++ b/drivers/base/platform-msi.c
@@ -213,7 +213,7 @@  int platform_msi_domain_alloc_irqs(struc
 	if (err)
 		return err;
 
-	err = msi_domain_alloc_irqs(dev->msi.domain, dev, nvec);
+	err = msi_domain_alloc_irqs_range(dev, MSI_DEFAULT_DOMAIN, 0, nvec - 1);
 	if (err)
 		platform_msi_free_priv_data(dev);
 
@@ -227,7 +227,7 @@  EXPORT_SYMBOL_GPL(platform_msi_domain_al
  */
 void platform_msi_domain_free_irqs(struct device *dev)
 {
-	msi_domain_free_irqs(dev->msi.domain, dev);
+	msi_domain_free_irqs_all(dev, MSI_DEFAULT_DOMAIN);
 	platform_msi_free_priv_data(dev);
 }
 EXPORT_SYMBOL_GPL(platform_msi_domain_free_irqs);