mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: Fabien DESSENNE <fabien.dessenne@st.com>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Benjamin GAIGNARD <benjamin.gaignard@st.com>,
	Hans Verkuil <hverkuil@xs4all.nl>
Subject: Re: [PATCH 1/2] bdisp: Fix a possible sleep-in-atomic bug in bdisp_hw_reset
Date: Sat, 16 Dec 2017 12:14:27 -0200	[thread overview]
Message-ID: <20171216121427.6307c584@recife.lan> (raw)
In-Reply-To: <abd7b14d-cda6-ab67-3c5b-7cbd0dbaa336@gmail.com>

Em Sat, 16 Dec 2017 19:53:55 +0800
Jia-Ju Bai <baijiaju1990@gmail.com> escreveu:

> Hi,
> 
> On 2017/12/15 22:51, Fabien DESSENNE wrote:
> > Hi
> >
> > On 12/12/17 14:47, Jia-Ju Bai wrote:  
> >> The driver may sleep under a spinlock.
> >> The function call path is:
> >> bdisp_device_run (acquire the spinlock)
> >>     bdisp_hw_reset
> >>       msleep --> may sleep
> >>
> >> To fix it, msleep is replaced with mdelay.  
> > May I suggest you to use readl_poll_timeout_atomic (instead of the whole
> > "for" block): this fixes the problem and simplifies the code?  
> 
> Okay, I have submitted a patch according to your advice.
> You can have a look :)

This can still be usind mdelay() to wait for a long time.

It doesn't seem wise to do that, as it could cause system
contention. Couldn't this be reworked in a way to avoid
having the spin locked while sleeping?

Once we had a similar issue on Siano, and it was solved by this

commit 3cdadc50bbe8f04c1231c8af614cafd7ddd622bf
Author: Richard Zidlicky <rz@linux-m68k.org>
Date:   Tue Aug 24 09:52:36 2010 -0300

    V4L/DVB: dvb: fix smscore_getbuffer() logic
    
    Drivers shouldn't sleep while holding a spinlock. A previous workaround
    were to release the spinlock before callinc schedule().
    
    This patch uses a different approach: it just waits for the
    siano hardware to answer.
    
    Signed-off-by: Richard Zidlicky <rz@linux-m68k.org>
    Cc: stable@kernel.org
    Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

The code as changed to use wait_event() at the kthread that was
waiting for data to arrive. Only when the data is ready, the
code with the spin lock is called.

It made the driver a way more stable, and didn't add any penalties
of needing to do long delays on a non-interruptible code.

Thanks,
Mauro

  reply	other threads:[~2017-12-16 14:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-12 13:47 Jia-Ju Bai
2017-12-15 14:16 ` Hans Verkuil
2017-12-15 14:51 ` Fabien DESSENNE
2017-12-16 11:53   ` Jia-Ju Bai
2017-12-16 14:14     ` Mauro Carvalho Chehab [this message]
2017-12-19  9:01       ` Fabien DESSENNE
2017-12-19  9:40         ` Mauro Carvalho Chehab

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=20171216121427.6307c584@recife.lan \
    --to=mchehab@kernel.org \
    --cc=baijiaju1990@gmail.com \
    --cc=benjamin.gaignard@st.com \
    --cc=fabien.dessenne@st.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@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 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®