linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hui Chun Ong <hui.chun.ong@ni.com>
To: Julia Cartwright <julia.cartwright@ni.com>,
	"j.anaszewski@samsung.com" <j.anaszewski@samsung.com>,
	"jacek.anaszewski@gmail.com" <jacek.anaszewski@gmail.com>
Cc: "rpurdie@rpsys.net" <rpurdie@rpsys.net>,
	"mika.westerberg@linux.intel.com"
	<mika.westerberg@linux.intel.com>,
	"linux-leds@vger.kernel.org" <linux-leds@vger.kernel.org>,
	"rjw@rjwysocki.net" <rjw@rjwysocki.net>,
	Jonathan Hearn <jonathan.hearn@ni.com>,
	Brad Mouring <brad.mouring@ni.com>
Subject: Re: [PATCH] leds: Add user LED driver for NIC78bx device
Date: Tue, 25 Oct 2016 10:07:08 +0000	[thread overview]
Message-ID: <1477390026.2682.3.camel@ni.com> (raw)
In-Reply-To: <5bd2fac9-0fe7-4445-e0a6-0342b08f7e33@gmail.com>

Hi Jacek,

On Sun, 2016-10-23 at 16:12 +0200, Jacek Anaszewski wrote:
> Hi Julia,
> 
> On 10/21/2016 11:33 PM, Julia Cartwright wrote:
> > 
> > On Fri, Oct 21, 2016 at 02:56:15PM +0200, Jacek Anaszewski wrote:
> > > 
> > > Hi Hui,
> > > 
> > > Thanks for the patch. I have few comments in the code below.
> > > 
> > > On 10/21/2016 08:33 AM, Hui Chun Ong wrote:
> > > > 
> > > > Add the driver to support User LEDs on PXI Embedded Controller.
> > > > 
> > > > Signed-off-by: Hui Chun Ong <hui.chun.ong@ni.com>
> > > > Signed-off-by: Brad Mouring <brad.mouring@ni.com>
> > [..]
> > > 
> > > 
> > > > 
> > > > +
> > > > +struct ni78bx_led {
> > > > +	u8 bit;
> > > > +	u8 mask;
> > > > +	struct led_classdev cdev;
> > > > +};
> > > > +
> > > > +static inline struct ni78bx_led *to_ni78bx_led(struct
> > > > led_classdev *cdev)
> > > > +{
> > > > +	return container_of(cdev, struct ni78bx_led, cdev);
> > > > +}
> > > > +
> > > > +static void ni78bx_brightness_set(struct led_classdev *cdev,
> > > > +				  enum led_brightness
> > > > brightness)
> > > > +{
> > > > +	struct ni78bx_led *nled = to_ni78bx_led(cdev);
> > > > +	u8 value;
> > > > +
> > > > +	mutex_lock(&led_lock);
> > > You can use spin_lock_irqsave() instead, since we are not going
> > > to sleep
> > > while accessing memory mapped registers.
> > Could you explain why spin_lock_irqsave() is appropriate
> > here?  This
> > device doesn't have an interrupt to be synchronized with.  I could
> > understand spin_lock()/spin_unlock(), maybe, but why disable
> > interrupts?
> brightness_set op can be called from atomic context e.g. in case of
> timer trigger. The code that runs in the interrupt context cannot
> sleep
> due to reasons explained in [0], whereas mutex can sleep on
> contention.
> 
> spin_lock() is appropriate only in a hard irq handler.
> 
> > 
> > Is what you're saying that the set/get brightness calls can be re-
> > entered
> > by LED consumers in hardirq context?
> > 
> > The systems this driver is deployed to is much more sensitive to RT
> > execution latency than anything else, which is why I take pause to
> > unnecessary interrupt mask twiddling/preemption disabling :).
> [0] http://www.makelinux.net/ldd3/chp-5-sect-5
> 
I'm update the driver to use spin_lock_irqsave. Thanks for the
feedback.

      reply	other threads:[~2016-10-25 12:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20161021063441eucas1p221cdc9bd704f03ad367df8cf59fa35e6@eucas1p2.samsung.com>
2016-10-21  6:33 ` [PATCH] leds: Add user LED driver for NIC78bx device Hui Chun Ong
2016-10-21 12:56   ` Jacek Anaszewski
2016-10-21 13:06     ` Mika Westerberg
2016-10-21 21:11       ` Rafael J. Wysocki
2016-10-25 10:33         ` Hui Chun Ong
2016-10-21 21:33     ` Julia Cartwright
2016-10-23 14:12       ` Jacek Anaszewski
2016-10-25 10:07         ` Hui Chun Ong [this message]

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=1477390026.2682.3.camel@ni.com \
    --to=hui.chun.ong@ni.com \
    --cc=brad.mouring@ni.com \
    --cc=j.anaszewski@samsung.com \
    --cc=jacek.anaszewski@gmail.com \
    --cc=jonathan.hearn@ni.com \
    --cc=julia.cartwright@ni.com \
    --cc=linux-leds@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=rpurdie@rpsys.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).