All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] reset: socfpga: no need to store modrst_offset
@ 2016-07-05 10:17 ` Philipp Zabel
  0 siblings, 0 replies; 18+ messages in thread
From: Philipp Zabel @ 2016-07-05 10:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Maxime Ripard, Chen-Yu Tsai, Steffen Trumtrar, Dinh Nguyen,
	linux-arm-kernel, Philipp Zabel

Since we can just add it to membase once, there is no need to store
modrst_offset separately, and to repeat the addition with every access.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/reset/reset-socfpga.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 12add9b..78ebf84 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -28,7 +28,6 @@
 struct socfpga_reset_data {
 	spinlock_t			lock;
 	void __iomem			*membase;
-	u32				modrst_offset;
 	struct reset_controller_dev	rcdev;
 };
 
@@ -45,9 +44,8 @@ static int socfpga_reset_assert(struct reset_controller_dev *rcdev,
 
 	spin_lock_irqsave(&data->lock, flags);
 
-	reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
-	writel(reg | BIT(offset), data->membase + data->modrst_offset +
-				 (bank * NR_BANKS));
+	reg = readl(data->membase + (bank * NR_BANKS));
+	writel(reg | BIT(offset), data->membase + (bank * NR_BANKS));
 	spin_unlock_irqrestore(&data->lock, flags);
 
 	return 0;
@@ -67,9 +65,8 @@ static int socfpga_reset_deassert(struct reset_controller_dev *rcdev,
 
 	spin_lock_irqsave(&data->lock, flags);
 
-	reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
-	writel(reg & ~BIT(offset), data->membase + data->modrst_offset +
-				  (bank * NR_BANKS));
+	reg = readl(data->membase + (bank * NR_BANKS));
+	writel(reg & ~BIT(offset), data->membase + (bank * NR_BANKS));
 
 	spin_unlock_irqrestore(&data->lock, flags);
 
@@ -85,7 +82,7 @@ static int socfpga_reset_status(struct reset_controller_dev *rcdev,
 	int offset = id % BITS_PER_LONG;
 	u32 reg;
 
-	reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
+	reg = readl(data->membase + (bank * NR_BANKS));
 
 	return !(reg & BIT(offset));
 }
@@ -102,6 +99,7 @@ static int socfpga_reset_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
+	u32 modrst_offset;
 
 	/*
 	 * The binding was mainlined without the required property.
@@ -122,10 +120,11 @@ static int socfpga_reset_probe(struct platform_device *pdev)
 	if (IS_ERR(data->membase))
 		return PTR_ERR(data->membase);
 
-	if (of_property_read_u32(np, "altr,modrst-offset", &data->modrst_offset)) {
+	if (of_property_read_u32(np, "altr,modrst-offset", &modrst_offset)) {
 		dev_warn(dev, "missing altr,modrst-offset property, assuming 0x10!\n");
-		data->modrst_offset = 0x10;
+		modrst_offset = 0x10;
 	}
+	data->membase += modrst_offset;
 
 	spin_lock_init(&data->lock);
 
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 1/3] reset: socfpga: no need to store modrst_offset
@ 2016-07-05 10:17 ` Philipp Zabel
  0 siblings, 0 replies; 18+ messages in thread
From: Philipp Zabel @ 2016-07-05 10:17 UTC (permalink / raw)
  To: linux-arm-kernel

Since we can just add it to membase once, there is no need to store
modrst_offset separately, and to repeat the addition with every access.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/reset/reset-socfpga.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 12add9b..78ebf84 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -28,7 +28,6 @@
 struct socfpga_reset_data {
 	spinlock_t			lock;
 	void __iomem			*membase;
-	u32				modrst_offset;
 	struct reset_controller_dev	rcdev;
 };
 
@@ -45,9 +44,8 @@ static int socfpga_reset_assert(struct reset_controller_dev *rcdev,
 
 	spin_lock_irqsave(&data->lock, flags);
 
-	reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
-	writel(reg | BIT(offset), data->membase + data->modrst_offset +
-				 (bank * NR_BANKS));
+	reg = readl(data->membase + (bank * NR_BANKS));
+	writel(reg | BIT(offset), data->membase + (bank * NR_BANKS));
 	spin_unlock_irqrestore(&data->lock, flags);
 
 	return 0;
@@ -67,9 +65,8 @@ static int socfpga_reset_deassert(struct reset_controller_dev *rcdev,
 
 	spin_lock_irqsave(&data->lock, flags);
 
-	reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
-	writel(reg & ~BIT(offset), data->membase + data->modrst_offset +
-				  (bank * NR_BANKS));
+	reg = readl(data->membase + (bank * NR_BANKS));
+	writel(reg & ~BIT(offset), data->membase + (bank * NR_BANKS));
 
 	spin_unlock_irqrestore(&data->lock, flags);
 
@@ -85,7 +82,7 @@ static int socfpga_reset_status(struct reset_controller_dev *rcdev,
 	int offset = id % BITS_PER_LONG;
 	u32 reg;
 
-	reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
+	reg = readl(data->membase + (bank * NR_BANKS));
 
 	return !(reg & BIT(offset));
 }
@@ -102,6 +99,7 @@ static int socfpga_reset_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
+	u32 modrst_offset;
 
 	/*
 	 * The binding was mainlined without the required property.
@@ -122,10 +120,11 @@ static int socfpga_reset_probe(struct platform_device *pdev)
 	if (IS_ERR(data->membase))
 		return PTR_ERR(data->membase);
 
-	if (of_property_read_u32(np, "altr,modrst-offset", &data->modrst_offset)) {
+	if (of_property_read_u32(np, "altr,modrst-offset", &modrst_offset)) {
 		dev_warn(dev, "missing altr,modrst-offset property, assuming 0x10!\n");
-		data->modrst_offset = 0x10;
+		modrst_offset = 0x10;
 	}
+	data->membase += modrst_offset;
 
 	spin_lock_init(&data->lock);
 
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 2/3] reset: sunxi: use readl/writel_relaxed
  2016-07-05 10:17 ` Philipp Zabel
@ 2016-07-05 10:17   ` Philipp Zabel
  -1 siblings, 0 replies; 18+ messages in thread
From: Philipp Zabel @ 2016-07-05 10:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Maxime Ripard, Chen-Yu Tsai, Steffen Trumtrar, Dinh Nguyen,
	linux-arm-kernel, Philipp Zabel

This just removes the rmb()/wmb() pair between register read and
write. Since no relevant reads follow the rmb and no relevant writes
precede the wmb, they should be safe to remove.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/reset/reset-sunxi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c
index 3080190..7a35950 100644
--- a/drivers/reset/reset-sunxi.c
+++ b/drivers/reset/reset-sunxi.c
@@ -41,8 +41,8 @@ static int sunxi_reset_assert(struct reset_controller_dev *rcdev,
 
 	spin_lock_irqsave(&data->lock, flags);
 
-	reg = readl(data->membase + (bank * 4));
-	writel(reg & ~BIT(offset), data->membase + (bank * 4));
+	reg = readl_relaxed(data->membase + (bank * 4));
+	writel_relaxed(reg & ~BIT(offset), data->membase + (bank * 4));
 
 	spin_unlock_irqrestore(&data->lock, flags);
 
@@ -62,8 +62,8 @@ static int sunxi_reset_deassert(struct reset_controller_dev *rcdev,
 
 	spin_lock_irqsave(&data->lock, flags);
 
-	reg = readl(data->membase + (bank * 4));
-	writel(reg | BIT(offset), data->membase + (bank * 4));
+	reg = readl_relaxed(data->membase + (bank * 4));
+	writel_relaxed(reg | BIT(offset), data->membase + (bank * 4));
 
 	spin_unlock_irqrestore(&data->lock, flags);
 
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 2/3] reset: sunxi: use readl/writel_relaxed
@ 2016-07-05 10:17   ` Philipp Zabel
  0 siblings, 0 replies; 18+ messages in thread
From: Philipp Zabel @ 2016-07-05 10:17 UTC (permalink / raw)
  To: linux-arm-kernel

This just removes the rmb()/wmb() pair between register read and
write. Since no relevant reads follow the rmb and no relevant writes
precede the wmb, they should be safe to remove.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/reset/reset-sunxi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c
index 3080190..7a35950 100644
--- a/drivers/reset/reset-sunxi.c
+++ b/drivers/reset/reset-sunxi.c
@@ -41,8 +41,8 @@ static int sunxi_reset_assert(struct reset_controller_dev *rcdev,
 
 	spin_lock_irqsave(&data->lock, flags);
 
-	reg = readl(data->membase + (bank * 4));
-	writel(reg & ~BIT(offset), data->membase + (bank * 4));
+	reg = readl_relaxed(data->membase + (bank * 4));
+	writel_relaxed(reg & ~BIT(offset), data->membase + (bank * 4));
 
 	spin_unlock_irqrestore(&data->lock, flags);
 
@@ -62,8 +62,8 @@ static int sunxi_reset_deassert(struct reset_controller_dev *rcdev,
 
 	spin_lock_irqsave(&data->lock, flags);
 
-	reg = readl(data->membase + (bank * 4));
-	writel(reg | BIT(offset), data->membase + (bank * 4));
+	reg = readl_relaxed(data->membase + (bank * 4));
+	writel_relaxed(reg | BIT(offset), data->membase + (bank * 4));
 
 	spin_unlock_irqrestore(&data->lock, flags);
 
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 3/3] reset: socfpga: use readl/writel_relaxed
  2016-07-05 10:17 ` Philipp Zabel
@ 2016-07-05 10:17   ` Philipp Zabel
  -1 siblings, 0 replies; 18+ messages in thread
From: Philipp Zabel @ 2016-07-05 10:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Maxime Ripard, Chen-Yu Tsai, Steffen Trumtrar, Dinh Nguyen,
	linux-arm-kernel, Philipp Zabel

This just removes the rmb()/wmb() pair between register read and
write. Since no relevant reads follow the rmb and no relevant writes
precede the wmb, they should be safe to remove.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/reset/reset-socfpga.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 78ebf84..4a65128 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -44,8 +44,8 @@ static int socfpga_reset_assert(struct reset_controller_dev *rcdev,
 
 	spin_lock_irqsave(&data->lock, flags);
 
-	reg = readl(data->membase + (bank * NR_BANKS));
-	writel(reg | BIT(offset), data->membase + (bank * NR_BANKS));
+	reg = readl_relaxed(data->membase + (bank * NR_BANKS));
+	writel_relaxed(reg | BIT(offset), data->membase + (bank * NR_BANKS));
 	spin_unlock_irqrestore(&data->lock, flags);
 
 	return 0;
@@ -65,8 +65,8 @@ static int socfpga_reset_deassert(struct reset_controller_dev *rcdev,
 
 	spin_lock_irqsave(&data->lock, flags);
 
-	reg = readl(data->membase + (bank * NR_BANKS));
-	writel(reg & ~BIT(offset), data->membase + (bank * NR_BANKS));
+	reg = readl_relaxed(data->membase + (bank * NR_BANKS));
+	writel_relaxed(reg & ~BIT(offset), data->membase + (bank * NR_BANKS));
 
 	spin_unlock_irqrestore(&data->lock, flags);
 
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 3/3] reset: socfpga: use readl/writel_relaxed
@ 2016-07-05 10:17   ` Philipp Zabel
  0 siblings, 0 replies; 18+ messages in thread
From: Philipp Zabel @ 2016-07-05 10:17 UTC (permalink / raw)
  To: linux-arm-kernel

This just removes the rmb()/wmb() pair between register read and
write. Since no relevant reads follow the rmb and no relevant writes
precede the wmb, they should be safe to remove.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/reset/reset-socfpga.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 78ebf84..4a65128 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -44,8 +44,8 @@ static int socfpga_reset_assert(struct reset_controller_dev *rcdev,
 
 	spin_lock_irqsave(&data->lock, flags);
 
-	reg = readl(data->membase + (bank * NR_BANKS));
-	writel(reg | BIT(offset), data->membase + (bank * NR_BANKS));
+	reg = readl_relaxed(data->membase + (bank * NR_BANKS));
+	writel_relaxed(reg | BIT(offset), data->membase + (bank * NR_BANKS));
 	spin_unlock_irqrestore(&data->lock, flags);
 
 	return 0;
@@ -65,8 +65,8 @@ static int socfpga_reset_deassert(struct reset_controller_dev *rcdev,
 
 	spin_lock_irqsave(&data->lock, flags);
 
-	reg = readl(data->membase + (bank * NR_BANKS));
-	writel(reg & ~BIT(offset), data->membase + (bank * NR_BANKS));
+	reg = readl_relaxed(data->membase + (bank * NR_BANKS));
+	writel_relaxed(reg & ~BIT(offset), data->membase + (bank * NR_BANKS));
 
 	spin_unlock_irqrestore(&data->lock, flags);
 
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/3] reset: socfpga: use readl/writel_relaxed
  2016-07-05 10:17   ` Philipp Zabel
@ 2016-07-05 11:20     ` Arnd Bergmann
  -1 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2016-07-05 11:20 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Philipp Zabel, linux-kernel, Chen-Yu Tsai, Dinh Nguyen,
	Steffen Trumtrar, Maxime Ripard

On Tuesday, July 5, 2016 12:17:52 PM CEST Philipp Zabel wrote:
> This just removes the rmb()/wmb() pair between register read and
> write. Since no relevant reads follow the rmb and no relevant writes
> precede the wmb, they should be safe to remove.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

We should only do this if you are fixing a bug (which you don't mention
in the changelog), or if you can show a relevant performance
improvement. Is this code ever used in a fast path? If it is,
wouldn't that indicate a problem in some driver?

	Arnd

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 3/3] reset: socfpga: use readl/writel_relaxed
@ 2016-07-05 11:20     ` Arnd Bergmann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2016-07-05 11:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Tuesday, July 5, 2016 12:17:52 PM CEST Philipp Zabel wrote:
> This just removes the rmb()/wmb() pair between register read and
> write. Since no relevant reads follow the rmb and no relevant writes
> precede the wmb, they should be safe to remove.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

We should only do this if you are fixing a bug (which you don't mention
in the changelog), or if you can show a relevant performance
improvement. Is this code ever used in a fast path? If it is,
wouldn't that indicate a problem in some driver?

	Arnd

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/3] reset: socfpga: use readl/writel_relaxed
  2016-07-05 11:20     ` Arnd Bergmann
@ 2016-07-05 11:40       ` Philipp Zabel
  -1 siblings, 0 replies; 18+ messages in thread
From: Philipp Zabel @ 2016-07-05 11:40 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arm-kernel, linux-kernel, Chen-Yu Tsai, Dinh Nguyen,
	Steffen Trumtrar, Maxime Ripard

Am Dienstag, den 05.07.2016, 13:20 +0200 schrieb Arnd Bergmann:
> On Tuesday, July 5, 2016 12:17:52 PM CEST Philipp Zabel wrote:
> > This just removes the rmb()/wmb() pair between register read and
> > write. Since no relevant reads follow the rmb and no relevant writes
> > precede the wmb, they should be safe to remove.
> > 
> > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> 
> We should only do this if you are fixing a bug (which you don't mention
> in the changelog), or if you can show a relevant performance
> improvement. Is this code ever used in a fast path? If it is,
> wouldn't that indicate a problem in some driver?

It does not fix a bug, and it's not about performance either. I'd like
to align code with the recently posted stm32 driver, to unify them in a
future patch.
Of course we can change the stm32 driver to use readl/writel instead of
the relaxed variants, it just seemed useless to have those barriers
between the read and write.

If anything, we'd need to try to make sure that the writel in assert
hits the hardware before the function returns, so that a
assert-delay-deassert doesn't accidentally spend half its delay with the
writel still in the store buffer, and we'd need a full barrier after the
writel in deassert so that there can be no successive reads from still
disabled IP cores.

regards
Philipp

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 3/3] reset: socfpga: use readl/writel_relaxed
@ 2016-07-05 11:40       ` Philipp Zabel
  0 siblings, 0 replies; 18+ messages in thread
From: Philipp Zabel @ 2016-07-05 11:40 UTC (permalink / raw)
  To: linux-arm-kernel

Am Dienstag, den 05.07.2016, 13:20 +0200 schrieb Arnd Bergmann:
> On Tuesday, July 5, 2016 12:17:52 PM CEST Philipp Zabel wrote:
> > This just removes the rmb()/wmb() pair between register read and
> > write. Since no relevant reads follow the rmb and no relevant writes
> > precede the wmb, they should be safe to remove.
> > 
> > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> 
> We should only do this if you are fixing a bug (which you don't mention
> in the changelog), or if you can show a relevant performance
> improvement. Is this code ever used in a fast path? If it is,
> wouldn't that indicate a problem in some driver?

It does not fix a bug, and it's not about performance either. I'd like
to align code with the recently posted stm32 driver, to unify them in a
future patch.
Of course we can change the stm32 driver to use readl/writel instead of
the relaxed variants, it just seemed useless to have those barriers
between the read and write.

If anything, we'd need to try to make sure that the writel in assert
hits the hardware before the function returns, so that a
assert-delay-deassert doesn't accidentally spend half its delay with the
writel still in the store buffer, and we'd need a full barrier after the
writel in deassert so that there can be no successive reads from still
disabled IP cores.

regards
Philipp

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/3] reset: socfpga: use readl/writel_relaxed
  2016-07-05 11:40       ` Philipp Zabel
@ 2016-07-05 12:59         ` Arnd Bergmann
  -1 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2016-07-05 12:59 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: linux-arm-kernel, linux-kernel, Chen-Yu Tsai, Dinh Nguyen,
	Steffen Trumtrar, Maxime Ripard

On Tuesday, July 5, 2016 1:40:16 PM CEST Philipp Zabel wrote:
> Am Dienstag, den 05.07.2016, 13:20 +0200 schrieb Arnd Bergmann:
> > On Tuesday, July 5, 2016 12:17:52 PM CEST Philipp Zabel wrote:
> > > This just removes the rmb()/wmb() pair between register read and
> > > write. Since no relevant reads follow the rmb and no relevant writes
> > > precede the wmb, they should be safe to remove.
> > > 
> > > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> > 
> > We should only do this if you are fixing a bug (which you don't mention
> > in the changelog), or if you can show a relevant performance
> > improvement. Is this code ever used in a fast path? If it is,
> > wouldn't that indicate a problem in some driver?
> 
> It does not fix a bug, and it's not about performance either. I'd like
> to align code with the recently posted stm32 driver, to unify them in a
> future patch.
> Of course we can change the stm32 driver to use readl/writel instead of
> the relaxed variants, it just seemed useless to have those barriers
> between the read and write.

On stm32, there is no barrier because ARM_DMA_MEM_BUFFERABLE is not set.

I'd really prefer to just have readl/writel everywhere except in the
few places that are performance critical and have a comment explaining
why it's safe there, mainly to avoid having new developers blindly
add the relaxed accessors in drivers because they think it's the
normal coding style.

> If anything, we'd need to try to make sure that the writel in assert
> hits the hardware before the function returns, so that a
> assert-delay-deassert doesn't accidentally spend half its delay with the
> writel still in the store buffer, and we'd need a full barrier after the
> writel in deassert so that there can be no successive reads from still
> disabled IP cores.

In general, I think you need a readl() following the writel() to guarantee
that it has actually hit the hardware.

On ARM you often have just the CPU write buffer that needs to be flushed,
but if you have a PCI device or a more complex SoC, then a barriers doesn't
wait for a write to arrive at the device, it only ensures that a subsequent
write cannot arrive any earlier.

	Arnd

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 3/3] reset: socfpga: use readl/writel_relaxed
@ 2016-07-05 12:59         ` Arnd Bergmann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2016-07-05 12:59 UTC (permalink / raw)
  To: linux-arm-kernel

On Tuesday, July 5, 2016 1:40:16 PM CEST Philipp Zabel wrote:
> Am Dienstag, den 05.07.2016, 13:20 +0200 schrieb Arnd Bergmann:
> > On Tuesday, July 5, 2016 12:17:52 PM CEST Philipp Zabel wrote:
> > > This just removes the rmb()/wmb() pair between register read and
> > > write. Since no relevant reads follow the rmb and no relevant writes
> > > precede the wmb, they should be safe to remove.
> > > 
> > > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> > 
> > We should only do this if you are fixing a bug (which you don't mention
> > in the changelog), or if you can show a relevant performance
> > improvement. Is this code ever used in a fast path? If it is,
> > wouldn't that indicate a problem in some driver?
> 
> It does not fix a bug, and it's not about performance either. I'd like
> to align code with the recently posted stm32 driver, to unify them in a
> future patch.
> Of course we can change the stm32 driver to use readl/writel instead of
> the relaxed variants, it just seemed useless to have those barriers
> between the read and write.

On stm32, there is no barrier because ARM_DMA_MEM_BUFFERABLE is not set.

I'd really prefer to just have readl/writel everywhere except in the
few places that are performance critical and have a comment explaining
why it's safe there, mainly to avoid having new developers blindly
add the relaxed accessors in drivers because they think it's the
normal coding style.

> If anything, we'd need to try to make sure that the writel in assert
> hits the hardware before the function returns, so that a
> assert-delay-deassert doesn't accidentally spend half its delay with the
> writel still in the store buffer, and we'd need a full barrier after the
> writel in deassert so that there can be no successive reads from still
> disabled IP cores.

In general, I think you need a readl() following the writel() to guarantee
that it has actually hit the hardware.

On ARM you often have just the CPU write buffer that needs to be flushed,
but if you have a PCI device or a more complex SoC, then a barriers doesn't
wait for a write to arrive at the device, it only ensures that a subsequent
write cannot arrive any earlier.

	Arnd

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/3] reset: socfpga: use readl/writel_relaxed
  2016-07-05 12:59         ` Arnd Bergmann
@ 2016-07-05 13:20           ` Philipp Zabel
  -1 siblings, 0 replies; 18+ messages in thread
From: Philipp Zabel @ 2016-07-05 13:20 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arm-kernel, linux-kernel, Chen-Yu Tsai, Dinh Nguyen,
	Steffen Trumtrar, Maxime Ripard

Am Dienstag, den 05.07.2016, 14:59 +0200 schrieb Arnd Bergmann:
> On Tuesday, July 5, 2016 1:40:16 PM CEST Philipp Zabel wrote:
> > Am Dienstag, den 05.07.2016, 13:20 +0200 schrieb Arnd Bergmann:
> > > On Tuesday, July 5, 2016 12:17:52 PM CEST Philipp Zabel wrote:
> > > > This just removes the rmb()/wmb() pair between register read and
> > > > write. Since no relevant reads follow the rmb and no relevant writes
> > > > precede the wmb, they should be safe to remove.
> > > > 
> > > > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> > > 
> > > We should only do this if you are fixing a bug (which you don't mention
> > > in the changelog), or if you can show a relevant performance
> > > improvement. Is this code ever used in a fast path? If it is,
> > > wouldn't that indicate a problem in some driver?
> > 
> > It does not fix a bug, and it's not about performance either. I'd like
> > to align code with the recently posted stm32 driver, to unify them in a
> > future patch.
> > Of course we can change the stm32 driver to use readl/writel instead of
> > the relaxed variants, it just seemed useless to have those barriers
> > between the read and write.
> 
> On stm32, there is no barrier because ARM_DMA_MEM_BUFFERABLE is not set.
> 
> I'd really prefer to just have readl/writel everywhere except in the
> few places that are performance critical and have a comment explaining
> why it's safe there, mainly to avoid having new developers blindly
> add the relaxed accessors in drivers because they think it's the
> normal coding style.

I get your point. I'll ask the stm32 developers to use non-relaxed
readl/writel then.

> > If anything, we'd need to try to make sure that the writel in assert
> > hits the hardware before the function returns, so that a
> > assert-delay-deassert doesn't accidentally spend half its delay with the
> > writel still in the store buffer, and we'd need a full barrier after the
> > writel in deassert so that there can be no successive reads from still
> > disabled IP cores.
> 
> In general, I think you need a readl() following the writel() to guarantee
> that it has actually hit the hardware.
>
> On ARM you often have just the CPU write buffer that needs to be flushed,
> but if you have a PCI device or a more complex SoC, then a barriers doesn't
> wait for a write to arrive at the device, it only ensures that a subsequent
> write cannot arrive any earlier.

Yes, exactly. Until now I have not considered this at all.

regards
Philipp

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 3/3] reset: socfpga: use readl/writel_relaxed
@ 2016-07-05 13:20           ` Philipp Zabel
  0 siblings, 0 replies; 18+ messages in thread
From: Philipp Zabel @ 2016-07-05 13:20 UTC (permalink / raw)
  To: linux-arm-kernel

Am Dienstag, den 05.07.2016, 14:59 +0200 schrieb Arnd Bergmann:
> On Tuesday, July 5, 2016 1:40:16 PM CEST Philipp Zabel wrote:
> > Am Dienstag, den 05.07.2016, 13:20 +0200 schrieb Arnd Bergmann:
> > > On Tuesday, July 5, 2016 12:17:52 PM CEST Philipp Zabel wrote:
> > > > This just removes the rmb()/wmb() pair between register read and
> > > > write. Since no relevant reads follow the rmb and no relevant writes
> > > > precede the wmb, they should be safe to remove.
> > > > 
> > > > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> > > 
> > > We should only do this if you are fixing a bug (which you don't mention
> > > in the changelog), or if you can show a relevant performance
> > > improvement. Is this code ever used in a fast path? If it is,
> > > wouldn't that indicate a problem in some driver?
> > 
> > It does not fix a bug, and it's not about performance either. I'd like
> > to align code with the recently posted stm32 driver, to unify them in a
> > future patch.
> > Of course we can change the stm32 driver to use readl/writel instead of
> > the relaxed variants, it just seemed useless to have those barriers
> > between the read and write.
> 
> On stm32, there is no barrier because ARM_DMA_MEM_BUFFERABLE is not set.
> 
> I'd really prefer to just have readl/writel everywhere except in the
> few places that are performance critical and have a comment explaining
> why it's safe there, mainly to avoid having new developers blindly
> add the relaxed accessors in drivers because they think it's the
> normal coding style.

I get your point. I'll ask the stm32 developers to use non-relaxed
readl/writel then.

> > If anything, we'd need to try to make sure that the writel in assert
> > hits the hardware before the function returns, so that a
> > assert-delay-deassert doesn't accidentally spend half its delay with the
> > writel still in the store buffer, and we'd need a full barrier after the
> > writel in deassert so that there can be no successive reads from still
> > disabled IP cores.
> 
> In general, I think you need a readl() following the writel() to guarantee
> that it has actually hit the hardware.
>
> On ARM you often have just the CPU write buffer that needs to be flushed,
> but if you have a PCI device or a more complex SoC, then a barriers doesn't
> wait for a write to arrive at the device, it only ensures that a subsequent
> write cannot arrive any earlier.

Yes, exactly. Until now I have not considered this at all.

regards
Philipp

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/3] reset: socfpga: no need to store modrst_offset
  2016-07-05 10:17 ` Philipp Zabel
@ 2016-07-06 16:06   ` Dinh Nguyen
  -1 siblings, 0 replies; 18+ messages in thread
From: Dinh Nguyen @ 2016-07-06 16:06 UTC (permalink / raw)
  To: Philipp Zabel, linux-kernel
  Cc: Maxime Ripard, Chen-Yu Tsai, Steffen Trumtrar, linux-arm-kernel

On 07/05/2016 05:17 AM, Philipp Zabel wrote:
> Since we can just add it to membase once, there is no need to store
> modrst_offset separately, and to repeat the addition with every access.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/reset/reset-socfpga.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 

In case you want it:

Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>

Thanks,
Dinh

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/3] reset: socfpga: no need to store modrst_offset
@ 2016-07-06 16:06   ` Dinh Nguyen
  0 siblings, 0 replies; 18+ messages in thread
From: Dinh Nguyen @ 2016-07-06 16:06 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/05/2016 05:17 AM, Philipp Zabel wrote:
> Since we can just add it to membase once, there is no need to store
> modrst_offset separately, and to repeat the addition with every access.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/reset/reset-socfpga.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 

In case you want it:

Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>

Thanks,
Dinh

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/3] reset: socfpga: no need to store modrst_offset
  2016-07-06 16:06   ` Dinh Nguyen
@ 2016-07-06 16:26     ` Philipp Zabel
  -1 siblings, 0 replies; 18+ messages in thread
From: Philipp Zabel @ 2016-07-06 16:26 UTC (permalink / raw)
  To: Dinh Nguyen
  Cc: linux-kernel, Maxime Ripard, Chen-Yu Tsai, Steffen Trumtrar,
	linux-arm-kernel

Am Mittwoch, den 06.07.2016, 11:06 -0500 schrieb Dinh Nguyen:
> On 07/05/2016 05:17 AM, Philipp Zabel wrote:
> > Since we can just add it to membase once, there is no need to store
> > modrst_offset separately, and to repeat the addition with every access.
> > 
> > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> > ---
> >  drivers/reset/reset-socfpga.c | 19 +++++++++----------
> >  1 file changed, 9 insertions(+), 10 deletions(-)
> > 
> 
> In case you want it:
> 
> Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>

I'll take it, thank you.

regards
Philipp

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/3] reset: socfpga: no need to store modrst_offset
@ 2016-07-06 16:26     ` Philipp Zabel
  0 siblings, 0 replies; 18+ messages in thread
From: Philipp Zabel @ 2016-07-06 16:26 UTC (permalink / raw)
  To: linux-arm-kernel

Am Mittwoch, den 06.07.2016, 11:06 -0500 schrieb Dinh Nguyen:
> On 07/05/2016 05:17 AM, Philipp Zabel wrote:
> > Since we can just add it to membase once, there is no need to store
> > modrst_offset separately, and to repeat the addition with every access.
> > 
> > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> > ---
> >  drivers/reset/reset-socfpga.c | 19 +++++++++----------
> >  1 file changed, 9 insertions(+), 10 deletions(-)
> > 
> 
> In case you want it:
> 
> Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>

I'll take it, thank you.

regards
Philipp

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-07-06 17:49 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-05 10:17 [PATCH 1/3] reset: socfpga: no need to store modrst_offset Philipp Zabel
2016-07-05 10:17 ` Philipp Zabel
2016-07-05 10:17 ` [PATCH 2/3] reset: sunxi: use readl/writel_relaxed Philipp Zabel
2016-07-05 10:17   ` Philipp Zabel
2016-07-05 10:17 ` [PATCH 3/3] reset: socfpga: " Philipp Zabel
2016-07-05 10:17   ` Philipp Zabel
2016-07-05 11:20   ` Arnd Bergmann
2016-07-05 11:20     ` Arnd Bergmann
2016-07-05 11:40     ` Philipp Zabel
2016-07-05 11:40       ` Philipp Zabel
2016-07-05 12:59       ` Arnd Bergmann
2016-07-05 12:59         ` Arnd Bergmann
2016-07-05 13:20         ` Philipp Zabel
2016-07-05 13:20           ` Philipp Zabel
2016-07-06 16:06 ` [PATCH 1/3] reset: socfpga: no need to store modrst_offset Dinh Nguyen
2016-07-06 16:06   ` Dinh Nguyen
2016-07-06 16:26   ` Philipp Zabel
2016-07-06 16:26     ` Philipp Zabel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.