From patchwork Mon Mar 10 01:28:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 872169 Delivered-To: patch@linaro.org Received: by 2002:a5d:64ce:0:b0:38f:210b:807b with SMTP id f14csp764443wri; Sun, 9 Mar 2025 18:29:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWbMjD2tvwAEdqvrGtsnXcWTPmtXo7UpvRGrbws8VpSKxpuxnN5Rqe44qYYsG6qneQNE7dCnQ==@linaro.org X-Google-Smtp-Source: AGHT+IEK3M6G5Ac7YGIwNvCdy5M6fBHDfTTP5X3wIOUHQiyf1Za4P69DNJZ+t65C7W/qwNQMjJHB X-Received: by 2002:a05:620a:2722:b0:7c3:ded7:6330 with SMTP id af79cd13be357-7c4e167d6ecmr1714227685a.13.1741570193971; Sun, 09 Mar 2025 18:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1741570193; cv=none; d=google.com; s=arc-20240605; b=jbBc4r85pTt0cD6L7gELv2SJmWhIff8469BvrlW9fczwb9lu/fJJCgxPBTATWeXKji 7fdInYaUEp674zlnk6HhPGBX9WkIjuI0E0gWr1Y5JuVpdESSLOM5B+Y6UmgcC/CvwiaU PMCWf7khSNx9uGcmW8hygCAQfh50BtWu6ddfZRhofjdO0CpW8bkAC9WdtVkD0OddexqV CwGnIbOldndkXgUkY+hwEo1t/GoD6c22njrCCJQk00OSWR+AoYFmMIVObX6IVtsdKFXC tsrlcIx35+HG8j0gau0AKyjPXDQJZB+5/6mPzKlhISsTx/im3uENwcuYGFoVUk48SyS2 t7Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8ce/6NRq1JPvdEj2O0uStpJg+L6PTsOBLcGGWbCWAug=; fh=EPO+XMDoylG26O8AfLK4l02IrH8PqYL7jb8PVK09dDA=; b=M/h/AIMewFSgtlm2h0w5GiIigoUfNaGDq5WuuMbz5QfMeNpvrw0CTl0Aquk32gA7Dz 7LBT7oReDgfJ22EAco0fvk9SOgAkRAiGEbbJOdf3KFvbNY68JM+kCPXTgyIDU2pLKpWT aA4aGnc9MCDBoPGbT3D9c+cDIGn3aUUDrzkwXEUGa4aRb4JvfoJFUDyP+ppR/R4v9DgZ DdB+gAMyn2CaRILy/6ylJy0AXiplRxr0VApJdR0i1dvPA8AC6e7/5i+hNqy9YVuv2TAS HIpaSGsZIHHNux7igSfppVA1bcrZ4lATAUHvnE6HKGLWqEGzOtBtwEIJxbIzYXnl0T3j tRMQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tNUvdt5l; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c54bab875csi205393885a.529.2025.03.09.18.29.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Mar 2025 18:29:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tNUvdt5l; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1trRwv-00044M-4p; Sun, 09 Mar 2025 21:28:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1trRwo-0003zG-3r for qemu-devel@nongnu.org; Sun, 09 Mar 2025 21:28:51 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1trRwl-0006RU-Dc for qemu-devel@nongnu.org; Sun, 09 Mar 2025 21:28:48 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-388cae9eb9fso1712421f8f.3 for ; Sun, 09 Mar 2025 18:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741570125; x=1742174925; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8ce/6NRq1JPvdEj2O0uStpJg+L6PTsOBLcGGWbCWAug=; b=tNUvdt5lwIZGxaZT9eXnOYNuO8PtEA+6+48BJaTtk7ziAx0FOlKCNsbqrOEEA+UJMg hAAkHiLAecUrtAmXWCQKdHI+HaP5Td0BwgEaJGSwe1nZG2ZYqnjSVrSb29CC0uVVHSUC tvDeqkcKnij1vYaHTr/ItqY62feMTj42Mt003imwgHzUnTN2oELnZ+JjOfI6FEdn1/Xe yURZsLH04i/xqW4SXqS6z6fqc9/gQd7pz6Fm6LIJhMtJW3uZsHVrZ519KwKed/F1neIP rQsotQ/9K+FV03Ves7JuFzaw4bxtHKu2OKrNO7boMeeE9xfjFx5vmqujXePsnO8gsCXY QoVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741570125; x=1742174925; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8ce/6NRq1JPvdEj2O0uStpJg+L6PTsOBLcGGWbCWAug=; b=MTS76wW3I7Eb49ubDrA3lbv/gYyvGzgplowM8AxM+1m4YcKOtwJmgCynTDARTwTnIq JNsVN6z5vxy+CUmVw0XLW1OGt+3kxTSqVxDOfGmnO3DQ6OBryKLVSrw6JVd+K1xOIzSv CwtJuX9I9vl6DZle/8XMUUSQ/gkI9iWp4rHNGMYINqmfITqbzz5/vJPYOrNevJPVGQ/h xsOyNTRBCvTL0QyDWEz8yTQBfURh5c9EyGoR23ditGLgYZ49thI3oMeeedzh7QHLto1Q z55FFFh+6qNYQKWezQsmt3MTOMaHWqgXsp6lUdg8VAgT1iApNkwNU4X/2DBiyX7dbeX4 47uA== X-Gm-Message-State: AOJu0YxWCau8LD1/m5NZnoZHCoRk+QBwTG6F8DIi/w+R983NdtxVF1/0 8udxY60yFi5TlUWOKBT+oZhGbxZsXM81mlpQch2nQx0UGqRNXqPGiy7YlJAqdUtB7CXoToJnrGX nHTw= X-Gm-Gg: ASbGnctno87cxd1mJ+pCVZg0DDqEN8mDBt5DzEQcF3nHuP4mg/Ek44Nkn16tGGhLyfR dIU4FH/xTVrQXLmKHTZhA4YCMxubKLGE0aYzp9s+O6lL7kkzXfcX3Bhqp+J1kAlkTD5rRQ/ewCj MQ6jzfL6CqhRdIELjfugMxcJnXt4Opjp1fA3rwrHkCuexbSh+2jPD7rSfzFVWrYFuiaTlcy8UFg XAumUBp19LXDJODHLq9+yUr7FC9K5YqbN/Y3SH+tW0OJO95KckmQDmPQnradElWZR3Sjg+zDLte BjpThjaPShIGqZGpNOoGNLCQatpsI5BJFsfuoU15v0LgyJDZvsbxzMExPpIrrg0U56q6T8gcS5b d8838Kw8Z1tbebzpWPZuwRLYGdT5fwA== X-Received: by 2002:a05:6000:410a:b0:391:4559:8761 with SMTP id ffacd0b85a97d-39145598929mr1319845f8f.36.1741570125026; Sun, 09 Mar 2025 18:28:45 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912bfba83csm13154773f8f.6.2025.03.09.18.28.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 09 Mar 2025 18:28:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?q?Marc-Andr=C3=A9_Lure?= =?utf-8?q?au?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Mark Cave-Ayland , qemu-arm@nongnu.org, Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v7 3/7] hw/char/pl011: Factor pl011_xmit_cb() out as GSource Date: Mon, 10 Mar 2025 02:28:21 +0100 Message-ID: <20250310012825.79614-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250310012825.79614-1-philmd@linaro.org> References: <20250310012825.79614-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.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 Signed-off-by: Philippe Mathieu-Daudé --- 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;