Skip to content

Commit 75ff85a

Browse files
Ira Snyderozbenh
authored andcommitted
carma-fpga: fix lockdep warning
Lockdep occasionally complains with the message: INFO: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected This is caused by calling videobuf_dma_unmap() under spin_lock_irq(). To fix the warning, we drop the lock before unmapping and freeing the buffer. Signed-off-by: Ira W. Snyder <iws@ovro.caltech.edu> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
1 parent 6d45584 commit 75ff85a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/misc/carma/carma-fpga.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,7 @@ static ssize_t data_read(struct file *filp, char __user *ubuf, size_t count,
10791079
struct fpga_reader *reader = filp->private_data;
10801080
struct fpga_device *priv = reader->priv;
10811081
struct list_head *used = &priv->used;
1082+
bool drop_buffer = false;
10821083
struct data_buf *dbuf;
10831084
size_t avail;
10841085
void *data;
@@ -1166,10 +1167,12 @@ static ssize_t data_read(struct file *filp, char __user *ubuf, size_t count,
11661167
* One of two things has happened, the device is disabled, or the
11671168
* device has been reconfigured underneath us. In either case, we
11681169
* should just throw away the buffer.
1170+
*
1171+
* Lockdep complains if this is done under the spinlock, so we
1172+
* handle it during the unlock path.
11691173
*/
11701174
if (!priv->enabled || dbuf->size != priv->bufsize) {
1171-
videobuf_dma_unmap(priv->dev, &dbuf->vb);
1172-
data_free_buffer(dbuf);
1175+
drop_buffer = true;
11731176
goto out_unlock;
11741177
}
11751178

@@ -1178,6 +1181,12 @@ static ssize_t data_read(struct file *filp, char __user *ubuf, size_t count,
11781181

11791182
out_unlock:
11801183
spin_unlock_irq(&priv->lock);
1184+
1185+
if (drop_buffer) {
1186+
videobuf_dma_unmap(priv->dev, &dbuf->vb);
1187+
data_free_buffer(dbuf);
1188+
}
1189+
11811190
return count;
11821191
}
11831192

0 commit comments

Comments
 (0)