From patchwork Tue Nov 6 08:41:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lokesh Vutla X-Patchwork-Id: 10669935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F25A014BD for ; Tue, 6 Nov 2018 08:58:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD8192951E for ; Tue, 6 Nov 2018 08:58:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0D77298DC; Tue, 6 Nov 2018 08:58:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0FE422951E for ; Tue, 6 Nov 2018 08:58:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DDENo+ptEfYNVRHzs6SunMcfU83/cu6pKaNcYV12hOI=; b=reAvpztnEc6kYW wM8QETczaCZ2y3C0PasGEWyQX7gimQtq/9tFppcAk/+j4c+PkoqLhY13A/U0dx2xTtR99zFjCfa+7 /UL8V4lbh6ToMU1ASoWj3SJ5tYB3B9WwA6olVgrSopIftNtoJiGeSv6Sg81YouomT5uvHAXrGEYcH w1ZAPdL4n2qv9K8ErlLVbKD4KFXmyxcGRmLU6DiieZJhuiXgXfFMfMOX7s8/uBOe2miLMyh54rpSS ET55GycHa8Xb0vPN3vKM+K15Ygm0DgP2Vwy7BBot1slYLkJDQt+iEm0OUQuzTT7he/bwC23u4LkDb QploROM7bEScArjgqqhA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJxC9-0002LL-1z; Tue, 06 Nov 2018 08:58:45 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJxBk-0001hX-2H for linux-arm-kernel@bombadil.infradead.org; Tue, 06 Nov 2018 08:58:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=n6IwY2Ny7IBcKzmcIwaJzrKg0C1tWOop6pzt+3gzEwg=; b=RcVgk6q6zJDqFzLtm9oU6Nv8hU 4GrcdoCVLyvvrumjOuZGY4cL04vQ+Ya833BRBeUzQJr9v7CaDXcddC4A9yIbEQSYisGiA7NA9pPI2 UeUR12MG8XZskkpWzU42qfLbMORHpQlI2EPoful7qLzdZ0P7a5t8otj6w4CA7oFHJ0LJWl63NK2DO stHGEigaJlBpjlNN/JlZ5LfTfqWjYcRr8pfSoZtzvfofq9YX3Y6nWhADJKeQEgzFWf7QM4s48TeXC GFv/6bPgEy7vPgnfpbXSO4DyBbiN/M7PlQI4dvDdE64nFumJeADWO9ArDfkke8mx7ddxR93dkQ6S5 lhQe/K5g==; Received: from fllv0016.ext.ti.com ([198.47.19.142]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJwwa-0007Kv-Iv for linux-arm-kernel@lists.infradead.org; Tue, 06 Nov 2018 08:42:42 +0000 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id wA68fvU7092030; Tue, 6 Nov 2018 02:41:57 -0600 Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wA68fvtm096280 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 6 Nov 2018 02:41:57 -0600 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 6 Nov 2018 02:41:56 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Tue, 6 Nov 2018 02:41:56 -0600 Received: from uda0131933.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id wA68fJ3r032677; Tue, 6 Nov 2018 02:41:53 -0600 From: Lokesh Vutla To: Nishanth Menon , Santosh Shilimkar , Rob Herring , , , Subject: [RFC PATCH v3 08/13] genirq/msi: Add support for allocating single MSI for a device Date: Tue, 6 Nov 2018 14:11:00 +0530 Message-ID: <20181106084105.32483-9-lokeshvutla@ti.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181106084105.32483-1-lokeshvutla@ti.com> References: <20181106084105.32483-1-lokeshvutla@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181106_084240_841450_70597743 X-CRM114-Status: GOOD ( 19.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Device Tree Mailing List , Grygorii Strashko , Peter Ujfalusi , Lokesh Vutla , Sekhar Nori , linux-kernel@vger.kernel.org, Tero Kristo , Linux ARM Mailing List Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Previously all MSIs for a device are allocated in one go by calling msi_domain_alloc_irq() from a bus layer. This might not be the case when a device is trying to allocate interrupts dynamically based on a request to it. So introduce msi_domain_alloc/free_irq() apis to allocate a single msi. prepare and activate operations to be handled by bus layer calling msi_domain_alloc/free_irq() apis. Signed-off-by: Lokesh Vutla --- Changes since v2: - New patch include/linux/msi.h | 3 +++ kernel/irq/msi.c | 62 +++++++++++++++++++++++++++++---------------- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/include/linux/msi.h b/include/linux/msi.h index 0e9c50052ff3..021f789226b5 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -299,8 +299,11 @@ int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask, struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode, struct msi_domain_info *info, struct irq_domain *parent); +int msi_domain_alloc_irq(struct irq_domain *domain, struct device *dev, + struct msi_desc *desc, msi_alloc_info_t *arg); int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, int nvec); +void msi_domain_free_irq(struct msi_desc *desc); void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev); struct msi_domain_info *msi_get_domain_info(struct irq_domain *domain); diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 4ca2fd46645d..e37238317fab 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -387,6 +387,35 @@ static bool msi_check_reservation_mode(struct irq_domain *domain, return desc->msi_attrib.is_msix || desc->msi_attrib.maskbit; } +int msi_domain_alloc_irq(struct irq_domain *domain, struct device *dev, + struct msi_desc *desc, msi_alloc_info_t *arg) +{ + struct msi_domain_info *info = domain->host_data; + struct msi_domain_ops *ops = info->ops; + int i, ret, virq; + + ops->set_desc(arg, desc); + + virq = __irq_domain_alloc_irqs(domain, -1, desc->nvec_used, + dev_to_node(dev), arg, false, + desc->affinity); + if (virq < 0) { + ret = -ENOSPC; + if (ops->handle_error) + ret = ops->handle_error(domain, desc, ret); + if (ops->msi_finish) + ops->msi_finish(arg, ret); + return ret; + } + + for (i = 0; i < desc->nvec_used; i++) { + irq_set_msi_desc_off(virq, i, desc); + irq_debugfs_copy_devname(virq + i, dev); + } + + return 0; +} + /** * msi_domain_alloc_irqs - Allocate interrupts from a MSI interrupt domain * @domain: The domain to allocate from @@ -404,7 +433,7 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, struct irq_data *irq_data; struct msi_desc *desc; msi_alloc_info_t arg; - int i, ret, virq; + int ret, virq; bool can_reserve; ret = msi_domain_prepare_irqs(domain, dev, nvec, &arg); @@ -412,24 +441,9 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, return ret; for_each_msi_entry(desc, dev) { - ops->set_desc(&arg, desc); - - virq = __irq_domain_alloc_irqs(domain, -1, desc->nvec_used, - dev_to_node(dev), &arg, false, - desc->affinity); - if (virq < 0) { - ret = -ENOSPC; - if (ops->handle_error) - ret = ops->handle_error(domain, desc, ret); - if (ops->msi_finish) - ops->msi_finish(&arg, ret); + ret = msi_domain_alloc_irq(domain, dev, desc, &arg); + if (ret) return ret; - } - - for (i = 0; i < desc->nvec_used; i++) { - irq_set_msi_desc_off(virq, i, desc); - irq_debugfs_copy_devname(virq + i, dev); - } } if (ops->msi_finish) @@ -487,6 +501,12 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, return ret; } +void msi_domain_free_irq(struct msi_desc *desc) +{ + irq_domain_free_irqs(desc->irq, desc->nvec_used); + desc->irq = 0; +} + /** * msi_domain_free_irqs - Free interrupts from a MSI interrupt @domain associated tp @dev * @domain: The domain to managing the interrupts @@ -503,10 +523,8 @@ void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev) * enough that there is no IRQ associated to this * entry. If that's the case, don't do anything. */ - if (desc->irq) { - irq_domain_free_irqs(desc->irq, desc->nvec_used); - desc->irq = 0; - } + if (desc->irq) + msi_domain_free_irq(desc); } }