From patchwork Mon Sep 13 16:11:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 509800 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp702480jao; Mon, 13 Sep 2021 09:15:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLXn/HfDyJZEb7GEK84AKX5MIgo8YsStA7h5T0c7FG1oTP0WkUGevth46hD9IweGouCtlt X-Received: by 2002:a1c:f606:: with SMTP id w6mr12046634wmc.42.1631549701409; Mon, 13 Sep 2021 09:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631549701; cv=none; d=google.com; s=arc-20160816; b=gFQcVRgo30o+m4r/rGKJfHXDlofE40FaC7TGPksVwbFctDONpYnEJqR/oKrw+s60jz 1BI3MAr8FoWHBSWirz+FJOMrr7kdyvyuc7jB9UYYEQuXsxO6CXopsxk1lY+UGnzldlsI FcKmeBS5YKr4G6EOUp1Jz8YjzVG2H7k5nQPRE/IMBoclNn4Arhr3YZK7Pb9vdLEUgMJv myDFubA8HkiHzNAMoPH2xvldLzpuj0yxjw45WxdC5NiIxWB7yW8uGCrghRtM4910KMtx vdLrFXeroxGm7RtEodzqcgkwxaybQOHMN6tUbJv+cnppJ1O0irhZUGd8X/8nvM1hZQ9q kYoA== 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:to:from :dkim-signature; bh=KUKdUJ0N5EPE3TGaxGcZDbPbShFxk6EWZr/urNOByoM=; b=0SmOvt6gnk+MyzboH5f51lN/xvcbGX4lp/d0tQzg6poDuT77NCwDURu4DP1Lxyo+te srDotgreiToyCVz103bkRH3xbtPWhcgc5gtzEDm28RgaqVXhVXOvX9PgL5QCjH4yuAHR xnIoqJ1Ucwbn+28Acv/lhw4iJbgKlM0fTUBaHPTeyx2DCcFEy0fiJbjtSF+A2jGyb7lc XXhbtE1wUZlO8SJp7yrXlJNsdOMrQaffBW7n81ORqF3p27cGYhag16sy0lZ+7OuxbsOh a81iKW3KGkfa7uJtAJikl8MGxRzE+cpP2B86RrWufEtlMJCMXSF5AC1aK/yHp743ta/Z ZHcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rCA9PptD; 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 q4si7929366wrm.41.2021.09.13.09.15.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Sep 2021 09:15:01 -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=rCA9PptD; 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]:59066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPobk-0003sR-Fh for patch@linaro.org; Mon, 13 Sep 2021 12:15:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPoYj-0000kb-Ix for qemu-devel@nongnu.org; Mon, 13 Sep 2021 12:11:53 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:43775) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mPoYh-00083q-G7 for qemu-devel@nongnu.org; Mon, 13 Sep 2021 12:11:53 -0400 Received: by mail-wm1-x336.google.com with SMTP id n7-20020a05600c3b8700b002f8ca941d89so361477wms.2 for ; Mon, 13 Sep 2021 09:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=KUKdUJ0N5EPE3TGaxGcZDbPbShFxk6EWZr/urNOByoM=; b=rCA9PptDsj6wyPSij58a7/BOf0N5EmfJ9ttee7xMrTrPLMJ4YZiOZ1JNR3WzTqzwq8 8lJDVKOS2CFtCHT8DL7xzbWQ6OiYlUqo0q14qndy9ANHo8TEJRHls2CKMcmUMILlHzCY 3cnmHATePWxnk6TpJqzSftFlZH8m0Ru/FgE2wW5D9ScJTpv8ZOnpoZ4tH2yI5u+2/yh+ +b9avvt5LzrIF/sEYRYabLfxfAmZ8o8v7+mDlvR0aYox8IEcyQfiyBTvxXYtvJpgaIhE 2Nx2fpus8OXDUHdfuEA4OiVMSW09IRSXLhVgD1CbsWVqdHDocnAfJ+JHIClan5eHQnO0 DViQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KUKdUJ0N5EPE3TGaxGcZDbPbShFxk6EWZr/urNOByoM=; b=O8ptEIrAh3U5TFaV2KAf83rTrGL7qVIl93xpkVKqJWqZazcNbQt4HEWLRwSnwP1Nla ociV7VVjttSupd7GYivdK19Xwi9NWkhqOAcr7weR1PcioFpIZ2oI4qUD3GAlsYH4Lqin kKVipn/TEKoVUefr9x/txYMAsFMej9WswV16gJM+pxFAntBVWVsiK+aeXZb8+apucYVc Uc+0PA2/DeDzEzo+xHsq+MrjFWgFwI4ZsmI5Y/bBtwnMUZTHl7v3nZMIKfsmQ1tLqAZl f0hQtWWeFnwi+/3WmA43R4tmoxbqDKkTNrAymFnPFjpvmTBIcjr57SlM9wgiYRuaDfyJ pbRQ== X-Gm-Message-State: AOAM532nJYA6itGHcoCzrwj+kyoQ1Jc5kfxJBb5Tyirvq7rt0tzrpJZJ 6FZRQcmFUWao2qfwE2Qzo0vuPggGtYexDg== X-Received: by 2002:a1c:2943:: with SMTP id p64mr11949971wmp.107.1631549510154; Mon, 13 Sep 2021 09:11:50 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y1sm7629265wmq.43.2021.09.13.09.11.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 09:11:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 05/23] hw/char: cadence_uart: Ignore access when unclocked or in reset for uart_{read, write}() Date: Mon, 13 Sep 2021 17:11:26 +0100 Message-Id: <20210913161144.12347-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210913161144.12347-1-peter.maydell@linaro.org> References: <20210913161144.12347-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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.23 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" From: Bin Meng Read or write to uart registers when unclocked or in reset should be ignored. Add the check there, and as a result of this, the check in uart_write_tx_fifo() is now unnecessary. Signed-off-by: Bin Meng Reviewed-by: Edgar E. Iglesias Reviewed-by: Alistair Francis Message-id: 20210901124521.30599-6-bmeng.cn@gmail.com Signed-off-by: Peter Maydell --- hw/char/cadence_uart.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 8bcf2b718a0..5f5a4645ac0 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -335,11 +335,6 @@ static gboolean cadence_uart_xmit(void *do_not_use, GIOCondition cond, static void uart_write_tx_fifo(CadenceUARTState *s, const uint8_t *buf, int size) { - /* ignore characters when unclocked or in reset */ - if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { - return; - } - if ((s->r[R_CR] & UART_CR_TX_DIS) || !(s->r[R_CR] & UART_CR_TX_EN)) { return; } @@ -416,6 +411,11 @@ static MemTxResult uart_write(void *opaque, hwaddr offset, { CadenceUARTState *s = opaque; + /* ignore access when unclocked or in reset */ + if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { + return MEMTX_ERROR; + } + DB_PRINT(" offset:%x data:%08x\n", (unsigned)offset, (unsigned)value); offset >>= 2; if (offset >= CADENCE_UART_R_MAX) { @@ -476,6 +476,11 @@ static MemTxResult uart_read(void *opaque, hwaddr offset, CadenceUARTState *s = opaque; uint32_t c = 0; + /* ignore access when unclocked or in reset */ + if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { + return MEMTX_ERROR; + } + offset >>= 2; if (offset >= CADENCE_UART_R_MAX) { return MEMTX_DECODE_ERROR;