public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Athlon possible fixes
@ 2001-05-05  7:35 Alan Cox
  2001-05-05 16:26 ` Rogier Wolff
  2001-05-06  2:23 ` Chris Wedgwood
  0 siblings, 2 replies; 18+ messages in thread
From: Alan Cox @ 2001-05-05  7:35 UTC (permalink / raw)
  To: linux-kernel

Assuming Manfred's diagnosis is right something like this might fix it

*note*: Not tested this is just off the top of my head...


--- arch/i386/lib/mmx.c~	Sun Apr 15 16:49:54 2001
+++ arch/i386/lib/mmx.c	Sat May  5 08:03:17 2001
@@ -57,7 +57,11 @@
 		: : "r" (from) );
 		
 	
-	for(; i>0; i--)
+	/*
+	 *	While we have at least 320 bytes left to copy
+	 */
+	 
+	for(; i>5; i--)
 	{
 		__asm__ __volatile__ (
 		"1:  prefetch 320(%0)\n"
@@ -89,6 +93,31 @@
 		from+=64;
 		to+=64;
 	}
+
+	/*
+	 *	While we have at least 64 bytes left to copy
+	 */
+	 
+	for(; i>0; i--)
+	{
+		__asm__ __volatile__ (
+		"  movq (%0), %%mm0\n"
+		"  movq 8(%0), %%mm1\n"
+		"  movq 16(%0), %%mm2\n"
+		"  movq 24(%0), %%mm3\n"
+		"  movq %%mm0, (%1)\n"
+		"  movq %%mm1, 8(%1)\n"
+		"  movq %%mm2, 16(%1)\n"
+		"  movq %%mm3, 24(%1)\n"
+		"  movq 32(%0), %%mm0\n"
+		"  movq 40(%0), %%mm1\n"
+		"  movq 48(%0), %%mm2\n"
+		"  movq 56(%0), %%mm3\n"
+		"  movq %%mm0, 32(%1)\n"
+		"  movq %%mm1, 40(%1)\n"
+		"  movq %%mm2, 48(%1)\n"
+		"  movq %%mm3, 56(%1)\n"
+		: : "r" (from), "r" (to) : "memory");
 	/*
 	 *	Now do the tail of the block
 	 */
@@ -163,7 +192,11 @@
 		".previous"
 		: : "r" (from) );
 
-	for(i=0; i<4096/64; i++)
+	/*
+	 *	While there is at least 320 bytes to copy
+	 */
+	 
+	for(i=0; i<59; i++)
 	{
 		__asm__ __volatile__ (
 		"1: prefetch 320(%0)\n"
@@ -195,6 +228,35 @@
 		from+=64;
 		to+=64;
 	}
+
+	/*
+	 *	Finish off the page
+	 */
+	 
+	for(; i<64; i++)
+	{
+		__asm__ __volatile__ (
+		"   movq (%0), %%mm0\n"
+		"   movntq %%mm0, (%1)\n"
+		"   movq 8(%0), %%mm1\n"
+		"   movntq %%mm1, 8(%1)\n"
+		"   movq 16(%0), %%mm2\n"
+		"   movntq %%mm2, 16(%1)\n"
+		"   movq 24(%0), %%mm3\n"
+		"   movntq %%mm3, 24(%1)\n"
+		"   movq 32(%0), %%mm4\n"
+		"   movntq %%mm4, 32(%1)\n"
+		"   movq 40(%0), %%mm5\n"
+		"   movntq %%mm5, 40(%1)\n"
+		"   movq 48(%0), %%mm6\n"
+		"   movntq %%mm6, 48(%1)\n"
+		"   movq 56(%0), %%mm7\n"
+		"   movntq %%mm7, 56(%1)\n"
+		: : "r" (from), "r" (to) : "memory");
+		from+=64;
+		to+=64;
+	}
+
 	/* since movntq is weakly-ordered, a "sfence" is needed to become
 	 * ordered again.
 	 */
@@ -270,7 +332,11 @@
 		".previous"
 		: : "r" (from) );
 
-	for(i=0; i<4096/64; i++)
+	/*
+	 *	Copy the page until we have 320 bytes to go
+	 */
+	 
+	for(i=0; i<59; i++)
 	{
 		__asm__ __volatile__ (
 		"1: prefetch 320(%0)\n"
@@ -298,6 +364,34 @@
 		"	.align 4\n"
 		"	.long 1b, 3b\n"
 		".previous"
+		: : "r" (from), "r" (to) : "memory");
+		from+=64;
+		to+=64;
+	}
+
+	/*
+	 *	Copy the tail of the page
+	 */
+	 
+	for(; i<64; i++)
+	{
+		__asm__ __volatile__ (
+		"   movq (%0), %%mm0\n"
+		"   movq 8(%0), %%mm1\n"
+		"   movq 16(%0), %%mm2\n"
+		"   movq 24(%0), %%mm3\n"
+		"   movq %%mm0, (%1)\n"
+		"   movq %%mm1, 8(%1)\n"
+		"   movq %%mm2, 16(%1)\n"
+		"   movq %%mm3, 24(%1)\n"
+		"   movq 32(%0), %%mm0\n"
+		"   movq 40(%0), %%mm1\n"
+		"   movq 48(%0), %%mm2\n"
+		"   movq 56(%0), %%mm3\n"
+		"   movq %%mm0, 32(%1)\n"
+		"   movq %%mm1, 40(%1)\n"
+		"   movq %%mm2, 48(%1)\n"
+		"   movq %%mm3, 56(%1)\n"
 		: : "r" (from), "r" (to) : "memory");
 		from+=64;
 		to+=64;

^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: Athlon possible fixes
@ 2001-05-12 18:31 Ishikawa
  2001-05-12 23:02 ` Alan Cox
  0 siblings, 1 reply; 18+ messages in thread
From: Ishikawa @ 2001-05-12 18:31 UTC (permalink / raw)
  To: linux-kernel

>On Sun, May 06, 2001 at 01:51:59PM +0100, Alan Cox wrote:
>
>> > There really needs to be a hardware fix... this doesn't stop some
>> > application having it's owne optimised code from breaking on some
>> > hardware (think games and similation software perhaps).
>>
>> prefetch is virtually addresses. An application would need access to
/dev/mem
>> or similar. So the only folks I think it might actually bite are the
Xserver
>> people.
>
>Prefetch bugs in hardware have biten Linux/68k as early as '94; a GVP
SCSI
>HBA on the Amiga may touch areas beyond the last valid RAM address when

>doing DMA to the last page. Being a burned child from that time
Linux/MIPS
>didn't use the last RAM page just to be on the safe side.
>
>  Ralf

I use Duron 750 MHz and has experienced a strange X11 server error.
(The motherboard is Gigabyte 7IXE4 and uses AMD 751 and 756 chipsets.)

If I follow a certain steps accessing a web page using
netscape, the X11 server crashes reliably.
(The server is for ATI rage 128. Xfree86 3.3.6.)

After recompiling the X11 server with debug flag to C compiler,
I figured that the X11 server crashes in a bitblt copy againt
its backing up store . (I forgot what the proper X11 terminology, but
this is where the image data is saved for quick re-display, etc..
You can build an image in a memory buffer and then simply copy it
onto screen memory, etc..)

I was a little skeptical to think that the X11 server code
has such a bug for SVGA 16bits color server today,
and yet was still wondering if
the code might want to access non-allocated area due
to some optimized accessing pattern or something.

(Long time ago, I had a similar bug on a dedicated bitblt
instruction for a  workstation: the bitblt instruction could
access outside the boundary of malloc-ed  area
since it tries to access as many words as possible if there is a chance
to use
long word access. In doing so, the CPU could
step outside sbrk() limit and VM access error condition was generated.
Since this access violation occured inside the CPU firmware and
not visible to outside, it was very hard to track. Eventually, I figured
out
the problem, and always allocated enough trailing area for bitmap
storage
just in case the CPU tried to access a few word outside the limit.

Now, back to DuronAthlon problem:
I wasn't following this Athlong bug discussion in depth, thinking
it has something to do with VIA chipset alone.

But can the same problem manifest on AMD 751 chipset?
That would explain this mysterious X11 server
crash beatifully :-)

Happy Hacking,
ci




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

end of thread, other threads:[~2001-05-12 23:05 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-05  7:35 Athlon possible fixes Alan Cox
2001-05-05 16:26 ` Rogier Wolff
2001-05-05 16:42   ` Kurt Roeckx
2001-05-05 22:44   ` Seth Goldberg
2001-05-06 16:44     ` Jussi Laako
2001-05-06 17:41       ` Zilvinas Valinskas
2001-05-06 18:16       ` Christian Bornträger
2001-05-06 19:23         ` Marek Pętlicki
2001-05-07 18:54         ` Jussi Laako
2001-05-11 20:09         ` Jussi Laako
2001-05-11 20:22           ` Alan Cox
2001-05-12  9:51             ` Jussi Laako
2001-05-06  2:23 ` Chris Wedgwood
2001-05-06 12:51   ` Alan Cox
2001-05-06 13:00     ` Chris Wedgwood
2001-05-11  4:02     ` Ralf Baechle
  -- strict thread matches above, loose matches on Subject: below --
2001-05-12 18:31 Ishikawa
2001-05-12 23:02 ` Alan Cox

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