From nobody Mon Jun 15 15:08:03 2026 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37B24E555 for ; Sun, 12 Apr 2026 15:36:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776008203; cv=none; b=E94clxMH/m1WNILnCwPCGiqAqIsDggzC3hRC3mYIOaYBs2zqJm8mK6eQusVL/hWc/7Iu3R1rsH9ymbk2CDz+MBS7+CZF+M0MelWC8wJlgprVyiXar6ljQjlCVWjN4amp0vNW7NHagnsqKo7qnhHY0LZs1hu5H+xCjiek4ekr19g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776008203; c=relaxed/simple; bh=tRRvi5YtRVXMY4QJsM9F6kWKMx/wNMB3++ordcHvjY0=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=d1fNBA6kMPhjUHpk0AQr7kf+uEqCoyTuAToaQzdwLmAUQSQDoKgNsELv5HBGY+jM1pkpz0LZwhm6RNZC55H2ryx5/xdhiZuXTAiadVg/3bcvFApkVQm7k+etBsEIva6pp3lDGl92icRKkg7SleRXyo/2QrUbmaOtXxPUTDC6zq4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=dH4q2jSr; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dH4q2jSr" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-82f220f1dabso536166b3a.1 for ; Sun, 12 Apr 2026 08:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776008201; x=1776613001; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=zIIsrwYoyoyzN/bzsbXwITV0IR2iB/tzp3wGCo7y0Zw=; b=dH4q2jSreBUceZPNq96jlFO823mQDHP1sJS3qfgaduuEDke2pyNjhy/Tu4KYeTzAIk Q2y1S+jlvhHz+H9b72OpyQLDa9zVdQllYnY+h12u7/zG/Z9D9yUTkjl7FTVJPSrcRest mehqBFyiRsxwJYRDScdb0om9tfuGWkJn68Mft+iWlshVmZneBrX9n7B2DdVPsPG6v4+u 9wX+P7Nt1Y5baYCuV7+LHMBau1hEeRrlkoUmmDAU2jSsFhCeLEfEMk3M/pv9gtDmZdmz 8aVkaxY9H3wFcTWR8QYuALhnBmACvypp4ekBY2QQpS3o3StC4iJTWE9Fz5HMBri9Jscz kl1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776008201; x=1776613001; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=zIIsrwYoyoyzN/bzsbXwITV0IR2iB/tzp3wGCo7y0Zw=; b=k+0NmGsk9PQdnf6l1/5LUO/HqzTgrMNhxkTRpAY+N0IJ/FjfJaluhUsRPYmoaDqvHx bPddnaWRsRsCxzBPPJTyvHnR/ZGbf932+VRCvXWKjbX2EoXzvDFwj4h7uZRprdONTgQJ 2CRBUWA74+khsmxVuDu+DS0cakCTcsogLleJimmDkfYFo3npzYRtJp8w2iOlgwxy/5D2 5AIyKBlTfl1TVoyYhBZBYpZQkSxjr122IHHdAnI4sPT/yp0hIt5puxYgku95VNLoyixz +XadnL5J/4nNWkfCm6TPqN4E3xzeyXBEOWmqs9k219FQJyxMM8wwgCk5k6Z8waN+kgyY xjuw== X-Forwarded-Encrypted: i=1; AFNElJ930gLiDUTSndgGYF6JmKpw75UAC9R/iJivafhQhx6/4CVQLtMss1DxH5nVBe/AOezlWPXtNVaosOrP4Ao=@vger.kernel.org X-Gm-Message-State: AOJu0YwgXXXJZ5sNC6PFqAaHPrIm1ZzQYxSMQ6A2L0SULcsxKA03Zmcs 64tnIevhLMhAccqZNeqsMgOfp8A0AuBXgJ0TIp8j6OfKz7NuVHM0pPHVtXQiu+kFxdq8Z2d/Gq7 iuP9ci+owdlzk7w== X-Received: from pfgs39.prod.google.com ([2002:a05:6a00:17a7:b0:82c:e9cd:a73f]) (user=ipylypiv job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3e05:b0:82f:37e3:ae72 with SMTP id d2e1a72fcca58-82f37e3b155mr2033486b3a.5.1776008201289; Sun, 12 Apr 2026 08:36:41 -0700 (PDT) Date: Sun, 12 Apr 2026 08:36:37 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260412153637.475606-1-ipylypiv@google.com> Subject: [PATCH v=2] ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands From: Igor Pylypiv To: Damien Le Moal , Niklas Cassel Cc: "Martin K. Petersen" , John Garry , Xingui Yang , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Pylypiv Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit 0ea84089dbf6 ("ata: libata-scsi: avoid Non-NCQ command starvation") introduced ata_scsi_requeue_deferred_qc() to handle commands deferred during resets or NCQ failures. This deferral logic completed commands with DID_SOFT_ERROR to trigger a retry in the SCSI mid-layer. However, DID_SOFT_ERROR is subject to scsi_cmd_retry_allowed() checks. ATA PASS-THROUGH commands sent via SG_IO ioctl have scmd->allowed set to zero. This causes the mid-layer to fail the command immediately instead of retrying, even though the command was never actually issued to the hardware. Switch to DID_REQUEUE to ensure these commands are inserted back into the request queue regardless of retry limits. Fixes: 0ea84089dbf6 ("ata: libata-scsi: avoid Non-NCQ command starvation") Reviewed-by: Damien Le Moal Signed-off-by: Igor Pylypiv --- Changes from v1: - Dropped the usage of set_host_byte() because it is logically a separate change from what this commit is fixing. set_host_byte() does not clear the status byte and the ML byte. drivers/ata/libata-scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 3b65df914ebb..cd607911d724 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -1692,7 +1692,7 @@ void ata_scsi_requeue_deferred_qc(struct ata_port *ap) /* * If we have a deferred qc when a reset occurs or NCQ commands fail, * do not try to be smart about what to do with this deferred command - * and simply retry it by completing it with DID_SOFT_ERROR. + * and simply requeue it by completing it with DID_REQUEUE. */ if (!qc) return; @@ -1701,7 +1701,7 @@ void ata_scsi_requeue_deferred_qc(struct ata_port *ap) ap->deferred_qc =3D NULL; cancel_work(&ap->deferred_qc_work); ata_qc_free(qc); - scmd->result =3D (DID_SOFT_ERROR << 16); + scmd->result =3D (DID_REQUEUE << 16); scsi_done(scmd); } =20 --=20 2.53.0.1213.gd9a14994de-goog