Message ID | 20230413070342.36155-1-tony@atomide.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp842918vqo; Thu, 13 Apr 2023 00:13:38 -0700 (PDT) X-Google-Smtp-Source: AKy350YJrbnP5OCyCp5w6DY3j/7eErsoSwB5u6vHP/oTMAEMLTvqCfA4OknozGd3oH/TYwUgSIv7 X-Received: by 2002:aa7:c2d4:0:b0:504:923f:e657 with SMTP id m20-20020aa7c2d4000000b00504923fe657mr1519359edp.35.1681370018386; Thu, 13 Apr 2023 00:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681370018; cv=none; d=google.com; s=arc-20160816; b=0CxBrz0cEICvxERp5wU6h5skhvCeLb3Iv3Ae+uOJKKXR2vr8ZYU81Q84bvJpxDU095 /VS63xwFVhEUqU1x3aenouwBYb5v99lcxfPhvSIN/VIMosbU+B+hOXTArxQdG/9TkLfg 393iQQYls82NQmhsS/MXNZxlWWQ5yFHcqIZEID7JdyUOtm0rNujLSWZAchSo0Qcr8Oo0 ZEse+ZK+9Uo0wHi0tcJJR3N6QW7ZD4Me1iCYXHutSjhOUGWnM/dLAgh+pqGhZC8Wt1TQ 9FSJ3fJHmpkPhQbJoCvPBr+ikx0KEfoc1DUFehjH7s2kRzQj4f95GxT0ruDItlIFHdB0 Dngw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=SHwJBrq4SwRDMeu2g/n7MDDNulLRu/ved3hljXaXi5k=; b=Jqg7H6wW7NVtOTjT6riIgXtu2MzpBtSy04HtI5/O5K/oC7zAvbcSomu9VoEHhf+G05 riophuaRT/QAgPuLsxXaBVeKVIShdZ1p+oiKEc+pHmjWaxIo2K3OePsQPcrJtqnehRsD qF3Hm/W33/OvgXrfkzEk+cd4wbqMJPWRWWNpi6KuTV1CGicS5G76lM4Zve25ATli6T20 lFyADwT3kXQEu5CIqhmZ1aHIbqMyvCW/myr5so2mzSMarqn2jwKrINM9q3pG17hXt23c FMcm+IM0l3ZjJITQysL47Sxn9nAX/knfnAH69ffye6B/2MqIFmm0Rx8hLMWCXrnP7gaB RTDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c13-20020aa7df0d000000b00504806b0ff0si1125136edy.127.2023.04.13.00.13.14; Thu, 13 Apr 2023 00:13:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229721AbjDMHEB (ORCPT <rfc822;peter110.wang@gmail.com> + 99 others); Thu, 13 Apr 2023 03:04:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbjDMHD5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Apr 2023 03:03:57 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5344F46B9; Thu, 13 Apr 2023 00:03:56 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 5C3C580F0; Thu, 13 Apr 2023 07:03:54 +0000 (UTC) From: Tony Lindgren <tony@atomide.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org> Cc: Andy Shevchenko <andriy.shevchenko@intel.com>, =?utf-8?q?Ilpo_J=C3=A4rvi?= =?utf-8?q?nen?= <ilpo.jarvinen@linux.intel.com>, Johan Hovold <johan@kernel.org>, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Vignesh Raghavendra <vigneshr@ti.com>, linux-omap@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] serial: 8250: Clear port->pm on port specific driver unbind Date: Thu, 13 Apr 2023 10:03:41 +0300 Message-Id: <20230413070342.36155-1-tony@atomide.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763044248634019753?= X-GMAIL-MSGID: =?utf-8?q?1763044248634019753?= |
Series |
serial: 8250: Clear port->pm on port specific driver unbind
|
|
Commit Message
Tony Lindgren
April 13, 2023, 7:03 a.m. UTC
When we unbind a serial port hardware specific 8250 driver, the generic
serial8250 driver takes over the port. After that we see an oops about 10
seconds later. This can produce the following at least on some TI SoCs:
Unhandled fault: imprecise external abort (0x1406)
Internal error: : 1406 [#1] SMP ARM
Turns out that we may still have the serial port hardware specific driver
port->pm in use, and serial8250_pm() tries to call it after the port
specific driver is gone:
serial8250_pm [8250_base] from uart_change_pm+0x54/0x8c [serial_base]
uart_change_pm [serial_base] from uart_hangup+0x154/0x198 [serial_base]
uart_hangup [serial_base] from __tty_hangup.part.0+0x328/0x37c
__tty_hangup.part.0 from disassociate_ctty+0x154/0x20c
disassociate_ctty from do_exit+0x744/0xaac
do_exit from do_group_exit+0x40/0x8c
do_group_exit from __wake_up_parent+0x0/0x1c
Let's fix the issue by clearing port->pm in serial8250_unregister_port().
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/tty/serial/8250/8250_core.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Thu, Apr 13, 2023 at 10:03:41AM +0300, Tony Lindgren wrote: > When we unbind a serial port hardware specific 8250 driver, the generic > serial8250 driver takes over the port. After that we see an oops about 10 > seconds later. This can produce the following at least on some TI SoCs: > > Unhandled fault: imprecise external abort (0x1406) > Internal error: : 1406 [#1] SMP ARM > > Turns out that we may still have the serial port hardware specific driver > port->pm in use, and serial8250_pm() tries to call it after the port > specific driver is gone: > > serial8250_pm [8250_base] from uart_change_pm+0x54/0x8c [serial_base] > uart_change_pm [serial_base] from uart_hangup+0x154/0x198 [serial_base] > uart_hangup [serial_base] from __tty_hangup.part.0+0x328/0x37c > __tty_hangup.part.0 from disassociate_ctty+0x154/0x20c > disassociate_ctty from do_exit+0x744/0xaac > do_exit from do_group_exit+0x40/0x8c > do_group_exit from __wake_up_parent+0x0/0x1c > > Let's fix the issue by clearing port->pm in serial8250_unregister_port(). Sounds to me like a fix that needs a Fixes tag. Code wise LGTM, Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Signed-off-by: Tony Lindgren <tony@atomide.com> > --- > drivers/tty/serial/8250/8250_core.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c > --- a/drivers/tty/serial/8250/8250_core.c > +++ b/drivers/tty/serial/8250/8250_core.c > @@ -1157,6 +1157,7 @@ void serial8250_unregister_port(int line) > uart->port.flags &= ~UPF_BOOT_AUTOCONF; > uart->port.type = PORT_UNKNOWN; > uart->port.dev = &serial8250_isa_devs->dev; > + uart->port.pm = NULL; > uart->capabilities = 0; > serial8250_apply_quirks(uart); > uart_add_one_port(&serial8250_reg, &uart->port); > -- > 2.40.0
* Andy Shevchenko <andriy.shevchenko@linux.intel.com> [230413 16:06]: > On Thu, Apr 13, 2023 at 10:03:41AM +0300, Tony Lindgren wrote: > > Let's fix the issue by clearing port->pm in serial8250_unregister_port(). > > Sounds to me like a fix that needs a Fixes tag. Maybe commit c161afe9759d ("8250: allow platforms to override PM hook."). That's a bit unclear though as the hardware specific functions were available at that point as they were passed in platform data. This can be seen with git blame c161afe9759d drivers/serial/8250.c. To me it seems the port->pm became potentially invalid if a serial port device driver started implementing PM runtime? Maybe just tagging it with Cc: stable is better if no obvious Fixes tag can be figured out. > Code wise LGTM, > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> OK thanks, Tony
On Fri, 14 Apr 2023, Tony Lindgren wrote: > * Andy Shevchenko <andriy.shevchenko@linux.intel.com> [230413 16:06]: > > On Thu, Apr 13, 2023 at 10:03:41AM +0300, Tony Lindgren wrote: > > > Let's fix the issue by clearing port->pm in serial8250_unregister_port(). > > > > Sounds to me like a fix that needs a Fixes tag. > > Maybe commit c161afe9759d ("8250: allow platforms to override PM hook."). > > That's a bit unclear though as the hardware specific functions were > available at that point as they were passed in platform data. This can > be seen with git blame c161afe9759d drivers/serial/8250.c. To me it seems > the port->pm became potentially invalid if a serial port device driver > started implementing PM runtime? > > Maybe just tagging it with Cc: stable is better if no obvious Fixes tag > can be figured out. I'd just put that c161afe9759d there. It seems quite harmless even if it would be unnecessary before some driver commit which is much harder to pinpoint (and it would likely turn out old enough to not matter anyway for the kernels stable cares about). I forgot to give this earlier: Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
* Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> [230414 07:36]: > On Fri, 14 Apr 2023, Tony Lindgren wrote: > > > * Andy Shevchenko <andriy.shevchenko@linux.intel.com> [230413 16:06]: > > > On Thu, Apr 13, 2023 at 10:03:41AM +0300, Tony Lindgren wrote: > > > > Let's fix the issue by clearing port->pm in serial8250_unregister_port(). > > > > > > Sounds to me like a fix that needs a Fixes tag. > > > > Maybe commit c161afe9759d ("8250: allow platforms to override PM hook."). > > > > That's a bit unclear though as the hardware specific functions were > > available at that point as they were passed in platform data. This can > > be seen with git blame c161afe9759d drivers/serial/8250.c. To me it seems > > the port->pm became potentially invalid if a serial port device driver > > started implementing PM runtime? > > > > Maybe just tagging it with Cc: stable is better if no obvious Fixes tag > > can be figured out. > > I'd just put that c161afe9759d there. It seems quite harmless even if it > would be unnecessary before some driver commit which is much harder to > pinpoint (and it would likely turn out old enough to not matter anyway > for the kernels stable cares about). OK works for me. I'm now wondering still if we should clear all the conditional hardware specific functions too in addition to port->pm that get set in serial8250_register_8250_port(). Maybe best done in a separate patch as needed.. Any suggestions? > I forgot to give this earlier: > > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Thanks, Tony
* Tony Lindgren <tony@atomide.com> [230414 09:40]: > I'm now wondering still if we should clear all the conditional hardware > specific functions too in addition to port->pm that get set in > serial8250_register_8250_port(). Maybe best done in a separate patch > as needed.. Any suggestions? Well we can't do memset on the port for sure at this point.. But what we can do is call serial8250_set_defaults() instead of clearing just port->pm. This will set the port back to serial8250 default functions, and will set port->pm too. I'll send v2 patch after some more testing. Regards, Tony
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c @@ -1157,6 +1157,7 @@ void serial8250_unregister_port(int line) uart->port.flags &= ~UPF_BOOT_AUTOCONF; uart->port.type = PORT_UNKNOWN; uart->port.dev = &serial8250_isa_devs->dev; + uart->port.pm = NULL; uart->capabilities = 0; serial8250_apply_quirks(uart); uart_add_one_port(&serial8250_reg, &uart->port);