From: Thierry Reding <thierry.reding@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Manfred Schlaegl <manfred.schlaegl@gmx.at>,
Manfred Schlaegl <manfred.schlaegl@ginzinger.com>,
Luis de Bethencourt <luis@debethencourt.com>,
Olivier Sobrie <olivier@sobrie.be>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] Input: pwm-beeper - defer pwm config if pwm can sleep
Date: Thu, 12 May 2016 14:18:52 +0200 [thread overview]
Message-ID: <20160512121852.GB26824@ulmo.ba.sec> (raw)
In-Reply-To: <20160222194639.GD26177@dtor-ws>
[-- Attachment #1: Type: text/plain, Size: 1890 bytes --]
On Mon, Feb 22, 2016 at 11:46:39AM -0800, Dmitry Torokhov wrote:
> On Wed, Feb 17, 2016 at 02:19:26PM +0100, Manfred Schlaegl wrote:
> > If the pwm can sleep defer actions to it using a worker.
> > A similar approach was used in leds-pwm (c971ff185)
> >
> > Trigger:
> > On a Freescale i.MX53 based board we ran into "BUG: scheduling while
> > atomic" because input_inject_event locks interrupts, but
> > imx_pwm_config_v2 sleeps.
> >
> > Tested on Freescale i.MX53 SoC with 4.5-rc1 and 4.1.
> >
> > Unmodified applicable to
> > * 4.5-rc4
> > * 4.4.1 (stable)
> > * 4.3.5 (stable)
> > * 4.1.18 (longterm)
> >
> > Modified applicable to
> > * 3.18.27 (longterm)
> >
> > Signed-off-by: Manfred Schlaegl <manfred.schlaegl@gmx.at>
> > ---
> > drivers/input/misc/pwm-beeper.c | 62 +++++++++++++++++++++++++++++------------
> > 1 file changed, 44 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
> > index f2261ab..c160b5e 100644
> > --- a/drivers/input/misc/pwm-beeper.c
> > +++ b/drivers/input/misc/pwm-beeper.c
> > @@ -20,21 +20,42 @@
> > #include <linux/platform_device.h>
> > #include <linux/pwm.h>
> > #include <linux/slab.h>
> > +#include <linux/workqueue.h>
> >
> > struct pwm_beeper {
> > struct input_dev *input;
> > struct pwm_device *pwm;
> > + struct work_struct work;
> > unsigned long period;
> > + bool can_sleep;
>
> I wonder if it is not better to always schedule work, regardless of
> whether PWM may sleep or not.
I agree with Dmitry. Users of the PWM API should always assume that
calls to the PWM API might sleep. Conditionalizing on pwm_can_sleep()
isn't a good idea, since that function is scheduled to be removed. In
fact it's been returning true unconditionally since v4.5, so the fast
path is dead code anyway.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-05-12 12:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 13:19 Manfred Schlaegl
2016-02-22 19:46 ` Dmitry Torokhov
2016-02-23 8:46 ` Manfred Schlaegl
2016-03-30 14:57 ` Manfred Schlaegl
2016-05-12 12:18 ` Thierry Reding [this message]
2016-05-13 15:38 ` Manfred Schlaegl
2016-05-18 15:16 ` [PATCH] Input: pwm-beeper - fix: scheduling while atomic Manfred Schlaegl
2016-05-18 16:06 ` Greg Kroah-Hartman
2016-05-19 7:52 ` Manfred Schlaegl
2016-05-20 16:59 ` Dmitry Torokhov
2016-05-24 8:32 ` Manfred Schlaegl
2016-05-24 8:37 ` Manfred Schlaegl
2016-05-26 0:36 ` Dmitry Torokhov
2016-05-27 8:54 ` Manfred Schlaegl
2016-05-27 9:11 ` Manfred Schlaegl
2016-05-27 9:14 ` Manfred Schlaegl
2016-05-27 23:38 ` Dmitry Torokhov
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=20160512121852.GB26824@ulmo.ba.sec \
--to=thierry.reding@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luis@debethencourt.com \
--cc=manfred.schlaegl@ginzinger.com \
--cc=manfred.schlaegl@gmx.at \
--cc=olivier@sobrie.be \
/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
all inboxes | Powered by JetHome®