All of lore.kernel.org
 help / color / mirror / Atom feed
* spinlock bad magic on SiFive uart driver
@ 2020-04-26  6:40 Atish Patra
  2020-05-04 20:31 ` Palmer Dabbelt
  0 siblings, 1 reply; 5+ messages in thread
From: Atish Patra @ 2020-04-26  6:40 UTC (permalink / raw)
  To: linux-riscv; +Cc: paul.walmsley

Hi,
I am seeing following spinlock bad magic error with 5.7-rc1+ kernels
on HiFive Unleashed board. But it continues to boot without any other
issue.

Here is the relevant boot log:
-----------------------------------------------------------------------
[    0.346494] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.353268] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 1,
base_baud = 0) is a SiFive UART v0
[    0.361720] BUG: spinlock bad magic on CPU#1, swapper/0/1
[    0.367179]  lock: 0xffffffe1f6f56018, .magic: 00000000, .owner:
<none>/-1, .owner_cpu: 0
[    0.375425] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.7.0-rc2-
00004-g47dfd752cad3 #142
[    0.383580] Call Trace:
[    0.386109] [<ffffffe0002024c6>] walk_stackframe+0x0/0xa4
[    0.391572] [<ffffffe0002026ac>] show_stack+0x2a/0x34
[    0.396703] [<ffffffe00046a09e>] dump_stack+0x6a/0x84
[    0.401818] [<ffffffe00024306a>] spin_dump+0x68/0x74
[    0.406853] [<ffffffe000242c8a>] do_raw_spin_lock+0xb0/0xcc
[    0.412499] [<ffffffe000841700>] _raw_spin_lock_irqsave+0x20/0x2c
[    0.418664] [<ffffffe0004d9c0c>] uart_add_one_port+0x2f6/0x406
[    0.424567] [<ffffffe0004e3a94>] sifive_serial_probe+0x184/0x270
[    0.430644] [<ffffffe00061337c>] platform_drv_probe+0x32/0x5e
[    0.436465] [<ffffffe000611b6e>] really_probe+0x9a/0x21e
[    0.441843] [<ffffffe000611df4>] driver_probe_device+0x2e/0x88
[    0.447747] [<ffffffe000611fc6>] device_driver_attach+0x4c/0x50
[    0.453738] [<ffffffe000612004>] __driver_attach+0x3a/0xac
[    0.459294] [<ffffffe00061016a>] bus_for_each_dev+0x4a/0x72
[    0.464937] [<ffffffe00061167a>] driver_attach+0x1a/0x22
[    0.470320] [<ffffffe0006111ac>] bus_add_driver+0x192/0x198
[    0.475964] [<ffffffe0006124f2>] driver_register+0x3a/0xd0
[    0.481520] [<ffffffe000613342>]
__platform_driver_register+0x3a/0x42
[    0.488035] [<ffffffe00001ff70>] sifive_serial_init+0x30/0x50
[    0.493856] [<ffffffe0002000d0>] do_one_initcall+0x50/0x15a
[    0.499494] [<ffffffe000002c80>] kernel_init_freeable+0x16a/0x1de
[    0.505662] [<ffffffe00083cd5c>] kernel_init+0x12/0x118
[    0.510955] [<ffffffe00020120a>] ret_from_exception+0x0/0xc
[    0.516647] printk: console [ttySIF0] enabled
[    0.516647] printk: console [ttySIF0] enabled
[    0.525382] printk: bootconsole [sbi0] disabled
[    0.525382] printk: bootconsole [sbi0] disabled
[    0.534799] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 2,
base_baud = 0) is a SiFive UART v0
-----------------------------------------------------------------------

I have not debugged further. Just wanted to check if anybody else also
has seen this error.

-- 
Regards,
Atish

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: spinlock bad magic on SiFive uart driver
  2020-04-26  6:40 spinlock bad magic on SiFive uart driver Atish Patra
@ 2020-05-04 20:31 ` Palmer Dabbelt
  2020-05-05 11:09   ` Sagar Kadam
  0 siblings, 1 reply; 5+ messages in thread
From: Palmer Dabbelt @ 2020-05-04 20:31 UTC (permalink / raw)
  To: Atish Patra; +Cc: linux-riscv, Paul Walmsley

On Sat, 25 Apr 2020 23:40:58 PDT (-0700), Atish Patra wrote:
> Hi,
> I am seeing following spinlock bad magic error with 5.7-rc1+ kernels
> on HiFive Unleashed board. But it continues to boot without any other
> issue.
> 
> Here is the relevant boot log:
> -----------------------------------------------------------------------
> [    0.346494] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
> [    0.353268] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 1,
> base_baud = 0) is a SiFive UART v0
> [    0.361720] BUG: spinlock bad magic on CPU#1, swapper/0/1
> [    0.367179]  lock: 0xffffffe1f6f56018, .magic: 00000000, .owner:
> <none>/-1, .owner_cpu: 0
> [    0.375425] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.7.0-rc2-
> 00004-g47dfd752cad3 #142
> [    0.383580] Call Trace:
> [    0.386109] [<ffffffe0002024c6>] walk_stackframe+0x0/0xa4
> [    0.391572] [<ffffffe0002026ac>] show_stack+0x2a/0x34
> [    0.396703] [<ffffffe00046a09e>] dump_stack+0x6a/0x84
> [    0.401818] [<ffffffe00024306a>] spin_dump+0x68/0x74
> [    0.406853] [<ffffffe000242c8a>] do_raw_spin_lock+0xb0/0xcc
> [    0.412499] [<ffffffe000841700>] _raw_spin_lock_irqsave+0x20/0x2c
> [    0.418664] [<ffffffe0004d9c0c>] uart_add_one_port+0x2f6/0x406
> [    0.424567] [<ffffffe0004e3a94>] sifive_serial_probe+0x184/0x270
> [    0.430644] [<ffffffe00061337c>] platform_drv_probe+0x32/0x5e
> [    0.436465] [<ffffffe000611b6e>] really_probe+0x9a/0x21e
> [    0.441843] [<ffffffe000611df4>] driver_probe_device+0x2e/0x88
> [    0.447747] [<ffffffe000611fc6>] device_driver_attach+0x4c/0x50
> [    0.453738] [<ffffffe000612004>] __driver_attach+0x3a/0xac
> [    0.459294] [<ffffffe00061016a>] bus_for_each_dev+0x4a/0x72
> [    0.464937] [<ffffffe00061167a>] driver_attach+0x1a/0x22
> [    0.470320] [<ffffffe0006111ac>] bus_add_driver+0x192/0x198
> [    0.475964] [<ffffffe0006124f2>] driver_register+0x3a/0xd0
> [    0.481520] [<ffffffe000613342>]
> __platform_driver_register+0x3a/0x42
> [    0.488035] [<ffffffe00001ff70>] sifive_serial_init+0x30/0x50
> [    0.493856] [<ffffffe0002000d0>] do_one_initcall+0x50/0x15a
> [    0.499494] [<ffffffe000002c80>] kernel_init_freeable+0x16a/0x1de
> [    0.505662] [<ffffffe00083cd5c>] kernel_init+0x12/0x118
> [    0.510955] [<ffffffe00020120a>] ret_from_exception+0x0/0xc
> [    0.516647] printk: console [ttySIF0] enabled
> [    0.516647] printk: console [ttySIF0] enabled
> [    0.525382] printk: bootconsole [sbi0] disabled
> [    0.525382] printk: bootconsole [sbi0] disabled
> [    0.534799] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 2,
> base_baud = 0) is a SiFive UART v0
> -----------------------------------------------------------------------
> 
> I have not debugged further. Just wanted to check if anybody else also
> has seen this error.

Any news?  I don't have a HiFive Unleashed so I don't test on it, but I'm going
to go try and run with a SiFive UART in QEMU now...


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: spinlock bad magic on SiFive uart driver
  2020-05-04 20:31 ` Palmer Dabbelt
@ 2020-05-05 11:09   ` Sagar Kadam
  2020-05-05 12:00     ` Anup Patel
  0 siblings, 1 reply; 5+ messages in thread
From: Sagar Kadam @ 2020-05-05 11:09 UTC (permalink / raw)
  To: Palmer Dabbelt, Atish Patra; +Cc: linux-riscv, Paul Walmsley

Hello Atish,

> -----Original Message-----
> From: linux-riscv <linux-riscv-bounces@lists.infradead.org> On Behalf Of
> Palmer Dabbelt
> Sent: Tuesday, May 5, 2020 2:02 AM
> To: Atish Patra <Atish.Patra@wdc.com>
> Cc: linux-riscv@lists.infradead.org; Paul Walmsley
> <paul.walmsley@sifive.com>
> Subject: Re: spinlock bad magic on SiFive uart driver
> 
> [External Email] Do not click links or attachments unless you recognize the
> sender and know the content is safe
> 
> On Sat, 25 Apr 2020 23:40:58 PDT (-0700), Atish Patra wrote:
> > Hi,
> > I am seeing following spinlock bad magic error with 5.7-rc1+ kernels
> > on HiFive Unleashed board. But it continues to boot without any other
> > issue.
> >
> > Here is the relevant boot log:
> > -----------------------------------------------------------------------
> > [    0.346494] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
> > [    0.353268] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 1,
> > base_baud = 0) is a SiFive UART v0
> > [    0.361720] BUG: spinlock bad magic on CPU#1, swapper/0/1
> > [    0.367179]  lock: 0xffffffe1f6f56018, .magic: 00000000, .owner:
> > <none>/-1, .owner_cpu: 0
> > [    0.375425] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.7.0-rc2-
> > 00004-g47dfd752cad3 #142
> > [    0.383580] Call Trace:
> > [    0.386109] [<ffffffe0002024c6>] walk_stackframe+0x0/0xa4
> > [    0.391572] [<ffffffe0002026ac>] show_stack+0x2a/0x34
> > [    0.396703] [<ffffffe00046a09e>] dump_stack+0x6a/0x84
> > [    0.401818] [<ffffffe00024306a>] spin_dump+0x68/0x74
> > [    0.406853] [<ffffffe000242c8a>] do_raw_spin_lock+0xb0/0xcc
> > [    0.412499] [<ffffffe000841700>] _raw_spin_lock_irqsave+0x20/0x2c
> > [    0.418664] [<ffffffe0004d9c0c>] uart_add_one_port+0x2f6/0x406
> > [    0.424567] [<ffffffe0004e3a94>] sifive_serial_probe+0x184/0x270
> > [    0.430644] [<ffffffe00061337c>] platform_drv_probe+0x32/0x5e
> > [    0.436465] [<ffffffe000611b6e>] really_probe+0x9a/0x21e
> > [    0.441843] [<ffffffe000611df4>] driver_probe_device+0x2e/0x88
> > [    0.447747] [<ffffffe000611fc6>] device_driver_attach+0x4c/0x50
> > [    0.453738] [<ffffffe000612004>] __driver_attach+0x3a/0xac
> > [    0.459294] [<ffffffe00061016a>] bus_for_each_dev+0x4a/0x72
> > [    0.464937] [<ffffffe00061167a>] driver_attach+0x1a/0x22
> > [    0.470320] [<ffffffe0006111ac>] bus_add_driver+0x192/0x198
> > [    0.475964] [<ffffffe0006124f2>] driver_register+0x3a/0xd0
> > [    0.481520] [<ffffffe000613342>]
> > __platform_driver_register+0x3a/0x42
> > [    0.488035] [<ffffffe00001ff70>] sifive_serial_init+0x30/0x50
> > [    0.493856] [<ffffffe0002000d0>] do_one_initcall+0x50/0x15a
> > [    0.499494] [<ffffffe000002c80>] kernel_init_freeable+0x16a/0x1de
> > [    0.505662] [<ffffffe00083cd5c>] kernel_init+0x12/0x118
> > [    0.510955] [<ffffffe00020120a>] ret_from_exception+0x0/0xc
> > [    0.516647] printk: console [ttySIF0] enabled
> > [    0.516647] printk: console [ttySIF0] enabled
> > [    0.525382] printk: bootconsole [sbi0] disabled
> > [    0.525382] printk: bootconsole [sbi0] disabled
> > [    0.534799] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 2,
> > base_baud = 0) is a SiFive UART v0
> > -----------------------------------------------------------------------
> >
> > I have not debugged further. Just wanted to check if anybody else also
> > has seen this error.
> 
> Any news?  I don't have a HiFive Unleashed so I don't test on it, but I'm
> going
> to go try and run with a SiFive UART in QEMU now...

I could reproduce it with OpenSBI v0.7 and as below:

OpenSBI v0.7-31-gd626037
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name          : SiFive Freedom U540
Platform HART Features : RV64ACDFIMSU
Platform HART Count    : 4
Current HART ID        : 1
Firmware Base          : 0x80000000
Firmware Size          : 100 KB
Runtime SBI Version    : 0.2

MIDELEG : 0x0000000000000222
MEDELEG : 0x000000000000b109
PMP0    : 0x0000000080000000-0x000000008001ffff (A)
PMP1    : 0x0000000000000000-0x0000007fffffffff (A,R,W,X)


U-Boot 2020.07-rc1-00201-g24e3f96 (May 04 2020 - 12:25:18 -0700)

CPU:   rv64imafdc
Model: SiFive HiFive Unleashed A00
DRAM:  8 GiB
MMC:   spi@10050000:mmc@0: 0
In:    serial@10010000
Out:   serial@10010000
Err:   serial@10010000
Net:   eth0: ethernet@10090000
Hit any key to stop autoboot:  0
=> setenv bootargs "root=/dev/ram rw console=ttySIF0 earlycon=sbi"
=> mmc rescan ; fatload mmc 0:2 0x80200000 uImage ; fatload mmc 0:2 0x82200000 hifive-unleashed-a00.dtb ; bootm 0x80200000 - 0x82200000
Starting kernel ...

[    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[    0.000000] Linux version 5.7.0-rc3-00001-ga4bf42d-dirty (sagark2@sifive.com) (gcc version 8.2.0 (Buildroot 2018.11-rc2-00003-ga0787e9), GNU ld (GNU Binutils) 2.31.1) #3 SMP Tue May 5 03:17:50 PDT 2020
[    0.000000] earlycon: sbi0 at I/O port 0x0 (options '')
[    0.000000] printk: bootconsole [sbi0] enabled
[    0.000000] initrd not found or empty - disabling initrd
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000080200000-0x00000000ffffffff]
[    0.000000]   Normal   [mem 0x0000000100000000-0x000000027fffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080200000-0x000000027fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x000000027fffffff]
[    0.000000] software IO TLB: mapped [mem 0xfbfff000-0xfffff000] (64MB)
[    0.000000] SBI specification v0.2 detected
[    0.000000] SBI implementation ID=0x1 Version=0x7
[    0.000000] SBI v0.2 TIME extension detected
[    0.000000] SBI v0.2 IPI extension detected
[    0.000000] SBI v0.2 RFENCE extension detected
[    0.000000] SBI v0.2 HSM extension detected
[    0.000000] CPU with hartid=0 is not available
[    0.000000] CPU with hartid=0 is not available
[    0.000000] elf_hwcap is 0x112d
[    0.000000] percpu: Embedded 17 pages/cpu s31976 r8192 d29464 u69632
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 2067975
[    0.000000] Kernel command line: root=/dev/ram rw console=ttySIF0 earlycon=sbi
[    0.000000] Dentry cache hash table entries: 1048576 (order: 11, 8388608 bytes, linear)
[    0.000000] Inode-cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[    0.000000] Sorting __ex_table...
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 8172076K/8386560K available (6451K kernel code, 4222K rwdata, 4096K rodata, 4603K init, 317K bss, 214484K reserved, 0K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.000000]       fixmap : 0xffffffcefee00000 - 0xffffffceff000000   (2048 kB)
[    0.000000]       pci io : 0xffffffceff000000 - 0xffffffcf00000000   (  16 MB)
[    0.000000]      vmemmap : 0xffffffcf00000000 - 0xffffffcfffffffff   (4095 MB)
[    0.000000]      vmalloc : 0xffffffd000000000 - 0xffffffdfffffffff   (65535 MB)
[    0.000000]       lowmem : 0xffffffe000000000 - 0xffffffe1ffe00000   (8190 MB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
[    0.000000] rcu:     RCU debug extended QS entry/exit.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[    0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
[    0.000000] plic: mapped 53 interrupts with 4 handlers for 9 contexts.
[    0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [1]
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 3526361616960 ns
[    0.000006] sched_clock: 64 bits at 1000kHz, resolution 1000ns, wraps every 2199023255500ns
[    0.008563] Console: colour dummy device 80x25
[    0.012994] Calibrating delay loop (skipped), value calculated using timer frequency.. 2.00 BogoMIPS (lpj=4000)
[    0.023104] pid_max: default: 32768 minimum: 301
[    0.028306] Mount-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.035767] Mountpoint-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.045470] rcu: Hierarchical SRCU implementation.
[    0.050234] smp: Bringing up secondary CPUs ...
[    0.056201] smp: Brought up 1 node, 4 CPUs
[    0.060963] devtmpfs: initialized
[    0.065532] random: get_random_u32 called from bucket_table_alloc.isra.25+0x4e/0x160 with crng_init=0
[    0.065924] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.084277] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
[    0.091975] NET: Registered protocol family 16
[    0.112804] vgaarb: loaded
[    0.115183] SCSI subsystem initialized
[    0.119121] usbcore: registered new interface driver usbfs
[    0.124262] usbcore: registered new interface driver hub
[    0.129672] usbcore: registered new device driver usb
[    0.135731] clocksource: Switched to clocksource riscv_clocksource
[    0.148925] NET: Registered protocol family 2
[    0.153254] tcp_listen_portaddr_hash hash table entries: 4096 (order: 5, 163840 bytes, linear)
[    0.161852] TCP established hash table entries: 65536 (order: 7, 524288 bytes, linear)
[    0.171366] TCP bind hash table entries: 65536 (order: 9, 2097152 bytes, linear)
[    0.185351] TCP: Hash tables configured (established 65536 bind 65536)
[    0.191718] UDP hash table entries: 4096 (order: 6, 393216 bytes, linear)
[    0.199390] UDP-Lite hash table entries: 4096 (order: 6, 393216 bytes, linear)
[    0.207489] NET: Registered protocol family 1
[    0.211831] RPC: Registered named UNIX socket transport module.
[    0.217163] RPC: Registered udp transport module.
[    0.221936] RPC: Registered tcp transport module.
[    0.226703] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.233226] PCI: CLS 0 bytes, default 64
[    0.584632] workingset: timestamp_bits=62 max_order=21 bucket_order=0
[    0.599792] NFS: Registering the id_resolver key type
[    0.604240] Key type id_resolver registered
[    0.608415] Key type id_legacy registered
[    0.612508] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.619415] 9p: Installing v9fs 9p2000 file system support
[    0.625234] NET: Registered protocol family 38
[    0.629383] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[    0.636814] io scheduler mq-deadline registered
[    0.641408] io scheduler kyber registered
[    0.696163] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.702957] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 1, base_baud = 0) is a SiFive UART v0
[    0.711414] BUG: spinlock bad magic on CPU#1, swapper/0/1
[    0.716867]  lock: 0xffffffe1f6372018, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0
[    0.725113] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.7.0-rc3-00001-ga4bf42d-dirty #3
[    0.733182] Call Trace:
[    0.735711] [<ffffffe0006024c6>] walk_stackframe+0x0/0xa4
[    0.741174] [<ffffffe0006026ac>] show_stack+0x2a/0x34
[    0.746304] [<ffffffe000869ea0>] dump_stack+0x6a/0x84
[    0.751427] [<ffffffe000643074>] spin_dump+0x68/0x74
[    0.756456] [<ffffffe000642c94>] do_raw_spin_lock+0xb0/0xcc
[    0.762107] [<ffffffe000c4b520>] _raw_spin_lock_irqsave+0x20/0x2c
[    0.768264] [<ffffffe0008d9a24>] uart_add_one_port+0x2f6/0x406
[    0.774167] [<ffffffe0008e38ac>] sifive_serial_probe+0x184/0x270
[    0.780253] [<ffffffe000a13166>] platform_drv_probe+0x32/0x5e
[    0.786062] [<ffffffe000a11958>] really_probe+0x9a/0x21e
[    0.791445] [<ffffffe000a11bde>] driver_probe_device+0x2e/0x88
[    0.797349] [<ffffffe000a11db0>] device_driver_attach+0x4c/0x50
[    0.803339] [<ffffffe000a11dee>] __driver_attach+0x3a/0xac
[    0.808896] [<ffffffe000a0ff54>] bus_for_each_dev+0x4a/0x72
[    0.814539] [<ffffffe000a11464>] driver_attach+0x1a/0x22
[    0.819922] [<ffffffe000a10f96>] bus_add_driver+0x192/0x198
[    0.825566] [<ffffffe000a122dc>] driver_register+0x3a/0xd0
[    0.831123] [<ffffffe000a1312c>] __platform_driver_register+0x3a/0x42
[    0.837637] [<ffffffe0000174c2>] sifive_serial_init+0x30/0x50
[    0.843457] [<ffffffe0006000d0>] do_one_initcall+0x50/0x15a
[    0.849095] [<ffffffe000001c80>] kernel_init_freeable+0x16a/0x1de
[    0.855259] [<ffffffe000c46d32>] kernel_init+0x12/0x118
[    0.860557] [<ffffffe00060120a>] ret_from_exception+0x0/0xc
[    0.866240] printk: console [ttySIF0] enabled
[    0.866240] printk: console [ttySIF0] enabled
[    0.874992] printk: bootconsole [sbi0] disabled
[    0.874992] printk: bootconsole [sbi0] disabled
[    0.884404] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 10, base_baud = 0) is a SiFive UART v0
[    0.893847] [drm] radeon kernel modesetting enabled.

I think the issue might be due to uninitialized spin_lock of ssp (sifive_serial_port).
So adding a spin_lock_init resolve's this. Please let me know your views here.

diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c
index 13eadcb..607d188 100644
--- a/drivers/tty/serial/sifive.c
+++ b/drivers/tty/serial/sifive.c
@@ -989,6 +989,8 @@ static int sifive_serial_probe(struct platform_device *pdev)
        ssp->clk = clk;
        ssp->clk_notifier.notifier_call = sifive_serial_clk_notifier;
 
+       spin_lock_init(&ssp->port.lock);
+
        r = clk_notifier_register(ssp->clk, &ssp->clk_notifier);
        if (r) {
                dev_err(&pdev->dev, "could not register clock notifier: %d\n",


With this I didn’t encounter the spinlock bug we are discussing, following is the relevant log
post the patch:

[    0.637824] io scheduler mq-deadline registered
[    0.642419] io scheduler kyber registered
[    0.696561] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.703359] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 1, base_baud = 0) is a SiFive UART v0
[    0.711834] printk: console [ttySIF0] enabled
[    0.711834] printk: console [ttySIF0] enabled
[    0.720583] printk: bootconsole [sbi0] disabled
[    0.720583] printk: bootconsole [sbi0] disabled
[    0.729998] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 10, base_baud = 0) is a SiFive UART v0
[    0.739449] [drm] radeon kernel modesetting enabled.

# cat /proc/cmdline
root=/dev/ram rw console=ttySIF0 earlycon=sbi
# uname -a
Linux buildroot 5.7.0-rc3-00001-ga4bf42d-dirty #5 SMP Tue May 5 03:32:47 PDT 2020 riscv64 GNU/Linux
#

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: spinlock bad magic on SiFive uart driver
  2020-05-05 11:09   ` Sagar Kadam
@ 2020-05-05 12:00     ` Anup Patel
  2020-05-05 12:04       ` Sagar Kadam
  0 siblings, 1 reply; 5+ messages in thread
From: Anup Patel @ 2020-05-05 12:00 UTC (permalink / raw)
  To: Sagar Kadam, Palmer Dabbelt, Atish Patra; +Cc: linux-riscv, Paul Walmsley

Hi Sagar,

> -----Original Message-----
> From: linux-riscv <linux-riscv-bounces@lists.infradead.org> On Behalf Of
> Sagar Kadam
> Sent: 05 May 2020 16:40
> To: Palmer Dabbelt <palmer@dabbelt.com>; Atish Patra
> <Atish.Patra@wdc.com>
> Cc: linux-riscv@lists.infradead.org; Paul Walmsley
> <paul.walmsley@sifive.com>
> Subject: RE: spinlock bad magic on SiFive uart driver
> 
> Hello Atish,
> 
> > -----Original Message-----
> > From: linux-riscv <linux-riscv-bounces@lists.infradead.org> On Behalf
> > Of Palmer Dabbelt
> > Sent: Tuesday, May 5, 2020 2:02 AM
> > To: Atish Patra <Atish.Patra@wdc.com>
> > Cc: linux-riscv@lists.infradead.org; Paul Walmsley
> > <paul.walmsley@sifive.com>
> > Subject: Re: spinlock bad magic on SiFive uart driver
> >
> > [External Email] Do not click links or attachments unless you
> > recognize the sender and know the content is safe
> >
> > On Sat, 25 Apr 2020 23:40:58 PDT (-0700), Atish Patra wrote:
> > > Hi,
> > > I am seeing following spinlock bad magic error with 5.7-rc1+ kernels
> > > on HiFive Unleashed board. But it continues to boot without any
> > > other issue.
> > >
> > > Here is the relevant boot log:
> > > -----------------------------------------------------------------------
> > > [    0.346494] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
> > > [    0.353268] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 1,
> > > base_baud = 0) is a SiFive UART v0
> > > [    0.361720] BUG: spinlock bad magic on CPU#1, swapper/0/1
> > > [    0.367179]  lock: 0xffffffe1f6f56018, .magic: 00000000, .owner:
> > > <none>/-1, .owner_cpu: 0
> > > [    0.375425] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.7.0-rc2-
> > > 00004-g47dfd752cad3 #142
> > > [    0.383580] Call Trace:
> > > [    0.386109] [<ffffffe0002024c6>] walk_stackframe+0x0/0xa4
> > > [    0.391572] [<ffffffe0002026ac>] show_stack+0x2a/0x34
> > > [    0.396703] [<ffffffe00046a09e>] dump_stack+0x6a/0x84
> > > [    0.401818] [<ffffffe00024306a>] spin_dump+0x68/0x74
> > > [    0.406853] [<ffffffe000242c8a>] do_raw_spin_lock+0xb0/0xcc
> > > [    0.412499] [<ffffffe000841700>] _raw_spin_lock_irqsave+0x20/0x2c
> > > [    0.418664] [<ffffffe0004d9c0c>] uart_add_one_port+0x2f6/0x406
> > > [    0.424567] [<ffffffe0004e3a94>] sifive_serial_probe+0x184/0x270
> > > [    0.430644] [<ffffffe00061337c>] platform_drv_probe+0x32/0x5e
> > > [    0.436465] [<ffffffe000611b6e>] really_probe+0x9a/0x21e
> > > [    0.441843] [<ffffffe000611df4>] driver_probe_device+0x2e/0x88
> > > [    0.447747] [<ffffffe000611fc6>] device_driver_attach+0x4c/0x50
> > > [    0.453738] [<ffffffe000612004>] __driver_attach+0x3a/0xac
> > > [    0.459294] [<ffffffe00061016a>] bus_for_each_dev+0x4a/0x72
> > > [    0.464937] [<ffffffe00061167a>] driver_attach+0x1a/0x22
> > > [    0.470320] [<ffffffe0006111ac>] bus_add_driver+0x192/0x198
> > > [    0.475964] [<ffffffe0006124f2>] driver_register+0x3a/0xd0
> > > [    0.481520] [<ffffffe000613342>]
> > > __platform_driver_register+0x3a/0x42
> > > [    0.488035] [<ffffffe00001ff70>] sifive_serial_init+0x30/0x50
> > > [    0.493856] [<ffffffe0002000d0>] do_one_initcall+0x50/0x15a
> > > [    0.499494] [<ffffffe000002c80>] kernel_init_freeable+0x16a/0x1de
> > > [    0.505662] [<ffffffe00083cd5c>] kernel_init+0x12/0x118
> > > [    0.510955] [<ffffffe00020120a>] ret_from_exception+0x0/0xc
> > > [    0.516647] printk: console [ttySIF0] enabled
> > > [    0.516647] printk: console [ttySIF0] enabled
> > > [    0.525382] printk: bootconsole [sbi0] disabled
> > > [    0.525382] printk: bootconsole [sbi0] disabled
> > > [    0.534799] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 2,
> > > base_baud = 0) is a SiFive UART v0
> > > --------------------------------------------------------------------
> > > ---
> > >
> > > I have not debugged further. Just wanted to check if anybody else
> > > also has seen this error.
> >
> > Any news?  I don't have a HiFive Unleashed so I don't test on it, but
> > I'm going to go try and run with a SiFive UART in QEMU now...
> 
> I could reproduce it with OpenSBI v0.7 and as below:
> 
> OpenSBI v0.7-31-gd626037
>    ____                    _____ ____ _____
>   / __ \                  / ____|  _ \_   _|
>  | |  | |_ __   ___ _ __ | (___ | |_) || |
>  | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |  | |__| | |_) |  __/ | | |____) | |_) || |_
>   \____/| .__/ \___|_| |_|_____/|____/_____|
>         | |
>         |_|
> 
> Platform Name          : SiFive Freedom U540
> Platform HART Features : RV64ACDFIMSU
> Platform HART Count    : 4
> Current HART ID        : 1
> Firmware Base          : 0x80000000
> Firmware Size          : 100 KB
> Runtime SBI Version    : 0.2
> 
> MIDELEG : 0x0000000000000222
> MEDELEG : 0x000000000000b109
> PMP0    : 0x0000000080000000-0x000000008001ffff (A)
> PMP1    : 0x0000000000000000-0x0000007fffffffff (A,R,W,X)
> 
> 
> U-Boot 2020.07-rc1-00201-g24e3f96 (May 04 2020 - 12:25:18 -0700)
> 
> CPU:   rv64imafdc
> Model: SiFive HiFive Unleashed A00
> DRAM:  8 GiB
> MMC:   spi@10050000:mmc@0: 0
> In:    serial@10010000
> Out:   serial@10010000
> Err:   serial@10010000
> Net:   eth0: ethernet@10090000
> Hit any key to stop autoboot:  0
> => setenv bootargs "root=/dev/ram rw console=ttySIF0 earlycon=sbi"
> => mmc rescan ; fatload mmc 0:2 0x80200000 uImage ; fatload mmc 0:2
> 0x82200000 hifive-unleashed-a00.dtb ; bootm 0x80200000 - 0x82200000
> Starting kernel ...
> 
> [    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
> [    0.000000] Linux version 5.7.0-rc3-00001-ga4bf42d-dirty
> (sagark2@sifive.com) (gcc version 8.2.0 (Buildroot 2018.11-rc2-00003-
> ga0787e9), GNU ld (GNU Binutils) 2.31.1) #3 SMP Tue May 5 03:17:50 PDT
> 2020
> [    0.000000] earlycon: sbi0 at I/O port 0x0 (options '')
> [    0.000000] printk: bootconsole [sbi0] enabled
> [    0.000000] initrd not found or empty - disabling initrd
> [    0.000000] Zone ranges:
> [    0.000000]   DMA32    [mem 0x0000000080200000-0x00000000ffffffff]
> [    0.000000]   Normal   [mem 0x0000000100000000-0x000000027fffffff]
> [    0.000000] Movable zone start for each node
> [    0.000000] Early memory node ranges
> [    0.000000]   node   0: [mem 0x0000000080200000-0x000000027fffffff]
> [    0.000000] Initmem setup node 0 [mem 0x0000000080200000-
> 0x000000027fffffff]
> [    0.000000] software IO TLB: mapped [mem 0xfbfff000-0xfffff000] (64MB)
> [    0.000000] SBI specification v0.2 detected
> [    0.000000] SBI implementation ID=0x1 Version=0x7
> [    0.000000] SBI v0.2 TIME extension detected
> [    0.000000] SBI v0.2 IPI extension detected
> [    0.000000] SBI v0.2 RFENCE extension detected
> [    0.000000] SBI v0.2 HSM extension detected
> [    0.000000] CPU with hartid=0 is not available
> [    0.000000] CPU with hartid=0 is not available
> [    0.000000] elf_hwcap is 0x112d
> [    0.000000] percpu: Embedded 17 pages/cpu s31976 r8192 d29464 u69632
> [    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 2067975
> [    0.000000] Kernel command line: root=/dev/ram rw console=ttySIF0
> earlycon=sbi
> [    0.000000] Dentry cache hash table entries: 1048576 (order: 11, 8388608
> bytes, linear)
> [    0.000000] Inode-cache hash table entries: 524288 (order: 10, 4194304
> bytes, linear)
> [    0.000000] Sorting __ex_table...
> [    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
> [    0.000000] Memory: 8172076K/8386560K available (6451K kernel code,
> 4222K rwdata, 4096K rodata, 4603K init, 317K bss, 214484K reserved, 0K cma-
> reserved)
> [    0.000000] Virtual kernel memory layout:
> [    0.000000]       fixmap : 0xffffffcefee00000 - 0xffffffceff000000   (2048 kB)
> [    0.000000]       pci io : 0xffffffceff000000 - 0xffffffcf00000000   (  16 MB)
> [    0.000000]      vmemmap : 0xffffffcf00000000 - 0xffffffcfffffffff   (4095 MB)
> [    0.000000]      vmalloc : 0xffffffd000000000 - 0xffffffdfffffffff   (65535 MB)
> [    0.000000]       lowmem : 0xffffffe000000000 - 0xffffffe1ffe00000   (8190 MB)
> [    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
> [    0.000000] rcu: Hierarchical RCU implementation.
> [    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
> [    0.000000] rcu:     RCU debug extended QS entry/exit.
> [    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25
> jiffies.
> [    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
> [    0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
> [    0.000000] plic: mapped 53 interrupts with 4 handlers for 9 contexts.
> [    0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [1]
> [    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff
> max_cycles: 0x1d854df40, max_idle_ns: 3526361616960 ns
> [    0.000006] sched_clock: 64 bits at 1000kHz, resolution 1000ns, wraps every
> 2199023255500ns
> [    0.008563] Console: colour dummy device 80x25
> [    0.012994] Calibrating delay loop (skipped), value calculated using timer
> frequency.. 2.00 BogoMIPS (lpj=4000)
> [    0.023104] pid_max: default: 32768 minimum: 301
> [    0.028306] Mount-cache hash table entries: 16384 (order: 5, 131072 bytes,
> linear)
> [    0.035767] Mountpoint-cache hash table entries: 16384 (order: 5, 131072
> bytes, linear)
> [    0.045470] rcu: Hierarchical SRCU implementation.
> [    0.050234] smp: Bringing up secondary CPUs ...
> [    0.056201] smp: Brought up 1 node, 4 CPUs
> [    0.060963] devtmpfs: initialized
> [    0.065532] random: get_random_u32 called from
> bucket_table_alloc.isra.25+0x4e/0x160 with crng_init=0
> [    0.065924] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff,
> max_idle_ns: 7645041785100000 ns
> [    0.084277] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
> [    0.091975] NET: Registered protocol family 16
> [    0.112804] vgaarb: loaded
> [    0.115183] SCSI subsystem initialized
> [    0.119121] usbcore: registered new interface driver usbfs
> [    0.124262] usbcore: registered new interface driver hub
> [    0.129672] usbcore: registered new device driver usb
> [    0.135731] clocksource: Switched to clocksource riscv_clocksource
> [    0.148925] NET: Registered protocol family 2
> [    0.153254] tcp_listen_portaddr_hash hash table entries: 4096 (order: 5,
> 163840 bytes, linear)
> [    0.161852] TCP established hash table entries: 65536 (order: 7, 524288
> bytes, linear)
> [    0.171366] TCP bind hash table entries: 65536 (order: 9, 2097152 bytes,
> linear)
> [    0.185351] TCP: Hash tables configured (established 65536 bind 65536)
> [    0.191718] UDP hash table entries: 4096 (order: 6, 393216 bytes, linear)
> [    0.199390] UDP-Lite hash table entries: 4096 (order: 6, 393216 bytes, linear)
> [    0.207489] NET: Registered protocol family 1
> [    0.211831] RPC: Registered named UNIX socket transport module.
> [    0.217163] RPC: Registered udp transport module.
> [    0.221936] RPC: Registered tcp transport module.
> [    0.226703] RPC: Registered tcp NFSv4.1 backchannel transport module.
> [    0.233226] PCI: CLS 0 bytes, default 64
> [    0.584632] workingset: timestamp_bits=62 max_order=21 bucket_order=0
> [    0.599792] NFS: Registering the id_resolver key type
> [    0.604240] Key type id_resolver registered
> [    0.608415] Key type id_legacy registered
> [    0.612508] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
> [    0.619415] 9p: Installing v9fs 9p2000 file system support
> [    0.625234] NET: Registered protocol family 38
> [    0.629383] Block layer SCSI generic (bsg) driver version 0.4 loaded (major
> 252)
> [    0.636814] io scheduler mq-deadline registered
> [    0.641408] io scheduler kyber registered
> [    0.696163] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
> [    0.702957] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 1, base_baud
> = 0) is a SiFive UART v0
> [    0.711414] BUG: spinlock bad magic on CPU#1, swapper/0/1
> [    0.716867]  lock: 0xffffffe1f6372018, .magic: 00000000, .owner: <none>/-1,
> .owner_cpu: 0
> [    0.725113] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.7.0-rc3-00001-
> ga4bf42d-dirty #3
> [    0.733182] Call Trace:
> [    0.735711] [<ffffffe0006024c6>] walk_stackframe+0x0/0xa4
> [    0.741174] [<ffffffe0006026ac>] show_stack+0x2a/0x34
> [    0.746304] [<ffffffe000869ea0>] dump_stack+0x6a/0x84
> [    0.751427] [<ffffffe000643074>] spin_dump+0x68/0x74
> [    0.756456] [<ffffffe000642c94>] do_raw_spin_lock+0xb0/0xcc
> [    0.762107] [<ffffffe000c4b520>] _raw_spin_lock_irqsave+0x20/0x2c
> [    0.768264] [<ffffffe0008d9a24>] uart_add_one_port+0x2f6/0x406
> [    0.774167] [<ffffffe0008e38ac>] sifive_serial_probe+0x184/0x270
> [    0.780253] [<ffffffe000a13166>] platform_drv_probe+0x32/0x5e
> [    0.786062] [<ffffffe000a11958>] really_probe+0x9a/0x21e
> [    0.791445] [<ffffffe000a11bde>] driver_probe_device+0x2e/0x88
> [    0.797349] [<ffffffe000a11db0>] device_driver_attach+0x4c/0x50
> [    0.803339] [<ffffffe000a11dee>] __driver_attach+0x3a/0xac
> [    0.808896] [<ffffffe000a0ff54>] bus_for_each_dev+0x4a/0x72
> [    0.814539] [<ffffffe000a11464>] driver_attach+0x1a/0x22
> [    0.819922] [<ffffffe000a10f96>] bus_add_driver+0x192/0x198
> [    0.825566] [<ffffffe000a122dc>] driver_register+0x3a/0xd0
> [    0.831123] [<ffffffe000a1312c>] __platform_driver_register+0x3a/0x42
> [    0.837637] [<ffffffe0000174c2>] sifive_serial_init+0x30/0x50
> [    0.843457] [<ffffffe0006000d0>] do_one_initcall+0x50/0x15a
> [    0.849095] [<ffffffe000001c80>] kernel_init_freeable+0x16a/0x1de
> [    0.855259] [<ffffffe000c46d32>] kernel_init+0x12/0x118
> [    0.860557] [<ffffffe00060120a>] ret_from_exception+0x0/0xc
> [    0.866240] printk: console [ttySIF0] enabled
> [    0.866240] printk: console [ttySIF0] enabled
> [    0.874992] printk: bootconsole [sbi0] disabled
> [    0.874992] printk: bootconsole [sbi0] disabled
> [    0.884404] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 10,
> base_baud = 0) is a SiFive UART v0
> [    0.893847] [drm] radeon kernel modesetting enabled.
> 
> I think the issue might be due to uninitialized spin_lock of ssp
> (sifive_serial_port).
> So adding a spin_lock_init resolve's this. Please let me know your views here.
> 
> diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c index
> 13eadcb..607d188 100644
> --- a/drivers/tty/serial/sifive.c
> +++ b/drivers/tty/serial/sifive.c
> @@ -989,6 +989,8 @@ static int sifive_serial_probe(struct platform_device
> *pdev)
>         ssp->clk = clk;
>         ssp->clk_notifier.notifier_call = sifive_serial_clk_notifier;
> 
> +       spin_lock_init(&ssp->port.lock);
> +
>         r = clk_notifier_register(ssp->clk, &ssp->clk_notifier);
>         if (r) {
>                 dev_err(&pdev->dev, "could not register clock notifier: %d\n",
> 

Please send this fix to ASAP with appropriate "Fixes:" line.

Thanks for debugging the issue.

Regards,
Anup

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: spinlock bad magic on SiFive uart driver
  2020-05-05 12:00     ` Anup Patel
@ 2020-05-05 12:04       ` Sagar Kadam
  0 siblings, 0 replies; 5+ messages in thread
From: Sagar Kadam @ 2020-05-05 12:04 UTC (permalink / raw)
  To: Anup Patel, Palmer Dabbelt, Atish Patra; +Cc: linux-riscv, Paul Walmsley

Hi Atish,

> -----Original Message-----
> From: Anup Patel <Anup.Patel@wdc.com>
> Sent: Tuesday, May 5, 2020 5:30 PM
> To: Sagar Kadam <sagar.kadam@sifive.com>; Palmer Dabbelt
> <palmer@dabbelt.com>; Atish Patra <Atish.Patra@wdc.com>
> Cc: linux-riscv@lists.infradead.org; Paul Walmsley
> <paul.walmsley@sifive.com>
> Subject: RE: spinlock bad magic on SiFive uart driver
> 
> [External Email] Do not click links or attachments unless you recognize the
> sender and know the content is safe
> 
> Hi Sagar,
> 
> > -----Original Message-----
> > From: linux-riscv <linux-riscv-bounces@lists.infradead.org> On Behalf
> > Of Sagar Kadam
> > Sent: 05 May 2020 16:40
> > To: Palmer Dabbelt <palmer@dabbelt.com>; Atish Patra
> > <Atish.Patra@wdc.com>
> > Cc: linux-riscv@lists.infradead.org; Paul Walmsley
> > <paul.walmsley@sifive.com>
> > Subject: RE: spinlock bad magic on SiFive uart driver
> >
> > Hello Atish,
> >
> > > -----Original Message-----
> > > From: linux-riscv <linux-riscv-bounces@lists.infradead.org> On
> > > Behalf Of Palmer Dabbelt
> > > Sent: Tuesday, May 5, 2020 2:02 AM
> > > To: Atish Patra <Atish.Patra@wdc.com>
> > > Cc: linux-riscv@lists.infradead.org; Paul Walmsley
> > > <paul.walmsley@sifive.com>
> > > Subject: Re: spinlock bad magic on SiFive uart driver
> > >
> > > [External Email] Do not click links or attachments unless you
> > > recognize the sender and know the content is safe
> > >
> > > On Sat, 25 Apr 2020 23:40:58 PDT (-0700), Atish Patra wrote:
> > > > Hi,
> > > > I am seeing following spinlock bad magic error with 5.7-rc1+
> > > > kernels on HiFive Unleashed board. But it continues to boot
> > > > without any other issue.
> > > >
> > > > Here is the relevant boot log:
> > > > -----------------------------------------------------------------------
> > > > [    0.346494] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
> > > > [    0.353268] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 1,
> > > > base_baud = 0) is a SiFive UART v0
> > > > [    0.361720] BUG: spinlock bad magic on CPU#1, swapper/0/1
> > > > [    0.367179]  lock: 0xffffffe1f6f56018, .magic: 00000000, .owner:
> > > > <none>/-1, .owner_cpu: 0
> > > > [    0.375425] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.7.0-rc2-
> > > > 00004-g47dfd752cad3 #142
> > > > [    0.383580] Call Trace:
> > > > [    0.386109] [<ffffffe0002024c6>] walk_stackframe+0x0/0xa4
> > > > [    0.391572] [<ffffffe0002026ac>] show_stack+0x2a/0x34
> > > > [    0.396703] [<ffffffe00046a09e>] dump_stack+0x6a/0x84
> > > > [    0.401818] [<ffffffe00024306a>] spin_dump+0x68/0x74
> > > > [    0.406853] [<ffffffe000242c8a>] do_raw_spin_lock+0xb0/0xcc
> > > > [    0.412499] [<ffffffe000841700>] _raw_spin_lock_irqsave+0x20/0x2c
> > > > [    0.418664] [<ffffffe0004d9c0c>] uart_add_one_port+0x2f6/0x406
> > > > [    0.424567] [<ffffffe0004e3a94>] sifive_serial_probe+0x184/0x270
> > > > [    0.430644] [<ffffffe00061337c>] platform_drv_probe+0x32/0x5e
> > > > [    0.436465] [<ffffffe000611b6e>] really_probe+0x9a/0x21e
> > > > [    0.441843] [<ffffffe000611df4>] driver_probe_device+0x2e/0x88
> > > > [    0.447747] [<ffffffe000611fc6>] device_driver_attach+0x4c/0x50
> > > > [    0.453738] [<ffffffe000612004>] __driver_attach+0x3a/0xac
> > > > [    0.459294] [<ffffffe00061016a>] bus_for_each_dev+0x4a/0x72
> > > > [    0.464937] [<ffffffe00061167a>] driver_attach+0x1a/0x22
> > > > [    0.470320] [<ffffffe0006111ac>] bus_add_driver+0x192/0x198
> > > > [    0.475964] [<ffffffe0006124f2>] driver_register+0x3a/0xd0
> > > > [    0.481520] [<ffffffe000613342>]
> > > > __platform_driver_register+0x3a/0x42
> > > > [    0.488035] [<ffffffe00001ff70>] sifive_serial_init+0x30/0x50
> > > > [    0.493856] [<ffffffe0002000d0>] do_one_initcall+0x50/0x15a
> > > > [    0.499494] [<ffffffe000002c80>] kernel_init_freeable+0x16a/0x1de
> > > > [    0.505662] [<ffffffe00083cd5c>] kernel_init+0x12/0x118
> > > > [    0.510955] [<ffffffe00020120a>] ret_from_exception+0x0/0xc
> > > > [    0.516647] printk: console [ttySIF0] enabled
> > > > [    0.516647] printk: console [ttySIF0] enabled
> > > > [    0.525382] printk: bootconsole [sbi0] disabled
> > > > [    0.525382] printk: bootconsole [sbi0] disabled
> > > > [    0.534799] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 2,
> > > > base_baud = 0) is a SiFive UART v0
> > > > ------------------------------------------------------------------
> > > > --
> > > > ---
> > > >
> > > > I have not debugged further. Just wanted to check if anybody else
> > > > also has seen this error.
> > >
> > > Any news?  I don't have a HiFive Unleashed so I don't test on it,
> > > but I'm going to go try and run with a SiFive UART in QEMU now...
> >
> > I could reproduce it with OpenSBI v0.7 and as below:
> >
> > OpenSBI v0.7-31-gd626037
> >    ____                    _____ ____ _____
> >   / __ \                  / ____|  _ \_   _|
> >  | |  | |_ __   ___ _ __ | (___ | |_) || |
> >  | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |  | |__| | |_) |  __/ | | |____) | |_) ||
> |_
> >   \____/| .__/ \___|_| |_|_____/|____/_____|
> >         | |
> >         |_|
> >
> > Platform Name          : SiFive Freedom U540
> > Platform HART Features : RV64ACDFIMSU
> > Platform HART Count    : 4
> > Current HART ID        : 1
> > Firmware Base          : 0x80000000
> > Firmware Size          : 100 KB
> > Runtime SBI Version    : 0.2
> >
> > MIDELEG : 0x0000000000000222
> > MEDELEG : 0x000000000000b109
> > PMP0    : 0x0000000080000000-0x000000008001ffff (A)
> > PMP1    : 0x0000000000000000-0x0000007fffffffff (A,R,W,X)
> >
> >
> > U-Boot 2020.07-rc1-00201-g24e3f96 (May 04 2020 - 12:25:18 -0700)
> >
> > CPU:   rv64imafdc
> > Model: SiFive HiFive Unleashed A00
> > DRAM:  8 GiB
> > MMC:   spi@10050000:mmc@0: 0
> > In:    serial@10010000
> > Out:   serial@10010000
> > Err:   serial@10010000
> > Net:   eth0: ethernet@10090000
> > Hit any key to stop autoboot:  0
> > => setenv bootargs "root=/dev/ram rw console=ttySIF0 earlycon=sbi"
> > => mmc rescan ; fatload mmc 0:2 0x80200000 uImage ; fatload mmc 0:2
> > 0x82200000 hifive-unleashed-a00.dtb ; bootm 0x80200000 - 0x82200000
> > Starting kernel ...
> >
> > [    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
> > [    0.000000] Linux version 5.7.0-rc3-00001-ga4bf42d-dirty
> > (sagark2@sifive.com) (gcc version 8.2.0 (Buildroot 2018.11-rc2-00003-
> > ga0787e9), GNU ld (GNU Binutils) 2.31.1) #3 SMP Tue May 5 03:17:50 PDT
> > 2020
> > [    0.000000] earlycon: sbi0 at I/O port 0x0 (options '')
> > [    0.000000] printk: bootconsole [sbi0] enabled
> > [    0.000000] initrd not found or empty - disabling initrd
> > [    0.000000] Zone ranges:
> > [    0.000000]   DMA32    [mem 0x0000000080200000-0x00000000ffffffff]
> > [    0.000000]   Normal   [mem 0x0000000100000000-0x000000027fffffff]
> > [    0.000000] Movable zone start for each node
> > [    0.000000] Early memory node ranges
> > [    0.000000]   node   0: [mem 0x0000000080200000-0x000000027fffffff]
> > [    0.000000] Initmem setup node 0 [mem 0x0000000080200000-
> > 0x000000027fffffff]
> > [    0.000000] software IO TLB: mapped [mem 0xfbfff000-0xfffff000] (64MB)
> > [    0.000000] SBI specification v0.2 detected
> > [    0.000000] SBI implementation ID=0x1 Version=0x7
> > [    0.000000] SBI v0.2 TIME extension detected
> > [    0.000000] SBI v0.2 IPI extension detected
> > [    0.000000] SBI v0.2 RFENCE extension detected
> > [    0.000000] SBI v0.2 HSM extension detected
> > [    0.000000] CPU with hartid=0 is not available
> > [    0.000000] CPU with hartid=0 is not available
> > [    0.000000] elf_hwcap is 0x112d
> > [    0.000000] percpu: Embedded 17 pages/cpu s31976 r8192 d29464
> u69632
> > [    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 2067975
> > [    0.000000] Kernel command line: root=/dev/ram rw console=ttySIF0
> > earlycon=sbi
> > [    0.000000] Dentry cache hash table entries: 1048576 (order: 11,
> 8388608
> > bytes, linear)
> > [    0.000000] Inode-cache hash table entries: 524288 (order: 10, 4194304
> > bytes, linear)
> > [    0.000000] Sorting __ex_table...
> > [    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
> > [    0.000000] Memory: 8172076K/8386560K available (6451K kernel code,
> > 4222K rwdata, 4096K rodata, 4603K init, 317K bss, 214484K reserved, 0K
> > cma-
> > reserved)
> > [    0.000000] Virtual kernel memory layout:
> > [    0.000000]       fixmap : 0xffffffcefee00000 - 0xffffffceff000000   (2048 kB)
> > [    0.000000]       pci io : 0xffffffceff000000 - 0xffffffcf00000000   (  16 MB)
> > [    0.000000]      vmemmap : 0xffffffcf00000000 - 0xffffffcfffffffff   (4095 MB)
> > [    0.000000]      vmalloc : 0xffffffd000000000 - 0xffffffdfffffffff   (65535 MB)
> > [    0.000000]       lowmem : 0xffffffe000000000 - 0xffffffe1ffe00000   (8190
> MB)
> > [    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4,
> Nodes=1
> > [    0.000000] rcu: Hierarchical RCU implementation.
> > [    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=8 to
> nr_cpu_ids=4.
> > [    0.000000] rcu:     RCU debug extended QS entry/exit.
> > [    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25
> > jiffies.
> > [    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16,
> nr_cpu_ids=4
> > [    0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
> > [    0.000000] plic: mapped 53 interrupts with 4 handlers for 9 contexts.
> > [    0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid
> [1]
> > [    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff
> > max_cycles: 0x1d854df40, max_idle_ns: 3526361616960 ns
> > [    0.000006] sched_clock: 64 bits at 1000kHz, resolution 1000ns, wraps
> every
> > 2199023255500ns
> > [    0.008563] Console: colour dummy device 80x25
> > [    0.012994] Calibrating delay loop (skipped), value calculated using timer
> > frequency.. 2.00 BogoMIPS (lpj=4000)
> > [    0.023104] pid_max: default: 32768 minimum: 301
> > [    0.028306] Mount-cache hash table entries: 16384 (order: 5, 131072
> bytes,
> > linear)
> > [    0.035767] Mountpoint-cache hash table entries: 16384 (order: 5,
> 131072
> > bytes, linear)
> > [    0.045470] rcu: Hierarchical SRCU implementation.
> > [    0.050234] smp: Bringing up secondary CPUs ...
> > [    0.056201] smp: Brought up 1 node, 4 CPUs
> > [    0.060963] devtmpfs: initialized
> > [    0.065532] random: get_random_u32 called from
> > bucket_table_alloc.isra.25+0x4e/0x160 with crng_init=0
> > [    0.065924] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff,
> > max_idle_ns: 7645041785100000 ns
> > [    0.084277] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
> > [    0.091975] NET: Registered protocol family 16
> > [    0.112804] vgaarb: loaded
> > [    0.115183] SCSI subsystem initialized
> > [    0.119121] usbcore: registered new interface driver usbfs
> > [    0.124262] usbcore: registered new interface driver hub
> > [    0.129672] usbcore: registered new device driver usb
> > [    0.135731] clocksource: Switched to clocksource riscv_clocksource
> > [    0.148925] NET: Registered protocol family 2
> > [    0.153254] tcp_listen_portaddr_hash hash table entries: 4096 (order: 5,
> > 163840 bytes, linear)
> > [    0.161852] TCP established hash table entries: 65536 (order: 7, 524288
> > bytes, linear)
> > [    0.171366] TCP bind hash table entries: 65536 (order: 9, 2097152 bytes,
> > linear)
> > [    0.185351] TCP: Hash tables configured (established 65536 bind 65536)
> > [    0.191718] UDP hash table entries: 4096 (order: 6, 393216 bytes, linear)
> > [    0.199390] UDP-Lite hash table entries: 4096 (order: 6, 393216 bytes,
> linear)
> > [    0.207489] NET: Registered protocol family 1
> > [    0.211831] RPC: Registered named UNIX socket transport module.
> > [    0.217163] RPC: Registered udp transport module.
> > [    0.221936] RPC: Registered tcp transport module.
> > [    0.226703] RPC: Registered tcp NFSv4.1 backchannel transport module.
> > [    0.233226] PCI: CLS 0 bytes, default 64
> > [    0.584632] workingset: timestamp_bits=62 max_order=21
> bucket_order=0
> > [    0.599792] NFS: Registering the id_resolver key type
> > [    0.604240] Key type id_resolver registered
> > [    0.608415] Key type id_legacy registered
> > [    0.612508] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
> > [    0.619415] 9p: Installing v9fs 9p2000 file system support
> > [    0.625234] NET: Registered protocol family 38
> > [    0.629383] Block layer SCSI generic (bsg) driver version 0.4 loaded
> (major
> > 252)
> > [    0.636814] io scheduler mq-deadline registered
> > [    0.641408] io scheduler kyber registered
> > [    0.696163] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
> > [    0.702957] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 1,
> base_baud
> > = 0) is a SiFive UART v0
> > [    0.711414] BUG: spinlock bad magic on CPU#1, swapper/0/1
> > [    0.716867]  lock: 0xffffffe1f6372018, .magic: 00000000, .owner: <none>/-
> 1,
> > .owner_cpu: 0
> > [    0.725113] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.7.0-rc3-00001-
> > ga4bf42d-dirty #3
> > [    0.733182] Call Trace:
> > [    0.735711] [<ffffffe0006024c6>] walk_stackframe+0x0/0xa4
> > [    0.741174] [<ffffffe0006026ac>] show_stack+0x2a/0x34
> > [    0.746304] [<ffffffe000869ea0>] dump_stack+0x6a/0x84
> > [    0.751427] [<ffffffe000643074>] spin_dump+0x68/0x74
> > [    0.756456] [<ffffffe000642c94>] do_raw_spin_lock+0xb0/0xcc
> > [    0.762107] [<ffffffe000c4b520>] _raw_spin_lock_irqsave+0x20/0x2c
> > [    0.768264] [<ffffffe0008d9a24>] uart_add_one_port+0x2f6/0x406
> > [    0.774167] [<ffffffe0008e38ac>] sifive_serial_probe+0x184/0x270
> > [    0.780253] [<ffffffe000a13166>] platform_drv_probe+0x32/0x5e
> > [    0.786062] [<ffffffe000a11958>] really_probe+0x9a/0x21e
> > [    0.791445] [<ffffffe000a11bde>] driver_probe_device+0x2e/0x88
> > [    0.797349] [<ffffffe000a11db0>] device_driver_attach+0x4c/0x50
> > [    0.803339] [<ffffffe000a11dee>] __driver_attach+0x3a/0xac
> > [    0.808896] [<ffffffe000a0ff54>] bus_for_each_dev+0x4a/0x72
> > [    0.814539] [<ffffffe000a11464>] driver_attach+0x1a/0x22
> > [    0.819922] [<ffffffe000a10f96>] bus_add_driver+0x192/0x198
> > [    0.825566] [<ffffffe000a122dc>] driver_register+0x3a/0xd0
> > [    0.831123] [<ffffffe000a1312c>] __platform_driver_register+0x3a/0x42
> > [    0.837637] [<ffffffe0000174c2>] sifive_serial_init+0x30/0x50
> > [    0.843457] [<ffffffe0006000d0>] do_one_initcall+0x50/0x15a
> > [    0.849095] [<ffffffe000001c80>] kernel_init_freeable+0x16a/0x1de
> > [    0.855259] [<ffffffe000c46d32>] kernel_init+0x12/0x118
> > [    0.860557] [<ffffffe00060120a>] ret_from_exception+0x0/0xc
> > [    0.866240] printk: console [ttySIF0] enabled
> > [    0.866240] printk: console [ttySIF0] enabled
> > [    0.874992] printk: bootconsole [sbi0] disabled
> > [    0.874992] printk: bootconsole [sbi0] disabled
> > [    0.884404] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 10,
> > base_baud = 0) is a SiFive UART v0
> > [    0.893847] [drm] radeon kernel modesetting enabled.
> >
> > I think the issue might be due to uninitialized spin_lock of ssp
> > (sifive_serial_port).
> > So adding a spin_lock_init resolve's this. Please let me know your views
> here.
> >
> > diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c
> > index
> > 13eadcb..607d188 100644
> > --- a/drivers/tty/serial/sifive.c
> > +++ b/drivers/tty/serial/sifive.c
> > @@ -989,6 +989,8 @@ static int sifive_serial_probe(struct
> > platform_device
> > *pdev)
> >         ssp->clk = clk;
> >         ssp->clk_notifier.notifier_call = sifive_serial_clk_notifier;
> >
> > +       spin_lock_init(&ssp->port.lock);
> > +
> >         r = clk_notifier_register(ssp->clk, &ssp->clk_notifier);
> >         if (r) {
> >                 dev_err(&pdev->dev, "could not register clock
> > notifier: %d\n",
> >
> 
> Please send this fix to ASAP with appropriate "Fixes:" line.
> 

Sure will send it.

BR,
Sagar Kadam

> Thanks for debugging the issue.
> 
> Regards,
> Anup

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-05-05 12:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-26  6:40 spinlock bad magic on SiFive uart driver Atish Patra
2020-05-04 20:31 ` Palmer Dabbelt
2020-05-05 11:09   ` Sagar Kadam
2020-05-05 12:00     ` Anup Patel
2020-05-05 12:04       ` Sagar Kadam

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.