LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] alpha: io: reorder barriers to guarantee writeX() and iowriteX() ordering #2
@ 2018-04-16 22:16 Sinan Kaya
  2018-04-17 18:43 ` Sinan Kaya
  0 siblings, 1 reply; 5+ messages in thread
From: Sinan Kaya @ 2018-04-16 22:16 UTC (permalink / raw)
  To: linux-alpha, arnd, timur, sulrich
  Cc: linux-arm-msm, linux-arm-kernel, Sinan Kaya, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Philippe Ombredanne,
	Greg Kroah-Hartman, Thomas Gleixner, Kate Stewart, linux-kernel

memory-barriers.txt has been updated with the following requirement.

"When using writel(), a prior wmb() is not needed to guarantee that the
cache coherent memory writes have completed before writing to the MMIO
region."

Current writeX() and iowriteX() implementations on alpha are not
satisfying this requirement as the barrier is after the register write.

Move mb() in writeX() and iowriteX() functions to guarantee that HW
observes memory changes before performing register operations.

Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
Reported-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/alpha/kernel/io.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/alpha/kernel/io.c b/arch/alpha/kernel/io.c
index 3e3d49c..c025a3e 100644
--- a/arch/alpha/kernel/io.c
+++ b/arch/alpha/kernel/io.c
@@ -37,20 +37,20 @@ unsigned int ioread32(void __iomem *addr)
 
 void iowrite8(u8 b, void __iomem *addr)
 {
-	IO_CONCAT(__IO_PREFIX,iowrite8)(b, addr);
 	mb();
+	IO_CONCAT(__IO_PREFIX,iowrite8)(b, addr);
 }
 
 void iowrite16(u16 b, void __iomem *addr)
 {
-	IO_CONCAT(__IO_PREFIX,iowrite16)(b, addr);
 	mb();
+	IO_CONCAT(__IO_PREFIX,iowrite16)(b, addr);
 }
 
 void iowrite32(u32 b, void __iomem *addr)
 {
-	IO_CONCAT(__IO_PREFIX,iowrite32)(b, addr);
 	mb();
+	IO_CONCAT(__IO_PREFIX,iowrite32)(b, addr);
 }
 
 EXPORT_SYMBOL(ioread8);
@@ -176,26 +176,26 @@ u64 readq(const volatile void __iomem *addr)
 
 void writeb(u8 b, volatile void __iomem *addr)
 {
-	__raw_writeb(b, addr);
 	mb();
+	__raw_writeb(b, addr);
 }
 
 void writew(u16 b, volatile void __iomem *addr)
 {
-	__raw_writew(b, addr);
 	mb();
+	__raw_writew(b, addr);
 }
 
 void writel(u32 b, volatile void __iomem *addr)
 {
-	__raw_writel(b, addr);
 	mb();
+	__raw_writel(b, addr);
 }
 
 void writeq(u64 b, volatile void __iomem *addr)
 {
-	__raw_writeq(b, addr);
 	mb();
+	__raw_writeq(b, addr);
 }
 
 EXPORT_SYMBOL(readb);
-- 
2.7.4

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

* Re: [PATCH] alpha: io: reorder barriers to guarantee writeX() and iowriteX() ordering #2
  2018-04-16 22:16 [PATCH] alpha: io: reorder barriers to guarantee writeX() and iowriteX() ordering #2 Sinan Kaya
@ 2018-04-17 18:43 ` Sinan Kaya
  2018-04-20 16:20   ` Sinan Kaya
  0 siblings, 1 reply; 5+ messages in thread
From: Sinan Kaya @ 2018-04-17 18:43 UTC (permalink / raw)
  To: linux-alpha, arnd, timur, sulrich
  Cc: linux-arm-msm, linux-arm-kernel, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Philippe Ombredanne,
	Greg Kroah-Hartman, Thomas Gleixner, Kate Stewart, linux-kernel

On 4/16/2018 6:16 PM, Sinan Kaya wrote:
> memory-barriers.txt has been updated with the following requirement.
> 
> "When using writel(), a prior wmb() is not needed to guarantee that the
> cache coherent memory writes have completed before writing to the MMIO
> region."
> 
> Current writeX() and iowriteX() implementations on alpha are not
> satisfying this requirement as the barrier is after the register write.
> 
> Move mb() in writeX() and iowriteX() functions to guarantee that HW
> observes memory changes before performing register operations.
> 
> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  arch/alpha/kernel/io.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)

Sorry for catching this late but this also needs to go to 4.17 after
review.

I missed the writel() implementation on arch/alpha/kernel/io.c file
on my first patch.

-- 
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.

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

* Re: [PATCH] alpha: io: reorder barriers to guarantee writeX() and iowriteX() ordering #2
  2018-04-17 18:43 ` Sinan Kaya
@ 2018-04-20 16:20   ` Sinan Kaya
  2018-05-01 22:48     ` Sinan Kaya
  2018-05-09  2:57     ` Matt Turner
  0 siblings, 2 replies; 5+ messages in thread
From: Sinan Kaya @ 2018-04-20 16:20 UTC (permalink / raw)
  To: linux-alpha, arnd, timur, sulrich, Matt Turner
  Cc: linux-arm-msm, linux-arm-kernel, Richard Henderson,
	Ivan Kokshaysky, Philippe Ombredanne, Greg Kroah-Hartman,
	Thomas Gleixner, Kate Stewart, linux-kernel

Hi Matt,

On 4/17/2018 2:43 PM, Sinan Kaya wrote:
> On 4/16/2018 6:16 PM, Sinan Kaya wrote:
>> memory-barriers.txt has been updated with the following requirement.
>>
>> "When using writel(), a prior wmb() is not needed to guarantee that the
>> cache coherent memory writes have completed before writing to the MMIO
>> region."
>>
>> Current writeX() and iowriteX() implementations on alpha are not
>> satisfying this requirement as the barrier is after the register write.
>>
>> Move mb() in writeX() and iowriteX() functions to guarantee that HW
>> observes memory changes before performing register operations.
>>
>> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
>> Reported-by: Arnd Bergmann <arnd@arndb.de>
>> ---
>>  arch/alpha/kernel/io.c | 14 +++++++-------
>>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> Sorry for catching this late but this also needs to go to 4.17 after
> review.
> 
> I missed the writel() implementation on arch/alpha/kernel/io.c file
> on my first patch.
> 

Can you also queue this for 4.17?

There are already drivers checked into 4.17 that dropped the unnecessary
barriers. 

I really hate to see Alpha broken because of this.

Sinan

-- 
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.

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

* Re: [PATCH] alpha: io: reorder barriers to guarantee writeX() and iowriteX() ordering #2
  2018-04-20 16:20   ` Sinan Kaya
@ 2018-05-01 22:48     ` Sinan Kaya
  2018-05-09  2:57     ` Matt Turner
  1 sibling, 0 replies; 5+ messages in thread
From: Sinan Kaya @ 2018-05-01 22:48 UTC (permalink / raw)
  To: linux-alpha, arnd, timur, sulrich, Matt Turner
  Cc: linux-arm-msm, linux-arm-kernel, Richard Henderson,
	Ivan Kokshaysky, Philippe Ombredanne, Greg Kroah-Hartman,
	Thomas Gleixner, Kate Stewart, linux-kernel

On 4/20/2018 12:20 PM, Sinan Kaya wrote:
> Hi Matt,
> 
> On 4/17/2018 2:43 PM, Sinan Kaya wrote:
>> On 4/16/2018 6:16 PM, Sinan Kaya wrote:
>>> memory-barriers.txt has been updated with the following requirement.
>>>
>>> "When using writel(), a prior wmb() is not needed to guarantee that the
>>> cache coherent memory writes have completed before writing to the MMIO
>>> region."
>>>
>>> Current writeX() and iowriteX() implementations on alpha are not
>>> satisfying this requirement as the barrier is after the register write.
>>>
>>> Move mb() in writeX() and iowriteX() functions to guarantee that HW
>>> observes memory changes before performing register operations.
>>>
>>> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
>>> Reported-by: Arnd Bergmann <arnd@arndb.de>
>>> ---
>>>  arch/alpha/kernel/io.c | 14 +++++++-------
>>>  1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> Sorry for catching this late but this also needs to go to 4.17 after
>> review.
>>
>> I missed the writel() implementation on arch/alpha/kernel/io.c file
>> on my first patch.
>>
> 
> Can you also queue this for 4.17?
> 
> There are already drivers checked into 4.17 that dropped the unnecessary
> barriers. 
> 
> I really hate to see Alpha broken because of this.

ping.

> 
> Sinan
> 


-- 
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.

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

* Re: [PATCH] alpha: io: reorder barriers to guarantee writeX() and iowriteX() ordering #2
  2018-04-20 16:20   ` Sinan Kaya
  2018-05-01 22:48     ` Sinan Kaya
@ 2018-05-09  2:57     ` Matt Turner
  1 sibling, 0 replies; 5+ messages in thread
From: Matt Turner @ 2018-05-09  2:57 UTC (permalink / raw)
  To: Sinan Kaya
  Cc: linux-alpha, Arnd Bergmann, Timur Tabi, sulrich, linux-arm-msm,
	linux-arm-kernel, Richard Henderson, Ivan Kokshaysky,
	Philippe Ombredanne, Greg Kroah-Hartman, Thomas Gleixner,
	Kate Stewart, LKML

On Fri, Apr 20, 2018 at 9:20 AM, Sinan Kaya <okaya@codeaurora.org> wrote:
> Hi Matt,
>
> On 4/17/2018 2:43 PM, Sinan Kaya wrote:
>> On 4/16/2018 6:16 PM, Sinan Kaya wrote:
>>> memory-barriers.txt has been updated with the following requirement.
>>>
>>> "When using writel(), a prior wmb() is not needed to guarantee that the
>>> cache coherent memory writes have completed before writing to the MMIO
>>> region."
>>>
>>> Current writeX() and iowriteX() implementations on alpha are not
>>> satisfying this requirement as the barrier is after the register write.
>>>
>>> Move mb() in writeX() and iowriteX() functions to guarantee that HW
>>> observes memory changes before performing register operations.
>>>
>>> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
>>> Reported-by: Arnd Bergmann <arnd@arndb.de>
>>> ---
>>>  arch/alpha/kernel/io.c | 14 +++++++-------
>>>  1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> Sorry for catching this late but this also needs to go to 4.17 after
>> review.
>>
>> I missed the writel() implementation on arch/alpha/kernel/io.c file
>> on my first patch.
>>
>
> Can you also queue this for 4.17?
>
> There are already drivers checked into 4.17 that dropped the unnecessary
> barriers.
>
> I really hate to see Alpha broken because of this.

Yes, I will pick it up for 4.17.

Thanks for the patch.

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

end of thread, other threads:[~2018-05-09  2:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-16 22:16 [PATCH] alpha: io: reorder barriers to guarantee writeX() and iowriteX() ordering #2 Sinan Kaya
2018-04-17 18:43 ` Sinan Kaya
2018-04-20 16:20   ` Sinan Kaya
2018-05-01 22:48     ` Sinan Kaya
2018-05-09  2:57     ` Matt Turner

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).