OSDN Git Service

scsi: bnx2fc: Avoid using get_cpu() in bnx2fc_cmd_alloc()
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Fri, 6 May 2022 10:57:58 +0000 (12:57 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 17 May 2022 01:26:50 +0000 (21:26 -0400)
commit20f8932f979e7377a625f6e711bd4e84ec025d0b
tree99f9cb90000d07c703c08cf001ba086b6fcc07fa
parenta0548edf852a8776dade1e511694b2980c674e2a
scsi: bnx2fc: Avoid using get_cpu() in bnx2fc_cmd_alloc()

Using get_cpu() leads to disabling preemption and in this context it is not
possible to acquire the following spinlock_t on PREEMPT_RT because it
becomes a sleeping lock.

Commit 0ea5c27583e1 ("[SCSI] bnx2fc: common free list for cleanup
commands") says that it is using get_cpu() as a fix in case the CPU is
preempted.  While this might be true, the important part is that it is now
using the same CPU for locking and unlocking while previously it always
relied on smp_processor_id().  The date structure itself is protected with
a lock so it does not rely on CPU-local access.

Replace get_cpu() with raw_smp_processor_id() to obtain the current CPU
number which is used as an index for the per-CPU resource.

Link: https://lore.kernel.org/r/20220506105758.283887-5-bigeasy@linutronix.de
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/bnx2fc/bnx2fc_io.c