Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2020142rdb; Tue, 3 Oct 2023 08:03:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHrloxiOMyLUQDikhFbyLAe9Tmb/EAUWAOBGa2uyLTTdRoyPBVcUGoHSl80L/8K9JoftHk4 X-Received: by 2002:a17:903:230d:b0:1c7:54f1:337e with SMTP id d13-20020a170903230d00b001c754f1337emr8579252plh.33.1696345414052; Tue, 03 Oct 2023 08:03:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696345414; cv=none; d=google.com; s=arc-20160816; b=qBzwJOYPN45yLaL15gIqnBn9pgS0zLN54HDa8rRf9WGx0tXBMYsqjmRTL3Cfm+ZDdC aZ4yE/95FKBgAd78EAVTQxOsX36q8+aE2+X0AYoufm2nJuccLjRiCGAO40jzVIF7sWPg o9Y8UhtWi/fsiLaK2ayjHnVmjHjvlP1Z6UKd2MInPL1bQVnE4gGHrUyLlROKaF5nBl+q upGAStVuwCoXHL5QxxLX6X4jhwCXEVbV7w5Wgdn/Mhhc84NPBqeUQaLSFdo1zC4OVuCx yaFcz4TckZ5AQ6SXN0y8i1KgEI2TI7zmYN10SdDTgmktKbJKnbLG+wYbEN2Lwz1Y1WN6 Rf3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=itPSWChSKSi6ugS/lmgoutrSOcaHkJCVBahg+HjNGKc=; fh=PPO2FGV28VWBPzTqbtJvrdyXxlp3INATmGBO8gHABZ4=; b=UEjXxSQoj1W855mUzM/g9pkuEWPjH5oDyIjsQjtZgufVTVD+jya1X1WITF7auRoZ/H +qNVK+RG8F96KNnsDi6AenIwTYWSUrwDpVUCTq6vexVHBiXmnr2jyJ9kFe9hlCaZp/rD 1dg65JRYOhkQ7dHKB4G1R4oi+9/rTKwh+HFmHHS5gzq7TqWN5ka99PmTTq7C20gCxwXP xAS+znztEzmfLb9e3664KPO0KYLNYIXFb1bu5z9V5HWUrRH+4YKpYR3MswbRO/LlQQ0p tmYAJ56bPKtDb0mGwHWwwL7UNhTSqsyB0pgyv2Ig0E5ab/vLtskeiN/AIpWOSGBaLN55 hxWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=L5J7yxkj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id r2-20020a170902c60200b001c72476ca30si1477775plr.281.2023.10.03.08.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 08:03:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=L5J7yxkj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id BFBBF802B00F; Tue, 3 Oct 2023 08:03:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240092AbjJCPDU (ORCPT + 99 others); Tue, 3 Oct 2023 11:03:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231321AbjJCPDT (ORCPT ); Tue, 3 Oct 2023 11:03:19 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88258A1; Tue, 3 Oct 2023 08:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696345394; x=1727881394; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=rW+Lg7rT5WGFqXNG31SVtvblQmNhqrvYQey1S6Xq/7U=; b=L5J7yxkjDXD4/VTpUuvE/Q1i4WnxA/aRGQZEE862uYT9cTRuuN831MbQ MtoDpH0KLKJBbiPfYdbPlHmCgSgq/tjERjqFFjSLCIZge9avpydBsclXu VhEdzQ8Btp9lZbK8xJOUlG8Us50NJc2gOnWYEdZ1ai0qjjeiCllyf/mkI knbsu2qPq/QTgt80uAbCFwRU9CLwqRzfm986x5tgpYZyE//lulV0BkKmy D6hsBH/wddcas3APT1g1fJYHTt+T9HmM5mElldNffYidkehaGzdbhvvR7 S2OXGebortVR9ohg20W69aEr49uM7ktojgw8EpfHWy6z4ase4w4WKNZ5M A==; X-IronPort-AV: E=McAfee;i="6600,9927,10852"; a="469172258" X-IronPort-AV: E=Sophos;i="6.03,197,1694761200"; d="scan'208";a="469172258" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2023 08:02:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10852"; a="874733955" X-IronPort-AV: E=Sophos;i="6.03,197,1694761200"; d="scan'208";a="874733955" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.252.56.99]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2023 08:02:30 -0700 Message-ID: <81bf38cd-b6a4-4a6f-a51d-bc916e3b8f96@intel.com> Date: Tue, 3 Oct 2023 18:02:24 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V12 10/23] mmc: sdhci-uhs2: add reset function and uhs2_mode function Content-Language: en-US To: Ulf Hansson Cc: Victor Shih , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, benchuanggli@gmail.com, HL.Liu@genesyslogic.com.tw, Greg.tu@genesyslogic.com.tw, takahiro.akashi@linaro.org, dlunev@chromium.org, Ben Chuang , Victor Shih References: <20230915094351.11120-1-victorshihgli@gmail.com> <20230915094351.11120-11-victorshihgli@gmail.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 03 Oct 2023 08:03:30 -0700 (PDT) On 3/10/23 15:22, Ulf Hansson wrote: > On Tue, 3 Oct 2023 at 13:37, Adrian Hunter wrote: >> >> On 3/10/23 13:30, Ulf Hansson wrote: >>> On Fri, 15 Sept 2023 at 11:44, Victor Shih wrote: >>>> >>>> From: Victor Shih >>>> >>>> Sdhci_uhs2_reset() does a UHS-II specific reset operation. >>>> >>>> Signed-off-by: Ben Chuang >>>> Signed-off-by: AKASHI Takahiro >>>> Signed-off-by: Victor Shih >>>> Acked-by: Adrian Hunter >>>> --- >>>> >>>> Updates in V8: >>>> - Adjust the position of matching brackets. >>>> >>>> Updates in V6: >>>> - Remove unnecessary functions and simplify code. >>>> >>>> --- >>>> >>>> drivers/mmc/host/sdhci-uhs2.c | 45 +++++++++++++++++++++++++++++++++++ >>>> drivers/mmc/host/sdhci-uhs2.h | 2 ++ >>>> 2 files changed, 47 insertions(+) >>>> >>>> diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c >>>> index e339821d3504..dfc80a7f1bad 100644 >>>> --- a/drivers/mmc/host/sdhci-uhs2.c >>>> +++ b/drivers/mmc/host/sdhci-uhs2.c >>>> @@ -10,7 +10,9 @@ >>>> * Author: AKASHI Takahiro >>>> */ >>>> >>>> +#include >>>> #include >>>> +#include >>>> >>>> #include "sdhci.h" >>>> #include "sdhci-uhs2.h" >>>> @@ -49,6 +51,49 @@ void sdhci_uhs2_dump_regs(struct sdhci_host *host) >>>> } >>>> EXPORT_SYMBOL_GPL(sdhci_uhs2_dump_regs); >>>> >>>> +/*****************************************************************************\ >>>> + * * >>>> + * Low level functions * >>>> + * * >>>> +\*****************************************************************************/ >>>> + >>>> +bool sdhci_uhs2_mode(struct sdhci_host *host) >>>> +{ >>>> + return host->mmc->flags & MMC_UHS2_SUPPORT; >>> >>> The MMC_UHS2_SUPPORT bit looks redundant to me. Instead, I think we >>> should be using mmc->ios.timings, which already indicates whether we >>> are using UHS2 (MMC_TIMING_UHS2_SPEED_*). See patch2 where we added >>> this. >>> >>> That said, I think we should drop the sdhci_uhs2_mode() function >>> altogether and instead use mmc_card_uhs2(), which means we should move >>> it to include/linux/mmc/host.h, so it becomes available for host >>> drivers. >>> >> >> UHS2 mode starts at UHS2 initialization and ends either when UHS2 >> initialization fails, or the card is removed. >> >> So it includes re-initialization and reset when the transfer mode >> currently transitions through MMC_TIMING_LEGACY. >> >> So mmc_card_uhs2() won't work correctly for the host callbacks >> unless something is done about that. > > Right, thanks for clarifying! > > In that case I wonder if we couldn't change the way we update the > ->ios.timing for UHS2. It seems silly to have two (similar) ways to > indicate that we have moved to UHS2. Perhaps something like below: diff --git a/drivers/mmc/core/sd_uhs2.c b/drivers/mmc/core/sd_uhs2.c index aacefdd6bc9e..e39d63d46041 100644 --- a/drivers/mmc/core/sd_uhs2.c +++ b/drivers/mmc/core/sd_uhs2.c @@ -70,7 +70,8 @@ static int sd_uhs2_power_off(struct mmc_host *host) host->ios.vdd = 0; host->ios.clock = 0; - host->ios.timing = MMC_TIMING_LEGACY; + /* Must set UHS2 timing to identify UHS2 mode */ + host->ios.timing = MMC_TIMING_UHS2_SPEED_A; host->ios.power_mode = MMC_POWER_OFF; if (host->flags & MMC_UHS2_SD_TRAN) host->flags &= ~MMC_UHS2_SD_TRAN; @@ -1095,7 +1096,8 @@ static void sd_uhs2_detect(struct mmc_host *host) mmc_claim_host(host); mmc_detach_bus(host); sd_uhs2_power_off(host); - host->flags &= ~MMC_UHS2_SUPPORT; + /* Remove UHS2 timing to indicate the end of UHS2 mode */ + host->ios.timing = MMC_TIMING_LEGACY; mmc_release_host(host); } } @@ -1338,7 +1340,8 @@ static int sd_uhs2_attach(struct mmc_host *host) err: mmc_detach_bus(host); sd_uhs2_power_off(host); - host->flags &= ~MMC_UHS2_SUPPORT; + /* Remove UHS2 timing to indicate the end of UHS2 mode */ + host->ios.timing = MMC_TIMING_LEGACY; return err; } diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c index 517c497112f4..d1f3318b7d3a 100644 --- a/drivers/mmc/host/sdhci-uhs2.c +++ b/drivers/mmc/host/sdhci-uhs2.c @@ -267,10 +267,11 @@ static void __sdhci_uhs2_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) /* UHS2 timing. Note, UHS2 timing is disabled when powering off */ ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2); - if (ios->timing == MMC_TIMING_UHS2_SPEED_A || - ios->timing == MMC_TIMING_UHS2_SPEED_A_HD || - ios->timing == MMC_TIMING_UHS2_SPEED_B || - ios->timing == MMC_TIMING_UHS2_SPEED_B_HD) + if (ios->power_mode != MMC_POWER_OFF && + (ios->timing == MMC_TIMING_UHS2_SPEED_A || + ios->timing == MMC_TIMING_UHS2_SPEED_A_HD || + ios->timing == MMC_TIMING_UHS2_SPEED_B || + ios->timing == MMC_TIMING_UHS2_SPEED_B_HD)) ctrl_2 |= SDHCI_CTRL_UHS2 | SDHCI_CTRL_UHS2_ENABLE; else ctrl_2 &= ~(SDHCI_CTRL_UHS2 | SDHCI_CTRL_UHS2_ENABLE);