From: Dan Carpenter <dan.carpenter@oracle.com>
To: huangfq.daxian@gmail.com
Cc: linux-spi@vger.kernel.org
Subject: [bug report] mfd: ezx-pcap: Replace mutex_lock with spin_lock
Date: Wed, 26 Oct 2022 15:20:16 +0300 [thread overview]
Message-ID: <Y1kmAN62MalAODUL@kili> (raw)
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
reply other threads:[~2022-10-26 12:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y1kmAN62MalAODUL@kili \
--to=dan.carpenter@oracle.com \
--cc=huangfq.daxian@gmail.com \
--cc=linux-spi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox