From patchwork Mon Jul 10 17:51:00 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: 701047 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5305446wrs; Mon, 10 Jul 2023 10:54:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlGXJg6yfiAjvGH6Ha4BMlKfv3dyacpbFc/HXPxtDuO6/XctagK92QSuZdKs7ymlELlxTjfo X-Received: by 2002:a05:622a:130b:b0:402:36dd:20f6 with SMTP id v11-20020a05622a130b00b0040236dd20f6mr14616038qtk.53.1689011655254; Mon, 10 Jul 2023 10:54:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689011655; cv=none; d=google.com; s=arc-20160816; b=hq937UrVKfup8oU8EGxd7J5b95k3hxwq7aZw7BuDb2nKd+dz9REHgB45SlRrVaZev9 Yv4USjy+Hzfq+6Ycnss5OiMtOv5GCB+2XwKx8aWjj9GfEn8xn34fXI214poJtv9GFpel +h6z0jJf+b+xMHz5jzHKPvsa7G8H5etQm/BHu4Z4UlaG+SR+PZU7etnwa5iQZr+OcUFK JtIQqwEfgZe0Jn2GuzHD+q4w2HxT7/epKgpClzMoNfm6yAcNeowC57NLLCExMTwAjCJB dNbVupS6Mj2c+uEzdEyvrYOLkkUFS4LNvEhrAMcwUMLlR0pYzS3Cu2bVAxK6j/E7DMLe NUaA== 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=ef0gwQxZ6wwALYiU0bKC0wOaAk58Ouu2v7vVPMXHDsg=; fh=4TWVGTMFk+XB48cTX7H3L2FEUZf3X6lSQ5h15kr1III=; b=Z8DPAydn+FhcpRXyuq8BynsWk8VGuLihLGsHLv1ZDzdxGmhtXDZQpTkh3+2x6RfC6/ dXy9r/Gz0dCcHhNExKa+RJXhX7M3HcLuwuGYqRPaXDEBOuC0m5DHb0G22RTsUA4v5T9O m+wk7upAAiDYRapU8vAixPCZ592wjIOAxdETYun+ZZiii+3E0aLHH6Fq0cuX7MCegio+ p41OAD/o7lC3wVxqKJ1CezAzfDlcgy+7q4BT23oz+kG6jwaooUiIU+BAP8ete2tjZAng 5xRSxYzH1E1xi4xEF5aMqhqOm/8kX4ed3Y5P9BAUFKjGM+5KlBjrUvhk2mz3RRTMbfEd y+2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eb39i6i7; 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 9-20020ac85949000000b00403a77b0ca3si108962qtz.629.2023.07.10.10.54.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 10:54:15 -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=eb39i6i7; 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 1qIv3K-0001H7-NG; Mon, 10 Jul 2023 13:52:02 -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 1qIv3I-0001Ei-OZ for qemu-devel@nongnu.org; Mon, 10 Jul 2023 13:52:00 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIv3H-0000Xq-7j for qemu-devel@nongnu.org; Mon, 10 Jul 2023 13:52:00 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3143b72c5ffso5639329f8f.3 for ; Mon, 10 Jul 2023 10:51:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689011517; x=1691603517; 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=ef0gwQxZ6wwALYiU0bKC0wOaAk58Ouu2v7vVPMXHDsg=; b=eb39i6i7xi4nlBgWcpkrPATAugD/ggTyTyPTcXl+fGuW6SV0vt8rj+5FHUlxaH1vnX iLDdCSljVhVQRZBY0YhxR0w4s0lkssx6npLSXepZhggJnSx/z535pdpgeLuYUAHlcE5A AtkEXWML8t6KVRp4AbuNsBCjbYq9ahdSX2dnBbryKfxmr0OMA/LZQxXYsyNQBrA00JbK mE8xfj8oGKbuQEbSMD49k1ZCkR9YVWOFbGdbkTjvL5+UKjwm8hV7/Bas7q80Tl/Ckb72 6cdoWJkMxlaNMguwahRwZuIC2GcERO+FJryvCRgN02rtSQY9bJIq4EZ8vgxpcPD5JW7y n5nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689011517; x=1691603517; 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=ef0gwQxZ6wwALYiU0bKC0wOaAk58Ouu2v7vVPMXHDsg=; b=OcNDKCv29qzdrynpgZ8RUUlg93kb9H8zZROhX71YggK5rtxyLBxIcRs9aWpnbpnTAG zo5by8/6tdC2e8mM6OoZLH8h8Hk9h2WQNkB3vRChOIWseoiw3HAgt+1hQMXBCjDLDr7w hSSYNXWl5L+rUgsaD53HSe6dfNAUb2EyUx02lV48DXeuwvcpjxjdGgQcR/ioTiXRortu n3Au3tdOVhgOvk0DmbfxRXU/k1uQfIqECIrw+wh9fK0TpeFqEyTZxF/rZ0NQMPXELAsp z33gimTc3BTAeXrCAqSm6U1yUW7bILtbja8ld1WKUbb7N3Gfo8VHkDX08WaEhEjEk062 DUIQ== X-Gm-Message-State: ABy/qLZA6Zwmds01xwL180dhWkHuKvOYz1zL3Rp9QJPxqAxAqYuEnqoF yrZRgG/svo5uJgU4GtwD3hvRwDy+aBEigwwWv7OvxQ== X-Received: by 2002:adf:d84e:0:b0:314:2d71:1f7a with SMTP id k14-20020adfd84e000000b003142d711f7amr16256091wrl.32.1689011517665; Mon, 10 Jul 2023 10:51:57 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id p7-20020a5d6387000000b003143801f8d8sm7154wru.103.2023.07.10.10.51.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 10:51:57 -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?= , Peter Maydell , Evgeny Iakovlev , =?utf-8?q?Alex_Benn=C3=A9e?= , Gavin Shan , Paolo Bonzini , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 09/11] hw/char/pl011: Check if receiver is enabled Date: Mon, 10 Jul 2023 19:51:00 +0200 Message-Id: <20230710175102.32429-10-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710175102.32429-1-philmd@linaro.org> References: <20230710175102.32429-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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 Do not receive characters when UART or receiver are disabled. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/char/pl011.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 03dce0a1ec..59d239cb83 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -77,6 +77,7 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) #define LCR_BRK (1 << 0) /* Control Register, UARTCR */ +#define CR_RXE (1 << 9) #define CR_TXE (1 << 8) #define CR_UARTEN (1 << 0) @@ -357,9 +358,11 @@ static void pl011_write(void *opaque, hwaddr offset, static int pl011_can_receive(void *opaque) { PL011State *s = (PL011State *)opaque; - int r; + int r = 0; - r = s->read_count < pl011_get_fifo_depth(s); + if ((s->cr & CR_UARTEN) && (s->cr & CR_RXE)) { + r = s->read_count < pl011_get_fifo_depth(s); + } trace_pl011_can_receive(s->lcr, s->read_count, r); return r; }