Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1572247pxk; Thu, 10 Sep 2020 20:37:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlEjEFhVeWY2BD4lT0vymm61xZ2oIp1JIDF0cOlFFSO24weDan9ESMz8v4GzEhRAGDz++v X-Received: by 2002:aa7:c38a:: with SMTP id k10mr12967674edq.325.1599795433562; Thu, 10 Sep 2020 20:37:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599795433; cv=none; d=google.com; s=arc-20160816; b=OX/zphMkCyhQ7iTSYZ9YMh/vRqepk5c0WaihexuhPINAPDC9ftPAGFyWaFtdmsdkcn ann3EBfzqLiSrnrR7SfvbRtupV53OV6bopVW13DSO3K+1oJIxIlul4Gyhe7FIV6bmNs7 nbK65WXihxOjVboZueab0wogfiNjUjuVhFqQoUt3uX5OpghXhEkPUrYAdc4BvM21qeQr kYssSTXncaxhVwhMtPBKuC6Ui+LtKTA78Y7VZEjbWysrhKB8IQl9NZBkfUkijlQa+TWu Mp4+hZVy0R+JxNvA3AxCjx9LRU827B6+xiDHOzWyiZ2MXg5SldurFUh8s8hleo7Ng+Dw Ql9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rdWC82PKEhEwsaXh3LAxl47RN5F/LTuAnkpnqIreE2Q=; b=JCn51rSfMGtEAPVVnYXJ1ocBv4bu7sHfazYaOuJbfpA6B3ePLWFrx0TOcO/0WLYPZ/ M57WRSS/uROQrHIz6CCimfn6G/miHlA7VwJuZlCWRFhlS+DLY2JiIzu6jN476dSd9/ND Ujj0bHxtcMQfjFkHO/WWxRpQGViDtFyvIxx/Ag/88a59qPSta8Fv6Hpp8UGER8uipUXe j11BNy1pc017jCSNpAbBdqunEhdw/UOu4lr9BFiybvC/QhftM6Lc8xp04wb6VND33x2P fG+JH7OCh0f455hVMvEUq4YWW4BO9Ugl1XQdcymz3YtMfw4jgRVZMz04rXZyDhMV7A1w t1Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jms.id.au header.s=google header.b=f7hAImC+; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h10si443107edw.139.2020.09.10.20.36.50; Thu, 10 Sep 2020 20:37:13 -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=@jms.id.au header.s=google header.b=f7hAImC+; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725730AbgIKDeP (ORCPT + 99 others); Thu, 10 Sep 2020 23:34:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725300AbgIKDeL (ORCPT ); Thu, 10 Sep 2020 23:34:11 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBBBCC061573; Thu, 10 Sep 2020 20:34:10 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id w1so8532361edr.3; Thu, 10 Sep 2020 20:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jms.id.au; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rdWC82PKEhEwsaXh3LAxl47RN5F/LTuAnkpnqIreE2Q=; b=f7hAImC+A8EN07tWzuoorjAACjNBmgZj9nxMqSY+DSMKQiuC5kczlXpOVkgrBoMLSt EFCR7nxnwQhkOKl8k72xV56bOooIo3JMF0iY4Ddg4LHP1XqouEAEAF+KMEWCU/7k4LsE ERbh2VMLY3LELI+NF8FJ8mJZhyE4tJiJL4hT8= 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:cc; bh=rdWC82PKEhEwsaXh3LAxl47RN5F/LTuAnkpnqIreE2Q=; b=iUFE9/v8Coje5M9MEvR17/uSMdjYB5WKBZfdxp25Q7P4zeNUaLV0oa9r+tH/OPlxPB /f4ZRZl1TbuTsp6U0k3rOHEtA/KYb6TNw0YViwLs9N/xu/1YKlHQthF7pMp/KnbdRnj7 dlieoly8MV4FEIBH0Eoeo4NtFqLVEg8D3doFBCO/VigGgil133wv8uER6gUkYWBLxxRJ hbJDj0fAXk4qnQSDWkQYFvxS6stvYVNoOZ4ePxzL+S7SbpJt4dlV/rcJ1JTMiHT3Dtpf RL8d9c9t69TOO6rPmoC+qjANUTxVUMO+Jtav9VlQ3wzfpdotIaKsIUtFmIp6HP9wf/WK lMCg== X-Gm-Message-State: AOAM533C4NEVkyTpESzpb0WTOBsb0lmbrVNbAuh1jqFw67ZTC4CX4jv5 sLzXGjvYloc1e2+H90phpnNbS4FOqp5yOzxbDIA= X-Received: by 2002:aa7:d959:: with SMTP id l25mr12310657eds.383.1599795249576; Thu, 10 Sep 2020 20:34:09 -0700 (PDT) MIME-Version: 1.0 References: <20200910105440.3087723-1-andrew@aj.id.au> <20200910105440.3087723-3-andrew@aj.id.au> <57d48d7a-7cea-4be7-92bd-8f3b93f84a06@www.fastmail.com> In-Reply-To: <57d48d7a-7cea-4be7-92bd-8f3b93f84a06@www.fastmail.com> From: Joel Stanley Date: Fri, 11 Sep 2020 03:33:56 +0000 Message-ID: Subject: Re: [PATCH 2/3] mmc: sdhci-of-aspeed: Expose data sample phase delay tuning To: Andrew Jeffery Cc: linux-mmc , Adrian Hunter , Ulf Hansson , Rob Herring , devicetree , Linux ARM , linux-aspeed , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 11 Sep 2020 at 02:49, Andrew Jeffery wrote: > > > > On Fri, 11 Sep 2020, at 11:32, Joel Stanley wrote: > > On Thu, 10 Sep 2020 at 10:55, Andrew Jeffery wrote: > > > > > > Allow sample phase adjustment to deal with layout or tolerance issues. > > > > > > Signed-off-by: Andrew Jeffery > > > --- > > > drivers/mmc/host/sdhci-of-aspeed.c | 137 +++++++++++++++++++++++++++-- > > > 1 file changed, 132 insertions(+), 5 deletions(-) > > > > > > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c > > > index 4f008ba3280e..641accbfcde4 100644 > > > --- a/drivers/mmc/host/sdhci-of-aspeed.c > > > +++ b/drivers/mmc/host/sdhci-of-aspeed.c > > > +static void > > > +aspeed_sdc_configure_phase(struct aspeed_sdc *sdc, > > > + const struct aspeed_sdhci_phase_desc *phase, > > > + uint8_t value, bool enable) > > > +{ > > > + u32 reg; > > > + > > > + spin_lock(&sdc->lock); > > > > What is the lock protecting against? > > > > We call this in the ->probe, so there should be no concurrent access going on. > > Because the register is in the "global" part of the SD/MMC controller address > space (it's not part of the SDHCI), and there are multiple slots that may have > a driver probed concurrently. That points to having the property be part of the "global" device tree node. This would simplify the code; you wouldn't need the locking either. > > > > > > > > + reg = readl(sdc->regs + ASPEED_SDC_PHASE); > > > + reg &= ~phase->enable_mask; > > > + if (enable) { > > > + reg &= ~phase->value_mask; > > > + reg |= value << __ffs(phase->value_mask); > > > + reg |= phase->enable_value << __ffs(phase->enable_mask); > > > + } > > > + writel(reg, sdc->regs + ASPEED_SDC_PHASE); > > > + spin_unlock(&sdc->lock); > > > +} > > > + > > > static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock) > > > { > > > struct sdhci_pltfm_host *pltfm_host; > > > @@ -155,8 +195,58 @@ static inline int aspeed_sdhci_calculate_slot(struct aspeed_sdhci *dev, > > > return (delta / 0x100) - 1; > > > } > > > > > > +static int aspeed_sdhci_configure_of(struct platform_device *pdev, > > > + struct aspeed_sdhci *sdhci) > > > +{ > > > + u32 iphase, ophase; > > > + struct device_node *np; > > > + struct device *dev; > > > + int ret; > > > + > > > + if (!sdhci->phase) > > > + return 0; > > > + > > > + dev = &pdev->dev; > > > + np = dev->of_node; > > > + > > > + ret = of_property_read_u32(np, "aspeed,input-phase", &iphase); > > > + if (ret < 0) { > > > + aspeed_sdc_configure_phase(sdhci->parent, &sdhci->phase->in, 0, > > > + false); > > > > Will this clear any value that eg. u-boot writes? > > No, see the 'enable' test in aspeed_sdc_configure_phase() OK, so this branch will never cause any change in the register? Best to drop it then. > > > > > The register should be left alone if the kernel doesn't have a > > configuration of it's own, otherwise we may end up breaking an > > otherwise working system. > > Right, I can rework that.