All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuckleberryfinn <chuckleberryfinn@gmail.com>
To: "Sell, Timothy C" <Timothy.Sell@unisys.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	*S-Par-Maintainer <SParMaintainer@unisys.com>,
	"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Kershner, David A" <David.Kershner@unisys.com>
Subject: Re: [PATCH] staging: unisys: visorbus: visorchannel: Refactor locking code to be statically deterministic.
Date: Wed, 19 Oct 2016 22:56:43 +0100	[thread overview]
Message-ID: <20161019215642.GA4198@Shiva> (raw)
In-Reply-To: <BN3PR07MB2580C88FA99C5977432CC4B5FCD20@BN3PR07MB2580.namprd07.prod.outlook.com>

On Wed, Oct 19, 2016 at 05:00:53PM +0000, Sell, Timothy C wrote:
> 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 <chuckleberryfinn@gmail.com>
> > ---
> >  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
>

Thanks for your feedback Tim.
Submitted v2 with the suggested updates.
Thanks again.

Kind regards,
Cathal

  reply	other threads:[~2016-10-19 21:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-19 11:30 [PATCH] staging: unisys: visorbus: visorchannel: Refactor locking code to be statically deterministic Cathal Mullaney
2016-10-19 17:00 ` Sell, Timothy C
2016-10-19 21:56   ` Chuckleberryfinn [this message]
2016-10-19 21:43 ` [PATCH v2] " Cathal Mullaney
2016-10-20  0:04   ` Kershner, David A
2016-10-20  3:10     ` Sell, Timothy C

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161019215642.GA4198@Shiva \
    --to=chuckleberryfinn@gmail.com \
    --cc=David.Kershner@unisys.com \
    --cc=SParMaintainer@unisys.com \
    --cc=Timothy.Sell@unisys.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.