Skip to content

Commit ec177e4

Browse files
Sean Andersonvinodkoul
authored andcommitted
dma: Add lockdep asserts to virt-dma
Add lockdep asserts to all functions with "vc.lock must be held by caller" in their documentation. This will help catch cases where these assumptions do not hold. Signed-off-by: Sean Anderson <sean.anderson@linux.dev> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Link: https://lore.kernel.org/r/20240308210034.3634938-4-sean.anderson@linux.dev Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 28ccf02 commit ec177e4

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

drivers/dma/virt-dma.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ static inline struct dma_async_tx_descriptor *vchan_tx_prep(struct virt_dma_chan
8181
*/
8282
static inline bool vchan_issue_pending(struct virt_dma_chan *vc)
8383
{
84+
lockdep_assert_held(&vc->lock);
85+
8486
list_splice_tail_init(&vc->desc_submitted, &vc->desc_issued);
8587
return !list_empty(&vc->desc_issued);
8688
}
@@ -96,6 +98,8 @@ static inline void vchan_cookie_complete(struct virt_dma_desc *vd)
9698
struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan);
9799
dma_cookie_t cookie;
98100

101+
lockdep_assert_held(&vc->lock);
102+
99103
cookie = vd->tx.cookie;
100104
dma_cookie_complete(&vd->tx);
101105
dev_vdbg(vc->chan.device->dev, "txd %p[%x]: marked complete\n",
@@ -146,6 +150,8 @@ static inline void vchan_terminate_vdesc(struct virt_dma_desc *vd)
146150
{
147151
struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan);
148152

153+
lockdep_assert_held(&vc->lock);
154+
149155
list_add_tail(&vd->node, &vc->desc_terminated);
150156

151157
if (vc->cyclic == vd)
@@ -160,6 +166,8 @@ static inline void vchan_terminate_vdesc(struct virt_dma_desc *vd)
160166
*/
161167
static inline struct virt_dma_desc *vchan_next_desc(struct virt_dma_chan *vc)
162168
{
169+
lockdep_assert_held(&vc->lock);
170+
163171
return list_first_entry_or_null(&vc->desc_issued,
164172
struct virt_dma_desc, node);
165173
}
@@ -177,6 +185,8 @@ static inline struct virt_dma_desc *vchan_next_desc(struct virt_dma_chan *vc)
177185
static inline void vchan_get_all_descriptors(struct virt_dma_chan *vc,
178186
struct list_head *head)
179187
{
188+
lockdep_assert_held(&vc->lock);
189+
180190
list_splice_tail_init(&vc->desc_allocated, head);
181191
list_splice_tail_init(&vc->desc_submitted, head);
182192
list_splice_tail_init(&vc->desc_issued, head);

0 commit comments

Comments
 (0)