From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JIWTF-0007Z9-Aj for qemu-devel@nongnu.org; Fri, 25 Jan 2008 16:52:21 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JIWTE-0007YK-CF for qemu-devel@nongnu.org; Fri, 25 Jan 2008 16:52:20 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JIWTE-0007YC-8V for qemu-devel@nongnu.org; Fri, 25 Jan 2008 16:52:20 -0500 Received: from pop-tawny.atl.sa.earthlink.net ([207.69.195.67]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JIWTD-0000iI-SL for qemu-devel@nongnu.org; Fri, 25 Jan 2008 16:52:20 -0500 Received: from user-142h2k8.cable.mindspring.com ([72.40.138.136] helo=earthlink.net) by pop-tawny.atl.sa.earthlink.net with esmtp (Exim 3.36 #1) id 1JIWTD-0005Q6-00 for qemu-devel@nongnu.org; Fri, 25 Jan 2008 16:52:19 -0500 Message-ID: <479A5A14.3000009@earthlink.net> Date: Fri, 25 Jan 2008 16:52:20 -0500 From: Robert Reif MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] hw/slavio_timer.c user timer mode change fix References: <4796ACEC.9040901@earthlink.net> <479A4CB6.4040207@earthlink.net> In-Reply-To: <479A4CB6.4040207@earthlink.net> Content-Type: multipart/mixed; boundary="------------010402020108090604010507" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------010402020108090604010507 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Rediffed against cvs. --------------010402020108090604010507 Content-Type: text/plain; name="newtimer.diff.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="newtimer.diff.txt" 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; --------------010402020108090604010507--