From patchwork Mon Jul 10 17:50:56 2023 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: 701049 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5305457wrs; Mon, 10 Jul 2023 10:54:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlE00ZRLiL2zIJZOTCH2+g2SmWNYJPrlfJOmPfIoArOoVJhODzAXo0bKb2KxAhtG6sac+huS X-Received: by 2002:ac8:5907:0:b0:403:929f:12e2 with SMTP id 7-20020ac85907000000b00403929f12e2mr13646141qty.49.1689011655819; Mon, 10 Jul 2023 10:54:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689011655; cv=none; d=google.com; s=arc-20160816; b=CRDvMWvIJILqIJXNPD6WeJvJBLM56Dr8XoP42Y70Y4NUJ2O9rYnpFqQhAYMCxt+1Ln JtjeEyHlzFEoEVQmHkVgeqKx+yyQgOiaULvNYo+FhFApo/FZQvlCsY1RXncWuhSgE9ts 6h8Ye2z/cpxj2+urb5EbfkhB41tBp9+QwMVWDHVBUR18DFoOIerNXUXmsuEOydseFbJ8 O9YYAvq5vf6Eifj2yXSHfjnQqWZ3l8/SlR7oBehq57P/9F44xflXw2dfmgHys2rBY7pF iM/vLidrMbNzUMPvaNWh8ttceYfS7cFF5FqYZ+IyxmZq9ISHH1VQx/Si17cwgPOZIYSZ gLTA== 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=vINMBBFp0tNBmc0jxCNSawkrMv3zFmYswmW1JkHmuF4=; fh=4TWVGTMFk+XB48cTX7H3L2FEUZf3X6lSQ5h15kr1III=; b=YJk5aBUsm2oJPrqFpV2ReV4j8f5HhKrojeXnwKS/ExSJ2g8dk9mYvri33gbhNidPWx lIZda+Qf6X7wS+ohQ5hkFyefgfLQ21eVMQ5BF2YIm5z05zU/WSEvCRMiOe7LY+avRFPy IVUJbkuaSrIqEUyscqVDumAEoiOB+gtB97dohsMojez86oKMWkli7e3NPhwX12isceBy W+/6554dtFHkub3jKhxeB4riEBRwFrRjrCz8VYghrxKxpRdhRTVN5SLuLxzaMyRgI+6z 0QKrcmwBDqDrTFXitWbvYmFW7Bw2Fw2x+oKCZpC363/wp973FFntlndF5C8zgaWlWQTD fu3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jn7tXF0V; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v19-20020a05622a015300b004033c97b521si114092qtw.639.2023.07.10.10.54.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 10:54:15 -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=jn7tXF0V; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIv31-00016C-O7; Mon, 10 Jul 2023 13:51:43 -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 1qIv2z-00015Q-LC for qemu-devel@nongnu.org; Mon, 10 Jul 2023 13:51:41 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIv2w-0000OO-Te for qemu-devel@nongnu.org; Mon, 10 Jul 2023 13:51:41 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3090d3e9c92so5645048f8f.2 for ; Mon, 10 Jul 2023 10:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689011494; x=1691603494; 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=vINMBBFp0tNBmc0jxCNSawkrMv3zFmYswmW1JkHmuF4=; b=jn7tXF0Vb0kI9zsoLl9pbMSgyVMTyYig7Y7CT3MRnsBjQTEb/vS3dk7yZAseCFEMCk 6HeReqKI82E32hJ9ZZhOEoVtrMYY+bVlDHWa1XJsCuY2rmP388jPFHHBdtF9lN26/UU6 QcE16m6QH0l42CQgMTI8mgBeTOhXdyBBxNRU1bYSAkXlEpRRa6tgj9DVzgMnkepE6re4 KAv1z49zOkq6eJib3YdFIHV3RtSLZa+UFcXQ3WqhD5mjSv5EFEhTcy/T4txY9xJjRWON ozhEaklkTE6GFj0ozcd2bHIHB7qa2oGjGLuFCPrBfMHi8L1Ns6Ue5M66BnJ4X3B56R6h vVXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689011494; x=1691603494; 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=vINMBBFp0tNBmc0jxCNSawkrMv3zFmYswmW1JkHmuF4=; b=IcqCKqgJEXJ8abHARYuf3e2q2Ah91tSSfIrXFfn6YIeyn0/LFHLp9W3ydoynqUbiti oi0w9EgRRCKbx6edgRmhVJ2IMOHtG59yEgt9yP/BdOT7TjRjI+5sAtJAir9R9JJSbNmf eGTZvBCt0kF2Z2h9IxGcMd4fWH32hUfeoFn3ty6tPU5Lh9oClSR0p9HlojE2lpnKbPDq fJOqB3pf1Xl73bNmAqpsws8eF7nxEPI/CRrbUSAeNq9k0qLt8okLLFMeV3z4INtasi62 FmNU9I9sZStcGVr5TTp5tgOUKwWdmN0AlSFmLGdXz0o0Rw7weGWjUf4MUDUjPq33Tc/t gP4A== X-Gm-Message-State: ABy/qLZiUnsBgvltFee9B6bc3lecKA+ak2hFIVcoRqU5+4wAPXlEhd2L Yw52YlaVKqtTDnKMK0TOySWA2z2T3aGOyq2d7VdpNQ== X-Received: by 2002:a5d:4ec7:0:b0:314:3843:ebaa with SMTP id s7-20020a5d4ec7000000b003143843ebaamr16189249wrv.68.1689011494797; Mon, 10 Jul 2023 10:51:34 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id k3-20020a5d66c3000000b00314398e4dd4sm29988wrw.54.2023.07.10.10.51.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 10:51:34 -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?= , Peter Maydell , Evgeny Iakovlev , =?utf-8?q?Alex_Benn=C3=A9e?= , Gavin Shan , Paolo Bonzini , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 05/11] hw/char/pl011: Split RX/TX path of pl011_reset_fifo() Date: Mon, 10 Jul 2023 19:50:56 +0200 Message-Id: <20230710175102.32429-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710175102.32429-1-philmd@linaro.org> References: <20230710175102.32429-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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 To be able to reset the RX or TX FIFO separately, split pl011_reset_fifo() in two. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson --- hw/char/pl011.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 58edeb9ddb..1f07c7b021 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -132,14 +132,21 @@ static inline unsigned pl011_get_fifo_depth(PL011State *s) return pl011_is_fifo_enabled(s) ? PL011_FIFO_DEPTH : 1; } -static inline void pl011_reset_fifo(PL011State *s) +static inline void pl011_reset_rx_fifo(PL011State *s) { s->read_count = 0; s->read_pos = 0; /* Reset FIFO flags */ - s->flags &= ~(PL011_FLAG_RXFF | PL011_FLAG_TXFF); - s->flags |= PL011_FLAG_RXFE | PL011_FLAG_TXFE; + s->flags &= ~PL011_FLAG_RXFF; + s->flags |= PL011_FLAG_RXFE; +} + +static inline void pl011_reset_tx_fifo(PL011State *s) +{ + /* Reset FIFO flags */ + s->flags &= ~PL011_FLAG_TXFF; + s->flags |= PL011_FLAG_TXFE; } static uint64_t pl011_read(void *opaque, hwaddr offset, @@ -289,7 +296,8 @@ static void pl011_write(void *opaque, hwaddr offset, case 11: /* UARTLCR_H */ /* Reset the FIFO state on FIFO enable or disable */ if ((s->lcr ^ value) & LCR_FEN) { - pl011_reset_fifo(s); + pl011_reset_rx_fifo(s); + pl011_reset_tx_fifo(s); } if ((s->lcr ^ value) & LCR_BRK) { int break_enable = value & LCR_BRK; @@ -506,7 +514,8 @@ static void pl011_reset(DeviceState *dev) s->ifl = 0x12; s->cr = 0x300; s->flags = 0; - pl011_reset_fifo(s); + pl011_reset_rx_fifo(s); + pl011_reset_tx_fifo(s); } static void pl011_class_init(ObjectClass *oc, void *data)