x86_64: Add memcpy32_toio to write to PCI MMIO
PATCH 1/1 x86_64: Add memcpy32_toio to write to PCI MMIO
This is needed because the hardware does not support 64-bit moveq insructions while writing to PCI MMIO.
--- arch/x86/include/asm/io.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/x86/include/asm/io.h +22 -0
@@ -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
Signature · 1 line
1.9.0
Quoted 1 line · Subhransu S. Prusty
This is needed because the hardware
Which hardware? Every x86-64 CPU ever built by AMD, Intel, and VIA?
arch/x86/include/asm/io.h memcpy_toio(volatile void __iomem *dst, const void *src, size_t count) · line 225
Quoted 7 lines
does not support 64-bit moveq insructions while writing to PCI MMIO.
arch/x86/include/asm/io.h +5
-0+#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().
arch/x86/include/asm/io.h memcpy_toio(volatile void __iomem *dst, const void *src, size_t count) · line 240
Quoted 2 lines
arch/x86/include/asm/io.h +2
-0+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
Quoted 4 lines · Clemens Ladisch
Quoted 1 line · Subhransu S. Prusty
This is needed because the hardware
Which hardware? Every x86-64 CPU ever built by AMD, Intel, and VIA?
Baytrail and few other SoCs
Quoted 10 lines
arch/x86/include/asm/io.h memcpy_toio(volatile void __iomem *dst, const void *src, size_t count) · line 225
Quoted 8 lines
does not support 64-bit moveq insructions while writing to PCI MMIO.
arch/x86/include/asm/io.h +5
-0+#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
Quoted 5 lines
arch/x86/include/asm/io.h memcpy_toio(volatile void __iomem *dst, const void *src, size_t count) · line 240
Quoted 3 lines
arch/x86/include/asm/io.h +2
-0+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
Signature · 1 line
~Vinod