qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] sparc32: make number of per CPU timers match number of CPUs
@ 2007-12-16 22:58 Robert Reif
  2007-12-16 23:19 ` Robert Reif
  0 siblings, 1 reply; 3+ messages in thread
From: Robert Reif @ 2007-12-16 22:58 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 54 bytes --]

Only create as many per CPU timers as there are CPUs.

[-- Attachment #2: timer.diff.txt --]
[-- Type: text/plain, Size: 2613 bytes --]

Index: hw/slavio_timer.c
===================================================================
RCS file: /sources/qemu/qemu/hw/slavio_timer.c,v
retrieving revision 1.21
diff -p -u -r1.21 slavio_timer.c
--- hw/slavio_timer.c	1 Dec 2007 15:58:22 -0000	1.21
+++ hw/slavio_timer.c	16 Dec 2007 22:53:33 -0000
@@ -61,6 +61,7 @@ typedef struct SLAVIO_TIMERState {
     struct SLAVIO_TIMERState *master;
     int slave_index;
     // system only
+    unsigned int num_slaves;
     struct SLAVIO_TIMERState *slave[MAX_CPUS];
     uint32_t slave_mode;
 } SLAVIO_TIMERState;
@@ -352,14 +353,16 @@ static SLAVIO_TIMERState *slavio_timer_i
 }
 
 void slavio_timer_init_all(target_phys_addr_t base, qemu_irq master_irq,
-                           qemu_irq *cpu_irqs)
+                           qemu_irq *cpu_irqs, unsigned int num_cpus)
 {
     SLAVIO_TIMERState *master;
     unsigned int i;
 
     master = slavio_timer_init(base + SYS_TIMER_OFFSET, master_irq, NULL, 0);
 
-    for (i = 0; i < MAX_CPUS; i++) {
+    master->num_slaves = num_cpus;
+
+    for (i = 0; i < master->num_slaves; i++) {
         master->slave[i] = slavio_timer_init(base + (target_phys_addr_t)
                                              CPU_TIMER_OFFSET(i),
                                              cpu_irqs[i], master, i);
Index: hw/sun4m.c
===================================================================
RCS file: /sources/qemu/qemu/hw/sun4m.c,v
retrieving revision 1.69
diff -p -u -r1.69 sun4m.c
--- hw/sun4m.c	10 Dec 2007 20:00:11 -0000	1.69
+++ hw/sun4m.c	16 Dec 2007 22:53:33 -0000
@@ -436,7 +436,7 @@ static void sun4m_hw_init(const struct h
                         hwdef->nvram_size, 8);
 
     slavio_timer_init_all(hwdef->counter_base, slavio_irq[hwdef->clock1_irq],
-                          slavio_cpu_irq);
+                          slavio_cpu_irq, smp_cpus);
 
     slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq],
                               nographic);
Index: hw/sun4m.h
===================================================================
RCS file: /sources/qemu/qemu/hw/sun4m.h,v
retrieving revision 1.4
diff -p -u -r1.4 sun4m.h
--- hw/sun4m.h	9 Dec 2007 17:03:50 -0000	1.4
+++ hw/sun4m.h	16 Dec 2007 22:53:33 -0000
@@ -36,7 +36,7 @@ void slavio_irq_info(void *opaque);
 
 /* slavio_timer.c */
 void slavio_timer_init_all(target_phys_addr_t base, qemu_irq master_irq,
-                           qemu_irq *cpu_irqs);
+                           qemu_irq *cpu_irqs, unsigned int num_cpus);
 
 /* slavio_serial.c */
 SerialState *slavio_serial_init(target_phys_addr_t base, qemu_irq irq,

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

* Re: [Qemu-devel] [PATCH] sparc32: make number of per CPU timers match number of CPUs
  2007-12-16 22:58 [Qemu-devel] [PATCH] sparc32: make number of per CPU timers match number of CPUs Robert Reif
@ 2007-12-16 23:19 ` Robert Reif
  2007-12-17 18:23   ` Blue Swirl
  0 siblings, 1 reply; 3+ messages in thread
From: Robert Reif @ 2007-12-16 23:19 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 109 bytes --]

Robert Reif wrote:

> Only create as many per CPU timers as there are CPUs.

This time with the right patch.

[-- Attachment #2: timer.diff.txt --]
[-- Type: text/plain, Size: 3327 bytes --]

Index: hw/slavio_timer.c
===================================================================
RCS file: /sources/qemu/qemu/hw/slavio_timer.c,v
retrieving revision 1.21
diff -p -u -r1.21 slavio_timer.c
--- hw/slavio_timer.c	1 Dec 2007 15:58:22 -0000	1.21
+++ hw/slavio_timer.c	16 Dec 2007 23:14:34 -0000
@@ -61,6 +61,7 @@ typedef struct SLAVIO_TIMERState {
     struct SLAVIO_TIMERState *master;
     int slave_index;
     // system only
+    unsigned int num_slaves;
     struct SLAVIO_TIMERState *slave[MAX_CPUS];
     uint32_t slave_mode;
 } SLAVIO_TIMERState;
@@ -230,7 +231,7 @@ static void slavio_timer_mem_writel(void
         if (s->master == NULL) {
             unsigned int i;
 
-            for (i = 0; i < MAX_CPUS; i++) {
+            for (i = 0; i < s->num_slaves; i++) {
                 if (val & (1 << i)) {
                     qemu_irq_lower(s->slave[i]->irq);
                     s->slave[i]->limit = -1ULL;
@@ -244,7 +245,7 @@ static void slavio_timer_mem_writel(void
                     ptimer_run(s->slave[i]->timer, 0);
                 }
             }
-            s->slave_mode = val & ((1 << MAX_CPUS) - 1);
+            s->slave_mode = val & ((1 << s->num_slaves) - 1);
         } else
             DPRINTF("not system timer\n");
         break;
@@ -352,14 +353,16 @@ static SLAVIO_TIMERState *slavio_timer_i
 }
 
 void slavio_timer_init_all(target_phys_addr_t base, qemu_irq master_irq,
-                           qemu_irq *cpu_irqs)
+                           qemu_irq *cpu_irqs, unsigned int num_cpus)
 {
     SLAVIO_TIMERState *master;
     unsigned int i;
 
     master = slavio_timer_init(base + SYS_TIMER_OFFSET, master_irq, NULL, 0);
 
-    for (i = 0; i < MAX_CPUS; i++) {
+    master->num_slaves = num_cpus;
+
+    for (i = 0; i < master->num_slaves; i++) {
         master->slave[i] = slavio_timer_init(base + (target_phys_addr_t)
                                              CPU_TIMER_OFFSET(i),
                                              cpu_irqs[i], master, i);
Index: hw/sun4m.c
===================================================================
RCS file: /sources/qemu/qemu/hw/sun4m.c,v
retrieving revision 1.69
diff -p -u -r1.69 sun4m.c
--- hw/sun4m.c	10 Dec 2007 20:00:11 -0000	1.69
+++ hw/sun4m.c	16 Dec 2007 23:14:35 -0000
@@ -436,7 +436,7 @@ static void sun4m_hw_init(const struct h
                         hwdef->nvram_size, 8);
 
     slavio_timer_init_all(hwdef->counter_base, slavio_irq[hwdef->clock1_irq],
-                          slavio_cpu_irq);
+                          slavio_cpu_irq, smp_cpus);
 
     slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq],
                               nographic);
Index: hw/sun4m.h
===================================================================
RCS file: /sources/qemu/qemu/hw/sun4m.h,v
retrieving revision 1.4
diff -p -u -r1.4 sun4m.h
--- hw/sun4m.h	9 Dec 2007 17:03:50 -0000	1.4
+++ hw/sun4m.h	16 Dec 2007 23:14:35 -0000
@@ -36,7 +36,7 @@ void slavio_irq_info(void *opaque);
 
 /* slavio_timer.c */
 void slavio_timer_init_all(target_phys_addr_t base, qemu_irq master_irq,
-                           qemu_irq *cpu_irqs);
+                           qemu_irq *cpu_irqs, unsigned int num_cpus);
 
 /* slavio_serial.c */
 SerialState *slavio_serial_init(target_phys_addr_t base, qemu_irq irq,

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

* Re: [Qemu-devel] [PATCH] sparc32: make number of per CPU timers match number of CPUs
  2007-12-16 23:19 ` Robert Reif
@ 2007-12-17 18:23   ` Blue Swirl
  0 siblings, 0 replies; 3+ messages in thread
From: Blue Swirl @ 2007-12-17 18:23 UTC (permalink / raw)
  To: qemu-devel

On 12/17/07, Robert Reif <reif@earthlink.net> wrote:
> Robert Reif wrote:
>
> > Only create as many per CPU timers as there are CPUs.

Thanks, applied. I changed the timer setup a bit so that it doesn't
break my SMP tests.

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

end of thread, other threads:[~2007-12-17 18:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-16 22:58 [Qemu-devel] [PATCH] sparc32: make number of per CPU timers match number of CPUs Robert Reif
2007-12-16 23:19 ` Robert Reif
2007-12-17 18:23   ` Blue Swirl

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