From patchwork Sat Nov 27 01:24:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12642095 X-Patchwork-Delegate: bhelgaas@google.com 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 98E59C4332F for ; Sat, 27 Nov 2021 02:17:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229697AbhK0CUO (ORCPT ); Fri, 26 Nov 2021 21:20:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230193AbhK0CSN (ORCPT ); Fri, 26 Nov 2021 21:18:13 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 847CDC08EC1F; Fri, 26 Nov 2021 17:31:43 -0800 (PST) Message-ID: <20211127000918.534790941@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976272; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=FLvm8heMaeaty/kI8f2vBLPLCFbQls4zKlJo+z99yXU=; b=lLwdFr2xpc7l1dE+4T8c1MEKxJXFHIuawpdbeLObZ4rSaOX110baGDslF/rOU9wDbvXSVb 9FwK80ttcZC8FgPdvRGW7y+G22X8ncPFzpiSbdXExua+JKuSc4E2bG1vBFN78+SwFYmocu i4eGI4fj8p39sd3rd6Ikj8XDkzYWruMiT/gYryLTYgCEbJIM9Ls+cqlNHwu16K+5dQ/V0s 4Jni/zQOIv0JeWnIL4L/IqKFWqWgoygRU5fSIYZYHv4gyS/8gekFSB4AkkbcfaAi6tmBvg cxy9ZrieNVf0BFY+uwSNchlatRpkrPSBy8I+FDfJxHsLOviNLiig21t6lXu8gQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976272; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=FLvm8heMaeaty/kI8f2vBLPLCFbQls4zKlJo+z99yXU=; b=33qL6FsZitG3y1vbXi3dduciYhZhSt51lSZUkO/B+lH+mEZreTJcZXMUe4QnrCYqlPVu8j IM/59Op77c6+5+AQ== From: Thomas Gleixner To: LKML Cc: Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , Michael Ellerman , Andrew Cooper , Juergen Gross , linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [patch 01/10] genirq/msi: Add range argument to alloc/free MSI domain ops References: <20211126233124.618283684@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:24:31 +0100 (CET) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org In preparation for supporting range allocations for MSI-X, add a range argument to the MSI domain alloc/free function pointers and fixup all affected places. The range is supplied via a pointer to a struct msi_range which contains the first and last MSI index and the number of vectors to allocate/free. To support the sparse MSI-X allocations via pci_enable_msix_range() and pci_enable_msix_exact() the number of vectors can be smaller than the range defined by the first and last MSI index. This can be cleaned up later once the code is converted by converting these sparse allocations to an initial allocation on enable and expansion of the vector space at the required indices. Signed-off-by: Thomas Gleixner --- arch/powerpc/platforms/pseries/msi.c | 6 +++--- arch/x86/pci/xen.c | 10 +++++----- include/linux/msi.h | 30 +++++++++++++++++++++++------- kernel/irq/msi.c | 12 ++++++------ 4 files changed, 37 insertions(+), 21 deletions(-) --- a/arch/powerpc/platforms/pseries/msi.c +++ b/arch/powerpc/platforms/pseries/msi.c @@ -450,13 +450,13 @@ static void pseries_msi_ops_msi_free(str * RTAS can not disable one MSI at a time. It's all or nothing. Do it * at the end after all IRQs have been freed. */ -static void pseries_msi_domain_free_irqs(struct irq_domain *domain, - struct device *dev) +static void pseries_msi_domain_free_irqs(struct irq_domain *domain, struct device *dev, + struct msi_range *range) { if (WARN_ON_ONCE(!dev_is_pci(dev))) return; - __msi_domain_free_irqs(domain, dev); + __msi_domain_free_irqs(domain, dev, range); rtas_disable_msi(to_pci_dev(dev)); } --- a/arch/x86/pci/xen.c +++ b/arch/x86/pci/xen.c @@ -407,8 +407,8 @@ static void xen_pv_teardown_msi_irqs(str xen_teardown_msi_irqs(dev); } -static int xen_msi_domain_alloc_irqs(struct irq_domain *domain, - struct device *dev, int nvec) +static int xen_msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, + struct msi_range *range) { int type; @@ -420,11 +420,11 @@ static int xen_msi_domain_alloc_irqs(str else type = PCI_CAP_ID_MSI; - return xen_msi_ops.setup_msi_irqs(to_pci_dev(dev), nvec, type); + return xen_msi_ops.setup_msi_irqs(to_pci_dev(dev), range->ndesc, type); } -static void xen_msi_domain_free_irqs(struct irq_domain *domain, - struct device *dev) +static void xen_msi_domain_free_irqs(struct irq_domain *domain, struct device *dev, + struct msi_range *range) { if (WARN_ON_ONCE(!dev_is_pci(dev))) return; --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -191,6 +191,23 @@ struct msi_device_data { enum msi_desc_filter __iter_filter; }; +/** + * msi_range - Descriptor for a MSI index range + * @first: First index + * @last: Last index (inclusive) + * @ndesc: Number of descriptors for allocations + * + * @first = 0 and @last = UINT_MAX is the full range for an operation. + * + * Note: @ndesc can be less than the range defined by @first and @last to + * support sparse allocations from PCI/MSI-X. + */ +struct msi_range { + unsigned int first; + unsigned int last; + unsigned int ndesc; +}; + int msi_setup_device_data(struct device *dev); /* MSI device properties */ @@ -415,10 +432,10 @@ struct msi_domain_ops { msi_alloc_info_t *arg); void (*set_desc)(msi_alloc_info_t *arg, struct msi_desc *desc); - int (*domain_alloc_irqs)(struct irq_domain *domain, - struct device *dev, int nvec); - void (*domain_free_irqs)(struct irq_domain *domain, - struct device *dev); + int (*domain_alloc_irqs)(struct irq_domain *domain, struct device *dev, + struct msi_range *range); + void (*domain_free_irqs)(struct irq_domain *domain, struct device *dev, + struct msi_range *range); }; /** @@ -484,13 +501,12 @@ int msi_domain_set_affinity(struct irq_d struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode, struct msi_domain_info *info, struct irq_domain *parent); -int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, - int nvec); +int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, struct msi_range *range); int msi_domain_alloc_irqs_descs_locked(struct irq_domain *domain, struct device *dev, int nvec); int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, int nvec); -void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev); +void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev, struct msi_range *range); void msi_domain_free_irqs_descs_locked(struct irq_domain *domain, struct device *dev); void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev); struct msi_domain_info *msi_get_domain_info(struct irq_domain *domain); --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -869,8 +869,7 @@ static int msi_init_virq(struct irq_doma return 0; } -int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, - int nvec) +int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, struct msi_range *range) { struct msi_domain_info *info = domain->host_data; struct msi_domain_ops *ops = info->ops; @@ -880,7 +879,7 @@ int __msi_domain_alloc_irqs(struct irq_d int allocated = 0; int i, ret, virq; - ret = msi_domain_prepare_irqs(domain, dev, nvec, &arg); + ret = msi_domain_prepare_irqs(domain, dev, range->ndesc, &arg); if (ret) return ret; @@ -960,6 +959,7 @@ int msi_domain_alloc_irqs_descs_locked(s int nvec) { struct msi_domain_info *info = domain->host_data; + struct msi_range range = { .ndesc = nvec }; struct msi_domain_ops *ops = info->ops; int ret; @@ -969,7 +969,7 @@ int msi_domain_alloc_irqs_descs_locked(s if (ret) return ret; - ret = ops->domain_alloc_irqs(domain, dev, nvec); + ret = ops->domain_alloc_irqs(domain, dev, &range); if (ret) msi_domain_free_irqs_descs_locked(domain, dev); return ret; @@ -994,7 +994,7 @@ int msi_domain_alloc_irqs(struct irq_dom return ret; } -void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev) +void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev, struct msi_range *range) { struct msi_domain_info *info = domain->host_data; struct irq_data *irqd; @@ -1041,7 +1041,7 @@ void msi_domain_free_irqs_descs_locked(s lockdep_assert_held(&dev->msi.data->mutex); - ops->domain_free_irqs(domain, dev); + ops->domain_free_irqs(domain, dev, NULL); msi_domain_free_msi_descs(info, dev); } From patchwork Sat Nov 27 01:24:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12642081 X-Patchwork-Delegate: bhelgaas@google.com 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 8818DC433EF for ; Sat, 27 Nov 2021 01:33:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351876AbhK0Bg7 (ORCPT ); Fri, 26 Nov 2021 20:36:59 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:40722 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350533AbhK0Be6 (ORCPT ); Fri, 26 Nov 2021 20:34:58 -0500 Message-ID: <20211127000918.594818541@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=EW+Gm4C9srsYC5SImaDJkppoIX48hbwPcUobStKFJEM=; b=ba0qGeiB41JUVA/nbXIZqI/ZzR+lBVMsJEDx5NRNT/VAMjLuu4gdSY/IW2XqyTiCDLdfWK AQojkSzf0utkC0bMvnh29aBEv80K2O2wGaYj6Aba7BmI3wxtr19BQARnAuvbb1iEcFmo6I hlDD4BF/OfoIMuJ2s540besiWNAKWIpBGrHUFqoqUKXdsLvTElmNbz3nO/aZYfFyRcip8+ EyAKNeFCcDrle450/Hx6NPInjM4wsqaFaUZ62JFjd2yxuWSRw0kkEbA6kTiDYHUWYhGPEY M30MNH/ErWNFGfXjykXzp8rnRca9Xg4qCwqGov4eS+2PP6X9zLCe0KqcivXq9A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=EW+Gm4C9srsYC5SImaDJkppoIX48hbwPcUobStKFJEM=; b=HOol/oYi7k4NJTRqZmozHsVnqCuHGZv01jWHIiq8+jdIzZ0IwgPtzldd7npF1ZckQ/Ku5Z mXV0fPjO/GkB7DCA== From: Thomas Gleixner To: LKML Cc: Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , Michael Ellerman , Andrew Cooper , Juergen Gross , linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [patch 02/10] genirq/msi: Add range argument to msi_domain_alloc/free_descs_locked() References: <20211126233124.618283684@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:24:33 +0100 (CET) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org In preparation for supporting range allocations for MSI-X, add a range argument to the msi_domain_alloc/free_descs_locked() functions and fixup all affected places. Hand in ranges which are covering the current use case. They will be refined in later steps. Signed-off-by: Thomas Gleixner --- drivers/pci/msi/irqdomain.c | 6 ++++-- include/linux/msi.h | 5 ++--- kernel/irq/msi.c | 21 ++++++++++++--------- 3 files changed, 18 insertions(+), 14 deletions(-) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -10,22 +10,24 @@ int pci_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) { + struct msi_range range = { .first = 0, .last = UINT_MAX, .ndesc = nvec}; struct irq_domain *domain; domain = dev_get_msi_domain(&dev->dev); if (domain && irq_domain_is_hierarchy(domain)) - return msi_domain_alloc_irqs_descs_locked(domain, &dev->dev, nvec); + return msi_domain_alloc_irqs_descs_locked(domain, &dev->dev, &range); return pci_msi_legacy_setup_msi_irqs(dev, nvec, type); } void pci_msi_teardown_msi_irqs(struct pci_dev *dev) { + struct msi_range range = { .first = 0, .last = UINT_MAX, }; struct irq_domain *domain; domain = dev_get_msi_domain(&dev->dev); if (domain && irq_domain_is_hierarchy(domain)) - msi_domain_free_irqs_descs_locked(domain, &dev->dev); + msi_domain_free_irqs_descs_locked(domain, &dev->dev, &range); else pci_msi_legacy_teardown_msi_irqs(dev); } --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -502,12 +502,11 @@ struct irq_domain *msi_create_irq_domain struct msi_domain_info *info, struct irq_domain *parent); int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, struct msi_range *range); -int msi_domain_alloc_irqs_descs_locked(struct irq_domain *domain, struct device *dev, - int nvec); +int msi_domain_alloc_irqs_descs_locked(struct irq_domain *domain, struct device *dev, struct msi_range *range); int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, int nvec); void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev, struct msi_range *range); -void msi_domain_free_irqs_descs_locked(struct irq_domain *domain, struct device *dev); +void msi_domain_free_irqs_descs_locked(struct irq_domain *domain, struct device *dev, struct msi_range *range); void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev); struct msi_domain_info *msi_get_domain_info(struct irq_domain *domain); --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -956,22 +956,21 @@ static int msi_domain_add_simple_msi_des * Return: %0 on success or an error code. */ int msi_domain_alloc_irqs_descs_locked(struct irq_domain *domain, struct device *dev, - int nvec) + struct msi_range *range) { struct msi_domain_info *info = domain->host_data; - struct msi_range range = { .ndesc = nvec }; struct msi_domain_ops *ops = info->ops; int ret; lockdep_assert_held(&dev->msi.data->mutex); - ret = msi_domain_add_simple_msi_descs(info, dev, nvec); + ret = msi_domain_add_simple_msi_descs(info, dev, range->ndesc); if (ret) return ret; - ret = ops->domain_alloc_irqs(domain, dev, &range); + ret = ops->domain_alloc_irqs(domain, dev, range); if (ret) - msi_domain_free_irqs_descs_locked(domain, dev); + msi_domain_free_irqs_descs_locked(domain, dev, range); return ret; } @@ -986,10 +985,11 @@ int msi_domain_alloc_irqs_descs_locked(s */ 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, }; int ret; msi_lock_descs(dev); - ret = msi_domain_alloc_irqs_descs_locked(domain, dev, nvec); + ret = msi_domain_alloc_irqs_descs_locked(domain, dev, &range); msi_unlock_descs(dev); return ret; } @@ -1034,14 +1034,15 @@ static void msi_domain_free_msi_descs(st * pair. Use this for MSI irqdomains which implement their own vector * allocation. */ -void msi_domain_free_irqs_descs_locked(struct irq_domain *domain, struct device *dev) +void msi_domain_free_irqs_descs_locked(struct irq_domain *domain, struct device *dev, + struct msi_range *range) { struct msi_domain_info *info = domain->host_data; struct msi_domain_ops *ops = info->ops; lockdep_assert_held(&dev->msi.data->mutex); - ops->domain_free_irqs(domain, dev, NULL); + ops->domain_free_irqs(domain, dev, range); msi_domain_free_msi_descs(info, dev); } @@ -1053,8 +1054,10 @@ void msi_domain_free_irqs_descs_locked(s */ void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev) { + struct msi_range range = { .first = 0, .last = UINT_MAX, }; + msi_lock_descs(dev); - msi_domain_free_irqs_descs_locked(domain, dev); + msi_domain_free_irqs_descs_locked(domain, dev, &range); msi_unlock_descs(dev); } From patchwork Sat Nov 27 01:24:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12642083 X-Patchwork-Delegate: bhelgaas@google.com 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 28639C433EF for ; Sat, 27 Nov 2021 01:33:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351973AbhK0BhD (ORCPT ); Fri, 26 Nov 2021 20:37:03 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:40724 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345991AbhK0BfC (ORCPT ); Fri, 26 Nov 2021 20:35:02 -0500 Message-ID: <20211127000918.664542907@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976275; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=rrdNHJUyUgKyNz6Pbn0ws4hWiMPwwbNMnZ1F31AYBD0=; b=MarT9tzc3uD/IHylu0qgFMXJqCIRF9E81IK9oU/QSiHl//TLD0MlLLyVDHc3E7fdnFbWu4 jNajrFTveOc0UcHgHrFVYFiOkVWUcp3VDcqqQXPjZNVJR5XW50P58xX/SZg2KrTAsXpTtY Tx+yiPXnYoApeFdOBCHvl1LeKN2JqGWS+8oSh99qUDZtlKU0CvhJVcdO1Ig3H9Vvi7C6vm Kbuso6YgToHZ6EpxYMF78Igydg+8TrnH0g8uLD1WNk02H7AaNPPJZHQyTMgOO2HrkZQhcQ qo2f721FKRrB+prTdNZtaax2ROXufT5XV4IAi0xugE7NPJhFzBmGup8OcxopZw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976275; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=rrdNHJUyUgKyNz6Pbn0ws4hWiMPwwbNMnZ1F31AYBD0=; b=z83mpLTnkklHBxL+vHIMKuuahXOWE70VTpa6amHX4Jp0eBu+uIRunBrhjFfksl44tytuvK ibg2EKm4G97OPyCw== From: Thomas Gleixner To: LKML Cc: Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , Michael Ellerman , Andrew Cooper , Juergen Gross , linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [patch 03/10] genirq/msi: Make MSI descriptor alloc/free ready for range allocations References: <20211126233124.618283684@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:24:34 +0100 (CET) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Convert the MSI descriptor related functions to ranges and fixup the call sites. Signed-off-by: Thomas Gleixner --- drivers/base/platform-msi.c | 3 ++- include/linux/msi.h | 7 ++++--- kernel/irq/msi.c | 38 +++++++++++++++++++------------------- 3 files changed, 25 insertions(+), 23 deletions(-) --- a/drivers/base/platform-msi.c +++ b/drivers/base/platform-msi.c @@ -320,11 +320,12 @@ struct irq_domain * void platform_msi_device_domain_free(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs) { + struct msi_range range = { .first = virq, .last = virq + nr_irqs - 1, }; struct platform_msi_priv_data *data = domain->host_data; msi_lock_descs(data->dev); irq_domain_free_irqs_common(domain, virq, nr_irqs); - msi_free_msi_descs_range(data->dev, MSI_DESC_ALL, virq, nr_irqs); + msi_free_msi_descs_range(data->dev, MSI_DESC_ALL, &range); msi_unlock_descs(data->dev); } --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -321,8 +321,7 @@ static inline void pci_write_msi_msg(uns #endif /* CONFIG_PCI_MSI */ int msi_add_msi_desc(struct device *dev, struct msi_desc *init_desc); -void msi_free_msi_descs_range(struct device *dev, enum msi_desc_filter filter, - unsigned int base_index, unsigned int ndesc); +void msi_free_msi_descs_range(struct device *dev, enum msi_desc_filter filter, struct msi_range *range); /** * msi_free_msi_descs - Free MSI descriptors of a device @@ -330,7 +329,9 @@ void msi_free_msi_descs_range(struct dev */ static inline void msi_free_msi_descs(struct device *dev) { - msi_free_msi_descs_range(dev, MSI_DESC_ALL, 0, UINT_MAX); + struct msi_range range = { .first = 0, .last = UINT_MAX, }; + + msi_free_msi_descs_range(dev, MSI_DESC_ALL, &range); } void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg); --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -101,19 +101,19 @@ int msi_add_msi_desc(struct device *dev, * * Return: 0 on success or an appropriate failure code. */ -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) { struct msi_desc *desc; - unsigned long i; + unsigned long idx; int ret; lockdep_assert_held(&dev->msi.data->mutex); - for (i = 0; i < ndesc; i++) { + for (idx = range->first; idx <= range->last; idx++) { desc = msi_alloc_desc(dev, 1, NULL); if (!desc) goto fail_mem; - ret = msi_insert_desc(dev->msi.data, desc, index + i); + ret = msi_insert_desc(dev->msi.data, desc, idx); if (ret) goto fail; } @@ -122,7 +122,7 @@ static int msi_add_simple_msi_descs(stru fail_mem: ret = -ENOMEM; fail: - msi_free_msi_descs_range(dev, MSI_DESC_NOTASSOCIATED, index, ndesc); + msi_free_msi_descs_range(dev, MSI_DESC_NOTASSOCIATED, range); return ret; } @@ -148,14 +148,14 @@ static bool msi_desc_match(struct msi_de * @ndesc: Number of descriptors to free */ void msi_free_msi_descs_range(struct device *dev, enum msi_desc_filter filter, - unsigned int base_index, unsigned int ndesc) + struct msi_range *range) { struct msi_desc *desc; unsigned long idx; lockdep_assert_held(&dev->msi.data->mutex); - xa_for_each_range(&dev->msi.data->store, idx, desc, base_index, base_index + ndesc - 1) { + xa_for_each_range(&dev->msi.data->store, idx, desc, range->first, range->last) { if (msi_desc_match(desc, filter)) { xa_erase(&dev->msi.data->store, idx); msi_free_desc(desc); @@ -746,17 +746,18 @@ int msi_domain_prepare_irqs(struct irq_d int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev, int virq_base, int nvec, msi_alloc_info_t *arg) { + struct msi_range range = { .first = virq_base, .last = virq_base + nvec - 1 }; struct msi_domain_info *info = domain->host_data; struct msi_domain_ops *ops = info->ops; struct msi_desc *desc; int ret, virq; msi_lock_descs(dev); - ret = msi_add_simple_msi_descs(dev, virq_base, nvec); + ret = msi_add_simple_msi_descs(dev, &range); if (ret) goto unlock; - for (virq = virq_base; virq < virq_base + nvec; virq++) { + for (virq = range.first; virq <= range.last; virq++) { desc = xa_load(&dev->msi.data->store, virq); desc->irq = virq; @@ -773,7 +774,7 @@ int msi_domain_populate_irqs(struct irq_ fail: for (--virq; virq >= virq_base; virq--) irq_domain_free_irqs_common(domain, virq, 1); - msi_free_msi_descs_range(dev, MSI_DESC_ALL, virq_base, nvec); + msi_free_msi_descs_range(dev, MSI_DESC_ALL, &range); unlock: msi_unlock_descs(dev); return ret; @@ -932,14 +933,13 @@ int __msi_domain_alloc_irqs(struct irq_d return 0; } -static int msi_domain_add_simple_msi_descs(struct msi_domain_info *info, - struct device *dev, - unsigned int num_descs) +static int msi_domain_add_simple_msi_descs(struct msi_domain_info *info, struct device *dev, + struct msi_range *range) { if (!(info->flags & MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS)) return 0; - return msi_add_simple_msi_descs(dev, 0, num_descs); + return msi_add_simple_msi_descs(dev, range); } /** @@ -964,7 +964,7 @@ int msi_domain_alloc_irqs_descs_locked(s lockdep_assert_held(&dev->msi.data->mutex); - ret = msi_domain_add_simple_msi_descs(info, dev, range->ndesc); + ret = msi_domain_add_simple_msi_descs(info, dev, range); if (ret) return ret; @@ -1017,11 +1017,11 @@ void __msi_domain_free_irqs(struct irq_d } } -static void msi_domain_free_msi_descs(struct msi_domain_info *info, - struct device *dev) +static void msi_domain_free_msi_descs(struct msi_domain_info *info, struct device *dev, + struct msi_range *range) { if (info->flags & MSI_FLAG_FREE_MSI_DESCS) - msi_free_msi_descs(dev); + msi_free_msi_descs_range(dev, MSI_DESC_ALL, range); } /** @@ -1043,7 +1043,7 @@ void msi_domain_free_irqs_descs_locked(s lockdep_assert_held(&dev->msi.data->mutex); ops->domain_free_irqs(domain, dev, range); - msi_domain_free_msi_descs(info, dev); + msi_domain_free_msi_descs(info, dev, range); } /** From patchwork Sat Nov 27 01:25:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12642089 X-Patchwork-Delegate: bhelgaas@google.com 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 D13FEC433EF for ; Sat, 27 Nov 2021 01:34:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229994AbhK0BhV (ORCPT ); Fri, 26 Nov 2021 20:37:21 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:40750 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239833AbhK0BfU (ORCPT ); Fri, 26 Nov 2021 20:35:20 -0500 Message-ID: <20211127000918.723637256@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976304; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=wAZLS4DVWG/31wPrjnVkWgrCpcsyPlNJgofX29BhKpw=; b=US7UNPS+NXprP3fC+BqxW5rKcXZSUWRgYEei1kp1cCjbCMj3u+ySTjRvZnXM2ceKo4onbi DdeUZvv7ATkP7ocNNn103LksVWfjm5uN9xsMKNKUkJ5r7sAXBwyi3mWHJUGAYCIKsxFF8W zeL8yJWHe6fOAHY3g1/48EOhvZlfjNp/xG9NYWpzEZ3rn98/Ofvp3DTasIjXlw2cK2wMds TqzUkjIiplaZtF10uMqyFnaMhAQOSsF6MZzpiHysW2poqTq6yZnmBnI89SRY6U/PvhxBa9 +2GTvPrB5USmFIGIwqM5iNn3fQxU8Z4UCD6VIYJcstNKx8rpJV4CIsc0NRThdA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976304; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=wAZLS4DVWG/31wPrjnVkWgrCpcsyPlNJgofX29BhKpw=; b=5hog39uj/8+DNtMBKVJ45GPgya8dS0p++jg39/Ye2fIq1TOglsCWtkpKvp9KVSipqhlIKT vEZHhZd84iLgrSBQ== From: Thomas Gleixner To: LKML Cc: Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , Michael Ellerman , Andrew Cooper , Juergen Gross , linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [patch 04/10] genirq/msi: Prepare MSI domain alloc/free for range irq allocation References: <20211126233124.618283684@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:25:03 +0100 (CET) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Make the iterators in the allocation and free functions range based. Signed-off-by: Thomas Gleixner --- kernel/irq/msi.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -877,6 +877,7 @@ int __msi_domain_alloc_irqs(struct irq_d msi_alloc_info_t arg = { }; unsigned int vflags = 0; struct msi_desc *desc; + unsigned long idx; int allocated = 0; int i, ret, virq; @@ -906,7 +907,10 @@ int __msi_domain_alloc_irqs(struct irq_d vflags |= VIRQ_NOMASK_QUIRK; } - msi_for_each_desc(desc, dev, MSI_DESC_NOTASSOCIATED) { + xa_for_each_range(&dev->msi.data->store, idx, desc, range->first, range->last) { + if (!msi_desc_match(desc, MSI_DESC_NOTASSOCIATED)) + continue; + ops->set_desc(&arg, desc); virq = __irq_domain_alloc_irqs(domain, -1, desc->nvec_used, @@ -999,10 +1003,14 @@ void __msi_domain_free_irqs(struct irq_d struct msi_domain_info *info = domain->host_data; struct irq_data *irqd; struct msi_desc *desc; + unsigned long idx; int i; /* Only handle MSI entries which have an interrupt associated */ - msi_for_each_desc(desc, dev, MSI_DESC_ASSOCIATED) { + xa_for_each_range(&dev->msi.data->store, idx, desc, range->first, range->last) { + if (!msi_desc_match(desc, MSI_DESC_ASSOCIATED)) + continue; + /* Make sure all interrupts are deactivated */ for (i = 0; i < desc->nvec_used; i++) { irqd = irq_domain_get_irq_data(domain, desc->irq + i); From patchwork Sat Nov 27 01:24:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12642097 X-Patchwork-Delegate: bhelgaas@google.com 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 3403FC433F5 for ; Sat, 27 Nov 2021 02:18:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237612AbhK0CVz (ORCPT ); Fri, 26 Nov 2021 21:21:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244994AbhK0CTz (ORCPT ); Fri, 26 Nov 2021 21:19:55 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F087C08EC36; Fri, 26 Nov 2021 17:31:50 -0800 (PST) Message-ID: <20211127000918.779751933@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=CFmm+AWRwXcJQSLL7VY9/FlDxYE98PyZd7GrvqHxiD8=; b=e24VzNipUk4hxg1PHC6IAXr9weR7Gc/SoXDfA3RHuL3eUYXW0KQ0vmOx1Rup57wdQ4/c0M j0SsM53zaTsEp+xcsTJcjjvt9idxHze65/F9ku69wsdFH4O1IR3xnNt1kBpYgjtuq1EJx3 G4+8DqRMVr0EurGDQTIs906q+2dXCPyTndaD2DMJHPeXSLph/ufoqB5pa8guu1m5SJm17L kBtRWLOCwVpFplTZ//BIVum2PpChXwXEF/pgcDF3hqzjYmEihoy8xv/uTBJ/AHXGcWoyWZ FCUJcprzFqND4a981S/J+eyIOTEK4LUqOJJk4OnVzXGII9RmrCOyMXoWJHxGBg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=CFmm+AWRwXcJQSLL7VY9/FlDxYE98PyZd7GrvqHxiD8=; b=gCM9TtH7kdRRuRtrS2dC9nAFXYnyiZU34H6DDhO0H4O61lGny8X8mQzTO3e0hAM5LNj6ef CHes+qC3TZO1npAA== From: Thomas Gleixner To: LKML Cc: Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , Michael Ellerman , Andrew Cooper , Juergen Gross , linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [patch 05/10] genirq/msi: Add domain info flag MSI_FLAG_CAN_EXPAND References: <20211126233124.618283684@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:24:37 +0100 (CET) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Not all MSI domains support runtime expansions of PCI/MSI-X vectors. Add a domain flag so implementations can opt in. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 2 ++ 1 file changed, 2 insertions(+) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -494,6 +494,8 @@ enum { MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS = (1 << 9), /* Free MSI descriptors */ MSI_FLAG_FREE_MSI_DESCS = (1 << 10), + /* MSI vectors can be expanded after initial setup */ + MSI_FLAG_CAN_EXPAND = (1 << 11), }; int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask, From patchwork Sat Nov 27 01:24:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12642099 X-Patchwork-Delegate: bhelgaas@google.com 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 5BA81C433EF for ; Sat, 27 Nov 2021 02:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244994AbhK0CV7 (ORCPT ); Fri, 26 Nov 2021 21:21:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349249AbhK0CT6 (ORCPT ); Fri, 26 Nov 2021 21:19:58 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 633DFC08EC38; Fri, 26 Nov 2021 17:31:51 -0800 (PST) Message-ID: <20211127000918.836550402@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=QyFkdnL3oY21jCwm7LMhiRAQpgzR7HBWMPckiZs+cZQ=; b=GBjn+b8QrsutedncAZPAURSSsA4cAXX/k7rT1hR+oC058LdbCYvWngK4orYIZgTSd/uxwl Aa+UcI+mivU7IjeRpqO9KD1764v9FRykg9zl00tSY4UcIHx67r0Udm9yLYeRLWYyvQlAY6 3tnrDvlJ/tZEiowTqvphP2SenTauFkT8SnCUF1cB4tGasAweDA0p5ZZ58RCgRgZPFI8Umg 3P+G9THTmbwcT+pPPNufVw7efW/jGCbDtTlJsig9IzdDZBTC8T1dqdMjTApAGPtcoC3fG2 NLsuG3m+9Q1T5nNk6Bf1DIVl7xUvdlctpWZxI9N7809o4lW5h5sTyHaJN9pQmA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=QyFkdnL3oY21jCwm7LMhiRAQpgzR7HBWMPckiZs+cZQ=; b=qbNWScsKoX9jhoddvCDdBjSKrocguh1IQ5ezIZ/W0XajOCHwP+R6ptVU1LrhlXA7w6l1L3 qq8DHdqoSrxdHCDw== From: Thomas Gleixner To: LKML Cc: Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , Michael Ellerman , Andrew Cooper , Juergen Gross , linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [patch 06/10] PCI/MSI: Use range in allocation path References: <20211126233124.618283684@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:24:39 +0100 (CET) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Make the allocation path range based to prepare for runtime expansion of MSI-X vectors. Signed-off-by: Thomas Gleixner --- drivers/pci/msi/irqdomain.c | 7 +++---- drivers/pci/msi/msi.c | 34 +++++++++++++++++++++------------- drivers/pci/msi/msi.h | 2 +- 3 files changed, 25 insertions(+), 18 deletions(-) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -8,16 +8,15 @@ #include "msi.h" -int pci_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) +int pci_msi_setup_msi_irqs(struct pci_dev *dev, struct msi_range *range, int type) { - struct msi_range range = { .first = 0, .last = UINT_MAX, .ndesc = nvec}; struct irq_domain *domain; domain = dev_get_msi_domain(&dev->dev); if (domain && irq_domain_is_hierarchy(domain)) - return msi_domain_alloc_irqs_descs_locked(domain, &dev->dev, &range); + return msi_domain_alloc_irqs_descs_locked(domain, &dev->dev, range); - return pci_msi_legacy_setup_msi_irqs(dev, nvec, type); + return pci_msi_legacy_setup_msi_irqs(dev, range->ndesc, type); } void pci_msi_teardown_msi_irqs(struct pci_dev *dev) --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -370,14 +370,16 @@ static int msi_setup_msi_desc(struct pci return ret; } -static int msi_verify_entries(struct pci_dev *dev) +static int msi_verify_entries(struct pci_dev *dev, struct msi_range *range) { struct msi_desc *entry; if (!dev->no_64bit_msi) return 0; - msi_for_each_desc(entry, &dev->dev, MSI_DESC_ALL) { + msi_for_each_desc_from(entry, &dev->dev, MSI_DESC_ALL, range->first) { + if (entry->msi_index > range->last) + return 0; if (entry->msg.address_hi) { pci_err(dev, "arch assigned 64-bit MSI address %#x%08x but device only supports 32 bits\n", entry->msg.address_hi, entry->msg.address_lo); @@ -402,6 +404,7 @@ static int msi_verify_entries(struct pci static int msi_capability_init(struct pci_dev *dev, int nvec, struct irq_affinity *affd) { + struct msi_range range = { .first = 0, .last = 0, .ndesc = nvec, }; struct irq_affinity_desc *masks = NULL; struct msi_desc *entry; int ret; @@ -421,11 +424,11 @@ static int msi_capability_init(struct pc pci_msi_mask(entry, msi_multi_mask(entry)); /* Configure MSI capability structure */ - ret = pci_msi_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSI); + ret = pci_msi_setup_msi_irqs(dev, &range, PCI_CAP_ID_MSI); if (ret) goto err; - ret = msi_verify_entries(dev); + ret = msi_verify_entries(dev, &range); if (ret) goto err; @@ -469,7 +472,8 @@ static void __iomem *msix_map_region(str } static int msix_setup_msi_descs(struct pci_dev *dev, void __iomem *base, - struct msix_entry *entries, int nvec, + struct msi_range *range, + struct msix_entry *entries, struct irq_affinity_desc *masks) { int ret, i, vec_count = pci_msix_vec_count(dev); @@ -485,8 +489,8 @@ static int msix_setup_msi_descs(struct p desc.pci.msi_attrib.default_irq = dev->irq; desc.pci.mask_base = base; - for (i = 0, curmsk = masks; i < nvec; i++, curmsk++) { - desc.msi_index = entries ? entries[i].entry : i; + for (i = 0, curmsk = masks; i < range->ndesc; i++, curmsk++) { + desc.msi_index = entries ? entries[i].entry : range->first + i; desc.affinity = masks ? curmsk : NULL; desc.pci.msi_attrib.is_virtual = desc.msi_index >= vec_count; desc.pci.msi_attrib.can_mask = !pci_msi_ignore_mask && @@ -500,6 +504,9 @@ static int msix_setup_msi_descs(struct p ret = msi_add_msi_desc(&dev->dev, &desc); if (ret) break; + + if (desc.msi_index > range->last) + range->last = desc.msi_index; } return ret; @@ -530,28 +537,28 @@ static void msix_mask_all(void __iomem * } static int msix_setup_interrupts(struct pci_dev *dev, void __iomem *base, - struct msix_entry *entries, int nvec, + struct msi_range *range, struct msix_entry *entries, struct irq_affinity *affd) { struct irq_affinity_desc *masks = NULL; int ret; if (affd) - masks = irq_create_affinity_masks(nvec, affd); + masks = irq_create_affinity_masks(range->ndesc, affd); msi_lock_descs(&dev->dev); - ret = msix_setup_msi_descs(dev, base, entries, nvec, masks); + ret = msix_setup_msi_descs(dev, base, range, entries, masks); if (ret) goto out_free; dev->dev.msi.data->properties = MSI_PROP_PCI_MSIX | MSI_PROP_64BIT; - ret = pci_msi_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX); + ret = pci_msi_setup_msi_irqs(dev, range, PCI_CAP_ID_MSIX); if (ret) goto out_free; /* Check if all MSI entries honor device restrictions */ - ret = msi_verify_entries(dev); + ret = msi_verify_entries(dev, range); if (ret) goto out_free; @@ -580,6 +587,7 @@ static int msix_setup_interrupts(struct static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries, int nvec, struct irq_affinity *affd) { + struct msi_range range = { .first = 0, .last = 0, .ndesc = nvec, }; void __iomem *base; int ret, tsize; u16 control; @@ -606,7 +614,7 @@ static int msix_capability_init(struct p /* Ensure that all table entries are masked. */ msix_mask_all(base, tsize); - ret = msix_setup_interrupts(dev, base, entries, nvec, affd); + ret = msix_setup_interrupts(dev, base, &range, entries, affd); if (ret) goto out_disable; --- a/drivers/pci/msi/msi.h +++ b/drivers/pci/msi/msi.h @@ -5,7 +5,7 @@ #define msix_table_size(flags) ((flags & PCI_MSIX_FLAGS_QSIZE) + 1) -extern int pci_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); +extern int pci_msi_setup_msi_irqs(struct pci_dev *dev, struct msi_range *range, int type); extern void pci_msi_teardown_msi_irqs(struct pci_dev *dev); #ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS From patchwork Sat Nov 27 01:25:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12642091 X-Patchwork-Delegate: bhelgaas@google.com 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 E6C7BC433FE for ; Sat, 27 Nov 2021 01:34:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351794AbhK0Bh2 (ORCPT ); Fri, 26 Nov 2021 20:37:28 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:40756 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347449AbhK0Bf0 (ORCPT ); Fri, 26 Nov 2021 20:35:26 -0500 Message-ID: <20211127000918.892733246@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=1qj+ON8bFgIPks8keDU/08NOHxNWcizsMPwkJuRGMrI=; b=Eb7F85yxU2/GXtXpV1Sbb34yCwETsFbXL6M7KB9gCsOrYAe6tvU0vngeF/GvrxkU48lja3 F2zgIqZSQKLmhH4uMq3X7em//nMRXmU/jZfkb/wa14gNatb0Eli/rAD5NP2uW4bG1SCAGT daORTovBU6EUrncvhpHjbL86mNf4uuVU8GDe9SLJ6YHFAwpj/WqqO6Qc8e4Yag5TmqcKSn DGX39oD0FUT7ul4zvXZzOUfffaSI9QoWqGTO4a4QAba7gVl6kbxBmdQVUxhvoGu1hwhhfi DXhZ97otf5O1h336e4rygoy6F8az9re0LGekPc8fp0UpHFu3ANwAV7cnDpEkNw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=1qj+ON8bFgIPks8keDU/08NOHxNWcizsMPwkJuRGMrI=; b=EDFk1OiAUgj/RtChZZpnV6C9dpDJ9EJQvgRHe6OJnzHUx7c1LOTjhWgYmcXwQPmh8R+ML8 cAasvyhML01ZIfDQ== From: Thomas Gleixner To: LKML Cc: Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , Michael Ellerman , Andrew Cooper , Juergen Gross , linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [patch 07/10] PCI/MSI: Make free related functions range based References: <20211126233124.618283684@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:25:08 +0100 (CET) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org In preparation of runtime expandable PCI/MSI-X vectors convert the related free functions to take ranges instead of assuming a zero based vector space. Signed-off-by: Thomas Gleixner --- drivers/pci/msi/irqdomain.c | 5 ++--- drivers/pci/msi/msi.c | 24 ++++++++++++++++-------- drivers/pci/msi/msi.h | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -19,14 +19,13 @@ int pci_msi_setup_msi_irqs(struct pci_de return pci_msi_legacy_setup_msi_irqs(dev, range->ndesc, type); } -void pci_msi_teardown_msi_irqs(struct pci_dev *dev) +void pci_msi_teardown_msi_irqs(struct pci_dev *dev, struct msi_range *range) { - struct msi_range range = { .first = 0, .last = UINT_MAX, }; struct irq_domain *domain; domain = dev_get_msi_domain(&dev->dev); if (domain && irq_domain_is_hierarchy(domain)) - msi_domain_free_irqs_descs_locked(domain, &dev->dev, &range); + msi_domain_free_irqs_descs_locked(domain, &dev->dev, range); else pci_msi_legacy_teardown_msi_irqs(dev); } --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -222,9 +222,12 @@ void pci_write_msi_msg(unsigned int irq, } EXPORT_SYMBOL_GPL(pci_write_msi_msg); -static void free_msi_irqs(struct pci_dev *dev) +static void free_msi_irqs(struct pci_dev *dev, struct msi_range *range, bool shutdown) { - pci_msi_teardown_msi_irqs(dev); + pci_msi_teardown_msi_irqs(dev, range); + + if (!shutdown) + return; if (dev->msix_base) { iounmap(dev->msix_base); @@ -443,7 +446,7 @@ static int msi_capability_init(struct pc err: pci_msi_unmask(entry, msi_multi_mask(entry)); - free_msi_irqs(dev); + free_msi_irqs(dev, &range, true); unlock: msi_unlock_descs(&dev->dev); kfree(masks); @@ -538,7 +541,7 @@ static void msix_mask_all(void __iomem * static int msix_setup_interrupts(struct pci_dev *dev, void __iomem *base, struct msi_range *range, struct msix_entry *entries, - struct irq_affinity *affd) + struct irq_affinity *affd, bool expand) { struct irq_affinity_desc *masks = NULL; int ret; @@ -566,7 +569,8 @@ static int msix_setup_interrupts(struct goto out_unlock; out_free: - free_msi_irqs(dev); + free_msi_irqs(dev, range, !expand); + out_unlock: msi_unlock_descs(&dev->dev); kfree(masks); @@ -614,7 +618,7 @@ static int msix_capability_init(struct p /* Ensure that all table entries are masked. */ msix_mask_all(base, tsize); - ret = msix_setup_interrupts(dev, base, &range, entries, affd); + ret = msix_setup_interrupts(dev, base, &range, entries, affd, false); if (ret) goto out_disable; @@ -728,12 +732,14 @@ static void pci_msi_shutdown(struct pci_ void pci_disable_msi(struct pci_dev *dev) { + struct msi_range range = { .first = 0, .last = 0, }; + if (!pci_msi_enable || !dev || !dev->msi_enabled) return; msi_lock_descs(&dev->dev); pci_msi_shutdown(dev); - free_msi_irqs(dev); + free_msi_irqs(dev, &range, true); msi_unlock_descs(&dev->dev); } EXPORT_SYMBOL(pci_disable_msi); @@ -817,12 +823,14 @@ static void pci_msix_shutdown(struct pci void pci_disable_msix(struct pci_dev *dev) { + struct msi_range range = { .first = 0, .last = UINT_MAX, }; + if (!pci_msi_enable || !dev || !dev->msix_enabled) return; msi_lock_descs(&dev->dev); pci_msix_shutdown(dev); - free_msi_irqs(dev); + free_msi_irqs(dev, &range, true); msi_unlock_descs(&dev->dev); } EXPORT_SYMBOL(pci_disable_msix); --- a/drivers/pci/msi/msi.h +++ b/drivers/pci/msi/msi.h @@ -6,7 +6,7 @@ #define msix_table_size(flags) ((flags & PCI_MSIX_FLAGS_QSIZE) + 1) extern int pci_msi_setup_msi_irqs(struct pci_dev *dev, struct msi_range *range, int type); -extern void pci_msi_teardown_msi_irqs(struct pci_dev *dev); +extern void pci_msi_teardown_msi_irqs(struct pci_dev *dev, struct msi_range *range); #ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS extern int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); From patchwork Sat Nov 27 01:24:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12642085 X-Patchwork-Delegate: bhelgaas@google.com 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 6A68DC433EF for ; Sat, 27 Nov 2021 01:33:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353343AbhK0BhG (ORCPT ); Fri, 26 Nov 2021 20:37:06 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:40736 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349139AbhK0BfG (ORCPT ); Fri, 26 Nov 2021 20:35:06 -0500 Message-ID: <20211127000918.948090130@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=0A61IAyhwI6GY5iuZYdA+ROlAbbN0w/XOIQw6hDb9NM=; b=u9TKqnusy4chqm3EGles3FCrSf9gO2SOc5ZSS2v+xgZD7/jCXibBKaEp2usPlK43Ep4OyF nluuEvkjH9Zwh3EDRF4zD+tPCC7NyAfn/QQs0J3glLsMhER63aL9Hqy+jdJwnGVjLn/TbV A1QjvxuddB8p4pNSNzu2Ed0dDQ4CPhfiN1AsChvb5X7XicA6ZLMdEx2E9qFBFwpV2PZyN/ bjiLIBGIiTlLYA+LxdGOY9ii+Fv3KJ7hBe/zdjqFsVI8hi0ub1SYXHy+N8kfvQUCB9htBH LMNGk56OV16MgLVSmUat+bpOijccz06MfnH9BVG4zo9uiV1i1K7vl0fBXVgwKQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=0A61IAyhwI6GY5iuZYdA+ROlAbbN0w/XOIQw6hDb9NM=; b=xEM4t7hASH4Fv9+Q06S2RwK+mQnaOqtbNKdZ9iN52VWX1kdgv/gw59z1rFiY2d5SqPSweM DKCVIioTt0nAxJCw== From: Thomas Gleixner To: LKML Cc: Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , Michael Ellerman , Andrew Cooper , Juergen Gross , linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [patch 08/10] PCI/MSI: Provide pci_msi_domain_supports_expand() References: <20211126233124.618283684@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:24:42 +0100 (CET) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Not all irq domain implementations can support runtime MSI-X vector expansion as they assume zero based allocations or have other restrictions. The legacy PCI allocation functions are not suited for runtime vector expansion either. Add a function which allows to query whether runtime MSI-X vector expansion is supported or not. Signed-off-by: Thomas Gleixner --- drivers/pci/msi/irqdomain.c | 29 +++++++++++++++++++++++------ include/linux/msi.h | 2 ++ 2 files changed, 25 insertions(+), 6 deletions(-) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -8,12 +8,18 @@ #include "msi.h" +static struct irq_domain *pci_get_msi_domain(struct pci_dev *dev) +{ + struct irq_domain *domain = dev_get_msi_domain(&dev->dev); + + return domain && irq_domain_is_hierarchy(domain) ? domain : NULL; +} + int pci_msi_setup_msi_irqs(struct pci_dev *dev, struct msi_range *range, int type) { - struct irq_domain *domain; + struct irq_domain *domain = pci_get_msi_domain(dev); - domain = dev_get_msi_domain(&dev->dev); - if (domain && irq_domain_is_hierarchy(domain)) + if (domain) return msi_domain_alloc_irqs_descs_locked(domain, &dev->dev, range); return pci_msi_legacy_setup_msi_irqs(dev, range->ndesc, type); @@ -21,15 +27,26 @@ int pci_msi_setup_msi_irqs(struct pci_de void pci_msi_teardown_msi_irqs(struct pci_dev *dev, struct msi_range *range) { - struct irq_domain *domain; + struct irq_domain *domain = pci_get_msi_domain(dev); - domain = dev_get_msi_domain(&dev->dev); - if (domain && irq_domain_is_hierarchy(domain)) + if (domain) msi_domain_free_irqs_descs_locked(domain, &dev->dev, range); else pci_msi_legacy_teardown_msi_irqs(dev); } +bool pci_msi_domain_supports_expand(struct pci_dev *dev) +{ + struct irq_domain *domain = pci_get_msi_domain(dev); + struct msi_domain_info *info; + + if (!domain) + return false; + + info = domain->host_data; + return info->flags & MSI_FLAG_CAN_EXPAND; +} + /** * pci_msi_domain_write_msg - Helper to write MSI message to PCI config space * @irq_data: Pointer to interrupt data of the MSI interrupt --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -552,11 +552,13 @@ struct irq_domain *pci_msi_create_irq_do u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev); struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev); bool pci_dev_has_special_msi_domain(struct pci_dev *pdev); +bool pci_msi_domain_supports_expand(struct pci_dev *dev); #else static inline struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev) { return NULL; } +static inline bool pci_msi_domain_supports_expand(struct pci_dev *dev) { return false; } #endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */ #endif /* LINUX_MSI_H */ From patchwork Sat Nov 27 01:25:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12642093 X-Patchwork-Delegate: bhelgaas@google.com 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 4EB72C433F5 for ; Sat, 27 Nov 2021 01:34:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347407AbhK0BiF (ORCPT ); Fri, 26 Nov 2021 20:38:05 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:40764 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352462AbhK0BgE (ORCPT ); Fri, 26 Nov 2021 20:36:04 -0500 Message-ID: <20211127000919.004572849@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976311; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=iXWx8ngjVm94paCMjL44qtncyzw3jmQTRYweVvwdUTE=; b=XMZ8+C4S5qdKr1Con79Z8ll6XVMM2fnwfUd6VibARMXKBZJmbzz2rdgHplVFzqQWoTjqXL a71t/1Td6DZLsRGHxaA0Xy69M6LynlfnUWWrPppwCpmvz1S4krQdufBQTGAqkoP0l3s8T3 5/d33e6N4qMca0wqhegVl6SB4Kg+rkn1Q5Lq3ndlMN3YDCufaLN+bpKiuw5/eO8PEddKg7 KXX4wVb7cTsJ2Tc/55bKjXTrqTb0PPVsc9nsJs/ZzoOSFGZaIbOseCSK90/VO3qoq0OR3S bX2HgbvnzX2XCKSBc8Aiz7O3JmG+aqKSvt2jQ+saMx9qcR/0zEVPXRcCgYtdXQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976311; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=iXWx8ngjVm94paCMjL44qtncyzw3jmQTRYweVvwdUTE=; b=KqCEEAwQIQ5ub2ZhfoOhVriWcwZnFHllmQP6Q5tXV21krUdnjIG0tW2/eI3ljwxV7nF3wo hBnPVTOZ03C+6jDQ== From: Thomas Gleixner To: LKML Cc: Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , Michael Ellerman , Andrew Cooper , Juergen Gross , linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [patch 09/10] PCI/MSI: Provide pci_msix_expand_vectors[_at]() References: <20211126233124.618283684@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:25:11 +0100 (CET) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Provide a new interface which allows to expand the MSI-X vector space if the underlying irq domain implementation supports it. Signed-off-by: Thomas Gleixner --- drivers/pci/msi/msi.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 13 +++++++++++++ 2 files changed, 54 insertions(+) --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -1025,6 +1025,47 @@ int pci_alloc_irq_vectors_affinity(struc EXPORT_SYMBOL(pci_alloc_irq_vectors_affinity); /** + * pci_msix_expand_vectors_at - Expand MSI-X interrupts for a device + * + * @dev: PCI device to operate on + * @at: Allocate at MSI-X index. If @at == PCI_MSI_EXPAND_AUTO + * the function expands automatically after the last + * active index. + * @nvec: Number of vectors to allocate + * + * Expand the MSI-X vectors of a device after an initial enablement and + * allocation. + * + * Return: 0 if the allocation was successful, an error code otherwise. + */ +int pci_msix_expand_vectors_at(struct pci_dev *dev, unsigned int at, unsigned int nvec) +{ + struct msi_device_data *md = dev->dev.msi.data; + struct msi_range range = { .ndesc = nvec, }; + unsigned int max_vecs; + int ret; + + if (!pci_msi_enable || !dev || !dev->msix_enabled || !md) + return -ENOTSUPP; + + if (!pci_msi_domain_supports_expand(dev)) + return -ENOTSUPP; + + max_vecs = pci_msix_vec_count(dev); + if (!nvec || nvec > max_vecs) + return -EINVAL; + + range.first = at == PCI_MSIX_EXPAND_AUTO ? md->num_descs : at; + + if (range.first >= max_vecs || nvec > max_vecs - range.first) + return -ENOSPC; + + ret = msix_setup_interrupts(dev, dev->msix_base, &range, NULL, NULL, true); + return ret <= 0 ? ret : -ENOSPC;; +} +EXPORT_SYMBOL_GPL(pci_msix_expand_vectors_at); + +/** * pci_free_irq_vectors - free previously allocated IRQs for a device * @dev: PCI device to operate on * --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1534,6 +1534,7 @@ static inline int pci_enable_msix_exact( int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, unsigned int max_vecs, unsigned int flags, struct irq_affinity *affd); +int pci_msix_expand_vectors_at(struct pci_dev *dev, unsigned int at, unsigned int nvec); void pci_free_irq_vectors(struct pci_dev *dev); int pci_irq_vector(struct pci_dev *dev, unsigned int nr); @@ -1565,6 +1566,11 @@ pci_alloc_irq_vectors_affinity(struct pc return -ENOSPC; } +static inline int pci_msix_expand_vectors_at(struct pci_dev *dev, unsigned int at, unsigned int nvec) +{ + return -ENOTSUPP; +} + static inline void pci_free_irq_vectors(struct pci_dev *dev) { } @@ -1582,6 +1588,13 @@ static inline const struct cpumask *pci_ } #endif +#define PCI_MSIX_EXPAND_AUTO (UINT_MAX) + +static inline int pci_msix_expand_vectors(struct pci_dev *dev, unsigned int nvec) +{ + return pci_msix_expand_vectors_at(dev, PCI_MSIX_EXPAND_AUTO, nvec); +} + /** * pci_irqd_intx_xlate() - Translate PCI INTx value to an IRQ domain hwirq * @d: the INTx IRQ domain From patchwork Sat Nov 27 01:24:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12642087 X-Patchwork-Delegate: bhelgaas@google.com 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 00EBDC433F5 for ; Sat, 27 Nov 2021 01:34:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349352AbhK0BhN (ORCPT ); Fri, 26 Nov 2021 20:37:13 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:40740 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349115AbhK0BfL (ORCPT ); Fri, 26 Nov 2021 20:35:11 -0500 Message-ID: <20211127000919.061417652@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=hCvJ3RXlnaO1z2W7zc0iNOJLM+aNENiBxAWv9ZJQoBs=; b=XC2Gl2AXYUosg2kIFrKUz3oPHKElC1X9JFf4x3rxNOfcEV8Sq7ff8QkEBIiBuBsTfaHNCM 65bhXgRy5LZ9CnQBXg7GbCNI4vggc91+DCTEERsiANj0TGuDaiFlcTbB0M47vNHEjihjSW 8DA00mBgmlvScWnWuX/6xFMQMcL0n5mNIlPxb5zZocO3pbdWx0Ofy1wQIIEqhY38Jgc0AN q500czOHWsLH6192qrfut6JygO3G0UlybO6Qtx41PQKuS/ypTmzA4msGtxAX4YLtPpouxb /3SyS/cHVyI76sDvXyavx8EUa0STgNuiEnp8ZEVMmX/DZiNkTIl1EM8TAZq2cQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=hCvJ3RXlnaO1z2W7zc0iNOJLM+aNENiBxAWv9ZJQoBs=; b=ailFWK1MoN7Bi6dOYGgm53UBim2lp4UpqheAs+DlCTXZcPa4k+6E5dnX9FNo8gNNMKECaq WAcA1zeyb1QOLQAQ== From: Thomas Gleixner To: LKML Cc: Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , Michael Ellerman , Andrew Cooper , Juergen Gross , linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [patch 10/10] x86/apic/msi: Support MSI-X vector expansion References: <20211126233124.618283684@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:24:45 +0100 (CET) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The X86 PCI/MSI irq domaim implementation supports vector expansion out of the box. Make it available. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/msi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/x86/kernel/apic/msi.c +++ b/arch/x86/kernel/apic/msi.c @@ -178,7 +178,7 @@ static struct msi_domain_ops pci_msi_dom static struct msi_domain_info pci_msi_domain_info = { .flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | - MSI_FLAG_PCI_MSIX, + MSI_FLAG_PCI_MSIX | MSI_FLAG_CAN_EXPAND, .ops = &pci_msi_domain_ops, .chip = &pci_msi_controller, .handler = handle_edge_irq, @@ -226,7 +226,7 @@ static struct irq_chip pci_msi_ir_contro static struct msi_domain_info pci_msi_ir_domain_info = { .flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | - MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX, + MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX | MSI_FLAG_CAN_EXPAND, .ops = &pci_msi_domain_ops, .chip = &pci_msi_ir_controller, .handler = handle_edge_irq,