qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Damien Hedde <damien.hedde@greensocs.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: hw/clock: What clock rate for virt machines?
Date: Wed, 2 Sep 2020 17:49:09 +0100	[thread overview]
Message-ID: <CAFEAcA8mwjWP-KhJ5bp_Qo_h81Mt_yn8k_5oepgMas9COBQgWQ@mail.gmail.com> (raw)
In-Reply-To: <bbdacc80-a321-5f06-e430-973a38e7e037@amsat.org>

On Wed, 2 Sep 2020 at 17:35, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> Peter said "'clock' is basically meaningless for virt machines",
>
> I understand and agree. But how to make that explicit/obvious in
> the code, when a device expects a clock frequency/period?

When a particular *device* needs a clock, then presumably
it has a defined purpose for it, and we can pick a
frequency for it then.

> See for example hw/riscv/virt.c, it uses the following (confusing
> to me) in virt_machine_init():
>
>    serial_mm_init(system_memory, memmap[VIRT_UART0].base,
>        0, qdev_get_gpio_in(DEVICE(mmio_plic), UART0_IRQ), 399193,
>        serial_hd(0), DEVICE_LITTLE_ENDIAN);

In this case, the board has a model of a 16550A UART on it,
which uses its input clock to determine what the actual baud
rate is for particular guest settings of the divisor registers.
So we need to look at:
 * what does guest software expect the frequency to be?
 * what is a "good" frequency which gives the guest the best
   possible choices of baud rate?
and also at whether we need to tell the guest the frequency
via a device tree or other mechanism.

In some devices the input clock genuinely doesn't affect the
guest-visible behaviour, in which case we can pick an arbitrary
or conventional value, or just implement the device to work OK
without a clock connected.

Note also that we don't have to make a single decision for the
whole board -- we can run different devices with different clocks
if that makes sense.

Incidentally the serial.c API seems to be slightly confused
about the difference between setting the baudbase as a value
in bps (ie the traditional 9600, 115200, etc values) or a
frequency (where 115200 bps corresponds to a 1.8432MHz clock,
apparently). Luckily nobody uses the serial_set_frequency()
function :-)

thanks
-- PMM


  reply	other threads:[~2020-09-02 16:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-02 16:35 hw/clock: What clock rate for virt machines? Philippe Mathieu-Daudé
2020-09-02 16:49 ` Peter Maydell [this message]
2020-09-02 17:03   ` Philippe Mathieu-Daudé
2020-09-02 17:09     ` Philippe Mathieu-Daudé
2020-09-02 18:18     ` Peter Maydell
2020-09-02 19:40       ` Philippe Mathieu-Daudé
2020-09-04 17:52         ` Alistair Francis
2020-09-05  1:47           ` Palmer Dabbelt

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=CAFEAcA8mwjWP-KhJ5bp_Qo_h81Mt_yn8k_5oepgMas9COBQgWQ@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=damien.hedde@greensocs.com \
    --cc=f4bug@amsat.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).