From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zpfot-0001Ue-6I for qemu-devel@nongnu.org; Fri, 23 Oct 2015 13:07:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zpfop-0008DM-VD for qemu-devel@nongnu.org; Fri, 23 Oct 2015 13:07:59 -0400 Received: from mail-lf0-x236.google.com ([2a00:1450:4010:c07::236]:34661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zpfop-0008DF-Oa for qemu-devel@nongnu.org; Fri, 23 Oct 2015 13:07:55 -0400 Received: by lfaz124 with SMTP id z124so90830911lfa.1 for ; Fri, 23 Oct 2015 10:07:54 -0700 (PDT) References: <1444779048-10096-1-git-send-email-digetx@gmail.com> <56254C0E.8050909@gmail.com> From: Dmitry Osipenko Message-ID: <562A6937.1060605@gmail.com> Date: Fri, 23 Oct 2015 20:07:03 +0300 MIME-Version: 1.0 In-Reply-To: <56254C0E.8050909@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v5 1/2] hw/ptimer: Set delta to the original limit on reload in ptimer_set_limit() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Peter Crosthwaite , QEMU Developers 19.10.2015 23:01, Dmitry Osipenko пишет: > What about the following: > > Add additional ptimer struct member, say "limit_corrected", to check whether the > limit was corrected or not. > > ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload) > { > .limit_corrected = 0; > > // on the limit correction: > .limit_corrected = (limit == 0) ? 1 : 2; > limit = 10000 / s->period; > } > > ptimer_get_count() > { > if (enabled) { > if (expired || .limit_corrected == 1) { > counter = 0; > } else if (.limit_corrected == 2) { > counter = 1; > } else { > // do the counter calculations ... > } > } > } > > and clear .limit_corrected on the one-shot timer start. That would bump ptimer > VMSD version, but keep .minimum_version_id. > However, that would break set_counter(). Also limit should be corrected on period / freq change. I'll work more on it. -- Dmitry