Received: from eggs.gnu.org ([2001:4830:134:3::10]:55102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afxlq-0000cR-20 for qemu-devel@nongnu.org; Tue, 15 Mar 2016 18:48:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afxlp-0003ZT-1n for qemu-devel@nongnu.org; Tue, 15 Mar 2016 18:48:57 -0400 Message-ID: <1458082119.29435.29.camel@aj.id.au> From: Andrew Jeffery Date: Wed, 16 Mar 2016 09:18:39 +1030 In-Reply-To: <56E850F9.5080307@gmail.com> References: <1457928832-31026-1-git-send-email-andrew@aj.id.au> <1457928832-31026-2-git-send-email-andrew@aj.id.au> <56E850F9.5080307@gmail.com> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-luOkRVdxnFvBAAO0YeK9" Mime-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH v4 1/4] hw/timer: Add ASPEED timer device model Reply-To: andrew@aj.id.au List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dmitry Osipenko , Peter Maydell Cc: Alexey Kardashevskiy , Jeremy Kerr , qemu-arm@nongnu.org, qemu-devel@nongnu.org, =?ISO-8859-1?Q?C=E9dric?= Le Goater --=-luOkRVdxnFvBAAO0YeK9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Dmitry, On Tue, 2016-03-15 at 21:14 +0300, Dmitry Osipenko wrote: > Hello Andrew, >=20 > 14.03.2016 07:13, Andrew Jeffery =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > > Implement basic ASPEED timer functionality for the AST2400 SoC[1]: Up t= o > > 8 timers can independently be configured, enabled, reset and disabled. > > Some hardware features are not implemented, namely clock value matching > > and pulse generation, but the implementation is enough to boot the Linu= x > > kernel configured with aspeed_defconfig. > >=20 >=20 > [snip] >=20 > > +static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer,= int reg, > > + uint32_t value) > > +{ > > + AspeedTimer *t; > > + > > + g_assert(timer >=3D 0 && timer < ASPEED_TIMER_NR_TIMERS); >=20 > This would never fail, wouldn't it? You're right, it shouldn't: I put it in as a sanity check and some "active" documentation. I'm happy to remove it if you think just adds noise. >=20 > [snip] >=20 > > +static void aspeed_timer_write(void *opaque, hwaddr offset, uint64_t v= alue, > > + unsigned size) > > +{ > > + const uint32_t tv =3D (uint32_t)(value & 0xFFFFFFFF); > > + const int reg =3D (offset & 0xf) / 4; > > + AspeedTimerCtrlState *s =3D opaque; > > + > > + switch (offset) { > > + /* Control Registers */ > > + case 0x30: > > + aspeed_timer_set_ctrl(s, tv); > > + break; > > + case 0x34: > > + aspeed_timer_set_ctrl2(s, tv); > > + break; > > + /* Timer Registers */ > > + case 0x00 ... 0x2c: > > + aspeed_timer_set_value(s, (offset >> TIMER_NR_REGS), reg, tv); > > + break; > > + case 0x40 ... 0x8c: > > + aspeed_timer_set_value(s, (offset >> TIMER_NR_REGS) - 1, reg, = tv); > > + break; >=20 >=20 > [snip] >=20 > > +static void aspeed_init_one_timer(AspeedTimerCtrlState *s, uint8_t id) > > +{ > > + QEMUBH *bh; > > + AspeedTimer *t =3D &s->timers[id]; > > + > > + t->id =3D id; > > + bh =3D qemu_bh_new(aspeed_timer_expire, t); > > + assert(bh); > > + t->timer =3D ptimer_init(bh); > > + assert(t->timer); > > +} >=20 > I'm wondering why do you need those asserts, it's very unlikely that this= code=20 > would fail. Have you had any weird issues with it? No, no weird issues - thanks for pointing them out as I'll remove them: I put them in when I started developing the series, before understanding that either call should already have aborted if the allocations failed. Thanks for taking a look at the patch! Andrew --=-luOkRVdxnFvBAAO0YeK9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABCgAGBQJW6JFHAAoJEJ0dnzgO5LT5aDQP/20cYZLXwvTgNwduoe4giCEg UBIKbS0ePRTfkjMux6HzMWl8cweT6gzDUAjN7bMFwYsA45nUK+RjwXzkaA5W87KL D4ST2zNCVsEkK1rct48XrcRC1s8zxr1DIXtYxYTj2MmzmzxORlmVPJOHtUkhtehU k3N0uwn3enW0xFMBPQ0mprA/CZMb0OVmabEk+rgBWhU16PUDvUFHFdu3qU2Wfcui 7wLq21jkd6/rI2HtyX9eXT72aZWf9QNEu1Is9W5jHh0YRh4+6ccJ+V2vFkl+/kRJ pOVtmb2zYCD+lgijFir4xsodt220qsJjdFkY1HCBmM448X8NUoPQYgEsHjKRndZ1 WWb/+Ra0qpZm+P/y5cDg2HCbYyPdwmDZzGN4K0bsVwAD/HFEcmmkkt/QLWXrKx8r InthVaMKs28uqP8k1oDTEFso7/T0EDOdhz6W7z6BzWzn5LfCJM9vxiyXB1E9yPFm oSozVUfS590MTpANJ8Lfq5Dj9kNLMkqL355PXk3ofCWtCR5v75bXeLlHJEiMCDHO vwk4sL5wBzPxzJmM/M2wk8ozgtHfxmvYIszeDrbmlyjmEu+QHVJ3STTs4tXPbPC0 HhohG4hX5y8ZBvH41oJUSzw5FzNrqbIga4MqcVrwJUIdwh4O2ZqvOHAwJn5zRPkZ VTnDYZdmNTQETQgL94Nt =7Xk3 -----END PGP SIGNATURE----- --=-luOkRVdxnFvBAAO0YeK9--