From nobody Sun Feb 8 18:18:48 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9414B27CCD0; Wed, 9 Apr 2025 18:54:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744224874; cv=none; b=ei5/am6VBQ2P19emu06r/Etl/3Uy/+CYILj7LwoTCucJbI1Yw6q9sd3palLl1rOMHPw+2iB2fvBsDYym6hhXHvdKL9QLbLTYaPk7hCYZQ/Dx5/lAdG2Q/nl8WKrDhq+ay5lynGoXRMXeB7nL6rY6OZhi7cdrSM+OTvNaXX7rCRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744224874; c=relaxed/simple; bh=ZB36i4BFClwetcSRL+tqtvCplDmplz8+1AwsRWt/JCg=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=leR2cese14goUzrLasurWpBKYMuHDs5s9Ij0grG2eWzO9tteyGzuLmxyOOtwwCGwgdgdVAXMYinwvod/+USPOsD4dYR9IeurEmdmscADo7NbOsrW4Cv7p6Or7Oyp+ZopNJ8F5yfl2El0q7XTuzSypMEOLqIODX5ixgLUpiUwyVM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=qYXeFz9D; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=sP7C5Ida; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qYXeFz9D"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sP7C5Ida" Date: Wed, 09 Apr 2025 18:54:30 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744224870; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L2khK4V/+bL/n/x7ArYBZ/IatwUBblzGq4qNd1PoXV8=; b=qYXeFz9DgeQa0ARPYhFMxVytQy+t271Tcob7RZijORe6vXXcc6mh4R5UIPgjpNzIdEr0Qy cVZKyOP83YarPatgAt8KWm/Tko/DSyYlWTQ8HeIB9pAjcxOiYAU6joJEdYAfelfHYvY7iA DY6+hgb5vlj7L1chpJHETY0eW6LOvtvWW/HKot5gmlf/3qRXpRhelI77A/EW7qKelUlqcz V1HcRc6862IZ6lBzGrRY850c2tE9WzoWmFKhW4e/t5ZMOlk2iR2ykeK3DNWRhI1iy56yT2 ebHvxWRU8mP8qPK2tZUWhpK3qxbDnEOkiI+jic+GEsTQUGpvGHcFtLPqnrLQBg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744224870; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L2khK4V/+bL/n/x7ArYBZ/IatwUBblzGq4qNd1PoXV8=; b=sP7C5Idaw3Vfqo743+lieDgP2A0hx9Cr4m0H5L5sQUxJMSZubiJgGU4WVEB4pqCHBkdB+4 3GbYKbIoOel2y1AA== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/msi] PCI/MSI: Switch msix_capability_init() to guard(msi_desc_lock) Cc: Thomas Gleixner , Bjorn Helgaas , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20250319105506.564105011@linutronix.de> References: <20250319105506.564105011@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <174422487021.31282.6683134058141552285.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the irq/msi branch of tip: Commit-ID: 891146645e5d55166847b8e004a30fb9f8b03266 Gitweb: https://git.kernel.org/tip/891146645e5d55166847b8e004a30fb9f= 8b03266 Author: Thomas Gleixner AuthorDate: Wed, 19 Mar 2025 11:56:54 +01:00 Committer: Thomas Gleixner CommitterDate: Wed, 09 Apr 2025 20:47:30 +02:00 PCI/MSI: Switch msix_capability_init() to guard(msi_desc_lock) Split the lock protected functionality of msix_capability_init() out into a helper function and use guard(msi_desc_lock) to replace the lock/unlock pair. Simplify the error path in the helper function by utilizing a custom cleanup to get rid of the remaining gotos. No functional change intended. Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Link: https://lore.kernel.org/all/20250319105506.564105011@linutronix.de --- drivers/pci/msi/msi.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 9987483..732166a 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -660,35 +660,39 @@ static void msix_mask_all(void __iomem *base, int tsi= ze) writel(ctrl, base + PCI_MSIX_ENTRY_VECTOR_CTRL); } =20 -static int msix_setup_interrupts(struct pci_dev *dev, struct msix_entry *e= ntries, - int nvec, struct irq_affinity *affd) +DEFINE_FREE(free_msi_irqs, struct pci_dev *, if (_T) pci_free_msi_irqs(_T)= ); + +static int __msix_setup_interrupts(struct pci_dev *__dev, struct msix_entr= y *entries, + int nvec, struct irq_affinity_desc *masks) { - struct irq_affinity_desc *masks __free(kfree) =3D - affd ? irq_create_affinity_masks(nvec, affd) : NULL; - int ret; + struct pci_dev *dev __free(free_msi_irqs) =3D __dev; =20 - msi_lock_descs(&dev->dev); - ret =3D msix_setup_msi_descs(dev, entries, nvec, masks); + int ret =3D msix_setup_msi_descs(dev, entries, nvec, masks); if (ret) - goto out_free; + return ret; =20 ret =3D pci_msi_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX); if (ret) - goto out_free; + return ret; =20 /* Check if all MSI entries honor device restrictions */ ret =3D msi_verify_entries(dev); if (ret) - goto out_free; + return ret; =20 msix_update_entries(dev, entries); - goto out_unlock; + retain_and_null_ptr(dev); + return 0; +} =20 -out_free: - pci_free_msi_irqs(dev); -out_unlock: - msi_unlock_descs(&dev->dev); - return ret; +static int msix_setup_interrupts(struct pci_dev *dev, struct msix_entry *e= ntries, + int nvec, struct irq_affinity *affd) +{ + struct irq_affinity_desc *masks __free(kfree) =3D + affd ? irq_create_affinity_masks(nvec, affd) : NULL; + + guard(msi_descs_lock)(&dev->dev); + return __msix_setup_interrupts(dev, entries, nvec, masks); } =20 /**