From patchwork Mon May 22 15:31:41 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: 684728 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1262501wrt; Mon, 22 May 2023 08:37:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Vuelk7bsRSnEfAgS3uGypUpp1lc0tz3Wfdigrh0NJMc7mRellfiQkrQ8mE7ZRaB4eBpt1 X-Received: by 2002:ac8:5a93:0:b0:3f6:b505:ec94 with SMTP id c19-20020ac85a93000000b003f6b505ec94mr2122331qtc.17.1684769863647; Mon, 22 May 2023 08:37:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684769863; cv=none; d=google.com; s=arc-20160816; b=Lj8e5NaTGI4wAwFkKRpsdbadfsXMGu0vRD6uVJ8fiq3JZ+S7SlMDeCWnJTDDNos+iv cTWHdGWENlkYMEgirEa0fRxwNEextT1xDhhs1D9vyJvYxSPDIjU6M5vqG7AiNIHs4f2G 5Hgx+3yjTW9WTWi8n5uKVGxEqGYnIHV9RUS7Nbv7pL/AzUTTcLBCva0teTKnmRML8d/m Lb6MtPgwLVaFLhOZxhCme74OwdZbuFfGVUqlWLJ/fes64ZnU3KgLb6strrhcKENjj1+f pPVjVc8t7colYDqSQrn4qs7Hg1PfsuwWhxdxBU9HsYW36JBVg7/r2TNba2afZnIO0V7P jmMw== 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=zbYgJ/CF6X8oXk1c18I3fiTWkENuu1esnlnJzdOgw0U=; b=xo7phwQ++8oU+4Le+0S+FTE9WNJ1qEGj0PhL3tnV1a14yXo0fHAaBq/kcBYswo7L61 a/D7q1qsWTE18MFswyC0Up4f3yY9VnbobjTkr7QRPWhmixlLDk/0rb/Nu2qw64Us5G/h wyY87s+BlsI9HEVj13FgLBC+DBFLVP33wQXR6MsMvIyflab7c5Z3qL567ulM6V8T39fR QEHAY6nvxO4INQtl8BpOIkeZgeT+ysULWExadbX1O8cPhBscGcJEbNlqu7cVR958BV2D HaHufAzrnqTBNtXiYPD03yNVrM9upc1BI7nxDBcu7vGGX3BRDNkYv/J+1BF77SW+KOJT ecJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sQTsuO1+; 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 d8-20020a05622a100800b003ea63719f0fsi3751250qte.611.2023.05.22.08.37.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 May 2023 08:37: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=sQTsuO1+; 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 1q17Wd-0007bF-HK; Mon, 22 May 2023 11:32:43 -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 1q17Wc-0007Z7-6b for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:42 -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 1q17Wa-0001Tm-H5 for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:41 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3078d1c8828so5996737f8f.3 for ; Mon, 22 May 2023 08:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769558; x=1687361558; 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=zbYgJ/CF6X8oXk1c18I3fiTWkENuu1esnlnJzdOgw0U=; b=sQTsuO1+IR3wG1880nFla6zQQ4pT1gMu2cJlzad94PzBKPVJQZ1U+TWNTTNFvSXnEk S5E+9kvIAUfjTOolpryQJJLDJaL4mkJ5AK3rL5Gd1X3q+j1KYU/ivJH5OScWV+fEDSvv /IWAEWg/EpFl/t/nb1SmEBVCbuqMW7cEKesoiLB1uF1B2iJczBnDt+bzz3tBXpu0WM9R Thwuq0eIgb36ABh/BtBlJYuMSM+pYVEsjStML30tSr7ngWXXZ5tHnQB+z3Lx10VhZUW7 qhQylGRGA5IJT1WBRbw1Atx4k0whDA2qDQM7BrQiPDZfgDRkVNyylKwexiX121ORirQ2 v1Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769558; x=1687361558; 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=zbYgJ/CF6X8oXk1c18I3fiTWkENuu1esnlnJzdOgw0U=; b=MTXd2qiItqTS0RAUX8OxAPNCQ04yDqvtcL7BsUlQy+6G0W2WNhD9TwISwZhcXnlDbG ZidpUS+6Z/AmuH8udgdGt3QzEhbN6o/4R3W3c88XwftacositUZmRZa0N8FjVHbTMkP+ FtkGbg9FPA6PrrO/9ohd69n5V8u9jB+KidZY8uDOroTP8mNCFuo3Fr63syNfk+Lq7zP5 gs4tFeQSpPN3uvWALRqii6SaWTD4JvpiKO4itGLm7G54qBrQ1oe44yaRO/bHmBUpDwx3 8x48TEGEQcqg3FlGw1p3/AFacYBDwabzh8px9nJMxELeZ2OfI5uVs3jJQWsElM9b5mjz MaZw== X-Gm-Message-State: AC+VfDzEIkI85/82ONlsRa6awuJtExRCiHxTT883nnqw1gvM6FG5Qyjl yO+sxwTlJ/PPqOVcKzO8sLlpI47aATC/oOxW3ss= X-Received: by 2002:a5d:44cf:0:b0:309:54b6:33b0 with SMTP id z15-20020a5d44cf000000b0030954b633b0mr7758639wrr.44.1684769557960; Mon, 22 May 2023 08:32:37 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id f15-20020a0560001b0f00b00307acec258esm8082350wrz.3.2023.05.22.08.32.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:32:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , Evgeny Iakovlev , =?utf-8?q?Marc-Andr=C3=A9_?= =?utf-8?q?Lureau?= , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH 09/12] hw/char/pl011: Check if transmitter is enabled Date: Mon, 22 May 2023 17:31:41 +0200 Message-Id: <20230522153144.30610-10-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-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, 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 transmit characters when UART or transmitter are disabled. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- hw/char/pl011.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index c55ef41fbf..30bedeac15 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -76,6 +76,10 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) #define LCR_FEN (1 << 4) #define LCR_BRK (1 << 0) +/* Control Register, UARTCR */ +#define CR_TXE (1 << 8) +#define CR_UARTEN (1 << 0) + static const unsigned char pl011_id_arm[8] = { 0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0, 0x05, 0xb1 }; static const unsigned char pl011_id_luminary[8] = @@ -151,7 +155,9 @@ static inline void pl011_reset_tx_fifo(PL011State *s) static void pl011_write_tx(PL011State *s, const uint8_t *buf, int length) { - /* ??? Check if transmitter is enabled. */ + if (!(s->cr & (CR_UARTEN | CR_TXE))) { + return; + } /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */