From patchwork Mon May 22 15:31:39 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: 684724 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1262304wrt; Mon, 22 May 2023 08:37:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7QLLvayibRz3B0x5XwthV8+4nlJXmqZIULuYJeOPzQJBXQpus3J36TjONyY9vMeyckHcPd X-Received: by 2002:a05:6214:413:b0:616:5f27:b96a with SMTP id z19-20020a056214041300b006165f27b96amr22368156qvx.27.1684769841542; Mon, 22 May 2023 08:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684769841; cv=none; d=google.com; s=arc-20160816; b=AcUhLXGHLvrmHvdNA+6vPbkMjon5lWJCzpzCO2Ql29Sb7sdOoLuLuJfrTPd3mYVIr2 CkiSVyP4gsg5ZYnvv4H9AOom0MEn72EfBaFn4P2wkjMLTFErtL11yw3mPgeqvoD3ksg2 9kTOW9qet9rlNMAWKsPOZdrWxihqg7rF1A0KMdQnqpp55U4Hy5rZgugdL46tXZyunDO0 tBHU5CEKe8WnfoUP5JD1ABQeFimB4WvAwOQGR1uPawvFe0v6YcTvNlsBXjO5CdF2/OPF 9XSqNKgCwhW7gMs4k8D/G5brHNo86FO39bk0n2AxHeWNsURfzL/aIfHR9N78gXSy5af3 FtLg== 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=256qRxVoRgmn8ZQNw96BSPjzs8Oo5GL3PGwhSL7cRNw=; b=HD8NbR/jvYLXG82Z2EKsuEZqWlC2ZbBos0IryK7y3yBQh2SJszE1lv0093uXFLVPlf BmpQuWffH6NEQo7gITLS2HkK7Wd13q0XOoiPPDXpzT6xwEJET7aDKmSQQ1dz4bxcgaUd srC8jhop1RZ8reQBlz2i4b+gYjIaOomCxet3iWRrENYxWOplRpFE27HzhbJXFd5/RmHq m0PjqXa/b43JXD4ZBzVLAJFtQD3DRB/qpdqIZ+lL6PzwKzIbAOI2APGsQpfNI9E8Rc3x Wz6RekFHj+ikws9KOwvhraHGrERMbhoWFFz9uFc/2xo6UHhM85QDnKAi9qkh3p9NAQBN a2sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="C/t7JMkQ"; 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 d8-20020a05622a100800b003ea63719f0fsi3750806qte.611.2023.05.22.08.37.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 May 2023 08:37:21 -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="C/t7JMkQ"; 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 1q17We-0007cB-Gj; Mon, 22 May 2023 11:32:44 -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 1q17Wa-0007Uu-WD for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:41 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q17WP-0001RU-J8 for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:36 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f606912ebaso9303235e9.3 for ; Mon, 22 May 2023 08:32:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769546; x=1687361546; 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=256qRxVoRgmn8ZQNw96BSPjzs8Oo5GL3PGwhSL7cRNw=; b=C/t7JMkQsTbjpIgJ59MHwv63ucFDE2WtK1AE0dsf4JCAAsNUrp1pDlOCrmtxwNAj+C oceIXdKSpx4vUBXmKDLfyQ+5HS+At35HtKg2gvcngba7a/Lzav1Jvpv7XGm969IfTPKc lh2eTjhN3LR5TiRFc3LSSFTVtFhLGmUPEmwd7xIC+rcCrEjG46BtGVY9L3KlhU26iMxw JCv4Lu5Xx+PjGfWP86KsSoMROJ14gykSKxfg4Jkbvcv1xGpblT1+KdtLfCwft61nCPVX n/NBbkh4uHNUUC/CjtuAokQbW7UQTZu7tv9rUWGkpX3Px2K1MiFXZEzchZTE26af3RZy k57w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769546; x=1687361546; 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=256qRxVoRgmn8ZQNw96BSPjzs8Oo5GL3PGwhSL7cRNw=; b=jGa+kwnUivsN0UlyBum8r609n9WLig9jdOPFvRJAfm22xRXoClQPLyl8bDk/Lx1xMK FXRlQx0HuPNpktlC3Q+vL93BzyA3wA/qkcZNBvXS8+eCSwPwOUGrcCWZRwiOd46nmn1y RAffMP1FwcbZG9b8XCH7Cjuvf/M8C37MKCVOk0t6xQgK69SllvklM2gHHcQHFjjT8ik+ iBEkwACzEsrEnx2g5CEVmHWvCKdSB4sjCa2Vtp6LXHZfZbCjYkrxGQi1CyUCYBGIawM6 +b4PrtqhUt2pbtSPJFvmTjroqOQdFD5iZNapufjjW0/qRVqLuH3Fibhu8beN3uQueTgO HwGw== X-Gm-Message-State: AC+VfDxWpH476QPo/LHGZtZMQ6h6jv2mtYsxYeXnaJxzUjcCj6QdGfbB jEZZMQR3aYZBl022SI4BLyh8ciuft8/VOeLIi7c= X-Received: by 2002:a7b:cc8e:0:b0:3f6:89a:94c8 with SMTP id p14-20020a7bcc8e000000b003f6089a94c8mr658221wma.24.1684769546718; Mon, 22 May 2023 08:32:26 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id 18-20020a05600c229200b003f42d8dd7d1sm12078857wmf.7.2023.05.22.08.32.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:32:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , Evgeny Iakovlev , =?utf-8?q?Marc-Andr=C3=A9_?= =?utf-8?q?Lureau?= , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH 07/12] hw/char/pl011: Split RX/TX path of pl011_reset_fifo() Date: Mon, 22 May 2023 17:31:39 +0200 Message-Id: <20230522153144.30610-8-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 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 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 --- 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 98c5268388..f0b305e5d7 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; @@ -504,7 +512,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)