Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp773457img; Wed, 20 Mar 2019 10:32:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOOudR3FinsxnEkE+odlnNHvIaSR/Tax/wRq6ox9Nc48NjEdF3KMEMkr8GlX2fksgaE5jw X-Received: by 2002:a63:c242:: with SMTP id l2mr8500305pgg.138.1553103126571; Wed, 20 Mar 2019 10:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553103126; cv=none; d=google.com; s=arc-20160816; b=D6TsnmLMT2nwldGtY7ZdT23pe8ultMWklUMX5RVhsOysAMeQxhbntDuZvCvgLHqIPD XbC4jxRly21pUMYQ45LRyBh78W2nxKhP4/C+p2pDWa0DgsqjuMVZRnJNCSrr68qXWkAE 2LjgkuNQGbSWOd0iJUmPhNuJQbfBKwT8yYM8joCOsXhZGgP/W2zXg67fG53moA/o7wsD 3WwSuDf+01rdStK1WzG7ZKtt8Ow4YqXoDGZvpYjg7zW9xuHrMj9PUBywQ8ntWUKzcyzo sbh+eHihpSxAgtFblSSNJe4UbiwahMa72GkZimtSWTkx7MK+Xg2q/xQVnw0RyX1qxb55 7O4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WAi+T+TuJkOY2/zypYL61QcvUuzQMK0U/Jt9Mgzl8ZE=; b=aDNSfEYmJk5D/VWtX1n8huv5m5+wnV7QJmO0sDhJK/RsHJa916iBBzAB9q55C+D/w9 C6yIDBwt4vHAtS2dQtqur3lciJHsOxeMOariitd5l8pTkwjquUrnw47MrBXSrOjexUjJ cKHRs2/Z190rD/EkICG0A7uLGmMYLpWXbNGED6w7x3GRCB76cQKYy/heQa+e6y+XuEJ6 V4c/BQilfViSPsl0pOwv4ERFJMKHkXSMoSEDvJic0sue2/ihen9l5oiCKJzCTIAAsaKL Ytiu0G/+BwZ9nnPiwAwVQvakZwrFxUEGmEUFixnC3Z99y+JAcvelMrxuVWGILa0lkenX e6iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b="usGMKa/K"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si2212771plo.371.2019.03.20.10.31.51; Wed, 20 Mar 2019 10:32:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b="usGMKa/K"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727599AbfCTRak (ORCPT + 99 others); Wed, 20 Mar 2019 13:30:40 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:32860 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727503AbfCTRaK (ORCPT ); Wed, 20 Mar 2019 13:30:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=WAi+T+TuJkOY2/zypYL61QcvUuzQMK0U/Jt9Mgzl8ZE=; b=usGMKa/KfAjTnmwGxWEa3CgJo 68164ovSYUuJpxhofjrDoWAjIZDC20HZHTo/1eLYSq4M/G+UNWKAseOjj40WvMRxfosWHS8G3Of88 Fttsw+5BnTSMR9Ktm4Fhhb+S1Hc1rYI55MQFrP7VbIzW9P9Q9Vn7Hjy/cU69Anfzmez4lIIObx8fX lXw8yvje5LttAE1NnoHiCQTJpqQdd5wJMymVMMU7n0z3IDBu7zhcYuORNLiKe6lhuUauGRuAavI6V BgOnSqVIquWhOT2Z/WbDP9bpizJeeQqGuCFKFGWYN74vXhaKi8v0shCnzJuNbl5kWBm1IDfsIMhuO ms3++4rNw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:51806) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1h6f2O-0005jt-Jp; Wed, 20 Mar 2019 17:30:00 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.89) (envelope-from ) id 1h6f2L-0007WL-1r; Wed, 20 Mar 2019 17:29:57 +0000 Date: Wed, 20 Mar 2019 17:29:56 +0000 From: Russell King - ARM Linux admin To: Manivannan Sadhasivam Cc: Daniel Thompson , xuwei5@hisilicon.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linus.walleij@linaro.org, peter.griffin@linaro.org, guodong.xu@linaro.org, haojian.zhuang@linaro.org Subject: Re: [PATCH 1/2] amba: Take device out of reset before reading pid and cid values Message-ID: <20190320172956.lt4eq3vusq4traea@shell.armlinux.org.uk> References: <20190309015635.5401-1-manivannan.sadhasivam@linaro.org> <20190309015635.5401-2-manivannan.sadhasivam@linaro.org> <20190312122711.b2ibipico2dgavl7@holly.lan> <20190320065658.GA22381@Mani-XPS-13-9360> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190320065658.GA22381@Mani-XPS-13-9360> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 20, 2019 at 12:26:58PM +0530, Manivannan Sadhasivam wrote: > Hi Daniel, > > On Tue, Mar 12, 2019 at 12:27:11PM +0000, Daniel Thompson wrote: > > On Sat, Mar 09, 2019 at 07:26:34AM +0530, Manivannan Sadhasivam wrote: > > > For the AMBA Primecell devices having the reset lines wired, it is > > > necessary to take them out of reset before reading the pid and cid values. > > > Earlier we were dependent on the bootloader to do this but a more cleaner > > > approach would be to do it in the kernel itself. Hence, this commit > > > deasserts the reset line just before reading the pid and cid values. > > > > > > Suggested-by: Daniel Thompson > > > Signed-off-by: Manivannan Sadhasivam > > > --- > > > drivers/amba/bus.c | 9 +++++++++ > > > 1 file changed, 9 insertions(+) > > > > > > diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c > > > index 41b706403ef7..da8f1aac5315 100644 > > > --- a/drivers/amba/bus.c > > > +++ b/drivers/amba/bus.c > > > @@ -21,6 +21,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > > > > #include > > > > > > @@ -352,6 +353,7 @@ static void amba_device_release(struct device *dev) > > > > > > static int amba_device_try_add(struct amba_device *dev, struct resource *parent) > > > { > > > + struct reset_control *rst; > > > u32 size; > > > void __iomem *tmp; > > > int i, ret; > > > @@ -388,6 +390,13 @@ static int amba_device_try_add(struct amba_device *dev, struct resource *parent) > > > if (ret == 0) { > > > u32 pid, cid; > > > > > > + /* De-assert the reset line to take the device out of reset */ > > > + rst = reset_control_get_optional_exclusive(&dev->dev, NULL); > > > + if (IS_ERR(rst)) > > > + return PTR_ERR(rst); > > > > It is really correct to propagate an error if we cannot get exclusive > > ownership of the reset line. > > > > With drivers for vendor specific cells it is ok to "just know" that the > > reset line is never shared but we cannot know this for generic cells and > > we certainly can't know this for the bus. > > > > I think it *might* be OK to propagate an error if you used > > reset_control_get_optional_shared() instead because if that reports an > > error than arguably we have either a mistake in the DT or a bug in the > > driver we are sharing a reset with. > > > > Hmm. I'm not sure whether we can assume shared reset lines here or not! Maybe > Russell can share his opinion here. I've no reference to base an opinion on as I have no hardware that would use this facility. However, it seems obvious to me that if a reset line is shared between several devices, and when the reset line is asserted, it blocks reading the ID, then we do need a way for the AMBA primecell code to be able to lift the reset to read the device ID, and we need to do it in a way that is capable of being done even when another device/driver has already bound and taken control of the reset line. That said, if a reset line is shared between multiple devices, and a driver wants to assert the reset line, it would disrupt the operation of all those devices, so there would need to be some kind of synchronisation between the drivers. A different way to look at it though is that such a reset line is not a property of the individual devices, but of the bus - in which case it should be specified at bus level and controlled at bus level, not at individual device level. What is appropriate is entirely dependent on the hardware setup, and as I said above, with no view of the hardware I am unable to give a meaningful opinion. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up