From patchwork Fri Jul 19 18:10:30 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: 813415 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp878145wro; Fri, 19 Jul 2024 11:14:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUt7YmD9zkAqCBdSTieRIuSawfm68rOs9Zvyy4z0jpRJQwrU52bkxN6Oma411Uysmg0cD5mNvn+GtH383rNz2Qn X-Google-Smtp-Source: AGHT+IFoCxvJCt1UCn/3RHAOmZkVbeJyUecOcYZ0FT/HF8xoTHjJf9itznAOTK/vt+nZQj/q7YpZ X-Received: by 2002:a4a:e90b:0:b0:5ce:f75b:175e with SMTP id 006d021491bc7-5d564f5fb1fmr575208eaf.4.1721412868761; Fri, 19 Jul 2024 11:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412868; cv=none; d=google.com; s=arc-20160816; b=Crqa0f3li5+zoIKLyUQ66ArHracvD+uzD2RUeaBgSjnu0YOjMyWext4QmIKJJTSYlR 3iwxvcl9sS7zMJDp+SXZn8S3mH3t4TZFrSkh5TrKFPqnT1DXCO3zeb7kb8dLZ8HUxi5c ghlNaTsem8Y9oG2O6imxjtsZTTHG7J4i9mIExCHs3iYLkxQvPNJjkzzo2sahX4EJ+SxL me99SGBu31LrwRU/R7akQZnzr2hgYGpF/iirBe5CAJoMUr1HJOtDJpU9RMgM1CAbgwVk 9kJ/ELe7eTsbE5yezGHDC/WKbwb8KqfafyKRWZCEQ0lfmcz0Yobmisa8+sY+RBVZjaC/ GIJw== 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=WBQBL5W8xgFprC/jppYzPypv2gfWoCKhxuevh4igzXc=; fh=8nLw5DkymCkC7Fl2VB/6HOK2iJbyi0CR8pyTF7gwHbU=; b=zRdUzRKDzi69NVGSUOz7wofHg1RF+piZmNJ9hTCMedmVBvwAEC1rkgnQM3KdCnxcQj srtbYwy3eyVnFg9cvWqKYznrbwileWmFFU0cu5N6HLeKgMyfz26yxT+vInCNRQYyb+Jd Li6cIbSIAfLDFF75hcO3A/0nLBx2unmLIIfc16IJW6Frd1w0Va/baxPLpj2o5T04MOlG rkHGBdGtcq1JdRgeVGG7LcT8PK25HPsaoOQZfJEcYcte5KEIZr0UMLOCbJo5zoCsxEcj xO+RIx31wGoXCqDYfPYUboAljhgDKPYk6ISpRQsrBMUwb3kGZR/HJLwxB7yirvAisax8 CYuA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cHDup4H5; 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 6a1803df08f44-6b7acb1028asi21423306d6.540.2024.07.19.11.14.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:14:28 -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=cHDup4H5; 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 1sUs4y-00039d-H0; Fri, 19 Jul 2024 14:11:41 -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 1sUs4e-0002Qd-AS for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:21 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUs4b-0003ok-Mp for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:19 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4266edee10cso13005545e9.2 for ; Fri, 19 Jul 2024 11:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412675; x=1722017475; 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=WBQBL5W8xgFprC/jppYzPypv2gfWoCKhxuevh4igzXc=; b=cHDup4H5TPWAimxswXCit7TSGbrQixMkYckcWu8Lqxk8n3YDSE+HGcFpvaaaIdXf+T LwOYwyQfqRzoVBjpJ3pWNFdEPpY7lmm0Br1KxonT4+PuCkRPu8rsdG06nwcPPGitjTEw rFk779FCoXpXYMrCHvVBHSquRXFij60RK2EUuBO6IdD4Lgwp1NNYQOLZcauPZJsrmNV3 KqOuFGQkLNvv4n7wEAa2xHyn39P4QdnrEna/KWPIj8gtM+yUk/0mernOWHbmAQhpiBlj BLMt2AZKDRE6YTxicO3hvRvc+HqCQM7nxUAibI2HXV6dFhV2NMxo4GNVwEUioTsqQxT4 HJaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412675; x=1722017475; 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=WBQBL5W8xgFprC/jppYzPypv2gfWoCKhxuevh4igzXc=; b=eNnG38kKE0pp8/+RjsZOUxnuxgdmhDbSmTenTolcy+PDdSzFpX32vMplfStZtB5fE6 ZU8hnL8+CrZIB+ZovGGbekc1xKVjqvA/QsuFxhp4mgsdAG7FdmezVqVPgUjieVowDlFO YxhMuzeG0IRL0LCwNJzCAyHUzR21lvzHCKYi062tAyJWHXlWTlShzkBPtTiVSoqsS7sy 2GF9VGjD12pfe6FJUCz7PxHmV7nARN930GuJyCnvQKcnoFpBjzex6ZsCZlqL5m+vvVyI mn+uyhvKwA+5r+NegBm4SzbgKrcJTmqtbDAkcnPwejR34YmHdo5MZnC1cc5p5tCcZlnb Pv1Q== X-Gm-Message-State: AOJu0Yypf88jwb3oqODMtkDQ3Ro58IvKahruqUfZ1Shbq0cCUSDaMzYR dhq8ahi4o90yCTuGgRP8qo9WuEc+OQcxMzaUin2AhAPUewcmz0s+9DTvZxvaVV4+mJAgz68aKwC L X-Received: by 2002:a5d:58da:0:b0:368:65a0:a423 with SMTP id ffacd0b85a97d-36865a0a82amr3024174f8f.27.1721412674957; Fri, 19 Jul 2024 11:11:14 -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-427d2a94c0dsm59991275e9.46.2024.07.19.11.11.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:11:14 -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?= , Richard Henderson Subject: [PATCH v5 05/16] hw/char/pl011: Split RX/TX path of pl011_reset_fifo() Date: Fri, 19 Jul 2024 20:10:30 +0200 Message-ID: <20240719181041.49545-6-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::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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 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 22195ead7b..3d294c3b52 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -154,14 +154,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 void pl011_put_fifo(void *opaque, uint32_t value) @@ -410,7 +417,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; @@ -619,7 +627,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)