[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/28] hw/char/goldfish: Use DMA memory API
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 19/28] hw/char/goldfish: Use DMA memory API |
Date: |
Tue, 23 Jul 2024 22:38:46 +0200 |
Rather than using address_space_rw(..., 0 or 1),
use the simpler DMA memory API which expand to
the same code. This allows removing a cast on
the 'buf' variable which is really const. Since
'buf' is only used in the CMD_READ_BUFFER case,
we can reduce its scope.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240723181850.46000-1-philmd@linaro.org>
---
hw/char/goldfish_tty.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/hw/char/goldfish_tty.c b/hw/char/goldfish_tty.c
index f8ff043c396..cdff46bc13b 100644
--- a/hw/char/goldfish_tty.c
+++ b/hw/char/goldfish_tty.c
@@ -16,6 +16,7 @@
#include "qemu/log.h"
#include "trace.h"
#include "exec/address-spaces.h"
+#include "sysemu/dma.h"
#include "hw/char/goldfish_tty.h"
#define GOLDFISH_TTY_VERSION 1
@@ -69,7 +70,6 @@ static uint64_t goldfish_tty_read(void *opaque, hwaddr addr,
static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd)
{
uint32_t to_copy;
- uint8_t *buf;
uint8_t data_out[GOLFISH_TTY_BUFFER_SIZE];
int len;
uint64_t ptr;
@@ -97,8 +97,8 @@ static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t
cmd)
while (len) {
to_copy = MIN(GOLFISH_TTY_BUFFER_SIZE, len);
- address_space_rw(&address_space_memory, ptr,
- MEMTXATTRS_UNSPECIFIED, data_out, to_copy, 0);
+ dma_memory_read_relaxed(&address_space_memory, ptr,
+ data_out, to_copy);
qemu_chr_fe_write_all(&s->chr, data_out, to_copy);
len -= to_copy;
@@ -109,9 +109,9 @@ static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t
cmd)
len = s->data_len;
ptr = s->data_ptr;
while (len && !fifo8_is_empty(&s->rx_fifo)) {
- buf = (uint8_t *)fifo8_pop_buf(&s->rx_fifo, len, &to_copy);
- address_space_rw(&address_space_memory, ptr,
- MEMTXATTRS_UNSPECIFIED, buf, to_copy, 1);
+ const uint8_t *buf = fifo8_pop_buf(&s->rx_fifo, len, &to_copy);
+
+ dma_memory_write_relaxed(&address_space_memory, ptr, buf, to_copy);
len -= to_copy;
ptr += to_copy;
--
2.41.0
- [PULL 08/28] docs/interop/firmware.json: add new enum FirmwareArchitecture, (continued)
- [PULL 08/28] docs/interop/firmware.json: add new enum FirmwareArchitecture, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 09/28] docs/interop/firmware.json: convert "Example" section, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 10/28] hw/i2c/mpc_i2c: Fix mmio region size, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 11/28] hw/mips/loongson3_virt: remove useless type cast, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 12/28] util/range: Make ranges_overlap() return bool, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 15/28] system/memory_mapping: make range overlap check more readable, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 14/28] sparc/ldst_helper: make range overlap check more readable, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 13/28] cxl/mailbox: make range overlap check more readable, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 16/28] crypto/block-luks: make range overlap check more readable, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 18/28] hw/nubus/virtio-mmio: Fix missing ERRP_GUARD() in realize handler, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 19/28] hw/char/goldfish: Use DMA memory API,
Philippe Mathieu-Daudé <=
- [PULL 17/28] dump: make range overlap check more readable, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 20/28] chardev/char-fe: Document returned value on error, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 21/28] util/fifo8: Fix style, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 22/28] util/fifo8: Use fifo8_reset() in fifo8_create(), Philippe Mathieu-Daudé, 2024/07/23
- [PULL 23/28] util/fifo8: Rename fifo8_peek_buf() -> fifo8_peek_bufptr(), Philippe Mathieu-Daudé, 2024/07/23
- [PULL 24/28] util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_bufptr(), Philippe Mathieu-Daudé, 2024/07/23
- [PULL 25/28] util/fifo8: Expose fifo8_pop_buf(), Philippe Mathieu-Daudé, 2024/07/23
- [PULL 27/28] MAINTAINERS: Cover guest-agent in QAPI schema, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 28/28] MAINTAINERS: Add myself as a reviewer of machine core, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 26/28] util/fifo8: Introduce fifo8_drop(), Philippe Mathieu-Daudé, 2024/07/23