From: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
To: <linux-kernel@vger.kernel.org>, <linux-serial@vger.kernel.org>,
<ayan.kumar.halder@amd.com>
Cc: julien@xen.org, stefano.stabellini@amd.com,
gregkh@linuxfoundation.org, linuxppc-dev@lists.ozlabs.org,
jirislaby@kernel.org, michal.orzel@amd.com, michal.simek@amd.com
Subject: [PATCH] tty: hvc: dcc: Check for TXfull condition while setting up early console
Date: Tue, 5 Dec 2023 12:35:34 +0000 [thread overview]
Message-ID: <20231205123534.3376883-1-ayan.kumar.halder@amd.com> (raw)
Refer ARM DDI 0487I.a ID081822, D17.3.8, DBGDTRTX_EL0,
"If TXfull is set to 1, set DTRRX and DTRTX to UNKNOWN"
Thus one should always check for TXfull condition before hvc can be
used as an early console. This is similar to what is being done
today in hvc_dcc_console_init() and hvc_dcc_init().
The count 0x4000000 has been obtained from uboot (v2024.01-rc3)
drivers/serial/arm_dcc.c "TIMEOUT_COUNT".
It reads the dcc status and waits for 0x4000000 times for the TX Fifo
to be available before returning an error. Thus, it will prevent DCC
to be used as early console.
Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
---
drivers/tty/hvc/hvc_dcc.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/tty/hvc/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c
index 1751108cf763..136381bec7cd 100644
--- a/drivers/tty/hvc/hvc_dcc.c
+++ b/drivers/tty/hvc/hvc_dcc.c
@@ -47,6 +47,14 @@ static void dcc_early_write(struct console *con, const char *s, unsigned n)
static int __init dcc_early_console_setup(struct earlycon_device *device,
const char *opt)
{
+ unsigned int count = 0x4000000;
+
+ while (--count && (__dcc_getstatus() & DCC_STATUS_TX))
+ cpu_relax();
+
+ if (__dcc_getstatus() & DCC_STATUS_TX)
+ return -ENODEV;
+
device->con->write = dcc_early_write;
return 0;
--
2.25.1
reply other threads:[~2023-12-06 0:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231205123534.3376883-1-ayan.kumar.halder@amd.com \
--to=ayan.kumar.halder@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=julien@xen.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=michal.orzel@amd.com \
--cc=michal.simek@amd.com \
--cc=stefano.stabellini@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).