From patchwork Wed Jan 25 17:31:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 646561 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp401365pvb; Wed, 25 Jan 2023 09:32:02 -0800 (PST) X-Google-Smtp-Source: AK7set93U+n9Ly7Tr+odaVx28A30acd/oOeVkCs+Q96nI0zi3+30wc3wNGQScXmUTWltMxDALcpl X-Received: by 2002:aca:e144:0:b0:36f:f33:8cc with SMTP id y65-20020acae144000000b0036f0f3308ccmr1678844oig.35.1674667922579; Wed, 25 Jan 2023 09:32:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674667922; cv=none; d=google.com; s=arc-20160816; b=XSmS366vH6fPCFvBCNDNs9o8RJ28ZxH6nIwfxQ5d1FKcRyPiSm2zE9f6hW9oxXACvT EmHRu6EMHqtnVs7nmjYemIavrje1y0LMPyUFQbY/L+LQpLRx0lX7EWk4T/wcEXRdkFya DBlXSUtsunIl0jWYVd3+Mp/4vArjKQzobOGSJVwz11QNpm2lSJodijc6E1rswsRCKMma yl2Cf58cAvUsYOQuww612AKGFLl3mgPDjMbVANXpILsQkTjD5jWsBYBbPiLckDdejWrW Oc8Q9MY65OX+dsRoxrH1kOFob6SeDvNfMMMwW9fNg/YCauHUHeFlcpCExq+3dG+jGpiI Fb2A== 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=UuMj28wdSwykFeEuiaFXWhIV25FoxxFITjuBsocL42s=; b=xHMqPaOvCF6OjJExyfvhzzP01A0m4FKmmzB02TxKZSvC7BWK08pYC+wqOPyqwUqQ9T GL6ckC4aVAJTfd2zLN91Sj/03ZWxmO4ZXVXc86N6hSDjIgbDRqtweiIVF59s0ssbAt/o b5b2X83whaRTIz5qt012Li7iL4uEBw0Fdxii4nYG/bJ6V6gOoc0ddtvKPVtZSINuZwra H7ys66KiC2zpCTljX1LiNBcnjYXONRnsj6Dbrvn/QOqux/PWLvxkzFsTsLOcnTuLuSX5 /nuaWirg53EkH/XbT80iZCzg7+rYMC26KB4PD/LTnYg/1O0IC5mvTlkETPl8GpRaLcc4 yGkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cCFMXU5n; 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 s184-20020acac2c1000000b0035b70842962si4660278oif.22.2023.01.25.09.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 09:32:02 -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=cCFMXU5n; 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 D33B7856C7; Wed, 25 Jan 2023 18:31:59 +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="cCFMXU5n"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A23A3856C7; Wed, 25 Jan 2023 18:31:57 +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-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (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 E94D1856DD for ; Wed, 25 Jan 2023 18:31:52 +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-x334.google.com with SMTP id f19-20020a1c6a13000000b003db0ef4dedcso1748358wmc.4 for ; Wed, 25 Jan 2023 09:31:52 -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=UuMj28wdSwykFeEuiaFXWhIV25FoxxFITjuBsocL42s=; b=cCFMXU5ntJRL37PBd8UztQYfKeSrQBOmRKYhCcR4e8/DB/8anw3OVaXfA/NR8v2Fpx sCMm2tD7jbGRNqZeOzg4Bf/gH0n6qBN/cGj46lSi9/KvizS3EdvJ+12gR1ye6FIjk5bD 2IluOA5+zKIq3pi1njqUxpH1nISYKwBb63jmnV1kxVGMkPw2hfOTDPGCJSn7bkGTpeId 9sWeCzfBEiV/5ZX5uipX0p5qoORngeaBkxxi8+U6U0rlGyD+eL/lOCV/u2d7sd4FDbmB 1qCQLrCXcOZpzo9omkaal2eIKr0z3mZ3zu1pAK/Ne7i40tJ80CblVNis2G9gyWJr/uAU YhKg== 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=UuMj28wdSwykFeEuiaFXWhIV25FoxxFITjuBsocL42s=; b=l9qM8UStLpVHaVSy7UqNoKuN0dYD+qINxpLkOE0jqbQIiehEeZoUUE3rtpQYlm6zx6 Yj54/OZmg2W8Xs53d4dKCrUUjuXzlEeJ+PC7rp8BkEAFz4Ee4Fkp+klN/nbm0C0DYF4m M0oGEHMCeUHVWUfViHs+EDV73hY7J45NLjMZc/qFQCBg+CRK2s70Ijf9saT7s3xmS1ZV usY8HT+2jThRiw7uLmHHn4Uv6sDoHrgpnnu2ezQW6Rk/GqAKRwIWEsGRoXaPyQ0Jf9uA fqUQ3wynrDx8L8IbGsljIbC07vQbguNTVsrEM1o7nd7J8j8oV/gYd0rYbiEf+b5mSHaJ ghcA== X-Gm-Message-State: AFqh2kr0MAXgzOOQw9Wqeo2GodpLfvMIHmqVnPCDkaBN6PpKYxV1z6vx ZaPJlwen8u45xIf/Esw7ljH2vA== X-Received: by 2002:a05:600c:1e21:b0:3d0:7fee:8a70 with SMTP id ay33-20020a05600c1e2100b003d07fee8a70mr32855282wmb.19.1674667912423; Wed, 25 Jan 2023 09:31:52 -0800 (PST) Received: from loic-ThinkPad-T470p.. ([2a01:e0a:82c:5f0:bda1:2bc4:dac2:c66f]) by smtp.gmail.com with ESMTPSA id u36-20020a05600c4d2400b003daf681d05dsm2421533wmp.26.2023.01.25.09.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 09:31:51 -0800 (PST) From: Loic Poulain To: peng.fan@nxp.com, sjg@chromium.org, jh80.chung@samsung.com Cc: u-boot@lists.denx.de, Loic Poulain Subject: [PATCH 1/2] mmc: Check support for TRIM operations Date: Wed, 25 Jan 2023 18:31:46 +0100 Message-Id: <20230125173147.477383-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 --- 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 */