[PATCH v2 17/32] swim: Convert to blocking queue
From: Finn Thain <fthain@linux-m68k.org>
Date: 2026-08-17 01:57:02
Also in:
linux-m68k, lkml
Subsystem:
block layer, the rest · Maintainers:
Jens Axboe, Linus Torvalds
These drives are slow: completing a request can take hundreds of
milliseconds. Delays are managed by disabling interrupts judiciously and
sleeping opportunistically.
As of commit e3896d77b702 ("swim: convert to blk-mq"), a spinlock is
taken in irq mode as soon as a request is issued. That lock is held for
the duration of the request. Hence the driver sleeps while holding the
lock which is forbidden.
Adopt BLK_MQ_F_BLOCKING and remove the spinlock. Use a mutex to serialize
requests from the two request queues. (The chip cannot simultaneously
process requests on both internal and external drive.)
Cc: Omar Sandoval <redacted>
Fixes: e3896d77b702 ("swim: convert to blk-mq")
Reviewed-by: Laurent Vivier <redacted>
Signed-off-by: Finn Thain <fthain@linux-m68k.org>
---
drivers/block/swim.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index 33374498d621..8c8b157e2d74 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c@@ -211,7 +211,6 @@ enum head { struct swim_priv { struct swim __iomem *base; - spinlock_t lock; int floppy_count; struct floppy_state unit[FD_MAX_UNIT]; };
@@ -537,12 +536,10 @@ static blk_status_t swim_queue_rq(struct blk_mq_hw_ctx *hctx, const struct blk_mq_queue_data *bd) { struct floppy_state *fs = hctx->queue->queuedata; - struct swim_priv *swd = fs->swd; struct request *req = bd->rq; blk_status_t err; - if (!spin_trylock_irq(&swd->lock)) - return BLK_STS_DEV_RESOURCE; + mutex_lock(&swim_mutex); blk_mq_start_request(req);
@@ -560,7 +557,7 @@ static blk_status_t swim_queue_rq(struct blk_mq_hw_ctx *hctx, err = BLK_STS_OK; out: - spin_unlock_irq(&swd->lock); + mutex_unlock(&swim_mutex); return err; }
@@ -841,11 +838,9 @@ static int swim_floppy_init(struct platform_device *pdev) return -EBUSY; } - spin_lock_init(&swd->lock); - for (drive = 0; drive < swd->floppy_count; drive++) { err = blk_mq_alloc_sq_tag_set(&swd->unit[drive].tag_set, - &swim_mq_ops, 2, 0); + &swim_mq_ops, 2, BLK_MQ_F_BLOCKING); if (err) goto exit_put_disks;
--
2.52.0