From nobody Tue Sep 9 21:40:10 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1757114874; cv=none; d=zohomail.com; s=zohoarc; b=bwX52st5shCZnAOHOcztmoS2bu8sSzqwnMtqubOIearwpSKCrje2UIp7Dlr2k4kTCZItrtohSrpCXqEzOH0bzp2WfvIq5HvB4uQjb6UAM07k12Ra0oy2jg0Xf417nzqz21VH5Vfl6WmuO+C6LTAGM+NidMZeyiVyiqV4CiSQmLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757114874; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=u2jdc7rLZ93+UT0tmBIy3UeulgEZY7zZ1DBAZKI8/+g=; b=NIvP7EGRd4+643JupbHN24LCd2HhIN8jMvNhP0rhKY1ZZNq+QNHA3We6H0+nKN+Llnwd6+VJELjD3Smo2/+BjsEHe3P+EGJZd3riZABXqCkgk2d0duGZ26tE3nG5MnW+/6TGYszcE7I1X+fJ8k8be+0x7wcHt6pORRyhn6Fq7ig= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 175711487486314.555515625793532; Fri, 5 Sep 2025 16:27:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1112643.1460938 (Exim 4.92) (envelope-from ) id 1uufqA-0004Df-CT; Fri, 05 Sep 2025 23:27:34 +0000 Received: by outflank-mailman (output) from mailman id 1112643.1460938; Fri, 05 Sep 2025 23:27:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uufqA-0004C5-1A; Fri, 05 Sep 2025 23:27:34 +0000 Received: by outflank-mailman (input) for mailman id 1112643; Fri, 05 Sep 2025 23:27:32 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uufq8-0003lL-82 for xen-devel@lists.xenproject.org; Fri, 05 Sep 2025 23:27:32 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1uufq7-008ACU-2B; Fri, 05 Sep 2025 23:27:31 +0000 Received: from [19.12.91.86] (helo=localhost) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uufq7-0005DY-2A; Fri, 05 Sep 2025 23:27:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From; bh=u2jdc7rLZ93+UT0tmBIy3UeulgEZY7zZ1DBAZKI8/+g=; b=us44G4mHhQkzqi+a5rTigbberW DnTiESUfEPrrt/+dqdcPnY+djyikMBzPjhNUgfvQefLwkIwxvgNpdQmHu2ijFn0KXgidlXHwroc7i Yu1ryjQ5U6MP2GTTDbd9gnou7KFoFOJxghmL3ozDz77Jtx/swpPAQ7kBW39sIordgTXo=; From: dmukhin@xen.org To: xen-devel@lists.xenproject.org Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v6 12/15] emul/ns16550: implement dump_state() hook Date: Fri, 5 Sep 2025 16:27:11 -0700 Message-ID: <20250905232715.440758-13-dmukhin@ford.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905232715.440758-1-dmukhin@ford.com> References: <20250905232715.440758-1-dmukhin@ford.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1757114876824124100 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Implement dump_state() vUART hook for debugging UART state machine over Xen console. dump_state() prints state of all emulated registers (including state-less IIR) and state of RX/TX FIFOs. Signed-off-by: Denis Mukhin --- Changes since v5: - Fixed printouts formatters - Link to v5: https://lore.kernel.org/xen-devel/20250828235409.2835815-13-d= mukhin@ford.com/ --- xen/common/emul/vuart/ns16x50.c | 59 ++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/xen/common/emul/vuart/ns16x50.c b/xen/common/emul/vuart/ns16x5= 0.c index 3fc1112709df..a4fa3a9be713 100644 --- a/xen/common/emul/vuart/ns16x50.c +++ b/xen/common/emul/vuart/ns16x50.c @@ -648,6 +648,58 @@ static int ns16x50_io_read( return rc; } =20 +static void cf_check ns16x50_dump_state(void *arg) +{ +#ifdef CONFIG_VUART_NS16X50_DEBUG + struct vuart_ns16x50 *vdev =3D arg; + const struct domain *d =3D vdev->owner; + const struct vuart_info *info =3D vdev->info; + const struct xencons_interface *cons; + const uint8_t *regs; + + if ( !vdev ) + return; + + /* Allow printing state in case of a deadlock. */ + if ( !spin_trylock(&vdev->lock) ) + return; + + cons =3D &vdev->cons; + regs =3D &vdev->regs[0]; + + printk("Virtual " pr_prefix " (%s) I/O port 0x%04x IRQ#%d owner %pd\n", + vdev->name, info->base_addr, info->irq, d); + + printk(" RX FIFO size %ld in_prod %d in_cons %d used %d\n", + ARRAY_SIZE(cons->in), cons->in_prod, cons->in_cons, + cons->in_prod - cons->in_cons); + + printk(" TX FIFO size %ld out_prod %d out_cons %d used %d\n", + ARRAY_SIZE(cons->out), cons->out_prod, cons->out_cons, + cons->out_prod - cons->out_cons); + + printk(" %02"PRIx8" RBR %02"PRIx8" THR %02"PRIx8" DLL %02"PRIx8" DLM = %02"PRIx8"\n", + UART_RBR, + cons->in[MASK_XENCONS_IDX(cons->in_prod, cons)], + cons->out[MASK_XENCONS_IDX(cons->out_prod, cons)], + regs[NS16X50_REGS_NUM + UART_DLL], + regs[NS16X50_REGS_NUM + UART_DLM]); + + printk(" %02"PRIx8" IER %02"PRIx8"\n", UART_IER, regs[UART_IER]); + + printk(" %02"PRIx8" FCR %02"PRIx8" IIR %02"PRIx8"\n", + UART_FCR, regs[UART_FCR], ns16x50_iir_get(vdev)); + + printk(" %02"PRIx8" LCR %02"PRIx8"\n", UART_LCR, regs[UART_LCR]); + printk(" %02"PRIx8" MCR %02"PRIx8"\n", UART_MCR, regs[UART_MCR]); + printk(" %02"PRIx8" LSR %02"PRIx8"\n", UART_LSR, regs[UART_LSR]); + printk(" %02"PRIx8" MSR %02"PRIx8"\n", UART_MSR, regs[UART_MSR]); + printk(" %02"PRIx8" SCR %02"PRIx8"\n", UART_SCR, regs[UART_SCR]); + + spin_unlock(&vdev->lock); +#endif /* CONFIG_VUART_NS16X50_DEBUG */ +} + /* * Emulate I/O access to ns16x50 register. * Note, emulation always returns X86EMUL_OKAY, once I/O port trap is enab= led. @@ -724,6 +776,9 @@ static int cf_check ns16x50_io_handle( =20 spin_unlock(&vdev->lock); =20 + if ( ns16x50_log_level >=3D 3 ) + ns16x50_dump_state(vdev); + out: rcu_unlock_domain(d); =20 @@ -854,6 +909,8 @@ static int cf_check ns16x50_put_rx(void *arg, char ch) } =20 spin_unlock(&vdev->lock); + if ( ns16x50_log_level >=3D 3 ) + ns16x50_dump_state(vdev); =20 return rc; } @@ -863,7 +920,7 @@ static int cf_check ns16x50_put_rx(void *arg, char ch) .compatible =3D "ns16550", \ .alloc =3D ns16x50_alloc, \ .free =3D ns16x50_free, \ - .dump_state =3D NULL, \ + .dump_state =3D ns16x50_dump_state, \ .put_rx =3D ns16x50_put_rx, \ } =20 --=20 2.51.0