bus: mhi: ep: Add support for suspending and resuming channels
Hello Manivannan Sadhasivam,
The patch e4b7b5f0f30a: "bus: mhi: ep: Add support for suspending and resuming channels" from Apr 5, 2022, leads to the following Smatch static checker warning:
drivers/bus/mhi/ep/main.c:1141 mhi_ep_resume_channels() warn: sleeping in atomic context
drivers/bus/mhi/ep/main.c
1129 void mhi_ep_resume_channels(struct mhi_ep_cntrl *mhi_cntrl)
1130 {
1131 struct mhi_ep_chan *mhi_chan;
1132 u32 tmp;
1133 int i;
1134
1135 for (i = 0; i < mhi_cntrl->max_chan; i++) {
1136 mhi_chan = &mhi_cntrl->mhi_chan[i];
1137
1138 if (!mhi_chan->mhi_dev)
1139 continue;
1140
--> 1141 mutex_lock(&mhi_chan->lock);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^This is called from mhi_ep_set_m0_state(). The mhi_ep_set_m0_state() function takes a spinlock so we can't take a mutex if we're holding a spinlock.
Enable CONFIG_DEBUG_ATOMIC_SLEEP for more information.
regards,
dan carpenter
Manivannan Sadhasivam
maintainerQuoted 25 lines · Dan Carpenter
Hello Manivannan Sadhasivam,
The patch
e4b7b5f0f30a: "bus: mhi: ep: Add support for suspending and resuming channels" from Apr 5, 2022, leads to the following Smatch static checker warning:drivers/bus/mhi/ep/main.c:1141 mhi_ep_resume_channels() warn: sleeping in atomic context
drivers/bus/mhi/ep/main.c1129 void mhi_ep_resume_channels(struct mhi_ep_cntrl *mhi_cntrl) 1130 { 1131 struct mhi_ep_chan *mhi_chan; 1132 u32 tmp; 1133 int i; 1134 1135 for (i = 0; i < mhi_cntrl->max_chan; i++) { 1136 mhi_chan = &mhi_cntrl->mhi_chan[i]; 1137 1138 if (!mhi_chan->mhi_dev) 1139 continue; 1140 --> 1141 mutex_lock(&mhi_chan->lock); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 6 lines
This is called from
mhi_ep_set_m0_state(). Themhi_ep_set_m0_state()function takes a spinlock so we can't take a mutex if we're holding a spinlock.Enable
CONFIG_DEBUG_ATOMIC_SLEEPfor more information.
Thanks Dan for the report!
Submitted a fix now: https://lore.kernel.org/mhi/[email protected]/
Thanks,
Mani
Quoted 4 lines
regards,
dan carpenter
Signature · 1 line
மணிவண்ணன் சதாசிவம்