2022-12-13 14:30:35

by Johan Hovold

[permalink] [raw]
Subject: [PATCH 2/2] genirq/irqdomain/msi: Add irq_domain_alloc_irqs_affinity() wrapper

The full __irq_domain_alloc_irqs() interface was initially only intended
for some legacy (x86) use cases while most callers should use the
irq_domain_alloc_irqs() wrapper.

Add a matching irq_domain_alloc_irqs_affinity() wrapper that can be used
when an affinity hint needs to be provided and use it for MSI
allocations.

Signed-off-by: Johan Hovold <[email protected]>
---
include/linux/irqdomain.h | 15 +++++++++++++++
kernel/irq/msi.c | 6 +++---
2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index cad47737a052..b1b06d75d31a 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -507,6 +507,14 @@ static inline int irq_domain_alloc_irqs(struct irq_domain *domain,
NULL);
}

+static inline int irq_domain_alloc_irqs_affinity(struct irq_domain *domain,
+ unsigned int nr_irqs, int node, void *arg,
+ const struct irq_affinity_desc *affinity)
+{
+ return __irq_domain_alloc_irqs(domain, -1, nr_irqs, node, arg, false,
+ affinity);
+}
+
extern int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain,
unsigned int irq_base,
unsigned int nr_irqs, void *arg);
@@ -585,6 +593,13 @@ static inline int irq_domain_alloc_irqs(struct irq_domain *domain,
return -1;
}

+static inline int irq_domain_alloc_irqs_affinity(struct irq_domain *domain,
+ unsigned int nr_irqs, int node, void *arg,
+ const struct irq_affinity_desc *affinity)
+{
+ return -1;
+}
+
static inline void irq_domain_free_irqs(unsigned int virq,
unsigned int nr_irqs) { }

diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index bd4d4dd626b4..01f7f3c8d77a 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -1272,9 +1272,9 @@ static int __msi_domain_alloc_irqs(struct device *dev, struct irq_domain *domain

ops->set_desc(&arg, desc);

- virq = __irq_domain_alloc_irqs(domain, -1, desc->nvec_used,
- dev_to_node(dev), &arg, false,
- desc->affinity);
+ virq = irq_domain_alloc_irqs_affinity(domain, desc->nvec_used,
+ dev_to_node(dev), &arg,
+ desc->affinity);
if (virq < 0)
return msi_handle_pci_fail(domain, desc, allocated);

--
2.37.4


2023-01-11 19:51:42

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH 2/2] genirq/irqdomain/msi: Add irq_domain_alloc_irqs_affinity() wrapper

On Tue, Dec 13 2022 at 15:08, Johan Hovold wrote:
> The full __irq_domain_alloc_irqs() interface was initially only intended
> for some legacy (x86) use cases while most callers should use the
> irq_domain_alloc_irqs() wrapper.
>
> Add a matching irq_domain_alloc_irqs_affinity() wrapper that can be used
> when an affinity hint needs to be provided and use it for MSI
> allocations.

I definitely like the irqchip cleanup, but this one is core code and
having the extra wrapper is not really buying us much.

Thanks,

tglx

2023-01-12 14:04:45

by Johan Hovold

[permalink] [raw]
Subject: Re: [PATCH 2/2] genirq/irqdomain/msi: Add irq_domain_alloc_irqs_affinity() wrapper

On Wed, Jan 11, 2023 at 07:52:42PM +0100, Thomas Gleixner wrote:
> On Tue, Dec 13 2022 at 15:08, Johan Hovold wrote:
> > The full __irq_domain_alloc_irqs() interface was initially only intended
> > for some legacy (x86) use cases while most callers should use the
> > irq_domain_alloc_irqs() wrapper.
> >
> > Add a matching irq_domain_alloc_irqs_affinity() wrapper that can be used
> > when an affinity hint needs to be provided and use it for MSI
> > allocations.
>
> I definitely like the irqchip cleanup, but this one is core code and
> having the extra wrapper is not really buying us much.

Fair enough. If you don't expect there to be any further users then
perhaps it's not worth it even if it arguably makes the call site a bit
more readable (e.g. by dropping the base and realloc arguments).

Johan

2023-01-12 14:05:06

by Johan Hovold

[permalink] [raw]
Subject: Re: [PATCH 2/2] genirq/irqdomain/msi: Add irq_domain_alloc_irqs_affinity() wrapper

On Thu, Jan 12, 2023 at 02:24:58PM +0100, Johan Hovold wrote:
> On Wed, Jan 11, 2023 at 07:52:42PM +0100, Thomas Gleixner wrote:
> > On Tue, Dec 13 2022 at 15:08, Johan Hovold wrote:
> > > The full __irq_domain_alloc_irqs() interface was initially only intended
> > > for some legacy (x86) use cases while most callers should use the
> > > irq_domain_alloc_irqs() wrapper.
> > >
> > > Add a matching irq_domain_alloc_irqs_affinity() wrapper that can be used
> > > when an affinity hint needs to be provided and use it for MSI
> > > allocations.
> >
> > I definitely like the irqchip cleanup, but this one is core code and
> > having the extra wrapper is not really buying us much.
>
> Fair enough. If you don't expect there to be any further users then
> perhaps it's not worth it even if it arguably makes the call site a bit
> more readable (e.g. by dropping the base and realloc arguments).

And having this wrapper would also limit the use of the full (internal)
helper to places that actually need the realloc parameter (e.g. making
those stand out more).

Johan