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: 13687631 Received: from sonic322-19.consmr.mail.gq1.yahoo.com (sonic322-19.consmr.mail.gq1.yahoo.com [98.137.70.82]) (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 E0EB06FD0 for ; Wed, 5 Jun 2024 22:22:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=98.137.70.82 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717626144; cv=none; b=LSV5fRpr2VCAFl+/0/MN7iqPGj90LBmVdsqofzyzl0J/TmEMQPUgQRzmQhX+4PNF4dXAX7CljKjTVPoGgzNLsy6PRkCO9WxuSphBJQc7J0TyhyZXPtWi9GceLp4CeCVOBFhe+us6Yo9sgcwNpqR3YiwWbZatVbdwM3ILwpuk3Ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717626144; c=relaxed/simple; bh=yVX8r4qEnwDYzTpdDCUC/a6Wns6YVRUvt9z3s9GeARo=; h=Date:From:To:Cc:Message-ID:Subject:MIME-Version:Content-Type: References; b=HgSXrSUwvRMkQgEOR9AAQQXLfRSVR0OpnpPKloH/mPulDaITXLwSo9ZJyfI44EaHDOb7XWsk8qs1h+e2YCSumOPZFw0IMOSsgOdmnm4Ywwsfk8G6JZ4KTT5Sj1Ttu7atQKmD0egRGSND/dockcKcVb6Z/FxRCOxA/bvBOTUegk0= 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=PRbf//X5; arc=none smtp.client-ip=98.137.70.82 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="PRbf//X5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1717626142; bh=yVX8r4qEnwDYzTpdDCUC/a6Wns6YVRUvt9z3s9GeARo=; h=Date:From:To:Cc:Subject:References:From:Subject:Reply-To; b=PRbf//X5Wap1ifWf8b6L57KS2gVBv4MTWqKHM1l8BCD+WcHw2gGUjw7dULjfgLomA+8eRvb/fedcs/MdcjrvJP4i5mA5Y7ocxXkO8e52KOoFPssVyHPfUGMweKWYXnSf4r5jvdtrO2QLoogyehbat3f1ZC+muYePF9+/p8CYUzraBp+Fe76m7KkVFzOs9Sq99BEGXlne/PI9AnCLPMPbCcZU1d8UPTpbngx0p6eFC1wIDH8lXqEuHP2hVnFOdwky0q9QAN7IxtSoC0ZZIxR3oiwl2P1r5Cau3FjS4IRZda7s+VywinyyUZLcwrFrff5BknwvhcP1DvG9CjFm/djk4Q== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1717626142; bh=5YvTXGBZsAoG+n+SslNDQdJIKTLeg2Uom4Bv3m3nyJk=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=AFC1KojFlZ++92T7QvfB72U3QIJoBUhFaB0UJD43gik3WFNhnnaqv6FofaSZ8Pg4IwTFt1ytqSY8LTZpzCvYAoDoo0Q92+ptoGKAGIf46EpS+1aaB2YEUkjAcS5l65eurvsSD729sfoA+GAT/WnC66tWhQnLRNP5gyapoabQpOaRc7pbHkcgygzH4dP4WDir0Wt9KTmdIrwAubmWNaqOFJz5LUyRKSaXg5maTp49MCa3q+QOtxlx3pt+94K0j6S/0NQ9jc+a7ftUovh3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vvdspQ8vF4aygwZDphFMYELH1safSjmagQ0EhkSrempLKEHiQi8 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 sonic322.consmr.mail.gq1.yahoo.com with HTTP; Wed, 5 Jun 2024 22:22:22 +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-usb@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); }