From patchwork Wed Jun 5 21:52:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shantanu Goel X-Patchwork-Id: 801873 Received: from sonic304-25.consmr.mail.gq1.yahoo.com (sonic304-25.consmr.mail.gq1.yahoo.com [98.137.68.206]) (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 404AE136E1F for ; Wed, 5 Jun 2024 22:32:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=98.137.68.206 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717626751; cv=none; b=iW8CQB4jg+tJE2JfNpDOjYx7irL1R6yD0gJ/E0vEiV4W4XfbN/krXCGAS1Uk/oZ1JTIgU5gzfUVYaeVV382P71aOCCI5z5WXApXV32wGpJRQBCbp5LqadB7x4a/dtrHvO3OKfHjqSNdXiHPhgan5XMrVJcDnhV03qgy8uDTmupM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717626751; c=relaxed/simple; bh=yVX8r4qEnwDYzTpdDCUC/a6Wns6YVRUvt9z3s9GeARo=; h=Date:From:To:Cc:Message-ID:Subject:MIME-Version:Content-Type: References; b=nAskPTxdLSo1vTxi/vW2UKIyF4ywHnM50dGnr60HVm0Wop8ymuDR5KC/n/Hh7fkg/uDyZhTBQKqw5puxAlCui1iEXVs9CmYWBv8cTn6a+dNhANMXt1wCoslYUlIFGDJu+7DOUyMXJJ8OjOBm5o5ALQRBK+hETgeStMOQ7h6WxUo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=yahoo.com; spf=pass smtp.mailfrom=yahoo.com; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b=pCinrNqP; arc=none smtp.client-ip=98.137.68.206 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=yahoo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yahoo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b="pCinrNqP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1717626749; bh=yVX8r4qEnwDYzTpdDCUC/a6Wns6YVRUvt9z3s9GeARo=; h=Date:From:To:Cc:Subject:References:From:Subject:Reply-To; b=pCinrNqPvUJE1Px089QtGpE/IsHgfIgJ4WImlMTlpuBPJciO6C+ETkHWATELlFhfT9vCuCNvN7HSCIjSfkmR2GoZjXf1AKz6EXW8b7qHbAeGqjfQBtKdFB9wMQ1ZgTz+saODcdhpS7JbcexGAqFKDLjgUKtIoI6rMbzQAiosQ6v0Cye97A6KLgzEhFfWPyy9Jq0HgJLk0XXzu/JGVAqaiR5XP7JpUuUx0BR2Z9LHdwW89M5uIkzOSQHQQ5Qt9fxfvImkD59RI5snk7yz+9vHjn2gpLxxWgUfYksZxPI4Qc41QM2W7oFEDYlzaVkjQRJNk3OFMbx1gtXHJbVoj+vBHQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1717626749; bh=K9Vl9ix0Fxf1rQtDZb4B6K3NtS3WRCL+eUgP1PQF7G0=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=og4p3FJMxVS4/644njhU/B43QVkkRhqszLL/LPnwpUJ6V3WmIYPhcNaiD/q6R5/E/BPij+YqGGUjSDg0jihhVTo1pMJNyFobVnOydsXKkVHSgJj5dZNth63nfYnxhWcWSnUOjeGdRSaGgLwuCTpMGVdJkeT1C8p+UJWaACVmoUwmCpU2Hx6k9rJ9eS4JKOeXcPJiUO4ewgvkIqzjdqvTWyM9sLRbMglbM9YUDhzRiYRDkVFbUSXwnWx66HSAMEPMD46uy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Di_wNzscJzpNjVsjvvdspQ8vF4aygwZDphFMYELH1safSjmagQ0EhkSrempLKEHiQi8 7AtUPbdy7KuIUQG.VyZclhFgRNMFx1Zxl2kWuMNgpsHGSNlaCsnBGfK5iUe4u7Rlpg_5HMdQnHaQ IxuMaE_qnCy0Xwbut8WWE04nq4.glPaqTgXn6ihsl922vhqFQ1swgJ88hjPXvKaq4 X-Sonic-MF: X-Sonic-ID: 8cadc2be-f04d-4de7-ab7f-9a2074382d89 Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.gq1.yahoo.com with HTTP; Wed, 5 Jun 2024 22:32:29 +0000 Date: Wed, 5 Jun 2024 21:52:00 +0000 (UTC) From: Shantanu Goel To: Oliver Neukum Cc: "linux-usb@vger.kernel.org" , "linux-scsi@vger.kernel.org" Message-ID: <675774215.2024605.1717624320352@mail.yahoo.com> Subject: [PATCH] uas: set host status byte on data completion error Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <675774215.2024605.1717624320352.ref@mail.yahoo.com> X-Mailer: WebService/1.1.22407 YMailNorrin Hi, I have a disk enclosure which is prone to data completion errors during initialization and because the UAS driver only sets the resid on a data completion error and not the host status byte, the SD driver ends up using invalid zero'ed data. The attached patch against v6.6.32 fixes this by setting the host status byte to DID_ERROR so the SD driver will notice the error and retry the command. This bug is present in all stable kernels (4.19, 5.4, 5.15, 6.1, 6,6) and the current 6.9.3 kernel. This is the behavior prior to applying the patch. [   11.872824] sd 0:0:0:1: [sdf] tag#9 data cmplt err -75 uas-tag 1 inflight: [   11.872826] sd 0:0:0:1: [sdf] tag#9 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00 [   11.872830] sd 0:0:0:1: [sdf] Sector size 0 reported, assuming 512. [   11.872995] sd 2:0:0:1: [sdn] Preferred minimum I/O size 4096 bytes [   11.872996] sd 2:0:0:1: [sdn] Optimal transfer size 33553920 bytes not a multiple of preferred minimum block size (4096 bytes) [   11.873466] sd 1:0:0:0: [sdd] tag#29 data cmplt err -75 uas-tag 1 inflight: [   11.873468] sd 1:0:0:0: [sdd] tag#29 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00 [   11.873472] sd 1:0:0:0: [sdd] Sector size 0 reported, assuming 512. [   11.873824] sd 7:0:0:0: [sde] Attached SCSI disk [   11.874064] sd 3:0:0:1: [sdk] tag#16 data cmplt err -75 uas-tag 1 inflight: [   11.874065] sd 3:0:0:1: [sdk] tag#16 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00 [   11.874070] sd 3:0:0:1: [sdk] Sector size 0 reported, assuming 512. [   11.874465] sd 5:0:0:0: [sdo] tag#10 data cmplt err -75 uas-tag 1 inflight: [   11.874466] sd 5:0:0:0: [sdo] tag#10 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00 [   11.874474] sd 5:0:0:0: [sdo] Sector size 0 reported, assuming 512. [   11.876151] sd 4:0:0:1: [sdj] tag#10 data cmplt err -75 uas-tag 2 inflight: [   11.876153] sd 4:0:0:1: [sdj] tag#10 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00 [   11.876158] sd 4:0:0:1: [sdj] Sector size 0 reported, assuming 512. After applying the patch I no longer see the zero sector sizes above and all sizes are detected correctly despite the presence of completion errors. Thanks Signed-off-by: Shantanu Goel --- .orig/drivers/usb/storage/uas.c 2024-06-02 11:46:49.144457253 -0400 +++ linux-6.6.32-1.sg.1.el9.x86_64/drivers/usb/storage/uas.c 2024-06-02 11:44:21.523375517 -0400 @@ -422,6 +422,7 @@ uas_log_cmd_state(cmnd, "data cmplt err", status); /* error: no data transfered */ scsi_set_resid(cmnd, sdb->length); + set_host_byte(cmnd, DID_ERROR); } else { scsi_set_resid(cmnd, sdb->length - urb->actual_length); }