From patchwork Wed Dec 9 01:48:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 7803271 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 748209F71A for ; Wed, 9 Dec 2015 01:51:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 84B32203FB for ; Wed, 9 Dec 2015 01:51:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96C952045A for ; Wed, 9 Dec 2015 01:50:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a6TsG-0004Mi-Ix; Wed, 09 Dec 2015 01:48:56 +0000 Received: from mail-by2on0075.outbound.protection.outlook.com ([207.46.100.75] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a6Ts5-0004HX-4W for linux-arm-kernel@lists.infradead.org; Wed, 09 Dec 2015 01:48:45 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; Received: from ssuthiku-fedora-lt.amd.com (165.204.77.1) by BY1PR12MB0437.namprd12.prod.outlook.com (10.162.147.139) with Microsoft SMTP Server (TLS) id 15.1.337.19; Wed, 9 Dec 2015 01:48:21 +0000 From: Suravee Suthikulpanit To: , , , Subject: [PATCH v5 1/5] acpi: pci: Setup MSI domain for ACPI based pci devices Date: Tue, 8 Dec 2015 17:48:02 -0800 Message-ID: <1449625686-5594-2-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1449625686-5594-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1449625686-5594-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BLUPR05CA0068.namprd05.prod.outlook.com (10.141.20.38) To BY1PR12MB0437.namprd12.prod.outlook.com (25.162.147.139) X-Microsoft-Exchange-Diagnostics: 1; BY1PR12MB0437; 2:wViXxO04p+GQLS/1cFZ+de+rhyb+ao/GgvQ33PYvTsreBF1ZHlnf9ngu0x4jEyLlYdSWZNqi8MVpDcrp4wh/hn7pn8NBgpVnQuUwI9nqRzUQwAVNQW6gxZpLuRe0vNkGAkUsZbDXxvl+CRWY0/sD7g==; 3:EMievusRgMqSabFR0UH/4tEYa4zIUCxRBQYbQyfpIpu5Yg5Vb3vCjzXXJYNsezg4UIL3yR6uGMZGxiQ51rxxqbrXNskfK8jJRJM27EJqTHGJe4OyextIAV9JHyyXzHMr; 25:Gf7HAm+q+t60PBufZeKnehAn3lylFSyZGdaNGAkrFJ9afLYsDJDeKZnrNWMXVwtmr4wzSvTh/PImP5pjl1sQaTA/AR64zMEdgKsbaK/+zByb43+y99CJQlxnNZebYB+JI4bKVhlLdm4OzuQVh8F/U/v1MLNpTPSSMDC7kr2YD3qPA4Yz9axR5pXabsOfpunBddJ+M4y5jb4FezjCSAOLD34NmYtOTAoH1OJUakJyc7eIo76ySI+0veeesBuecK++lmI0vF2Cs450EQ3YhxHhfQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR12MB0437; X-Microsoft-Exchange-Diagnostics: 1; BY1PR12MB0437; 20:0/D+5pt2OJoBfjsAJgJ7MgNYeky2JzKeiF/ID4qMcngDSEVP2erchn5E2Rb8RndKie+NIS4gHT3k8ZhC+EyQC0hu8pBOjO6K3Vp8VgzZykCuQVzNdCuBXGSaQ+oixlt0aJGUn0bET+w6etxAXG/3kXaJEure4V3sXTMS2GXD/vYw0ca+g68PtIBTVxnR+cohzpHqQGyEtWViS71g6W0UpV40mrqIpmD8piXHtReiFzgCWpB/oOdfWnq/w99PTSLtVZn/viD8a/od3hcGa38tsMW0gAxZBrJgycvPGd4M/C+tQUF6f4pVMM6KxmnJDK/K+PzUhR0FILR/n697VgOZojOrF5vvdiYwOt5UwSJcNuYxWB+uKh8+OQYqsxdGswyf/LDorhTgvTm5qyrF5JkLyu/bK4wFoOez7PrT2kUSTK+sGlSkrAo+wk0NmPWawt7OALITTohoS5I2l51JspTyVjRVp6u8TpGiujfmWQrSnubiVjBQFTp5sAoh4LjqBHCR; 4:5yVrd0Y7g4ifvpuPflYsUc490MzDQPM8RIX/lpNR88A389h17R69mj5sRROVaEflRcvTxaGtMNpNDUqoxOstKTkKRMln6G03n1xKV9KWk1AVRgvMAoMX1gEaYev0ETsovj+ckC+ExHENawh1NbyV3fv87XNOJhyJ16bN47l47Su0p6hLi7LI/88rdNFZF85IDOR06OIkhrbIz2jPeSOCUDTXwevJcN5KgVjbFsH2xR5v6wbbOgai8EnCFq6C4tnH/OaEL6Cwa/xs07QaW9LHsX2763pOzr0tt+WxorAwtXJ5UNuKIc7paLxk5VplE4bMKSINls5vnN5Y0kDgddwVG5gMT6XndJDxAgKwKzBD3N7xmQrKwwpQ5lqonBYrbj2k0uHAj+EZv5FspnzsQraQsJHTCkZRaguI/TZAzGhD/qQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046); SRVR:BY1PR12MB0437; BCL:0; PCL:0; RULEID:; SRVR:BY1PR12MB0437; X-Forefront-PRVS: 0785459C39 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(36756003)(77096005)(2950100001)(86362001)(229853001)(92566002)(101416001)(53416004)(122386002)(97736004)(2201001)(42186005)(87976001)(5001770100001)(19580405001)(5004730100002)(50226001)(48376002)(19580395003)(1096002)(47776003)(189998001)(50986999)(66066001)(5003940100001)(106356001)(5008740100001)(6116002)(50466002)(3846002)(586003)(76176999)(105586002)(40100003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR12MB0437; H:ssuthiku-fedora-lt.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR12MB0437; 23:o+Dmn2R+edmCxtVfA26e6q2U7b2o3e428S289WUmu?= =?us-ascii?Q?U6vDXuusp7GSEHbk/7pTKsrPrQWFy6ykqE0yjbpkyysUVMEoQbYdKDvO0fBr?= =?us-ascii?Q?XpB4VQBnlbywsal27QKyjhSHH8tIQNvvOvonyrHtkq/zyFlLTrkGwobKsty+?= =?us-ascii?Q?0Cs9xyMzv6XxxI3vWU6X6GgeL8+knwczKg5o4L+2q2trWD9hGW6VWdEX/FLo?= =?us-ascii?Q?jzCoEPhuifg9K4svGBzGvEGwe9sWI650uSABqNp0JlhxqsoafIsiX3SDmaQt?= =?us-ascii?Q?YsO3RypcVnsCMoSO4hnZFd0hStsG3YUR2PCUQdYOe/Pt9IlU6c5aL/CyB85K?= =?us-ascii?Q?OZn2mGW6NHc7tz4GQbiTIt0XWq+4zIpuzrBe0cmNGL2baRiKlBU8xi24LT1I?= =?us-ascii?Q?ZldqyI4gFNVS+5l51GBgBVN+hR4rMl8fQIW3NCxVLas9dLd0B0fIBZb8H6Jm?= =?us-ascii?Q?hYyQufM/cr4ZKPFK32ae1A2V6MRi8PPr7cCKD4cV5mi8Oz0JWgQCgWbsrorf?= =?us-ascii?Q?NpNwh80ddqK7sLMOlk2iOUpfMnnJjecw8CyJm0KoIgSUtpHO8x1HExx93YzF?= =?us-ascii?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akG19pnhq9M4pn+4 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2015 01:48:21.1159 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR12MB0437 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151208_174845_280291_7414BF7A X-CRM114-Status: GOOD ( 12.69 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , graeme.gregory@linaro.org, Catalin Marinas , dhdang@apm.com, Will Deacon , linux-kernel@vger.kernel.org, tomasz.nowicki@linaro.org, linux-acpi@vger.kernel.org, hanjun.guo@linaro.org, Suravee Suthikulpanit , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces pci_msi_register_fwnode_provider() for irqchip to register a callback, to provide a way to determine appropriate MSI domain for a pci device. It also introduces pci_host_bridge_acpi_msi_domain(), which returns the MSI domain of the specified PCI host bridge with DOMAIN_BUS_PCI_MSI bus token. Then, it is assigned to pci device. Signed-off-by: Suravee Suthikulpanit Reviewed-by: Marc Zyngier --- drivers/pci/pci-acpi.c | 32 ++++++++++++++++++++++++++++++++ drivers/pci/probe.c | 2 ++ include/linux/irqdomain.h | 5 +++++ include/linux/pci.h | 10 ++++++++++ 4 files changed, 49 insertions(+) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index a32ba75..a555d7e 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -9,7 +9,9 @@ #include #include +#include #include +#include #include #include #include @@ -689,6 +691,36 @@ static struct acpi_bus_type acpi_pci_bus = { .cleanup = pci_acpi_cleanup, }; + +static struct fwnode_handle *(*pci_msi_get_fwnode_cb)(struct device *dev); + +/** + * pci_msi_register_fwnode_provider - Register callback to retrieve fwnode + * @fn: The interrupt domain to retrieve + * + * This should be called by irqchip driver, which is the parent of + * the MSI domain to provide callback interface to query fwnode. + */ +void +pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *)) +{ + pci_msi_get_fwnode_cb = fn; +} + +struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) +{ + struct irq_domain *dom = NULL; + struct fwnode_handle *fwnode = NULL; + + if (pci_msi_get_fwnode_cb) + fwnode = pci_msi_get_fwnode_cb(&bus->dev); + + if (fwnode) + dom = irq_find_matching_fwnode(fwnode, + DOMAIN_BUS_PCI_MSI); + return dom; +} + static int __init acpi_pci_init(void) { int ret; diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index edb1984..553a029 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -672,6 +672,8 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus) * should be called from here. */ d = pci_host_bridge_of_msi_domain(bus); + if (!d) + d = pci_host_bridge_acpi_msi_domain(bus); return d; } diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index d5e5c5b..a06feda 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -410,6 +410,11 @@ static inline bool irq_domain_is_hierarchy(struct irq_domain *domain) static inline void irq_dispose_mapping(unsigned int virq) { } static inline void irq_domain_activate_irq(struct irq_data *data) { } static inline void irq_domain_deactivate_irq(struct irq_data *data) { } +static inline struct irq_domain *irq_find_matching_fwnode( + struct fwnode_handle *fwnode, enum irq_domain_bus_token bus_token) +{ + return NULL; +} #endif /* !CONFIG_IRQ_DOMAIN */ #endif /* _LINUX_IRQDOMAIN_H */ diff --git a/include/linux/pci.h b/include/linux/pci.h index 6ae25aa..d86378c 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1946,6 +1946,16 @@ static inline struct irq_domain * pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; } #endif /* CONFIG_OF */ +#ifdef CONFIG_ACPI +struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus); + +void +pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *)); +#else +static inline struct irq_domain * +pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; } +#endif + #ifdef CONFIG_EEH static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev) {