Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932399AbbKXWtN (ORCPT ); Tue, 24 Nov 2015 17:49:13 -0500 Received: from mail-by2on0141.outbound.protection.outlook.com ([207.46.100.141]:2190 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932379AbbKXWsI (ORCPT ); Tue, 24 Nov 2015 17:48:08 -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 RESEND v3 07/11] staging: fsl-mc: Populate the IRQ pool for an MC bus instance Date: Tue, 24 Nov 2015 16:31:20 -0600 Message-ID: <1448404284-22258-8-git-send-email-German.Rivera@freescale.com> X-Mailer: git-send-email 2.3.3 In-Reply-To: <1448404284-22258-1-git-send-email-German.Rivera@freescale.com> References: <1448404284-22258-1-git-send-email-German.Rivera@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD035;1:JSWF1Z/hLhcdprcYQqUfC3N+ahBdaQdEkKnHvbVgZGZa6SGqd6fIjuk0mcebXnwnYWGv45tqS8kRmGg7uazh+wvEKORhy8KqsmV+C7SkE36WysjKWk3SeJMIFRnnzD6YV+E2uljX64xyZHD/GAkf0pIcVZszT19t7j0cTuDgxDqBpJ41h8VvzABm6cOl0/R7O6Yb3G7jesMactDUo7o87u7dz6g4x+TFI3StbMfK9Y5Oraxrc+oufJxOScfVmJH5xQa3ZGe7kMEaVb5/NxKVfXizRTZmh+Hy5M/6sXIC+ZY1yxNhwRm7vCVm9/1q+glYcDJLuGZ/X5OeZsB9Dw9PUH5tKQ5eFDpz/RkrDiodnRYoyzHbiV4ousEnLulcjIFPoxS4kT9TYRASSfceoQ5V5qtVGkrInlp3X6gH3ltcjLYbR9UU97WgO+OVuAJlV9ZAsJ0cT7GRQMlOTdzU9dpL3Q== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(448002)(3190300001)(199003)(189002)(5008740100001)(36756003)(50986999)(6806005)(48376002)(106466001)(5001960100002)(4001430100002)(92566002)(5003940100001)(189998001)(5007970100001)(5001770100001)(81156007)(85326001)(2950100001)(97736004)(107886002)(19580395003)(47776003)(50226001)(2201001)(19580405001)(229853001)(76176999)(586003)(104016004)(50466002)(86362001)(11100500001)(87936001)(77096005)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR03MB508;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;BY2PR03MB508;2:gXGH4/eSNGepj3MbRNXOIzQbY+s7cJTahPXdYZH3ieuNmVeBmllGHBuJTANyEh2Cki7SXd9oFkl5bMi8hZfrVNMzwk594N9NmfrZ+e1wctNkbc7gDpU43+okA7XhiV0MUjXINAAqZXmSNBMDFmpSwQ==;3:KKCpD9sgLQx72KqNTaH4PWiS073dEuFe1TOeEuTdjzwCmeEugpJDCNQyNy8MznG1Rm4rqdx4p11UvLN0nW92dV8QDibDXnc38w2oDXPTcKzOAimFyOITBfAA0lqlkvLsP8o3MlLJDkrVNySIEjv7dIhnQwCN4U+laNp7HMWnZeONTGs+gqzjZx2tegIJH19nUdjem8a/F35xNuTMe+wYrMqQV9amL0XtXqPvRRh0Uag=;25:ChJWRUzUQJWO6F0+RrWpL2MF7wzDGmX6tRzkMf1AFO+x0OI+EOjeG6dZSqJ9Z60PVSVagtejOA3XiD9+9bdQ2tmQo2TMeRhiKf/0YiipcDJ19QLnOP2vkeTW4m3TbjpJWJWIgvrOTK4X6h5na4OphlFVPxFC6wrdo4FitK3DTiex70Gt2FQ6W3K5qqoJLRSapxYlQWp7QC3+AM6YwKiw/W8H851l7GR/lVRUYj8RxZJs+tByad/JBLBEfA0SLo64ggGlKjKZoyeqaaG7gprDPg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB508; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB508;20:x4k7g8x62eK7pN5xEHkiGPLFTtcKJiQHoxxv/RjuUGGp1X+hhmRM0dYs0N23NOCjSNEYMufU5onYdVdLSVWfxKORojpr9DfD1WU98pgIpXi+zFFLv3ox56t7aadeEgr1T00V2SYS7pJmPF7LOUMcqHLLBOL+kDC4+C7IrCYzPRDV2+7i9MKN9bCY1nFiQIm0pR4z9BA4yjZisfWwK+N2Q4A6bEvAJrGG8rr7VORl71HY4mcCz69GGsNq1Y1tDLgTWEdt4tN9lFzxlVE59rhn42O2YJUMx8GsL0Avm51ehVDeDQcQ7lVSAoeqTt1hK6mJHDaFskGKs3s7wEi/fnf2/F49i/g2dksi9bx9g3rKyPs=;4:OPXnLexoejNsp3WD72bWFjqXuauaBbGcR6sjGouWpfPailNXHsTCNz3iEcibRFOTu79l+lVIrrPnpq5jvJ/tQbcIqiDJFNwryGC5xdi8fLahWfJdk87MobP5ZOSB0Yb5UwE/9BruSYjxy22MExHPAn/FqMZPQmqgrSflKP7Jp1qqvjnS6u6MarE9IkGcepU/qypicSI0DE/PyC0qmLIKlsGjoqbuQBGI9tRQkvn9lIcL2QPdHTgjnAOuDUdE/GSLpuQ2Op1eAdawk2ix4zpKwUt2XGOhsKAvfy1ZGBGf2Ijn37MIK+RbB+eSQacHrHKoKPLWKXVKvhOMudExez6vfYJqGefg/IaDJRWdKdOaTYxUIJUaHsk59RLMW5aJ7WYilK631wxNQDDtNnkKFTCn5z3HvYhefsyc+gg8NYXI9RccSxVXzSMR0+2wHVm339SW 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)(5005006)(8121501046)(3002001)(10201501046);SRVR:BY2PR03MB508;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB508; X-Forefront-PRVS: 0770F75EA9 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR03MB508;23:7On43f8mM3yDRKauOvUly8yPHAyuiNMgWHRWjbSKlk?= =?us-ascii?Q?WpEHaB9FTfe4d3IWIZ4atCs1Dnc3Hje3wsSJ+gaEoP8HaGN8QCM88JMRAMXt?= =?us-ascii?Q?kXxUGRzgi9d25LRfFCYS4PfnAk0j9TYYir9u3g/F2njyKoolnnDzNrrZPe9b?= =?us-ascii?Q?G0BYnJUrMCaStsIMMAjl1wHR5ZQqqEPidbb7Kq8u+Qf3bvvP3ym9/tYclDOG?= =?us-ascii?Q?iywQpjMCarlyP6YVsF+/B9lSDhnPmsHh1PqaeDyTLLY+WxYmQVt88MCmO6vr?= =?us-ascii?Q?sNRn7Ppx8mITy9lyrAbutinsxNaH9qvvh9Jc04+5/AvmS4+ssCPmcG5GAob/?= =?us-ascii?Q?EU3BET5/nohq9tgvUgPdA1IgDq14sHQfryjM5iBFicRWsk4ve2XF4gMeYukq?= =?us-ascii?Q?3Vqo2RG+5hgMoZe43hnOXIhMAYOFZsipzHxUAtm1BhCNYp5WPyU4vGWfF6yC?= =?us-ascii?Q?6YdkNxpm97iUY/xZhVy8aApJtdGDGZu868p0QuivenkXOPTotrWFZ3ZLlKXm?= =?us-ascii?Q?loVRdkR/rrwWRYuQgIappokpUReT44UzgQvapvzKgeVWCrUUTJLwcgZFXcU+?= =?us-ascii?Q?mBKgjxgFSDDWZ2X4yuZrAdlYXFCQ7c4+0ynYNZAMzuWP9yNQUVveKi6QvEzD?= =?us-ascii?Q?DrFnwexqTfdIOCVYLsGHvxWtlZrU8N0v9QiBzrPgWivBlCSvLMNHsdtFGeUP?= =?us-ascii?Q?Ug0QhPBTH87aOsKBguvCnTnwmsodMV5Rif5vGCw0Lg8XQpG18GWMoXN9jfpm?= =?us-ascii?Q?knN4UHLohIXUGl/FlZvA8Ly6yIWAN8UJGQaJOna4+8HbD3DMu1lIlrStfcSW?= =?us-ascii?Q?UttwExF8JaBMa5Lhhmj4cpvoFXU87o0bNPm0genRi/bJswTFRWO9gF3uobww?= =?us-ascii?Q?Ub8rKKiOGoISapk8Sw1vFZca9Ayl3njgknrlLAeD26QT/XFrxKDngoHCZwzL?= =?us-ascii?Q?Ti6umsXcy4uS5THx0d0XUe/qaeDP2GBAZQRifSAFYrlKupgsbvmTailsNYve?= =?us-ascii?Q?lefQE5xoiTbvF+ggUJhHGHQvbACzohgmPw2p5LSajcL1y/lf061eP7Vo+k2q?= =?us-ascii?Q?07YY9mPlvrJdWpAuWFdLzDM8Jj?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB508;5:pa5WlhtjXU01cRgATgRqGKc8BeaersKbPbURk0IbgVeFhAPjuiJ1CR7SQSd4OVH6C2jdnD3fYlMRTpR0mRK/UZYDSpuaZbteDCvSrBA++rWpqlVw0gabw04Am0y+a9FGRH6QdddNUQ+nMe65ufe7Nw==;24:YfdDybyGUPJwcYa/ewiXh4+wxWeHpwRdJuBpl20t/bY6saB37qC/NsFGJHYJhS3t6oLSBx4rDCaqvlA2NKBGL7jkIuxLSvWtS74hASY7oM0= X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2015 22:48:03.6838 (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: 4285 Lines: 120 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 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 e685934..bd514ee 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/