From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UV36u-0003yo-54 for qemu-devel@nongnu.org; Wed, 24 Apr 2013 13:04:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UV36p-0004UF-4r for qemu-devel@nongnu.org; Wed, 24 Apr 2013 13:04:00 -0400 Received: from cantor2.suse.de ([195.135.220.15]:52040 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UV36o-0004U1-RZ for qemu-devel@nongnu.org; Wed, 24 Apr 2013 13:03:55 -0400 Message-ID: <51781074.3070603@suse.de> Date: Wed, 24 Apr 2013 19:03:48 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1366705795-24732-1-git-send-email-imammedo@redhat.com> <1366705795-24732-7-git-send-email-imammedo@redhat.com> In-Reply-To: <1366705795-24732-7-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 06/21] target-i386: pc: update rtc_cmos on CPU hot-plug List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: kwolf@redhat.com, peter.maydell@linaro.org, aliguori@us.ibm.com, ehabkost@redhat.com, gleb@redhat.com, mst@redhat.com, jan.kiszka@siemens.com, quintela@redhat.com, claudio.fontana@huawei.com, qemu-devel@nongnu.org, aderumier@odiso.com, lcapitulino@redhat.com, blauwirbel@gmail.com, anthony.perard@citrix.com, alex.williamson@redhat.com, kraxel@redhat.com, yang.z.zhang@intel.com, pbonzini@redhat.com, stefano.stabellini@eu.citrix.com, armbru@redhat.com, rth@twiddle.net Am 23.04.2013 10:29, schrieb Igor Mammedov: > it provides updated currently available CPUs count to BIOS on reboot >=20 > Signed-off-by: Igor Mammedov > --- > v2: > * reorder fields in rtc_cpu_hotplug_arg, make cpu_added_notifier firs= t. > * rebase on top of "mc146818rtc: QOM'ify" and use QOM style cast > --- > hw/i386/pc.c | 20 ++++++++++++++++++++ > hw/timer/mc146818rtc.c | 7 +++++++ > include/hw/timer/mc146818rtc.h | 1 + > 3 files changed, 28 insertions(+), 0 deletions(-) >=20 > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index 0d6e72b..bbc3bea 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -338,6 +338,21 @@ static void pc_cmos_init_late(void *opaque) > qemu_unregister_reset(pc_cmos_init_late, opaque); > } > =20 > +typedef struct rtc_cpu_hotplug_arg { > + Notifier cpu_added_notifier; > + ISADevice *rtc_state; > +} rtc_cpu_hotplug_arg; RTCCPUHotplugArg? > + > +static void rtc_notify_cpu_added(Notifier *notifier, void *data) > +{ > + rtc_cpu_hotplug_arg *arg =3D container_of(notifier, rtc_cpu_hotplu= g_arg, > + cpu_added_notifier); Off-by-one (could fix myself) Rest looks good. Andreas > + ISADevice *s =3D arg->rtc_state; > + > + /* increment the number of CPUs */ > + rtc_set_memory(s, 0x5f, rtc_get_memory(s, 0x5f) + 1); > +} > + > void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, > const char *boot_device, > ISADevice *floppy, BusState *idebus0, BusState *ideb= us1, > @@ -346,6 +361,7 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t a= bove_4g_mem_size, > int val, nb, i; > FDriveType fd_type[2] =3D { FDRIVE_DRV_NONE, FDRIVE_DRV_NONE }; > static pc_cmos_init_late_arg arg; > + static rtc_cpu_hotplug_arg cpu_hotplug_cb; > =20 > /* various important CMOS locations needed by PC/Bochs bios */ > =20 > @@ -384,6 +400,10 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t = above_4g_mem_size, > =20 > /* set the number of CPU */ > rtc_set_memory(s, 0x5f, smp_cpus - 1); > + /* init CPU hotplug notifier */ > + cpu_hotplug_cb.rtc_state =3D s; > + cpu_hotplug_cb.cpu_added_notifier.notify =3D rtc_notify_cpu_added; > + qemu_register_cpu_added_notifier(&cpu_hotplug_cb.cpu_added_notifie= r); > =20 > /* set boot devices, and disable floppy signature check if request= ed */ > if (set_boot_dev(s, boot_device, fd_bootchk)) { > diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c > index afbd0db..481604d 100644 > --- a/hw/timer/mc146818rtc.c > +++ b/hw/timer/mc146818rtc.c > @@ -680,6 +680,13 @@ void rtc_set_memory(ISADevice *dev, int addr, int = val) > s->cmos_data[addr] =3D val; > } > =20 > +int rtc_get_memory(ISADevice *dev, int addr) > +{ > + RTCState *s =3D MC146818_RTC(dev); > + assert(addr >=3D 0 && addr <=3D 127); > + return s->cmos_data[addr]; > +} > + > static void rtc_set_date_from_host(ISADevice *dev) > { > RTCState *s =3D MC146818_RTC(dev); > diff --git a/include/hw/timer/mc146818rtc.h b/include/hw/timer/mc146818= rtc.h > index 425bd17..753dda6 100644 > --- a/include/hw/timer/mc146818rtc.h > +++ b/include/hw/timer/mc146818rtc.h > @@ -8,6 +8,7 @@ > =20 > ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq= ); > void rtc_set_memory(ISADevice *dev, int addr, int val); > +int rtc_get_memory(ISADevice *dev, int addr); > void rtc_set_date(ISADevice *dev, const struct tm *tm); > =20 > #endif /* !MC146818RTC_H */ >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg