From: Stephen Boyd <sboyd@codeaurora.org> To: Peter Hurley <peter@hurleysoftware.com> Cc: Kumar Gala <galak@codeaurora.org>, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-arm-msm <linux-arm-msm@vger.kernel.org>, linux-arm-kernel@lists.infradead.org, Rob Herring <robh@kernel.org> Subject: Re: [PATCH] tty: serial: msm: Fix lock init issue with earlycon Date: Mon, 20 Oct 2014 15:16:56 -0700 [thread overview] Message-ID: <20141020221656.GC12469@codeaurora.org> (raw) In-Reply-To: <544580ED.3050604@hurleysoftware.com> On 10/20, Peter Hurley wrote: > On 10/20/2014 02:27 PM, Stephen Boyd wrote: > > On 10/17/2014 06:13 AM, Kumar Gala wrote: > >> With CONFIG_DEBUG_SPINLOCK enabled we see: > >> > >> BUG: spinlock bad magic on CPU#0, swapper/0 > >> lock: early_console_dev+0x8/0x160, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0 > >> CPU: 0 PID: 0 Comm: swapper Not tainted 3.17.0-09733-gb446b33-dirty #18 > > > > [...] > > > >> diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c > >> index 4b6c783..8ab27c9 100644 > >> --- a/drivers/tty/serial/msm_serial.c > >> +++ b/drivers/tty/serial/msm_serial.c > >> @@ -973,6 +973,8 @@ msm_serial_early_console_setup(struct earlycon_device *device, const char *opt) > >> if (!device->port.membase) > >> return -ENODEV; > >> + spin_lock_init(&device->port.lock); > >> + > >> device->con->write = msm_serial_early_write; > >> return 0; > >> } > >> @@ -995,6 +997,8 @@ msm_serial_early_console_setup_dm(struct earlycon_device *device, > >> if (!device->port.membase) > >> return -ENODEV; > >> + spin_lock_init(&device->port.lock); > >> + > >> device->con->write = msm_serial_early_write_dm; > >> return 0; > >> } > > > > Could this be done in the tty core instead? > > Or even better: refactor __msm_console_write() so no spin_lock() is required > for the earlycon write. Can't we keep the early console forever with keep_bootcon? In which case we may want to prevent things from trampling on each other? I don't see how the lock will help us here though because the port isn't even the same between the earlycon and the ttyMSM console. Removing the lock from the earlycon path is probably easier than caring about this debugging scenario. > > FWIW, __msm_console_write() is a deadlock-waiting-to_happen since it does > not disable interrupts with spin_lock_irqsave(). > Yeah we should fix that. As far as I can tell we've never used the irqsave variant of the lock in the console path. Did this become necessary at some point since this driver was introduced? I'm wondering how many stable trees need the fix. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
WARNING: multiple messages have this Message-ID (diff)
From: sboyd@codeaurora.org (Stephen Boyd) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] tty: serial: msm: Fix lock init issue with earlycon Date: Mon, 20 Oct 2014 15:16:56 -0700 [thread overview] Message-ID: <20141020221656.GC12469@codeaurora.org> (raw) In-Reply-To: <544580ED.3050604@hurleysoftware.com> On 10/20, Peter Hurley wrote: > On 10/20/2014 02:27 PM, Stephen Boyd wrote: > > On 10/17/2014 06:13 AM, Kumar Gala wrote: > >> With CONFIG_DEBUG_SPINLOCK enabled we see: > >> > >> BUG: spinlock bad magic on CPU#0, swapper/0 > >> lock: early_console_dev+0x8/0x160, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0 > >> CPU: 0 PID: 0 Comm: swapper Not tainted 3.17.0-09733-gb446b33-dirty #18 > > > > [...] > > > >> diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c > >> index 4b6c783..8ab27c9 100644 > >> --- a/drivers/tty/serial/msm_serial.c > >> +++ b/drivers/tty/serial/msm_serial.c > >> @@ -973,6 +973,8 @@ msm_serial_early_console_setup(struct earlycon_device *device, const char *opt) > >> if (!device->port.membase) > >> return -ENODEV; > >> + spin_lock_init(&device->port.lock); > >> + > >> device->con->write = msm_serial_early_write; > >> return 0; > >> } > >> @@ -995,6 +997,8 @@ msm_serial_early_console_setup_dm(struct earlycon_device *device, > >> if (!device->port.membase) > >> return -ENODEV; > >> + spin_lock_init(&device->port.lock); > >> + > >> device->con->write = msm_serial_early_write_dm; > >> return 0; > >> } > > > > Could this be done in the tty core instead? > > Or even better: refactor __msm_console_write() so no spin_lock() is required > for the earlycon write. Can't we keep the early console forever with keep_bootcon? In which case we may want to prevent things from trampling on each other? I don't see how the lock will help us here though because the port isn't even the same between the earlycon and the ttyMSM console. Removing the lock from the earlycon path is probably easier than caring about this debugging scenario. > > FWIW, __msm_console_write() is a deadlock-waiting-to_happen since it does > not disable interrupts with spin_lock_irqsave(). > Yeah we should fix that. As far as I can tell we've never used the irqsave variant of the lock in the console path. Did this become necessary at some point since this driver was introduced? I'm wondering how many stable trees need the fix. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2014-10-20 22:16 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-10-17 13:13 [PATCH] tty: serial: msm: Fix lock init issue with earlycon Kumar Gala 2014-10-17 13:13 ` Kumar Gala 2014-10-20 18:27 ` Stephen Boyd 2014-10-20 18:27 ` Stephen Boyd 2014-10-20 21:38 ` Peter Hurley 2014-10-20 21:38 ` Peter Hurley 2014-10-20 22:16 ` Stephen Boyd [this message] 2014-10-20 22:16 ` Stephen Boyd 2014-10-20 22:20 ` Stephen Boyd 2014-10-20 22:20 ` Stephen Boyd 2014-10-21 19:42 ` Peter Hurley 2014-10-21 19:42 ` Peter Hurley
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=20141020221656.GC12469@codeaurora.org \ --to=sboyd@codeaurora.org \ --cc=galak@codeaurora.org \ --cc=gregkh@linuxfoundation.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-arm-msm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=peter@hurleysoftware.com \ --cc=robh@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: linkBe 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.