Skip to contentSkip to conversation

bus: mhi: ep: Add support for suspending and resuming channels

bug report Dan Carpenter 2 participants 2 messages Jan 17, 2023 – Jan 23, 2023 MHI bus

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 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.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);
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 6 lines

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.

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
மணிவண்ணன் சதாசிவம்