From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
qemu-arm@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v7 3/7] hw/char/pl011: Factor pl011_xmit_cb() out as GSource
Date: Mon, 10 Mar 2025 02:28:21 +0100 [thread overview]
Message-ID: <20250310012825.79614-4-philmd@linaro.org> (raw)
In-Reply-To: <20250310012825.79614-1-philmd@linaro.org>
Implement pl011_xmit_cb() using the FEWatchFunc prototype
to register it as GSource. While the return value is not
yet used, we return G_SOURCE_REMOVE, meaning the GSource is
removed from the main loop (because we only send one char).
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/char/pl011.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
index 113b29cd9e6..18ea03a52f4 100644
--- a/hw/char/pl011.c
+++ b/hw/char/pl011.c
@@ -226,8 +226,9 @@ static void pl011_loopback_tx(PL011State *s, uint32_t value)
pl011_fifo_rx_put(s, value);
}
-static void pl011_xmit(PL011State *s)
+static gboolean pl011_xmit_cb(void *do_not_use, GIOCondition cond, void *opaque)
{
+ PL011State *s = opaque;
int bytes_consumed;
uint8_t buf[PL011_FIFO_DEPTH];
uint32_t count;
@@ -254,6 +255,13 @@ static void pl011_xmit(PL011State *s)
}
pl011_update(s);
+
+ return G_SOURCE_REMOVE;
+}
+
+static void pl011_xmit(PL011State *s)
+{
+ (void)pl011_xmit_cb(NULL, G_IO_OUT, s);
}
static void pl011_write_txdata(PL011State *s, uint8_t data)
@@ -630,6 +638,11 @@ static int pl011_post_load(void *opaque, int version_id)
s->read_pos = 0;
}
+ if (!fifo8_is_empty(&s->xmit_fifo)) {
+ /* Reschedule another transmission */
+ qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP, pl011_xmit_cb, s);
+ }
+
s->ibrd &= IBRD_MASK;
s->fbrd &= FBRD_MASK;
--
2.47.1
next prev parent reply other threads:[~2025-03-10 1:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-10 1:28 [PATCH v7 0/7] hw/char/pl011: Implement TX (async) FIFO to avoid blocking the main loop Philippe Mathieu-Daudé
2025-03-10 1:28 ` [PATCH v7 1/7] hw/char/pl011: Add transmit FIFO to PL011State Philippe Mathieu-Daudé
2025-03-10 1:28 ` [PATCH v7 2/7] hw/char/pl011: Introduce pl011_xmit() Philippe Mathieu-Daudé
2025-03-10 1:28 ` Philippe Mathieu-Daudé [this message]
2025-03-10 1:28 ` [PATCH v7 4/7] hw/char/pl011: Trace FIFO enablement Philippe Mathieu-Daudé
2025-03-10 1:28 ` [PATCH v7 5/7] hw/char/pl011: Consider TX FIFO overrun error Philippe Mathieu-Daudé
2025-03-10 1:28 ` [PATCH v7 6/7] hw/char/pl011: Drain TX FIFO when no backend connected Philippe Mathieu-Daudé
2025-03-10 1:28 ` [PATCH v7 7/7] hw/char/pl011: Implement TX FIFO Philippe Mathieu-Daudé
2025-03-10 14:42 ` [PATCH v7 0/7] hw/char/pl011: Implement TX (async) FIFO to avoid blocking the main loop Peter Maydell
2025-03-10 17:28 ` Peter Maydell
2025-03-11 10:33 ` Philippe Mathieu-Daudé
2025-03-11 18:36 ` Peter Maydell
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=20250310012825.79614-4-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=marcandre.lureau@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--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).