* [bug report] mfd: ezx-pcap: Replace mutex_lock with spin_lock
@ 2022-10-26 12:20 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-10-26 12:20 UTC (permalink / raw)
To: huangfq.daxian; +Cc: linux-spi
Hello Fuqian Huang,
The patch b65dc4f6b339: "mfd: ezx-pcap: Replace mutex_lock with
spin_lock" from Aug 13, 2019, leads to the following Smatch static
checker warning:
drivers/spi/spi.c:1666 __spi_pump_transfer_message()
warn: sleeping in atomic context
One problematic call tree is:
ezx_pcap_set_bits() <- disables preempt
-> ezx_pcap_putget()
-> spi_sync()
drivers/mfd/ezx-pcap.c
109 int ezx_pcap_set_bits(struct pcap_chip *pcap, u8 reg_num, u32 mask, u32 val)
110 {
111 unsigned long flags;
112 int ret;
113 u32 tmp = PCAP_REGISTER_READ_OP_BIT |
114 (reg_num << PCAP_REGISTER_ADDRESS_SHIFT);
115
116 spin_lock_irqsave(&pcap->io_lock, flags);
This use to be a mutex but it was change to a spinlock to avoid a
sleeping in atomic bug.
117 ret = ezx_pcap_putget(pcap, &tmp);
But ezx_pcap_putget() calls spi_sync() which takes a mutex so the fix
is not complete.
118 if (ret)
119 goto out_unlock;
120
121 tmp &= (PCAP_REGISTER_VALUE_MASK & ~mask);
122 tmp |= (val & mask) | PCAP_REGISTER_WRITE_OP_BIT |
123 (reg_num << PCAP_REGISTER_ADDRESS_SHIFT);
124
125 ret = ezx_pcap_putget(pcap, &tmp);
126 out_unlock:
127 spin_unlock_irqrestore(&pcap->io_lock, flags);
128
129 return ret;
130 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-26 12:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-26 12:20 [bug report] mfd: ezx-pcap: Replace mutex_lock with spin_lock Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox