Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sean Anderson and committed by
Vinod Koul
ec177e46 28ccf02c

+10
+10
drivers/dma/virt-dma.h
··· 81 81 */ 82 82 static inline bool vchan_issue_pending(struct virt_dma_chan *vc) 83 83 { 84 + lockdep_assert_held(&vc->lock); 85 + 84 86 list_splice_tail_init(&vc->desc_submitted, &vc->desc_issued); 85 87 return !list_empty(&vc->desc_issued); 86 88 } ··· 97 95 { 98 96 struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan); 99 97 dma_cookie_t cookie; 98 + 99 + lockdep_assert_held(&vc->lock); 100 100 101 101 cookie = vd->tx.cookie; 102 102 dma_cookie_complete(&vd->tx); ··· 150 146 { 151 147 struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan); 152 148 149 + lockdep_assert_held(&vc->lock); 150 + 153 151 list_add_tail(&vd->node, &vc->desc_terminated); 154 152 155 153 if (vc->cyclic == vd) ··· 166 160 */ 167 161 static inline struct virt_dma_desc *vchan_next_desc(struct virt_dma_chan *vc) 168 162 { 163 + lockdep_assert_held(&vc->lock); 164 + 169 165 return list_first_entry_or_null(&vc->desc_issued, 170 166 struct virt_dma_desc, node); 171 167 } ··· 185 177 static inline void vchan_get_all_descriptors(struct virt_dma_chan *vc, 186 178 struct list_head *head) 187 179 { 180 + lockdep_assert_held(&vc->lock); 181 + 188 182 list_splice_tail_init(&vc->desc_allocated, head); 189 183 list_splice_tail_init(&vc->desc_submitted, head); 190 184 list_splice_tail_init(&vc->desc_issued, head);