Re: [RFC RESEND] serial: 8250: fix regression in 8250 uart driver

From: Andy Shevchenko
Date: Tue Aug 23 2016 - 11:03:16 EST


On Tue, 2016-08-23 at 08:53 -0500, Dinh Nguyen wrote:
> Hi Andy,
>
> On 08/17/2016 06:14 AM, Andy Shevchenko wrote:
> >
> >
> > I sent a v2 of the series for internal review, same you may found on
> > [1]. If Heikki is okay to that I'll send it here.
> >
> > [1] https://bitbucket.org/andy-shev/linux/branch/topic%2Fdw%2Fqrk
> >
>
> I tested this branch on SoCFPGA hardware and encountered this
> error[1].
> Doing a bisect led me to this commit[2].

Thanks! Found today the same.

Yes, here is the fix (will push an updated version later):


--- a/drivers/tty/serial/8250/8250_dma.c
+++ b/drivers/tty/serial/8250/8250_dma.c
@@ -260,7 +260,7 @@ void serial8250_release_dma(struct uart_8250_port
*p)
Â{
ÂÂÂÂÂÂÂÂstruct uart_8250_dma *dma = p->dma;

-ÂÂÂÂÂÂÂif (!dma)
+ÂÂÂÂÂÂÂif (!dma->in_use)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn;

ÂÂÂÂÂÂÂÂ/* Release RX resources */

>
> Dinh
>
>
> --------------------[1]------------------------------
>
> [ÂÂÂÂ5.907714] ttyS0 - failed to request DMA
> [ÂÂÂÂ5.921937] VFS: Mounted root (nfs filesystem) on device 0:13.
> [ÂÂÂÂ5.928732] devtmpfs: mounted
> [ÂÂÂÂ5.932504] Freeing unused kernel memory: 1024K (c0900000 -
> c0a00000)
> [ÂÂÂÂ6.004532] Unable to handle kernel NULL pointer dereference at
> virtual address 0000000c
> [ÂÂÂÂ6.012619] pgd = ef670000
> [ÂÂÂÂ6.015321] [0000000c] *pgd=2ec0a831, *pte=00000000, *ppte=00000000
> [ÂÂÂÂ6.021609] Internal error: Oops: 17 [#1] SMP ARM
> [ÂÂÂÂ6.026301] Modules linked in:
> [ÂÂÂÂ6.029365] CPU: 1 PID: 1 Comm: init Not tainted
> 4.8.0-rc3-00063-g6ce52b1 #12
> [ÂÂÂÂ6.036476] Hardware name: Altera SOCFPGA
> [ÂÂÂÂ6.040476] task: ef4ac000 task.stack: ef4b0000
> [ÂÂÂÂ6.045007] PC is at _stop+0x4/0x254
> [ÂÂÂÂ6.048579] LR is at pl330_terminate_all+0x4c/0x1e4
> [ÂÂÂÂ6.053447] pc : [<c03c2e5c>]ÂÂÂÂlr : [<c03c30f8>]ÂÂÂÂpsr: 60000093
> [ÂÂÂÂ6.053447] sp : ef4b1e88ÂÂip : 00000000ÂÂfp : 0000a109
> [ÂÂÂÂ6.064890] r10: 00000000ÂÂr9 : ef7c7cc0ÂÂr8 : eedfaa94
> [ÂÂÂÂ6.070099] r7 : eed30410ÂÂr6 : eec2be0cÂÂr5 : 60000013ÂÂr4 :
> eec2be70
> [ÂÂÂÂ6.076605] r3 : 00000002ÂÂr2 : 00000002ÂÂr1 : 00000000ÂÂr0 :
> 00000000
> [ÂÂÂÂ6.083113] Flags: nZCvÂÂIRQs offÂÂFIQs onÂÂMode SVC_32ÂÂISA ARM
> Segment none
> [ÂÂÂÂ6.090318] Control: 10c5387dÂÂTable: 2f67004aÂÂDAC: 00000051
> [ÂÂÂÂ6.096046] Process init (pid: 1, stack limit = 0xef4b0218)
> [ÂÂÂÂ6.101603] Stack: (0xef4b1e88 to 0xef4b2000)
> [ÂÂÂÂ6.105953] 1e80:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂeec2be70 60000013 eec2be0c
> eedfaa94 ef7c7cc0 c03c30f8
> [ÂÂÂÂ6.114112] 1ea0: ef4b1ea0 ef4b1ea0 eedfaa00 eed8c02c eec2be20
> 20000013 c0a66208 c03f2b44
> [ÂÂÂÂ6.122272] 1ec0: 00000001 00000000 c0a66208 c0a66208 c0a66324
> 20000013 c0a66208 eedfaa94
> [ÂÂÂÂ6.130432] 1ee0: ef7c7cc0 c03f041c eedfaa00 c0a66208 eedfaa8c
> c03ea774 eedfaa00 ef7cec00
> [ÂÂÂÂ6.138592] 1f00: c0a66208 00000001 eedfaa94 c03eb9a4 ef7cec00
> ef1a2930 00000000 ef41bd90
> [ÂÂÂÂ6.146751] 1f20: ef1a4440 c03d0790 00080040 00080060 00000000
> 00000000 00002710 ef7c7cc0
> [ÂÂÂÂ6.154911] 1f40: ef1a2930 00000000 ef41bd90 ef1a4440 00000008
> ef7c7cc8 0000a109 c021b594
> [ÂÂÂÂ6.163071] 1f60: 00000000 00000000 ef4ac3d4 c0a532f8 00000000
> ef4ac000 c0107884 ef4b0000
> [ÂÂÂÂ6.171231] 1f80: 00000000 c0138a14 ef4b0000 ef4b1fb0 c0107884
> 00000006 c0107884 c010b274
> [ÂÂÂÂ6.179390] 1fa0: 00015500 00000000 bea16c4c c0107714 00000000
> 00000800 00000045 0000c79c
> [ÂÂÂÂ6.187550] 1fc0: 00015500 00000000 bea16c4c 00000006 bea16bc0
> 00009c59 10000000 0000a109
> [ÂÂÂÂ6.195709] 1fe0: 00000000 bea16bb4 0000bf81 b6f6413c 40000010
> 00000002 00000c84 01000002
> [ÂÂÂÂ6.203878] [<c03c2e5c>] (_stop) from [<c03c30f8>]
> (pl330_terminate_all+0x4c/0x1e4)
> [ÂÂÂÂ6.211526] [<c03c30f8>] (pl330_terminate_all) from [<c03f2b44>]
> (serial8250_release_dma+0x30/0x1c8)
> [ÂÂÂÂ6.220640] [<c03f2b44>] (serial8250_release_dma) from [<c03f041c>]
> (serial8250_do_shutdown+0x64/0x144)
> [ÂÂÂÂ6.230019] [<c03f041c>] (serial8250_do_shutdown) from [<c03ea774>]
> (uart_shutdown+0xd0/0x104)
> [ÂÂÂÂ6.238614] [<c03ea774>] (uart_shutdown) from [<c03eb9a4>]
> (uart_close+0x148/0x298)
> [ÂÂÂÂ6.246266] [<c03eb9a4>] (uart_close) from [<c03d0790>]
> (tty_release+0xf0/0x4d4)
> [ÂÂÂÂ6.253658] [<c03d0790>] (tty_release) from [<c021b594>]
> (__fput+0x80/0x1c8)
> [ÂÂÂÂ6.260694] [<c021b594>] (__fput) from [<c0138a14>]
> (task_work_run+0xb8/0xe8)
> [ÂÂÂÂ6.267822] [<c0138a14>] (task_work_run) from [<c010b274>]
> (do_work_pending+0x7c/0xa4)
> [ÂÂÂÂ6.275727] [<c010b274>] (do_work_pending) from [<c0107714>]
> (slow_work_pending+0xc/0x20)
> [ÂÂÂÂ6.283888] Code: e8bd8070 e3a04000 eafffff9 e92d4370 (e590300c)
> [ÂÂÂÂ6.289963] ---[ end trace e214cd70660516e6 ]---
> [ÂÂÂÂ6.294806] Kernel panic - not syncing: Attempted to kill init!
> exitcode=0x0000000b
> [ÂÂÂÂ6.294806]
> [ÂÂÂÂ6.303932] CPU0: stopping
> [ÂÂÂÂ6.306645] CPU: 0 PID: 0 Comm: swapper/0 Tainted: GÂÂÂÂÂÂD
> 4.8.0-rc3-00063-g6ce52b1 #12
> [ÂÂÂÂ6.315406] Hardware name: Altera SOCFPGA
> [ÂÂÂÂ6.319425] [<c010fef0>] (unwind_backtrace) from [<c010b8a4>]
> (show_stack+0x10/0x14)
> [ÂÂÂÂ6.327159] [<c010b8a4>] (show_stack) from [<c037aa18>]
> (dump_stack+0x84/0x98)
> [ÂÂÂÂ6.334372] [<c037aa18>] (dump_stack) from [<c010edb4>]
> (handle_IPI+0x2a0/0x2bc)
> [ÂÂÂÂ6.341755] [<c010edb4>] (handle_IPI) from [<c01014cc>]
> (gic_handle_irq+0x88/0x8c)
> [ÂÂÂÂ6.349310] [<c01014cc>] (gic_handle_irq) from [<c010c38c>]
> (__irq_svc+0x6c/0x90)
> [ÂÂÂÂ6.356775] Exception stack(0xc0a01f50 to 0xc0a01f98)
> [ÂÂÂÂ6.361815] 1f40:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ00000000
> ef9cd368 0000153c c01184a0
> [ÂÂÂÂ6.369976] 1f60: c0a00000 c0a024a4 c0a023c0 c0a50390 c0a02454
> 00000001 c0a02454 00000000
> [ÂÂÂÂ6.378135] 1f80: 60000013 c0a01fa0 c01081a8 c01081ac 60000013
> ffffffff
> [ÂÂÂÂ6.384734] [<c010c38c>] (__irq_svc) from [<c01081ac>]
> (arch_cpu_idle+0x38/0x3c)
> [ÂÂÂÂ6.392127] [<c01081ac>] (arch_cpu_idle) from [<c0158cec>]
> (cpu_startup_entry+0x204/0x25c)
> [ÂÂÂÂ6.400379] [<c0158cec>] (cpu_startup_entry) from [<c0900c60>]
> (start_kernel+0x370/0x37c)
> [ÂÂÂÂ6.408542] ---[ end Kernel panic - not syncing: Attempted to kill
> init! exitcode=0x0000000b
> [ÂÂÂÂ6.408542]
>
>
> --------------------[2]----------------------------------
> commit 60a0605738814ca8fa180cdfef20fcc2a32ec1ef
> Author: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> Date:ÂÂÂMon Jun 13 12:17:03 2016 +0300
>
> ÂÂÂÂserial: 8250: allow user to skip using of DMA channels
>
> ÂÂÂÂCurrently DMA mode is enforced if the certain driver has such
> support. It prevents user to enforce PIO mode for RX, TX, or both.
>
> ÂÂÂÂThe new module parameters skip_rxdma and skip_txdma allow user to
> choose between auto mode, which is current and default behaviour,
> disable RX, TX, or both DMA channels without hacking a kernel.
>
> ÂÂÂÂSigned-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>

--
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy