Part Number: PROCESSOR-SDK-AM335X
Tool/software: Linux
Hi TI,
Observed below crash on AM335x target. SPI_ASYNC is used in the spi slave driver and SPI_ASYNC will be called for every 20msec duration. Brief spi slave driver design is as below:
1. SPI Chip will have data to exchange for every 20 to 30msec, so it needs continuous communication. Reading spi chip data with spi_async. HR timer is used to poll data from spi chip. for every 30msec hr timer polling function will be called and that will call spi_async. As this read is happening inside hrtimer, spi_sync can't be used.
2. User application sets the poll duration of HR timer's call back function. SPI_ASYNC wil be called continuously for every HR timer duration.
3. In the life time of this application and driver, app needs restart and drive needs rmmod and insmod.
4. What has been observed is, after close of the application, spi transfer is still not stooping. SPI transfer is still running with the list queue even if spi_async is not called..
5. Added following things in release driver of the spi slave driver: hrtimer_cancel (stooping the call back function). spi_msg.complete = NULL . putting NULL to the spi_message structure's complete call back function.
6. rmmod has following things: spi_unregister_driver, hrtimer_cancel, spi_msg.complete = NULL and memory de-allocation.
My suspect is spi_async has added tx and rx request in the spi.c queue. this queue is not stopping even after release and rmmod. rmmod is releasing the memory, but queue is runing in spi.c and this is causing the crash. Can you please check this let me know the fix for this?
crash is as below: System crashed immediately after rmmod, may be after freeing slave driver resources.
This issue is not always. It is a sometimes issue.
[ 2163.321140] Unable to handle kernel paging request at virtual address a56d2000
[ 2163.328659] pgd = c0004000
[ 2163.331603] [a56d2000] *pgd=00000000
[ 2163.335370] Internal error: Oops: 805 [#1] ARM
[ 2163.339845] Modules linked in: mercury_spi(-) dynamic_mercury_node [last unloaded: dynamic_mercury_node]
[ 2163.349445] CPU: 0 PID: 581 Comm: spi1 Not tainted 4.4.14 #4
[ 2163.355138] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 2163.361270] task: c7174000 ti: c746a000 task.ti: c746a000
[ 2163.366727] PC is at v7_dma_inv_range+0x20/0x48
[ 2163.371305] LR is at dma_cache_maint_page+0x90/0x138
[ 2163.376308] pc : [<c001ec40>] lr : [<c001aa58>] psr: 20070013
[ 2163.376308] sp : c746bd38 ip : c746bd38 fp : c746bd6c
[ 2163.387853] r10: c0802090 r9 : c61a38c0 r8 : 00000100
[ 2163.393111] r7 : 00000002 r6 : 000656d2 r5 : 0000002d r4 : c79aca40
[ 2163.399678] r3 : 0000003f r2 : 00000040 r1 : a56d212d r0 : a56d2000
[ 2163.406248] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
[ 2163.413426] Control: 10c5387d Table: 86004019 DAC: 00000051
[ 2163.419208] Process spi1 (pid: 581, stack limit = 0xc746a210)
[ 2163.424990] Stack: (0xc746bd38 to 0xc746c000)
[ 2163.429380] bd20: c08d3aac c080520c
[ 2163.437616] bd40: c746a000 0000002d 00000100 00000100 c001b4e0 c79aca40 c61a38c0 c7466280
[ 2163.445852] bd60: c746bd9c c746bd70 c001ac3c c001a9d4 c001ece0 c00562ac 00000100 c7cff000
[ 2163.454088] bd80: c626a248 00000100 c001b4e0 c7466280 c746bdb4 c746bda0 c001b544 c001ac0c
[ 2163.462324] bda0: c7632c00 c626a248 c746beac c746bdb8 c03958e0 c001b4ec 00000000 00000000
[ 2163.470560] bdc0: 0000000a c0575bfc 00000100 381143d1 00000100 c6218d00 c7478310 00000008
[ 2163.478795] bde0: c722e000 c7478310 00000001 00000000 c7466000 c7466280 00000000 00000000
[ 2163.487031] be00: c0036088 00000002 00000000 00000100 8722e000 00000000 4803013c 48030138
[ 2163.495266] be20: 00000001 00000001 00000020 00000020 00000000 00000000 00000000 4803013c
[ 2163.503500] be40: 48030138 00000001 00000001 00000020 00000020 00000000 00000000 00000000
[ 2163.511735] be60: 4803013c 48030138 00000001 00000001 00000020 00000020 00000000 00000000
[ 2163.519971] be80: c038f090 c626a248 00000000 c626a284 c7466000 00000001 c084b604 c7632c00
[ 2163.528206] bea0: c746beec c746beb0 c0391860 c0394b90 00000000 c0876a28 c7632d78 c74661f0
[ 2163.536442] bec0: 00000001 c7466000 00000000 c626a284 c746617c 00000001 00000000 00000000
[ 2163.544678] bee0: c746bf2c c746bef0 c0391f40 c039178c c7466158 00000000 00000001 c7466158
[ 2163.552912] bf00: c7466190 c7466190 00000000 c746a000 c746617c 00000001 00000000 00000000
[ 2163.561147] bf20: c746bf3c c746bf30 c03921b0 c0391ba8 c746bf64 c746bf40 c004dc8c c039219c
[ 2163.569383] bf40: 00000000 c7461800 c746617c c004dbe0 00000000 00000000 c746bfac c746bf68
[ 2163.577618] bf60: c004de40 c004dbec c746bf8c 00000000 c7461800 c746617c 00000000 c746bf7c
[ 2163.585854] bf80: c746bf7c 00000000 c746bf88 c746bf88 c7461800 c004dd5c 00000000 00000000
[ 2163.594089] bfa0: 00000000 c746bfb0 c0010630 c004dd68 00000000 00000000 00000000 00000000
[ 2163.602322] bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 2163.610557] bfe0: 00000000 00000000 00000000 00000000 00000013 00000000 df5bedfb df3fd749
[ 2163.618777] Backtrace:
[ 2163.621277] [<c001a9c8>] (dma_cache_maint_page) from [<c001ac3c>] (__dma_page_dev_to_cpu+0x3c/0xd8)
[ 2163.630374] r10:c7466280 r9:c61a38c0 r8:c79aca40 r7:c001b4e0 r6:00000100 r5:00000100
[ 2163.638317] r4:0000002d
[ 2163.640897] [<c001ac00>] (__dma_page_dev_to_cpu) from [<c001b544>] (arm_dma_unmap_page+0x64/0x68)
[ 2163.649817] r8:c7466280 r7:c001b4e0 r6:00000100 r5:c626a248 r4:c7cff000
[ 2163.656656] [<c001b4e0>] (arm_dma_unmap_page) from [<c03958e0>] (omap2_mcspi_transfer_one+0xd5c/0x161c)
[ 2163.666099] r5:c626a248 r4:c7632c00
[ 2163.669738] [<c0394b84>] (omap2_mcspi_transfer_one) from [<c0391860>] (spi_transfer_one_message+0xe0/0x41c)
[ 2163.679530] r10:c7632c00 r9:c084b604 r8:00000001 r7:c7466000 r6:c626a284 r5:00000000
[ 2163.687471] r4:c626a248
[ 2163.690047] [<c0391780>] (spi_transfer_one_message) from [<c0391f40>] (__spi_pump_messages+0x3a4/0x5f4)
[ 2163.699490] r10:00000000 r9:00000000 r8:00000001 r7:c746617c r6:c626a284 r5:00000000
[ 2163.707430] r4:c7466000
[ 2163.710007] [<c0391b9c>] (__spi_pump_messages) from [<c03921b0>] (spi_pump_messages+0x20/0x24)
[ 2163.718665] r10:00000000 r9:00000000 r8:00000001 r7:c746617c r6:c746a000 r5:00000000
[ 2163.726605] r4:c7466190
[ 2163.729191] [<c0392190>] (spi_pump_messages) from [<c004dc8c>] (kthread_worker_fn+0xac/0xf0)
[ 2163.737690] [<c004dbe0>] (kthread_worker_fn) from [<c004de40>] (kthread+0xe4/0xfc)
[ 2163.745302] r9:00000000 r8:00000000 r7:c004dbe0 r6:c746617c r5:c7461800 r4:00000000
[ 2163.753181] [<c004dd5c>] (kthread) from [<c0010630>] (ret_from_fork+0x14/0x24)
[ 2163.760443] r7:00000000 r6:00000000 r5:c004dd5c r4:c7461800
[ 2163.766198] Code: e1a02312 e2423001 e1100003 e1c00003 (1e070f3e)
[ 2163.772567] ---[ end trace adc52a3b07bd1b19 ]---
Regards and Thanks,
Akshay