From patchwork Fri Oct 13 14:11:26 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: 733225 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1489852wrv; Fri, 13 Oct 2023 07:13:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFhC+hyYocQhYoSteWMRSOr2UmAkYzAYYO5UvTKgL80umyTBx/+h66Q/jgRAM2oCHIffQ5 X-Received: by 2002:a05:622a:105:b0:418:14ee:ac55 with SMTP id u5-20020a05622a010500b0041814eeac55mr26309061qtw.25.1697206418622; Fri, 13 Oct 2023 07:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697206418; cv=none; d=google.com; s=arc-20160816; b=BsomrTNdTBR0KYwCyvf3YdG0Q287J1mgY9vIef5ttAKHR0YcFqh+9pUFQwtcoOeLkW yBEysVnnkSngaU8S3ad4hOb8gBqA3k7WPEO+CS7OIXDLCp4qqWsNx1bJv1Glbi0YTBWQ 2Cz4gaFgungh8D5uszvxuc6uFDtP8wBszkVOd+u9vDdULRrb3GVFUphPQfilAl26EJ6y XUa/3zho1f7L97mwei3Rz0B+N9u+ccARV9ku3U5+sNWbM9qd2HpmJ8rwSXhabufFKa9m xzfHjmzlzcQ2hPTLRmMSuaLcn4kBja0+VNZDc6blhp7YWllFYtMSkTLY/samOzaj7aV4 tIiA== 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=5g0UHLmrzpBXUAHJbDdjYHH8dsW06tpS080WDx/2FO0=; fh=MusjSs7gXCZ/MKYOlww+3pkKR+FOAC+Wy5x6PlCIutc=; b=Iye3KTJBIXVdF6vaWBVkhy6Dp2FP0ktGvHRi7QhpvoyAx7WYLbT9PCRuzaov/ll7ZC 0c1UQi7RijwTZy440NNSXPC+6YI1ObVlumqTR/puovi/Dd6WvztUmvyPEobV/XNZGAZg 1UqN0wkK9Ty3YBvlxKOfaGh0z3dHlJbWlykc7ugmZypyRYkJbm8joy2Yw+vYDw++hbVQ puAtfgoA6fkdjFQXHDFiY5L1NLVPRIXcxZc++ij0R6U5CCGIrPJNkfP8WCqO/DKLJ5oq ru2hjyTkDQTjhzpp5Ns6ghsz2ydHEVqcsf6km0bJK7TaIy5p9onddGcuUpgDzn3YsdLq oVxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LbR4l6wh; 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 o7-20020a05622a044700b0041805d0969bsi1245996qtx.210.2023.10.13.07.13.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 07:13:38 -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=LbR4l6wh; 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 1qrItl-0000CI-F8; Fri, 13 Oct 2023 10:12:17 -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 1qrIti-0008JR-LE for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:15 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrIth-0004Y0-30 for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:14 -0400 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-533d31a8523so3764885a12.1 for ; Fri, 13 Oct 2023 07:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697206331; x=1697811131; 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=5g0UHLmrzpBXUAHJbDdjYHH8dsW06tpS080WDx/2FO0=; b=LbR4l6wh4PeuIsGyPnZOBHs/BTmVrry41/p4vuPe+zq5cnbuno+NLxKAo1rvpdhFrR bNsGlEf7ptEkDoMqCmYO2PWR4cFSC4/R9xzz+hnjOV7p1Dm1Hox9nLiuiogsRe5kjaYo i1IZd9yViATOLSwQdx519DHWmamyONFlI1n+tyn5ZtGEvHrjHzxH9oORk++EexRKLPcm Q+3QSoi86bkEa2uNcfKMSBFf0o/TBV6Gfz3K6OhNU8Vxie0IHuCusmcwb3ZtbY4qEYtk Xa52P2mbxd2is6lJ+jD2G+m8RbYP7UlRk9EdwavW9vV6I6miq2Dd1fXia8C2bEB9FXWa lgjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697206331; x=1697811131; 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=5g0UHLmrzpBXUAHJbDdjYHH8dsW06tpS080WDx/2FO0=; b=vt1ddHcZI/C3tLeXswGYQzNN25lTEQU5cr1vkm99W0CCypR0rHDA5DUUjLyMRvR/wF ztlHOLdl8N4bfuL60ZgJTEvsDoyFLZvPS2CchCZkxPO4Xfvp+bosr4PpA/znWbn8dj+g dnx00/66ntHTF8qZKxKGR0fqQYwD9Fur6m3y3gkZ8O8EabWOPdhXv3BWU2P3/lBdVqaa 0uCXrHQW4sNtbGBUvbO7VhxhE/NDWI02PbBqOPbuW/h83UyDApF8okw7IuUq9sday18G G0SevxlwvexkSBKYLnHK8VVix3YfgfbWnMAI8Ds3bteCmvGUdaVEXgu9B9oHKqu9ZO/Y dmRw== X-Gm-Message-State: AOJu0YzLdPHUhlCGdIKUFSqhExN0G3ftnqAh69QbDyI3haakBQ0MMi23 XgpOPbr0W01vYGWznZjDk3crXHcdRSawkm5WT6Q= X-Received: by 2002:a17:907:a0c7:b0:9ba:33ef:fe51 with SMTP id hw7-20020a170907a0c700b009ba33effe51mr9836619ejc.11.1697206331196; Fri, 13 Oct 2023 07:12:11 -0700 (PDT) Received: from m1x-phil.lan ([176.172.118.168]) by smtp.gmail.com with ESMTPSA id jw5-20020a170906e94500b009ae6a6451fdsm12419392ejb.35.2023.10.13.07.12.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Oct 2023 07:12:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Evgeny Iakovlev , =?utf-8?q?Marc-Andr=C3=A9_?= =?utf-8?q?Lureau?= , Gavin Shan , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Richard Henderson Subject: [PATCH v3 5/10] hw/char/pl011: Extract pl011_read_rxdata() from pl011_read() Date: Fri, 13 Oct 2023 16:11:26 +0200 Message-ID: <20231013141131.1531-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231013141131.1531-1-philmd@linaro.org> References: <20231013141131.1531-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=philmd@linaro.org; helo=mail-ed1-x534.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é --- 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 1cb9015ea2..30309337b1 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -160,31 +160,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;