From patchwork Fri Jul 19 18:10:35 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: 813407 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp877516wro; Fri, 19 Jul 2024 11:12:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWvJLAb3eF7DWHIJ84ICUUrjvfnnFlP5ck/D3oZMcwMYnZsU84HXF8MmwzlDDfEDkTmJs3huF5Q6U20L5mJORlo X-Google-Smtp-Source: AGHT+IGpt0aOnGh/LAGnActdFsjfKQ+I3Hc/OhCOHnj3/Jfo1/Cq9YHhO4kUitq30+WZ38KBPluI X-Received: by 2002:ad4:5f8b:0:b0:6b7:9c28:4cc9 with SMTP id 6a1803df08f44-6b79c285cdamr80046426d6.51.1721412763710; Fri, 19 Jul 2024 11:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412763; cv=none; d=google.com; s=arc-20160816; b=JQIEWZ19vcx0jE4NW2DBNGg1qCMOpyIOySFTT7v6IeEyKptDf6px0KL1OrYEI1iqZx XdMpzheZ2MpOq2BcHAEL3MUWgh7O4XAn1exCEByUpQmeM10QvNtcRjfBE6Abw1VVDdiL 2QsDO4MR1hZrbREgI2d7utG6La3A7R7KcMsfxS/UdPE2+3geF/DBKRUr8BhSjc5Amczc 4+2/xE5yWlmOIUsU71TBHDc10+tM2Wqcy99DfnhibCT9dXbODcqoBc+v+oghIsZFd0Vk jFD7/ZE1zpUCysg8D7ppek0nU3CAAM4UKGZYjpeUo0Vdz/UEAVBHvrIgcSg3AbhiHCtE zmww== 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=grsGKEIQC5JMZTvNvSN/qnaW61vNteYTEI5sYVegySE=; fh=8nLw5DkymCkC7Fl2VB/6HOK2iJbyi0CR8pyTF7gwHbU=; b=k6Typ8hQUqq+nhBnFI7203YZaitp65L1EyBslK5Oc45e8tbKuViKrgNbXw08u4ae30 /KAIMrMc0GXAx5Us05l5GhmuM2HqQjnNtxIaFwmRMVXpPUiUA1n6hdiTTFqj/qoArKCd bJw3XPLiA4YqhEufpcctD/nenLni+Jc8W5TnamPW/Mg5hQN3hm3iFk0ZwMPs7lL2jIKx ih16vVCZpQYGyIgTzWPb1SNlcdepd+4IleyZx0snUAkkODw9oJpZ+MSNDQF3747yVkRX yC6kVznxgS/lNiM/Ga0VmIcbPuCkgyCPvMgYo6TOkMn/yY1N0/1YHJMBEvKJkca+EX+m KVnQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rSZEVosb; 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-6b7ac9b8e8fsi21592316d6.340.2024.07.19.11.12.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:12:43 -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=rSZEVosb; 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 1sUs5b-0005p8-P9; Fri, 19 Jul 2024 14:12:25 -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 1sUs5D-0004oL-Pd for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:59 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUs59-0003vh-QJ for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:54 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4277a5ed48bso14848395e9.2 for ; Fri, 19 Jul 2024 11:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412707; x=1722017507; 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=grsGKEIQC5JMZTvNvSN/qnaW61vNteYTEI5sYVegySE=; b=rSZEVosbJZE0iEj3ZcpATu6RmNENH2lcc3RRV1yZ026+vxKQdVsTffeAjTqDmwrq/c m+NLZz7Nc+i7ChbtiMBWfa7fRvygtn8oKm5R6EpggYoAgbYr/r/MQx7/zSh6sTb3VODm 4y9R8HL7sssqOjuWnHwCtcgH4+IBQgT4o9ZRiBcqLqVuvIJV2wckjJma/IOsBRgwbYod /ImD1KzefSI8vAQMJUJtSY3LfBQ2hCEfsKve0qQG3tKOjtckXhBfEd8a2O6/b2pjvajs bXWRYhum7j5CRlk2dhZcPojt5a5nOJLhM8plJMhtWpLxu/khacWuiXqyNr5+09ZW5+j3 P6Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412707; x=1722017507; 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=grsGKEIQC5JMZTvNvSN/qnaW61vNteYTEI5sYVegySE=; b=jSzJONYc5jYgXNuk/ZimapJ15cOoby8y4TY08iuVeSd2PjnkLgcTf2nIeseHGF1Tn+ SqYBBGddHB0vBlwGy9VZ40b2TuzyHeKMzdvTMKPU+BlGIAMNzJ41uWzqmAtiXW21qtzh Wqh7ib6bb5zTNzciLPunLc/AGWLC5WJQMKqvenLzlQpUgPS8nndWRKh6yDzq9GdyKsFy Qyk41sfPt5uJ5qJmt0vzRAjN7HyVRj8QTPqUQ/hIwZMQ1NW57AEUPY+C2GXnMljoYqDx dvQwkV05VDTpUVv9aUwYydWXKTti/e9ExDi+iIzOXNy7WwE3Vqom9nvovII742dpEyHQ j/Ew== X-Gm-Message-State: AOJu0YxmqindwNsj7QuGBLBEnapP/poIttex/S1AFzrqCWK6QwLZ2p6W b11nVLdmuQnsNcGKot3WIANZGpzQ+Hde8dYd86GUE1kCOzQ+d02I+XgXlR3lBO7fM2+fmB6O4zF R X-Received: by 2002:a05:600c:3d9a:b0:426:6ed2:6130 with SMTP id 5b1f17b1804b1-427c2cb6a6bmr54800415e9.14.1721412707456; Fri, 19 Jul 2024 11:11:47 -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-427d6906a96sm34009935e9.22.2024.07.19.11.11.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:11:47 -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 10/16] hw/char/pl011: Check if receiver is enabled Date: Fri, 19 Jul 2024 20:10:35 +0200 Message-ID: <20240719181041.49545-11-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::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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 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 c76283dccf..0ce91c13d3 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -85,6 +85,7 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) #define CR_OUT1 (1 << 12) #define CR_RTS (1 << 11) #define CR_DTR (1 << 10) +#define CR_RXE (1 << 9) #define CR_TXE (1 << 8) #define CR_LBE (1 << 7) #define CR_UARTEN (1 << 0) @@ -481,9 +482,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; }