hw/riscv/Kconfig | 1 + hw/riscv/virt.c | 15 +++ hw/timer/Kconfig | 3 + hw/timer/Makefile.objs | 1 + hw/timer/goldfish_rtc.c | 221 ++++++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 2 + include/hw/timer/goldfish_rtc.h | 45 +++++++ 7 files changed, 288 insertions(+) create mode 100644 hw/timer/goldfish_rtc.c create mode 100644 include/hw/timer/goldfish_rtc.h
This series adds RTC device to QEMU RISC-V virt machine. We have selected Goldfish RTC device model for this. It's a pretty simple synthetic device with few MMIO registers and no dependency external clock. The driver for Goldfish RTC is already available in Linux so we just need to enable it in Kconfig for RISCV and also update Linux defconfigs. We have tested this series with Linux-5.3 plus defconfig changes available in 'goldfish_rtc_v1' branch of: https://github.com/avpatel/linux.git Anup Patel (2): hw: timer: Add Goldfish RTC device riscv: virt: Use Goldfish RTC device hw/riscv/Kconfig | 1 + hw/riscv/virt.c | 15 +++ hw/timer/Kconfig | 3 + hw/timer/Makefile.objs | 1 + hw/timer/goldfish_rtc.c | 221 ++++++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 2 + include/hw/timer/goldfish_rtc.h | 45 +++++++ 7 files changed, 288 insertions(+) create mode 100644 hw/timer/goldfish_rtc.c create mode 100644 include/hw/timer/goldfish_rtc.h -- 2.17.1
On Tue, Sep 24, 2019 at 08:42:36AM +0000, Anup Patel wrote: > This series adds RTC device to QEMU RISC-V virt machine. We have > selected Goldfish RTC device model for this. It's a pretty simple > synthetic device with few MMIO registers and no dependency external > clock. The driver for Goldfish RTC is already available in Linux so > we just need to enable it in Kconfig for RISCV and also update Linux > defconfigs. > > We have tested this series with Linux-5.3 plus defconfig changes > available in 'goldfish_rtc_v1' branch of: > https://github.com/avpatel/linux.git Why was this device chosen instead of kvm-clock? Rich. > Anup Patel (2): > hw: timer: Add Goldfish RTC device > riscv: virt: Use Goldfish RTC device > > hw/riscv/Kconfig | 1 + > hw/riscv/virt.c | 15 +++ > hw/timer/Kconfig | 3 + > hw/timer/Makefile.objs | 1 + > hw/timer/goldfish_rtc.c | 221 ++++++++++++++++++++++++++++++++ > include/hw/riscv/virt.h | 2 + > include/hw/timer/goldfish_rtc.h | 45 +++++++ > 7 files changed, 288 insertions(+) > create mode 100644 hw/timer/goldfish_rtc.c > create mode 100644 include/hw/timer/goldfish_rtc.h > > -- > 2.17.1 -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
> -----Original Message----- > From: Richard W.M. Jones <rjones@redhat.com> > Sent: Friday, September 27, 2019 5:21 PM > To: Anup Patel <Anup.Patel@wdc.com> > Cc: Palmer Dabbelt <palmer@sifive.com>; Alistair Francis > <Alistair.Francis@wdc.com>; Sagar Karandikar <sagark@eecs.berkeley.edu>; > Bastian Koppelmann <kbastian@mail.uni-paderborn.de>; Atish Patra > <Atish.Patra@wdc.com>; qemu-riscv@nongnu.org; qemu- > devel@nongnu.org; Anup Patel <anup@brainfault.org> > Subject: Re: [PATCH 0/2] RTC support for QEMU RISC-V virt machine > > > On Tue, Sep 24, 2019 at 08:42:36AM +0000, Anup Patel wrote: > > This series adds RTC device to QEMU RISC-V virt machine. We have > > selected Goldfish RTC device model for this. It's a pretty simple > > synthetic device with few MMIO registers and no dependency external > > clock. The driver for Goldfish RTC is already available in Linux so we > > just need to enable it in Kconfig for RISCV and also update Linux > > defconfigs. > > > > We have tested this series with Linux-5.3 plus defconfig changes > > available in 'goldfish_rtc_v1' branch of: > > https://github.com/avpatel/linux.git > > Why was this device chosen instead of kvm-clock? We need a RTC device which worked fine in TCG mode (even without KVM). The KVMCLOCK is PTP clock which depends on KVM hypercalls. On ARM virt machine, we have PL031 so instead of that we have Goldfish RTC on RISC-V virt machine. Regards, Anup > > Rich. > > > Anup Patel (2): > > hw: timer: Add Goldfish RTC device > > riscv: virt: Use Goldfish RTC device > > > > hw/riscv/Kconfig | 1 + > > hw/riscv/virt.c | 15 +++ > > hw/timer/Kconfig | 3 + > > hw/timer/Makefile.objs | 1 + > > hw/timer/goldfish_rtc.c | 221 > ++++++++++++++++++++++++++++++++ > > include/hw/riscv/virt.h | 2 + > > include/hw/timer/goldfish_rtc.h | 45 +++++++ > > 7 files changed, 288 insertions(+) > > create mode 100644 hw/timer/goldfish_rtc.c create mode 100644 > > include/hw/timer/goldfish_rtc.h > > > > -- > > 2.17.1 > > -- > Richard Jones, Virtualization Group, Red Hat > http://people.redhat.com/~rjones Read my programming and virtualization > blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny > program with many powerful monitoring features, net stats, disk stats, > logging, etc. > http://people.redhat.com/~rjones/virt-top
On Fri, Sep 27, 2019 at 12:05:43PM +0000, Anup Patel wrote: > > > > -----Original Message----- > > From: Richard W.M. Jones <rjones@redhat.com> > > Sent: Friday, September 27, 2019 5:21 PM > > To: Anup Patel <Anup.Patel@wdc.com> > > Cc: Palmer Dabbelt <palmer@sifive.com>; Alistair Francis > > <Alistair.Francis@wdc.com>; Sagar Karandikar <sagark@eecs.berkeley.edu>; > > Bastian Koppelmann <kbastian@mail.uni-paderborn.de>; Atish Patra > > <Atish.Patra@wdc.com>; qemu-riscv@nongnu.org; qemu- > > devel@nongnu.org; Anup Patel <anup@brainfault.org> > > Subject: Re: [PATCH 0/2] RTC support for QEMU RISC-V virt machine > > > > > > On Tue, Sep 24, 2019 at 08:42:36AM +0000, Anup Patel wrote: > > > This series adds RTC device to QEMU RISC-V virt machine. We have > > > selected Goldfish RTC device model for this. It's a pretty simple > > > synthetic device with few MMIO registers and no dependency external > > > clock. The driver for Goldfish RTC is already available in Linux so we > > > just need to enable it in Kconfig for RISCV and also update Linux > > > defconfigs. > > > > > > We have tested this series with Linux-5.3 plus defconfig changes > > > available in 'goldfish_rtc_v1' branch of: > > > https://github.com/avpatel/linux.git > > > > Why was this device chosen instead of kvm-clock? > > We need a RTC device which worked fine in TCG mode (even without > KVM). The KVMCLOCK is PTP clock which depends on KVM hypercalls. > > On ARM virt machine, we have PL031 so instead of that we have > Goldfish RTC on RISC-V virt machine. Could we not make kvm-clock work on TCG (I wasn't aware that it needed actual KVM - I wonder how timekeeping works on TCG?) Alternately why not use PL031 here? The reason I'm asking this is because adding a new virtual device means we have to change this all the way up the stack (libvirt, virt-*) _and_ have special cases everywhere just for RISC-V. That's a load of extra work for everyone. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
> -----Original Message----- > From: Richard W.M. Jones <rjones@redhat.com> > Sent: Friday, September 27, 2019 6:01 PM > To: Anup Patel <Anup.Patel@wdc.com> > Cc: Palmer Dabbelt <palmer@sifive.com>; Alistair Francis > <Alistair.Francis@wdc.com>; Sagar Karandikar <sagark@eecs.berkeley.edu>; > Bastian Koppelmann <kbastian@mail.uni-paderborn.de>; Atish Patra > <Atish.Patra@wdc.com>; qemu-riscv@nongnu.org; qemu- > devel@nongnu.org; Anup Patel <anup@brainfault.org> > Subject: Re: [PATCH 0/2] RTC support for QEMU RISC-V virt machine > > On Fri, Sep 27, 2019 at 12:05:43PM +0000, Anup Patel wrote: > > > > > > > -----Original Message----- > > > From: Richard W.M. Jones <rjones@redhat.com> > > > Sent: Friday, September 27, 2019 5:21 PM > > > To: Anup Patel <Anup.Patel@wdc.com> > > > Cc: Palmer Dabbelt <palmer@sifive.com>; Alistair Francis > > > <Alistair.Francis@wdc.com>; Sagar Karandikar > > > <sagark@eecs.berkeley.edu>; Bastian Koppelmann > > > <kbastian@mail.uni-paderborn.de>; Atish Patra > <Atish.Patra@wdc.com>; > > > qemu-riscv@nongnu.org; qemu- devel@nongnu.org; Anup Patel > > > <anup@brainfault.org> > > > Subject: Re: [PATCH 0/2] RTC support for QEMU RISC-V virt machine > > > > > > > > > On Tue, Sep 24, 2019 at 08:42:36AM +0000, Anup Patel wrote: > > > > This series adds RTC device to QEMU RISC-V virt machine. We have > > > > selected Goldfish RTC device model for this. It's a pretty simple > > > > synthetic device with few MMIO registers and no dependency > > > > external clock. The driver for Goldfish RTC is already available > > > > in Linux so we just need to enable it in Kconfig for RISCV and > > > > also update Linux defconfigs. > > > > > > > > We have tested this series with Linux-5.3 plus defconfig changes > > > > available in 'goldfish_rtc_v1' branch of: > > > > https://github.com/avpatel/linux.git > > > > > > Why was this device chosen instead of kvm-clock? > > > > We need a RTC device which worked fine in TCG mode (even without > KVM). > > The KVMCLOCK is PTP clock which depends on KVM hypercalls. > > > > On ARM virt machine, we have PL031 so instead of that we have Goldfish > > RTC on RISC-V virt machine. > > Could we not make kvm-clock work on TCG (I wasn't aware that it needed > actual KVM - I wonder how timekeeping works on TCG?) > > Alternately why not use PL031 here? PL031 requires input clock. Of course, we can provide fake input clock (i.e. some random fixed clock) to make it work but it will be a HACK. Also, it will be really strange to hook an ARM device into RISC-V virt machine. On other hand, Goldfish para-virt devices are used across architectures x86, ARM and MIPS. > > The reason I'm asking this is because adding a new virtual device means we > have to change this all the way up the stack (libvirt, > virt-*) _and_ have special cases everywhere just for RISC-V. That's a load of > extra work for everyone. The RTC devices are pretty much transparent in usage. I am not sure why libvirt will require to know about type of RTC device. Regards, Anup
© 2016 - 2024 Red Hat, Inc.