use SPI and timer respectively, which are good, but an error occurs when the timer uses spi to read the chip data. Why is this? I am using the imx6sx board. The kernel version is linux imx6sxsabresd 5.4.24-2.1.0+gbabac008e5cf #1 SMP PREEMPT Sun Jan 31 06:20:10 UTC 2021 armv7l GNU/Linux. The error message is as follows:
BUG: scheduling while atomic: swapper/0/0/0x00000102
[ 698.793258] Modules linked in: di(O) [last unloaded: di]
[ 698.798621] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G O 5.4.24-2.1.0+gbabac008e5cf #1
[ 698.807678] Hardware name: Freescale i.MX6 SoloX (Device Tree)
[ 698.813566] [<801107b8>] (unwind_backtrace) from [<8010b684>] (show_stack+0x10/0x14)
[ 698.821344] [<8010b684>] (show_stack) from [<80bd6aec>] (dump_stack+0x90/0xa4)
[ 698.828595] [<80bd6aec>] (dump_stack) from [<80154338>] (__schedule_bug+0x70/0x84)
[ 698.836195] [<80154338>] (__schedule_bug) from [<80bee434>] (__schedule+0x3b4/0x4cc)
[ 698.843957] [<80bee434>] (__schedule) from [<80bee5ac>] (schedule+0x60/0x104)
[ 698.851118] [<80bee5ac>] (schedule) from [<80bf23f8>] (schedule_timeout+0x168/0x288)
[ 698.858886] [<80bf23f8>] (schedule_timeout) from [<80bef614>] (wait_for_completion_timeout+0xb0/0x124)
[ 698.868228] [<80bef614>] (wait_for_completion_timeout) from [<806f5e54>] (spi_imx_transfer+0x2d0/0x464)
[ 698.877648] [<806f5e54>] (spi_imx_transfer) from [<806f039c>] (spi_bitbang_transfer_one+0x50/0xa0)
[ 698.886645] [<806f039c>] (spi_bitbang_transfer_one) from [<806ed448>] (spi_transfer_one_message+0x198/0x468)
[ 698.896501] [<806ed448>] (spi_transfer_one_message) from [<806eda10>] (__spi_pump_messages+0x2f8/0x53c)
[ 698.905915] [<806eda10>] (__spi_pump_messages) from [<806ede08>] (__spi_sync+0x1a8/0x1b0)
[ 698.914109] [<806ede08>] (__spi_sync) from [<806ede34>] (spi_sync+0x24/0x3c)
[ 698.921197] [<806ede34>] (spi_sync) from [<7f0003a0>] (mcp23s17_read_regs.constprop.0+0xe8/0x134 [di])
[ 698.930547] [<7f0003a0>] (mcp23s17_read_regs.constprop.0 [di]) from [<7f000424>] (timer_function+0x38/0x74 [di])
[ 698.940759] [<7f000424>] (timer_function [di]) from [<80190be4>] (call_timer_fn.constprop.0+0x24/0x98)
[ 698.950089] [<80190be4>] (call_timer_fn.constprop.0) from [<8019127c>] (run_timer_softirq+0x3e0/0x3f8)
[ 698.959420] [<8019127c>] (run_timer_softirq) from [<801022ac>] (__do_softirq+0x104/0x278)
[ 698.967634] [<801022ac>] (__do_softirq) from [<80135690>] (irq_exit+0xb0/0xd8)
[ 698.974895] [<80135690>] (irq_exit) from [<80178328>] (__handle_domain_irq+0x60/0xb0)
[ 698.982763] [<80178328>] (__handle_domain_irq) from [<8049e4d8>] (gic_handle_irq+0x4c/0x90)
[ 698.991142] [<8049e4d8>] (gic_handle_irq) from [<80101a8c>] (__irq_svc+0x6c/0xa8)
[ 698.998635] Exception stack(0x81201f20 to 0x81201f68)
[ 699.003712] 1f20: 00000000 000245e4 9f9b69f4 801199c0 81200000 00000000 81204f28 81204f64
[ 699.011908] 1f40: 81185670 00000000 81201f78 00000000 00000000 81201f70 80108904 80108908
[ 699.020095] 1f60: 600f0013 ffffffff
[ 699.023614] [<80101a8c>] (__irq_svc) from [<80108908>] (arch_cpu_idle+0x38/0x3c)
[ 699.031043] [<80108908>] (arch_cpu_idle) from [<8015abac>] (do_idle+0x22c/0x29c)
[ 699.038464] [<8015abac>] (do_idle) from [<8015af10>] (cpu_startup_entry+0x18/0x1c)
[ 699.046063] [<8015af10>] (cpu_startup_entry) from [<81100da8>] (start_kernel+0x458/0x484)
Is it a driver program? or your program running in user space? have you try to use ioctl like spidev?
I just added the work queue