From patchwork Fri Feb 21 15:41:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Haschka X-Patchwork-Id: 13985711 Received: from secgw1.intern.tuwien.ac.at (secgw1.intern.tuwien.ac.at [128.130.30.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5DFC8632E; Fri, 21 Feb 2025 15:41:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=128.130.30.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740152508; cv=none; b=BTitRZCleDrluEFtndUo8HJdQeQFW0zT3o8GanLxwNdXspbpl31l9T1J/UCxESXQOy69ZuQHAg3e5x+LE7AU8dJ+GQCnQU3R1sqM9yLgKunAfPDjGThgRNT2MVPAYu6+2AHr7xKMIrry/5WmNDJvmEG26kuxIdCrkzN2Ilnchbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740152508; c=relaxed/simple; bh=NHnVmROgJKgOicdXoX3szo0m8m9umbiZAT8YDQYRSB4=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; b=BOtkNCxZEgy8Lq5/+d9noXfVftAL58mJe28llA9hoZJphsD125ABsaRcwebqaiDFyms9VsypQn2m4OUI+qfCq+BU5Y70+dXpmnSCtVNXDApKMyeVWPSgwhGjdNIAtzIEIx8xZTlxrVeJZq6fChiPJfDFM+o44/sWsrxhokEEsKs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tuwien.ac.at; spf=pass smtp.mailfrom=tuwien.ac.at; arc=none smtp.client-ip=128.130.30.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tuwien.ac.at Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuwien.ac.at Received: from Kiteworks (kwmta1.intern.tuwien.ac.at [128.130.30.91]) by secgw1.intern.tuwien.ac.at (8.14.7/8.14.7) with ESMTP id 51LFaOsS004695; Fri, 21 Feb 2025 16:36:24 +0100 Received: from secgw1.intern.tuwien.ac.at ([128.130.30.71]) by totemomail.intern.tuwien.ac.at (Totemo SMTP Server) with SMTP ID 272; Fri, 21 Feb 2025 15:36:23 +0000 (GMT) Received: from edge19b.intern.tuwien.ac.at (edge19b.intern.tuwien.ac.at [IPv6:2001:629:1005:30::46]) by secgw1.intern.tuwien.ac.at (8.14.7/8.14.7) with ESMTP id 51LFaNnc004675 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 21 Feb 2025 16:36:23 +0100 Received: from mbx19b.intern.tuwien.ac.at (2001:629:1005:30::82) by edge19b.intern.tuwien.ac.at (2001:629:1005:30::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Fri, 21 Feb 2025 16:36:23 +0100 Received: from t197-243.demo.tuwien.ac.at (128.131.197.243) by mbx19b.intern.tuwien.ac.at (2001:629:1005:30::82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Fri, 21 Feb 2025 16:36:22 +0100 Date: Fri, 21 Feb 2025 16:41:02 +0100 From: Thomas Haschka To: , , , , Subject: Patch and bugfix in block/blk-mq.c to regain stability when using various SD Cards and Card Readers. Message-ID: Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: mbx19b.intern.tuwien.ac.at (2001:629:1005:30::82) To mbx19b.intern.tuwien.ac.at (2001:629:1005:30::82) Bug Fix: block: Improve stability of SD cards in Microsoft Surface GO 2 and possibly other devices. The commit 65a558f66c308 block: Improve performance for BLK_MQ_F_BLOCKING drivers basically made the use of SD cards in my Microsoft Surface GO 2 impossible. The cards do stop functioning after about 15 minutes. Mostly at io intensive tasks. As outlined in https://bugzilla.kernel.org/show_bug.cgi?id=218821 i bisected the problem that yielded an unstable operation of the cardreader on my Surface GO 2. I successfully reversed the commit 65a558f66c308 in 6.12.16 using the attached patch. As I suppose the bug introduced with this commit might hit other users of sd-cards in similar hardware I suggest this commit shall be reversed, even if the improved performance might be gone. All the best, Thomas Haschka diff '--color=auto' -urpN a/block/blk-mq.c b/block/blk-mq.c --- a/block/blk-mq.c 2025-02-21 14:01:47.000000000 +0100 +++ b/block/blk-mq.c 2025-02-21 15:52:51.848041852 +0100 @@ -1418,7 +1418,7 @@ void blk_execute_rq_nowait(struct reques } blk_mq_insert_request(rq, at_head ? BLK_MQ_INSERT_AT_HEAD : 0); - blk_mq_run_hw_queue(hctx, hctx->flags & BLK_MQ_F_BLOCKING); + blk_mq_run_hw_queue(hctx, false); } EXPORT_SYMBOL_GPL(blk_execute_rq_nowait); @@ -2322,8 +2322,6 @@ void blk_mq_run_hw_queue(struct blk_mq_h */ WARN_ON_ONCE(!async && in_interrupt()); - might_sleep_if(!async && hctx->flags & BLK_MQ_F_BLOCKING); - need_run = blk_mq_hw_queue_need_run(hctx); if (!need_run) { unsigned long flags; @@ -2342,7 +2340,8 @@ void blk_mq_run_hw_queue(struct blk_mq_h return; } - if (async || !cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask)) { + if (async || (hctx->flags & BLK_MQ_F_BLOCKING) || + !cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask)) { blk_mq_delay_run_hw_queue(hctx, 0); return; } @@ -2477,7 +2476,7 @@ void blk_mq_start_hw_queue(struct blk_mq { clear_bit(BLK_MQ_S_STOPPED, &hctx->state); - blk_mq_run_hw_queue(hctx, hctx->flags & BLK_MQ_F_BLOCKING); + blk_mq_run_hw_queue(hctx, false); } EXPORT_SYMBOL(blk_mq_start_hw_queue); @@ -2513,8 +2512,7 @@ void blk_mq_start_stopped_hw_queues(stru unsigned long i; queue_for_each_hw_ctx(q, hctx, i) - blk_mq_start_stopped_hw_queue(hctx, async || - (hctx->flags & BLK_MQ_F_BLOCKING)); + blk_mq_start_stopped_hw_queue(hctx, async); } EXPORT_SYMBOL(blk_mq_start_stopped_hw_queues); @@ -2572,8 +2570,6 @@ static void blk_mq_insert_requests(struc list_for_each_entry(rq, list, queuelist) { BUG_ON(rq->mq_ctx != ctx); trace_block_rq_insert(rq); - if (rq->cmd_flags & REQ_NOWAIT) - run_queue_async = true; } spin_lock(&ctx->lock); @@ -2739,7 +2735,7 @@ static void blk_mq_try_issue_directly(st if ((rq->rq_flags & RQF_USE_SCHED) || !blk_mq_get_budget_and_tag(rq)) { blk_mq_insert_request(rq, 0); - blk_mq_run_hw_queue(hctx, rq->cmd_flags & REQ_NOWAIT); + blk_mq_run_hw_queue(hctx, false); return; } diff '--color=auto' -urpN a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c --- a/drivers/scsi/scsi_lib.c 2025-02-21 14:01:47.000000000 +0100 +++ b/drivers/scsi/scsi_lib.c 2025-02-21 15:53:54.654044691 +0100 @@ -429,8 +429,7 @@ static void scsi_single_lun_run(struct s * but in most cases, we will be first. Ideally, each LU on the * target would get some limited time or requests on the target. */ - blk_mq_run_hw_queues(current_sdev->request_queue, - shost->queuecommand_may_block); + blk_mq_run_hw_queues(current_sdev->request_queue, false); spin_lock_irqsave(shost->host_lock, flags); if (!starget->starget_sdev_user)