Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753135AbbLKS3A (ORCPT ); Fri, 11 Dec 2015 13:29:00 -0500 Received: from mail-by2on0107.outbound.protection.outlook.com ([207.46.100.107]:36448 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751157AbbLKS1N (ORCPT ); Fri, 11 Dec 2015 13:27:13 -0500 Authentication-Results: spf=permerror (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none;freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; From: "J. German Rivera" To: , , , CC: , , , , , , , , , , , , , , "J. German Rivera" Subject: [PATCH v4 07/11] staging: fsl-mc: Populate the IRQ pool for an MC bus instance Date: Fri, 11 Dec 2015 12:09:45 -0600 Message-ID: <1449857389-2506-8-git-send-email-German.Rivera@freescale.com> X-Mailer: git-send-email 2.3.3 In-Reply-To: <1449857389-2506-1-git-send-email-German.Rivera@freescale.com> References: <1449857389-2506-1-git-send-email-German.Rivera@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11OLC001;1:4r0XJvb3KreU6CgeWfgCREnDK1i9SFQSzToSQHrgI/Uhtl5mAc8+qT/fO931O3IdI5x+tpATh9awRN0xBfKP3I9uJAXFG4f3OVqy91FYm0U0uSjSgRRWzhbTheIdSCo1xsl0RmrK1h0hHjtfa5TKKO8zpIvOMIhPFaUB14T7gl7bW5oRgiAxDRrCBosWyns2sww7eDTns/0tESeVY/t5qEjILPWxmIIisppdVR0D8rH6jMxIkm+REY08R7QPQSG1Rt/8XMq2CRxUnfjKxzdq3EsoUWeOYJU+z0DjZF6nEP2M+pXiJoaxJTywQk1GAHu1lhpQVbDVmLA1pmcD4ncdK5ZPmDKDHxlQrRVe8PidIzwbvSfBZwTbxLuvQWDIWfa0jvRjqJnFd+DUtshxnMYb3k6qzlHM8adb4HDDrmDneMlrUgk9K55EU7BCNwRquyOZ X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(448002)(199003)(189002)(104016004)(19580405001)(76176999)(47776003)(5008740100001)(87936001)(5003940100001)(5001960100002)(189998001)(4001430100002)(1220700001)(107886002)(36756003)(586003)(1096002)(6806005)(2950100001)(77096005)(2201001)(11100500001)(86362001)(85326001)(229853001)(106466001)(50466002)(50986999)(48376002)(81156007)(5001770100001)(97736004)(19580395003)(92566002)(50226001);DIR:OUT;SFP:1102;SCL:1;SRVR:BL2PR03MB498;H:tx30smr01.am.freescale.net;FPR:;SPF:PermError;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB498;2:L5InDu2D3kY1/0CBEwHUsVDaawwon63R0VAusHpTXmaf7mqf5jVvzmt3JHr6/BRw6RZ3UexxhfHVTb15AG+LSGEF/kuTrtx9hAYp/gfCliHehbHGEf/CHAbaULrOZnGuhsgJgjXRrzi22JlUYLcWtQ==;3:6db1bN9unQXskSNblI/v3HVDtazOsBneItFSmSQGzOZEZ/mx/lTU6sVf46C6pURT2RalOYS95EPKrdTecaRKojPh67NzqeKHsWz6Gc7ydjTEXBaV/h7cs2kzaR7CtEMEkJoJy03bY+FVYlnYJ0sc31rKHkbkxWLxCJyuIjLnlWoowFCyZJK+4Lt5yjeAGhj3ypxX9bv+aUqdxcfa7T66lmCvmC/oKdX6hkyviJYhJSs=;25:/cghZ27j0uvLeMAUJ4GZEdmF+pSEHtEKvV6kTtUg+g3NmDJG06K0zCuqNRWVjlQ6fiawFyxj1pU1LIMGNxJYrDVVw2AzYx9IZHefd2uRctFdZ0bxUqLinL3RysFZrfwfZn08jgxi8VOHrG3Lg0tgs3ws9PXvgaFH09psyl4Syvn7xQ949F9evo0WbdZClwGs/6VfnXHGIatxn3m1WWMvYX+oHs0gngtm/K9NclAqC9AJBkrp23U3G3k3P/IwrdwBBFF+Zx0erOeal3gayDcFqQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB498; X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB498;20:DGMFtI9AdcK/O6szdoWIvlJcudBTN9VFd5lq2/Vi042IsYvaVwrd5Bi1wWCfmnZLYcQ2Hj7q+RaBJqcRGuzJyTi1fVMbQqRfZg8qV5kULh+Knq+SwNSRm5EP6LUhlYqaoF2TstsZwKEt7cHrrSFJ/B2szQlFSdaJEsLJK5msEmre+Mp5RmlU03N79VU/RevOSqPN+Q7fQMNY9sId9KSc+rF/WfS+lv1KuHfRjJlb4WTXZlZG6T1gWNqhyXdGm3ubSBK+Cg9NmkHiVL1gpfKqg373RfqOssyUmD28FeoPDI5o6AMnVEGgHRUiFCdD2z9Nu2DYpVmWB80ZrtmPfZvuogpyPY+2cXRevVueS8ALRzo=;4:Oy3FFQEoyaSxkBdkog3VQRmJMKX7G0x8+hMLdIC2N61J/AjuQ8MXQ5oA31rsLlqsrSaCJZCUBYlt3Y5uhau69H6LeN3miS8B+ojZoaJjUmslABAPivXzx+y4V4jkTkGyX+6PDGV5++9grbF5QDYTQ8LPrQlFNfhjw3JFAI02pDPvGITNNREJkUU7pNFgSGZmK1ClkGIz9aTt5jSuh6OADpOKfoZ9KyvqagVb5xSqdo9QSV1i7fCZQEdvGsFUq6efQP9ryHb70Ono+8pBt1oPgYnNhLQgm/mspL29ugj5evhHQT61RnyrQXy0TPWc3Abjgq9N6O06UjAdaHZuNEYFAOZYn/FH76901+4qlRd2corvRmyT1D1DZOh1aRx9kfPhWrWdEaNraIQNugSKfNbH+Bc6cCDyMriAh+DDkIuvNORK2YpV/NCLJndcGqAQZuZm X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(10201501046)(3002001);SRVR:BL2PR03MB498;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB498; X-Forefront-PRVS: 0787459938 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BL2PR03MB498;23:E1ZfiQd+7iJrOP3Zr1D38AiIV17OD6Nn/YWhTQS25x?= =?us-ascii?Q?9f1vdJSQWlNG2tEskIr3AjOQJQAquBfHh7I85nXw3zjYrH5mP4ZAvMPK3gsF?= =?us-ascii?Q?ipYptsqRcrKgWkYNdM/mG7rTB+qL262/YDQ9ElJa5K2aCBu8KSoPjoHUBJ6E?= =?us-ascii?Q?4H3rhLzJAzajTP6Hb5ecPiTcRrs3MeolZIPCn8Lvlywm0YDOBuJ3kfvMUEKf?= =?us-ascii?Q?zYW7FDMMHEx1k1NMzdSMx1lCZiLyp4iKrWrBGZdbTUN0CZsLdGierx3NaVJ/?= =?us-ascii?Q?7XKZzBiVFbcAxzq3Sez7rORu2z2zvrZx55WLSxztthyOUlBiWnfxiu9lA9kp?= =?us-ascii?Q?/V2xr6iNukmPWR1NWOXCqzTP5BgtCfWU8qLfH4hBuojj5LksH7E0pTsIabXq?= =?us-ascii?Q?cu5wwFjlIbqZ84NaXguEYp1gHiVRgpAqPwUSfDSL50KLmkmvfOe6oGxvu2AI?= =?us-ascii?Q?GJL9q9a9gcx3DUWRVXFNz6B64G1zcd/No1I5s5SqWSSMe8CDJNExw5WWQDjc?= =?us-ascii?Q?AqH/rtpr1JsjagpnE5de6cJe1fa0IHykk0lBOSvP2TDnm161HdSjKWczUljg?= =?us-ascii?Q?+KeP7tw9+6Wn9rASuT3I1SS9ZRM9n2o8kZ6DjoNyvJSMA0ADxSvc80vm+Ate?= =?us-ascii?Q?+BRR5wNpbA/706itEaHCv9Pz1T3PISTuZzUrRauzC+rPVNc0xuwHgEAUJPmN?= =?us-ascii?Q?lVL0Eox8XFzm5sYcnfzGdpMQG+DCgVYOSL7XA2VtvMHdh5zQQrOXqUbAg75C?= =?us-ascii?Q?WWyq/XxCl8cErjVwVg3HEmYF7RT9x8znj2BSSZGcZPGGyd/+/G2yosG4KMFv?= =?us-ascii?Q?1OxY+LPO2BakkJRj3BL5ctjmp2q8BFFgGY0z/uKNb8AQ1yPD83ON2FzrqmKC?= =?us-ascii?Q?mIShB6gK6ULq73Ygecz9m9Gc0mYqr0M1tQivatqSHWhkAoQg1XrsVL2L8mj4?= =?us-ascii?Q?yjEsZSqjI/P3zYLpXKBvyN0N8G3IPf1tqsW5wjjInpbNeMbNW5Ff9yDgZ2Id?= =?us-ascii?Q?cNLoJXc5dMZKc/phTH4wWNwzecFrjO2Ud1igtQD7wkZA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB498;5:vhGKIV95Unamv2Mn2A5ONPUxhqRx1tL+qViMR9UQ7hUm5xg42ViqSXuxBnULGNJCB82mTcto168hf+eifCuex7geZWksUAFLwOBjpZjjXH7MkFVPG3idp00pv4zkAWdMYGtW0iD3q1ZGMJIDbr/dJg==;24:Gr1sRqvdDON8q7j+sQ09V23oarvCnWkUSYFkZt9lYTF0Zkpzry3lln83vrX+dWhQOMqpY52XmAagLNP3Io57ummMaTAR9sFoLex6GvO6t0w= X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2015 18:27:09.3522 (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: BL2PR03MB498 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4306 Lines: 122 Scan the corresponding DPRC container to get total count of IRQs needed by all its child DPAA2 objects. Then, preallocate a set of MSI IRQs with the DPRC's ICID (GIT-ITS device Id) to populate the the DPRC's IRQ pool. Each child DPAA2 object in the DPRC and the DPRC object itself will allocate their necessary MSI IRQs from the DPRC's IRQ pool, in their driver probe function. Signed-off-by: J. German Rivera --- CHANGE HISTORY Changes in v4: none Changes in v3: none Changes in v2: none drivers/staging/fsl-mc/bus/dprc-driver.c | 24 ++++++++++++++++++++++-- drivers/staging/fsl-mc/include/mc-private.h | 3 ++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl-mc/bus/dprc-driver.c index 767d437..ef1bb93 100644 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c @@ -241,6 +241,7 @@ 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 + * @total_irq_count: total number of IRQs needed by objects in the DPRC. * * Detects objects added and removed from a DPRC and synchronizes the * state of the Linux bus driver, MC by adding and removing @@ -254,11 +255,13 @@ static void dprc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev) * populated before they can get allocation requests from probe callbacks * of the device drivers for the non-allocatable devices. */ -int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev) +int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev, + unsigned int *total_irq_count) { int num_child_objects; int dprc_get_obj_failures; int error; + unsigned int irq_count = mc_bus_dev->obj_desc.irq_count; struct dprc_obj_desc *child_obj_desc_array = NULL; error = dprc_get_obj_count(mc_bus_dev->mc_io, @@ -307,6 +310,7 @@ int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev) continue; } + irq_count += obj_desc->irq_count; dev_dbg(&mc_bus_dev->dev, "Discovered object: type %s, id %d\n", obj_desc->type, obj_desc->id); @@ -319,6 +323,7 @@ int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev) } } + *total_irq_count = irq_count; dprc_remove_devices(mc_bus_dev, child_obj_desc_array, num_child_objects); @@ -344,6 +349,7 @@ EXPORT_SYMBOL_GPL(dprc_scan_objects); 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); dprc_init_all_resource_pools(mc_bus_dev); @@ -352,11 +358,25 @@ 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); + error = dprc_scan_objects(mc_bus_dev, &irq_count); mutex_unlock(&mc_bus->scan_mutex); if (error < 0) goto error; + if (dev_get_msi_domain(&mc_bus_dev->dev) && !mc_bus->irq_resources) { + if (irq_count > FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS) { + dev_warn(&mc_bus_dev->dev, + "IRQs needed (%u) exceed IRQs preallocated (%u)\n", + irq_count, FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS); + } + + error = fsl_mc_populate_irq_pool( + mc_bus, + FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS); + if (error < 0) + goto error; + } + return 0; error: dprc_cleanup_all_resource_pools(mc_bus_dev); diff --git a/drivers/staging/fsl-mc/include/mc-private.h b/drivers/staging/fsl-mc/include/mc-private.h index 3babe92..be72a44 100644 --- a/drivers/staging/fsl-mc/include/mc-private.h +++ b/drivers/staging/fsl-mc/include/mc-private.h @@ -114,7 +114,8 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev); int dprc_scan_container(struct fsl_mc_device *mc_bus_dev); -int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev); +int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev, + 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/