Skip to content

Commit

Permalink
misc: pci_endpoint_test: Fix a potential data abort issue
Browse files Browse the repository at this point in the history
Fix the following issue:
[    4.326562] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
[    4.335337] Mem abort info:
[    4.338120]   ESR = 0x96000004
[    4.341165]   EC = 0x25: DABT (current EL), IL = 32 bits
[    4.346465]   SET = 0, FnV = 0
[    4.349508]   EA = 0, S1PTW = 0
[    4.352637] Data abort info:
[    4.355507]   ISV = 0, ISS = 0x00000004
[    4.359331]   CM = 0, WnR = 0
[    4.362287] [0000000000000008] user address but active_mm is swapper
[    4.368631] Internal error: Oops: 96000004 [Freescale#1] PREEMPT SMP
[    4.374191] Modules linked in:
[    4.377239] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.4.3-00029-g96d7df2d4f6f-dirty Freescale#64
[    4.385404] Hardware name: NXP Layerscape LX2160ARDB (DT)
[    4.390793] pstate: 00000085 (nzcv daIf -PAN -UAO)
[    4.395583] pc : pci_endpoint_test_irqhandler+0x18/0x60
[    4.400802] lr : __handle_irq_event_percpu+0x74/0x198
[    4.405841] sp : ffff800010003e60
[    4.409145] x29: ffff800010003e60 x28: 0000000000000060
[    4.414447] x27: ffffa29b58840d30 x26: ffffa29b592ec2f3
[    4.419750] x25: ffff0022ed4a6e00 x24: ffffa29b590a9000
[    4.425051] x23: 0000000000000077 x22: ffff800010003f24
[    4.428548] pci-endpoint-test 0001:01:00.1: ignoring dependency for device, assuming no driver
[    4.430353] x21: 0000000000000000 x20: ffff0022e9b6cc80
[    4.444247] x19: 0000000000000008 x18: 0000000000000014
[    4.449549] x17: 00000000ee3004e0 x16: 00000000a2ab582f
[    4.454850] x15: 0000000000000000 x14: 0000000000000002
[    4.460151] x13: 0000000000000000 x12: 071c71c71c71c71c
[    4.465453] x11: 0000000000781790 x10: 0000000000000040
[    4.470754] x9 : ffffa29b590c3650 x8 : ffffa29b590c3648
[    4.476056] x7 : ffff0022edc468a0 x6 : 0000000000000000
[    4.481357] x5 : ffff0022edc466c0 x4 : ffff5d87a540b000
[    4.486658] x3 : 0000000000000000 x2 : ffffa29b5793fdb8
[    4.491960] x1 : ffff0022e9b6cc80 x0 : 0000000000000077
[    4.497262] Call trace:
[    4.499701]  pci_endpoint_test_irqhandler+0x18/0x60
[    4.504569]  __handle_irq_event_percpu+0x74/0x198
[    4.509264]  handle_irq_event_percpu+0x34/0x88
[    4.513698]  handle_irq_event+0x44/0xc8
[    4.517524]  handle_fasteoi_irq+0xac/0x150
[    4.521611]  generic_handle_irq+0x24/0x38
[    4.525611]  __handle_domain_irq+0x5c/0xb0
[    4.529697]  gic_handle_irq+0x5c/0x148
[    4.533436]  el1_irq+0xb8/0x180
[    4.536570]  cpuidle_enter_state+0x13c/0x340
[    4.540829]  cpuidle_enter+0x38/0x50
[    4.541884] ahci-qoriq 3200000.sata: ignoring dependency for device, assuming no driver
[    4.544395]  call_cpuidle+0x1c/0x40
[    4.544399]  do_idle+0x214/0x2b0
[    4.544403]  cpu_startup_entry+0x24/0x40
[    4.544407]  rest_init+0xd4/0xe0
[    4.544415]  arch_call_rest_init+0xc/0x14
[    4.552431] ahci-qoriq 3200000.sata: 3200000.sata supply ahci not found, using dummy regulator
[    4.555876]  start_kernel+0x42c/0x458
[    4.555883] Code: a90153f3 aa0103f4 f9400433 91002273 (b9400273)
[    4.559121] ahci-qoriq 3200000.sata: 3200000.sata supply phy not found, using dummy regulator
[    4.563019] ---[ end trace efbd1f306606ff3f ]---
[    4.566244] ahci-qoriq 3200000.sata: 3200000.sata supply target not found, using dummy regulator
[    4.570218] Kernel panic - not syncing: Fatal exception in interrupt
[    4.570227] SMP: stopping secondary CPUs
[    4.578887] ahci-qoriq 3200000.sata: AHCI 0001.0301 32 slots 1 ports 6 Gbps 0x1 impl platform mode
[    4.588548] Kernel Offset: 0x229b47000000 from 0xffff800010000000
[    4.588551] PHYS_OFFSET: 0xffffc4e2c0000000
[    4.588554] CPU features: 0x0002,21806008
[    4.588556] Memory Limit: none
[    4.646922] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---

This issue occurs when the interrupt is triggerred earlier than the test
BAR ioremap, so move the interrupt request function after all BARs
ioremap completion.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
  • Loading branch information
Zhiqiang-Hou authored and rehsack committed Jan 21, 2021
1 parent 50a7274 commit 5d1fd05
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/misc/pci_endpoint_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,6 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type))
goto err_disable_irq;

if (!pci_endpoint_test_request_irq(test))
goto err_disable_irq;

for (bar = BAR_0; bar <= BAR_5; bar++) {
if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
base = pci_ioremap_bar(pdev, bar);
Expand Down Expand Up @@ -724,13 +721,16 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
goto err_iounmap;
}

if (!pci_endpoint_test_request_irq(test))
goto err_ida_remove;

snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
misc_device = &test->miscdev;
misc_device->minor = MISC_DYNAMIC_MINOR;
misc_device->name = kstrdup(name, GFP_KERNEL);
if (!misc_device->name) {
err = -ENOMEM;
goto err_ida_remove;
goto err_release_irq;
}
misc_device->fops = &pci_endpoint_test_fops,

Expand All @@ -745,6 +745,9 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
err_kfree_name:
kfree(misc_device->name);

err_release_irq:
pci_endpoint_test_release_irq(test);

err_ida_remove:
ida_simple_remove(&pci_endpoint_test_ida, id);

Expand All @@ -753,7 +756,6 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
if (test->bar[bar])
pci_iounmap(pdev, test->bar[bar]);
}
pci_endpoint_test_release_irq(test);

err_disable_irq:
pci_endpoint_test_free_irq_vectors(test);
Expand Down

0 comments on commit 5d1fd05

Please sign in to comment.