Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S943555AbcJSUgE (ORCPT ); Wed, 19 Oct 2016 16:36:04 -0400 Received: from mail-co1nam03on0084.outbound.protection.outlook.com ([104.47.40.84]:20864 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S942006AbcJSUfO (ORCPT ); Wed, 19 Oct 2016 16:35:14 -0400 X-Greylist: delayed 10887 seconds by postgrey-1.27 at vger.kernel.org; Wed, 19 Oct 2016 16:35:14 EDT From: "Sell, Timothy C" To: "'Cathal Mullaney'" CC: "gregkh@linuxfoundation.org" , *S-Par-Maintainer , "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" , "Kershner, David A" Subject: RE: [PATCH] staging: unisys: visorbus: visorchannel: Refactor locking code to be statically deterministic. Thread-Topic: [PATCH] staging: unisys: visorbus: visorchannel: Refactor locking code to be statically deterministic. Thread-Index: AQHSKfxHvUJowD0ookKyXjN1B9Dc+KCv+ciw Date: Wed, 19 Oct 2016 17:00:53 +0000 Message-ID: References: <1476876643-3708-1-git-send-email-chuckleberryfinn@gmail.com> In-Reply-To: <1476876643-3708-1-git-send-email-chuckleberryfinn@gmail.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=Timothy.Sell@unisys.com; x-originating-ip: [192.63.205.23] x-ms-office365-filtering-correlation-id: 429f55e0-4c6a-4e48-5321-08d3f8417cef x-microsoft-exchange-diagnostics: 1;CY1PR0701MB1836;7:vd9ZOMi+tmfzAG7WhYr7PVC0yAlPLylQD9A0yDl9U5iS8Dk9M74s6SDQt2gergElWIHtgpP1LGo47viduOHfWDE7maEfJ2cR9N86zhcmfOf5WRLoJx20REhSO6eo+M4kN5xOIoFSliE8MqWQShlnPxriNrRGM7bkE/aFr2BH6bt9Zbn9NqkifCkWGv84o9eS/xp7SVEr40TFvqD7XA1K0dS03HUwVUZoj8X8Js1lVJXNp4rLOVZbS84KsSZ1WjL5Hkby4feMHDBJyYIZb9C13DNFd2HXqBRNRhMLK/RkHwAw4FmXrddMbWJ3KSJV2uVn7cL64kYyxRMqQQgKk86LVCkpnWNWLDqaQTU1hvIuirs= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0701MB1836; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6043046)(6042046);SRVR:CY1PR0701MB1836;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0701MB1836; x-forefront-prvs: 0100732B76 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(377454003)(199003)(24454002)(189002)(2900100001)(19580395003)(4326007)(3846002)(87936001)(81156014)(66066001)(7696004)(1411001)(8676002)(105586002)(77096005)(189998001)(81166006)(92566002)(86362001)(74316002)(3660700001)(76576001)(68736007)(97736004)(122556002)(107886002)(586003)(3280700002)(102836003)(305945005)(110136003)(4001430100002)(6116002)(5002640100001)(76176999)(7736002)(99286002)(8936002)(106356001)(7846002)(106116001)(2950100002)(101416001)(10400500002)(54356999)(9686002)(2906002)(33656002)(5660300001)(50986999)(11100500001)(6916009)(19580405001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR0701MB1836;H:BN3PR07MB2580.namprd07.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: unisys.com X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Oct 2016 17:00:53.8751 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8d894c2b-238f-490b-8dd1-d93898c5bf83 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0701MB1836 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 u9JKaBUb020798 Content-Length: 2107 Lines: 64 On Wednesday, October 19, 2016 7:31 AM, Cathal Mullaney wrote: > This patch makes locking in visorchannel_signalempty statically deterministic. > As a result this patch fixes the sparse warning: > Context imbalance in 'visorchannel_signalempty' - different lock contexts for > basic block. > > The logic of the locking code doesn't change but the layout of the original > code is "frowned upon" > according to mails on sparse context checking. > Refactoring removes the warning and makes the code more readable. > > Signed-off-by: Cathal Mullaney > --- > drivers/staging/unisys/visorbus/visorchannel.c | 26 +++++++++++++++++--- > ------ > 1 file changed, 17 insertions(+), 9 deletions(-) > > diff --git a/drivers/staging/unisys/visorbus/visorchannel.c > b/drivers/staging/unisys/visorbus/visorchannel.c > index a1381eb..1eea5d8 100644 > --- a/drivers/staging/unisys/visorbus/visorchannel.c > +++ b/drivers/staging/unisys/visorbus/visorchannel.c > @@ -300,22 +300,30 @@ > --- > bool > visorchannel_signalempty(struct visorchannel *channel, u32 queue) > { > unsigned long flags = 0; > - struct signal_queue_header sig_hdr; > bool rc = false; It appears as if you no longer need to initialize 'rc' above. Although this is NOT caused by your patch, it also looks like 'flags' is being unnecessarily initialized. You may want to fix that too while you're in the neighborhood. (Kernel folks seem to frown on unnecessary variable initializations.) > > - if (channel->needs_lock) > - spin_lock_irqsave(&channel->remove_lock, flags); > + if (!channel->needs_lock) > + return queue_empty(channel, queue); > > - if (sig_read_header(channel, queue, &sig_hdr)) > - rc = true; > - if (sig_hdr.head == sig_hdr.tail) > - rc = true; > - if (channel->needs_lock) > - spin_unlock_irqrestore(&channel->remove_lock, flags); > + spin_lock_irqsave(&channel->remove_lock, flags); > + rc = queue_empty(channel, queue); > + spin_unlock_irqrestore(&channel->remove_lock, flags); > > return rc; > } > -- > 2.7.4 Besides that, your patch looks good to me. Thanks. - Tim Sell