Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp160668pxy; Thu, 6 May 2021 23:43:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcVvZ0zE2/jGMDYUwa248/vTmuUDJbhfjKE34VT3aPElrS0TEyPLkT6y1U2VT2yaNUcSlF X-Received: by 2002:a17:906:c788:: with SMTP id cw8mr8236987ejb.190.1620369807314; Thu, 06 May 2021 23:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620369807; cv=none; d=google.com; s=arc-20160816; b=NM2sBqgTd/g9TS9Sj+n2OoTrmF+98C13DqVpehWiGBUZRKccR5rU60TRRmelvs8o94 RWSXKiV85HT3lJAPqYFPsrG2Y1tmj9v3gBMQqLJVk5CGwx9zgIyGCCD53IUPRkpqDJkF koQXlkUUz8vcrRsQ33MnvnuTIrEzZHTwibqgHrDudjoGXB30hh9gAlDAo+cmbinuIwpi pzCy896tBOXM4RkMP8XV+yoUFshpKqoZ5M7zE9GgzsGqbmIaepJAiRwRqsdTUW2H4mRG jh/S0oY4shgY3J9ZmpIPMhTEU3KwoeoHWpKOP0s116r9ENpYp/1Fka/m5Tr+S1NDeLr1 hyPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=08J+BbOd4YC6oyJ6cxSH8c6hXMzJ0BG+KdoB8LDPP10=; b=sVhEszAUv1p/bRxJO31XgJ55Gf8qVtuagUWR5rSXEETfdnHtSSt07b/FB8XsOsuTw/ J2ipvIwIgqbhCsZxRp+EGc4/GjwKZnc0PorGbaIIeYakjxWJaroOPjfVaGlhzllikPcT W1/C9dJNNq+zWdL/mPkGeVKVMR6M8fSQjInBp66heuIqdrsHQpe3Z2PFoarNj1t56O+8 Z50w+ZDYo74PXkU7AQDfEB4+BGfLMexqPjuRycxbyqpnnpyd1xOF0BgGR7E/uJAJgiSL 49i7zyScChVK2Ov78smjQwZ7d8+g5soiGr2fDqjn41CroIm8mIrKbdNas3SPLTAB0Eyb E0eA== ARC-Authentication-Results: i=1; mx.google.com; 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 f16si4856512edy.138.2021.05.06.23.43.02; Thu, 06 May 2021 23:43:27 -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; 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 S233960AbhEGGEs (ORCPT + 99 others); Fri, 7 May 2021 02:04:48 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:50889 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbhEGGEr (ORCPT ); Fri, 7 May 2021 02:04:47 -0400 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 1475oj5n034484; Fri, 7 May 2021 13:50:45 +0800 (GMT-8) (envelope-from steven_lee@aspeedtech.com) Received: from aspeedtech.com (192.168.100.253) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 7 May 2021 14:02:35 +0800 Date: Fri, 7 May 2021 14:02:29 +0800 From: Steven Lee To: Philipp Zabel CC: Andrew Jeffery , Ulf Hansson , Rob Herring , Joel Stanley , "Adrian Hunter" , Ryan Chen , "moderated list:ASPEED SD/MMC DRIVER" , "moderated list:ASPEED SD/MMC DRIVER" , "open list:ASPEED SD/MMC DRIVER" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "moderated list:ARM/ASPEED MACHINE SUPPORT" , open list , "Hongweiz@ami.com" , "Ryan Chen" , Chin-Ting Kuo Subject: Re: [PATCH v3 5/5] mmc: sdhci-of-aspeed: Assert/Deassert reset signal before probing eMMC Message-ID: <20210507060228.GC23749@aspeedtech.com> References: <20210506100312.1638-1-steven_lee@aspeedtech.com> <20210506100312.1638-6-steven_lee@aspeedtech.com> <20210506102458.GA20777@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: <20210506102458.GA20777@pengutronix.de> User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [192.168.100.253] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 1475oj5n034484 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The 05/06/2021 18:24, Philipp Zabel wrote: > Hi Steven, > > On Thu, May 06, 2021 at 06:03:12PM +0800, Steven Lee wrote: > > For cleaning up the AST2600 eMMC controller, the reset signal should be > > asserted and deasserted before it is probed. > > > > Signed-off-by: Steven Lee > > --- > > drivers/mmc/host/sdhci-of-aspeed.c | 49 ++++++++++++++++++++++++------ > > 1 file changed, 40 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c > > index 4979f98ffb52..8ef06f32abff 100644 > > --- a/drivers/mmc/host/sdhci-of-aspeed.c > > +++ b/drivers/mmc/host/sdhci-of-aspeed.c > [...] > > @@ -533,11 +545,22 @@ static struct platform_driver aspeed_sdhci_driver = { > > .remove = aspeed_sdhci_remove, > > }; > > > > +static const struct of_device_id aspeed_sdc_of_match[] = { > > + { .compatible = "aspeed,ast2400-sd-controller", }, > > + { .compatible = "aspeed,ast2500-sd-controller", }, > > + { .compatible = "aspeed,ast2600-sd-controller", .data = &ast2600_sdc_info}, > > + { } > > +}; > > + > > +MODULE_DEVICE_TABLE(of, aspeed_sdc_of_match); > > + > > static int aspeed_sdc_probe(struct platform_device *pdev) > > > > { > > struct device_node *parent, *child; > > struct aspeed_sdc *sdc; > > + const struct of_device_id *match = NULL; > > + const struct aspeed_sdc_info *info = NULL; > > There is no need to initialize these variables to NULL, see below: > Will modify it. > > int ret; > > > > sdc = devm_kzalloc(&pdev->dev, sizeof(*sdc), GFP_KERNEL); > > @@ -546,6 +569,23 @@ static int aspeed_sdc_probe(struct platform_device *pdev) > > > > spin_lock_init(&sdc->lock); > > > > + match = of_match_device(aspeed_sdc_of_match, &pdev->dev); > > match is set unconditionally before it is used, > > > + if (!match) > > + return -ENODEV; > > + > > + if (match->data) > > + info = match->data; > > and info could be set unconditionally as well: > > info = match->data; > > > + if (info) { > > + if (info->flag & PROBE_AFTER_ASSET_DEASSERT) { > > + sdc->rst = devm_reset_control_get(&pdev->dev, NULL); > > Please use devm_reset_control_get_exclusive() or > devm_reset_control_get_optional_exclusive(). > Will modify as you suggest. > > + if (!IS_ERR(sdc->rst)) { > > Please just return errors here instead of ignoring them. > The reset_control_get_optional variants return NULL in case the > device node doesn't contain a resets phandle, in case you really > consider this reset to be optional even though the flag is set? > Will return error here. > > + reset_control_assert(sdc->rst); > > + reset_control_deassert(sdc->rst); > > Is there no need for delays between assertion and deassertion or after > the reset is deasserted? > Per the internal discussion, I Will add udelay(1). > > + } > > + } > > + } > > + > > sdc->clk = devm_clk_get(&pdev->dev, NULL); > > if (IS_ERR(sdc->clk)) > > return PTR_ERR(sdc->clk); > > In general, I would assert/deassert the reset only after all resources > are successfully acquired. This might avoid unnecessary resets in case > of probe deferrals. > Thanks for the suggestion. I will try to move the implementation of reset after devm_ioremap_resource(). > regards > Philipp