From patchwork Fri Aug 11 13:06:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 9895841 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0656F60236 for ; Fri, 11 Aug 2017 13:19:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9E1728C2B for ; Fri, 11 Aug 2017 13:19:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE92928C2C; Fri, 11 Aug 2017 13:19:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8B64F28C2A for ; Fri, 11 Aug 2017 13:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=lgjEMKPAk5hh7bObLd8l5o6ApV3rSSL5lfxwlPS8FAQ=; b=FyknmrNxpZJ03opVT2tTdEJTlO 7x4QzEmH0v/UYzV5QuIiD9lBOIrhSkZT9ZM/vl3c6AwujO5/X3XPRYs1I2iAbB2q7sk44MCuj7HNo N1rBgp38OLDq5TxtobS91+9zRNZTB1MwP2yMYI6/MMkUa8wUP5ZuF9Acm5/p6joCP3h6jRZKVa0lw wy27sStAUIqOttPgBd6puOBz/ZMEWuNWrFuELxRe4MlPFLRsXdlALDeIIpoaaqvTFRr19aWpql/70 paBNZQDcc8f2QtYjZL0PrNL30XZVh3rugFREI/qQgZ0jTbaKAGqySDK6crSgE9McVpCQwlfP/En91 l1SPY1gg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dg9qg-0007yr-NZ; Fri, 11 Aug 2017 13:19:34 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dg9eY-0001SI-GA for linux-arm-kernel@bombadil.infradead.org; Fri, 11 Aug 2017 13:07:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: 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=vc+9GASA3aNRUntpZyVXZ+WjPOIYEpa87Kx/9hoQ9GM=; b=1zD5buIdw54BjX9P4qyHya0Rm 3kIg44v52246Dfycb3ZheSkNcHUdz2xI+T5UBk5IHvWyNTi975gLBPD5bN+dPY0fVohng/bBm83hw cGptGJiUZrqCGPuabPWJA4shiO7ceUSjTt8DNHHZcUhcM23u5FxOdWzM5fOeZSHZsuHuHWaLSoJI3 Ep6if0dZWBDceUWJWfInI+1cbVQ15mhS0TVU0JsSxwMFAVGXhjx+wXRVpGZ+MaGqjxmVDAizK6tXr sdO6/OYXIDpqd/wQmyzow8yzHwjnF1oMOd1hIYQeGpTXmY4lH7qF8gIajeGgaMO3Rllpk8I0Xdau/ ZP6dzz34A==; Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dg9eS-0000UB-Vu for linux-arm-kernel@lists.infradead.org; Fri, 11 Aug 2017 13:06:57 +0000 Received: from lupine.hi.pengutronix.de ([2001:67c:670:100:3ad5:47ff:feaf:1a17] helo=lupine.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.84_2) (envelope-from ) id 1dg9dx-0006Sn-R0; Fri, 11 Aug 2017 15:06:25 +0200 From: Philipp Zabel To: linux-kernel@vger.kernel.org Subject: [PATCH v2 5/5] reset: simple: read back to make sure changes are applied Date: Fri, 11 Aug 2017 15:06:18 +0200 Message-Id: <20170811130618.3676-6-p.zabel@pengutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170811130618.3676-1-p.zabel@pengutronix.de> References: <20170811130618.3676-1-p.zabel@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:3ad5:47ff:feaf:1a17 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandru Gagniuc , Steffen Trumtrar , Alexandre Torgue , Andre Przywara , Dinh Nguyen , Chen-Yu Tsai , Maxime Coquelin , Philipp Zabel , Maxime Ripard , Baoyou Xie , Eugeniy Paltsev , kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Read back the register after setting or clearing a reset bit to make sure that the changes are applied to the reset controller hardware. Theoretically, this avoids the write to stay stuck in a store buffer during the delay of an assert-delay-deassert sequence, and makes sure that the reset really is asserted for the specified duration. Signed-off-by: Philipp Zabel --- Changes since v1: - Rebased to only modify the reset_simple_set helper function. --- drivers/reset/reset-simple.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/reset/reset-simple.c b/drivers/reset/reset-simple.c index d2d6ac483d61d..1324ba45e138b 100644 --- a/drivers/reset/reset-simple.c +++ b/drivers/reset/reset-simple.c @@ -39,17 +39,20 @@ static int reset_simple_set(struct reset_controller_dev *rcdev, int reg_width = sizeof(u32); int bank = id / (reg_width * BITS_PER_BYTE); int offset = id % (reg_width * BITS_PER_BYTE); + void __iomem *addr = data->membase + (bank * reg_width); unsigned long flags; u32 reg; spin_lock_irqsave(&data->lock, flags); - reg = readl(data->membase + (bank * reg_width)); + reg = readl(addr); if (assert ^ data->inverted) reg |= BIT(offset); else reg &= ~BIT(offset); - writel(reg, data->membase + (bank * reg_width)); + writel(reg, addr); + /* Read back to make sure the write doesn't linger in a store buffer */ + readl(addr); spin_unlock_irqrestore(&data->lock, flags);