Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030868AbbD1Rrb (ORCPT ); Tue, 28 Apr 2015 13:47:31 -0400 Received: from mail-bl2on0124.outbound.protection.outlook.com ([65.55.169.124]:6400 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1030812AbbD1Rr0 (ORCPT ); Tue, 28 Apr 2015 13:47:26 -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 3/7] staging: fsl-mc: Propagate driver_override for a child DPRC's children Date: Tue, 28 Apr 2015 12:39:06 -0500 Message-ID: <1430242750-17745-4-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)(199003)(189002)(76176999)(77096005)(50226001)(48376002)(5001770100001)(50986999)(6806004)(19580395003)(19580405001)(104016003)(62966003)(50466002)(15975445007)(19625305001)(77156002)(85426001)(46102003)(47776003)(2201001)(86362001)(87936001)(2950100001)(229853001)(105606002)(36756003)(92566002)(106466001)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0301MB1307;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1307; 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:CY1PR0301MB1307;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1307; X-Forefront-PRVS: 0560A2214D X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2015 17:47:12.6488 (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: CY1PR0301MB1307 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6643 Lines: 166 When a child DPRC is bound to the vfio_fsl_mc driver via driver_override, its own children should not be bound to corresponding host kernel drivers, but instead should be bound to the vfio_fsl_mc driver as well. Currently, when a child container is scanned by the vfio_fsl_mc driver, child devices found are automatically bound to corresponding host kernel drivers (e.g., DPMCP and DPBP objects are bound to the fsl_mc_allocator driver, DPNI objects are bound to the ldpaa_eth driver, etc), Then, the user has to manually unbind these child devices from their drivers, set the driver_override sysfs attribute to vfio_fsl_mc driver, for each of them and rebind them. Signed-off-by: J. German Rivera Change-Id: I51e633367b019da1cd45bd4898e46be577b8ce42 Reviewed-on: http://git.am.freescale.net:8181/34567 Tested-by: Review Code-CDREVIEW Reviewed-by: Stuart Yoder Tested-by: Stuart Yoder --- drivers/staging/fsl-mc/bus/dprc-driver.c | 14 ++++++++++---- drivers/staging/fsl-mc/bus/mc-bus.c | 16 +++++++++++++++- drivers/staging/fsl-mc/include/mc-private.h | 2 ++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl-mc/bus/dprc-driver.c index 8531ba8..ce88859 100644 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c @@ -151,6 +151,8 @@ static void check_plugged_state_change(struct fsl_mc_device *mc_dev, * dprc_add_new_devices - Adds devices to the logical bus for a DPRC * * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object + * @driver_override: driver override to apply to new objects found in the DPRC, + * or NULL, if none. * @obj_desc_array: array of device descriptors for child devices currently * present in the physical DPRC. * @num_child_objects_in_mc: number of entries in obj_desc_array @@ -160,6 +162,7 @@ static void check_plugged_state_change(struct fsl_mc_device *mc_dev, * in the physical DPRC. */ static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev, + const char *driver_override, struct dprc_obj_desc *obj_desc_array, int num_child_objects_in_mc) { @@ -183,7 +186,7 @@ static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev, } error = fsl_mc_device_add(obj_desc, NULL, &mc_bus_dev->dev, - &child_dev); + driver_override, &child_dev); if (error < 0) continue; } @@ -242,6 +245,8 @@ static void dprc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev) * dprc_scan_objects - Discover objects in a DPRC * * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object + * @driver_override: driver override to apply to new objects found in the DPRC, + * or NULL, if none. * @total_irq_count: total number of IRQs needed by objects in the DPRC. * * Detects objects added and removed from a DPRC and synchronizes the @@ -257,6 +262,7 @@ static void dprc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev) * of the device drivers for the non-allocatable devices. */ int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev, + const char *driver_override, unsigned int *total_irq_count) { int num_child_objects; @@ -326,7 +332,7 @@ int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev, dprc_remove_devices(mc_bus_dev, child_obj_desc_array, num_child_objects); - dprc_add_new_devices(mc_bus_dev, child_obj_desc_array, + dprc_add_new_devices(mc_bus_dev, driver_override, child_obj_desc_array, num_child_objects); if (child_obj_desc_array) @@ -357,7 +363,7 @@ static int dprc_scan_container(struct fsl_mc_device *mc_bus_dev) * Discover objects in the DPRC: */ mutex_lock(&mc_bus->scan_mutex); - error = dprc_scan_objects(mc_bus_dev, &irq_count); + error = dprc_scan_objects(mc_bus_dev, NULL, &irq_count); mutex_unlock(&mc_bus->scan_mutex); if (error < 0) goto error; @@ -433,7 +439,7 @@ static irqreturn_t dprc_irq0_handler_thread(int irq_num, void *arg) DPRC_IRQ_EVENT_OBJ_CREATED)) { unsigned int irq_count; - error = dprc_scan_objects(mc_dev, &irq_count); + error = dprc_scan_objects(mc_dev, NULL, &irq_count); if (error < 0) { dev_err(dev, "dprc_scan_objects() failed: %d\n", error); goto out; diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c index a419c2f..08fd559 100644 --- a/drivers/staging/fsl-mc/bus/mc-bus.c +++ b/drivers/staging/fsl-mc/bus/mc-bus.c @@ -401,6 +401,7 @@ error_cleanup_regions: int fsl_mc_device_add(struct dprc_obj_desc *obj_desc, struct fsl_mc_io *mc_io, struct device *parent_dev, + const char *driver_override, struct fsl_mc_device **new_mc_dev) { int error; @@ -433,6 +434,18 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc, mc_dev->obj_desc = *obj_desc; mc_dev->mc_io = mc_io; + if (driver_override) { + /* + * We trust driver_override, so we don't need to use + * kstrndup() here + */ + mc_dev->driver_override = kstrdup(driver_override, GFP_KERNEL); + if (!mc_dev->driver_override) { + error = -ENOMEM; + goto error_cleanup_dev; + } + } + device_initialize(&mc_dev->dev); /* @@ -1082,7 +1095,8 @@ static int fsl_mc_bus_probe(struct platform_device *pdev) obj_desc.irq_count = 1; obj_desc.region_count = 0; - error = fsl_mc_device_add(&obj_desc, mc_io, &pdev->dev, &mc_bus_dev); + error = fsl_mc_device_add(&obj_desc, mc_io, &pdev->dev, NULL, + &mc_bus_dev); if (error < 0) goto error_cleanup_mc_io; diff --git a/drivers/staging/fsl-mc/include/mc-private.h b/drivers/staging/fsl-mc/include/mc-private.h index 6e33942..5b9c8f2 100644 --- a/drivers/staging/fsl-mc/include/mc-private.h +++ b/drivers/staging/fsl-mc/include/mc-private.h @@ -106,11 +106,13 @@ struct fsl_mc_bus { int __must_check fsl_mc_device_add(struct dprc_obj_desc *obj_desc, struct fsl_mc_io *mc_io, struct device *parent_dev, + const char *driver_override, struct fsl_mc_device **new_mc_dev); void fsl_mc_device_remove(struct fsl_mc_device *mc_dev); int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev, + const char *driver_override, unsigned int *total_irq_count); int __init dprc_driver_init(void); -- 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/