From patchwork Tue Mar 25 13:02:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 876000 Delivered-To: patch@linaro.org Received: by 2002:a5d:5f4c:0:b0:38f:210b:807b with SMTP id cm12csp2640426wrb; Tue, 25 Mar 2025 06:03:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWwd8JSzdcKC4BnsteDHFiwn8nBlVoPDe70ezRE3frgybfjt4rWk57nbymokpjfabxqS+LS0A==@linaro.org X-Google-Smtp-Source: AGHT+IGM0P3G3j8xXY8VDI9NDnu9sjFphID7/Pjm23OG8KqRzQqHpazJhnpbqMbl45MVRyW7VU1M X-Received: by 2002:a05:6102:3f8d:b0:4c1:a66f:a468 with SMTP id ada2fe7eead31-4c542034c5bmr4606499137.22.1742907792596; Tue, 25 Mar 2025 06:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1742907792; cv=none; d=google.com; s=arc-20240605; b=Td2PhgAHSMq6qO6MPIATp8bJ04zb7EOb5ib2KIoKFa89zIsJaHW2p4Ah6UnJ9gjrJq l/bZ+y/UmC43nCGAHdyryIP22cwF+rcSG+7WMJHvheQg6hij4yhffpwG2SPhej0mNCJR SOUdkVvRYS4s5fjgL1b0v2Vx/7nqjt/nCed2IzJegKxncA4CfvtW/baJcqqTqxii2G9C kYp0biMGTBVXravqgbZSE5oIpSUDQyiYAYYLDdWLWauUqfKoQkOhPoBeY0R/oElhoQZ7 Y+UQoXm5GIMw+1IR7PR96cf67KszbcVIhoqNT8Li74dplE/q+P0sebJtMr9stAleJb1x F1tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=cQRr6w0G6zC7ZGJWBs0blumcTdX6WaxdGqlr3sVH2V0=; fh=jGkCgQFpl12bIbHrwRuwCPoRzXw5u9KWkPaD+pO9Pvo=; b=G1hf0ae4Gecb6W2EngogepRSwq1r8R9tEWryVfQuRG1s2Lt0I2tWLGINkNuaUELDro +3T70dNOKzCrC3dq70RmLFBd1Zon3mEfi4iQOZ65MZ5qnbcSzinipfEkUSwkXuxjiXis bd6ADlb5ioKLWIPwlgxZ0o0HKHv9tLU3C6Gkoe1bI++fNFV8t5CebzuZ5ljjI81czIpM l1V/K/6xoM8wR8GkKTqrNmE4OhMpySOSCO7UjLHYbBpdhCq1lbHWEpWBFlb3DesP3om4 PxcgQHB4/+PxvPCuVnEEsWxD0KX8mU832p9PK9LRr3C200yctvIVlaC1cRrM+IBrCJ0C mjpA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FDX/WoRF"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id ada2fe7eead31-4c50bed1b90si2148871137.332.2025.03.25.06.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 06:03:12 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FDX/WoRF"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9251C8192A; Tue, 25 Mar 2025 14:03:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="FDX/WoRF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ECF0281CAF; Tue, 25 Mar 2025 14:03:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E608981B42 for ; Tue, 25 Mar 2025 14:02:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4394036c0efso35161545e9.2 for ; Tue, 25 Mar 2025 06:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1742907778; x=1743512578; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=cQRr6w0G6zC7ZGJWBs0blumcTdX6WaxdGqlr3sVH2V0=; b=FDX/WoRFh1FFj9AX6cBMSUL7Hp/4jZg74LgCooQPFoP6KRItUiBHiAVgWrzfTgVWXS v72irrAKzPNeASdAu6sdvdaqi7wt5dWJLWlv5Y+ZTZqyw7dO6bdElbQLzk/m85pvman6 DocVYAgZB1PaGUCQnR00+nygMTUZGdLjhGVVLyX013792gcVnvpktW5l/TWc+Gw38c1c +/MxhYGtmNwffNH1wdngQr5wtPAeQlIY1QVcWLxM4ESP8mrkU2Gsf6nt+uMlu4z7nTmP djGrrEx5HUsdbuBFYgRRWn+0DTp9/NZUV2d/wjss4xAsFU/MkLfwKTs7BG5l1d2dq32g mzdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742907778; x=1743512578; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cQRr6w0G6zC7ZGJWBs0blumcTdX6WaxdGqlr3sVH2V0=; b=SwHllWgcEMd3VgA5OnvQiaNpEIiNgaLiz4Z9ENN/4+3Y45tKYs63JKEBoZGOmxy/Ys THJIy2tUsiKaP5E7jA7dbkLp4s206cfXhLclmxgMqTgRflGLBLI9en5+7nrM2RBrqOJC P+ld/b6U4nUEw8zBBNR9HNzE2p1X1uG4dpwBRSRKF2j5YoACXu4QZQCNPpPVG2rVRd6Q 7zsbzdJZNiUZF6jLPMY6Ie/q6I7ZdHFFbO1SbcMTBqjynnqRd1IEqQgGLSEb319K6YmS mDo8E0lKyJGAme9B5LEOhLBjAyk4M5lsSOW9JAeuFYILqOacYJ7Vv/C41knry2dlTjLf 4AvQ== X-Forwarded-Encrypted: i=1; AJvYcCWhUpRdACLRj1Qahlam6J/PHby6YpMhilpfxfsrElOTGV68nblfjwaYbr+NCxdXvJN/2isveZg=@lists.denx.de X-Gm-Message-State: AOJu0YyX8PMaX1ekmv/xC07i6peUDCTVQH+98z9oKYUQOUPSQqg+usDr fUKHdx3EXoDndkVwIGgcLBqbN7Fxu0mMqsIoNmy+zr2UTur9h16KyJYi20JhPW1RUtnzIU1FLzx /WeQ= X-Gm-Gg: ASbGncsDl3+lSSh1rqJfHGx9tRu+6drAdbiMkN66mSvIRlylPfgQVzXSLMc0/A/RO64 Yd4T/uAZkSxE+wKqgPHjQC5Wx0PPW5YRbMfLdTj00UG220Kspl15f/4WR3+mda3Xq3oVdEtQF5/ cKQ1crDhQw1yHbzfDswXkVg89+BL6f4wuH8t4F3dGnrhN5U2uX6yHoZLqvtBmWPadjazpY78dSf C5U3B2YWRdZpRUM+4FWhVDp1Pho+I9OuZ1n2PMLG2J8U9zNrTtIKaSvAC+pIJTFUpsaM5qoGbRT 7rLdik93UTwcMuSTGnLZYNRnsqGuzlr31vMoleqIikscGXvc9IIPtzxD57UDz+jc6L9E4TFARgz af6/ZX4UJBOVD X-Received: by 2002:a05:600c:4fc8:b0:43c:eea9:f45a with SMTP id 5b1f17b1804b1-43d509e43c1mr161154595e9.4.1742907778194; Tue, 25 Mar 2025 06:02:58 -0700 (PDT) Received: from toyger.tail248178.ts.net (i5E863BED.versanet.de. [94.134.59.237]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d440ed793sm204706095e9.39.2025.03.25.06.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 06:02:57 -0700 (PDT) From: Caleb Connolly Date: Tue, 25 Mar 2025 14:02:52 +0100 Subject: [PATCH 1/3] scsi: fix typo in setup_read_ext() MIME-Version: 1.0 Message-Id: <20250325-scsi-sync-on-write-v1-1-3575aa1342e0@linaro.org> References: <20250325-scsi-sync-on-write-v1-0-3575aa1342e0@linaro.org> In-Reply-To: <20250325-scsi-sync-on-write-v1-0-3575aa1342e0@linaro.org> To: Tom Rini Cc: Neil Armstrong , Marek Vasut , Quentin Schulz , u-boot@lists.denx.de, u-boot-qcom@groups.io, Caleb Connolly X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1077; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=HiJHUQ0As//uZbfHPVnNG4S8lluRU1JKy79JCOKudc0=; b=owEBbQKS/ZANAwAKAQWDMSsZX2S2AcsmYgBn4ql/6a+ai2uyx1sWJKoAqwsAiM6cl6H1o5OJS NBmvGoZFPuJAjMEAAEKAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZ+KpfwAKCRAFgzErGV9k tuLxEACNCEI8tvKAA79WUOm9AI/0qgmA1vQaryWAlpyjtDIFZi2Y90nD9yube6CyRdoSnt9ZeuH ND0pPw2ONQxGg8YFcb3wYFRRycc8A1RFl3VPXgZwk5k1rXJ02dGE0amzIWUnDA5PDuRa7XUB54X SPHSv7KXnedxaZZ3W8aAPsdphDyMWFwlgm/T/ILeqm8C8fUtHAkINndYPrlfoyOXrNFelc2DLYD pAlFDeSnk0rfGJiBdZgqveP/vYFyzahwlvqBPmtO5TX9x/ewmnthliFiqYdhlDUElzkSuVQtxsP COW4b6jKW2FARSUrL4Xj4q1RzwLUJVmjaZCkP+SpcZCVd9EAkeOIN00F4yN6D6SRZyfSdiI3OrM z+hVtjGW/Y81DABbRpHeQxddzGzTIuuJPlD9iY3U/jYw2xtNH8lamp9OHwB1DIBVDYpggulcMD0 uBULcq0yUQ4tdNHAUP1vWTPuGeYhVbTQsWxHTNIbcyP2aOVwbwcJ825ZzcxeN53LECvAADmObt3 jx1j+QhdVidsOAWOuVm8MdKs5GumJq73EhghNieoEz5XxBhx7GgkR9xQnFkw6Z6V4slyjvzSqjf oOfYLuOfUsQdBbWGx7VAI+xShh8z6BLq94YTzWz75fpS9f9QdlYs03nhF7MMEZWe7l4u39PzSqf tSTBXnNaUhZaDYw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This clears the 6th byte of cmd twice rather than setting the 9th byte to 0. Fix it. The only other command that sets the 9th byte is the 64-bit read, so this likely never caused issues in practise. Signed-off-by: Caleb Connolly Reviewed-by: Neil Armstrong --- drivers/scsi/scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index cd0b84c062252118d250b9305728e03f61736600..34ac47c03ab397ca999abf130d84ccbd3be4c419 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -89,9 +89,9 @@ static void scsi_setup_read_ext(struct scsi_cmd *pccb, lbaint_t start, pccb->cmd[5] = (unsigned char)start & 0xff; pccb->cmd[6] = 0; pccb->cmd[7] = (unsigned char)(blocks >> 8) & 0xff; pccb->cmd[8] = (unsigned char)blocks & 0xff; - pccb->cmd[6] = 0; + pccb->cmd[9] = 0; pccb->cmdlen = 10; pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */ debug("scsi_setup_read_ext: cmd: %02X %02X startblk %02X%02X%02X%02X blccnt %02X%02X\n", pccb->cmd[0], pccb->cmd[1], From patchwork Tue Mar 25 13:02:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 876001 Delivered-To: patch@linaro.org Received: by 2002:a5d:5f4c:0:b0:38f:210b:807b with SMTP id cm12csp2640527wrb; Tue, 25 Mar 2025 06:03:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVsn600edpiRy+SlzpDEe7HSFj40E7JDD6LRkmk9UjH9F3uX0yidNT+yjdZTH2yTtHr26MebA==@linaro.org X-Google-Smtp-Source: AGHT+IFeKy0JnKCCFWtB/Jnvrbs6NY1EPZTyjYHlFi/8T6j2YEiNQ9uQl+Bczxw9AXDU3NBKVw3X X-Received: by 2002:a05:6102:d92:b0:4bb:e36f:6a35 with SMTP id ada2fe7eead31-4c50d4fd54fmr11367048137.14.1742907801830; Tue, 25 Mar 2025 06:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1742907801; cv=none; d=google.com; s=arc-20240605; b=ZLSue2pzPnGVFcJ+GzaODfs6hTQMhk2p1l7SMiawxAdIR9cgnofY2UzE6aDHXQmdPG J/ztJtsJQ4z4g6CT8nkBDTySoxlccajxTHMcAev38wfFvZZbOoVCgCioPHkanU7PlLHY uiI6xffScrkajLAkHv+h1F8Ss/1Xj3gNwFyb24IJEfeApdsEfaiq9KEIPZXj0QQNB1aW oVdChgZKfdeMeCQsQk/Ij1WiyFIktn75x9w+45quUWgYSTi5FnpveB+tstJ2mbK+cgVR f45vnYCv7qgT2IImmkvJS04ODuvLNfC5l1+bQrzplKLxNcihe1Y1xIvsHmyI0xgSLNXI /jnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=qDDf4E2uyNrrtvf4WYsXEMCAV/TBdsnWGIJ5gvaCHG4=; fh=Q3/EKbfr208kSLUf033zMgzYb1ClrtAln1wBFQptiZA=; b=P/alqAoyxnirs/m8GRVG2B6wV14OQTLte3WuZcf+zSA2ePVKUOr9V8RiRf0ywfMvIX pTJtbSj1jWMnKHK7qEA1WfF2WApOvzgeVkT14mBdDs3md1Mdi4O0zclEuR7y8w/Zir6o TyrerD+7IDJBcVtp3g+AOgSXV94Y6A40KKa+hkNQOkzoFMteeACCK90jEOzDazO6tUyD gd8odpwOFSRn65k9KWnyTUBHrGS0jgqRRGuLpeZtTr6oP7/CDHWN5pHuIIsCN6cSrcMZ Kaenu9ZzJed1JXmVVk8mXaguxedYapXxkX4P95SLU68j5bSoIrxW+HtOBeaEbX3UA79f jEAg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AU440krG; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id ada2fe7eead31-4c50bffb98csi2246632137.351.2025.03.25.06.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 06:03:21 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AU440krG; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DFC1281DB4; Tue, 25 Mar 2025 14:03:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="AU440krG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C4F8F81D4F; Tue, 25 Mar 2025 14:03:02 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AF51C80EEF for ; Tue, 25 Mar 2025 14:03:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3912baafc58so4418685f8f.1 for ; Tue, 25 Mar 2025 06:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1742907780; x=1743512580; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=qDDf4E2uyNrrtvf4WYsXEMCAV/TBdsnWGIJ5gvaCHG4=; b=AU440krGh680OrlVge1fYwmTA2btoEG8ucXZFFILmbHEkxdn+QbTBRLxKGugQLqMo4 ji/pu/ftHmLGaV7tZPfFy58GayWZ0SAmNdUmapV/4nBVVc2B1jASOEuMsg9Zv2UrdKAj /Q9lVcD9DqjQfn1ukDY1Ue5ALmjsGhhgLhsnRBthg+75zILs3gdowAK8r8L494tT6GRx F4TH1YnpV1PmjADnxMYuqtyDYb/qfA+oA2gthY25h+ra28osmqoFnXkK8kKlBk2/3nrr 0xxYLPwnzwXEZdWFgASucM1VFtrBppRfxP3yUs8Oaaw2XG/g9AtwNy/jDIQVr+pmWTo2 DRHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742907780; x=1743512580; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qDDf4E2uyNrrtvf4WYsXEMCAV/TBdsnWGIJ5gvaCHG4=; b=HgWx6+XO4bTMwwlTk2H6rRXV3hVz/DkYkOdm1biTSbJ49Qo/w3nGupvPTcpxlmBNwF 2NRsYWFe4UoermGbJM75Uz9BiA6SN/54w5Aw5//hLh1pFSmrLq2i3E31NrlPmh3LwLxA 7nPJYJxZv8oUe1P/Xa9c+SD54atzyisQtPmdrBfUs7LXH2wBXONR8rspQuLcvIxLoUNM JNsngg3yWbd/bUfVR1Qw9UTwiKpkFjTRXzXp3mBk4vgI5cbA8nZqsyubKkDrMUQyVXW0 ZUlPkqLlImQMA7bn0PmU9rdlN1vovyJ2amN2jkOehH2qFfN2KK7f+YdjYp86EqnPtVyS 5HZw== X-Forwarded-Encrypted: i=1; AJvYcCWF3X9rCpy2QzLggUeSJOSS9qImXzLg+FyB2DmVFQDqHk2+NrNVLcuidwbCEpvkOuL4MlxHStE=@lists.denx.de X-Gm-Message-State: AOJu0YwBALX2WnVBIzfmubSSBiveu/EGA/JvOZWyVag1uLgaIzp1Q7Pf oOPSDdJ8bqIRSKdFus7ZWbjM7kQphiAtF630x/RNTlyMRNPVgoJUyjx+mqSqGzI= X-Gm-Gg: ASbGnctfRIjoGkLmAjx1mfguu2qLjEmqtbhssvXwao4poCoK5ADUHaNRL7Yd+wau4lT RDUOVaeSpssY57m3lkXmPpyfOpsq2yhguEs6USPJfaH18bgpsEIMuNesJ6lzl3PbNTUts0G+lD+ 9fH6By0Pkw7f3dH+FttTYU8MCAVpxTibeKqZHgbknrtoxoN7g0OJytgKUZ5cvMx6kdNisvRMxr6 z7/7eunmZdLLLj8nBVIRnFpeuA8RgD7bjs+EMnws4/vBsOHxWixtp49q66R3m/hnQdyYyNrr4DG 50lOb8BrmAih6QW/dqWgSIWg6kBR/4FrtBs1tYevSKXUCoOCvpb7fX0MK0QDH6C1itH6vCdj5CY fDbsGeeiUOSxr X-Received: by 2002:a05:6000:2cd:b0:391:412b:e22b with SMTP id ffacd0b85a97d-3997f903a95mr14713719f8f.18.1742907779577; Tue, 25 Mar 2025 06:02:59 -0700 (PDT) Received: from toyger.tail248178.ts.net (i5E863BED.versanet.de. [94.134.59.237]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d440ed793sm204706095e9.39.2025.03.25.06.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 06:02:58 -0700 (PDT) From: Caleb Connolly Date: Tue, 25 Mar 2025 14:02:53 +0100 Subject: [PATCH 2/3] scsi: de-dup calls to scsi_setup_write_ext() MIME-Version: 1.0 Message-Id: <20250325-scsi-sync-on-write-v1-2-3575aa1342e0@linaro.org> References: <20250325-scsi-sync-on-write-v1-0-3575aa1342e0@linaro.org> In-Reply-To: <20250325-scsi-sync-on-write-v1-0-3575aa1342e0@linaro.org> To: Tom Rini Cc: Neil Armstrong , Marek Vasut , Quentin Schulz , u-boot@lists.denx.de, u-boot-qcom@groups.io, Caleb Connolly X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1609; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=iP226MTRSqJtOurISKhFsv13XkZmwW2x67BMen9zMJk=; b=owEBbQKS/ZANAwAKAQWDMSsZX2S2AcsmYgBn4ql/TRFnbpKNkjvqgUM0U329+iDoZLfxNwSLq xgDt43GCJ6JAjMEAAEKAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZ+KpfwAKCRAFgzErGV9k tjJiD/sEjlrh1IKjBlAYfZomkL9fCGZvev8Kj9pTwtodFxrPZICKNsOkM8/btkBGhtrGBu3FL8o Hsr1OdybvHxce7/KXdAUJvdgZEFGJVc234NA5c2MhVN231+SZvRJcv/dx6cM2gFPr0S4jKPAThv hpy25ES9kgbmAAfTOpUu51b9W59J0LVhC3GKrAyEHmt2edikizV2Mi3GIExXnDV1SfrgdDGtkSZ ayCRa2YIVe5jeRtnNQDsTK9mSJiq4ct/WckzSGrHuBsRPVopEkr0VyyspXcvAxbaj6pT1R+5ZDQ CYWDw4sfd2LOTH7kP6f35ci2uRUiN/QEAPt+HU1pfT0fNwxjDK5s5QVVBfuViScmHeSdzpSARRi 2WQHxaUlOY+LUNC6TntC+REHdFRyjaFXsMk3NWWT/fcBhKHmMmHAeP2oCg9CmfFxfl8fKm1HWd2 6D4SPaBvsCeTxTEMDkNG/e2OLm54mNQERcKilI+SJ2X4W2UhwtKIcA6/cpWu4qwYTQCAdDSIgSr QbmwsuzxVL8RtLZdnhSUFvP6lkX5B48vey0IGGj8AIvR9nwQ28LQcBjVn69s3u+vHSPNZ7SuO/O 644sX/tuD/McyIT5O3pLyL3bbhk/GrM2tPoeZfLnQhsfySsvgRHK/1NXSDN1ndgi/o8+dtT+ClP ONE5L1uL3R6k5Uw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This gets called with the same parameter in two paths in scsi_write(), de-dup them to prepare for additional logic after the write. Signed-off-by: Caleb Connolly --- drivers/scsi/scsi.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 34ac47c03ab397ca999abf130d84ccbd3be4c419..1aa7fbdbb5278e387de72a3c3e73d19ea0342fff 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -220,25 +220,30 @@ static ulong scsi_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, pccb->dma_dir = DMA_TO_DEVICE; if (blks > max_blks) { pccb->datalen = block_dev->blksz * max_blks; smallblks = max_blks; - scsi_setup_write_ext(pccb, start, smallblks); - start += max_blks; - blks -= max_blks; } else { pccb->datalen = block_dev->blksz * blks; smallblks = (unsigned short)blks; - scsi_setup_write_ext(pccb, start, smallblks); - start += blks; - blks = 0; } + debug("%s: startblk " LBAF ", blccnt %x buffer %lx\n", __func__, start, smallblks, buf_addr); + scsi_setup_write_ext(pccb, start, smallblks); + if (scsi_exec(bdev, pccb)) { scsi_print_error(pccb); blkcnt -= blks; break; } + + if (blks > max_blks) { + start += max_blks; + blks -= max_blks; + } else { + start += blks; + blks = 0; + } buf_addr += pccb->datalen; } while (blks != 0); debug("%s: end startblk " LBAF ", blccnt %x buffer %lX\n", __func__, start, smallblks, buf_addr); From patchwork Tue Mar 25 13:02:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 876002 Delivered-To: patch@linaro.org Received: by 2002:a5d:5f4c:0:b0:38f:210b:807b with SMTP id cm12csp2640674wrb; Tue, 25 Mar 2025 06:03:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV5/M+qUGbbCI0gGU6EljrWKrwqauwygrc96jjANcasAWbXb+0Bo5LkP94oc2SwxEzvUbEy0A==@linaro.org X-Google-Smtp-Source: AGHT+IGmFrCoB1Qd8BXh/JM9ZCl8DF76aK/mg8t6+xL43T0z40tciMr2PH6pH6G9BcZhabUnRUz8 X-Received: by 2002:a05:6102:330a:b0:4bb:eb4a:f9ef with SMTP id ada2fe7eead31-4c50d4803a0mr10819183137.4.1742907811989; Tue, 25 Mar 2025 06:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1742907811; cv=none; d=google.com; s=arc-20240605; b=IsuExKz0rwr4jD76OAvtM0tFi6dxNDygR1SCczoWxUXcCnw6hZ9m1XsIyL2shPSgEl 9ww+IHZysiLVplZIwjoFCzwEyu6OgWIlqLMyvhW7bTaoMC7aKELlGsTMZUQJNzRPeGOL czycTRtm92Ywj6xSjt4PIrkBg445DCf2E1qPtir7FhTDoOPeojUtjsQJ1+24nI48clWW 5BqvmbmvGb82nJJOpXIFM41ixcXwXqiOlzMgcBRNfUUAxnfsG6Hsc2mTWfzhbjrYesSZ D97aCMY5+mmgQHAudUdbc7u0TTYTwJHPdn8t4Iz41Yn9QYkgDhkRAdi/bWkBvHvcHou2 m0xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=55RcLJ+tquhWLa3l8UWa3Wt1h/0nWm7MQB6yx01lSY4=; fh=fPLu07kJN7bcTfBj8hSfVvxztjWBrOoVvcvtIr+0f2s=; b=PcLMjNjSyTmKRqawlefJYmKakv5RzYAe+KDaiEjAotpo/BZ+mdOSy7g+6kerv2fP2v Wm+hoYXkeAgfPSaVRV9lBMZzVT+4mz0sPeH3stq1Nr1XG4jFXylIx1uBP0USU/Y7P1mM +u3KmnzmSWtMJzlhkPmid9EayJIkc4JzUA1fMWGAW3ggPD+uEU5x11nmELfT7JYZS6Zx 50MDSBaMTAa/8mRml4l65IGUFMBhPXw9/Eia7wxAS+cXHxMedP71p6WGD+c49Lht/omH rq9FhuKKU4FWP3SxnzM8CtbmXF8YgNA9njGP/kHULoyruH/qCsux7+WN4Kc3XtE6W9Yd fOGQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ulFwX3Y7; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ada2fe7eead31-4c50c087726si2240834137.651.2025.03.25.06.03.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 06:03:31 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ulFwX3Y7; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3A6F281D3B; Tue, 25 Mar 2025 14:03:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ulFwX3Y7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 41DE581DDF; Tue, 25 Mar 2025 14:03:04 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 31FE381D27 for ; Tue, 25 Mar 2025 14:03:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4394a823036so56126885e9.0 for ; Tue, 25 Mar 2025 06:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1742907781; x=1743512581; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=55RcLJ+tquhWLa3l8UWa3Wt1h/0nWm7MQB6yx01lSY4=; b=ulFwX3Y7/0acRNUT24oA9kQqHJGkEn004Lyiw8CMCDbEcvY2Th3o8eeRhSOscfAMcq c2mdDArKaT4TZkiVwaskMoVuagzbAFlDIZh30eqdP53WHtemmT7dojsXqUl5OEvaP1nO Q/F6iyX8rk2fs+yUjCPcNvtK5CJ54sxewra5zjtI6PE8MladjA7GSWEwLJ/J1WGshOY/ rLfR+muBOcVP/r1WtBpuS4Gh92oPPazOMWvmV/dpC8JwxLuKiWAwG/zsk1w+eaaAh/BJ F5zdBh6n1w9Yy3n48yKl6GWeYSe7J/XXsC7SqPMsBf/WVfzQpxVFE7Qv4rtFuBRA9NSB B8SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742907781; x=1743512581; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=55RcLJ+tquhWLa3l8UWa3Wt1h/0nWm7MQB6yx01lSY4=; b=ropx5WGIK2e0Ku09Xh/NXllegDtgWq+q9DV8PnTgHYDqBKEpfOFwPFg/ku8gug06Np TNYRB79+mNF5wsTbydxVWSUqCvHWaRpJOGEaEYbGlAcChMYt8vT2AR1vZmn5clJDAXKu 7y7vdHI6NRDvwkEZUrBu23I9A+wvtIQtt1HZpCOYnoXlg84E/0P2+6gACzKyq5uepkSD Vc9xcDfPnSgZKv3MDaYDYlw6EUN4F1gn+F7wBrex2Tvn9vCCzdwdy49/0t/OFVOIKy9F Qpiikij1gHQ0ZXrIIJq3HpFkfxeL9/6h5iFegRpC1O2Qgiq2qsswNJPL8lT4mVz3MMjK Jdfg== X-Forwarded-Encrypted: i=1; AJvYcCV4jXxYXqeiMhNc1lmKLmutV+p0CdMzvb8HvWPLRowrw+BeLkZzLvGJHsSxDkM5X6/W8dK81xQ=@lists.denx.de X-Gm-Message-State: AOJu0Yz1ZOOch14L2KxWAXxpuL4x7mO5S+TAY8Q4rKBafBUzp+3gLwF/ EkOzpHSiGR18qoECRB2h9mAn3Z9pG20h4taw3eO74Ia8kzNhgqF4x0UUNwiJsD4= X-Gm-Gg: ASbGncvDg1uYXLYs6D1VeRL9fPo/SFS3b9Mj6IRATShG/a/f2lUw9nY2oHBboGHIvan LHW1zKczAF+/yvfEGoacOMm7+CTVjyHoC7jh5lvNpgEwIek+5G16QfGU+i1+3qjmZOONjG+pyD6 wBhI/4LPuHZrO0Hn5cmzTRMRukv3lWId/y8jZ40DB4rlOOm3gNP54soTOd0Ez9J7Ex56qVvsSl2 7+T3wJHPS9YbSXEdOtDO1vgfxoMvoIo69vCb+IEEmKMseX/YQJm2DYrUw8wetN//HUjgAVzhWE2 ij/qaiAmlDsYCVNRQeCQS06N6tdDcqA1cq8FWqqNvpGLh4y3TdvqSdSbXyIe6vnvTnTaMNDOnRx jUKODV+n/92r3 X-Received: by 2002:a05:600c:1547:b0:43c:f64c:44a4 with SMTP id 5b1f17b1804b1-43d509ec734mr149775245e9.8.1742907781330; Tue, 25 Mar 2025 06:03:01 -0700 (PDT) Received: from toyger.tail248178.ts.net (i5E863BED.versanet.de. [94.134.59.237]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d440ed793sm204706095e9.39.2025.03.25.06.02.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Mar 2025 06:03:00 -0700 (PDT) From: Caleb Connolly Date: Tue, 25 Mar 2025 14:02:54 +0100 Subject: [PATCH 3/3] scsi: sync cache on write MIME-Version: 1.0 Message-Id: <20250325-scsi-sync-on-write-v1-3-3575aa1342e0@linaro.org> References: <20250325-scsi-sync-on-write-v1-0-3575aa1342e0@linaro.org> In-Reply-To: <20250325-scsi-sync-on-write-v1-0-3575aa1342e0@linaro.org> To: Tom Rini Cc: Neil Armstrong , Marek Vasut , Quentin Schulz , u-boot@lists.denx.de, u-boot-qcom@groups.io, Caleb Connolly X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2275; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=HNK+WBkpcnM1HsMromVRzxLwtuqyPHRwebTQUASR8p4=; b=owEBbQKS/ZANAwAKAQWDMSsZX2S2AcsmYgBn4ql/FdAQqMGTxtTZwGZvzdX90d7MP2RB2jxNp txeGjmxwHKJAjMEAAEKAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZ+KpfwAKCRAFgzErGV9k tr7KEACbHKe9lCp50Mtcel4sd80hqoy3dBcsOjV302MjAxCAVwiAjuvwM0WF3hBXhHWhcxwQhPq /ALCTqN+z6HQPJ6Op9zyYXYmtWbkP/fE2mKKXnkbKbRltIy+rc00AI9mneyC1UJ5xF17qu2djTK FkMpeCMgKgScVl3a1eoCcLQ8M46GNBNqu7uh9BnRB0z6qMxvQUJ+uQGH+tDjeS3HXES4kO4NRlM mfqw45OJj7nOEfcJQDBm9azB72RxQwGs628pmiIc2KluzpFiXqvSxxhTZ4MM4QC2aFn96PMCRJs JfVXGYXlkW9ejAkQYPKS0ql0RO0Yai/2poodJPiBZXlEe5p3Lxt9AoUN7+Tl/CO1izuq87MrbOT atTLHRFrTldX2JZvv27vwb1maZj81IUda+JhqXJV44473c5bVa7oBW/EZqlKESfiU+R0baJBXLH CilDcAZmBdCDx0okfI5zXZEUy+7K67JhApjF7ZBMQM6NhtPQQQDcX4yR5E/5Bx03EzqwEDln1cW fwtlTkDDhUkczzSgh0jPzfRVP29X8FWN0dyXzBrfUU7hPNnk1Y9ArLnKy5aqq0N8KSpOU+oUaT8 yJIAlnMAzm7ZtQRBLa93JOytIHo48ZhnH0UtHEvbKtBPy0dhgC0T70pUEOO6mLUUrKVABxv4O/i Lf7ZC/N4AyvdTpw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean We don't have a mechanism to safely shutdown block devices prior to a baord reset or driver removal. Prevent data loss by synchronizing the SCSI cache after every write. In particular this solves the issue of capsule updates looping on some devices because the board resets immediately after deleting the capsule file and this write wouldn't be flushed in time. This may impact NAND wear, but should be negligible given the usecases for disk write in U-Boot. Signed-off-by: Caleb Connolly --- drivers/scsi/scsi.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 1aa7fbdbb5278e387de72a3c3e73d19ea0342fff..1b71e580b89b100395ea132a4976366a713cba8a 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -77,8 +77,25 @@ static void scsi_setup_inquiry(struct scsi_cmd *pccb) pccb->cmdlen = 6; pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */ } +static void scsi_setup_sync_cache(struct scsi_cmd *pccb, lbaint_t start, + unsigned short blocks) +{ + pccb->cmd[0] = SCSI_SYNC_CACHE; + pccb->cmd[1] = 0; + pccb->cmd[2] = (unsigned char)(start >> 24) & 0xff; + pccb->cmd[3] = (unsigned char)(start >> 16) & 0xff; + pccb->cmd[4] = (unsigned char)(start >> 8) & 0xff; + pccb->cmd[5] = (unsigned char)start & 0xff; + pccb->cmd[6] = 0; + pccb->cmd[7] = (unsigned char)(blocks >> 8) & 0xff; + pccb->cmd[8] = (unsigned char)blocks & 0xff; + pccb->cmd[9] = 0; + pccb->cmdlen = 10; + pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */ +} + static void scsi_setup_read_ext(struct scsi_cmd *pccb, lbaint_t start, unsigned short blocks) { pccb->cmd[0] = SCSI_READ10; @@ -235,8 +252,19 @@ static ulong scsi_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, blkcnt -= blks; break; } + /* + * Ensure the writes are flushed to disk so we don't lose data + * on board reset. + * FIXME: this ought to be in a SCSI shutdown path instead + */ + scsi_setup_sync_cache(pccb, start, smallblks); + if (scsi_exec(bdev, pccb)) { + scsi_print_error(pccb); + break; + } + if (blks > max_blks) { start += max_blks; blks -= max_blks; } else {