From patchwork Thu Dec 10 16:55:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 58229 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp615381lbb; Thu, 10 Dec 2015 08:56:37 -0800 (PST) X-Received: by 10.98.7.129 with SMTP id 1mr8360158pfh.70.1449766596912; Thu, 10 Dec 2015 08:56:36 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 81si21350413pfr.79.2015.12.10.08.56.35; Thu, 10 Dec 2015 08:56:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754157AbbLJQ4e (ORCPT + 28 others); Thu, 10 Dec 2015 11:56:34 -0500 Received: from mail-bn1on0079.outbound.protection.outlook.com ([157.56.110.79]:17680 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753376AbbLJQzz (ORCPT ); Thu, 10 Dec 2015 11:55:55 -0500 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; Thu, 10 Dec 2015 16:55:50 +0000 From: Suravee Suthikulpanit To: , , , , CC: Lorenzo Pieralisi , Will Deacon , Catalin Marinas , , , , , , , , , "Suravee Suthikulpanit" Subject: [PATCH v7 1/4] acpi: pci: Setup MSI domain for ACPI based pci devices Date: Thu, 10 Dec 2015 08:55:27 -0800 Message-ID: <1449766530-16935-2-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1449766530-16935-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1449766530-16935-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY1PR14CA0031.namprd14.prod.outlook.com (25.163.13.169) To BLUPR12MB0433.namprd12.prod.outlook.com (25.162.92.139) X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0433; 2:++tJ4IllXGL8HaFM97VVUa/GWDf7cRlPWCUJKsKFnbtmKjRZSfqv3jwcjWAv+RFZip2Z6rjtKsy1mArE2ZeggWczXCfVXW/XCV0rabhmG42JI1VjJzqfuJj2IZKzyYo1jIPLR4iXWeWJop4QzAxoSw==; 3:s/xP9G8vGf0+w92LQWfw8SgjhsDr3oDYCNrngPav/LR5YUnyKTaJO5GenU24D/F2jtzy3JokqwiqMLCXr2hYCGeRlNOyMMfyVSc8BNmWb/nxEMzWeICOU3GFUV1brGuH; 25:cdtwxAgVC1waPxwmUzwy5ZRMNM6rBQWOM8VNuNm6320DfOfeUeAgWdIwPQ84MjByvC05vkwV2qXV7lAYYgdsBg91Y/4XWiudf6ekUK6Wo+74QbQGLtuQ1ckNvEFksjlf0K5oPS75LCnAGEdUX4Ix3YyZ2c4fG1Opm8GTImG15bXnF2NM9Im1caIL66/vmXiHXCWHvsv7k8tK+jRv0FA3gZAHHm3WIug1ZdXp6j/9uplXyb06EKzzAPPPSCuMI8QITusQXzYxQMxU9wQIKgBueA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR12MB0433; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0433; 20:vvrYBKm4uRj4tYpnmN/ru59nfJhnWSAxEMY5CKqdZRNi1AShl8H+xJ9nfxZN2vs198pJ8y0QcxAyYDbe6dopzP2LUStNLcahRiP9+qgzCq+S7F1WvJk/U2N7vHkzsSOaTenkX5dVaCErHFf29bYC+bDTyuZSDDXI31B6a5rEhbhdphnwKELlp7ypOP0tAOYOuaYqMTbgW3RVKxmkqwVvyaYVq2m2IdszleNchsqp0liSq5es7xKSANEAVauid6WVODy2vDKGvuDVz7BpIDgb2HnvXjOYI8lJJ6kLKb+DHEdbZR6TF7rK5a/Y7etltFH3aqhW/3d9SUKQHYeiBwgLgEapv2+O1lcuhrDZ8xDgP9coLwhLIr9bvYZ30a00hpbCcOQXg25Hc1FypJNMuitiAh4I7ck4jpwOspzwB9JINPX0Lebe0N33tjbzYKFaMoBUZEj1u9Lt7rquPCBJi516Kl712BR64fcp4ksi34yMMPSOhi0bbM0pwVuTQhn6Czc2 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)(520078)(8121501046)(5005006)(10201501046)(3002001); SRVR:BLUPR12MB0433; BCL:0; PCL:0; RULEID:; SRVR:BLUPR12MB0433; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0433; 4:tgu8tOjSWz4Sm5S1sUiPoQbvlCWALu3ZgjUhwep4NqrsZr98FTpob0kvNKbTSzRLHrmv69pBhi3cER6ShipOwwlhlCUGiIHyX4mjAJ+kkxhen2dGDC6oxrit486hQuZNtWntQQ+g85gu60VIzjx7PLnZLlK5vi2dJDfUABn+8gTXiuG1/R0ThiMRrougRocZVk0q+16pqK2ZhjUDxWbZoPtwVXHVswUEIU/ciuuGE7c4TouVl+rY0fld2o8GbQhqDEJV9tbRFpwFk0C0OTgMOap0E0dLhL/mjQJHdSnINLvAhHHZUdnjnmnsZIodo3z9Yh5yWX2I6IHgRb0L0DN+YUPGAKOnsxUKDYox9SEeSHtJ9+UPbnK7GgKf8Z2Qhd2m2OwMt16NeGyBV4l7OS5tCclC0708de9ztaR/o26DPRt8+B2lJ1QvUH5JV5zVA+qnomubEAqCUyTqWSHoZSPh8A== X-Forefront-PRVS: 078693968A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(97736004)(50226001)(122386002)(5001770100001)(42186005)(229853001)(36756003)(106356001)(47776003)(2201001)(66066001)(5004730100002)(105586002)(53416004)(86362001)(5003940100001)(189998001)(5008740100001)(76176999)(586003)(101416001)(50986999)(50466002)(40100003)(3846002)(1096002)(2950100001)(77096005)(48376002)(6116002)(87976001)(19580395003)(19580405001)(92566002); 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:JT61fUQ59Zo3SVpCxOSBg2ZPBnizxN2GTYJD69N2r?= =?us-ascii?Q?fRCsUuwV2ifNyp9dLoFi2qdwIZSgXClTHqR0Ty9nyoL6DjXATige8ILCAAbD?= =?us-ascii?Q?7L8vF81hBf1LrEvBa7wAdd5Ou/NnU9sOX83CxZju0tIbX8blmwfxuF1yvmnT?= =?us-ascii?Q?9Wx+1V09UM6HOt1qw95OVXujgSLQAfeUg/hBEsHOWr2swSEotUwT22OULUDm?= =?us-ascii?Q?lFcJq6QDptdDeZvbmDvUVmZypcQHbKnIdQHckcMk+wCi54zQ3yayjRkYF4Yb?= =?us-ascii?Q?XixyZiNQdiFL2gdk1r8SONYYVeBBpVE4iOGuXPCByoDtibym3HIsEbt+Go5S?= =?us-ascii?Q?OC6e4rCaIz1JghN8MDwqUQa+3e0rHN/pwwG4gX1byq/uCzUKJRRIcPua6slw?= =?us-ascii?Q?AK5NfdTDzgikDl4GA+djzX5FBZ9VhfIiKNkGpQBQHXZT5y9CAyfpGvGffk2h?= =?us-ascii?Q?ORYTCFSMEO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wpwP9Ck61WNL0mfbZcMBk8wa/RKswQly46SnX57xpmEz7wcGqMjyxMVQFdSwpJNQwWmjcl6gOnKf4u8R4SF+cwBk5mSS7OpvFAO79frGjkymVk+Q9RhfVAVM8VS0H+eQ7tWIhUwZJT51whMM3JR6 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2015 16:55:50.8280 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR12MB0433 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Bjorn Helgaas Cc: Rafael J. Wysocki 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(+) -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ 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) {