Unverified Commit 7e9c59f9 authored by Liu Dalin's avatar Liu Dalin
Browse files

spi: phytium: fix phytium_spi_irq panic on boot

KylinSec inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8LGJS?from=project-issue



---------------------------

The root cause is that spi irq is triggered between request_irq
 and spi_master_set_devdata, and fts has not been initialized yet.

the process shown below:
        (probe)                                  |        (irq handler)
         ...snip...                              |
phytium_spi_add_host()                           |
  request_irq(fts->irq, phytium_spi_irq, ...)    |
         ...snip...                              |  phytium_spi_irq()
                                                 |      fts = spi_master_get_devdata(master)
                                                 |      phytium_readl(fts, ISR)
spi_master_set_devdata(master, fts)              |           ...snip...
         ...snip...                              |

[   11.612688] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000030
[   11.621472] Mem abort info:
[   11.624255]   ESR = 0x96000005
[   11.627297]   Exception class = DABT (current EL), IL = 32 bits
[   11.633202]   SET = 0, FnV = 0
[   11.636243]   EA = 0, S1PTW = 0
[   11.639371] Data abort info:
[   11.642238]   ISV = 0, ISS = 0x00000005
[   11.646060]   CM = 0, WnR = 0
[   11.649016] user pgtable: 64k pages, 48-bit VAs, pgdp = 0000000042711b01
[   11.655704] [0000000000000030] pgd=0000000000000000, pud=0000000000000000
[   11.662480] Internal error: Oops: 96000005 [#1] SMP
[   11.667344] Modules linked in: spi_phytium_plat(E) spi_phytium(E) sch_fq_codel(E) ip_tables(E) ext4(E) mbcache(E) jbd2(E) sd_mod(E) ahci(E) libahci(E) sdhci_pci(E) cqhci(E) sdhci(E) libata(E) mmc_core(E) phytium_dc_drm(E) dwmac_phytium(E) stmmac_platform(E) rtc_ds1307(E) stmmac(E) i2c_designware_platform(E) i2c_designware_core(E) dm_mirror(E) dm_region_hash(E) dm_log(E) dm_mod(E)
[   11.700953] Process systemd-udevd (pid: 813, stack limit = 0x00000000805e49d8)
[   11.708163] CPU: 0 PID: 813 Comm: systemd-udevd Tainted: G            E     4.19.90+ #2
[   11.716151] Hardware name: PHYTIUM LTD D2000/D2000, BIOS
[   11.721623] pstate: 00000085 (nzcv daIf -PAN -UAO)
[   11.726405] pc : phytium_spi_irq+0x24/0x80 [spi_phytium]
[   11.731707] lr : __handle_irq_event_percpu+0x64/0x228
[   11.736743] sp : ffff00000800fe60
[   11.740045] x29: ffff00000800fe60 x28: ffff801fac5e0000
[   11.745343] x27: ffff000009454000 x26: ffff801fa223f000
[   11.750641] x25: ffff00000800ff14 x24: ffff000009010028
[   11.755939] x23: ffff0000093557f0 x22: 000000000000001a
[   11.761237] x21: 0000000000000000 x20: ffff801fa223f000
[   11.766534] x19: ffff801fafc31000 x18: 0000000000002280
[   11.771832] x17: 0000000000000000 x16: 0000000000000000
[   11.777129] x15: 0000aaabfe88dca0 x14: 0000000000000000
[   11.782426] x13: 0000aaabfe88dbce x12: 000000007f010000
[   11.787724] x11: 0000000000000000 x10: 0000000000000040
[   11.793021] x9 : ffff00000937f3d8 x8 : ffff801fc0002fe8
[   11.798319] x7 : ffff801fc00030e0 x6 : 00000000000000d0
[   11.803616] x5 : 00008020b6db0000 x4 : 0000000000000000
[   11.808914] x3 : ffff801fafc316a8 x2 : 0000000000000030
[   11.814211] x1 : ffff801fafc31000 x0 : ffff000008180844
[   11.819509] Call trace:
[   11.821944]  phytium_spi_irq+0x24/0x80 [spi_phytium]
[   11.826895]  __handle_irq_event_percpu+0x64/0x228
[   11.831585]  handle_irq_event_percpu+0x40/0x98
[   11.836015]  handle_irq_event+0x50/0xe0
[   11.839838]  handle_fasteoi_irq+0xc8/0x158
[   11.843922]  generic_handle_irq+0x3c/0x58
[   11.847917]  __handle_domain_irq+0x68/0xc0
[   11.852001]  gic_handle_irq+0x78/0x180
[   11.855736]  el1_irq+0xb8/0x140
[   11.858868]  copy_page+0x64/0xac
[   11.862084]  wp_page_copy+0x104/0xc28
[   11.865733]  do_wp_page+0xd8/0x5c8
[   11.869123]  __handle_mm_fault+0x538/0x828
[   11.873206]  handle_mm_fault+0xd8/0x1a0
[   11.877030]  do_page_fault+0x210/0x4f8
[   11.880765]  do_mem_abort+0x68/0x118
[   11.884327]  el0_da+0x24/0x28
[   11.887283] Code: d503201f f9405e63 f9400c64 9100c082 (b9400042)
[   11.893368] ---[ end trace 03c7a882b84b4855 ]---
[   11.897971] Kernel panic - not syncing: Fatal exception in interrupt
[   11.904312] SMP: stopping secondary CPUs
[   11.908224] Kernel Offset: disabled
[   11.911700] CPU features: 0x10,a0802008
[   11.915522] Memory Limit: none
[   11.918565] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---

Fixes: e8483fcd ("spi: add phytium spi support")
Signed-off-by: default avatarLiu Dalin <liudalin@kylinsec.com.cn>
parent 251d793c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment