From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH v3 2/7] hpet: Save/restore cached RTC IRQ level Date: Tue, 31 Jan 2012 23:39:40 +0100 Message-ID: <4F286DAC.9020601@web.de> References: <1e517ab259c42885b0dbb49ea13db92f2df45815.1328031687.git.jan.kiszka@siemens.com> <4F2856EB.1030004@us.ibm.com> <4F2865AD.5060200@web.de> <4F286D4A.1010006@us.ibm.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigA3B18A9CEA4E98BF31999071" Cc: Blue Swirl , Marcelo Tosatti , qemu-devel , kvm , Avi Kivity To: Anthony Liguori Return-path: Received: from fmmailgate03.web.de ([217.72.192.234]:39644 "EHLO fmmailgate03.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753613Ab2AaWjo (ORCPT ); Tue, 31 Jan 2012 17:39:44 -0500 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate03.web.de (Postfix) with ESMTP id E658E1B08F028 for ; Tue, 31 Jan 2012 23:39:42 +0100 (CET) In-Reply-To: <4F286D4A.1010006@us.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigA3B18A9CEA4E98BF31999071 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2012-01-31 23:38, Anthony Liguori wrote: > On 01/31/2012 04:05 PM, Jan Kiszka wrote: >> On 2012-01-31 22:02, Anthony Liguori wrote: >>> On 01/31/2012 11:41 AM, Jan Kiszka wrote: >>>> In legacy mode, the HPET suppresses the RTC interrupt delivery via I= RQ >>>> 8 but keeps track of the RTC output level and applies it when legacy= >>>> mode is turned off again. This value has to be preserved across save= / >>>> restore as it cannot be reconstructed otherwise. >>>> >>>> Signed-off-by: Jan Kiszka >>>> --- >>>> hw/hpet.c | 26 ++++++++++++++++++++++++++ >>>> 1 files changed, 26 insertions(+), 0 deletions(-) >>>> >>>> diff --git a/hw/hpet.c b/hw/hpet.c >>>> index aba9ea9..39b291f 100644 >>>> --- a/hw/hpet.c >>>> +++ b/hw/hpet.c >>>> @@ -240,6 +240,24 @@ static int hpet_post_load(void *opaque, int >>>> version_id) >>>> return 0; >>>> } >>>> >>>> +static bool hpet_rtc_irq_level_needed(void *opaque) >>>> +{ >>>> + HPETState *s =3D opaque; >>>> + >>>> + return s->rtc_irq_level !=3D 0; >>>> +} >>>> + >>>> +static const VMStateDescription vmstate_hpet_rtc_irq_level =3D { >>>> + .name =3D "hpet/rtc_irq_level", >>>> + .version_id =3D 1, >>>> + .minimum_version_id =3D 1, >>>> + .minimum_version_id_old =3D 1, >>>> + .fields =3D (VMStateField[]) { >>>> + VMSTATE_UINT8(rtc_irq_level, HPETState), >>>> + VMSTATE_END_OF_LIST() >>>> + } >>>> +}; >>>> + >>> >>> This won't work. We don't clear rtc_irq_level on reset so rtc_irq_le= vel >>> may be high or low after reset. As such, we can't use a subsection >>> here. We need to bump the savevm state. >> >> rtc_irq_level is updated during reset by the connected RTC device. It >> clears its IRQ line. >=20 > Ah, that's subtle and warrants a comment :-) >=20 > Probably worth adding an s->rtc_irq_level =3D 0 in reset just to be ext= ra > safe. Agreed. Will do. Thanks, Jan --------------enigA3B18A9CEA4E98BF31999071 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8obawACgkQitSsb3rl5xSj/wCdGaBiLpKXdylvfty0kNEk9guc ctoAn2SXzSOIioHpDr3ak0szWuMWQt3h =rz/Y -----END PGP SIGNATURE----- --------------enigA3B18A9CEA4E98BF31999071-- From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:45373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsMMg-0004G4-9M for qemu-devel@nongnu.org; Tue, 31 Jan 2012 17:39:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RsMMa-0001UP-J0 for qemu-devel@nongnu.org; Tue, 31 Jan 2012 17:39:50 -0500 Received: from fmmailgate02.web.de ([217.72.192.227]:48215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsMMa-0001UD-5o for qemu-devel@nongnu.org; Tue, 31 Jan 2012 17:39:44 -0500 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate02.web.de (Postfix) with ESMTP id D9A271C090AF8 for ; Tue, 31 Jan 2012 23:39:42 +0100 (CET) Message-ID: <4F286DAC.9020601@web.de> Date: Tue, 31 Jan 2012 23:39:40 +0100 From: Jan Kiszka MIME-Version: 1.0 References: <1e517ab259c42885b0dbb49ea13db92f2df45815.1328031687.git.jan.kiszka@siemens.com> <4F2856EB.1030004@us.ibm.com> <4F2865AD.5060200@web.de> <4F286D4A.1010006@us.ibm.com> In-Reply-To: <4F286D4A.1010006@us.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigA3B18A9CEA4E98BF31999071" Subject: Re: [Qemu-devel] [PATCH v3 2/7] hpet: Save/restore cached RTC IRQ level List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Blue Swirl , Marcelo Tosatti , qemu-devel , kvm , Avi Kivity This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigA3B18A9CEA4E98BF31999071 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2012-01-31 23:38, Anthony Liguori wrote: > On 01/31/2012 04:05 PM, Jan Kiszka wrote: >> On 2012-01-31 22:02, Anthony Liguori wrote: >>> On 01/31/2012 11:41 AM, Jan Kiszka wrote: >>>> In legacy mode, the HPET suppresses the RTC interrupt delivery via I= RQ >>>> 8 but keeps track of the RTC output level and applies it when legacy= >>>> mode is turned off again. This value has to be preserved across save= / >>>> restore as it cannot be reconstructed otherwise. >>>> >>>> Signed-off-by: Jan Kiszka >>>> --- >>>> hw/hpet.c | 26 ++++++++++++++++++++++++++ >>>> 1 files changed, 26 insertions(+), 0 deletions(-) >>>> >>>> diff --git a/hw/hpet.c b/hw/hpet.c >>>> index aba9ea9..39b291f 100644 >>>> --- a/hw/hpet.c >>>> +++ b/hw/hpet.c >>>> @@ -240,6 +240,24 @@ static int hpet_post_load(void *opaque, int >>>> version_id) >>>> return 0; >>>> } >>>> >>>> +static bool hpet_rtc_irq_level_needed(void *opaque) >>>> +{ >>>> + HPETState *s =3D opaque; >>>> + >>>> + return s->rtc_irq_level !=3D 0; >>>> +} >>>> + >>>> +static const VMStateDescription vmstate_hpet_rtc_irq_level =3D { >>>> + .name =3D "hpet/rtc_irq_level", >>>> + .version_id =3D 1, >>>> + .minimum_version_id =3D 1, >>>> + .minimum_version_id_old =3D 1, >>>> + .fields =3D (VMStateField[]) { >>>> + VMSTATE_UINT8(rtc_irq_level, HPETState), >>>> + VMSTATE_END_OF_LIST() >>>> + } >>>> +}; >>>> + >>> >>> This won't work. We don't clear rtc_irq_level on reset so rtc_irq_le= vel >>> may be high or low after reset. As such, we can't use a subsection >>> here. We need to bump the savevm state. >> >> rtc_irq_level is updated during reset by the connected RTC device. It >> clears its IRQ line. >=20 > Ah, that's subtle and warrants a comment :-) >=20 > Probably worth adding an s->rtc_irq_level =3D 0 in reset just to be ext= ra > safe. Agreed. Will do. Thanks, Jan --------------enigA3B18A9CEA4E98BF31999071 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8obawACgkQitSsb3rl5xSj/wCdGaBiLpKXdylvfty0kNEk9guc ctoAn2SXzSOIioHpDr3ak0szWuMWQt3h =rz/Y -----END PGP SIGNATURE----- --------------enigA3B18A9CEA4E98BF31999071--