public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86_64: Add memcpy32_toio to write to PCI MMIO
@ 2014-09-08  8:14 Subhransu S. Prusty
  2014-09-09  8:01 ` Clemens Ladisch
  0 siblings, 1 reply; 3+ messages in thread
From: Subhransu S. Prusty @ 2014-09-08  8:14 UTC (permalink / raw)
  To: hpa; +Cc: tglx, mingo, x86, linux-kernel, vinod.koul, Subhransu S. Prusty

This is needed because the hardware does not support 64-bit moveq
insructions while writing to PCI MMIO.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
 arch/x86/include/asm/io.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index b8237d8..fa095fb 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -218,6 +218,28 @@ memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
 	memcpy((void __force *)dst, src, count);
 }
 
+#ifndef CONFIG_X86_64
+#define MEMCPY_TOIO memcpy_toio
+#else
+#define MEMCPY_TOIO memcpy32_toio
+#endif
+
+/**
+ * memcpy32_toio: Copy using writel commands
+ *
+ * This is needed because the hardware does not support
+ * 64-bit moveq insructions while writing to PCI MMIO
+ */
+static inline void memcpy32_toio(void *dst, const void *src, int count)
+{
+	int i;
+	const u32 *src_32 = src;
+	u32 *dst_32 = dst;
+
+	for (i = 0; i < count/sizeof(u32); i++)
+		writel(*src_32++, dst_32++);
+}
+
 /*
  * ISA space is 'always mapped' on a typical x86 system, no need to
  * explicitly ioremap() it. The fact that the ISA IO space is mapped
-- 
1.9.0


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

* Re: [PATCH] x86_64: Add memcpy32_toio to write to PCI MMIO
  2014-09-08  8:14 [PATCH] x86_64: Add memcpy32_toio to write to PCI MMIO Subhransu S. Prusty
@ 2014-09-09  8:01 ` Clemens Ladisch
  2014-09-16 15:29   ` Vinod Koul
  0 siblings, 1 reply; 3+ messages in thread
From: Clemens Ladisch @ 2014-09-09  8:01 UTC (permalink / raw)
  To: Subhransu S. Prusty; +Cc: hpa, tglx, mingo, x86, linux-kernel, vinod.koul

Subhransu S. Prusty wrote:
> This is needed because the hardware

Which hardware?  Every x86-64 CPU ever built by AMD, Intel, and VIA?

> does not support 64-bit moveq insructions while writing to PCI MMIO.

> +#ifndef CONFIG_X86_64
> +#define MEMCPY_TOIO memcpy_toio
> +#else
> +#define MEMCPY_TOIO memcpy32_toio
> +#endif

This does not change any code that uses memcpy_toio().

> +	for (i = 0; i < count/sizeof(u32); i++)
> +		writel(*src_32++, dst_32++);

This breaks when count is not a multiple of four.


Regards,
Clemens

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

* Re: [PATCH] x86_64: Add memcpy32_toio to write to PCI MMIO
  2014-09-09  8:01 ` Clemens Ladisch
@ 2014-09-16 15:29   ` Vinod Koul
  0 siblings, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2014-09-16 15:29 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: Subhransu S. Prusty, hpa, tglx, mingo, x86, linux-kernel

On Tue, Sep 09, 2014 at 10:01:18AM +0200, Clemens Ladisch wrote:
> Subhransu S. Prusty wrote:
> > This is needed because the hardware
> 
> Which hardware?  Every x86-64 CPU ever built by AMD, Intel, and VIA?
Baytrail and few other SoCs
> 
> > does not support 64-bit moveq insructions while writing to PCI MMIO.
> 
> > +#ifndef CONFIG_X86_64
> > +#define MEMCPY_TOIO memcpy_toio
> > +#else
> > +#define MEMCPY_TOIO memcpy32_toio
> > +#endif
> 
> This does not change any code that uses memcpy_toio().
So the devices cant do 64bit memcpy_toio so we are forced to use 32bit
copies only. This given us such an option
> 
> > +	for (i = 0; i < count/sizeof(u32); i++)
> > +		writel(*src_32++, dst_32++);
> 
> This breaks when count is not a multiple of four.
Ah yes, we can fix that

-- 
~Vinod


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

end of thread, other threads:[~2014-09-16 15:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-08  8:14 [PATCH] x86_64: Add memcpy32_toio to write to PCI MMIO Subhransu S. Prusty
2014-09-09  8:01 ` Clemens Ladisch
2014-09-16 15:29   ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox