Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752041AbdLLEzy (ORCPT ); Mon, 11 Dec 2017 23:55:54 -0500 Received: from mail-eopbgr30069.outbound.protection.outlook.com ([40.107.3.69]:18557 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751663AbdLLEzw (ORCPT ); Mon, 11 Dec 2017 23:55:52 -0500 From: Bharat Bhushan To: Nipun Gupta , Laurentiu Tudor , "stuyoder@gmail.com" , "gregkh@linuxfoundation.org" , "cakturk@gmail.com" , "bretth256@gmail.com" , "arnd@arndb.de" CC: "linux-kernel@vger.kernel.org" , "devel@driverdev.osuosl.org" , Nipun Gupta Subject: RE: [RESEND PATCH 1/2 v2] staging: fsl-mc: Allocate IRQ's before scanning DPRC objects Thread-Topic: [RESEND PATCH 1/2 v2] staging: fsl-mc: Allocate IRQ's before scanning DPRC objects Thread-Index: AQHTcmKy3EnJHK3c3ES8G+Wh+fHvNaM/JfdA Date: Tue, 12 Dec 2017 04:55:47 +0000 Message-ID: References: <1513007138-20146-1-git-send-email-nipun.gupta@nxp.com> In-Reply-To: <1513007138-20146-1-git-send-email-nipun.gupta@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=bharat.bhushan@nxp.com; x-originating-ip: [192.88.169.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR0401MB1853;6:XqQgjj49anItNMGq7DfSoCY0LSpoEblU5AZ2BjKJhYht4hwGY2L4KMOfwZC/+0LKln/IXvld9ta4PQj3YwiwPoeViC2PbHQh6xT2pokkCNPjOsj+9rslDCmoCfdRxqZ55Hzl35YG1CiLWbEuyMdwl+woBR7ZJN4Y+NqqkgTrYb+pUxP1ffvuJxXMBdoWRlGAQKsBBfTGv2g6VZdqWUVI0vXDRIP1Aa+MNvcr0+/RLSoTgZ7dfA0QNFgfdiyazHu3d0e8kME+Ddhb99SY8B56tNAqp/tqlnmNO5Bsy0SU9+2SS6ZHRu23aL7Fg39Y9HISIQcFySxaQGhrNwtnWMXv5wqs4mZ7DteUFr7V7rLsnLs=;5:duBa8ITwiRTRFIP58uYPqTtrgmAedMGrcJwVGP/c1quRRbPcSUDxZhPr793hRzt7IEOcElRLVdbOH+x+ZxiA+UyAx+/0fNJaYiXye5e4cbj/mcYnPALgyi3ru9E5WtKBcRuXgvzjB6ZTTpqaqGMBavYu3H7gBAABr4HZGodXu9M=;24:lcCuDIG5UUjOceBq/TARi5LqLXWv/gxdz2huMCNysdNdfvDRFpiXlberZOXKHw5Ns1pLvJW5fxWyanj4rNU+mKFa3THEUjW/J8aebUIHw0U=;7:GP6TUff1S71sXAEoLqM21P4qtUAEK7TYAfSI4AavSOgVEVUh0TJk8DM1RMvkvDuNtx5E+up9Q5elsIP3mRxtMibI3BOC1V8oK931y+rdJAef21NB053W2tKGaG32m5MschjQ1PkfB4btGLjgyynqQPqjIvDYcnbNQNDe0qaviIYcIc1GPPlR2chuUJAHMXoDh53ShnZaJ38K6oAw8XtABKkNiyZI/YHDWZr2wfBGv/IBCQ5MQGbFLfl06VX8bkYz x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10009020)(366004)(376002)(346002)(39860400002)(189003)(199004)(13464003)(8936002)(97736004)(53546010)(2900100001)(106356001)(229853002)(81166006)(105586002)(7736002)(76176011)(5660300001)(59450400001)(2201001)(14454004)(2501003)(2950100002)(316002)(4326008)(25786009)(110136005)(54906003)(33656002)(5250100002)(2906002)(3280700002)(6246003)(7696005)(39060400002)(55016002)(9686003)(68736007)(305945005)(74316002)(102836003)(3846002)(8676002)(6116002)(99286004)(81156014)(478600001)(6436002)(66066001)(3660700001)(86362001)(53936002)(6506006)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0401MB1853;H:AM5PR0401MB2545.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-correlation-id: 7fd97097-cac2-4061-dab0-08d5411c9c46 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603307);SRVR:VI1PR0401MB1853; x-ms-traffictypediagnostic: VI1PR0401MB1853: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(185117386973197); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231023)(3002001)(10201501046)(6055026)(6041248)(20161123564025)(20161123560025)(20161123555025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(201708071742011);SRVR:VI1PR0401MB1853;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:VI1PR0401MB1853; x-forefront-prvs: 051900244E spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fd97097-cac2-4061-dab0-08d5411c9c46 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Dec 2017 04:55:47.8790 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB1853 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id vBC4u0rn024162 Content-Length: 5347 Lines: 158 > -----Original Message----- > From: Nipun Gupta [mailto:nipun.gupta@nxp.com] > Sent: Monday, December 11, 2017 9:16 PM > To: Laurentiu Tudor ; stuyoder@gmail.com; > Bharat Bhushan ; gregkh@linuxfoundation.org; > cakturk@gmail.com; bretth256@gmail.com; arnd@arndb.de > Cc: linux-kernel@vger.kernel.org; devel@driverdev.osuosl.org; Nipun Gupta > > Subject: [RESEND PATCH 1/2 v2] staging: fsl-mc: Allocate IRQ's before > scanning DPRC objects > > Following is the current scenario when the devices are probed: > > FSL_MC Bus probe ---> dprc probe ---> dprc devices scan ---> > probe devices in DPRC container ---> allocate IRQ's > > In case the devices being probed in the DPRC container need the IRQ's; > probing of that device will fail. > > In current scenario the devices which need IRQ's such as DPIO gets deferred > because they aren't registered when first time the probing of these devices > is done in the dprc scan. > So they are probed once IRQ's have been allocated. > > In case where DPRC probing itself gets deferred, which does in case IOMMU > is enabled; all the devices in DPRC container gets probed before IRQ's are > allocated. This causes devices using IRQ's (such as DPIO) to fail. > > So having IRQ's allocated before any of the devices in the DPRC container are > probed is more legitimate. > > After this patch following is the flow of execution: > > FSL_MC Bus probe ---> dprc probe ---> dprc devices scan ---> > allocate IRQ's ---> probe of devices in DPRC container. > > Signed-off-by: Nipun Gupta Looks ok to me, Reviewed-by: Bharat Bhushan > --- > Resending v2 as missed mentioning the changes in the version Changes in v2: > - Polished the commit message > - Minor updation in the comment added in the code 'Allocate IRQ's...' > > drivers/staging/fsl-mc/bus/dprc-driver.c | 49 ++++++++++++++++++--------- > ----- > 1 file changed, 27 insertions(+), 22 deletions(-) > > diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl- > mc/bus/dprc-driver.c > index 06df528..f4bde58 100644 > --- a/drivers/staging/fsl-mc/bus/dprc-driver.c > +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c > @@ -206,7 +206,8 @@ static void dprc_add_new_devices(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. > + * @total_irq_count: If argument is provided the function populates the > + * total number of IRQs created 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 @@ -228,6 > +229,7 @@ static int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev, > int error; > unsigned int irq_count = mc_bus_dev->obj_desc.irq_count; > struct fsl_mc_obj_desc *child_obj_desc_array = NULL; > + struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev); > > error = dprc_get_obj_count(mc_bus_dev->mc_io, > 0, > @@ -297,7 +299,26 @@ static int dprc_scan_objects(struct fsl_mc_device > *mc_bus_dev, > } > } > > - *total_irq_count = irq_count; > + /* > + * Allocate IRQ's before binding the scanned devices with their > + * respective drivers. > + */ > + 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) > + return error; > + } > + > + if (total_irq_count) > + *total_irq_count = irq_count; > + > dprc_remove_devices(mc_bus_dev, child_obj_desc_array, > num_child_objects); > > @@ -322,7 +343,6 @@ static int dprc_scan_objects(struct fsl_mc_device > *mc_bus_dev, 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); > > fsl_mc_init_all_resource_pools(mc_bus_dev); > @@ -331,29 +351,14 @@ 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); > 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; > + if (error < 0) { > + fsl_mc_cleanup_all_resource_pools(mc_bus_dev); > + return error; > } > > return 0; > -error: > - fsl_mc_cleanup_all_resource_pools(mc_bus_dev); > - return error; > } > > /** > -- > 1.9.1