linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: p.zabel@pengutronix.de (Philipp Zabel)
To: linux-arm-kernel@lists.infradead.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	[thread overview]
Message-ID: <20170811130618.3676-6-p.zabel@pengutronix.de> (raw)
In-Reply-To: <20170811130618.3676-1-p.zabel@pengutronix.de>

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 <p.zabel@pengutronix.de>
---
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);
 
-- 
2.11.0

      parent reply	other threads:[~2017-08-11 13:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-11 13:06 [PATCH v2 0/5] Unify simple reset drivers Philipp Zabel
2017-08-11 13:06 ` [PATCH v2 1/5] reset: add reset-simple to unify socfpga, stm32, sunxi, and zx2967 Philipp Zabel
2017-08-11 15:39   ` Dinh Nguyen
2017-08-11 15:59     ` Philipp Zabel
2017-08-11 15:51   ` Chen-Yu Tsai
2017-08-11 15:57     ` Philipp Zabel
2017-08-11 16:04   ` Alexandru Gagniuc
2017-08-11 16:37     ` Philipp Zabel
2017-08-14 13:45       ` Eugeniy Paltsev
2017-08-11 17:47   ` Alexandru Gagniuc
2017-08-14  7:26     ` Philipp Zabel
2017-08-11 13:06 ` [PATCH v2 2/5] reset: socfpga: use the reset-simple driver Philipp Zabel
2017-08-11 16:28   ` Alexandru Gagniuc
2017-08-11 16:50     ` Philipp Zabel
2017-08-11 13:06 ` [PATCH v2 3/5] reset: stm32: " Philipp Zabel
2017-08-11 13:06 ` [PATCH v2 4/5] reset: zx2967: " Philipp Zabel
2017-08-11 13:06 ` Philipp Zabel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170811130618.3676-6-p.zabel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).