From patchwork Wed Mar 26 12:24:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 876316 Delivered-To: patch@linaro.org Received: by 2002:a5d:5f4c:0:b0:38f:210b:807b with SMTP id cm12csp3141883wrb; Wed, 26 Mar 2025 05:24:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWEdTBQLE4iw+8ogechl+8OTIEkSI59oZ7wKwP8wep8Wyl8ml9Kn94TR0xq4kxqWF9LeLusyg==@linaro.org X-Google-Smtp-Source: AGHT+IG5DL9ujWMvUtpU329L0JLeqNysS+tKgH0y/efTXDQucYDoSQPt+ciBCVAZkGFwF7txRWRN X-Received: by 2002:a05:6102:14a9:b0:4c1:abaa:ad93 with SMTP id ada2fe7eead31-4c50d515b0amr15495187137.14.1742991884951; Wed, 26 Mar 2025 05:24:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1742991884; cv=none; d=google.com; s=arc-20240605; b=dlPMnwqkMvXikm4WC+SReAUaFNCUWflFCnP6sOXsKmwxSjCjRhoOKAURDLzhT7CMcl SaNWLec8VuXcyEKpe3gIxIlBW6CDAFDYDM+2m93AibfQ08GlAyv6DGJjp4rEowsItszv VeBWFBOPDXbndeHMCyGb9eJxIqi9Twp7zW/xVRXVc8G8TNY5XKHeccqFv8wietjyYcNS lxUL7civOhRkYIVwtXhvYquVZ8cHPNld5ENvdJmhEOOxL3lN5cW95kF36g+bqRWXWCaL yXeo9/4/+/olzG9ZtatVkh1z9VelVxq52qb+TwTQ0GWzWNdARdtVjsuAJ+qatcVNsFn0 4AEA== 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=Or0qLFxndDL56zEI1o0/SJT9c1VYLS1Cd14lH3rYNAw=; fh=egcJm2IE+KO9/jmzrH+/QB+Zfb8sJ3n+n86Eifb2VBU=; b=Zc+mkbxFKBTM2ZHin/2nDEaOAN4BHR0b9waEyA+1+/Ge0AZ6VHvUr31jCyux0n2hB1 PKbmkfVLb3L5RNJmcDVO8iQn1Eiz18mRiB+tUWGW+UgogjVX4q0nwkvFpuNQVGaQEIZu 8Y3mVuARfXmNBNHPtpRSTzOSXhoQHBN7ekLczi0P8NtEECz+rdQ9/JrC1iBs9qoVcBUn rCgnoPuUO/QG7F3YAQQfY2WdIL2XEEhi2KDamlnc5cWqzWVIZqEHpp+r17U95UtXSqPX AtzpfpmQBP2Ov59DB4gr5ewsOyudQ0dGbyN6TrlFPHix82mwU4oJYH+DZIoDaY1n1LtP RMfA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FPxNiqqR; 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-4c555899440si798590137.403.2025.03.26.05.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Mar 2025 05:24:44 -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=FPxNiqqR; 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 D690181E1C; Wed, 26 Mar 2025 13:24:21 +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="FPxNiqqR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8AD3880BAA; Wed, 26 Mar 2025 13:24:19 +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-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (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 7AC1580756 for ; Wed, 26 Mar 2025 13:24:17 +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-x434.google.com with SMTP id ffacd0b85a97d-3912c09be7dso4484955f8f.1 for ; Wed, 26 Mar 2025 05:24:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1742991857; x=1743596657; 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=Or0qLFxndDL56zEI1o0/SJT9c1VYLS1Cd14lH3rYNAw=; b=FPxNiqqRNFJtVSlewNUWiGGcEq+AicOf3dgm4gDRLQy4ij/cg/KOwgjrvmOXTT9HIx N/G+yLkQBUaF8KLvWpTmX7oR4YhhRVY21JQXG/vngYGttfKw4Q7cMfGCerhhfWO+3JdN Jl5/E89JsJN4yJ/PQWt6WfuItl0qCTUo/1JAXPbT62it4Zufm+ha8MBFdK07ZLlAqT4M 0j8ocdumXg7gPWdBrcdfCdwjSSrUgp9QiBVJtDtma/FIsHNIZQV8z1cXNRXgtwfxGO2g NTon3VOe3ziEFz92IUkADkW4gC7YNWi/Hn6AE0fvYlBwyqjAxSI06EfmTtdXNhSVUb4/ z6Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742991857; x=1743596657; 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=Or0qLFxndDL56zEI1o0/SJT9c1VYLS1Cd14lH3rYNAw=; b=ecljGN5gN1wkIHWAE16qnjCuwWb0j7O8JVngcyU9yasyJbYBLRAarA38H9XZDCoIFt EK9NvkXh1N/aHDwbYWQ6fWTugZaqZ1/FvnMDutquo33GhMxPUAJAq9bbmJG5mHMKsBDV yRgfEbFNVkjtiWs/5blhOn+z/nSamknWjc1s/ZXpPBLWno08cqDbJCrkXdeukbqYflng FJJJWKdx+oMPcjq5TtJNvNzHcN5ML8+JYq2uxoyfo4dQ8jjKy7smJP/n5U37H+SoAJ4E 0iMtjA2WngLjNMQ0fUDcB4C4sqenBEeger6cKF1FXGcPKL/pNFLkgXHRRVzC0SO8W7pB 7jDA== X-Forwarded-Encrypted: i=1; AJvYcCVCVNO1rmuhVihn7rmQ48fBnWd7u9RlPjpVw85IhFrb8576gJsi1lOLAO9SKDyih+pyOrJr6Rc=@lists.denx.de X-Gm-Message-State: AOJu0YzQJJdBEqiZnNM1WG5HCDFoVgkUi8ZRCFEVpLQ1S+UzSOnvUJJq /BSEHrH9+UhNOAwNSyx39Q6nnytH0bnIfT6ZceUMesw1D1jSxqxcjQ/5NNLi5iU= X-Gm-Gg: ASbGnctpGhZGhe0RNGGKwZhJKv404dWDAw4ZFpVzuhMg0p2v+OiLFaTdxZsrAHPl4Xe Kr2P5F6yBTT7mSu3of8okh6Xkcu2z2vL7Oq1PHvGAQSE6KRNPIqQBa3g/l+VaGINa7I5Lsb0z6v EInTsfQ88X3WqcemNfL42MAa5DHibncY82HFnOA0tY0RKag3XOskGwYfUAHAF7P6xJTJAlfbC3f +RGXnFUUwHH9qKKn1jvJuerat5BlBcVI+phzc3IatjzIa7YL0ZO2iaRjrmC/5XI+22LAyjW5JI1 RpkZ+KHD1knIQG/wswA/AYXmMxzJhZrRHMWZw+eKD5Kq72lydu8Eu4B1KULkQLzgrX8IVNM/XOs oxdDTENIzbmSc X-Received: by 2002:a5d:6d81:0:b0:397:8ef9:a143 with SMTP id ffacd0b85a97d-3997f90c860mr15785992f8f.23.1742991856871; Wed, 26 Mar 2025 05:24:16 -0700 (PDT) Received: from toyger.tail248178.ts.net (i5E863BED.versanet.de. [94.134.59.237]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3997f9e65casm16923921f8f.69.2025.03.26.05.24.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Mar 2025 05:24:16 -0700 (PDT) From: Caleb Connolly Date: Wed, 26 Mar 2025 13:24:10 +0100 Subject: [PATCH v2 3/3] ata: ahci: implement SCSI_SYNC_CACHE MIME-Version: 1.0 Message-Id: <20250326-scsi-sync-on-write-v2-3-12ab05bd464b@linaro.org> References: <20250326-scsi-sync-on-write-v2-0-12ab05bd464b@linaro.org> In-Reply-To: <20250326-scsi-sync-on-write-v2-0-12ab05bd464b@linaro.org> To: Tom Rini Cc: Neil Armstrong , Marek Vasut , 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=2018; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=V5RueStbr9d92x6h7pIfVh6kG5HW1KQlF0AVP/dL3p0=; b=owEBbQKS/ZANAwAKAQWDMSsZX2S2AcsmYgBn4/Hq5rxIgZOz8cuU7oBlV1CdlFY5k/yRsvVFC zfd2JM1gaGJAjMEAAEKAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZ+Px6gAKCRAFgzErGV9k tgp4EACVb7mayHsonUGBUIKZ6r4bVASnJWmtw8We6kIJooKvn+Z138928SUX6hXo1Q9QIIgVwRq tlt+XuVv7H7dSpoW7NnrS7eGapQMw2/JwmSKxa5d+fzBUn/mF0vS/bMQvCAVukADV1bshTzCHbE tGYNfSr+60aX5jRsIxv1CtdCw6m8fpWeYLMeeMncVu7vzTLEhweEHxCxk6dsVeZemWO2rIJERJM W9X/hkFUh8ODHJwwkPF9B1Jtv4MWye3V9Kq/hQ6kMNmexfOrPBD34R9MqB0rcHL96Vzh9H8/yaT 2rzB3HCsmcikjr6lkyOmvwyYaMLgZ8AOjUln/jReJh0cXr2O7yqzBkhMeh67XlLpHSc3df6zoq2 FHr1vcbGppj17sUIgiUMpvYWqCWOS29IJiiOQ/b4Wi2d6uifu/N6dF2lspf0zH/LfWSMz+C/oNL ZwT10xuEtiXsc7SDbvvlq1JKRZ2I+nZxZ6yXoTeTMhQMzwycjugVyWMy2aEr4FlEby1h0XW7qvk ef2OyvHfVIHYGJlQmw7PSaLav3zBMxNc/u1A+haVyunlBuCu7gm5LmMsdrNAnQoBLygF4iC3jPN Kvc/47C+QuoFWkd+aPID8QqYNIH8SLX9CJRUEj317Rjwd+SHWwgDdsvyTF2CDr8Y347xtqiJ4wR d5xKXZ2VEjh/TpA== 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 The SCSI layer now issues a SYNC_CACHE command after every write to ensure there is no data loss due to a board reset after write. Implement support for this command and remove the same logic from the ATA write path to be consistent with other SCSI backends. Ranges are not supported and the whole cache will be flushed in all cases. This was done per iteration in ata_scsiop_read_write(), but it's not clear why this was the case, calling it once for the entire write ought to achieve the same result. Signed-off-by: Caleb Connolly Reviewed-by: Neil Armstrong --- drivers/ata/ahci.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 8058d5ff1c37f92914f250fa9cc78498a3f27331..deb91efd6d2666016f375feabb16ebc8f68fb697 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -735,19 +735,8 @@ static int ata_scsiop_read_write(struct ahci_uc_priv *uc_priv, debug("scsi_ahci: SCSI %s10 command failure.\n", is_write ? "WRITE" : "READ"); return -EIO; } - - /* If this transaction is a write, do a following flush. - * Writes in u-boot are so rare, and the logic to know when is - * the last write and do a flush only there is sufficiently - * difficult. Just do a flush after every write. This incurs, - * usually, one extra flush when the rare writes do happen. - */ - if (is_write) { - if (-EIO == ata_io_flush(uc_priv, pccb->target)) - return -EIO; - } user_buffer += transfer_size; user_buffer_size -= transfer_size; blocks -= now_blocks; lba += now_blocks; @@ -845,8 +834,11 @@ static int ahci_scsi_exec(struct udevice *dev, struct scsi_cmd *pccb) break; case SCSI_INQUIRY: ret = ata_scsiop_inquiry(uc_priv, pccb); break; + case SCSI_SYNC_CACHE: + ret = ata_io_flush(uc_priv, pccb->target); + break; default: printf("Unsupport SCSI command 0x%02x\n", pccb->cmd[0]); return -ENOTSUPP; }