Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp423156rdb; Fri, 17 Nov 2023 02:50:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwu0DofsD3am0H+RRVkqbVipbV+yDQ3xOQyLxaWZDxB4BKD+qnoEHFsgWJqjIbYn5pvVgd X-Received: by 2002:a05:6870:6b0a:b0:1eb:192b:e75a with SMTP id mt10-20020a0568706b0a00b001eb192be75amr23329514oab.22.1700218201501; Fri, 17 Nov 2023 02:50:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700218201; cv=none; d=google.com; s=arc-20160816; b=Pf09p6IrZ0aZ745T4U8SITmtN2dyfP694qkozbgg612VaBW71YymoODTgFPGfTxT8s DQ3tpIaazkSEGWD0Gt1YA4h4Z4h24PgA5ZOEYWgMJjaMTFs4R9LArSWPRuy99oM+ZAe+ CZrmrLuIzKCXf8tcTPFpR0uVos4PwhZTre0iEzihBvVadDZh0IR/wsftw2wYdVZ87dZl qZobXCt0hQZAGpQzV6bgjL0OGori6+iEkljfvp+U2UwPIEklU3zcoNayUxVwcbtBQkUo gCvknMFVgXstKWHBtm1WjDBzXhuEOq3P8+9S2084xoZ/hUpyGDex9KnxDF333kdFiaFN eXIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GtugVttdKITBqqbOP9WWTC41X2egJw0BMcAKX1VCzrM=; fh=oJwPziDPgXe8FzmdvaA6HVOCv+2+cH7zLPo3b0+yY0Q=; b=LWPhkCaya+aj5UYJBxfohbzuKjyRAK4Augcb32sV5UWYKTMolmjYeILuWtEP52ONMM U0vDwxtPQTpVAiYtC4BTMp2QQ2OmU5aXK2fwgQ/GuI0EsuOE9mWaI/2QEgZSDGnDE6pW ADpsrKj/us2PPT9uoqFPsCgEXX8HZwc3sOF/Gp/90cucJ6F9FQux9cvdjC5hYskop9yf OGmPpPzmjSEGWzv4B6r5m50jyDs1HSCMCTQjdLHGfwoMfVgjRGPDSqpcAa4npFr51WdI YmZDIYsU4wWcSYwA/3Uhe/vf6+sgf6D1MkdV7UWGJNGdDQ+xeeTbDUlzSHeh3UNTix4J 4LJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LZnWEoRM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z17-20020a631911000000b00573fc592e9dsi1585699pgl.848.2023.11.17.02.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 02:50:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LZnWEoRM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F2311827C199; Fri, 17 Nov 2023 02:49:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345923AbjKQKt6 (ORCPT + 99 others); Fri, 17 Nov 2023 05:49:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230379AbjKQKt5 (ORCPT ); Fri, 17 Nov 2023 05:49:57 -0500 Received: from mail-ua1-x931.google.com (mail-ua1-x931.google.com [IPv6:2607:f8b0:4864:20::931]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A652C2; Fri, 17 Nov 2023 02:49:51 -0800 (PST) Received: by mail-ua1-x931.google.com with SMTP id a1e0cc1a2514c-7be55675503so724576241.1; Fri, 17 Nov 2023 02:49:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700218190; x=1700822990; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=GtugVttdKITBqqbOP9WWTC41X2egJw0BMcAKX1VCzrM=; b=LZnWEoRMNfnmOZIfYcZVRGhcDLmAXgme3Y+lF8/jpa9jsK0oiHBcizR7iSFPqCBK6V xTmKpt/AgkYcrZLdp5nay+Ziyegfi+rFx4nUwV2ctdpsC000pLtuNLRc9tTecUhqDJ4x H0PteGsGt0ORrcnTsP2ego+4K4IYmwr3215GMQXlqsgdrNsKfErDaPOOxynUypmYrw4Z lTSt2bmLgXGQkfsyWyZtXMamVXB8zl3VCOXIVrX5B84GfSeTWHqbC2AY8exSTjhcgNyM N1SaOkylKNAuIOatA6ItOAHNp9c4z8lGT/yVI7G54hlJv6eVZQqEMXh+9k1yRPk7UuVE lKLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700218190; x=1700822990; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GtugVttdKITBqqbOP9WWTC41X2egJw0BMcAKX1VCzrM=; b=spDo1kRytSh3g6IUWev0I9/BRkarVFviERGw7dNDel/fHQVw1m6tychrkDcwwUQ2jp HxwMCe3/QIEkiIN3UdF7yHeJ2S3vpWZePCE3eG3rP48VVGTvex/TJCpj9rx3ZhOhpILz OddLL4zAHR/54ZZQaep0Hs1eT5CUOez4Ki2MDpu6hEnz31H/YNbBrJ2ErQsh6SKe1FdJ 9Juo5MZReBxT77jZyrAtEsxO4xgpqlzwNCwcr8qcZWn4uv8qvlYUl965NMi2sdccek0M +mB/+2zVs0QMcTOrJUvrSqSOe9kgk+LfAqGyKM3xFl8XbQxXeJAhf29rwRvfeWONh4Tp KNkA== X-Gm-Message-State: AOJu0YxO4inCSi9tO7hDqBizKJ+PugPy7h8fNnNNvb13YRsIQKHLjYE7 qTpbxvcDyo7FQQkCQM9s5quWCzon4BprZhke0gY= X-Received: by 2002:a05:6102:20d1:b0:462:887c:1698 with SMTP id i17-20020a05610220d100b00462887c1698mr144708vsr.3.1700218190079; Fri, 17 Nov 2023 02:49:50 -0800 (PST) MIME-Version: 1.0 References: <20230915094351.11120-1-victorshihgli@gmail.com> <20230915094351.11120-11-victorshihgli@gmail.com> <81bf38cd-b6a4-4a6f-a51d-bc916e3b8f96@intel.com> In-Reply-To: From: Victor Shih Date: Fri, 17 Nov 2023 18:49:37 +0800 Message-ID: Subject: Re: [PATCH V12 10/23] mmc: sdhci-uhs2: add reset function and uhs2_mode function To: Ulf Hansson Cc: Adrian Hunter , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 02:50:00 -0800 (PST) On Tue, Oct 10, 2023 at 7:08=E2=80=AFPM Ulf Hansson wrote: > > On Tue, 10 Oct 2023 at 12:29, Adrian Hunter wro= te: > > > > On 4/10/23 11:35, Ulf Hansson wrote: > > > On Tue, 3 Oct 2023 at 17:03, Adrian Hunter = wrote: > > >> > > >> 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/sd= hci-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 add= ed > > >>>>> 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 =3D 0; > > >> host->ios.clock =3D 0; > > >> - host->ios.timing =3D MMC_TIMING_LEGACY; > > >> + /* Must set UHS2 timing to identify UHS2 mode */ > > >> + host->ios.timing =3D MMC_TIMING_UHS2_SPEED_A; > > >> host->ios.power_mode =3D MMC_POWER_OFF; > > >> if (host->flags & MMC_UHS2_SD_TRAN) > > >> host->flags &=3D ~MMC_UHS2_SD_TRAN; > > >> @@ -1095,7 +1096,8 @@ static void sd_uhs2_detect(struct mmc_host *ho= st) > > >> mmc_claim_host(host); > > >> mmc_detach_bus(host); > > >> sd_uhs2_power_off(host); > > >> - host->flags &=3D ~MMC_UHS2_SUPPORT; > > >> + /* Remove UHS2 timing to indicate the end of UHS2 mo= de */ > > >> + host->ios.timing =3D MMC_TIMING_LEGACY; > > >> mmc_release_host(host); > > >> } > > >> } > > >> @@ -1338,7 +1340,8 @@ static int sd_uhs2_attach(struct mmc_host *hos= t) > > >> err: > > >> mmc_detach_bus(host); > > >> sd_uhs2_power_off(host); > > >> - host->flags &=3D ~MMC_UHS2_SUPPORT; > > >> + /* Remove UHS2 timing to indicate the end of UHS2 mode */ > > >> + host->ios.timing =3D MMC_TIMING_LEGACY; > > >> return err; > > >> } > > > > > > I wouldn't mind changing to the above. But, maybe an even better > > > option is to use the ->timing variable in the struct sdhci_host, as > > > it's there already to keep track of the current/previous timing state= . > > > Would that work too? > > > > The host does not really have enough information. > > Okay, let's go with the approach you suggested above/below then! > Hi, Ulf and Adrian I will update this in version 13. Thanks, Victor Shih > > > > > > > >> > > >> 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_ho= st *mmc, struct mmc_ios *ios) > > >> > > >> /* UHS2 timing. Note, UHS2 timing is disabled when powering = off */ > > >> ctrl_2 =3D sdhci_readw(host, SDHCI_HOST_CONTROL2); > > >> - if (ios->timing =3D=3D MMC_TIMING_UHS2_SPEED_A || > > >> - ios->timing =3D=3D MMC_TIMING_UHS2_SPEED_A_HD || > > >> - ios->timing =3D=3D MMC_TIMING_UHS2_SPEED_B || > > >> - ios->timing =3D=3D MMC_TIMING_UHS2_SPEED_B_HD) > > >> + if (ios->power_mode !=3D MMC_POWER_OFF && > > >> + (ios->timing =3D=3D MMC_TIMING_UHS2_SPEED_A || > > >> + ios->timing =3D=3D MMC_TIMING_UHS2_SPEED_A_HD || > > >> + ios->timing =3D=3D MMC_TIMING_UHS2_SPEED_B || > > >> + ios->timing =3D=3D MMC_TIMING_UHS2_SPEED_B_HD)) > > >> ctrl_2 |=3D SDHCI_CTRL_UHS2 | SDHCI_CTRL_UHS2_ENABLE= ; > > >> else > > >> ctrl_2 &=3D ~(SDHCI_CTRL_UHS2 | SDHCI_CTRL_UHS2_ENAB= LE); > > >> > > >> > > Kind regards > Uffe