Date: Sun, 4 Mar 2018 11:38:12 -0800 From: Thomas Skibo <thomasskibo@yahoo.com> To: freebsd-arm@freebsd.org Subject: Panic in spi driver Message-ID: <838BFE5B-61CD-4EC4-BB4F-8124B5B3AF9F@yahoo.com>
next in thread | raw e-mail | index | archive | help
--Apple-Mail=_5921723D-9B2B-449D-91BA-7076B225BE32 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 I=E2=80=99m developing a qspi driver for Zynq/Zedboard and running into = a problem that might affect other spi drivers. When my driver does its = attach, it triggers the attach of the flash driver, dev/flash/mx25l.c, = through spibus. In turn, the flash driver attempts to read the flash = device ident by calling back to my driver=E2=80=99s transfer function. = My driver initiates the transfer and then sleeps on its lock with a = timeout (mtx_sleep(=E2=80=A6, 2 * hz)). That panics the system: = =E2=80=9Cpanic: timed sleep before timers are working=E2=80=9D. I=E2=80=99= ve attached the stack backtrace. I loosely based my driver on bcm2835_spi.c which also sleeps with a = timeout in its transfer function. I tried greping through a few other = spi drivers and noticed dev/intel/spi.c does it too. =20 Okay, before I hit send, I noticed that the other flash driver, at45d.c, = uses some hook to do a delayed attach with the comment =E2=80=9CWe=E2=80=99= ll see what kind of flash we have later=E2=80=A6=E2=80=9D. Maybe = mx25l.c needs something like this. My other idea is to create a =E2=80=9Cfast transfer=E2=80=9D function = that doesn=E2=80=99t use interrupts to be used for trivial transfers. = That would take care of the IDENT and READ_STATUS commands that happen = in the flash driver=E2=80=99s attach routine. It might be a nice = optimization too. =E2=80=94Thomas --Apple-Mail=_5921723D-9B2B-449D-91BA-7076B225BE32 Content-Disposition: attachment; filename=panic.txt Content-Type: text/plain; x-unix-mode=0644; name="panic.txt" Content-Transfer-Encoding: 7bit .... spi0: <Zynq Quad-SPI Flash Controller> mem 0xd000-0xdfff irq 13 on simplebus1 spibus0: <OFW SPI bus> on spi0 mx25l0: <M25Pxx Flash Family> at cs 0 mode 0 on spibus0 panic: timed sleep before timers are working cpuid = 0 time = 1 KDB: stack backtrace: db_trace_self() at db_trace_self pc = 0xc04cef94 lr = 0xc0097da0 (db_trace_self_wrapper+0x30) sp = 0xc0913938 fp = 0xc0913a50 db_trace_self_wrapper() at db_trace_self_wrapper+0x30 pc = 0xc0097da0 lr = 0xc01e7394 (vpanic+0x154) sp = 0xc0913a58 fp = 0xc0913a78 r4 = 0x00000100 r5 = 0x00000001 r6 = 0xc05540f8 r7 = 0xc06789f0 vpanic() at vpanic+0x154 pc = 0xc01e7394 lr = 0xc01e742c (kproc_shutdown) sp = 0xc0913a80 fp = 0xc0913a84 r4 = 0x00000000 r5 = 0x00000001 r6 = 0xc30b6c80 r7 = 0xc30b6c80 r8 = 0xc06f6660 r9 = 0x00000001 r10 = 0xfffffdb0 kproc_shutdown() at kproc_shutdown pc = 0xc01e742c lr = 0xc023e184 (sleepq_timeout) sp = 0xc0913a8c fp = 0xc0913ad8 r4 = 0xc01e742c r5 = 0xc0913a8c sleepq_timeout() at sleepq_timeout pc = 0xc023e184 lr = 0xc01f211c (_sleep+0x320) sp = 0xc0913ae0 fp = 0xc0913b40 r4 = 0x00000001 r5 = 0xc30b6c80 r6 = 0xfffffdb0 r7 = 0xc3070904 r8 = 0xc065f780 r10 = 0x00000001 _sleep() at _sleep+0x320 pc = 0xc01f211c lr = 0xc0502024 (zy7_qspi_transfer+0x17c) sp = 0xc0913b48 fp = 0xc0913b80 r4 = 0xfffffdb0 r5 = 0xc3070900 r6 = 0xc30b6c80 r7 = 0xc3070904 r8 = 0x00000000 r9 = 0xc3070880 r10 = 0xc0913b90 zy7_qspi_transfer() at zy7_qspi_transfer+0x17c pc = 0xc0502024 lr = 0xc009ed70 (mx25l_attach+0xe4) sp = 0xc0913b88 fp = 0xc0913bd8 r4 = 0x00000000 r5 = 0x00000000 r6 = 0xc30b5400 r7 = 0xc30b5380 r8 = 0xc30b5400 r9 = 0xc3070880 r10 = 0xc30b5450 mx25l_attach() at mx25l_attach+0xe4 pc = 0xc009ed70 lr = 0xc0220f8c (device_attach+0x468) sp = 0xc0913be0 fp = 0xc0913c28 r4 = 0xc30b5400 r5 = 0xc30b5380 r6 = 0xc30b5438 r7 = 0x00000000 r8 = 0xc0554c3d r9 = 0xc022506c device_attach() at device_attach+0x468 pc = 0xc0220f8c lr = 0xc0220a88 (device_probe_and_attach+0x8c) sp = 0xc0913c30 fp = 0xc0913c48 r4 = 0xc30b5400 r5 = 0xc2ec6920 r6 = 0x3e0d8f29 r7 = 0xc0913c64 r8 = 0xc2ebe340 r9 = 0x00000000 r10 = 0xc0913c68 device_probe_and_attach() at device_probe_and_attach+0x8c pc = 0xc0220a88 lr = 0xc022231c (bus_generic_attach+0x1c) sp = 0xc0913c50 fp = 0xc0913c58 r4 = 0xc30b5400 r5 = 0x00000000 r6 = 0xc0532cdc r10 = 0xc0913c68 bus_generic_attach() at bus_generic_attach+0x1c pc = 0xc022231c lr = 0xc00c71b4 (ofw_spibus_attach+0x1e4) sp = 0xc0913c60 fp = 0xc0913c88 r4 = 0xc0634708 r10 = 0xc0913c68 ofw_spibus_attach() at ofw_spibus_attach+0x1e4 pc = 0xc00c71b4 lr = 0xc0220f8c (device_attach+0x468) sp = 0xc0913c90 fp = 0xc0913cd8 r4 = 0xc30b5380 r5 = 0xc30b6c80 r6 = 0xc30b53b8 r7 = 0x00000000 r8 = 0xc0554c3d r9 = 0xc022506c r10 = 0xc30b53d0 device_attach() at device_attach+0x468 pc = 0xc0220f8c lr = 0xc0220a88 (device_probe_and_attach+0x8c) sp = 0xc0913ce0 fp = 0xc0913cf8 r4 = 0xc30b5380 r5 = 0xc2ec6920 r6 = 0x3e0d8f29 r7 = 0xc3070900 r8 = 0xc30b6cd0 r9 = 0xc01f4fb4 r10 = 0xc30b6c80 device_probe_and_attach() at device_probe_and_attach+0x8c pc = 0xc0220a88 lr = 0xc022231c (bus_generic_attach+0x1c) sp = 0xc0913d00 fp = 0xc0913d08 r4 = 0xc30b5380 r5 = 0x00000000 r6 = 0xd2b789c0 r10 = 0xc30b6c80 bus_generic_attach() at bus_generic_attach+0x1c pc = 0xc022231c lr = 0xc0501cb8 (zy7_qspi_attach+0x440) sp = 0xc0913d10 fp = 0xc0913d58 r4 = 0xc051fe8f r10 = 0xc30b6c80 zy7_qspi_attach() at zy7_qspi_attach+0x440 pc = 0xc0501cb8 lr = 0xc0220f8c (device_attach+0x468) sp = 0xc0913d60 fp = 0xc0913da8 r4 = 0xc30b6c80 r5 = 0xc30b7680 r6 = 0xc30b6cb8 r7 = 0x00000000 r8 = 0xc0554c3d r9 = 0xc022506c r10 = 0xc30b6cd0 device_attach() at device_attach+0x468 pc = 0xc0220f8c lr = 0xc0220a88 (device_probe_and_attach+0x8c) sp = 0xc0913db0 fp = 0xc0913dc8 r4 = 0xc30b6c80 r5 = 0xc2ec6920 r6 = 0x3e0d8f29 r7 = 0x00000000 r8 = 0xc0688af4 r9 = 0xc06f744c r10 = 0xc06f6a28 device_probe_and_attach() at device_probe_and_attach+0x8c pc = 0xc0220a88 lr = 0xc0222940 (bus_generic_new_pass+0xe8) sp = 0xc0913dd0 fp = 0xc0913de8 r4 = 0xc30b6c80 r5 = 0xc062b0b4 r6 = 0xc0659b3c r10 = 0xc06f6a28 bus_generic_new_pass() at bus_generic_new_pass+0xe8 pc = 0xc0222940 lr = 0xc0222930 (bus_generic_new_pass+0xd8) sp = 0xc0913df0 fp = 0xc0913e08 r4 = 0xc30b7680 r5 = 0xc062b0b4 r6 = 0xc062182c r7 = 0x00000000 r8 = 0xc0688af4 r10 = 0xc06f6a28 bus_generic_new_pass() at bus_generic_new_pass+0xd8 pc = 0xc0222930 lr = 0xc0222930 (bus_generic_new_pass+0xd8) sp = 0xc0913e10 fp = 0xc0913e28 r4 = 0xc30b7780 r5 = 0xc062b0b4 r6 = 0xc0650600 r7 = 0x00000000 r8 = 0xc0688af4 r10 = 0xc06f6a28 bus_generic_new_pass() at bus_generic_new_pass+0xd8 pc = 0xc0222930 lr = 0xc0222930 (bus_generic_new_pass+0xd8) sp = 0xc0913e30 fp = 0xc0913e48 r4 = 0xc30b7900 r5 = 0xc062b0b4 r6 = 0xc30b7b00 r7 = 0x00000000 r8 = 0xc0688af4 r10 = 0xc06f6a28 bus_generic_new_pass() at bus_generic_new_pass+0xd8 pc = 0xc0222930 lr = 0xc021e568 (bus_set_pass+0x94) sp = 0xc0913e50 fp = 0xc0913e68 r4 = 0xc2ec6680 r5 = 0xc062b0b4 r6 = 0xc30b7b00 r7 = 0xc0688af4 r8 = 0x7fffffff r10 = 0xc06f6a28 bus_set_pass() at bus_set_pass+0x94 pc = 0xc021e568 lr = 0xc01847e0 (mi_startup+0x18c) sp = 0xc0913e70 fp = 0xc0913e90 r4 = 0xc06f6b24 r5 = 0x00000001 r6 = 0xc058b084 r7 = 0x00000000 r8 = 0xc06f6b20 r9 = 0xc058bb48 mi_startup() at mi_startup+0x18c pc = 0xc01847e0 lr = 0xc00002c4 (_start+0x144) sp = 0xc0913e98 fp = 0x00000000 r4 = 0xc00003f8 r5 = 0xc0710000 r6 = 0x01059480 r7 = 0x00c52078 r8 = 0xc0823000 r9 = 0x0000000a r10 = 0x0000000a _start() at _start+0x144 pc = 0xc00002c4 lr = 0xc00002c4 (_start+0x144) sp = 0xc0913e98 fp = 0x00000000 KDB: enter: panic [ thread pid 0 tid 100000 ] Stopped at $d.3: ldrb r15, [r15, r15, ror r15]! db> --Apple-Mail=_5921723D-9B2B-449D-91BA-7076B225BE32--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?838BFE5B-61CD-4EC4-BB4F-8124B5B3AF9F>