U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hung-Chun Tseng <alan.tseng.cs@gmail.com>
To: u-boot@lists.u-boot-project.org
Cc: bmeng.cn@gmail.com, trini@konsulko.com, visitorckw@gmail.com,
	sjg@chromium.org, xypron.glpk@gmx.de
Subject: [PATCH v6 0/6] virtio: Add a virtio RTC driver
Date: Mon,  2 Nov 2026 11:04:36 +0800	[thread overview]
Message-ID: <cover.1793588058.git.alan.tseng.cs@gmail.com> (raw)

QEMU v11.1.0 added a virtio RTC device (virtio-rtc-pci and
virtio-rtc-device), but U-Boot has no driver for it. This series adds
one, so that "date" and anything else using dm_rtc_get() work on any
virtio-capable QEMU target.

Patch 1 adds the driver, patch 2 updates the virtio documentation and
patch 3 adds a MAINTAINERS entry. Patch 4 lets sandbox tests answer
virtqueue requests as the device would, which patch 5 uses to test the
driver. Patch 6 documents how to reach the virtio RTC.

Changes in v6:
- Add patch 6, the documentation follow-up Simon suggested on v5, which
  I first sent on its own. Following Simon's review of it, the virtio
  RTC now has its own section, which also takes the QEMU version note
  from patch 2, and x86 is described like ARM and RISC-V: with DM_RTC
  enabled, the MC146818 CMOS RTC gets sequence 0. The Status section
  already lists the RTC since patch 2.
- Rebase onto main. Patches 1-5 are otherwise unchanged.

Tested with qemu-riscv64_smode_defconfig and RTC_GOLDFISH disabled, on
QEMU v11.1.2, which reports a UTC clock, and on QEMU master, which
reports a smeared UTC clock:

- With -device virtio-rtc-pci and with -device virtio-rtc-device,
  "date" reads the host time and advances between reads.
- Setting the time fails, as the clocks are read-only.
- With no virtio RTC device, "date" fails cleanly with err=-19.

With qemu-x86_64_defconfig plus DM_RTC on QEMU v11.1.2, "dm uclass rtc"
shows the CMOS RTC at sequence 0 and the virtio RTC at 1; with
RTC_MC146818 disabled, the virtio RTC is sequence 0 and "date" reads it.

On sandbox, "ut dm virtio_rtc*" passes.

Hung-Chun Tseng (6):
  virtio: rtc: Add virtio RTC driver
  doc: virtio: List the supported device types
  MAINTAINERS: Add entry for virtio RTC
  virtio: sandbox: Let tests emulate the device side of a virtqueue
  test: dm: Add tests for the virtio RTC driver
  doc: virtio: Explain how to reach the virtio RTC

 MAINTAINERS                         |   6 +
 arch/sandbox/dts/test.dts           |   5 +
 arch/sandbox/include/asm/test.h     |  25 +++
 doc/develop/driver-model/virtio.rst |  26 ++-
 drivers/virtio/Kconfig              |  11 +
 drivers/virtio/Makefile             |   1 +
 drivers/virtio/virtio-uclass.c      |   1 +
 drivers/virtio/virtio_rtc.c         | 244 ++++++++++++++++++++++
 drivers/virtio/virtio_sandbox.c     |  15 ++
 include/virtio.h                    |   4 +-
 test/dm/Makefile                    |   1 +
 test/dm/virtio_rtc.c                | 306 ++++++++++++++++++++++++++++
 12 files changed, 640 insertions(+), 5 deletions(-)
 create mode 100644 drivers/virtio/virtio_rtc.c
 create mode 100644 test/dm/virtio_rtc.c

-- 
2.43.0


             reply	other threads:[~2026-11-02  3:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02  3:04 Hung-Chun Tseng [this message]
2026-11-02  3:04 ` [PATCH v6 1/6] virtio: rtc: Add virtio RTC driver Hung-Chun Tseng
2026-11-02  3:04 ` [PATCH v6 2/6] doc: virtio: List the supported device types Hung-Chun Tseng
2026-11-02  3:04 ` [PATCH v6 3/6] MAINTAINERS: Add entry for virtio RTC Hung-Chun Tseng
2026-11-02  3:04 ` [PATCH v6 4/6] virtio: sandbox: Let tests emulate the device side of a virtqueue Hung-Chun Tseng
2026-11-02  3:04 ` [PATCH v6 5/6] test: dm: Add tests for the virtio RTC driver Hung-Chun Tseng
2026-11-02  3:04 ` [PATCH v6 6/6] doc: virtio: Explain how to reach the virtio RTC Hung-Chun Tseng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1793588058.git.alan.tseng.cs@gmail.com \
    --to=alan.tseng.cs@gmail.com \
    --cc=bmeng.cn@gmail.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=visitorckw@gmail.com \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox