From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGo7e-0004dj-4s for qemu-devel@nongnu.org; Sat, 25 Jun 2016 09:59:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bGo7d-000510-7r for qemu-devel@nongnu.org; Sat, 25 Jun 2016 09:59:46 -0400 References: <20160625123521.16752-1-digetx@gmail.com> From: Dmitry Osipenko Message-ID: <22cbcf06-a43d-efbc-d83e-c2d1301b8e57@gmail.com> Date: Sat, 25 Jun 2016 16:59:37 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] hw/ptimer: Don't wrap around counter for expired timer that uses tick handler List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark Cave-Ayland , QEMU Developers , qemu-arm@nongnu.org Cc: Peter Crosthwaite , Peter Maydell On 25.06.2016 16:20, Mark Cave-Ayland wrote: > On 25/06/16 13:35, Dmitry Osipenko wrote: > >> Software should see timer counter wrap around only after IRQ being triggered. >> Change returned counter value to "1" for the expired timer and avoid returning >> wrapped around counter value in periodic mode for the timer that has bottom-half >> handler setup, assuming it drives timer IRQ. >> >> This fixes regression introduced by the commit 5a50307 ("hw/ptimer: Perform >> counter wrap around if timer already expired") on SPARC emulated machine as >> reported by Mark Cave-Ayland. >> >> Signed-off-by: Dmitry Osipenko >> --- >> hw/core/ptimer.c | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c >> index 05b0c27..8006442 100644 >> --- a/hw/core/ptimer.c >> +++ b/hw/core/ptimer.c >> @@ -93,10 +93,10 @@ uint64_t ptimer_get_count(ptimer_state *s) >> bool oneshot = (s->enabled == 2); >> >> /* Figure out the current counter value. */ >> - if (s->period == 0 || (expired && (oneshot || use_icount))) { >> + if (expired && (oneshot || use_icount || s->bh != NULL)) { >> /* Prevent timer underflowing if it should already have >> triggered. */ >> - counter = 0; >> + counter = 1; >> } else { >> uint64_t rem; >> uint64_t div; >> @@ -143,7 +143,9 @@ uint64_t ptimer_get_count(ptimer_state *s) >> >> if (expired && counter != 0) { >> /* Wrap around periodic counter. */ >> - counter = s->limit - (counter - 1) % s->limit; >> + counter = s->delta = s->limit - (counter - 1) % s->limit; >> + /* Re-arm timer according to the wrapped around value. */ >> + ptimer_reload(s); >> } >> } >> } else { >> > > Hi Dmitry, > > I ran through all of my OpenBIOS test images for qemu-system-sparc and AFAICT > this fixes the issue without introducing any further regressions so: > > Tested-by: Mark Cave-Ayland > > > Many thanks, > > Mark. > Great! Thanks for testing it. -- Dmitry