Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751822AbbEDWJW (ORCPT ); Mon, 4 May 2015 18:09:22 -0400 Received: from mail-bn1bbn0104.outbound.protection.outlook.com ([157.56.111.104]:39223 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751295AbbEDWJM convert rfc822-to-8bit (ORCPT ); Mon, 4 May 2015 18:09:12 -0400 From: Jose Rivera To: Dan Carpenter CC: "gregkh@linuxfoundation.org" , "arnd@arndb.de" , "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" , Stuart Yoder , "bhupesh.sharma@freescale.com" , "agraf@suse.de" , "bhamciu1@freescale.com" , "nir.erez@freescale.com" , "itai.katz@freescale.com" , Scott Wood , "R89243@freescale.com" , Richard Schmitt Subject: RE: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support Thread-Topic: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support Thread-Index: AQHQgdtcWmwch7II+U+VbnIIkniD+51lc9iAgAbl/LA= Date: Mon, 4 May 2015 22:09:08 +0000 Message-ID: References: <1430242750-17745-1-git-send-email-German.Rivera@freescale.com> <1430242750-17745-2-git-send-email-German.Rivera@freescale.com> <20150430114957.GW14154@mwanda> In-Reply-To: <20150430114957.GW14154@mwanda> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: oracle.com; dkim=none (message not signed) header.d=none; x-originating-ip: [192.88.168.50] x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1248; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:DM2PR0301MB1248;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1248; x-forefront-prvs: 05669A7924 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(279900001)(51704005)(377454003)(52314003)(164054003)(24454002)(40100003)(575784001)(77156002)(107886002)(110136002)(54356999)(87936001)(2950100001)(46102003)(86362001)(62966003)(122556002)(92566002)(5001960100002)(2656002)(2900100001)(99286002)(76176999)(33656002)(19625305001)(5890100001)(19580395003)(19580405001)(106116001)(102836002)(74316001)(50986999)(15975445007)(76576001)(66066001)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR0301MB1248;H:DM2PR0301MB1309.namprd03.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 04 May 2015 22:09:08.8929 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB1248 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5021 Lines: 142 Dan, Thanks for your comments. My replies inline. Thanks, German > -----Original Message----- > From: Dan Carpenter [mailto:dan.carpenter@oracle.com] > Sent: Thursday, April 30, 2015 6:50 AM > To: Rivera Jose-B46482 > Cc: gregkh@linuxfoundation.org; arnd@arndb.de; > devel@driverdev.osuosl.org; linux-kernel@vger.kernel.org; Yoder Stuart- > B08248; Sharma Bhupesh-B45370; agraf@suse.de; Hamciuc Bogdan-BHAMCIU1; > Erez Nir-RM30794; katz Itai-RM05202; Wood Scott-B07421; Marginean > Alexandru-R89243; Schmitt Richard-B43082 > Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support > > On Tue, Apr 28, 2015 at 12:39:04PM -0500, J. German Rivera wrote: > > Change-Id: I2a986c465989c3811de19cfe9ed0b77168250cb1 > > Reviewed-on: http://git.am.freescale.net:8181/33626 > > Tested-by: Review Code-CDREVIEW > > These things are totally useless to the rest of us. Don't add them. > Agreed. I'll remove them in the next respin. > > > diff --git a/drivers/staging/fsl-mc/TODO b/drivers/staging/fsl-mc/TODO > > index d78288b..1b8868d 100644 > > --- a/drivers/staging/fsl-mc/TODO > > +++ b/drivers/staging/fsl-mc/TODO > > @@ -8,6 +8,9 @@ > > * Add at least one device driver for a DPAA2 object (child device of > the > > fsl-mc bus). > > > > +* Enable code blocks guarded by #ifdef GIC_ITS_MC_SUPPORT, when > > +GIC-ITS > > + support for the MC MSIs gets merged. > > + > > When will that be? I'd really prefer to not add these ifdeffed bits at > all. > The owner of the GIC-ITS support patches would need to answer the "when" question. These #ifdefs are needed to be able to make the code compile without the GIC-ITS support in place. Of course, the code will not be moved out of staging with these #ifdefs. There is already an item for this in the drivers/staging/fsl-mc/TODO file. > > + if (status & (DPRC_IRQ_EVENT_OBJ_ADDED | > > + DPRC_IRQ_EVENT_OBJ_REMOVED | > > + DPRC_IRQ_EVENT_CONTAINER_DESTROYED | > > + DPRC_IRQ_EVENT_OBJ_DESTROYED | > > + DPRC_IRQ_EVENT_OBJ_CREATED)) { > > + unsigned int irq_count; > > + > > + error = dprc_scan_objects(mc_dev, &irq_count); > > + if (error < 0) { > > + dev_err(dev, "dprc_scan_objects() failed: %d\n", > error); > > + goto out; > > + } > > + > > + WARN_ON((int16_t)irq_count < 0); > > This code is doing "WARN_ON(test_bit(15, (unsigned long *)&irq_count));". > That seems like nonsense. Anyway, just delete the WARN_ON(). > I disagree. This WARN_ON is checking that irq_count is in the expected range (it fits in int16_t as a positive number). The dprc_scan_objects() function expects irq_count to be of type "unsigned int" (which is 32-bit unsigned) > > + > > + if ((int16_t)irq_count > > > + mc_bus->resource_pools[FSL_MC_POOL_IRQ].max_count) { > > Why are we casting this? Also can you align it like: > This casting is done for safety, to prevent the comparison to be done in "unsigned int" due to integer promotion rules. > if (irq_count > > mc_bus->resource_pools[FSL_MC_POOL_IRQ].max_count) { > > [tab][tab][space][space][space][space]mc_bus->resource_pools[ > > That way you can tell the if condition from the indented block. Plus > that is standard kernel indenting style these days. > Agreed. I'll change this in the next respin. > > [ snip ] > > > + irqs = devm_kzalloc(&mc_dev->dev, irq_count * sizeof(irqs[0]), > > + GFP_KERNEL); > > + if (!irqs) { > > + error = -ENOMEM; > > + dev_err(&mc_dev->dev, "No memory to allocate irqs[]\n"); > > + goto error; > > I kind of hate One Err Style error handling, because the error labels are > so general... You can never guess the point of it until you scroll down > Agreed. I will replace the generic error cleanup exit point with error-specific cleanup exit points, and return directly when no cleanup is needed. > to read what "goto error;" does. The error handling here calls > devm_kfree() which is not needed... devm_ functions automatically clean > up after themselves. This seems a pattern throughout. Do a search for > devm_free() and see which ones are really needed or not. > I know that memory allocated with devm_kzalloc() is freed at the end of the lifetime of the device it is attached to. However, in error paths, why wait until the device is destroyed? Why not free the memory earlier so that it can be used for other purposes? > Also the error message isn't needed here. kzalloc() has its own better > error messages built-in. Adding these error messages which will never be > printed is just a waste of RAM. > Agreed. Error message removed. > In other words this should look like: > > irqs = devm_kcalloc(&mc_dev->dev, sizeof(*irqs), irq_count, > GFP_KERNEL); > if (!irqs) > return -ENOMEM; > > regards, > dan carpenter -- 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/