From patchwork Thu Nov 17 14:42:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Loehle X-Patchwork-Id: 21695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp443019wrr; Thu, 17 Nov 2022 06:56:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ZtlOpwtANW0lmSg0sy4uQD4xkxGuevF9Q107Syg92NrTxqLDmvgHLb75zPeX8FylPa6+q X-Received: by 2002:aa7:dbd8:0:b0:467:60fa:b629 with SMTP id v24-20020aa7dbd8000000b0046760fab629mr2408076edt.281.1668696974173; Thu, 17 Nov 2022 06:56:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668696974; cv=none; d=google.com; s=arc-20160816; b=OAkW3jOzxJwVGs1ioM159lNfNvConXc3D2IYtWBBNAzmlq/Rwh9HhgA09ttuXyO3/D MV+n4vfAyytDKHgYuZCZVFCG0p4AGWg19NTBMLI+bF0T8VxaiEQCmlyVdWkrv8O9q09u YPweIIGnb8VO07I2ZJnVXQVZAPY+mbjMiI7BtdAWuy+k7fyd6bnrk1DNkvlHK3wJ77Xd JjML2L3jYEqqZVUeeIkS30YjTPUQA2jW9Vkd8xMmMhTYnY/2w3J2vdlRqQ2t1JCkG4pn 7IZoNpY+rmalPDI8TPAXQsHZl+4dnyyyM3hHhpeNQatFgPWIIBJruJf4CICDyhGvexEs jHEQ== 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=h2fqNcRjxkJtMSa5/gQ7s8Qx4lfMqqwoCDbKncKFx1s=; b=UW3mMCzNyob9vIbs9dylaAc6iEKywuN2m7zZrQjMuMtda07DjRc2DC3W/i2PQYntpS 0CaEzUyii0phgfWEvGrFUgLPmFYuq2qEsat2ih0B9bLm8Omya9uFHxIYklr3LbcMmx9Y QY+vQ9YPpLXNQkw5FfwHNIcSrc56lSAwk32zFEx33kiGef7JOVosE9ENDyKunp/jd408 x6cXgRJBgOiFl108r1RZ30wOwU0TDwr7JCOnW3J5N1RjkyTB7tVPjQqlRC6GjHu9m8WM nQu5iuPbsOW1A67ivApVMMChzN2Y594bbIrnh58eu/GYOTxAzZfYsVyrnX37hNciJzgn BJQQ== 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 k20-20020aa7d2d4000000b00461c43d1113si875911edr.569.2022.11.17.06.55.50; Thu, 17 Nov 2022 06:56:14 -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 S240432AbiKQOno convert rfc822-to-8bit (ORCPT + 99 others); Thu, 17 Nov 2022 09:43:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240767AbiKQOnJ (ORCPT ); Thu, 17 Nov 2022 09:43:09 -0500 Received: from mail5.swissbit.com (mail5.swissbit.com [148.251.244.252]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73FD017A9D; Thu, 17 Nov 2022 06:42:11 -0800 (PST) Received: from mail5.swissbit.com (localhost [127.0.0.1]) by DDEI (Postfix) with ESMTP id 0B3623A2326; Thu, 17 Nov 2022 15:42:10 +0100 (CET) Received: from mail5.swissbit.com (localhost [127.0.0.1]) by DDEI (Postfix) with ESMTP id E51753A2322; Thu, 17 Nov 2022 15:42:09 +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 15:42:09 +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 15:42:09 +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 15:42:09 +0100 From: =?iso-8859-1?q?Christian_L=F6hle?= To: "ulf.hansson@linaro.org" , "linux-mmc@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: "adrian.hunter@intel.com" Subject: [PATCHv2] mmc: core: Fix ambiguous TRIM and DISCARD arg Thread-Topic: [PATCHv2] mmc: core: Fix ambiguous TRIM and DISCARD arg Thread-Index: Adj6krwMIu2DPqGURfe2wappqjTDcA== Date: Thu, 17 Nov 2022 14:42:09 +0000 Message-ID: <11376b5714964345908f3990f17e0701@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.4.12] MIME-Version: 1.0 X-TMASE-Version: DDEI-5.1-9.0.1002-27270.000 X-TMASE-Result: 10-0.263500-10.000000 X-TMASE-MatchedRID: ewN4Wv8Mz/iz4NrOslvOzoL5ja7E+OhyKQNhMboqZlp5eyhu4TpIqx3i uFfYqHyoy7U1qS9q0fS12HagvbwDji/7QU2czuUNA9lly13c/gGvMPxisLn2/B2kiqKHn7kiKwm qZIhHHZAf6lD5M6DX0D6eOS91uJ8FvWXpKoZUv2mSJLHHb2KALX0tCKdnhB58nFK7VE/xL0n6C0 ePs7A07fk39LXMSri6ZIvC7CApoXdX7H2owlcj9rJI8EoSnW9P/fOdXvUQcT0= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-TMASE-INERTIA: 0-0;;;; X-TMASE-XGENCLOUD: e00be06c-b119-4b09-ae46-c159e6b2b2af-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?1749755598232654126?= X-GMAIL-MSGID: =?utf-8?q?1749755598232654126?= 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 --- -v2: Avoid line break Previously submitted as mmc: core: Do not require secure trim for discard drivers/mmc/core/core.c | 9 +++++++-- include/linux/mmc/mmc.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 95fa8fb1d45f..77d4dba462a2 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,7 @@ 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))