mirror of
https://github.com/torvalds/linux.git
synced 2026-07-31 11:37:06 +02:00
bus: mhi: host: Add spinlock to protect WP access when queueing TREs
Protect WP accesses such that multiple threads queueing buffers for incoming data do not race and access the same WP twice. Ensure read and write locks for the channel are not taken in succession by dropping the read lock from parse_xfer_event() such that a callback given to client can potentially queue buffers and acquire the write lock in that process. Any queueing of buffers should be done without channel read lock acquired as it can result in multiple locks and a soft lockup. Change-Id: Iaa5849da70acd6ece06469312186edc194c7f050 Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org> Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
This commit is contained in:
parent
4cdf3aac4d
commit
ba41ac151c
|
|
@ -673,6 +673,8 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl,
|
|||
mhi_del_ring_element(mhi_cntrl, tre_ring);
|
||||
local_rp = tre_ring->rp;
|
||||
|
||||
read_unlock_bh(&mhi_chan->lock);
|
||||
|
||||
/* notify client */
|
||||
mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result);
|
||||
|
||||
|
|
@ -698,6 +700,8 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl,
|
|||
kfree(buf_info->cb_buf);
|
||||
}
|
||||
}
|
||||
|
||||
read_lock_bh(&mhi_chan->lock);
|
||||
}
|
||||
break;
|
||||
} /* CC_EOT */
|
||||
|
|
@ -1270,6 +1274,9 @@ int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan,
|
|||
int eot, eob, chain, bei;
|
||||
int ret;
|
||||
|
||||
/* Protect accesses for reading and incrementing WP */
|
||||
write_lock_bh(&mhi_chan->lock);
|
||||
|
||||
buf_ring = &mhi_chan->buf_ring;
|
||||
tre_ring = &mhi_chan->tre_ring;
|
||||
|
||||
|
|
@ -1305,6 +1312,8 @@ int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan,
|
|||
mhi_add_ring_element(mhi_cntrl, tre_ring);
|
||||
mhi_add_ring_element(mhi_cntrl, buf_ring);
|
||||
|
||||
write_unlock_bh(&mhi_chan->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user