From patchwork Thu Nov 9 19:28:07 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: 742598 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:110f:b0:32d:baff:b0ca with SMTP id z15csp1017925wrw; Thu, 9 Nov 2023 11:29:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhOJc5dUaSneka40kXWCKaCcugiLxmaw+zsQE1B6xn/w8BnuoD4zbjF5Lp54Zmpu5ZxiFb X-Received: by 2002:a0c:d791:0:b0:675:b83f:6db3 with SMTP id z17-20020a0cd791000000b00675b83f6db3mr303740qvi.22.1699558182997; Thu, 09 Nov 2023 11:29:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699558182; cv=none; d=google.com; s=arc-20160816; b=i5kRPjxVqRr7nkjr+wOdSV4H+jAwUcoYK55owMAS2UoqnbENCkKk0FfZuYT/kBeFEw wOxKqVIglKywNYHCMD+gXx6uJCraMImv/I9Do6HjoXmNZtw2xUDwGUnGbUMTNRK3BzPw 7qLkW2ARyiuNscHhVCQ/Gu5luk5wMXngtQ1QazSbd+/SCXVgKz9+6y6WzWk4jGQRlrSV Fvq77x6tN4FnTfzrGTgVvXKqRlDDPGQVDogDDshb679yzPzmdAbpMcu9fkOldLEG5Zru AlPCOvQcaB2BKn8gPN2rnKxiUoaA4R+BrNhXoygu6d6kQ8Oln09Rh1uEBY5RPDYxeGt3 qbug== 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=mP8e7F+MNf59pa1iU6FTfmv7Sb18zKeyajADdz6BZOc=; fh=Zi/lk1CoRxouROvt4Eod7oP2jg68ZE5jz0tOr4SBE9g=; b=iqCM50Wc7CNtetVRslsaZ/Le3Cwn/vytkSZPMuGQ+2lVXc8RB8BGHLe6sIYkxDm5wb PMGC3du/cHJGVGA/eZnU2whjEJmxaSTbAJ3E+8NA1CPnj0XluqHigyM90zTalZyTswNZ UAyg3i0JMaQRJcBzjufoHCgGBzlt1C00EmciCrdZVKcncyScTR0DwASgWYTkuMprq/oG SQEyjiY9T3SX1YSA2Ei3REJxOFkxEReZY4ZlFjYncqqh0FtLzsC8bOYEgPu058zyBDwb sZ7TBuf1nu1oK1qaDrBhg4Ee2tgbdc79dtcIs/kb68PtpVthC+54qgp9SW2SGwXvPf8X Z7fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yUA8Lh9v; 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 s8-20020a0cf648000000b0066db35504e0si3274722qvm.502.2023.11.09.11.29.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Nov 2023 11:29:42 -0800 (PST) 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=yUA8Lh9v; 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 1r1Ahk-00055w-Hc; Thu, 09 Nov 2023 14:28:40 -0500 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 1r1Ahi-00055K-PC for qemu-devel@nongnu.org; Thu, 09 Nov 2023 14:28:38 -0500 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r1Ahh-0005Gv-7J for qemu-devel@nongnu.org; Thu, 09 Nov 2023 14:28:38 -0500 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-53e2308198eso2022864a12.1 for ; Thu, 09 Nov 2023 11:28:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699558115; x=1700162915; 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=mP8e7F+MNf59pa1iU6FTfmv7Sb18zKeyajADdz6BZOc=; b=yUA8Lh9vnAqKuqVclqo4i3ETE3k3VEdY79vtFZFifhM6esPzTL+Sc1vbf6GCBFyaTt Y62vlH/CLoCuJaA7twdJw3h36m+WNZ2DmiKq2R3l4N1CC4WCpYBSx8pwPLbTrM/nKttr SQflwdGaeuFjcdqJW7kXLF5p5PTfX9qGgYS2pZUcckqSETQQR64s0h2avoLPApes/e1n 7S2mjFt5kmJBnhYbhsXkAksFPBLAXlAhMSb9Msj0uSmI/A/qcegHa7xD2dRgDtDeyqmD /zFoId7TjiraCPJmILdUVa4QpONPtym7ZCmNLQ7PVxO9RWIRaIJ2p+c0EaSIBbbP74NF VOZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699558115; x=1700162915; 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=mP8e7F+MNf59pa1iU6FTfmv7Sb18zKeyajADdz6BZOc=; b=nV8gVbj3FKIJoJ8gtBap4VIG+lvstfdbWtS8XmA792aYG/QbDbDIS0HGXEhFpkwOaN zs+gzGWwIwhNwcvvnbpgKPBB9kcgsQiL4wnrmmBwL9NBLECShh5OEEU4FGbwXUbNatX+ fHZD/DUAx8BOoOUTzS03PvzGL6nY6TO4eCZZ5uuidkKzJk6z10cWoGjzdPSROfJT/1TT qYVw4fH+z8GzmCKtL8ZwrdLkPOxGghzPyHmIhsob+yPjHt26KWsQO0UaclpmRSYcDns/ HlUtzBPZ1UwmsqkGaDsykJxTmu+MFkhU6u8Xt3EdiS2Z7ABap2/qiDOb0u6/Ihbi3SIQ Ze7g== X-Gm-Message-State: AOJu0YxYMeo1X0kAiDtYaauqBBrF935RMUsiKzRV5PlQULi/l3ZQ75ay FFLxbpl37nrVQwXg0Ae4SfcBqmdMZCWGDfRiTu71Mw== X-Received: by 2002:a17:906:d9dd:b0:9e5:21d9:3ba6 with SMTP id qk29-20020a170906d9dd00b009e521d93ba6mr712372ejb.9.1699558115130; Thu, 09 Nov 2023 11:28:35 -0800 (PST) Received: from m1x-phil.lan ([176.187.199.161]) by smtp.gmail.com with ESMTPSA id bw25-20020a170906c1d900b009bd9ac83a9fsm2946023ejb.152.2023.11.09.11.28.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Nov 2023 11:28:34 -0800 (PST) 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?= , Gavin Shan , Paolo Bonzini , Mark Cave-Ayland , Peter Maydell , Evgeny Iakovlev , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH-for-8.2 v4 03/10] hw/char/pl011: Split RX/TX path of pl011_reset_fifo() Date: Thu, 9 Nov 2023 20:28:07 +0100 Message-ID: <20231109192814.95977-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231109192814.95977-1-philmd@linaro.org> References: <20231109192814.95977-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=philmd@linaro.org; helo=mail-ed1-x530.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=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 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)