Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH][MIPS] fix divide by zero error in build_clear_page and build_copy_page
@ 2008-05-07 14:38 Yoichi Yuasa
  2008-05-07 16:14 ` Maciej W. Rozycki
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Yoichi Yuasa @ 2008-05-07 14:38 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: yoichi_yuasa, linux-mips

Fix divide by zero error in build_clear_page() and build_copy_page()

Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>

diff -pruN -X /home/yuasa/Memo/dontdiff linux-orig/arch/mips/mm/page.c linux/arch/mips/mm/page.c
--- linux-orig/arch/mips/mm/page.c	2008-05-07 10:28:03.732151097 +0900
+++ linux/arch/mips/mm/page.c	2008-05-07 23:27:00.212977534 +0900
@@ -310,8 +310,8 @@ void __cpuinit build_clear_page(void)
 	if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x())
 		uasm_i_lui(&buf, AT, 0xa000);
 
-	off = min(8, pref_bias_clear_store / cache_line_size) *
-	      cache_line_size;
+	off = cache_line_size ? min(8, pref_bias_clear_store / cache_line_size)
+	                        * cache_line_size : 0;
 	while (off) {
 		build_clear_pref(&buf, -off);
 		off -= cache_line_size;
@@ -454,12 +454,14 @@ void __cpuinit build_copy_page(void)
 	if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x())
 		uasm_i_lui(&buf, AT, 0xa000);
 
-	off = min(8, pref_bias_copy_load / cache_line_size) * cache_line_size;
+	off = cache_line_size ? min(8, pref_bias_copy_load / cache_line_size) *
+	                        cache_line_size : 0;
 	while (off) {
 		build_copy_load_pref(&buf, -off);
 		off -= cache_line_size;
 	}
-	off = min(8, pref_bias_copy_store / cache_line_size) * cache_line_size;
+	off = cache_line_size ? min(8, pref_bias_copy_load / cache_line_size) *
+	                        cache_line_size : 0;
 	while (off) {
 		build_copy_store_pref(&buf, -off);
 		off -= cache_line_size;

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

* Re: [PATCH][MIPS] fix divide by zero error in build_clear_page and build_copy_page
  2008-05-07 14:38 [PATCH][MIPS] fix divide by zero error in build_clear_page and build_copy_page Yoichi Yuasa
@ 2008-05-07 16:14 ` Maciej W. Rozycki
  2008-05-07 22:38   ` Yoichi Yuasa
  2008-05-15 10:00 ` Ralf Baechle
  2008-05-30  4:07 ` Atsushi Nemoto
  2 siblings, 1 reply; 8+ messages in thread
From: Maciej W. Rozycki @ 2008-05-07 16:14 UTC (permalink / raw)
  To: Yoichi Yuasa; +Cc: Ralf Baechle, linux-mips

On Wed, 7 May 2008, Yoichi Yuasa wrote:

> Fix divide by zero error in build_clear_page() and build_copy_page()

 Why would ever cache_line_size be zero in this place?  Are you trying to 
support a cacheless CPU?  If not, it should be a BUG_ON().

  Maciej

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

* Re: [PATCH][MIPS] fix divide by zero error in build_clear_page and build_copy_page
  2008-05-07 16:14 ` Maciej W. Rozycki
@ 2008-05-07 22:38   ` Yoichi Yuasa
  2008-05-07 23:04     ` Maciej W. Rozycki
  0 siblings, 1 reply; 8+ messages in thread
From: Yoichi Yuasa @ 2008-05-07 22:38 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: yoichi_yuasa, Ralf Baechle, linux-mips

On Wed, 7 May 2008 17:14:22 +0100 (BST)
"Maciej W. Rozycki" <macro@linux-mips.org> wrote:

> On Wed, 7 May 2008, Yoichi Yuasa wrote:
> 
> > Fix divide by zero error in build_clear_page() and build_copy_page()
> 
>  Why would ever cache_line_size be zero in this place?  Are you trying to 
> support a cacheless CPU?  If not, it should be a BUG_ON().
> 

When CPU has no prefetch, no cache cdex_s and no caache cdex_p, cache_line_size is zero.
I confirmed it with Nevada(Cobalt server) and VR41xx.

Yoichi

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

* Re: [PATCH][MIPS] fix divide by zero error in build_clear_page and build_copy_page
  2008-05-07 22:38   ` Yoichi Yuasa
@ 2008-05-07 23:04     ` Maciej W. Rozycki
  2008-05-09  8:49       ` Ralf Baechle
  0 siblings, 1 reply; 8+ messages in thread
From: Maciej W. Rozycki @ 2008-05-07 23:04 UTC (permalink / raw)
  To: Yoichi Yuasa; +Cc: Ralf Baechle, linux-mips

On Thu, 8 May 2008, Yoichi Yuasa wrote:

> >  Why would ever cache_line_size be zero in this place?  Are you trying to 
> > support a cacheless CPU?  If not, it should be a BUG_ON().
> > 
> 
> When CPU has no prefetch, no cache cdex_s and no caache cdex_p, cache_line_size is zero.
> I confirmed it with Nevada(Cobalt server) and VR41xx.

 Fair enough.  I confused the variable with some others used to store the
actual line size of each of the caches.  Your change is correct, thank you
and sorry about the noise.

  Maciej

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

* Re: [PATCH][MIPS] fix divide by zero error in build_clear_page and build_copy_page
  2008-05-07 23:04     ` Maciej W. Rozycki
@ 2008-05-09  8:49       ` Ralf Baechle
  0 siblings, 0 replies; 8+ messages in thread
From: Ralf Baechle @ 2008-05-09  8:49 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: Yoichi Yuasa, linux-mips

On Thu, May 08, 2008 at 12:04:54AM +0100, Maciej W. Rozycki wrote:

> > >  Why would ever cache_line_size be zero in this place?  Are you trying to 
> > > support a cacheless CPU?  If not, it should be a BUG_ON().
> > > 
> > 
> > When CPU has no prefetch, no cache cdex_s and no caache cdex_p, cache_line_size is zero.
> > I confirmed it with Nevada(Cobalt server) and VR41xx.
> 
>  Fair enough.  I confused the variable with some others used to store the
> actual line size of each of the caches.  Your change is correct, thank you
> and sorry about the noise.

And I guess that means the variable should get a better name.

  Ralf

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

* Re: [PATCH][MIPS] fix divide by zero error in build_clear_page and build_copy_page
  2008-05-07 14:38 [PATCH][MIPS] fix divide by zero error in build_clear_page and build_copy_page Yoichi Yuasa
  2008-05-07 16:14 ` Maciej W. Rozycki
@ 2008-05-15 10:00 ` Ralf Baechle
  2008-05-30  4:07 ` Atsushi Nemoto
  2 siblings, 0 replies; 8+ messages in thread
From: Ralf Baechle @ 2008-05-15 10:00 UTC (permalink / raw)
  To: Yoichi Yuasa; +Cc: linux-mips

On Wed, May 07, 2008 at 11:38:15PM +0900, Yoichi Yuasa wrote:

Applied a few days ago already.  Thanks!

  Ralf

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

* Re: [PATCH][MIPS] fix divide by zero error in build_clear_page and build_copy_page
  2008-05-07 14:38 [PATCH][MIPS] fix divide by zero error in build_clear_page and build_copy_page Yoichi Yuasa
  2008-05-07 16:14 ` Maciej W. Rozycki
  2008-05-15 10:00 ` Ralf Baechle
@ 2008-05-30  4:07 ` Atsushi Nemoto
  2008-06-13 13:19   ` Ralf Baechle
  2 siblings, 1 reply; 8+ messages in thread
From: Atsushi Nemoto @ 2008-05-30  4:07 UTC (permalink / raw)
  To: yoichi_yuasa; +Cc: ralf, linux-mips

On Wed, 7 May 2008 23:38:15 +0900, Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> wrote:
> Fix divide by zero error in build_clear_page() and build_copy_page()
> 
> Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
> 
> diff -pruN -X /home/yuasa/Memo/dontdiff linux-orig/arch/mips/mm/page.c linux/arch/mips/mm/page.c
> --- linux-orig/arch/mips/mm/page.c	2008-05-07 10:28:03.732151097 +0900
> +++ linux/arch/mips/mm/page.c	2008-05-07 23:27:00.212977534 +0900
...
> -	off = min(8, pref_bias_copy_store / cache_line_size) * cache_line_size;
> +	off = cache_line_size ? min(8, pref_bias_copy_load / cache_line_size) *
> +	                        cache_line_size : 0;
>  	while (off) {
>  		build_copy_store_pref(&buf, -off);
>  		off -= cache_line_size;

This change is wrong.  Please apply this on top of the patch.

diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c
index cab81f4..1edf0cb 100644
--- a/arch/mips/mm/page.c
+++ b/arch/mips/mm/page.c
@@ -460,7 +460,7 @@ void __cpuinit build_copy_page(void)
 		build_copy_load_pref(&buf, -off);
 		off -= cache_line_size;
 	}
-	off = cache_line_size ? min(8, pref_bias_copy_load / cache_line_size) *
+	off = cache_line_size ? min(8, pref_bias_copy_store / cache_line_size) *
 	                        cache_line_size : 0;
 	while (off) {
 		build_copy_store_pref(&buf, -off);

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

* Re: [PATCH][MIPS] fix divide by zero error in build_clear_page and build_copy_page
  2008-05-30  4:07 ` Atsushi Nemoto
@ 2008-06-13 13:19   ` Ralf Baechle
  0 siblings, 0 replies; 8+ messages in thread
From: Ralf Baechle @ 2008-06-13 13:19 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: yoichi_yuasa, linux-mips

On Fri, May 30, 2008 at 01:07:21PM +0900, Atsushi Nemoto wrote:

> This change is wrong.  Please apply this on top of the patch.

Applied.

  Ralf

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

end of thread, other threads:[~2008-06-13 13:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-07 14:38 [PATCH][MIPS] fix divide by zero error in build_clear_page and build_copy_page Yoichi Yuasa
2008-05-07 16:14 ` Maciej W. Rozycki
2008-05-07 22:38   ` Yoichi Yuasa
2008-05-07 23:04     ` Maciej W. Rozycki
2008-05-09  8:49       ` Ralf Baechle
2008-05-15 10:00 ` Ralf Baechle
2008-05-30  4:07 ` Atsushi Nemoto
2008-06-13 13:19   ` Ralf Baechle

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