From patchwork Thu Jan 26 09:24:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 647080 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp143650pvb; Thu, 26 Jan 2023 01:24:40 -0800 (PST) X-Google-Smtp-Source: AK7set9BR0QoqhpwQXqxyP8z0BlPmQvbTog1q2um+kOfbXfjvKn+n0YOsEQrH8bOSPFsLi1nJBIU X-Received: by 2002:aca:6187:0:b0:371:fe1:8943 with SMTP id v129-20020aca6187000000b003710fe18943mr692417oib.6.1674725080765; Thu, 26 Jan 2023 01:24:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674725080; cv=none; d=google.com; s=arc-20160816; b=U3jVkJ6rYL+zb/P1rgvKtBYwonFJ3Uj0MWj+a3jgJCHNAhXze/juhOJsvIexqNIjD7 ltjqGC2Cumg5Ni+0pvHRjW/ubxJIDmAl25bgi9m8oukNGFzcXiqNj7dYCnRykuw5cTBF 3KOIMpQ72jDLaN5+w6hCknkEbqkPhwcnCHEA6eRS3ksE/MF0OTOrCwespJUVaghBU9Bc ssMYjE8mCWZ+aZ6tKeSHI+4IdHB4F++EEaHhhWaAqvTDEdVRM9DzLUszHO7LlbhnFhfB Iv1y1mK3KxyUYhH55F4OvkggzWsA5p+W96kd97B55i1kN97TJGyic0pHF54dU9Y9rYfO /wyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=VUS1u747ImeKRA0A3IH2qi7kYUS6TVyQnGNriHEDudE=; b=SbSzPHKg2dO87ZI+DKa6E37r9tNRpQ+09MJPFyG4XnmkVYABk8pqgevl2ZLSgYPAl/ FSfeoqmdwmw+LTkqGsGFAJRiDe8cBV/KaA6QokF/colx1JChzx4g6GmQMhJULgddpUME c1LhWlKT1MBOSXKj0qHgYuYIsxtbBRXV6VK847VEptP0dpZXzNDqIbkvWLZp/v45v6RN ZOIApNDv7CiIgZrvOEQ1Ya/12UEXCUZMfxK5TF+4wTnDpMyGLfOPOoP8K1JnwTAVc3Fb eX2TrVBQjn2GJrumAvw4YKV88+dlgUtHBcJSIlnfA32YfEoFhvIUX2TckS9FmgpBie89 52GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aFZHzYHa; 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 Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id b133-20020acab28b000000b00363ea5fe235si767601oif.89.2023.01.26.01.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 01:24:40 -0800 (PST) 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=aFZHzYHa; 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 Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3D86184E8B; Thu, 26 Jan 2023 10:24:37 +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="aFZHzYHa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C563F855B4; Thu, 26 Jan 2023 10:24:34 +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,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (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 7EF1684954 for ; Thu, 26 Jan 2023 10:24:27 +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=loic.poulain@linaro.org Received: by mail-wm1-x32a.google.com with SMTP id l8so692064wms.3 for ; Thu, 26 Jan 2023 01:24:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=VUS1u747ImeKRA0A3IH2qi7kYUS6TVyQnGNriHEDudE=; b=aFZHzYHaiaib1UMBerk+iRBvfQLWgnrQoCvjlJa8+y80CZG9MQqXkaQqGzPpByysKq jMaAY28VMmko+bV5ZrzXHq2KbjO6lDQDG17JuPf4PQ0uRpF0h3kAO2vpfeRcGDE2QC9Z LW224N3tbgL5NBCHwLiWR7DfTxKMFSD5IuKC8HlD/II0ZFm04HD7iVSS0cgQq59COLFc /QaHYh+12To9LvVx+9zBxAAc8/LCfQxmQH5MZ+sRVvb427q1/MFb5OQKE0NryhJICZ/c /yInA8+L19Cb8w3hQD5CsogSwY0t7Eld7/rVoTJGLYN0h/zIRSwLb6Uz5scf1YF5IfWi EfMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VUS1u747ImeKRA0A3IH2qi7kYUS6TVyQnGNriHEDudE=; b=ZrkqePjGL2RYy0QZU/qtZxaIhLAbCyTSAyfqc35Pums8C7CvyC0MdiC758R4KGQcyk wcRXarZYfZnzvBy2YCWRoMmE5cjuRBjCvAR8IfXXP9LDkjIQmEcKEkQICF9IxGTF7QlQ 0YfLJMop3S8jHLWW1jEekTen5ss7wT9/x3MEXi9SibhPTa095FI1j64yiLIj0PtEXwMf X2TEVSW7ObrrltaLkIJ58LON7NlZDiTh20BZ9FyKnU5jGB5xrdcrsqmf4bIv+0itgtfQ 5GpNRV8liic6NZWYaz1xL7a/XTbkPL0NEa/jQo8hC9zD0D3nDYoJFL9OqKK8VThoJCTO 1g+w== X-Gm-Message-State: AFqh2kopFeGmtF6IfAV1a4y7y/ixbNjvH/LFuTQQKFl7ENIMnXZkb+J4 VMb4DGai14CQEV50v2kp0a2MFA== X-Received: by 2002:a05:600c:35d0:b0:3db:c4c:9224 with SMTP id r16-20020a05600c35d000b003db0c4c9224mr33337975wmq.3.1674725066847; Thu, 26 Jan 2023 01:24:26 -0800 (PST) Received: from loic-ThinkPad-T470p.. ([2a01:e0a:82c:5f0:352b:2cb1:8983:9f55]) by smtp.gmail.com with ESMTPSA id y34-20020a05600c342200b003dc16dee9b1sm920026wmp.15.2023.01.26.01.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 01:24:26 -0800 (PST) From: Loic Poulain To: sjg@chromium.org, peng.fan@nxp.com, jh80.chung@samsung.com Cc: u-boot@lists.denx.de, Loic Poulain Subject: [PATCH v2 1/3] mmc: Check support for TRIM operations Date: Thu, 26 Jan 2023 10:24:17 +0100 Message-Id: <20230126092419.534514-1-loic.poulain@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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.6 at phobos.denx.de X-Virus-Status: Clean When secure/insecure TRIM operations are supported. When used as erase command argument it applies the erase operation to write blocks instead of erase groups. Signed-off-by: Loic Poulain Reviewed-by: Simon Glass Reviewed-by: Jaehoon Chung --- v2: Add mmc unit test change to the series drivers/mmc/mmc.c | 3 +++ include/mmc.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 210703ea46..e5f5ccb5f4 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -2432,6 +2432,9 @@ static int mmc_startup_v4(struct mmc *mmc) mmc->wr_rel_set = ext_csd[EXT_CSD_WR_REL_SET]; + mmc->can_trim = + !!(ext_csd[EXT_CSD_SEC_FEATURE] & EXT_CSD_SEC_FEATURE_TRIM_EN); + return 0; error: if (mmc->ext_csd) { diff --git a/include/mmc.h b/include/mmc.h index 571fa625d0..f6e23625ca 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -241,6 +241,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */ #define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ #define EXT_CSD_BOOT_MULT 226 /* RO */ +#define EXT_CSD_SEC_FEATURE 231 /* RO */ #define EXT_CSD_GENERIC_CMD6_TIME 248 /* RO */ #define EXT_CSD_BKOPS_SUPPORT 502 /* RO */ @@ -315,6 +316,8 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define EXT_CSD_WR_DATA_REL_USR (1 << 0) /* user data area WR_REL */ #define EXT_CSD_WR_DATA_REL_GP(x) (1 << ((x)+1)) /* GP part (x+1) WR_REL */ +#define EXT_CSD_SEC_FEATURE_TRIM_EN (1 << 4) /* Support secure & insecure trim */ + #define R1_ILLEGAL_COMMAND (1 << 22) #define R1_APP_CMD (1 << 5) @@ -687,6 +690,7 @@ struct mmc { uint tran_speed; uint legacy_speed; /* speed for the legacy mode provided by the card */ uint read_bl_len; + bool can_trim; #if CONFIG_IS_ENABLED(MMC_WRITE) uint write_bl_len; uint erase_grp_size; /* in 512-byte sectors */