From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from galois.linutronix.de (Galois.linutronix.de. [193.142.43.55]) by gmr-mx.google.com with ESMTPS id f31si340699lfv.11.2022.01.10.10.12.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jan 2022 10:12:47 -0800 (PST) From: Thomas Gleixner Subject: [patch] genirq/msi: Populate sysfs entry only once In-Reply-To: <20211206210749.224917330@linutronix.de> References: <20211206210600.123171746@linutronix.de> <20211206210749.224917330@linutronix.de> Date: Mon, 10 Jan 2022 19:12:45 +0100 Message-ID: <87leznqx2a.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain To: LKML Cc: Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , linux-pci@vger.kernel.org, Cedric Le Goater , xen-devel@lists.xenproject.org, Juergen Gross , Greg Kroah-Hartman , Niklas Schnelle , linux-s390@vger.kernel.org, Heiko Carstens , Christian Borntraeger , Logan Gunthorpe , Jon Mason , Dave Jiang , Allen Hubbe , linux-ntb@googlegroups.com List-ID: The MSI entries for multi-MSI are populated en bloc for the MSI descriptor, but the current code invokes the population inside the per interrupt loop which triggers a warning in the sysfs code and causes the interrupt allocation to fail. Move it outside of the loop so it works correctly for single and multi-MSI. Fixes: bf5e758f02fc ("genirq/msi: Simplify sysfs handling") Reported-by: Borislav Petkov Signed-off-by: Thomas Gleixner --- kernel/irq/msi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -887,12 +887,11 @@ int __msi_domain_alloc_irqs(struct irq_d ret = msi_init_virq(domain, virq + i, vflags); if (ret) return ret; - - if (info->flags & MSI_FLAG_DEV_SYSFS) { - ret = msi_sysfs_populate_desc(dev, desc); - if (ret) - return ret; - } + } + if (info->flags & MSI_FLAG_DEV_SYSFS) { + ret = msi_sysfs_populate_desc(dev, desc); + if (ret) + return ret; } allocated++; }