mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Song liwei <liwei.song@windriver.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Chuah Kim Tatt <kim.tatt.chuah@intel.com>,
	Vinod Koul <vinod.koul@intel.com>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] serial: 8250_mid fix calltrace when hotplug 8250 serial controller
Date: Wed, 30 Nov 2016 18:14:49 +0200	[thread overview]
Message-ID: <1480522489.21899.55.camel@linux.intel.com> (raw)
In-Reply-To: <1480487125-214457-1-git-send-email-liwei.song@windriver.com>

On Wed, 2016-11-30 at 01:25 -0500, Song liwei wrote:
> From: Liwei Song <liwei.song@windriver.com>
> 
> Fix the following Calltrace:
> [   77.768221] WARNING: CPU: 5 PID: 645 at
> drivers/dma/dmaengine.c:1069 dma_async_device_unregister+0xe2/0xf0
> [   77.775058] dma_async_device_unregister called while 1 clients hold
> a reference
> [   77.825048] CPU: 5 PID: 645 Comm: sh Not tainted 4.8.8-
> WR9.0.0.0_standard+ #3
> [   77.832550] Hardware name: Intel Corp. Aspen Cove/Server, BIOS
> HAVLCRB1.X64.0012.D58.1604140405 04/14/2016
> [   77.840396]  0000000000000000 ffffc90008adbc80 ffffffff81403456
> ffffc90008adbcd0
> [   77.848245]  0000000000000000 ffffc90008adbcc0 ffffffff8105e2e1
> 0000042d08adbf20
> [   77.855934]  ffff88046a861c18 ffff88046a85c420 ffffffff820d4200
> ffff88046ae92318
> [   77.863601] Call Trace:
> [   77.871113]  [<ffffffff81403456>] dump_stack+0x4f/0x69
> [   77.878655]  [<ffffffff8105e2e1>] __warn+0xd1/0xf0
> [   77.886102]  [<ffffffff8105e34f>] warn_slowpath_fmt+0x4f/0x60
> [   77.893508]  [<ffffffff814187a9>] ? find_next_bit+0x19/0x20
> [   77.900730]  [<ffffffff814bf83e>] ?
> dma_channel_rebalance+0x23e/0x270
> [   77.907814]  [<ffffffff814bfee2>]
> dma_async_device_unregister+0xe2/0xf0
> [   77.914992]  [<ffffffff814c53aa>] hsu_dma_remove+0x1a/0x60
> [   77.921977]  [<ffffffff814ee14c>] dnv_exit+0x1c/0x20
> [   77.928752]  [<ffffffff814edff6>] mid8250_remove+0x26/0x40
> [   77.935607]  [<ffffffff8144f1b9>] pci_device_remove+0x39/0xc0
> [   77.942292]  [<ffffffff8160cfea>]
> __device_release_driver+0x9a/0x140
> [   77.948836]  [<ffffffff8160d0b3>] device_release_driver+0x23/0x30
> [   77.955364]  [<ffffffff81447dcc>] pci_stop_bus_device+0x8c/0xa0
> [   77.961769]  [<ffffffff81447f0a>]
> pci_stop_and_remove_bus_device_locked+0x1a/0x30
> [   77.968113]  [<ffffffff81450d4e>] remove_store+0x5e/0x70
> [   77.974267]  [<ffffffff81607ed8>] dev_attr_store+0x18/0x30
> [   77.980243]  [<ffffffff8123006a>] sysfs_kf_write+0x3a/0x50
> [   77.986180]  [<ffffffff8122f5ab>] kernfs_fop_write+0x10b/0x190
> [   77.992118]  [<ffffffff811bf1c8>] __vfs_write+0x18/0x40
> [   77.998032]  [<ffffffff811bfdee>] vfs_write+0xae/0x190
> [   78.003747]  [<ffffffff811c1016>] SyS_write+0x46/0xb0
> [   78.009234]  [<ffffffff81a4c31b>]
> entry_SYSCALL_64_fastpath+0x13/0x8f
> [   78.014809] ---[ end trace 0c36dd73b7408eb2 ]---
> 
> This happens when the 8250 serial controller is hotplugged as follows:
> echo 1 > /sys/bus/pci/devices/0000:00:1a.0/remove
> 
> This trace happens due to the serial port still holding a reference
> when
> the dma device is unregistered.
> The dma unregister routine will check if there is still a reference
> exist,
> if so it will give the WARNING(here serial port still was not
> unregister).
> 
> To fix this, We need to unregister the serial port first, then do DMA
> device unregister to make sure there is no reference when to DMA
> routine.
> 

Good catch, thanks!

Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Liwei Song <liwei.song@windriver.com>
> ---
>  drivers/tty/serial/8250/8250_mid.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_mid.c
> b/drivers/tty/serial/8250/8250_mid.c
> index 39c2324..ac013edf 100644
> --- a/drivers/tty/serial/8250/8250_mid.c
> +++ b/drivers/tty/serial/8250/8250_mid.c
> @@ -303,10 +303,10 @@ static void mid8250_remove(struct pci_dev *pdev)
>  {
>  	struct mid8250 *mid = pci_get_drvdata(pdev);
>  
> +	serial8250_unregister_port(mid->line);
> +
>  	if (mid->board->exit)
>  		mid->board->exit(mid);
> -
> -	serial8250_unregister_port(mid->line);
>  }
>  
>  static const struct mid8250_board pnw_board = {

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

      reply	other threads:[~2016-11-30 16:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30  6:25 Song liwei
2016-11-30 16:14 ` Andy Shevchenko [this message]

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=1480522489.21899.55.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jslaby@suse.com \
    --cc=kim.tatt.chuah@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=liwei.song@windriver.com \
    --cc=vinod.koul@intel.com \
    /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

Powered by JetHome