From: Jiafei Pan <jiafei....@nxp.com> commit 3eacacf7f8bb8f757590054e9fd318f6a86e258b from http://source.codeaurora.org/external/qoriq/qoriq-components/linux
When enable debug kernel configs,there will be calltrace as below: 009: BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1 009: caller is dpaa2_io_query_fq_count+0xb8/0x130 009: CPU: 9 PID: 1 Comm: swapper/0 Not tainted 5.2.50-rt15-yocto-preempt-rt #1 009: Hardware name: NXP Layerscape LX2160ARDB (DT) 009: Call trace: 009: dump_backtrace+0x0/0x138 009: show_stack+0x24/0x30 009: dump_stack+0x9c/0xc4 009: debug_smp_processor_id+0xe0/0xe8 009: dpaa2_io_query_fq_count+0xb8/0x130 009: dpaa2_eth_stop+0xc4/0x1a8 009: __dev_close_many+0xac/0x130 009: __dev_change_flags+0xb4/0x1c0 009: dev_change_flags+0x3c/0x78 009: ic_close_devs+0x4c/0x70 009: ip_auto_config+0xf08/0xf44 009: do_one_initcall+0x64/0x2c8 009: kernel_init_freeable+0x338/0x3d8 009: kernel_init+0x18/0x104 009: ret_from_fork+0x10/0x1c Because smp_processor_id() should be invoked in preempt disable status. So, add preempt_disable/enable() to protect smp_processor_id(). Signed-off-by: Jiafei Pan <jiafei....@nxp.com> [Zhantao: change subject and commit log to align with the issue] Signed-off-by: Zhantao Tang <zhantao.t...@windriver.com> Signed-off-by: Meng Li <meng...@windriver.com> --- drivers/soc/fsl/dpio/dpio-service.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/soc/fsl/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c index 19f47ea9dab0..afc3b89b0fc5 100644 --- a/drivers/soc/fsl/dpio/dpio-service.c +++ b/drivers/soc/fsl/dpio/dpio-service.c @@ -58,8 +58,11 @@ static inline struct dpaa2_io *service_select_by_cpu(struct dpaa2_io *d, * If cpu == -1, choose the current cpu, with no guarantees about * potentially being migrated away. */ - if (cpu < 0) - cpu = smp_processor_id(); + if (cpu < 0) { + preempt_disable(); + cpu = smp_processor_id(); + preempt_enable(); + } /* If a specific cpu was requested, pick it up immediately */ return dpio_by_cpu[cpu]; -- 2.17.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#10359): https://lists.yoctoproject.org/g/linux-yocto/message/10359 Mute This Topic: https://lists.yoctoproject.org/mt/85324883/21656 Group Owner: linux-yocto+ow...@lists.yoctoproject.org Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-