Re: [patch 03/10] genirq/msi: Make MSI descriptor alloc/free ready for range allocations

From: Thomas Gleixner
Date: Sun Nov 28 2021 - 14:20:03 EST


On Sun, Nov 28 2021 at 15:57, Marc Zyngier wrote:
> On Sat, 27 Nov 2021 01:24:34 +0000,
> Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> The issue seems to be originating in the previous patch, where the
> following line was added:
>
> + struct msi_range range = { .first = 0, .last = UINT_MAX, .ndesc = nvec, };
>
> In that context, only 'ndesc' was used, and that was fine.
>
> However, in the current patch, ndesc use is removed, only first/last
> are considered, and UINT_MAX is... a lot of MSIs.
>
> This fixes it:
>
> diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
> index bef5b74a7268..a520bfd94a56 100644
> --- a/kernel/irq/msi.c
> +++ b/kernel/irq/msi.c
> @@ -975,7 +975,7 @@ int msi_domain_alloc_irqs_descs_locked(struct irq_domain *domain, struct device
> */
> int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, int nvec)
> {
> - struct msi_range range = { .first = 0, .last = UINT_MAX, .ndesc = nvec, };
> + struct msi_range range = { .first = 0, .last = nvec - 1, .ndesc = nvec, };
> int ret;
>
> msi_lock_descs(dev);
>
> However, it'd be good to clarify the use of range->ndesc.

Hrm. The stupid search should terminated nevertheless. Let me stare at
it again.

>> -static int msi_add_simple_msi_descs(struct device *dev, unsigned int index, unsigned int ndesc)
>> +static int msi_add_simple_msi_descs(struct device *dev, struct msi_range *range)
>
> nit: most of the functions changed in this patch need to have their
> documentation tidied up.

Duh, yes.

Thanks,

tglx