Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756176AbcK3G0k (ORCPT ); Wed, 30 Nov 2016 01:26:40 -0500 Received: from mail.windriver.com ([147.11.1.11]:48769 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751606AbcK3G0c (ORCPT ); Wed, 30 Nov 2016 01:26:32 -0500 From: Song liwei To: Greg Kroah-Hartman CC: Jiri Slaby , Andy Shevchenko , Heikki Krogerus , Chuah Kim Tatt , Vinod Koul , , , Subject: [PATCH] serial: 8250_mid fix calltrace when hotplug 8250 serial controller Date: Wed, 30 Nov 2016 01:25:25 -0500 Message-ID: <1480487125-214457-1-git-send-email-liwei.song@windriver.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3409 Lines: 70 From: Liwei Song 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] [] dump_stack+0x4f/0x69 [ 77.878655] [] __warn+0xd1/0xf0 [ 77.886102] [] warn_slowpath_fmt+0x4f/0x60 [ 77.893508] [] ? find_next_bit+0x19/0x20 [ 77.900730] [] ? dma_channel_rebalance+0x23e/0x270 [ 77.907814] [] dma_async_device_unregister+0xe2/0xf0 [ 77.914992] [] hsu_dma_remove+0x1a/0x60 [ 77.921977] [] dnv_exit+0x1c/0x20 [ 77.928752] [] mid8250_remove+0x26/0x40 [ 77.935607] [] pci_device_remove+0x39/0xc0 [ 77.942292] [] __device_release_driver+0x9a/0x140 [ 77.948836] [] device_release_driver+0x23/0x30 [ 77.955364] [] pci_stop_bus_device+0x8c/0xa0 [ 77.961769] [] pci_stop_and_remove_bus_device_locked+0x1a/0x30 [ 77.968113] [] remove_store+0x5e/0x70 [ 77.974267] [] dev_attr_store+0x18/0x30 [ 77.980243] [] sysfs_kf_write+0x3a/0x50 [ 77.986180] [] kernfs_fop_write+0x10b/0x190 [ 77.992118] [] __vfs_write+0x18/0x40 [ 77.998032] [] vfs_write+0xae/0x190 [ 78.003747] [] SyS_write+0x46/0xb0 [ 78.009234] [] 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. Signed-off-by: Liwei Song --- 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 = { -- 2.9.3