Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934254AbcKKQ0m (ORCPT ); Fri, 11 Nov 2016 11:26:42 -0500 Received: from mail-db5eur01on0077.outbound.protection.outlook.com ([104.47.2.77]:61029 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932813AbcKKQ0j (ORCPT ); Fri, 11 Nov 2016 11:26:39 -0500 From: Stuart Yoder To: Dan Carpenter , Shiva Kerdel CC: "devel@driverdev.osuosl.org" , "gregkh@linuxfoundation.org" , Nipun Gupta , "linux-kernel@vger.kernel.org" , "treding@nvidia.com" , Laurentiu Tudor Subject: RE: [PATCH 1/2] Staging: fsl-mc: include: mc: Kernel type 's16' preferred over 'int16_t' Thread-Topic: [PATCH 1/2] Staging: fsl-mc: include: mc: Kernel type 's16' preferred over 'int16_t' Thread-Index: AQHSPAvfdnmnRhb0FUi9htvgspyz2aDTo/IAgAA0wlA= Date: Fri, 11 Nov 2016 14:52:31 +0000 Message-ID: References: <20161111110740.1926-1-shiva@exdev.nl> <20161111112326.GG28701@mwanda> In-Reply-To: <20161111112326.GG28701@mwanda> 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=stuart.yoder@nxp.com; x-originating-ip: [162.203.173.167] x-microsoft-exchange-diagnostics: 1;VI1PR0401MB1855;7:Ow99Zca5I7btN1aR74x9ZwUxX818X2vtc+AZMolaiBfk7vzP0TEhO4Z33FszGSrFZXlK5D++loU2j9bW9e8KuSJkZprq5aJQM1H2CRj7Gu8M47ygf1TdfOm0beXl5EGF/HFBJuIPVcbpzjg1858P2IfIjQSSd+hOOKsc8XnqdTViCRe3p6iU73DZZgAyt55UfnwARcaWIZaDnnMKZwc1fbDtHL6l0KSv++yDCVefDNhNWnmZDkJW5rLmhQBwoWlZBmdhbU4MBvJSDzy1iNpnPv/BGIfxYD5PSaBdAYO8sn9i7Lsyd9rLFQ815UV+Vim4OwyVvgxPHj4fqmtH0wKi38tK+H8vv7ek+i/VpUv58vg= x-ms-office365-filtering-correlation-id: ad39a087-ae80-4e33-80d0-08d40a425d27 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:VI1PR0401MB1855; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(185117386973197)(101931422205132)(146099531331640); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6045074)(6060229)(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6046074)(6072074);SRVR:VI1PR0401MB1855;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0401MB1855; x-forefront-prvs: 012349AD1C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(979002)(6009001)(7916002)(199003)(189002)(377454003)(13464003)(24454002)(76176999)(7696004)(77096005)(54356999)(50986999)(92566002)(81156014)(8676002)(97736004)(5001770100001)(86362001)(2900100001)(76576001)(81166006)(101416001)(33656002)(2906002)(74316002)(3660700001)(305945005)(4326007)(5660300001)(229853002)(106116001)(105586002)(102836003)(6116002)(122556002)(3280700002)(586003)(7846002)(3846002)(7736002)(106356001)(9686002)(66066001)(87936001)(68736007)(8936002)(189998001)(2950100002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0401MB1855;H:VI1PR0401MB2638.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Nov 2016 14:52:31.1490 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB1855 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 mail.home.local id uABGQoBB031335 Content-Length: 2819 Lines: 74 > -----Original Message----- > From: Dan Carpenter [mailto:dan.carpenter@oracle.com] > Sent: Friday, November 11, 2016 5:23 AM > To: Shiva Kerdel > Cc: Stuart Yoder ; devel@driverdev.osuosl.org; German.Rivera@freescale.com; > gregkh@linuxfoundation.org; Nipun Gupta ; linux-kernel@vger.kernel.org; German > Rivera ; treding@nvidia.com; itai.katz@nxp.com > Subject: Re: [PATCH 1/2] Staging: fsl-mc: include: mc: Kernel type 's16' preferred over 'int16_t' > > On Fri, Nov 11, 2016 at 12:07:39PM +0100, Shiva Kerdel wrote: > > Follow the kernel type preferrences of using 's16' over 'int16_t'. > > > > Signed-off-by: Shiva Kerdel > > Acked-by: Stuart Yoder > > --- > > Changes for v2: > > - corrected an error in the log message, wrote 's32' instead of 's16'. > > Changes for v3: > > - added the missing annotates. > > Changes for v4: > > - corrected patch subject to version 4. > > > > drivers/staging/fsl-mc/include/mc-bus.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/staging/fsl-mc/include/mc-bus.h b/drivers/staging/fsl-mc/include/mc-bus.h > > index e915574..c7cad87 100644 > > --- a/drivers/staging/fsl-mc/include/mc-bus.h > > +++ b/drivers/staging/fsl-mc/include/mc-bus.h > > @@ -42,8 +42,8 @@ struct msi_domain_info; > > */ > > struct fsl_mc_resource_pool { > > enum fsl_mc_pool_type type; > > - int16_t max_count; > > - int16_t free_count; > > + s16 max_count; > > My understanding is that this has to be signed because the design of > this driver is that we keep adding devices until the the counter > overflows. After that there are a couple tests for > "if (WARN_ON(res_pool->max_count < 0)) " which prevent the driver from > working again. > > This all seems pretty horrible. Can you elaborate? The resource pools managed by this driver are populated by hardware objects discovered when the fsl-mc bus probes a DPRC/container. The number of potential objects discovered of a given type is in the hundreds, so a signed 16-bit number is order of magnitudes larger than anything we will ever encounter. Would you feel better about this if max_count was an int? The max_count reflects the total number of objects discovered. If that is exceeded we display a warning, because something is horribly wrong. Nothing stops working, the allocator simply refuses to add anything else to the free list. The only reason max_count is there at all is as an internal check against bugs and resource leaks. If the driver is being removed and a resource pool is being freed, max_count must be zero...i.e. all objects should have been removed. If not, there is a leak somewhere. So, it's a sanity check. Thanks, Stuart