Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754031AbbFIWJN (ORCPT ); Tue, 9 Jun 2015 18:09:13 -0400 Received: from mail-bn1on0138.outbound.protection.outlook.com ([157.56.110.138]:58400 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753697AbbFIWIy (ORCPT ); Tue, 9 Jun 2015 18:08:54 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) 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 v4 3/7] staging: fsl-mc: Propagate driver_override for a child DPRC's children Date: Tue, 9 Jun 2015 16:59:04 -0500 Message-ID: <1433887148-2310-4-git-send-email-German.Rivera@freescale.com> X-Mailer: git-send-email 2.3.3 In-Reply-To: <1433887148-2310-1-git-send-email-German.Rivera@freescale.com> References: <1433887148-2310-1-git-send-email-German.Rivera@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD013;1:EyzV0JYv9VeLrXmVRQkJaNJLBQp/+m+dIqv4U4GZdTymBXrIfTc2bq4WBcpChKdQhnnmyDlOhKlP1RiDi8psxZEGaLzIgieabgvet6CwoEM6iVsE70higqWRvilhLpaGXGwVcaJI5Msx10NNZ0KVRZ72PawQli4Pa2qw5zsEqqWHBBI86fm7Mg+e9s4oMz+i6ZPKUVJKdJWoIsL8dRkj12ep+zfDZaND7riGTmfMN3Gf4Nj61OWyVKtWVHsoFji5h12BxPnng1KHbJiLzBOYNznMxLr83T2ezYQrgroP6WqqAXWECyBHHo/VJD76t5goHo2vIInmB4Rjm3Yur07KQA== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(339900001)(199003)(189002)(76176999)(46102003)(50986999)(85426001)(36756003)(47776003)(77096005)(19580395003)(19580405001)(86362001)(106466001)(104016003)(229853001)(2201001)(50226001)(6806004)(87936001)(50466002)(62966003)(5001770100001)(5001960100002)(48376002)(105606002)(92566002)(2950100001)(189998001)(77156002)(107886002)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR03MB508;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB508;2:U8L/Dbh6OPQxEzzL/szlXA2FWJmbgEZW3SSKzrI5I2SMF8iHEFdwmfdkUrMn76Hx;2:obHsXumYmf8MbLhTIT9MRr2s0kkcEg6+fgSQxza6yFBeASWR9R667zhAJTt+UGeZLUx57OtttILHEjZ8Y/8ZeiFndubiv45g61lEa3EN/Q0xZpmO71+SQJTP++9LGjDKWquWXTnlJ/okKQn4fM7DDmzCyJMptBUelKXC8N8mhB63c0r2vj009CP7URIeCbrH6obIHTZjeeFV01NRe2svtp2F2mz/vI13hIkeR7185j0=;6:j34cF+siaB9tbMXEiUJ80xk4AbzHZ0hUS280QKWqO1dH9Z498bhMgL9cOaFdQmkoxlzur3ANw4id4L7ldVSP68PC5QNc23YxCit3yHDLh9zCdPYteMknw0g3uGv+JEs4mcdNfNFm2UwOo1q9z3Uj5+ocCE/H1XUHqyFdKmkcIhGiHwo1fRWI8BnVs8s2FrsA/MqHHK7YU6riyMCh4k/QGGMT8eiSvsVOK0yFByQpLxHDVoyUhKiOaQ2kE7HSgLshjrU8Z0YxfRgj+jkor1JRvASiB26OtHmxFzSafclqvOvEEv3ricUrVRahl59WHhXXNUz44b6X0gEtdmuIMORv8A==;3:AINuIAEA2isGmjhiMBnbFLsnMU0kFUlgmla/MCZWKXgP8iDu6zYGJXv5O0ivaU137ufyfiXeRoJbPU53km/p1ew/GLH5578YrhmKZyrN3Yw2gY0Gc4zt4wVVep7gxsEfaON1HaOyJhozxi4AmdOa9lpbqwjj13FUBp5u5BmCa40ge0OcTSKiYx/pfRA4SJzvny5ssD1UIhgtM61G8y1kd2QhicyFzDgD58fKAkfJMaCJ6GHt/W6oGIa7U7CUweqXOPpkCHEr7c/NnoltGjF8v2d7cXsnOF2AAC/HQ01IUhOf69u7M98ywte62S4+DLhh X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB508; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(520003)(3002001);SRVR:BY2PR03MB508;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB508; X-Forefront-PRVS: 06022AA85F X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB508;9:VVDmGVqB3sYJD3yS735wtsbz9q8/A62/IcSDaqymYIzXjSt5yHRjQRXA9JjvuOkL75MYJ4ZpJzc+ZP/1loatrsadnBqvKWViXIGkmNaeC4QoSZg0p763uuBUxh/8tztg3xGV5dA9K+FOXxyKQme2LZlpchG77MvSx33LOJ/J1elT0KSDjzs7viFxF3+Lb3UAjHmm5MNedfIFHyygguXEY3jh0OjbflEMJO2xzA245Jil9vgc7Qk4rVV5K12YjckeSeusZV9XfuT66hhIVkID2WKr+HULvpDB/7xH8Zt4wMZ2AoRgLgXvYo8+2MUjM7Lt3neeXvSZW8S9+PkO/4p2dUCthHrjnJsTA045fkFwcQFXNWYY5fBW1JHaJVMfruR1yKIzeHu+n0Z+jt8J5jHGh6xnbjPYw9z+Mb61DjInQWmIY0E1QcRYaYnUwSmEj0hnTmzw17OhPWWLqCGXJWEILYgCLwT6ifOh0aGRfDcRtbL6nuwzvSAJl5vm/vxAzxwvJk7lur5dYH0adZuBft9n9NASNcxBq/ytyD1akwAB39Hi9hYMqcpBzvM7KUvv8YCFxDvha4VKEJJVz98lomuDuFGhBV6Lt9jcJsNa/qDHs8NCmUZfHLiKYVpkysgYKPJu38UcS4mw7T2dCri/ktKTbvj7SVH9oYsRcFxj0NG2vqTYg/cG4KKoooYSn5e0Cp1xdChHbcjXco2lzWSa/EQ/O4g3rG8mUDgJqRkSpdaIFoww5+iFplTXFbtIux1/iFWhKd0VZS/3rGjXxomI/lbhOgs6Of1z3WQ+nqNhvjd0OLG2XOd7axMnMTDmucybUz9WYcmZoVsdvwIWqBzJ6yBMxwshbHWJ5DbuIKtI7AyZZ+lufDIHiZH/MLECcvjVy6rYcgRFRGu+xhNr0r8OCXMKGQ== X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB508;3:3Whz7hKwVS2dNFuXfRwLwsgVrtZ3ODGtXUxyHwr2AKodlk07a414BtNvqfqBMxdJt6U/gOKo4g+xc+GS7AssOgNwN3aRozKPdy0VhfSPh40Ys5LCLoZAqNNrlOB6KM4dzsunYlkQMYcSbg0fQIY3Fw==;10:6/z9plcjDV9jTlPpS23+WYw1CMnJjQToj3rTmquoAzX1R4cjsjiceQJGYtDOW+Zv2XO7GygS2WMzCjW5Qi38H72m1150ib1a6/sSzOdTriM=;6:4D78dkXB1nfRN8xWitz+D6AGDX2DY7DZDFGe0AFmKlwV+lNuLoGDkOYQ8VR+hm4O X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2015 22:08:50.4353 (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.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB508 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6533 Lines: 163 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 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 5351170..85ec91b 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; } @@ -211,6 +214,8 @@ static void dprc_init_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 @@ -226,6 +231,7 @@ static void dprc_init_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; @@ -295,7 +301,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); kfree(child_obj_desc_array); @@ -324,7 +330,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) return error; @@ -397,7 +403,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 fdd3d17..60e45be 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); mc_dev->dev.parent = parent_dev; mc_dev->dev.bus = &fsl_mc_bus_type; @@ -870,7 +883,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/