Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030925AbbD1SDU (ORCPT ); Tue, 28 Apr 2015 14:03:20 -0400 Received: from mail-by2on0129.outbound.protection.outlook.com ([207.46.100.129]:24056 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1030316AbbD1SDQ (ORCPT ); Tue, 28 Apr 2015 14:03:16 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; From: "J. German Rivera" To: , , , CC: , , , , , , , , , "J. German Rivera" Subject: [PATCH 5/7] staging: fsl-mc: Allow the MC bus driver to run without GIC support Date: Tue, 28 Apr 2015 12:39:08 -0500 Message-ID: <1430242750-17745-6-git-send-email-German.Rivera@freescale.com> X-Mailer: git-send-email 2.3.3 In-Reply-To: <1430242750-17745-1-git-send-email-German.Rivera@freescale.com> References: <1430242750-17745-1-git-send-email-German.Rivera@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;BMV:1;SFV:NSPM;SFS:(10019020)(6009001)(279900001)(339900001)(189002)(199003)(46102003)(48376002)(47776003)(76176999)(2201001)(77096005)(15975445007)(50466002)(86362001)(87936001)(105606002)(92566002)(6806004)(50986999)(77156002)(19580405001)(2950100001)(85426001)(104016003)(36756003)(229853001)(5001770100001)(62966003)(19625305001)(50226001)(19580395003)(106466001)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR03MB506;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB506; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5002010)(5005006)(3002001);SRVR:BY2PR03MB506;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB506; X-Forefront-PRVS: 0560A2214D X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2015 17:47:08.8963 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB506 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7432 Lines: 202 If the lpi-parent property is not present in the fsl,qoriq-mc node of the device tree, the MC bus driver will assume that the GIC is not supported. This change is made in order to be able to use the MC bus driver in a KVM VM, without having GIC-ITS support in guests. Added function fsl_mc_interrupts_supported(), which can be called from DPAA2 object drivers. Signed-off-by: J. German Rivera Change-Id: I881ab2c45c949e55cfafe1d281a7a31560955e5b Reviewed-on: http://git.am.freescale.net:8181/34712 Tested-by: Review Code-CDREVIEW Reviewed-by: Stuart Yoder --- drivers/staging/fsl-mc/bus/dprc-driver.c | 31 +++++++++++++++++++---------- drivers/staging/fsl-mc/bus/mc-allocator.c | 4 ++++ drivers/staging/fsl-mc/bus/mc-bus.c | 16 +++++++++++++-- drivers/staging/fsl-mc/include/mc-private.h | 4 ++++ drivers/staging/fsl-mc/include/mc.h | 2 ++ 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl-mc/bus/dprc-driver.c index b84cca3..ff321c9 100644 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c @@ -412,6 +412,7 @@ static int dprc_scan_container(struct fsl_mc_device *mc_bus_dev) int error; unsigned int irq_count; struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev); + struct fsl_mc *mc = dev_get_drvdata(fsl_mc_bus_type.dev_root->parent); dprc_init_all_resource_pools(mc_bus_dev); @@ -424,7 +425,7 @@ static int dprc_scan_container(struct fsl_mc_device *mc_bus_dev) if (error < 0) goto error; - if (!mc_bus->irq_resources) { + if (mc->gic_supported && !mc_bus->irq_resources) { irq_count += FSL_MC_IRQ_POOL_MAX_EXTRA_IRQS; error = fsl_mc_populate_irq_pool(mc_bus, irq_count); if (error < 0) @@ -754,6 +755,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) int error; size_t region_size; struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); + struct fsl_mc *mc = dev_get_drvdata(fsl_mc_bus_type.dev_root->parent); if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0)) return -EINVAL; @@ -792,12 +794,15 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) if (error < 0) goto error_cleanup_open; - /* - * Configure interrupts for the DPRC object associated with this MC bus: - */ - error = dprc_setup_irqs(mc_dev); - if (error < 0) - goto error_cleanup_dprc_scan; + if (mc->gic_supported) { + /* + * Configure interrupts for the DPRC object associated with + * this MC bus: + */ + error = dprc_setup_irqs(mc_dev); + if (error < 0) + goto error_cleanup_dprc_scan; + } dev_info(&mc_dev->dev, "DPRC device bound to driver"); return 0; @@ -805,7 +810,8 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) error_cleanup_dprc_scan: device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove); dprc_cleanup_all_resource_pools(mc_dev); - fsl_mc_cleanup_irq_pool(mc_bus); + if (mc->gic_supported) + fsl_mc_cleanup_irq_pool(mc_bus); error_cleanup_open: (void)dprc_close(mc_dev->mc_io, mc_dev->mc_handle); @@ -839,6 +845,7 @@ static int dprc_remove(struct fsl_mc_device *mc_dev) { int error; struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); + struct fsl_mc *mc = dev_get_drvdata(fsl_mc_bus_type.dev_root->parent); if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0)) return -EINVAL; @@ -848,14 +855,18 @@ static int dprc_remove(struct fsl_mc_device *mc_dev) if (WARN_ON(!mc_bus->irq_resources)) return -EINVAL; - dprc_teardown_irqs(mc_dev); + if (mc->gic_supported) + dprc_teardown_irqs(mc_dev); + device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove); dprc_cleanup_all_resource_pools(mc_dev); error = dprc_close(mc_dev->mc_io, mc_dev->mc_handle); if (error < 0) dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error); - fsl_mc_cleanup_irq_pool(mc_bus); + if (mc->gic_supported) + fsl_mc_cleanup_irq_pool(mc_bus); + dev_info(&mc_dev->dev, "DPRC device unbound from driver"); return 0; } diff --git a/drivers/staging/fsl-mc/bus/mc-allocator.c b/drivers/staging/fsl-mc/bus/mc-allocator.c index 0c5fad0..313a533 100644 --- a/drivers/staging/fsl-mc/bus/mc-allocator.c +++ b/drivers/staging/fsl-mc/bus/mc-allocator.c @@ -489,6 +489,10 @@ int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device *mc_dev) struct fsl_mc_device_irq **irqs = NULL; struct fsl_mc_bus *mc_bus; struct fsl_mc_resource_pool *res_pool; + struct fsl_mc *mc = dev_get_drvdata(fsl_mc_bus_type.dev_root->parent); + + if (!mc->gic_supported) + return -ENOTSUPP; if (WARN_ON(mc_dev->irqs)) goto error; diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c index 55a8b86..be2faf6 100644 --- a/drivers/staging/fsl-mc/bus/mc-bus.c +++ b/drivers/staging/fsl-mc/bus/mc-bus.c @@ -287,6 +287,14 @@ void fsl_mc_driver_unregister(struct fsl_mc_driver *mc_driver) } EXPORT_SYMBOL_GPL(fsl_mc_driver_unregister); +bool fsl_mc_interrupts_supported(void) +{ + struct fsl_mc *mc = dev_get_drvdata(fsl_mc_bus_type.dev_root->parent); + + return mc->gic_supported; +} +EXPORT_SYMBOL_GPL(fsl_mc_interrupts_supported); + static int get_dprc_icid(struct fsl_mc_io *mc_io, int container_id, uint16_t *icid) { @@ -1003,8 +1011,12 @@ static int fsl_mc_bus_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mc); error = create_mc_irq_domain(pdev, &mc->irq_domain); - if (error < 0) - return error; + if (error < 0) { + dev_warn(&pdev->dev, + "WARNING: MC bus driver will run without interrupt support\n"); + } else { + mc->gic_supported = true; + } /* * Get physical address of MC portal for the root DPRC: diff --git a/drivers/staging/fsl-mc/include/mc-private.h b/drivers/staging/fsl-mc/include/mc-private.h index 67ba488..0757258 100644 --- a/drivers/staging/fsl-mc/include/mc-private.h +++ b/drivers/staging/fsl-mc/include/mc-private.h @@ -42,11 +42,15 @@ * struct fsl_mc - Private data of a "fsl,qoriq-mc" platform device * @root_mc_bus_dev: MC object device representing the root DPRC * @irq_domain: IRQ domain for the fsl-mc bus type + * @gic_supported: boolean flag that indicates if the GIC interrupt controller + * is supported. + * @num_translation_ranges: number of entries in addr_translation_ranges * @addr_translation_ranges: array of bus to system address translation ranges */ struct fsl_mc { struct fsl_mc_device *root_mc_bus_dev; struct irq_domain *irq_domain; + bool gic_supported; uint8_t num_translation_ranges; struct fsl_mc_addr_translation_range *translation_ranges; }; diff --git a/drivers/staging/fsl-mc/include/mc.h b/drivers/staging/fsl-mc/include/mc.h index 0a2f381d..c2a702e4 100644 --- a/drivers/staging/fsl-mc/include/mc.h +++ b/drivers/staging/fsl-mc/include/mc.h @@ -209,6 +209,8 @@ int __must_check __fsl_mc_driver_register(struct fsl_mc_driver *fsl_mc_driver, void fsl_mc_driver_unregister(struct fsl_mc_driver *driver); +bool fsl_mc_interrupts_supported(void); + int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev, uint16_t mc_io_flags, struct fsl_mc_io **new_mc_io); -- 2.3.3 -- 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/