* [Qemu-devel] [PATCH] hw/slavio_timer.c user timer mode change fix
@ 2008-01-23 2:56 Robert Reif
2008-01-25 20:30 ` Blue Swirl
0 siblings, 1 reply; 4+ messages in thread
From: Robert Reif @ 2008-01-23 2:56 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 106 bytes --]
Change ptimer limit only when mode changes.
Update timer configuration register user timer bits properly.
[-- Attachment #2: timer2.diff.txt --]
[-- Type: text/plain, Size: 4018 bytes --]
--- hw/slavio_timer.c.old 2008-01-22 21:35:33.000000000 -0500
+++ hw/slavio_timer.c 2008-01-22 21:36:13.000000000 -0500
@@ -198,10 +198,8 @@ static void slavio_timer_mem_writel(void
count = ((uint64_t)s->counthigh << 32) | s->count;
DPRINTF("processor %d user timer set to %016llx\n", s->slave_index,
count);
- if (s->timer) {
+ if (s->timer)
ptimer_set_count(s->timer, LIMIT_TO_PERIODS(s->limit - count));
- ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 0);
- }
} else {
// set limit, reset counter
qemu_irq_lower(s->irq);
@@ -225,10 +223,8 @@ static void slavio_timer_mem_writel(void
count = ((uint64_t)s->counthigh) << 32 | s->count;
DPRINTF("processor %d user timer set to %016llx\n", s->slave_index,
count);
- if (s->timer) {
+ if (s->timer)
ptimer_set_count(s->timer, LIMIT_TO_PERIODS(s->limit - count));
- ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 0);
- }
} else
DPRINTF("not user timer\n");
break;
@@ -263,22 +259,38 @@ static void slavio_timer_mem_writel(void
unsigned int 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;
- } else {
- ptimer_stop(s->slave[i]->timer);
- }
- if ((val & (1 << i)) != (s->slave_mode & (1 << i))) {
- ptimer_stop(s->slave[i]->timer);
- ptimer_set_limit(s->slave[i]->timer,
- LIMIT_TO_PERIODS(s->slave[i]->limit), 1);
- DPRINTF("processor %d timer changed\n",
- s->slave[i]->slave_index);
- ptimer_run(s->slave[i]->timer, 0);
+ unsigned int processor = 1 << i;
+ // check for a change in timer mode for this processor
+ if ((val & processor) != (s->slave_mode & processor)) {
+ if (val & processor) { // counter -> user timer
+ qemu_irq_lower(s->slave[i]->irq);
+ // counters are always running
+ ptimer_stop(s->slave[i]->timer);
+ s->slave[i]->running = 0;
+ // user timer limit is always the same
+ s->slave[i]->limit = TIMER_MAX_COUNT64;
+ ptimer_set_limit(s->slave[i]->timer,
+ LIMIT_TO_PERIODS(s->slave[i]->limit), 1);
+ // set this processors user timer bit in config
+ // register
+ s->slave_mode |= processor;
+ DPRINTF("processor %d changed from counter to user "
+ "timer\n", s->slave[i]->slave_index);
+ } else { // user timer -> counter
+ // stop the user timer if it is running
+ if (s->slave[i]->running)
+ ptimer_stop(s->slave[i]->timer);
+ // start the counter
+ ptimer_run(s->slave[i]->timer, 0);
+ s->slave[i]->running = 1;
+ // clear this processors user timer bit in config
+ // register
+ s->slave_mode &= ~processor;
+ DPRINTF("processor %d changed from user timer to "
+ "counter\n", s->slave[i]->slave_index);
+ }
}
}
- s->slave_mode = val & ((1 << s->num_slaves) - 1);
} else
DPRINTF("not system timer\n");
break;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/slavio_timer.c user timer mode change fix
2008-01-23 2:56 [Qemu-devel] [PATCH] hw/slavio_timer.c user timer mode change fix Robert Reif
@ 2008-01-25 20:30 ` Blue Swirl
2008-01-25 20:55 ` Robert Reif
0 siblings, 1 reply; 4+ messages in thread
From: Blue Swirl @ 2008-01-25 20:30 UTC (permalink / raw)
To: qemu-devel
On 1/23/08, Robert Reif <reif@earthlink.net> wrote:
> Change ptimer limit only when mode changes.
> Update timer configuration register user timer bits properly.
The patch does not apply.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/slavio_timer.c user timer mode change fix
2008-01-25 20:30 ` Blue Swirl
@ 2008-01-25 20:55 ` Robert Reif
2008-01-25 21:52 ` Robert Reif
0 siblings, 1 reply; 4+ messages in thread
From: Robert Reif @ 2008-01-25 20:55 UTC (permalink / raw)
To: qemu-devel
Blue Swirl wrote:
>On 1/23/08, Robert Reif <reif@earthlink.net> wrote:
>
>
>>Change ptimer limit only when mode changes.
>>Update timer configuration register user timer bits properly.
>>
>>
>
>The patch does not apply.
>
It should apply on top of the first user timer patch that is in CVS now.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/slavio_timer.c user timer mode change fix
2008-01-25 20:55 ` Robert Reif
@ 2008-01-25 21:52 ` Robert Reif
0 siblings, 0 replies; 4+ messages in thread
From: Robert Reif @ 2008-01-25 21:52 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 22 bytes --]
Rediffed against cvs.
[-- Attachment #2: newtimer.diff.txt --]
[-- Type: text/plain, Size: 4034 bytes --]
diff -p -u -r1.29 slavio_timer.c
--- hw/slavio_timer.c 25 Jan 2008 19:51:27 -0000 1.29
+++ hw/slavio_timer.c 25 Jan 2008 21:50:35 -0000
@@ -199,10 +199,8 @@ static void slavio_timer_mem_writel(void
count = ((uint64_t)s->counthigh << 32) | s->count;
DPRINTF("processor %d user timer set to %016llx\n", s->slave_index,
count);
- if (s->timer) {
+ if (s->timer)
ptimer_set_count(s->timer, LIMIT_TO_PERIODS(s->limit - count));
- ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 0);
- }
} else {
// set limit, reset counter
qemu_irq_lower(s->irq);
@@ -227,10 +225,8 @@ static void slavio_timer_mem_writel(void
count = ((uint64_t)s->counthigh) << 32 | s->count;
DPRINTF("processor %d user timer set to %016llx\n", s->slave_index,
count);
- if (s->timer) {
+ if (s->timer)
ptimer_set_count(s->timer, LIMIT_TO_PERIODS(s->limit - count));
- ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 0);
- }
} else
DPRINTF("not user timer\n");
break;
@@ -265,22 +261,38 @@ static void slavio_timer_mem_writel(void
unsigned int 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;
- } else {
- ptimer_stop(s->slave[i]->timer);
- }
- if ((val & (1 << i)) != (s->slave_mode & (1 << i))) {
- ptimer_stop(s->slave[i]->timer);
- ptimer_set_limit(s->slave[i]->timer,
- LIMIT_TO_PERIODS(s->slave[i]->limit), 1);
- DPRINTF("processor %d timer changed\n",
- s->slave[i]->slave_index);
- ptimer_run(s->slave[i]->timer, 0);
+ unsigned int processor = 1 << i;
+ // check for a change in timer mode for this processor
+ if ((val & processor) != (s->slave_mode & processor)) {
+ if (val & processor) { // counter -> user timer
+ qemu_irq_lower(s->slave[i]->irq);
+ // counters are always running
+ ptimer_stop(s->slave[i]->timer);
+ s->slave[i]->running = 0;
+ // user timer limit is always the same
+ s->slave[i]->limit = TIMER_MAX_COUNT64;
+ ptimer_set_limit(s->slave[i]->timer,
+ LIMIT_TO_PERIODS(s->slave[i]->limit), 1);
+ // set this processors user timer bit in config
+ // register
+ s->slave_mode |= processor;
+ DPRINTF("processor %d changed from counter to user "
+ "timer\n", s->slave[i]->slave_index);
+ } else { // user timer -> counter
+ // stop the user timer if it is running
+ if (s->slave[i]->running)
+ ptimer_stop(s->slave[i]->timer);
+ // start the counter
+ ptimer_run(s->slave[i]->timer, 0);
+ s->slave[i]->running = 1;
+ // clear this processors user timer bit in config
+ // register
+ s->slave_mode &= ~processor;
+ DPRINTF("processor %d changed from user timer to "
+ "counter\n", s->slave[i]->slave_index);
+ }
}
}
- s->slave_mode = val & ((1 << s->num_slaves) - 1);
} else
DPRINTF("not system timer\n");
break;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-01-25 21:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-23 2:56 [Qemu-devel] [PATCH] hw/slavio_timer.c user timer mode change fix Robert Reif
2008-01-25 20:30 ` Blue Swirl
2008-01-25 20:55 ` Robert Reif
2008-01-25 21:52 ` Robert Reif
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).