All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Hurley <peter@hurleysoftware.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	jslaby@suse.cz,
	Lists linaro-kernel <linaro-kernel@lists.linaro.org>,
	Patch Tracking <patches@linaro.org>,
	linux-serial@vger.kernel.org,
	Bryan Huntsman <bryanh@codeaurora.org>,
	Daniel Walker <dwalker@fifo99.com>,
	David Brown <davidb@codeaurora.org>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Tobias Klauser <tklauser@distanz.ch>,
	Tony Prisk <linux@prisktech.co.nz>
Subject: Re: [PATCH V2 00/25] tty: serial: drop uart_port->lock before calling
Date: Mon, 19 Aug 2013 22:35:46 -0400	[thread overview]
Message-ID: <5212D602.2000005@hurleysoftware.com> (raw)
In-Reply-To: <CAKohpon2k6SNUzJ0u0EqGZRPnMwyUk0QcWb-XVRc1PU8yW4PNg@mail.gmail.com>

On 08/19/2013 08:18 PM, Viresh Kumar wrote:
> Hi Peter,
>
> On 19 August 2013 21:01, Peter Hurley <peter@hurleysoftware.com> wrote:
>
>> Please review commit 677fe555cbfb188af58cce105f4dae9505e58c31
>> 'serial: imx: Fix recursive locking bug' to see if that is actually the
>> problem
>> you're having with the samsung serial driver.
>
> No, this doesn't seem to be the same issue... The issue here is:
>
> s3c24xx_serial_rx_chars()
> -> spin_lock_irqsave(&port->lock, flags);
> -> tty_flip_buffer_push()
>    -> flush_to_ldisc()
>      -> n_tty_receive_buf2()
>        -> __receive_buf()
>           -> uart_start()
>              -> spin_lock_irqsave(&port->lock, flags);

Nope.

First, you have two stack traces from your previous message.
The BUG report is the second stack trace:

worker_thread
   process_one_work
     flush_to_ldisc
       n_tty_receive_buf2
         __receive_buf
           uart_start
             raw_spin_lock_irqsave(&port->lock)

IOW, no lock recursion because it's running on a separate
kworker thread, and did not arrive from s3c24xx_serial_rx_chars()
(other than indirectly via schedule_work()).

It's BUGing because the uart_port spinlock cannot be acquired
_even though apparently there is no owning CPU_.

The key to why the flush_to_disc() worker thread cannot acquire the
uart_port spinlock is in the first stack trace:

s3c24xx_serial_rx_chars
   raw_spin_unlock_irqrestore
     do_raw_spin_unlock
       dump_stack

So the real question here is why do_raw_spin_unlock() is doing
a dump_stack()?  Is one of the SPIN_BUG_ON() asserts in debug_spin_unlock()
triggering?

> This seems to be a generic enough problem as many drivers are already
> doing the right thing. They release lock before calling
> tty_flip_buffer_push()..

No. Those drivers are carrying vestige code from the original 2.6
tree import.

As documented in tty_flip_buffer_push():

  *	Queue a push of the terminal flip buffers to the line discipline. This
  *	function must not be called from IRQ context if port->low_latency is
  *	set.

IOW, s3c24xx_serial_rx_chars() executing in IRQ context cannot call
flush_to_ldisc() -- the work must be scheduled instead. Since flush_to_ldisc()
will be scheduled on a separate kworker thread, the uart_port spin lock will
not be recursively claimed.

So, recursive locking of the uart_port lock is not the problem
(at least, not wrt the flush_to_ldisc() call chain).

Regards,
Peter Hurley


  reply	other threads:[~2013-08-20  2:35 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-19 14:44 [PATCH V2 00/25] tty: serial: drop uart_port->lock before calling Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 01/25] tty: serial: altera_jtag: drop uart_port->lock before calling tty_flip_buffer_push() Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 02/25] tty: serial: altera: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 03/25] tty: serial: apbuart: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 04/25] tty: serial: ar933x: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 05/25] tty: serial: arc: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 06/25] tty: serial: bcm63xx: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 07/25] tty: serial: bfin_sport: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 08/25] tty: serial: efm32: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 09/25] tty: serial: icom: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 10/25] tty: serial: lpc32xx_hs: don't call tty_flip_buffer_push() twice Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 11/25] tty: serial: lpc32xx_hs: drop uart_port->lock before calling tty_flip_buffer_push() Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 12/25] tty: serial: m32r_sio: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 13/25] tty: serial: mcf: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 14/25] tty: serial: mfd: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 15/25] tty: serial: mpsc: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 16/25] tty: serial: msm: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 17/25] tty: serial: netx: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 18/25] tty: serial: nwpserial: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 19/25] tty: serial: pnx8xxx: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 20/25] tty: serial: rp2: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 21/25] tty: serial: sa1100: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 22/25] tty: serial: samsung: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 23/25] tty: serial: tegra: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 24/25] tty: serial: sirfsoc: " Viresh Kumar
2013-08-19 14:44 ` [PATCH V2 25/25] tty: serial: vt8500: " Viresh Kumar
2013-08-19 15:31 ` [PATCH V2 00/25] tty: serial: drop uart_port->lock before calling Peter Hurley
2013-08-20  0:18   ` Viresh Kumar
2013-08-20  2:35     ` Peter Hurley [this message]
2013-08-20 10:52       ` Viresh Kumar
2013-08-20 19:38         ` Peter Hurley
2013-08-21  4:35           ` Viresh Kumar
2013-08-23  8:26             ` Viresh Kumar
2013-08-27 23:19               ` Greg Kroah-Hartman
2013-08-28  3:31                 ` Viresh Kumar
2013-08-28  3:43                   ` Greg Kroah-Hartman
2013-08-28  3:45                     ` Viresh Kumar
2013-08-28  5:58                 ` Viresh Kumar
2013-08-28  6:05                   ` Greg Kroah-Hartman
2013-08-28  6:07                     ` Viresh Kumar
2013-08-28  6:15                       ` Greg Kroah-Hartman

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=5212D602.2000005@hurleysoftware.com \
    --to=peter@hurleysoftware.com \
    --cc=bryanh@codeaurora.org \
    --cc=davidb@codeaurora.org \
    --cc=dwalker@fifo99.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@prisktech.co.nz \
    --cc=patches@linaro.org \
    --cc=swarren@wwwdotorg.org \
    --cc=tklauser@distanz.ch \
    --cc=viresh.kumar@linaro.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.