From patchwork Wed Sep 11 12:13:53 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: 827444 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp771268wrc; Wed, 11 Sep 2024 05:37:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVt71UKNakkmKF8E6M5bz6EutjXsiJyR6UfnIMgJPdqTQiN/uptU8rhLnSghoVTO9dj9UlnJQ==@linaro.org X-Google-Smtp-Source: AGHT+IFncmbVYCzKuki3llHzXQ3g3/JxKpDiahpf8/C604XctuugHpd6uh/MhAh9QoYc5tG9A8rw X-Received: by 2002:a05:6358:5e04:b0:1b8:3d4c:bb30 with SMTP id e5c5f4694b2df-1b84d142e6bmr534411255d.9.1726058275871; Wed, 11 Sep 2024 05:37:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726058275; cv=none; d=google.com; s=arc-20240605; b=JyL5Av+VOizdYusnmdXWXDi1+uLTZlrUeCyElsY13kHAfjQJH72KGoM55/WEMEQjKM zXznSA9YhGhE/0kmbQXtzGqAgUOCDbwlhDsCmuZGXpsU0rVM77TGSPsaTdsBlIC0h7ee YLG27RJGz2Ljco7Qm1mDn/WWq7Xl70B3N45t3g43b/DriZuyVojKoFHJQ6oiovIqoW1r nqVMu20VPE7oTdU7kk3mCSt8DXUsFaeqYBayqk9vbqTPfl2wX/5U0hoH0dEuleeAgHVX OUTLJWxVfvnMUm1kaNcQIFEhetb4+5NtG2jiHs0uiQO7HL3cPJd0RXtcY3pIQ8mTG+33 LEZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=8Nx+lj200bo+xsg0LIsQyP8I0DcjUxGoGWnFa0dywV4=; fh=qtn8prgQtzf5IzCNvLChUZDElvNECP6ej9YfjQeBz3I=; b=SXuDf9qo9ZzugV0PjllPiLwWy7qwvnBZZlZULf1TIUoPn+nj/WO4idyvTflczLlM1p IslzUbqU7NsVS+jNIswYSgCQES8zyalorO+zYfMA3b/Gb/WNHXeyS7oi00ukZuPJjtNu OqUCO4dWn2G1k4H1EzVuol2KHZIGot18GI1IFFpQhiHeTJRPahT8yBh6etm7D+U/zHgL S67UF4rZADcWRdQsF0hDqwqeDbLklrxJtzudJ+mnfl8gYKyTXAu8IdCi5MSdzO9aFv4a acsa4G2H4jxMJZxH4M771/jIH2nxlEmqFY7J13C61I5rY9HokvPWinN+Yvs380/K9tO9 bQFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hdeOgvN2; 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-7a9a7a49765si986222485a.521.2024.09.11.05.37.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2024 05:37:55 -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=hdeOgvN2; 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 1soMJq-0001xM-Pv; Wed, 11 Sep 2024 08:19:34 -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 1soMI4-0001oV-6E for qemu-devel@nongnu.org; Wed, 11 Sep 2024 08:17:52 -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 1soMHu-0007ZL-Nv for qemu-devel@nongnu.org; Wed, 11 Sep 2024 08:17:37 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3787ddbd5a2so1170926f8f.0 for ; Wed, 11 Sep 2024 05:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726057053; x=1726661853; 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=8Nx+lj200bo+xsg0LIsQyP8I0DcjUxGoGWnFa0dywV4=; b=hdeOgvN2djdyTB5Z2AeS/Sow0u8JMsaBAwz/jweEc/Glhs4GgxJrm3von+qaqMkzZZ n5Ayo46EYR5++Klyi1kfvcZcXsPElyTvu9WfR2AYGxYQIrq180p7vJ4LGRuEG6zyWOCj Hp3zjzdeJSeNNQy/5HYpT/PsJvOHLepLO8hdKZdXDvRilYynf3brsynSlxu+2ey9FIMr sbMv+XeMgJJpQWMWD9biTa0kBD1SmoTYJM08XiMB4FjxskkAzLK3EOoJiaxAXtLVSU9i xEykhTOZbWFD4xj5f0XSTX3mN60AJhLVAOORE9qPfpB9xXCpOnAvfV0jYh9P/N6izKtK 3Ihg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726057053; x=1726661853; 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=8Nx+lj200bo+xsg0LIsQyP8I0DcjUxGoGWnFa0dywV4=; b=FOGQ57KGlCSNyqMepNXphL4eqXUUZcIrSDGjheZyerVnrs5tcuhsSK8urnFGZfguqh CUKsm2Nw7WAQz6sliNS2Jw0bdGS8WK67zN/LQh53jh0V8PYHuVZ+M91XHkHT3P26/r/H nPvIXxreSuGchzJ+otfKACgqlXV6805nQiTAizikykyjoyLjicGYnfbgx+1b3LwSGt7+ 0U97rCH3MaunrJIUI6XNY2w/bnzChRMX4e6xPdjPhVwh3xlnhi70hn5p7YHW1+RMULZJ GKEVmHdn8Nj42X5AIKj/+6EpOHr5ffTnZOTdhr2iuxx3krfVUoH3WFT9mhCB24umnjSs BzxA== X-Gm-Message-State: AOJu0YwRONFqPPtGum+gH+6fN/Zr/T0Q0bKLZVDJyFcK7ptxNeTtVFvv 1B2/I+vhrlVmn62z9zKUyQZmmApSATO+Hf+OUZO5h1miEYpdKpZ8E6/rBZ6XjN8mT1GeZv+tvAV Y X-Received: by 2002:adf:eb8b:0:b0:371:88b9:256d with SMTP id ffacd0b85a97d-378b07966f2mr1836355f8f.6.1726057052793; Wed, 11 Sep 2024 05:17:32 -0700 (PDT) Received: from m1x-phil.lan ([176.187.196.107]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3789564a072sm11511514f8f.2.2024.09.11.05.17.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 11 Sep 2024 05:17:32 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 28/56] hw/char/pl011: Extract pl011_read_rxdata() from pl011_read() Date: Wed, 11 Sep 2024 14:13:53 +0200 Message-ID: <20240911121422.52585-29-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240911121422.52585-1-philmd@linaro.org> References: <20240911121422.52585-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 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 keep MemoryRegionOps read/write handlers with similar logic, factor pl011_read_txdata() out of pl011_read(), similar to what the previous commit did to pl011_write(). No functional change intended. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240719181041.49545-8-philmd@linaro.org> --- hw/char/pl011.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 1dfa60cb12..26d391a16d 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -235,31 +235,38 @@ static void pl011_write_txdata(PL011State *s, uint8_t data) pl011_update(s); } +static uint32_t pl011_read_rxdata(PL011State *s) +{ + uint32_t c; + + s->flags &= ~PL011_FLAG_RXFF; + c = s->read_fifo[s->read_pos]; + if (s->read_count > 0) { + s->read_count--; + s->read_pos = (s->read_pos + 1) & (pl011_get_fifo_depth(s) - 1); + } + if (s->read_count == 0) { + s->flags |= PL011_FLAG_RXFE; + } + if (s->read_count == s->read_trigger - 1) { + s->int_level &= ~INT_RX; + } + trace_pl011_read_fifo(s->read_count); + s->rsr = c >> 8; + pl011_update(s); + qemu_chr_fe_accept_input(&s->chr); + return c; +} + static uint64_t pl011_read(void *opaque, hwaddr offset, unsigned size) { PL011State *s = (PL011State *)opaque; - uint32_t c; uint64_t r; switch (offset >> 2) { case 0: /* UARTDR */ - s->flags &= ~PL011_FLAG_RXFF; - c = s->read_fifo[s->read_pos]; - if (s->read_count > 0) { - s->read_count--; - s->read_pos = (s->read_pos + 1) & (pl011_get_fifo_depth(s) - 1); - } - if (s->read_count == 0) { - s->flags |= PL011_FLAG_RXFE; - } - if (s->read_count == s->read_trigger - 1) - s->int_level &= ~ INT_RX; - trace_pl011_read_fifo(s->read_count); - s->rsr = c >> 8; - pl011_update(s); - qemu_chr_fe_accept_input(&s->chr); - r = c; + r = pl011_read_rxdata(s); break; case 1: /* UARTRSR */ r = s->rsr;