Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1099393pxk; Fri, 18 Sep 2020 03:52:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvfNlmu/xSZNOYcIaGAJouFk6UoDkyQSD9ZktjUv2OQI3uUq6QcxV5kgR3WTIRxOYoUZFu X-Received: by 2002:a17:906:1b58:: with SMTP id p24mr36732228ejg.77.1600426335132; Fri, 18 Sep 2020 03:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600426335; cv=none; d=google.com; s=arc-20160816; b=i2fxx1xH38Lr3kQxgoUfKoKKs6p/hW1EBtYqmNextWpu94/3zIZr7WFUtalw02JG6R ZByUqVU8xdKiGVeqF2xrXU6VfDs2F3kejrxcpP/KvQmcYLOHW8PeWCTgEIq2lyCKDrhm HtzK1k1pcTqNY67ZZ604tApKyzgYcowNAwOncAGAW+J/2F7nfCqLwMWerNUtk1uOvhcC bneiZhWRM00hFHSCcJtks1hxXZ+/jL2VV2H3ZwDPT7rJNLef6s/pZOfMtgKEg7vz/vFv HYeE/qHY23aErKjeYu9lp29tqgN7wE7hzDvTpPW07wvGRnAvXuA4FjczcF8g2s7n+EyM BCZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=I3G3khIWUlWhQUlaFkWi9beNmaTHarXOA3fj1sr8voA=; b=ItfiJbc4sVOSyKqxy7jvcR3Le0yAI2fNjLTdoibp8tPTCUssHCdyfYiU2feboIDBhF SUKf1MHBNS1Y+9jMq0184RFvABzuiI8D2LSzHO9zW3DiBx2DOLkJlKqrANAgHkepbH3R H2G6/cKasj9RSI24IJsoCgyARdHP0id3FH1T2MLS9mQj/9nTkmOFT6nR9/zkNdC63MwU ZQt6K6N/6WxHtkVJIX+1O595PTfsD3FMv4Yf1oHHUQFvoOAcIMu64h9r6ATPAtVO81R9 gp8mbnyjrCYls5b2Pjj3/SMmWxQiA/fDuN/15u9rv4PWRhg9Psd/CK7Jh6GeiRmRhjH+ R5DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XuOVvGLu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h2si1973126ejo.1.2020.09.18.03.51.51; Fri, 18 Sep 2020 03:52:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XuOVvGLu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726437AbgIRKug (ORCPT + 99 others); Fri, 18 Sep 2020 06:50:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725955AbgIRKug (ORCPT ); Fri, 18 Sep 2020 06:50:36 -0400 Received: from mail-yb1-xb43.google.com (mail-yb1-xb43.google.com [IPv6:2607:f8b0:4864:20::b43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00DD5C06174A; Fri, 18 Sep 2020 03:50:36 -0700 (PDT) Received: by mail-yb1-xb43.google.com with SMTP id h206so3972043ybc.11; Fri, 18 Sep 2020 03:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=I3G3khIWUlWhQUlaFkWi9beNmaTHarXOA3fj1sr8voA=; b=XuOVvGLuEBSGLqmcT234C1pVwvWhauxGpWof3PdOCoICAsJSISjuYshBKn1gA9mrta wHowlVYnoKJ9aK6wC0wMwuFoMAj68pyg5HehFzwh2NkJpt+tf1Crs/JvGM96rCxkG7XJ C1hMI8ZH6dfmKrsP3bxlDU4FfEVR09aB4g2/JxCNElR4bOYUcOmgnNTdzxDHrxJvB7aj 8OLj4MnYV7z7IxXH2WLsQLf+8uTXhUrrEgBe+3v2lxhiBujiAWfCi+YALpKk1iQSnuoa P6whW2xWwfBhnPYR277AtEaEdooLTZhyREnWtMeXWMRSpTWZsihTbwUyBPlVMIdwU82n VoKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=I3G3khIWUlWhQUlaFkWi9beNmaTHarXOA3fj1sr8voA=; b=VMFIM6zx/+7fLNTLTCn4I/WUf2CfMvvrGp4V29v8Q9vQjv+lt0C1Lw1MHjnGoQymla 0Zr2n7t/sXDBS6R0xTlAWDKxtdxYgZzb1ckdJbwfk4E43/opa93M9opxtp6az4C69p3g bQNBDb0CAz1ieeqYWWkXKXiLwkK4/bEefGEXBqbB8G388/M/Gd/FveDtGdIIftX4xXJd IeJFLtuQpKxyb3Ip0i18SQumDIgNvg6hTsxEfD1Rwa06i6QZND6ZE8/Eg3afu7TTwhzW YoKQwh5Bd9NPabUoygiqPUu7JA88Vukh59ey1It5CvO+5lnWKcD2nbKzSer3pySxC4M7 qo3w== X-Gm-Message-State: AOAM532TicX1nAcwTg2LppB0/KasSQrsLKEzgmRhGaiia99EnLuNGx0P mD1SgitaSfBOUCftPhKKSZnly1bZ5Nkve4w218g= X-Received: by 2002:a25:44:: with SMTP id 65mr8427789yba.6.1600426235320; Fri, 18 Sep 2020 03:50:35 -0700 (PDT) MIME-Version: 1.0 References: <20200710111054.29562-1-benchuanggli@gmail.com> <9fa17d60-a540-d0d8-7b2c-0016c3b5c532@intel.com> <20200918063843.GA46229@laputa> In-Reply-To: <20200918063843.GA46229@laputa> From: Ben Chuang Date: Fri, 18 Sep 2020 18:50:24 +0800 Message-ID: Subject: Re: [RFC PATCH V3 12/21] mmc: sdhci: UHS-II support, add hooks for additional operations To: AKASHI Takahiro , Adrian Hunter , Ben Chuang , Ulf Hansson , linux-mmc , Linux Kernel Mailing List , Ben Chuang , greg.tu@genesyslogic.com.tw, Renius.Chen@genesyslogic.com.tw Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 18, 2020 at 2:38 PM AKASHI Takahiro wrote: > > Adrian, Ben, > > Regarding _set_ios() function, > > On Fri, Aug 21, 2020 at 05:08:32PM +0300, Adrian Hunter wrote: > > On 10/07/20 2:10 pm, Ben Chuang wrote: > > > From: Ben Chuang > > > > > > In this commit, UHS-II related operations will be called via a function > > > pointer array, sdhci_uhs2_ops, in order to make UHS-II support as > > > a kernel module. > > > This array will be initialized only if CONFIG_MMC_SDHCI_UHS2 is enabled > > > and when the UHS-II module is loaded. Otherwise, all the functions > > > stay void. > > > > > > Signed-off-by: Ben Chuang > > > Signed-off-by: AKASHI Takahiro > > (snip) > > > > @@ -2261,6 +2324,7 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > > > { > > > struct sdhci_host *host = mmc_priv(mmc); > > > u8 ctrl; > > > + u16 ctrl_2; > > > > > > if (ios->power_mode == MMC_POWER_UNDEFINED) > > > return; > > > @@ -2287,6 +2351,10 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > > > sdhci_enable_preset_value(host, false); > > > > > > if (!ios->clock || ios->clock != host->clock) { > > > + if (IS_ENABLED(CONFIG_MMC_SDHCI_UHS2) && > > > + ios->timing == MMC_TIMING_UHS2) > > > + host->timing = ios->timing; > > > + > > > host->ops->set_clock(host, ios->clock); > > > host->clock = ios->clock; > > > > > > @@ -2308,6 +2376,18 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > > > else > > > sdhci_set_power(host, ios->power_mode, ios->vdd); > > > > > > + /* 4.0 host support */ > > > + if (host->version >= SDHCI_SPEC_400) { > > > + /* UHS2 Support */ > > > + if (IS_ENABLED(CONFIG_MMC_SDHCI_UHS2) && > > > + host->mmc->flags & MMC_UHS2_SUPPORT && > > > + host->mmc->caps & MMC_CAP_UHS2) { > > > + if (sdhci_uhs2_ops.do_set_ios) > > > + sdhci_uhs2_ops.do_set_ios(host, ios); > > > + return; > > > + } > > > + } > > > + > > > > Please look at using existing callbacks instead, maybe creating uhs2_set_ios(), uhs2_set_clock(), uhs2_set_power() > > I think that we will create uhs2_set_ios() (and uhs2_set_power() > as we discussed on patch#15/21), but not uhs_set_clock(). > > Since we have a hook only in struct mmc_host_ops, but not in struct > sdhci_ops, all the drivers who want to support UHS-II need to > set host->mmc_host_ops->set_ios to sdhci_uhs2_set_ios explicitly > in their own init (or probe) function. > (Again, sdhci_uhs2_set_ios() seems to be generic though.) > > Is this okay for you? > -> Adrian > > During refactoring the code, I found that sdhci_set_power() is called > twice in sdhci_set_ios(): > sdhci_set_ios(host, power_mode, vdd1, -1); in sdhci_set_ios(), and > sdhci_set_ios(host, power_mode, vdd1, vdd2) in ush2_do_set_ios() > > Can you please confirm that those are redundant? Yes, uhs2 set power is independent with uhs1. But set uhs2 power process should meet uhs2 spec. > -> Ben > > I also wonder why we need spin locks in uhs2_do_set_ios() while > not in sdhci_set_ios(). You can check if spin locks in uhs2_do_set_ios() is necessary. If set/clear irq can be execute safely without spin locks, you can remove spin locks. > > -> Ben > > -Takahiro Akashi