From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtozH-0004NW-NH for qemu-devel@nongnu.org; Tue, 03 Nov 2015 22:43:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtozE-0002PR-TM for qemu-devel@nongnu.org; Tue, 03 Nov 2015 22:43:51 -0500 Date: Wed, 4 Nov 2015 14:20:55 +1100 From: David Gibson Message-ID: <20151104032054.GJ21954@voom.redhat.com> References: <1445608598-24485-1-git-send-email-mark.cave-ayland@ilande.co.uk> <1445608598-24485-11-git-send-email-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="HcccYpVZDxQ8hzPO" Content-Disposition: inline In-Reply-To: <1445608598-24485-11-git-send-email-mark.cave-ayland@ilande.co.uk> Subject: Re: [Qemu-devel] [PATCH 10/13] cuda.c: refactor get_tb() so that the time can be passed in List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark Cave-Ayland Cc: cormac@c-obrien.org, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, agraf@suse.de --HcccYpVZDxQ8hzPO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 23, 2015 at 02:56:35PM +0100, Mark Cave-Ayland wrote: > This is in preparation for sharing the code between timers. >=20 > Signed-off-by: Mark Cave-Ayland Reviewed-by: David Gibson > --- > hw/misc/macio/cuda.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) >=20 > diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c > index d32afc6..7a1b10b 100644 > --- a/hw/misc/macio/cuda.c > +++ b/hw/misc/macio/cuda.c > @@ -143,10 +143,9 @@ static void cuda_update_irq(CUDAState *s) > } > } > =20 > -static uint64_t get_tb(uint64_t freq) > +static uint64_t get_tb(uint64_t time, uint64_t freq) > { > - return muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), > - freq, get_ticks_per_sec()); > + return muldiv64(time, freq, get_ticks_per_sec()); > } > =20 > static unsigned int get_counter(CUDATimer *s) > @@ -154,9 +153,10 @@ static unsigned int get_counter(CUDATimer *s) > int64_t d; > unsigned int counter; > uint64_t tb_diff; > + uint64_t current_time =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); > =20 > /* Reverse of the tb calculation algorithm that Mac OS X uses on boo= tup. */ > - tb_diff =3D get_tb(s->frequency) - s->load_time; > + tb_diff =3D get_tb(current_time, s->frequency) - s->load_time; > d =3D (tb_diff * 0xBF401675E5DULL) / (s->frequency << 24); > =20 > if (s->index =3D=3D 0) { > @@ -176,7 +176,8 @@ static unsigned int get_counter(CUDATimer *s) > static void set_counter(CUDAState *s, CUDATimer *ti, unsigned int val) > { > CUDA_DPRINTF("T%d.counter=3D%d\n", 1 + (ti->timer =3D=3D NULL), val); > - ti->load_time =3D get_tb(s->frequency); > + ti->load_time =3D get_tb(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), > + s->frequency); > ti->counter_value =3D val; > cuda_timer_update(s, ti, ti->load_time); > } --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --HcccYpVZDxQ8hzPO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWOXmWAAoJEGw4ysog2bOSngoP+gM16c7YmeLu2pYVxmMnWJwV r6EyhDqpPLMZrLcQNnkYLx8NUJhCBympB/UufT4VgA8vPMCZjVT0hp73W0KkSOT+ q/D9lPH8BcHaxiTVrXGdR+kOzyQYdLUBpOhYLU38Bn847GcOWjwUtJmanSnMrfaM pmCP6hFn1hVv9IcoQo72qwdaaA+gGSmSQH1DwxCmWb6tKOzD8hSwSHJNwNwqH3YE Jw+TIUOgG4sOdY1OWK26HeaSLDXfTjQhm2P2CTrryYlMOgKCcazVbQD4krFWy9uH gUNk04FrrEdHLq4KAPBxsABXBCP7RjwmKVPnJXM96SBZAVpTV3FlakJP7LW50Ps2 +lFTv8WXy11/i8MKlldz4SHuBSSeiSe/MBTVh8SQI4W9GsQxAamw4/D29csyTgN/ v74FaK+vh/l8lWwzHFK7T9m8FHWjeJNjSkUIkZ6Gh2jizONn1xmCbUbJeFjvtCvG RRkXwdOA+0avKQrmLzfCIdyrV9ed9/I6/JbsW5OISVejnZBCl1b8iGKxobEBknyO lPmlKv5U5jwjgVDd8j4XSfDiN5FfuAlifUWjk+5Sl/FyJNgOvmksEilgOOqcfV+f JH6U3QUKZDe29VGcap0xgy/IuF/kih9GTqBhF/vcEOJaRlnMjkHq/R/ccCPfSCqa C2PlSGq4uSPNeaJnGJoI =Y4x9 -----END PGP SIGNATURE----- --HcccYpVZDxQ8hzPO--