From nobody Mon Apr 29 03:00:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630500656205421.43956077123244; Wed, 1 Sep 2021 05:50:56 -0700 (PDT) Received: from localhost ([::1]:47462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLPhf-0003dz-0g for importer@patchew.org; Wed, 01 Sep 2021 08:50:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLPcW-0003A8-8W; Wed, 01 Sep 2021 08:45:37 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:46856) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mLPcU-0003Xz-9v; Wed, 01 Sep 2021 08:45:36 -0400 Received: by mail-pf1-x431.google.com with SMTP id y17so1918856pfl.13; Wed, 01 Sep 2021 05:45:33 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d22sm20917134pfq.158.2021.09.01.05.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 05:45:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5t8z8W2/Z4HnNDfJxkUtulZXcpKeSL8+hbjbGr7gaxg=; b=WwfViySbJ2IQ1mlgtvxlqChgoPMo2TxSK1Hgfl2YeY2n+EMc66LZ6z1AJIlHFmlIdZ mZo1ecfGYvxhtg6tg3+UNE803JXMBQ2Q2ih5nZHl+nluSb3EaWNeDrQGFHonGxmF6lHk trdeQ1rtJKtJMnMDZ6HHDrkCnGnQJsdyQN2eSyahTaIEvoc27rDQDRU1fdZIuXNkaBu5 OYYddKv1NkHzOglW6dbDPb4jBar0v4nQewM0aZ++txvLZ6LAwJJkQSa7Qw7nlyKTEkWu TwbTUPTPSk81f9YETvbVdo8iCEt8iZ1E/A07l2B99DIK98js7Qp9CnKameRGGA21ELiM gxRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5t8z8W2/Z4HnNDfJxkUtulZXcpKeSL8+hbjbGr7gaxg=; b=rJl2bhFEtV3tMrqb05nTY571dpCBesJHP3E89D7qINBrsD35Bt1xEpXAgwD0OkooYK qVOOSMHzgKJKVi0V/TEQ3zuIvvCxNGKDg79YYrZvcQfM6lCea/jFHc0+SLwDztU16gz3 E1LEjuiPPzZyP9UPaRAfTijQhT//CMLQLyFYZzAsupXv5wZNHR8N+MzYDR+N3t9HcdmK h1oQBB9hP5OLQihjckkXiGRUMYyzXGgg+sdFsOccVrONnjt01OD/DL+NXf7s6oE9JKca 6BORi4KipQw04Ylnwhmv9xkD58x2F2fi7vGhS4QOhmTs+R8klepJte12pDUX20CMh1N0 dRrA== X-Gm-Message-State: AOAM530zSK+Lz/GVTr/ujA5qQTvAY2sSbSxUvczSmSo3pzmasenjG4sI wrg8yqQtBaoELAEFjwZnVzM= X-Google-Smtp-Source: ABdhPJzLtPGb66i6tkQJjBENPgdT/h3/yD6rTGxMUfbD8GZpgN/A4VGPJL0Y7I5u49tMEXIbTHCLlg== X-Received: by 2002:a62:a513:0:b0:3f1:e19c:a23 with SMTP id v19-20020a62a513000000b003f1e19c0a23mr23555442pfm.43.1630500332170; Wed, 01 Sep 2021 05:45:32 -0700 (PDT) From: Bin Meng To: Damien Hedde , "Edgar E . Iglesias" , Alistair Francis , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 1/6] hw/misc: zynq_slcr: Correctly compute output clocks in the reset exit phase Date: Wed, 1 Sep 2021 20:45:16 +0800 Message-Id: <20210901124521.30599-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210901124521.30599-1-bmeng.cn@gmail.com> References: <20210901124521.30599-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x431.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, FREEMAIL_FROM=0.001, 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: , Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630500657283100001 Content-Type: text/plain; charset="utf-8" As of today, when booting upstream U-Boot for Xilinx Zynq, the UART does not receive anything. Debugging shows that the UART input clock frequency is zero which prevents the UART from receiving anything as per the logic in uart_receive(). From zynq_slcr_reset_exit() comment, it intends to compute output clocks according to ps_clk and registers. zynq_slcr_compute_clocks() is called to accomplish the task, inside which device_is_in_reset() is called to actually make the attempt in vain. Rework reset_hold() and reset_exit() so that in the reset exit phase, the logic can really compute output clocks in reset_exit(). With this change, upstream U-Boot boots properly again with: $ qemu-system-arm -M xilinx-zynq-a9 -m 1G -display none -serial null -seria= l stdio \ -device loader,file=3Du-boot-dtb.bin,addr=3D0x4000000,cpu-num=3D0 Fixes: 38867cb7ec90 ("hw/misc/zynq_slcr: add clock generation for uarts") Signed-off-by: Bin Meng Acked-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- (no changes since v1) hw/misc/zynq_slcr.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/hw/misc/zynq_slcr.c b/hw/misc/zynq_slcr.c index 5086e6b7ed..8b70285961 100644 --- a/hw/misc/zynq_slcr.c +++ b/hw/misc/zynq_slcr.c @@ -269,6 +269,21 @@ static uint64_t zynq_slcr_compute_clock(const uint64_t= periods[], zynq_slcr_compute_clock((plls), (state)->regs[reg], \ reg ## _ ## enable_field ## _SHIFT) =20 +static void zynq_slcr_compute_clocks_internal(ZynqSLCRState *s, uint64_t p= s_clk) +{ + uint64_t io_pll =3D zynq_slcr_compute_pll(ps_clk, s->regs[R_IO_PLL_CTR= L]); + uint64_t arm_pll =3D zynq_slcr_compute_pll(ps_clk, s->regs[R_ARM_PLL_C= TRL]); + uint64_t ddr_pll =3D zynq_slcr_compute_pll(ps_clk, s->regs[R_DDR_PLL_C= TRL]); + + uint64_t uart_mux[4] =3D {io_pll, io_pll, arm_pll, ddr_pll}; + + /* compute uartX reference clocks */ + clock_set(s->uart0_ref_clk, + ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT0)); + clock_set(s->uart1_ref_clk, + ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT1)); +} + /** * Compute and set the ouputs clocks periods. * But do not propagate them further. Connected clocks @@ -283,17 +298,7 @@ static void zynq_slcr_compute_clocks(ZynqSLCRState *s) ps_clk =3D 0; } =20 - uint64_t io_pll =3D zynq_slcr_compute_pll(ps_clk, s->regs[R_IO_PLL_CTR= L]); - uint64_t arm_pll =3D zynq_slcr_compute_pll(ps_clk, s->regs[R_ARM_PLL_C= TRL]); - uint64_t ddr_pll =3D zynq_slcr_compute_pll(ps_clk, s->regs[R_DDR_PLL_C= TRL]); - - uint64_t uart_mux[4] =3D {io_pll, io_pll, arm_pll, ddr_pll}; - - /* compute uartX reference clocks */ - clock_set(s->uart0_ref_clk, - ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT0)); - clock_set(s->uart1_ref_clk, - ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT1)); + zynq_slcr_compute_clocks_internal(s, ps_clk); } =20 /** @@ -416,7 +421,7 @@ static void zynq_slcr_reset_hold(Object *obj) ZynqSLCRState *s =3D ZYNQ_SLCR(obj); =20 /* will disable all output clocks */ - zynq_slcr_compute_clocks(s); + zynq_slcr_compute_clocks_internal(s, 0); zynq_slcr_propagate_clocks(s); } =20 @@ -425,7 +430,7 @@ static void zynq_slcr_reset_exit(Object *obj) ZynqSLCRState *s =3D ZYNQ_SLCR(obj); =20 /* will compute output clocks according to ps_clk and registers */ - zynq_slcr_compute_clocks(s); + zynq_slcr_compute_clocks_internal(s, clock_get(s->ps_clk)); zynq_slcr_propagate_clocks(s); } =20 --=20 2.25.1 From nobody Mon Apr 29 03:00:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630501013311207.76359192060454; Wed, 1 Sep 2021 05:56:53 -0700 (PDT) Received: from localhost ([::1]:37898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLPnQ-0007q3-7F for importer@patchew.org; Wed, 01 Sep 2021 08:56:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLPcX-0003AV-Ly; Wed, 01 Sep 2021 08:45:37 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:41546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mLPcW-0003Yz-9G; Wed, 01 Sep 2021 08:45:37 -0400 Received: by mail-pg1-x52e.google.com with SMTP id k24so2640252pgh.8; Wed, 01 Sep 2021 05:45:35 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d22sm20917134pfq.158.2021.09.01.05.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 05:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DnvfBbmV9W5QaBw9cjpxj3O1smfoTH7OnL+gTgkQoPM=; b=PrXqoLkmgqlYKDP1yselvjxX21JW2Feqa0TQbp0UW15DoRC6UHK/Hk101BYO/Yit6j 7gPdgMWGglTINLL41sSA5Q7v0opuqWAsQ/9hDY/Ho6YLtU+jDGwq79x4tS2BpDdyIxVw ccqYvCfmf0zNbT7c60bAhOj+7OPsvRmc/sGx/+luw9so5IFTkq7ZoQEVDzyH2X9BQW9g I39EEAO7qPUgqAZ1ejHokptJ/04jhZfFh2t6LEZLPcjcS4mwqxXwXQz3IgGXF0tcJM9v Higyl8IylrOI4rucNOBuiF+D9P5DgyjXGAjrYioqOxkkmnWNbDZpc/RXJDfHX4QNW3k+ CF2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DnvfBbmV9W5QaBw9cjpxj3O1smfoTH7OnL+gTgkQoPM=; b=LdF2XqYJEbAVfGouGFSD5j1/bZE857XEx36vsw6DWNBCo3FWFMFE+/9TfpDwexZ+HL HnFX2qHWe62Xhd4TvkNyW4Fb5zUqdlciApqEci6RATqMiNP2FGHvh4tw3nRP0Pj03oJ6 q3HxAHSUXOaaCZsEiJBN4RvgSkZXaRAXUWrdEOOAIb6afRJbU+yjbNAlxHSRuQ9HrXDe eWmfWkt/HAgccRWQuGVYO5KwE+XZ6msGdSQ0rVlAZSDiFIseCY10lqr7y0v8jWjb6fCU NZX2NLHVInvYEHN7iGE/wwFnFSR+jxW7F7neISaExWOxgsOP0VixGEuU+gT3FHW5eKle +Sxw== X-Gm-Message-State: AOAM530kChZyJiR1bNHnQLhwuuElnRDQv4dt+3cC5ChB4gnF7sSJMKDk EXZ4gQcLi/aLVx2ZayLpod8= X-Google-Smtp-Source: ABdhPJwi9mhCAN2pytFo3zDVDlBzAlWwSjeJ5GbszmrM99eZj6apgvQwlbfEePMa8wotoNNZJA27ZQ== X-Received: by 2002:aa7:9086:0:b029:39b:6377:17c1 with SMTP id i6-20020aa790860000b029039b637717c1mr33987450pfa.11.1630500334785; Wed, 01 Sep 2021 05:45:34 -0700 (PDT) From: Bin Meng To: Damien Hedde , "Edgar E . Iglesias" , Alistair Francis , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 2/6] hw/char: cadence_uart: Disable transmit when input clock is disabled Date: Wed, 1 Sep 2021 20:45:17 +0800 Message-Id: <20210901124521.30599-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210901124521.30599-1-bmeng.cn@gmail.com> References: <20210901124521.30599-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x52e.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, FREEMAIL_FROM=0.001, 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: , Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630501014328100001 Content-Type: text/plain; charset="utf-8" At present when input clock is disabled, any character transmitted to tx fifo can still show on the serial line, which is wrong. Fixes: b636db306e06 ("hw/char/cadence_uart: add clock support") Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- (no changes since v1) hw/char/cadence_uart.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index b4b5e8a3ee..154be34992 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -327,6 +327,11 @@ static gboolean cadence_uart_xmit(void *do_not_use, GI= OCondition 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; } --=20 2.25.1 From nobody Mon Apr 29 03:00:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630500675749571.1197965912035; Wed, 1 Sep 2021 05:51:15 -0700 (PDT) Received: from localhost ([::1]:49210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLPhy-0004os-OF for importer@patchew.org; Wed, 01 Sep 2021 08:51:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLPca-0003KB-PL; Wed, 01 Sep 2021 08:45:40 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:39701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mLPcZ-0003aU-6d; Wed, 01 Sep 2021 08:45:40 -0400 Received: by mail-pf1-x42b.google.com with SMTP id e16so1952963pfc.6; Wed, 01 Sep 2021 05:45:38 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d22sm20917134pfq.158.2021.09.01.05.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 05:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ev+aq0JxPAo6o7UOcP7jbXTgregVlkRbo8hoXTI7T1k=; b=baOT5eMEWdfO8bzuyV5Cu8ZmkQoATFMAV9NQU7vHMifn/T8HYLmyOcNsoy0jUsrCjT oa1meNceuZrW8mK4j7BszhLFiNWGVHDpoH5bx1Od5QiOJKxH3iW000isFBz63qOLolro Nwf/LatDNra7uPs2s5JgOzaxD4q9NU+0d2NJofAcDf/tvWC9ObAeSExwoG6JLS5niVRd rdszH87qjkAl+Cg2V7LDR7O1qGk52pKpieA+vwuuq8GhcW3gN7GEL0M/kdqE1XY5Zijj GUCyDLgZNMUujo7k4jHtbM/3PlFxWzQPebSbWy6TZhMCWGbjqykJHlsqA9jivw8zZ3tg WigA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ev+aq0JxPAo6o7UOcP7jbXTgregVlkRbo8hoXTI7T1k=; b=i0Uqe8QzCk6xsqW5pn4m4nwOdcTSbQ/HJ1uK8Z0b1ui6sjhmd1Bk+9G9lQfpshvjDm g7Lzckbf5uMbGlUVETvtDDO2LhZae49+9ntE5DjwCBjj9zNSIvOLBC1jE5RFVvvsZ+A+ VTgBP11Fy4QSZRMseraBYz5f73KB+JpfICW3Ps3Bzxj3MQLBn28NjwEKq3xfyWISuX3g qyyj3IF6vk4aSf6E++bSB0GtLimjb7/YwS/5smlSzceCSR4sZF7lsGLsgP2nwrgQWySa NEc4uFFxQKN9H3Hk9bnHDvY0ZTWBm3/a+3XkOi8XiBE6Pynd8KUgnfNtpwDO92DFurj1 /vsQ== X-Gm-Message-State: AOAM53287boCqZTMbt603HchuwJd9EjO6coCKISrW6Xc2uGLuXVcVR5i d1S9ly2fcMJbzejZ41AHYpQurQntq4zUaQ== X-Google-Smtp-Source: ABdhPJwGBh7YtMPkFNFC69GuhDZJ1Omi0DhfsuvxoHXpA1tIcAykgrxHjC6aQxCk+cJYVEyCoXgezg== X-Received: by 2002:a63:fd12:: with SMTP id d18mr32166158pgh.129.1630500337499; Wed, 01 Sep 2021 05:45:37 -0700 (PDT) From: Bin Meng To: Damien Hedde , "Edgar E . Iglesias" , Alistair Francis , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 3/6] hw/char: cadence_uart: Move clock/reset check to uart_can_receive() Date: Wed, 1 Sep 2021 20:45:18 +0800 Message-Id: <20210901124521.30599-4-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210901124521.30599-1-bmeng.cn@gmail.com> References: <20210901124521.30599-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x42b.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, FREEMAIL_FROM=0.001, 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: , Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630500677648100001 Content-Type: text/plain; charset="utf-8" Currently the clock/reset check is done in uart_receive(), but we can move the check to uart_can_receive() which is earlier. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- (no changes since v2) Changes in v2: - avoid declaring variables mid-scope hw/char/cadence_uart.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 154be34992..fff8be3619 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -235,8 +235,16 @@ static void uart_parameters_setup(CadenceUARTState *s) static int uart_can_receive(void *opaque) { CadenceUARTState *s =3D opaque; - int ret =3D MAX(CADENCE_UART_RX_FIFO_SIZE, CADENCE_UART_TX_FIFO_SIZE); - uint32_t ch_mode =3D s->r[R_MR] & UART_MR_CHMODE; + int ret; + uint32_t ch_mode; + + /* ignore characters when unclocked or in reset */ + if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { + return 0; + } + + ret =3D MAX(CADENCE_UART_RX_FIFO_SIZE, CADENCE_UART_TX_FIFO_SIZE); + ch_mode =3D s->r[R_MR] & UART_MR_CHMODE; =20 if (ch_mode =3D=3D NORMAL_MODE || ch_mode =3D=3D ECHO_MODE) { ret =3D MIN(ret, CADENCE_UART_RX_FIFO_SIZE - s->rx_count); @@ -358,11 +366,6 @@ static void uart_receive(void *opaque, const uint8_t *= buf, int size) CadenceUARTState *s =3D opaque; uint32_t ch_mode =3D s->r[R_MR] & UART_MR_CHMODE; =20 - /* ignore characters when unclocked or in reset */ - if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { - return; - } - if (ch_mode =3D=3D NORMAL_MODE || ch_mode =3D=3D ECHO_MODE) { uart_write_rx_fifo(opaque, buf, size); } --=20 2.25.1 From nobody Mon Apr 29 03:00:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630500461751391.9014264513054; Wed, 1 Sep 2021 05:47:41 -0700 (PDT) Received: from localhost ([::1]:38150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLPeW-0005mi-Nj for importer@patchew.org; Wed, 01 Sep 2021 08:47:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39670) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLPcd-0003Rh-3G; Wed, 01 Sep 2021 08:45:43 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]:33587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mLPcb-0003b2-Ix; Wed, 01 Sep 2021 08:45:42 -0400 Received: by mail-pf1-x432.google.com with SMTP id u6so1999543pfi.0; Wed, 01 Sep 2021 05:45:40 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d22sm20917134pfq.158.2021.09.01.05.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 05:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L07n8zX3R8GaFuJBCKEivKi6SKW1wli53ep7Q/Pq37k=; b=pwnSenhhI4iiB7KGYPoIfpziezgnieKsDSACMP2F7Qu5t25C6ERg3C4k6hTGOJySyf E2YQRlNo5ZpphPZ/L06EuAZGtfNMaqpfi8WiMCsTGHnWJEvSqjB1bF8diwPkux0afbCe xGLhaMD8b1KLB2dWqOX09oz+3MC4rsfLkofPoKAqQ7bMJf/g+h6SdhHaWdbdOUTccxPT 4t34CApThERdRcY2cM5crwOXTNBW9Yz/X0I/I2EozeNk+CONwzuc+D45saGpX4t9n4GO roeA/fDFUTG+I+18Ud0OXAYG93edIW5603zwdlJ1UpqgRZsHmXT+BtW0/zfGxlDMCLOA 5MKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L07n8zX3R8GaFuJBCKEivKi6SKW1wli53ep7Q/Pq37k=; b=qsfu3wTe5SFN1C/HC+KwGhQSJYDdCEgfrwzU/NctpNzNPhDEWmc3LErVLSaaLZBWmt FJ1OhjvPQunVH4A0TzXUFVOWZ1UBp0lx9LOB363tgHvzuWmwBQ4nbeUfNKdhIFhZhBlo 6j5VbquFr3OcPbBtmXpaCeIH+scUHXe6R9Sv95oeFL8Vw6i8r5li43Riq4Rgrm6DM4uP ZT12L0O1plaYHmQO6hU9YPZJUk3fIDMEhUSxlNse6HTKIOt8SjFwniYZjhULesXU0ANw gS3pBVuAou6+WEj5sD2xfwRmi9fHx5bJm+TnZ9nTMxy7IOHTOIgu7jM25Gd7AHH2l/PE V7Xg== X-Gm-Message-State: AOAM531EX8hz1HVh+CqUutjThj1Ki8JNroDffauklWhKNhAAoZs9U/3l u8W9gPEqlUQPI45hPg5aHB2FjnDC5JJ9Rw== X-Google-Smtp-Source: ABdhPJxqq99grwyCFRq/zmHpXkCvhTNre1lZ+kWFxY531yYu3iCI4y4NnZKxkfToFV1jNkfYSA3Jgg== X-Received: by 2002:a62:ea06:0:b0:3e1:62a6:95b8 with SMTP id t6-20020a62ea06000000b003e162a695b8mr34188875pfh.70.1630500340059; Wed, 01 Sep 2021 05:45:40 -0700 (PDT) From: Bin Meng To: Damien Hedde , "Edgar E . Iglesias" , Alistair Francis , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 4/6] hw/char: cadence_uart: Convert to memop_with_attrs() ops Date: Wed, 1 Sep 2021 20:45:19 +0800 Message-Id: <20210901124521.30599-5-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210901124521.30599-1-bmeng.cn@gmail.com> References: <20210901124521.30599-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x432.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, FREEMAIL_FROM=0.001, 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: , Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630500462808100005 Content-Type: text/plain; charset="utf-8" This converts uart_read() and uart_write() to memop_with_attrs() ops. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- (no changes since v2) Changes in v2: - new patch: hw/char: cadence_uart: Convert to memop_with_attrs() ops hw/char/cadence_uart.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index fff8be3619..8bcf2b718a 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -411,15 +411,15 @@ static void uart_read_rx_fifo(CadenceUARTState *s, ui= nt32_t *c) uart_update_status(s); } =20 -static void uart_write(void *opaque, hwaddr offset, - uint64_t value, unsigned size) +static MemTxResult uart_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size, MemTxAttrs at= trs) { CadenceUARTState *s =3D opaque; =20 DB_PRINT(" offset:%x data:%08x\n", (unsigned)offset, (unsigned)value); offset >>=3D 2; if (offset >=3D CADENCE_UART_R_MAX) { - return; + return MEMTX_DECODE_ERROR; } switch (offset) { case R_IER: /* ier (wts imr) */ @@ -466,30 +466,34 @@ static void uart_write(void *opaque, hwaddr offset, break; } uart_update_status(s); + + return MEMTX_OK; } =20 -static uint64_t uart_read(void *opaque, hwaddr offset, - unsigned size) +static MemTxResult uart_read(void *opaque, hwaddr offset, + uint64_t *value, unsigned size, MemTxAttrs at= trs) { CadenceUARTState *s =3D opaque; uint32_t c =3D 0; =20 offset >>=3D 2; if (offset >=3D CADENCE_UART_R_MAX) { - c =3D 0; - } else if (offset =3D=3D R_TX_RX) { + return MEMTX_DECODE_ERROR; + } + if (offset =3D=3D R_TX_RX) { uart_read_rx_fifo(s, &c); } else { - c =3D s->r[offset]; + c =3D s->r[offset]; } =20 DB_PRINT(" offset:%x data:%08x\n", (unsigned)(offset << 2), (unsigned)= c); - return c; + *value =3D c; + return MEMTX_OK; } =20 static const MemoryRegionOps uart_ops =3D { - .read =3D uart_read, - .write =3D uart_write, + .read_with_attrs =3D uart_read, + .write_with_attrs =3D uart_write, .endianness =3D DEVICE_NATIVE_ENDIAN, }; =20 --=20 2.25.1 From nobody Mon Apr 29 03:00:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163050062364325.21375195233793; Wed, 1 Sep 2021 05:50:23 -0700 (PDT) Received: from localhost ([::1]:46000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLPh8-0002f3-HO for importer@patchew.org; Wed, 01 Sep 2021 08:50:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLPcf-0003bX-Pz; Wed, 01 Sep 2021 08:45:45 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:42619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mLPce-0003cJ-79; Wed, 01 Sep 2021 08:45:45 -0400 Received: by mail-pl1-x630.google.com with SMTP id n4so1413021plh.9; Wed, 01 Sep 2021 05:45:43 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d22sm20917134pfq.158.2021.09.01.05.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 05:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iwqv3rn3ZLXoG5hEsp2R8ezKy0ImKKf4Ph1gMyrL2HU=; b=domoZ+gyU3iQRlpMhIMhkYEPtPnqY56xMUVABpdsa9dcVfv6PcFR56tqbFzZUrEVd+ gQwSezynAPDTrGGhqFcuAZwYCWWsjXFmcCYLAejzGznnyVN54Ru9c/ffEkgD8lvN5kGV BXKWyyjWNma7y5firYQ01l0kllsGKZ1ANZ0hjC6Ogdzpvvz424K8u1UKR+VvSJllzpZf xqoiTatwKwdpyfa1ILdQrWbKDJRSmYUPrq0xkiqwFY7GcA37ovAuNhsvIMX6kTXppk74 F/GQ5+SEHvF6hm6INv5ipU0de/H5cECyFCuwEVxlhW6g1cBzGsNx2GmA/ArBFrpb7bsU IQvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iwqv3rn3ZLXoG5hEsp2R8ezKy0ImKKf4Ph1gMyrL2HU=; b=nMxQBKJEOB+AtXiKwQHQphOYyq0eg+2KRNnXpn+8h3RigQcj3J4AE6dIFLZTAzGIl9 4Dfhy9TtsVu6vukRfjHNLHtX2MP4Hyy7aH+N3vMUjhGIUs0pi8upQPoHxt/VPi4SF8Z4 vatlJdVQzjZOBJWMQ+ZoZr0kcLUqFFZsxKej/Fxe7DpYKLDL/UWGRRwoj4V+PBEYGqvB a523H3n6oXUMHQvCLJw2XjVByEnN5d2ixp9x+M1V1GskIQaDqw1yUHGhAknm4zhJ5fkq Y9wOi7AFO8HCVsS6m388anABn8PTwtAwTFgzrh4ywLVU8sQ5WuASe5mkAv2rbxFYJnbN T+fw== X-Gm-Message-State: AOAM530CCHkR4TuMaaANSOzm5v66d9CnQpiN9eDBTWH6jIFnNonz5QY7 DrIUstPNzHIob0wX0sC4WtY= X-Google-Smtp-Source: ABdhPJwBzNWT36PnD/YNPN+lN7hTmmHK2HqKdc5I+wTpQtm6SF+KXixTRtwpLuYnVrAFf1Q56z9qYw== X-Received: by 2002:a17:90a:af92:: with SMTP id w18mr11348401pjq.98.1630500342574; Wed, 01 Sep 2021 05:45:42 -0700 (PDT) From: Bin Meng To: Damien Hedde , "Edgar E . Iglesias" , Alistair Francis , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 5/6] hw/char: cadence_uart: Ignore access when unclocked or in reset for uart_{read, write}() Date: Wed, 1 Sep 2021 20:45:20 +0800 Message-Id: <20210901124521.30599-6-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210901124521.30599-1-bmeng.cn@gmail.com> References: <20210901124521.30599-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x630.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, FREEMAIL_FROM=0.001, 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: , Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630500625357100003 Content-Type: text/plain; charset="utf-8" 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: Alistair Francis Reviewed-by: Edgar E. Iglesias --- (no changes since v2) Changes in v2: - new patch: hw/char: cadence_uart: Ignore access when unclocked or in rese= t for uart_{read,write}() hw/char/cadence_uart.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 8bcf2b718a..5f5a4645ac 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, GI= OCondition 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 off= set, { CadenceUARTState *s =3D opaque; =20 + /* 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 >>=3D 2; if (offset >=3D CADENCE_UART_R_MAX) { @@ -476,6 +476,11 @@ static MemTxResult uart_read(void *opaque, hwaddr offs= et, CadenceUARTState *s =3D opaque; uint32_t c =3D 0; =20 + /* ignore access when unclocked or in reset */ + if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { + return MEMTX_ERROR; + } + offset >>=3D 2; if (offset >=3D CADENCE_UART_R_MAX) { return MEMTX_DECODE_ERROR; --=20 2.25.1 From nobody Mon Apr 29 03:00:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630500862175640.7711525350569; Wed, 1 Sep 2021 05:54:22 -0700 (PDT) Received: from localhost ([::1]:58866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLPkz-0002rZ-5N for importer@patchew.org; Wed, 01 Sep 2021 08:54:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLPci-0003jA-4o; Wed, 01 Sep 2021 08:45:48 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:39709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mLPcg-0003ge-LG; Wed, 01 Sep 2021 08:45:47 -0400 Received: by mail-pf1-x433.google.com with SMTP id e16so1953240pfc.6; Wed, 01 Sep 2021 05:45:45 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d22sm20917134pfq.158.2021.09.01.05.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 05:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0+KB8VLhpjDCIb3k+XnxOMKOakzrhTJnwW420hgy2YA=; b=RO630i0c4UDvUHAZSkxa0pOSVXjJUThL3Hyu+OUN7brYuo9Jqz7YAAE3FGZp1VRP7D ESPg08odxk9ypns5U/F8qejexBpcM7Wcpy9UwxM8r1mvupm2cJKLZB0lqZslyKTVnRiu 7YpMqSsK+86d9ecfHQJ4IXjvZuBEEKdyAUHiCb9WH/nC3ZSb6/yjt5zLNDBhm0hBdi7Q u4YKqZ8jh5uuEhuevrWKS4Eh4M9UZbqx8PEZYaNg77+aPfI0crAQnoR0UHZaYhxP7NO/ MVDC0sm+SknNlkm2umscYZ1j4xCYG1IMrKP6ZxqZiE6zK7cpI2yGQaGH+GGbZrIvx8Cv QdCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0+KB8VLhpjDCIb3k+XnxOMKOakzrhTJnwW420hgy2YA=; b=hQRFyoXBzkTReTTCQzZuKeBA8nMBwfmdYniSC7uXDyJiExDyhIeDNLFKDwnRynjI/I hC3sNUQPf458TbTtt+LyGP1KFqWIKSmQMvs6cvZ48B2Tug+48BPFvoqUF83WQXHKoA/o 3W7daS4tBXMlWpwrFFWSz603bmaBonnBXdV0RzjzDXSsms2eFjsJwl2Ez21QWQx7Zzc4 zJ/TDGomzyNG4lJfO4u+52mAl6XYcyjxd3omBxUQWnkJ4VUHfC+YGOcWA4yahJo6i/aG hIiO3YmY9hx93F5vxtHwaRI/wttdj6Dt5H/CbkfEDGhUT8E8f0etKhrxBhGKAn5RzzgC MYZg== X-Gm-Message-State: AOAM531SXaqpg6C9HT4Y+XKqmeNXqWSCQ0Sb/Dn7FNNoxC/06TDeWOU4 DNRkMXLdihP9RDeztxfDMKE= X-Google-Smtp-Source: ABdhPJyKZ05wrtPKAXd372pjRGvQVa2DCd4nspCR55QBtCXfAFwYNxZAxKiq2/a0Ekb00lJHkrAkJA== X-Received: by 2002:aa7:8d4e:0:b0:3fd:b14b:950a with SMTP id s14-20020aa78d4e000000b003fdb14b950amr17922569pfe.26.1630500345130; Wed, 01 Sep 2021 05:45:45 -0700 (PDT) From: Bin Meng To: Damien Hedde , "Edgar E . Iglesias" , Alistair Francis , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 6/6] hw/char: cadence_uart: Log a guest error when device is unclocked or in reset Date: Wed, 1 Sep 2021 20:45:21 +0800 Message-Id: <20210901124521.30599-7-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210901124521.30599-1-bmeng.cn@gmail.com> References: <20210901124521.30599-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x433.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, FREEMAIL_FROM=0.001, 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: , Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630500862599100001 Content-Type: text/plain; charset="utf-8" We've got SW that expects FSBL (Bootlooader) to setup clocks and resets. It's quite common that users run that SW on QEMU without FSBL (FSBL typically requires the Xilinx tools installed). That's fine, since users can stil use -device loader to enable clocks etc. To help folks understand what's going, a log (guest-error) message would be helpful here. In particular with the serial port since things will go very quiet if they get things wrong. Suggested-by: Edgar E. Iglesias Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- Changes in v3: - new patch: hw/char: cadence_uart: Log a guest error when unclocked or in = reset hw/char/cadence_uart.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 5f5a4645ac..c069a30842 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -240,6 +240,8 @@ static int uart_can_receive(void *opaque) =20 /* ignore characters when unclocked or in reset */ if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: uart is unclocked or in reset\= n", + __func__); return 0; } =20 @@ -376,6 +378,8 @@ static void uart_event(void *opaque, QEMUChrEvent event) =20 /* ignore characters when unclocked or in reset */ if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: uart is unclocked or in reset\= n", + __func__); return; } =20 @@ -413,6 +417,8 @@ static MemTxResult uart_write(void *opaque, hwaddr offs= et, =20 /* ignore access when unclocked or in reset */ if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: uart is unclocked or in reset\= n", + __func__); return MEMTX_ERROR; } =20 @@ -478,6 +484,8 @@ static MemTxResult uart_read(void *opaque, hwaddr offse= t, =20 /* ignore access when unclocked or in reset */ if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: uart is unclocked or in reset\= n", + __func__); return MEMTX_ERROR; } =20 --=20 2.25.1