From patchwork Fri Jul 19 18:10:29 2024 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: 813404 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp877276wro; Fri, 19 Jul 2024 11:12:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUbzS/SO9H5m8WOLTVnWsEr/paGvmGpnNHMUob9YB6aXyalSAMxfpVMbpQMuoiMqJczmyupulUeRCRX3oJosWIb X-Google-Smtp-Source: AGHT+IEM5YTJWbLIs9IeZJUcyMpvL4O4KWkBqRnU3F5neynNBmQfCZyXKWPXucFKqH1Zft6LoN93 X-Received: by 2002:a05:620a:2901:b0:79d:6bba:4a66 with SMTP id af79cd13be357-7a187503d4amr1130505685a.66.1721412724939; Fri, 19 Jul 2024 11:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412724; cv=none; d=google.com; s=arc-20160816; b=eD9kwIJ+hWExhxgjv5byQkn5m4Xd0LAP1WD+rN14Zxsd0QS2kyU2bEUpIgWjoFn64v 5/8iaSG+dj/oWjhkTg8gvteJAOjCVs6C6KgzZUECPaFwIbAnhIQTlsWQE/61kj0pA1CC LvqGuLuZAeDfGctAd9cXj3/lyo02YED3008D6HG7yZ+j/e3UQNNGEMhI9YLFYRuMC6V0 bYJNbUgY/ROfA2865u6I14mAfUdMmqqpVmp5qMjHcSLMrNyr4RsWex6KIS4IwWQkmLBW GTewer3vdWnm8VghaOeNhTCRWyHYmPs/V9BZGhTbMCYtx4q0nPXiwCo+Qt6CrYm0jFV8 BdDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=HKEyUF5vAQXhfPoZ9bEoVMEJKlfitjNK1zaxUdDv/iQ=; fh=a4LTsj9O+qaKvI8P1KF8P/8hcdvsQ8EHyfSuvL3yAcM=; b=M+PbM3WPlJQmnt1h1SXBkujdSlhdIKOrABFzDBM42HnU/sF4aSlybTGDumdzCtPwl5 szoFIsylU9W7mb0GJdPdZyXB69WkUOhQor/WsLUNWOebHUcZOnsyH/tQ9kR0dFh4oqh7 XabK0WI0Km63OdcBD1vjkBQBKBOf6Uq1XrW8WHi0r4D2TX/6kUtKQzWgpF+xhCP8nJnQ PmC2i8bxc2Oi8N2cmxzXfWRJKFizjU5DSDIvteYtADO4W5OTPbSc6tRS/T3CS9lz2y2C 65OaOy7fA8GDCS0HD2x6nrWorbLiSQuZ+OoTUaaUBdQkaUUrkIoNdfvKyhAju15WDr/Z JkmA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K+xj+DNn; 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-7a19904b351si219781785a.381.2024.07.19.11.12.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:12:04 -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=K+xj+DNn; 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 1sUs4n-0002bu-P1; Fri, 19 Jul 2024 14:11:30 -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 1sUs4b-0002GE-WB for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:18 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUs4Y-0003nu-DQ for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:17 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4266eda81c5so16418445e9.0 for ; Fri, 19 Jul 2024 11:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412669; x=1722017469; 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=HKEyUF5vAQXhfPoZ9bEoVMEJKlfitjNK1zaxUdDv/iQ=; b=K+xj+DNn+cLdbOJg2lsW1RNdGSbc2+LzGrWNlsg+GVp3iTOknM7bX3ktPnQ/oadrdI vpMhCfL9tpyETxVcsEpjm94mPO6fnLfPguYYf4Nw5FL1XRrw4+7Sy25oh/5L3csN0JKj p/r7UYS/ZKtt7n9NyGlafq815UviiokuLJhoEGks0Q8pifEAXz0ZU0vHAJn/VkkOQpXb wozv0c4ZXB3hUyHSC30hzSzDiE7K2wkeYo5IhpNCygwwtSacwpWmbU1UYTnnQy8i81ks PnG0UaKqqd5ovW5hBpOicppQut2NRsmlBvq6fAOmQc2JeeczIVru2z6T0An2s/HEKnur UK0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412669; x=1722017469; 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=HKEyUF5vAQXhfPoZ9bEoVMEJKlfitjNK1zaxUdDv/iQ=; b=YR8h+ElBJraR/Dq4wnRbBCMUAESw5zlnjn2yI0hzMgIy0vTymccNbn9MOAoKSc/CWo Wwk2hdV7UwyTC+TgBrbvTQ6YYasezD+ERklHoHzbROiagaXUfIUhK17t7idL72dH1W1B qu4e2OHs5jOWzn0UBKBXupQJhdn9XRd1Kl1W3J/pgk770dmF8fAWR1A0TtG+gZDgN1CK fpceKoNmhbnlatKP+6inR1sxHCkoRFS7Srqp8UXDZ2Zy9OYKPz9kGqV1qHLBcA9fjyXM qmP1nOSyrpDMZaGkvtwy5CuD3AF+zCdpBxOF/fRQ3Awr6IfPziB4V+zgiQnmWLKNIbbU Z0qA== X-Gm-Message-State: AOJu0YzQgNpXKS6uuymPX6XnURSCemhlrEgybzI1LLtR5FLMD/yQkk3u 8mbMuzUs1Wfnbc77jdRXtEQMXrw8KCOCI3Lxtu24h4bB/jkn+FdArMQRHCUCkFTUCGcP4VkEvgJ 9 X-Received: by 2002:a05:600c:3b8f:b0:426:5520:b835 with SMTP id 5b1f17b1804b1-427c2cacf1emr61880365e9.5.1721412668901; Fri, 19 Jul 2024 11:11:08 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d7263687sm29524065e9.4.2024.07.19.11.11.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:11:08 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 04/16] hw/char/pl011: Move pl011_loopback_enabled|tx() around Date: Fri, 19 Jul 2024 20:10:29 +0200 Message-ID: <20240719181041.49545-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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 We'll soon use pl011_loopback_enabled() and pl011_loopback_tx() from functions defined before their declarations. In order to avoid forward-declaring them, move them around. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- hw/char/pl011.c | 66 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index edb5395fb8..22195ead7b 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -138,6 +138,11 @@ static void pl011_update(PL011State *s) } } +static bool pl011_loopback_enabled(PL011State *s) +{ + return !!(s->cr & CR_LBE); +} + static bool pl011_is_fifo_enabled(PL011State *s) { return (s->lcr & LCR_FEN) != 0; @@ -181,6 +186,34 @@ static void pl011_put_fifo(void *opaque, uint32_t value) } } +static void pl011_loopback_tx(PL011State *s, uint32_t value) +{ + if (!pl011_loopback_enabled(s)) { + return; + } + + /* + * Caveat: + * + * In real hardware, TX loopback happens at the serial-bit level + * and then reassembled by the RX logics back into bytes and placed + * into the RX fifo. That is, loopback happens after TX fifo. + * + * Because the real hardware TX fifo is time-drained at the frame + * rate governed by the configured serial format, some loopback + * bytes in TX fifo may still be able to get into the RX fifo + * that could be full at times while being drained at software + * pace. + * + * In such scenario, the RX draining pace is the major factor + * deciding which loopback bytes get into the RX fifo, unless + * hardware flow-control is enabled. + * + * For simplicity, the above described is not emulated. + */ + pl011_put_fifo(s, value); +} + static uint64_t pl011_read(void *opaque, hwaddr offset, unsigned size) { @@ -290,11 +323,6 @@ static void pl011_trace_baudrate_change(const PL011State *s) s->ibrd, s->fbrd); } -static bool pl011_loopback_enabled(PL011State *s) -{ - return !!(s->cr & CR_LBE); -} - static void pl011_loopback_mdmctrl(PL011State *s) { uint32_t cr, fr, il; @@ -336,34 +364,6 @@ static void pl011_loopback_mdmctrl(PL011State *s) pl011_update(s); } -static void pl011_loopback_tx(PL011State *s, uint32_t value) -{ - if (!pl011_loopback_enabled(s)) { - return; - } - - /* - * Caveat: - * - * In real hardware, TX loopback happens at the serial-bit level - * and then reassembled by the RX logics back into bytes and placed - * into the RX fifo. That is, loopback happens after TX fifo. - * - * Because the real hardware TX fifo is time-drained at the frame - * rate governed by the configured serial format, some loopback - * bytes in TX fifo may still be able to get into the RX fifo - * that could be full at times while being drained at software - * pace. - * - * In such scenario, the RX draining pace is the major factor - * deciding which loopback bytes get into the RX fifo, unless - * hardware flow-control is enabled. - * - * For simplicity, the above described is not emulated. - */ - pl011_put_fifo(s, value); -} - static void pl011_loopback_break(PL011State *s, int brk_enable) { if (brk_enable) {