Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp916853pxk; Fri, 25 Sep 2020 00:56:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp5XzheL4PzyREXE6KXxBPDJ39gMaj4EWFop49oVXsn1coPIGXFmlbjFEpddOrHlwgWN+o X-Received: by 2002:a50:cc9a:: with SMTP id q26mr11582edi.64.1601020614615; Fri, 25 Sep 2020 00:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601020614; cv=none; d=google.com; s=arc-20160816; b=yBxUagu7baAkZ6v0vFHz6a990wxvxz/7ZlV/GAE6zmIk61nyiLtW/RStOJarvORGw5 T7w5Jj5PzTBthNhKi53W4KAqLNyEuQ32QO2niB4x5mc5WQ12xtYRHvjW7yLV3YJgjQFA /bds8bch/4xoOFMrSyM7UEgGp1Hl8INHgO/4PlUcYYOWLyRP3EijXTQ5GHhs3nZn3ZSB sNni6L9mpMSWINGgwDkabarEQfoFhBbWRlfZNeq6JJzDG3/A/Ac+mdOnS7Xjjl9W+8NE 4jfP8msIedJ4T0e3LmR/NZKw0Ek49RHhD+rVU+/4JCz2kAxteIhvW9CTJf3l1JFdGKgr HIQw== 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=iJo/1ogq0q+CXmZVEN9qkXyL/ZNzxnbVbLL8sTb+tF0=; b=IPXJtQ+3cTgVBCxoaS97Ul+0Rmj9vw+dsXq/du3cO2SjTuG8tP3ac9SgSvB2QEmvq8 Pb0Sw4npkdVJMa4Yph/X0IVVbnONNWKt5MrjzISTUc88dEWOU15p185IGppVkkfhmTwv Ia+ws8YbovMn9k8YMyic+RiJnZIR83Zc/R0ZY5+oXHuSoVw/NRcI2gnFKV5MvtUVz4pQ o7k+3dXy2RyO8Ft7vaJYDmEdDNOxDFsyARErsQi9HNcq6g8llB2wsZUWT5UYmkoNE7vy tBmLv3UJRkdErUhS+hRr6l2pe/lQaDWfqYhlIc2u9R/KTWt036+WiFlYS5ED376DevIB n7+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bms69fzJ; 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 e12si1288407ejb.104.2020.09.25.00.56.30; Fri, 25 Sep 2020 00:56:54 -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=bms69fzJ; 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 S1727472AbgIYHzb (ORCPT + 99 others); Fri, 25 Sep 2020 03:55:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727401AbgIYHza (ORCPT ); Fri, 25 Sep 2020 03:55:30 -0400 Received: from mail-yb1-xb44.google.com (mail-yb1-xb44.google.com [IPv6:2607:f8b0:4864:20::b44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 747BFC0613CE; Fri, 25 Sep 2020 00:55:30 -0700 (PDT) Received: by mail-yb1-xb44.google.com with SMTP id x8so1362597ybe.12; Fri, 25 Sep 2020 00:55:30 -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=iJo/1ogq0q+CXmZVEN9qkXyL/ZNzxnbVbLL8sTb+tF0=; b=bms69fzJWqOnBLlGtPq3geLMZqTGFHhkCMg5DPJr5ZS9jNt/gWMnCkZPaQL3xL7Cdd sxOaKx3HeHgqgqOiy9HruN4ayDfLBCzcgpB2WsZUBGl/mVLPPkLpxESgXYMuIXwPefST F6zIn0WbQVdB8AJh45RAR7CYMZqyH3910XKDCFJxsT6ITF0EvoFPJ4kVQQrm8IoPCmiG ZFo7t0c2ChBxEqLXGtiPJTPzlw02AA7vGYTYUqIvDR490fVbnDzdyDoulcImg5tPlfk4 L15bOrLlNfwr7J0rQBzUaznaLyp86khr03PFGn0VDZZEq9vhR/esd2nO6nCZ3Bc3iyE/ MEYw== 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=iJo/1ogq0q+CXmZVEN9qkXyL/ZNzxnbVbLL8sTb+tF0=; b=Q4NeBCB58rYlR6gQ9uQpyf4Lr7m9UrZ6aRzU8T1owFu3d9oYG+Cd6TOR9zV1+INii0 vJAKxAlA0tKyHxwvanHRd5Cg+IndundhQ/NfIvscLqeQDU3kdVfEJxCUYX+usXoF7FGx ToHiOjtPci3oaMjJ7fAWvfPmsryeoaGQju1wiT0UsRyEEStz/d2mQ2kcKQUQieFhQc3G 6YCvqx/o5wZdXxe9nLXS69n//AQwJBAkgXDE9VLJ2FvAtK9fBB003MlnOpP5r0ZdyDWE ojbQsBVSUdHfmHM9uoA/Td5wQtCBR/0zXpW/hhVAs5NA1ZNNsG5/cqhSFhfwUC37KbJc vGig== X-Gm-Message-State: AOAM530ba3HQmThRR9Syk72U6yEnedm8eHkGMDU6bkPj58KV1gaHx3Aj BXuz9CehqkLCXqAKENcmlt2x4SZl16TDcOmYbBw= X-Received: by 2002:a25:c786:: with SMTP id w128mr3533818ybe.135.1601020529448; Fri, 25 Sep 2020 00:55:29 -0700 (PDT) MIME-Version: 1.0 References: <20200710111054.29562-1-benchuanggli@gmail.com> <9fa17d60-a540-d0d8-7b2c-0016c3b5c532@intel.com> <20200918063843.GA46229@laputa> <20200924095747.GB38298@laputa> In-Reply-To: <20200924095747.GB38298@laputa> From: Ben Chuang Date: Fri, 25 Sep 2020 15:55:18 +0800 Message-ID: Subject: Re: [RFC PATCH V3 12/21] mmc: sdhci: UHS-II support, add hooks for additional operations To: AKASHI Takahiro , Ben Chuang , Adrian Hunter , 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 Takahiro, On Thu, Sep 24, 2020 at 5:57 PM AKASHI Takahiro wrote: > > Ben, > > On Fri, Sep 18, 2020 at 06:50:24PM +0800, Ben Chuang wrote: > > 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. > > Can you elaborate a bit more about the last sentence, please? > > What I meant above is that > sdhci_set_ios(host, power_mode, vdd1, vdd2) in ush2_do_set_ios() > > this code will 'set_power' both vdd and vdd2 anyway and so > sdhci_set_ios(host, power_mode, vdd1, -1); in sdhci_set_ios(), and > is just redundant. > Yes, for uhs-2 flow, sdhci_set_ios(host, power_mode, vdd1, -1) is redundant. > > > > -> 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. > > I'm asking you. > > While calling set_ios() doesn't require spin locks, are you aware of > any cases where we need spin locks in calling set_ios() for uhs-2? > (I mean that callers/contexts are the same either for uhs or uhs-2.) I agree that it can be removed. I just didn't modify intel's original codes. > > -Takahiro Akashi > > > If set/clear irq can be execute safely without spin locks, you can > > remove spin locks. > > > > > > > > -> Ben > > > > > > -Takahiro Akashi