Send SPI data in the tasklet

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Send SPI data in the tasklet

1,032 Views
864535720
Contributor II

Hello everyone
I am using the 3.14.52 kernel on the IMX6 development board. I am using SPI to send data. Use the spi_sync function to send SPI data directly in the write function of file_operations, which can be sent and received normally. The SPI data is sent using the spi_async function, and the program reports an error. Then my goal is to send SPI data in the tasklet. But in the tasklet, whether it is spi_sync function or spi_async, it reports an error. Do you have any good solutions?

Labels (1)
0 Kudos
Reply
2 Replies

894 Views
igorpadykov
NXP Employee
NXP Employee

Hi 其东 刘

nxp ecspi driver uses queues as described in sect.37.2.1 SPI Sub-System in Linux OS

attached Linux Manual. One can try to implement tasklets using tasklet apis described on

Deferrable functions, kernel tasklets, and work queues – IBM Developer 

http://www.cs.otago.ac.nz/cosc440/labs/lab08.pdf 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

894 Views
864535720
Contributor II

Hi igorpadykov

I can now send SPI data using spi_async in the tasklet. At the same time, I encountered another problem. If I send data once in 1s, the data can be sent and received normally. If I send the data once in 1ms. The kernel will still crash. At the same time, I recorded the number of times the taskelt was called and the number of times the spi callback function was called. It is found that the number of calls to the taskelt is more than the number of calls to the spi callback function. Do you have any good suggestions for my situation?


Here is the information for my kernel crash prompt:

Sometimes prompted:

Unable to handle kernel NULL pointer dereference at virtual address 00000004
pgd = 80004000
[00000004] *pgd=00000000
Internal error: Oops: 817 [#1] PREEMPT SMP ARM
Modules linked in: spi_lqd(O)
CPU: 1 PID: 96 Comm: spi1 Tainted: G           O 3.14.52-1.1.1_ga #235
task: a8326d00 ti: a82f6000 task.ti: a82f6000
PC is at spi_pump_messages+0xdc/0x480
LR is at _raw_spin_lock_irqsave+0x18/0x5c
pc : [<8041c40c>]    lr : [<8075bdc8>]    psr: 60070093
sp : a82f7f08  ip : 00000000  fp : a837ddcc
r10: 80d0f504  r9 : 00000001  r8 : a82f6000
r7 : a837ddb4  r6 : a837dc00  r5 : 80d0f504  r4 : a837dde8
r3 : a87d5644  r2 : 00000000  r1 : a0070013  r0 : 00000000
Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 10c53c7d  Table: 387a804a  DAC: 00000015
Process spi1 (pid: 96, stack limit = 0xa82f6238)
Stack: (0xa82f7f08 to 0xa82f8000)
7f00:                   00000000 a837ddb4 a82f6000 00000001 80d0f504 a837ddcc
7f20: 80d0f504 00000000 a837ddb4 a82f6000 00000001 80d0f504 a82f6000 80045408
7f40: a8326d00 00000000 a8194d00 a837ddb4 800453bc 00000000 00000000 00000000
7f60: 00000000 8004528c 36e5fded 00000000 dcd7bffd a837ddb4 00000000 00000000
7f80: a82f7f80 a82f7f80 00000000 00000000 a82f7f90 a82f7f90 a82f7fac a8194d00
7fa0: 800451c0 00000000 00000000 8000e500 00000000 00000000 00000000 00000000
7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
7fe0: 00000000 00000000 00000000 00000000 00000013 00000000 ff9df77d d5f5fedb
[<8041c40c>] (spi_pump_messages) from [<80045408>] (kthread_worker_fn+0x4c/0x164)
[<80045408>] (kthread_worker_fn) from [<8004528c>] (kthread+0xcc/0xe4)
[<8004528c>] (kthread) from [<8000e500>] (ret_from_fork+0x14/0x34)
Code: eafffff5 e2432024 e58b2028 e8930005 (e5802004)
---[ end trace 1c380d84298e318a ]---
note: spi1[96] exited with preempt_count 1

Sometimes prompted:

Unable to handle kernel NULL pointer dereference at virtual address 00000160
pgd = 80004000
[00000160] *pgd=00000000
Internal error: Oops: 17 [#1] PREEMPT SMP ARM
Modules linked in: spi_lqd(O)
CPU: 1 PID: 96 Comm: spi1 Tainted: G           O 3.14.52-1.1.1_ga #235
task: a8326d00 ti: a82f6000 task.ti: a82f6000
PC is at spi_imx_setupxfer+0xc/0x1bc
LR is at spi_bitbang_transfer_one+0x148/0x244
pc : [<8041fa94>]    lr : [<8041e258>]    psr: 20070013
sp : a82f7eb8  ip : 00000000  fp : a837ddcc
r10: 80c7b6f0  r9 : ffffffff  r8 : a837de48
r7 : 00000000  r6 : a876b020  r5 : 00000000  r4 : a876b050
r3 : 8041fa88  r2 : 00000000  r1 : a876b050  r0 : 00000000
Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 10c53c7d  Table: 38ac804a  DAC: 00000015
Process spi1 (pid: 96, stack limit = 0xa82f6238)
Stack: (0xa82f7eb8 to 0xa82f8000)
7ea0:                                                       a837ddcc 8075c43c
7ec0: 00000000 60070013 a876b050 00000001 a876b020 8041e258 a837ddcc a837dc00
7ee0: 00000000 a876afec a876b020 a837dc00 a837de10 a8121a10 a8121a10 00000001
7f00: a837ddcc 8041c638 a837ddcc 80d0f504 00000000 a837ddb4 a82f6000 a837ddcc
7f20: 80d0f504 00000000 a837ddb4 a82f6000 00000001 80d0f504 a82f6000 80045408
7f40: a8326d00 00000000 a8194d00 a837ddb4 800453bc 00000000 00000000 00000000
7f60: 00000000 8004528c 36e5fded 00000000 dcdfbffd a837ddb4 00000000 00000000
7f80: a82f7f80 a82f7f80 00000000 00000000 a82f7f90 a82f7f90 a82f7fac a8194d00
7fa0: 800451c0 00000000 00000000 8000e500 00000000 00000000 00000000 00000000
7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
7fe0: 00000000 00000000 00000000 00000000 00000013 00000000 ff9df7fd d5f5fedb
[<8041fa94>] (spi_imx_setupxfer) from [<8041e258>] (spi_bitbang_transfer_one+0x148/0x244)
[<8041e258>] (spi_bitbang_transfer_one) from [<8041c638>] (spi_pump_messages+0x308/0x480)
[ <1860:4018c:638>] (spi_pump_messages) from [<80045408>] (kthread_worker_fn+0x4c/0x164)
[<8004528c>] (kthread) from [<8000e500>] (ret_from_fork+0x14/0x34)
Code: e8bd8010 e92d4070 e1a05000 e24dd010 (e5900160)
---[ end trace ac4df25e44f27646 ]---

0 Kudos
Reply