From patchwork Wed Dec 9 19:24:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 7811611 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 D53C89F349 for ; Wed, 9 Dec 2015 19:27:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 43A69204E2 for ; Wed, 9 Dec 2015 19:27:36 +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 3CDDA203A5 for ; Wed, 9 Dec 2015 19:27:35 +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 1a6kMe-0005eM-MR; Wed, 09 Dec 2015 19:25:24 +0000 Received: from mail-bn1on0059.outbound.protection.outlook.com ([157.56.110.59] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a6kMU-0004RN-0l for linux-arm-kernel@lists.infradead.org; Wed, 09 Dec 2015 19:25:14 +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 BLUPR12MB0433.namprd12.prod.outlook.com (10.162.92.139) with Microsoft SMTP Server (TLS) id 15.1.355.16; Wed, 9 Dec 2015 19:24:48 +0000 From: Suravee Suthikulpanit To: , , , Subject: [PATCH v6 1/4] acpi: pci: Setup MSI domain for ACPI based pci devices Date: Wed, 9 Dec 2015 11:24:31 -0800 Message-ID: <1449689074-30609-2-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1449689074-30609-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1449689074-30609-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY1PR20CA0108.namprd20.prod.outlook.com (25.164.213.162) To BLUPR12MB0433.namprd12.prod.outlook.com (25.162.92.139) X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0433; 2:MGJIXDzgMfO4qd7k0OHFbP0MJW54ry4/0clfzbwf7Oit0dyFLDxdw+MPax1aY/WIGYu8Ye+OUZ1bYl0+P6AS3IF8udf5E0ggHGu5yuopd7490AK2EJngZBNWfRS5nutyrjztt1Dlr2iRk82ik+AgIA==; 3:ybCX2ZCPcmCY+/tYFDUqe6niRImjbJAJibgKIL6wJuEteu0MSlezISNWv+WuBwoDZDQtu5mt/HiVJ5303Ye2wlc61FigCKlRftOYABGoE2OQ8Znt9aDB6TxNQ/18c6c1; 25:Gpd3Z2B8qmSgGsmPeiSUqxd73L1jJZyNBW6xD66zfQeNRjUOgAuKScHJo+hW8/I2XXsI3fEJz4RLKs4Q2IkggUWRGwWqaXQdCAyT/AdETUMqdGVnvM5P/kZcFkOhW5RO7KPSfSIOZmkHba9n7RGDlWPxLB4Sg9xUDga/gTnJc1Zc8FEBzUHt5ttSqmxd4dHQmrzVTkjQxayqQD5IGF/S7qMnI+m4wGcr64CaM30H7ZKSNTGZ7JTlhZVMKGJH+cPgg87AoEj1wemipSJdRRsibQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR12MB0433; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0433; 20:QQJHDe8tAodC92tsOMu04rAP1ngKUj+Xx6b3lcwgsZfns7KYYFyVNFG5Ui3coEEZWzMtqKowA6YaGo1nNTd04kwQUNfnIXo8lcAGm6xS1go5fa+eYDOUuWwhk+Yew4tpsc1qqCTImH7WP1kWyswerpFsguPwN2lBrnPdKaqMXQKUS47k4ijVez8X2/98Xa2NG8P8OcgzHduzfMb3Nk9Hjc+EZ7xsJrdLBfE5IxmsSw22p9yxywbN+piNRGeZ5BYFw4NPEk41pDGqJj+bzC9wSAP5fdsbL2JpBkV7TVBmzGGgknKxZ0kQUWhb3gArtl+J5hmiKtjRTHH5ApCMG8IxSgPlHyUWAHsOnPkD3Rp4dE2RY/1HcLEugt1RHiOq0zImAKA5yDqgvidLPEFrsNLf5BxNJxhiJ5BwgjVwLoXlq963utSrr9byUilqmtlGDw56LORhGj94Zji6uHvYoOSdGSlmn74hwSTYI1yCLb8OknYXhaZAiV/7Mi7twVYhD/1F X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001)(10201501046); SRVR:BLUPR12MB0433; BCL:0; PCL:0; RULEID:; SRVR:BLUPR12MB0433; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0433; 4:MfY7mTKzsljfesbwXVo+En+SHqvWOisuYkRMqFRFNlmuRskcjvf2tDr/DbKNM3gjD2+EkLZS5rWcdk55MMatFLh18tSGEztBUC/lmW3UWTJ10+DJ4qoyb18n6/D+Mg+h5R6Ht5aNBLOQ3QXgnZ2smUI1FSEJBR6YbOg9k5NCyVX8+F+jTaahxXg8fe53n9Tr2B1RyMwCi39G/xuokMqZB8tCWkQ1aeak5IK3U0e8T79BELwVAEvexEoNVSF7pfO+ZDnnTLB0Z3SB7aWiHc1gB3RN/kg4zl6i4385KCb9BFibYl38pOjWsdqyCHFE9LRGe0hlCM2Rqe7p3sh7lx6aHVklmZRoVL6Fx+8BYQhKY1zkh1cNqL2QJXf0sSVdSpp0rkuDAksWWYyxLQ0iS6g89+k26Ix1OLoNtUVCHOTD0baKArzr8TqZHVRmsxFUgoihFQPdge/CldR48UW63wMIwQ== X-Forefront-PRVS: 0785459C39 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(6009001)(199003)(189002)(5001770100001)(50226001)(122386002)(229853001)(36756003)(42186005)(106356001)(105586002)(5004730100002)(86362001)(5003940100001)(2201001)(66066001)(47776003)(53416004)(92566002)(76176999)(97736004)(586003)(189998001)(101416001)(5008740100001)(1096002)(50986999)(50466002)(40100003)(3846002)(2950100001)(77096005)(6116002)(48376002)(87976001)(19580395003)(19580405001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR12MB0433; H:ssuthiku-fedora-lt.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; BLUPR12MB0433; 23:RQd8C7SiL8vb686ym2FI2gIf0zDnGEU+h7oHQo3kE?= =?us-ascii?Q?d/CD6xjiJ2dMl5VUWERP9M+1SKW7H/gukgZzMoWxCU4tkWJ2jYy90QlljE2d?= =?us-ascii?Q?NlWA7ld8HTwz4r2cAmEL+oxvOUJzPpyM4Ot/0mO2vs7FoESKoR8Ftg4+SG1e?= =?us-ascii?Q?I/mo2He336395ldnk8WD3XpyWZVeDgR3NDMK/zXAaPXOuVtBlzvt34co2a0n?= =?us-ascii?Q?soiy+VNwXHKAhQvxyFFZJgabW5v+Sotsor80c9qoF8FvenGxkEjqcBZbATuN?= =?us-ascii?Q?ARp/tZQ8XbSiLKPD9v21HanCvvPlTixlE5cwCWdnQtI/ZnAV5Kqv34ux+iSO?= =?us-ascii?Q?BAP6SG5Ahlwp0Cs3U17qVtHmYEexKgz5h1XmPc3GtbjcDdiWIX4iyZpPtQ6Q?= =?us-ascii?Q?7GNpzMmBwtcetG9oiTQ7VFVYA2cKqrRXKLcHMz2n0P4WxBPrRQFPTgVmuEw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27pY3DEog29wNcz1d8+P3uiAcbxgk/HX15JpJEQwmPL6Q/4dyhu48=; 20:gEIB2uCwCpA2Ae7KaBEzFtZHsyro8zBX33xL+amugftwAGInPZFDyTdviuOd8Ze5Tkce7yz5iwJfAWDk/NaHEg3jEpaTiTETmy9lTZyb0uyhW4yBNGf+hR2xpQ3SqIUugkFMjyy1KeRxSul1Bt7WDTOPynb+BjRJurn2LmBSWaAga9rwDPkk73pIkoxKJ0knEWDdwKegWLM29ATCLzwKwzlJqCMSkKnSZYMbPQYJT+rvrn1w8T89Q3+VHIZ3osg3 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2015 19:24:48.9067 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR12MB0433 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151209_112514_145571_40ABFFBC X-CRM114-Status: GOOD ( 12.65 ) 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. Reviewed-by: Marc Zyngier Signed-off-by: Suravee Suthikulpanit --- drivers/pci/pci-acpi.c | 42 ++++++++++++++++++++++++++++++++++++++++++ drivers/pci/probe.c | 2 ++ include/linux/irqdomain.h | 5 +++++ include/linux/pci.h | 10 ++++++++++ 4 files changed, 59 insertions(+) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index a32ba75..d3f32d6 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,46 @@ 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: Callback matching a device to a fwnode that identifies a PCI + * MSI domain. + * + * 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; +} + +/** + * pci_host_bridge_acpi_msi_domain - Retrieve MSI domain of a PCI host bridge + * @bus: The PCI host bridge bus. + * + * This function uses the callback function registered by + * pci_msi_register_fwnode_provider() to retrieve the irq_domain with + * type DOMAIN_BUS_PCI_MSI of the specified host bridge bus. + * This returns NULL on error or when the domain is not found. + */ +struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) +{ + struct fwnode_handle *fwnode; + + if (!pci_msi_get_fwnode_cb) + return NULL; + + fwnode = pci_msi_get_fwnode_cb(&bus->dev); + if (!fwnode) + return NULL; + + return irq_find_matching_fwnode(fwnode, DOMAIN_BUS_PCI_MSI); +} + 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) {