From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 648B3C433F5 for ; Thu, 16 Dec 2021 21:42:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242382AbhLPVmm (ORCPT ); Thu, 16 Dec 2021 16:42:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242091AbhLPVlI (ORCPT ); Thu, 16 Dec 2021 16:41:08 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 531A7C061395; Thu, 16 Dec 2021 13:40:54 -0800 (PST) Date: Thu, 16 Dec 2021 21:40:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1639690852; 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=1bbTw6yudEvBea+0jaULeabiyFdZItl10M8xWBll1Kk=; b=NdN8OJaJGe0yTPQQm6JEgImQ+2hgN6yacYKbX7rJjJu+5pCInoKgrRNwfv0EEGQdQ+lCrN TXhypUGIIf3Yg9htAL23qMdf8J6zaITqNevH9CiosrUBGApqtYUo8EbfL+3IsiaBcZrWc2 bFuZH7eM7Y7o///egCt6KzDlspPkcFtcRwEdGq/LGlf3Ohl7jWxax/LY8arEDjDcwikMGV GHSHbFrbPKODZTO+JZc+DkLqhhOrtXz4ZX+wS3gpMJnH/c+dnX/HrAMSkCtpjGz686PwAq wbkMnnCXKwa6tVGx6S/iNjqwpiHQS91bkypdvhw2oeelFonPr1eIUfqUetlPFQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1639690852; 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=1bbTw6yudEvBea+0jaULeabiyFdZItl10M8xWBll1Kk=; b=RvraJk/IByIV+lRQ605ZYcs+iknn0U7tzPX3dfeOZpP/Y2ypzhgOGE8fmQoVazHa0mvsM3 /nKIDmupptio1/DA== 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: Simplify pci_irq_get_affinity() Cc: Thomas Gleixner , Michael Kelley , Nishanth Menon , "Greg Kroah-Hartman" , Jason Gunthorpe , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20211210221814.900929381@linutronix.de> References: <20211210221814.900929381@linutronix.de> MIME-Version: 1.0 Message-ID: <163969085124.23020.9449077619400402764.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the irq/msi branch of tip: Commit-ID: f48235900182d64537c6e8f8dc0932b57a1a0638 Gitweb: https://git.kernel.org/tip/f48235900182d64537c6e8f8dc0932b57a1a0638 Author: Thomas Gleixner AuthorDate: Fri, 10 Dec 2021 23:19:26 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 16 Dec 2021 22:16:41 +01:00 PCI/MSI: Simplify pci_irq_get_affinity() Replace open coded MSI descriptor chasing and use the proper accessor functions instead. Signed-off-by: Thomas Gleixner Tested-by: Michael Kelley Tested-by: Nishanth Menon Reviewed-by: Greg Kroah-Hartman Reviewed-by: Jason Gunthorpe Link: https://lore.kernel.org/r/20211210221814.900929381@linutronix.de --- drivers/pci/msi/msi.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index fad3873..0909b27 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -1104,26 +1104,20 @@ EXPORT_SYMBOL(pci_irq_vector); */ const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr) { - if (dev->msix_enabled) { - struct msi_desc *entry; + int irq = pci_irq_vector(dev, nr); + struct msi_desc *desc; - for_each_pci_msi_entry(entry, dev) { - if (entry->msi_index == nr) - return &entry->affinity->mask; - } - WARN_ON_ONCE(1); + if (WARN_ON_ONCE(irq <= 0)) return NULL; - } else if (dev->msi_enabled) { - struct msi_desc *entry = first_pci_msi_entry(dev); - - if (WARN_ON_ONCE(!entry || !entry->affinity || - nr >= entry->nvec_used)) - return NULL; - return &entry->affinity[nr].mask; - } else { + desc = irq_get_msi_desc(irq); + /* Non-MSI does not have the information handy */ + if (!desc) return cpu_possible_mask; - } + + if (WARN_ON_ONCE(!desc->affinity)) + return NULL; + return &desc->affinity[nr].mask; } EXPORT_SYMBOL(pci_irq_get_affinity);