From patchwork Thu Nov 17 10:51:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Loehle X-Patchwork-Id: 21554 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp331155wrr; Thu, 17 Nov 2022 02:54:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf5lKRnx7Usi4yRs18krF5waZOTwQM0ZGaTsDwLnPszNtaby/Zt7DvWbmZ7u+P2KdEaPCkON X-Received: by 2002:a17:902:eb92:b0:186:5f86:da41 with SMTP id q18-20020a170902eb9200b001865f86da41mr2241307plg.73.1668682470736; Thu, 17 Nov 2022 02:54:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668682470; cv=none; d=google.com; s=arc-20160816; b=njfvM9SGF/yX356R4cs0jEJwEKhpw19V7eRKIcJHtkS5iTyW3YOoNTNDzDVyc9nuT3 uChXj2duhpbWqpvfRtZeTa7FLT/kH2gIbQti+8FJNpztSIKkejQy5aULiD8bGLUDC0pL HT9B0+C+qvE04ZxsINKpRWRlZ/UQ8f0OE5w4sMB0kDktzO7iaAT3YqaDFy3J3mrfiLg6 WShLGnyB5Jl5AuNFQuE5mVJCyEqxLf3tCTVLIcNeiVPk6aq5AWa6gLbmmC6iRbJECYPr oew5mbSdOp5z8xm1kFD/drm7QcGILXvJJWaw7akNFhszKfSGChhnZZZ1bIDGyu1/hdVD IYJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=qgs9owjnzgZc0NcGpG8mrARTWY4hv5mLYhhi3cOcRiU=; b=IDX2z5wuG2J1E0efqDMBOIvMSaXDaE7NNzQvAq033qGzznpNN0JpXHxBTAYVJg9pXx MruIK4GyemSMCZTtFwUXkdRNo339eZfsGLQaxUbQ1u7siKbLqhHQGI/9AC6rZnMBHLzY n309KWptpXerLHkudRyhdutpIv31icUT7QyApkMobOkKzCrl4RZOj2vFItX7sK+8o0MO eWqOlDsF5Xxin01UHU8JfkmQVPU9l+1kgKSwYW9JQ5Ix4vcMF5wDOyxRNlZ8JZGFIf93 ugDjZAWrxRkipZnLiDl4NKFpi+Ib5kY4BOUHyv6cOUoaZ5X1Zry6qTrCRI9PFwWcAoIO Xk+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hyperstone.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l9-20020a17090270c900b0017123d2abd5si648926plt.457.2022.11.17.02.54.17; Thu, 17 Nov 2022 02:54:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hyperstone.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239280AbiKQKwL convert rfc822-to-8bit (ORCPT + 99 others); Thu, 17 Nov 2022 05:52:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239521AbiKQKvy (ORCPT ); Thu, 17 Nov 2022 05:51:54 -0500 Received: from mail5.swissbit.com (mail5.swissbit.com [148.251.244.252]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0882532FB; Thu, 17 Nov 2022 02:51:51 -0800 (PST) Received: from mail5.swissbit.com (localhost [127.0.0.1]) by DDEI (Postfix) with ESMTP id CD1243A2324; Thu, 17 Nov 2022 11:51:49 +0100 (CET) Received: from mail5.swissbit.com (localhost [127.0.0.1]) by DDEI (Postfix) with ESMTP id B2A6A3A2322; Thu, 17 Nov 2022 11:51:49 +0100 (CET) X-TM-AS-ERS: 10.149.2.42-127.5.254.253 X-TM-AS-SMTP: 1.0 ZXguc3dpc3NiaXQuY29t Y2xvZWhsZUBoeXBlcnN0b25lLmNvbQ== X-DDEI-TLS-USAGE: Used Received: from ex.swissbit.com (sbdeex04.sbitdom.lan [10.149.2.42]) by mail5.swissbit.com (Postfix) with ESMTPS; Thu, 17 Nov 2022 11:51:49 +0100 (CET) Received: from sbdeex04.sbitdom.lan (10.149.2.42) by sbdeex04.sbitdom.lan (10.149.2.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.9; Thu, 17 Nov 2022 11:51:49 +0100 Received: from sbdeex04.sbitdom.lan ([fe80::2047:4968:b5a0:1818]) by sbdeex04.sbitdom.lan ([fe80::2047:4968:b5a0:1818%9]) with mapi id 15.02.1118.009; Thu, 17 Nov 2022 11:51:49 +0100 From: =?iso-8859-1?q?Christian_L=F6hle?= To: "adrian.hunter@intel.com" , "ulf.hansson@linaro.org" CC: "linux-mmc@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] mmc: core: Fix ambiguous TRIM and DISCARD arg Thread-Topic: [PATCH] mmc: core: Fix ambiguous TRIM and DISCARD arg Thread-Index: Adj6cjlNmIWKPA3KQSivIeQjTaE/gQ== Date: Thu, 17 Nov 2022 10:51:48 +0000 Message-ID: <6373cfb97ef24ccfb5236c721f263f1b@hyperstone.com> Accept-Language: en-US, de-DE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.153.3.46] MIME-Version: 1.0 X-TMASE-Version: DDEI-5.1-9.0.1002-27268.007 X-TMASE-Result: 10-0.263500-10.000000 X-TMASE-MatchedRID: ewN4Wv8Mz/iz4NrOslvOzoL5ja7E+OhyKQNhMboqZlp5eyhu4TpIqx3i uFfYqHyoy7U1qS9q0fS12HagvbwDji/7QU2czuUNA9lly13c/gGvMPxisLn2/B2kiqKHn7kiKwm qZIhHHZAf6lD5M6DX0D6eOS91uJ8FvWXpKoZUv2mSJLHHb2KALX0tCKdnhB58nFK7VE/xL0n6C0 ePs7A07Xi4XEoPXecxQSmtvqQNS5+NUlAvN92JBe4VChlPobsxKIT7HncI3Qo= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-TMASE-INERTIA: 0-0;;;; X-TMASE-XGENCLOUD: 8810775b-4fde-458c-b87d-1b5c5e914dd9-0-0-200-0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749740390437933389?= X-GMAIL-MSGID: =?utf-8?q?1749740390437933389?= Clean up the MMC_TRIM_ARGS define that became ambiguous with DISCARD introduction. While at it fix one usage where MMC_TRIM_ARGS falsely included DISCARD, too. Fixes: b3bf915308ca ("mmc: core: new discard feature support at eMMC v4.5") Signed-off-by: Christian Loehle Acked-by: Adrian Hunter --- Previously submitted as mmc: core: Do not require secure trim for discard drivers/mmc/core/core.c | 10 ++++++++-- include/linux/mmc/mmc.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 95fa8fb1d45f..7ce26dbd5879 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1478,6 +1478,11 @@ void mmc_init_erase(struct mmc_card *card) card->pref_erase = 0; } +static bool is_trim_arg(unsigned int arg) +{ + return (arg & MMC_TRIM_OR_DISCARD_ARGS) && arg != MMC_DISCARD_ARG; +} + static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card, unsigned int arg, unsigned int qty) { @@ -1760,7 +1765,7 @@ int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr, !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN)) return -EOPNOTSUPP; - if (mmc_card_mmc(card) && (arg & MMC_TRIM_ARGS) && + if (mmc_card_mmc(card) && is_trim_arg(arg) && !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN)) return -EOPNOTSUPP; @@ -1790,7 +1795,8 @@ int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr, * identified by the card->eg_boundary flag. */ rem = card->erase_size - (from % card->erase_size); - if ((arg & MMC_TRIM_ARGS) && (card->eg_boundary) && (nr > rem)) { + if ((arg & MMC_TRIM_OR_DISCARD_ARGS) && (card->eg_boundary) && + (nr > rem)) { err = mmc_do_erase(card, from, from + rem - 1, arg); from += rem; if ((err) || (to <= from)) diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 9c50bc40f8ff..6f7993803ee7 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h @@ -451,7 +451,7 @@ static inline bool mmc_ready_for_data(u32 status) #define MMC_SECURE_TRIM1_ARG 0x80000001 #define MMC_SECURE_TRIM2_ARG 0x80008000 #define MMC_SECURE_ARGS 0x80000000 -#define MMC_TRIM_ARGS 0x00008001 +#define MMC_TRIM_OR_DISCARD_ARGS 0x00008003 #define mmc_driver_type_mask(n) (1 << (n))