Re: [PATCH 17/31] swim: Convert to blocking queue

Laurent Vivier <[email protected]> Tue, 21 Jul 2026 08:03:16 +0200
Newsgroups org.kernel.vger.linux-m68k,org.kernel.vger.linux-block,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Le 16/07/2026 =C3=A0 12:02, Finn Thain a =C3=A9crit=C2=A0:
> These drives are slow: completing a request can take hundreds of
> milliseconds. Delays are managed by disabling interrupts judiciously and
> sleeping opportunistically.
>=20
> 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.
>=20
> Adopt BLK_MQ_F_BLOCKING and remove the spinlock. Use a mutex to serializ=
e
> requests from the two request queues. (The chip cannot simultaneously
> process requests on both internal and external drive.)
>=20
> Cc: Omar Sandoval <[email protected]>
> Fixes: e3896d77b702 ("swim: convert to blk-mq")
> Signed-off-by: Finn Thain <[email protected]>
> ---
>   drivers/block/swim.c | 11 +++--------
>   1 file changed, 3 insertions(+), 8 deletions(-)
>=20

Reviewed-by: Laurent Vivier <[email protected]>

> diff --git a/drivers/block/swim.c b/drivers/block/swim.c
> index e2a8c4ba4e39..6f93ebaaffb7 100644
> --- a/drivers/block/swim.c
> +++ b/drivers/block/swim.c
> @@ -211,7 +211,6 @@ enum head {
>  =20
>   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 =3D hctx->queue->queuedata;
> -	struct swim_priv *swd =3D fs->swd;
>   	struct request *req =3D bd->rq;
>   	blk_status_t err;
>  =20
> -	if (!spin_trylock_irq(&swd->lock))
> -		return BLK_STS_DEV_RESOURCE;
> +	mutex_lock(&swim_mutex);
>  =20
>   	blk_mq_start_request(req);
>  =20
> @@ -560,7 +557,7 @@ static blk_status_t swim_queue_rq(struct blk_mq_hw_c=
tx *hctx,
>  =20
>   	err =3D BLK_STS_OK;
>   out:
> -	spin_unlock_irq(&swd->lock);
> +	mutex_unlock(&swim_mutex);
>   	return err;
>  =20
>   }
> @@ -839,11 +836,9 @@ static int swim_floppy_init(struct platform_device =
*pdev)
>   		return -EBUSY;
>   	}
>  =20
> -	spin_lock_init(&swd->lock);
> -
>   	for (drive =3D 0; drive < swd->floppy_count; drive++) {
>   		err =3D 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;
>  =20