From patchwork Mon Sep 20 06:41:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 12504629 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 X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38AD2C433F5 for ; Mon, 20 Sep 2021 06:41:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1569561019 for ; Mon, 20 Sep 2021 06:41:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232847AbhITGnQ (ORCPT ); Mon, 20 Sep 2021 02:43:16 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:54898 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbhITGnP (ORCPT ); Mon, 20 Sep 2021 02:43:15 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 18K6fhlb114089; Mon, 20 Sep 2021 01:41:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1632120103; bh=eb1cIdv3qoLYfUNttN6sbtnRdM99bDj5tbGobNqz3KU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BBsyILkPJrqg+OQ9BsLtftTlV2SpBRCTs64Diz0bi0duKWQRN+4U4GubwkTNmqygs 0IsJyrjTm4qsTOHtb1qOq2dJPiV5kOx3VpGaXshAP/GBKkdL03xCWOjAh5qsFvz8WA ikfdd6p+pYguNfVXrQwc/E2JuQxyoIak8TjSQxqg= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 18K6fhUl075792 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 20 Sep 2021 01:41:43 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Mon, 20 Sep 2021 01:41:42 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Mon, 20 Sep 2021 01:41:41 -0500 Received: from a0393678-lt.ent.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 18K6fYa6015912; Mon, 20 Sep 2021 01:41:38 -0500 From: Kishon Vijay Abraham I To: Thomas Gleixner , Marc Zyngier , Bjorn Helgaas CC: , , Lorenzo Pieralisi , Kishon Vijay Abraham I , Subject: [PATCH 1/3] PCI: Add support in pci_walk_bus() to invoke callback matching RID Date: Mon, 20 Sep 2021 12:11:31 +0530 Message-ID: <20210920064133.14115-2-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210920064133.14115-1-kishon@ti.com> References: <20210920064133.14115-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Add two arguments to pci_walk_bus() [requestorID and mask], and add support in pci_walk_bus() to invoke the *callback* only for devices whose RequestorID after applying *mask* matches with *requestorID* passed as argument. This is done in preparation for calculating the total number of interrupt vectors that has to be supported by a specific GIC ITS device ID, specifically when "msi-map-mask" is populated in device tree. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/bus.c | 13 +++++++++---- include/linux/pci.h | 7 +++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 3cef835b375f..e381e639ceaa 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -358,10 +358,12 @@ void pci_bus_add_devices(const struct pci_bus *bus) } EXPORT_SYMBOL(pci_bus_add_devices); -/** pci_walk_bus - walk devices on/under bus, calling callback. +/** __pci_walk_bus - walk devices on/under bus matching requestor ID, calling callback. * @top bus whose devices should be walked * @cb callback to be called for each device found * @userdata arbitrary pointer to be passed to callback. + * @rid Requestor ID that has to be matched for the callback to be invoked + * @mask Mask that has to be applied to pci_dev_id(), before compating it with @rid * * Walk the given bus, including any bridged devices * on buses under this bus. Call the provided callback @@ -371,8 +373,8 @@ EXPORT_SYMBOL(pci_bus_add_devices); * other than 0, we break out. * */ -void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), - void *userdata) +void __pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), + void *userdata, u32 rid, u32 mask) { struct pci_dev *dev; struct pci_bus *bus; @@ -399,13 +401,16 @@ void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), } else next = dev->bus_list.next; + if (mask != 0xffff && ((pci_dev_id(dev) & mask) != rid)) + continue; + retval = cb(dev, userdata); if (retval) break; } up_read(&pci_bus_sem); } -EXPORT_SYMBOL_GPL(pci_walk_bus); +EXPORT_SYMBOL_GPL(__pci_walk_bus); struct pci_bus *pci_bus_get(struct pci_bus *bus) { diff --git a/include/linux/pci.h b/include/linux/pci.h index cd8aa6fce204..8500fec56e50 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1473,14 +1473,17 @@ const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass); -void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), - void *userdata); +void __pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), + void *userdata, u32 rid, u32 mask); int pci_cfg_space_size(struct pci_dev *dev); unsigned char pci_bus_max_busnr(struct pci_bus *bus); void pci_setup_bridge(struct pci_bus *bus); resource_size_t pcibios_window_alignment(struct pci_bus *bus, unsigned long type); +#define pci_walk_bus(top, cb, userdata) \ + __pci_walk_bus((top), (cb), (userdata), 0x0, 0xffff) + #define PCI_VGA_STATE_CHANGE_BRIDGE (1 << 0) #define PCI_VGA_STATE_CHANGE_DECODES (1 << 1) From patchwork Mon Sep 20 06:41:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 12504631 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 X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E95AC433EF for ; Mon, 20 Sep 2021 06:42:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1788A60F93 for ; Mon, 20 Sep 2021 06:42:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233362AbhITGn2 (ORCPT ); Mon, 20 Sep 2021 02:43:28 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:48778 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233409AbhITGn1 (ORCPT ); Mon, 20 Sep 2021 02:43:27 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 18K6fjjs073480; Mon, 20 Sep 2021 01:41:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1632120105; bh=irwwhPCzZ2l+G6tBT9VTTRVLR5kG5CHiPJsvsZ/kQQg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=fvKpEbKaHeIpTobTTWtNB6jtG/15gld1qmcOrb242Jd7LAHjhKZzfCutKrPj8HtUI PAiMDe2AfEyBk4H3VkssyoZ8AE0O6drNVTEVdVh1BjKZwi2RKO4PazeqMW8z+2HT5g IO0iBCZISgG1OrLYYiSuzAhIPSPZiG/Y/A06h+Ok= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 18K6fjbj064810 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 20 Sep 2021 01:41:45 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Mon, 20 Sep 2021 01:41:45 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Mon, 20 Sep 2021 01:41:45 -0500 Received: from a0393678-lt.ent.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 18K6fYa7015912; Mon, 20 Sep 2021 01:41:42 -0500 From: Kishon Vijay Abraham I To: Thomas Gleixner , Marc Zyngier , Bjorn Helgaas CC: , , Lorenzo Pieralisi , Kishon Vijay Abraham I , Subject: [PATCH 2/3] PCI: Export find_pci_root_bus() Date: Mon, 20 Sep 2021 12:11:32 +0530 Message-ID: <20210920064133.14115-3-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210920064133.14115-1-kishon@ti.com> References: <20210920064133.14115-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Export find_pci_root_bus() in order for other subsystems (like IRQCHIP) to find the root bus of a particual PCIe device. This is done in preparation for GIC ITS to walk the PCIe bus for calculating the total number of interrupt vectors that has to be supported by a specific GIC ITS device ID, specifically when "msi-map-mask" is populated in device tree. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/host-bridge.c | 3 ++- include/linux/pci.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c index afa50b446567..4ec34d040c02 100644 --- a/drivers/pci/host-bridge.c +++ b/drivers/pci/host-bridge.c @@ -9,13 +9,14 @@ #include "pci.h" -static struct pci_bus *find_pci_root_bus(struct pci_bus *bus) +struct pci_bus *find_pci_root_bus(struct pci_bus *bus) { while (bus->parent) bus = bus->parent; return bus; } +EXPORT_SYMBOL_GPL(find_pci_root_bus); struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 8500fec56e50..b33ef3e08a2f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1475,6 +1475,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, void __pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), void *userdata, u32 rid, u32 mask); +struct pci_bus *find_pci_root_bus(struct pci_bus *bus); int pci_cfg_space_size(struct pci_dev *dev); unsigned char pci_bus_max_busnr(struct pci_bus *bus); void pci_setup_bridge(struct pci_bus *bus); From patchwork Mon Sep 20 06:41:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 12504633 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 X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42A8FC433F5 for ; Mon, 20 Sep 2021 06:42:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A3436101C for ; Mon, 20 Sep 2021 06:42:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233327AbhITGnb (ORCPT ); Mon, 20 Sep 2021 02:43:31 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:48790 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233374AbhITGna (ORCPT ); Mon, 20 Sep 2021 02:43:30 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 18K6fnNH073492; Mon, 20 Sep 2021 01:41:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1632120109; bh=/4Zz3FNlBeAefxVx1iflggGljsIGocoijkMKMEhCHa8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=iFrTV5T69RG37DgBBAFe7S2cGN4k2Vo32OxbM4eQP8/OabfOLgi/XiEPBqxDUmThz b99kSHMwPSbdgeooIayfpomBASLh45lx4px5okM0UqQJpPgd6awTb5PYv3zHsbtX7f fKoG2BjNc/Ksa2G5FrkTSCIWv25mAD2dlkO0HQqw= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 18K6fnvh064834 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 20 Sep 2021 01:41:49 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Mon, 20 Sep 2021 01:41:48 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Mon, 20 Sep 2021 01:41:48 -0500 Received: from a0393678-lt.ent.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 18K6fYa8015912; Mon, 20 Sep 2021 01:41:45 -0500 From: Kishon Vijay Abraham I To: Thomas Gleixner , Marc Zyngier , Bjorn Helgaas CC: , , Lorenzo Pieralisi , Kishon Vijay Abraham I , Subject: [PATCH 3/3] irqchip/gic-v3-its: Include "msi-map-mask" for calculating nvecs Date: Mon, 20 Sep 2021 12:11:33 +0530 Message-ID: <20210920064133.14115-4-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210920064133.14115-1-kishon@ti.com> References: <20210920064133.14115-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Using "msi-map-mask" in device tree lets multiple PCIe requestor ID to use the same GIC ITS device ID. So while creating the Interrupt Translation Table (ITT) for a specific GIC ITS device ID, the total number of interrupts required by all the PCIe requestor ID that maps to the same GIC ITS device ID should be calculated Add support for gic-v3-its to include "msi-map-mask" property in device tree for calculating the total number of MSI interrupts in its_pci_msi_prepare(). Signed-off-by: Kishon Vijay Abraham I --- drivers/irqchip/irq-gic-v3-its-pci-msi.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c index ad2810c017ed..c79bca1a5787 100644 --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c @@ -54,9 +54,13 @@ static int its_get_pci_alias(struct pci_dev *pdev, u16 alias, void *data) static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *info) { + int alias_count = 0, map_count = 0, minnvec = 1, ret; struct pci_dev *pdev, *alias_dev; struct msi_domain_info *msi_info; - int alias_count = 0, minnvec = 1; + struct device *parent_dev; + struct pci_bus *root_bus; + struct device_node *np; + u32 map_mask, rid; if (!dev_is_pci(dev)) return -EINVAL; @@ -78,6 +82,21 @@ static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev, info->flags |= MSI_ALLOC_FLAGS_PROXY_DEVICE; } + for (parent_dev = dev; parent_dev; parent_dev = parent_dev->parent) { + np = parent_dev->of_node; + if (!np) + continue; + + ret = of_property_read_u32(np, "msi-map-mask", &map_mask); + if (!ret && map_mask != 0xffff) { + rid = pci_dev_id(pdev) & map_mask; + root_bus = find_pci_root_bus(pdev->bus); + __pci_walk_bus(root_bus, its_pci_msi_vec_count, &map_count, rid, map_mask); + break; + } + } + alias_count = max(map_count, alias_count); + /* ITS specific DeviceID, as the core ITS ignores dev. */ info->scratchpad[0].ul = pci_msi_domain_get_msi_rid(domain, pdev);