diff options
author | Gabriel L. Somlo <somlo@cmu.edu> | 2015-11-05 09:32:48 -0500 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2015-12-15 11:45:59 +0100 |
commit | 3bef7e8aab8af2f86c5785761c37e068428c689d (patch) | |
tree | 0bb7dadd51c237b9651c891ce85b605a51f746e5 /include/hw/nvram | |
parent | 9c4a5c55f5c6c63c24c29e5a3b57ddbc1e550303 (diff) |
fw_cfg: amend callback behavior spec to once per select
Currently, the fw_cfg internal API specifies that if an item was set up
with a read callback, the callback must be run each time a byte is read
from the item. This behavior is both wasteful (most items do not have a
read callback set), and impractical for bulk transfers (e.g., DMA read).
At the time of this writing, the only items configured with a callback
are "/etc/table-loader", "/etc/acpi/tables", and "/etc/acpi/rsdp". They
all share the same callback functions: virt_acpi_build_update() on ARM
(in hw/arm/virt-acpi-build.c), and acpi_build_update() on i386 (in
hw/i386/acpi.c). Both of these callbacks are one-shot (i.e. they return
without doing anything at all after the first time they are invoked with
a given build_state; since build_state is also shared across all three
items mentioned above, the callback only ever runs *once*, the first
time either of the listed items is read).
This patch amends the specification for fw_cfg_add_file_callback() to
state that any available read callback will only be invoked once each
time the item is selected. This change has no practical effect on the
current behavior of QEMU, and it enables us to significantly optimize
the behavior of fw_cfg reads during guest firmware setup, eliminating
a large amount of redundant callback checks and invocations.
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Marc MarĂ <markmb@redhat.com>
Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-id: 1446733972-1602-3-git-send-email-somlo@cmu.edu
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'include/hw/nvram')
-rw-r--r-- | include/hw/nvram/fw_cfg.h | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index 4b5e196d17..a1cfaa4a2f 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -183,13 +183,9 @@ void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data, * structure residing at key value FW_CFG_FILE_DIR, containing the item name, * data size, and assigned selector key value. * Additionally, set a callback function (and argument) to be called each - * time a byte is read by the guest from this particular item, or, in the - * case of DMA, each time a read or skip request overlaps with the valid - * offset range of the item. - * NOTE: In addition to the opaque argument set here, the callback function - * takes the current data offset as an additional argument, allowing it the - * option of only acting upon specific offset values (e.g., 0, before the - * first data byte of the selected item is returned to the guest). + * time this item is selected (by having its selector key either written to + * the fw_cfg control register, or passed to QEMU in FWCfgDmaAccess.control + * with FW_CFG_DMA_CTL_SELECT). */ void fw_cfg_add_file_callback(FWCfgState *s, const char *filename, FWCfgReadCallback callback, void *callback_opaque, |