From patchwork Thu Nov 9 19:28:11 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: 742602 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:110f:b0:32d:baff:b0ca with SMTP id z15csp1019060wrw; Thu, 9 Nov 2023 11:32:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqoKzgWe6hzbwfPRfoMJkS7r9e/dn6IocFKaHcZ2rZoMeSBn61ybQjynmd4jifebxzMjw8 X-Received: by 2002:a05:620a:3712:b0:773:af69:e614 with SMTP id de18-20020a05620a371200b00773af69e614mr6669951qkb.58.1699558336542; Thu, 09 Nov 2023 11:32:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699558336; cv=none; d=google.com; s=arc-20160816; b=yzqPk0NymGQqkRcYlJExFr9lUaDAIWnA6b032XVxE46mEnES8gwMtTQhdDUJJrAyVk 5jYuBAUwn/hHCAB+9iekb/NGru+rp1GcsyAKtU9mOAvRRWp/XK/0M9IEKyWv6Y9Ox5kS 9f4yGZDH0Me1iAhZe9Ngy8s0Z5akXV1b4dWr8X8GK0do47mkh5zF/OB8+ObJ1SaxJwsR rHmdpW5w82zS7bsjf+MICSNMkhHw+u8Sl28aucW/tbZOYDW/2/B1+p3hTow3q1AIN2M+ faga+J49ayJ3QPIaJtKAxzslPO7fFCMfSkBn8EnYT3LeYxPpzIp3+4NSt4eUTxYdvTP6 0bJA== 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=SyyFM5rojPE+uJBRWUA1uUis15hpR5uGCcF147lyuU8=; fh=Zi/lk1CoRxouROvt4Eod7oP2jg68ZE5jz0tOr4SBE9g=; b=ScvCUYiJhy/ZozGWBSgSQjxE5OKHyb74azb8eA89KDFXANUG86RuYv18uglO6wj5F6 dQ0nxfQHlxF1+LT0BujSHv+HK2sHFBbZUN76Eav5ab3lH31A/1Hgey2cbO7Eohi0koVz EgXlDReA9a0fa+lPHa6IgT0JazgIFJSP1GjG4pmbcTvFeCapJVMdhNw50CTeFE4cXrwE CIwxwkwDtaF7enNeU5WTogyymQRoAa90i8WxmqIT5baqxdzqidDmsVKhyvP+pvSaj9jq JdoqkyUwkc2fDVT1a3vrHE3XT7Oc5NETPwd4Qsqum+rPdSBg0QPOQy5lhuWrjtI6HdsZ 5O5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ceWJJSVT; 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 w9-20020a05620a424900b00775a6554b41si3243461qko.285.2023.11.09.11.32.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Nov 2023 11:32:16 -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=ceWJJSVT; 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 1r1AiQ-0005wf-5E; Thu, 09 Nov 2023 14:29:22 -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 1r1Ai6-0005Ru-MA for qemu-devel@nongnu.org; Thu, 09 Nov 2023 14:29:04 -0500 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r1Ai5-0005J3-58 for qemu-devel@nongnu.org; Thu, 09 Nov 2023 14:29:02 -0500 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-9c2a0725825so216555366b.2 for ; Thu, 09 Nov 2023 11:29:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699558138; x=1700162938; 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=SyyFM5rojPE+uJBRWUA1uUis15hpR5uGCcF147lyuU8=; b=ceWJJSVTDqh3rVWtpr6FLID8/EGtwSPZfOCpxla5lqrYQx5o8LuqgVLsuI+x9kWjfm tDUiNPz1AsI0xqahGzAeKR7UoUT22pE1lh2Lzs+mHwgcJ20qRWtHHAZggxQoUcF9mN6N f/Ay6ySseUgVFULW6LSOeWLkNRdXFW9Zs/7UvVgtZIgJqO+msBUoE5xirzO+TSbAuIdT T89g69M3uNaLF7g9JMYKBQmwYWvi2VwDGkDXCseUgIdxqjIZgmPzBFawoNED1+jh7+Vl Y4BOZnq6dGKytEU/CHJxwGdD5cyrYpWjOaSoFdoCDSditHlKy/yMd1BaHv5+UbsqEgVG DjLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699558138; x=1700162938; 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=SyyFM5rojPE+uJBRWUA1uUis15hpR5uGCcF147lyuU8=; b=pOYEqV/7pvC15swAJObP1fwqYMJR4bD99PBknWT0keOhYg+83NEfoL2vRkyofImcKv DILEilAFtH8WtoIVhBiQ80XyXTG6QTg8JIfWkyt9eCFEQmmUKsemIEE5QB6oezub9FyO qWFK4cnBVesx8krdjcI1ZNQojJQCw376mLtQyHiROTfGQ34/KLICBimLDfAYrTjuf8Wm Gi4c4wHOvNvEARUwtplSzwAQFXU0DwokGfYv84Fn70WtrBIRa/BoNuBKGR8b8cnPhICc Zu5bwhmJE/eTVi86O1JBh2PIZX1wYgHlmmI9ZjR9FO5wZxlQ+BJMqP/HIG2LYfXARx22 z4kg== X-Gm-Message-State: AOJu0Ywhc/RYpkpZ7kjlvavtGK6LIx14nda+F8XwqW1Bm4PXX388966v AoEXXw6C1qWjzsVQfhslE0tUqY3tVFMF6kwY6EiQFg== X-Received: by 2002:a17:907:96a5:b0:9c5:7f8b:bafc with SMTP id hd37-20020a17090796a500b009c57f8bbafcmr5691609ejc.22.1699558138606; Thu, 09 Nov 2023 11:28:58 -0800 (PST) Received: from m1x-phil.lan ([176.187.199.161]) by smtp.gmail.com with ESMTPSA id s3-20020a1709067b8300b009adc77fe164sm2938523ejo.66.2023.11.09.11.28.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Nov 2023 11:28:58 -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 07/10] hw/char/pl011: Check if receiver is enabled Date: Thu, 9 Nov 2023 20:28:11 +0100 Message-ID: <20231109192814.95977-8-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::629; envelope-from=philmd@linaro.org; helo=mail-ej1-x629.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=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 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 9c43cb47bf..ca931be139 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) @@ -359,9 +360,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; }