From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] TTY: hvc_dcc: probe for a JTAG connection before registering
Date: Mon, 23 Sep 2013 16:35:51 -0500 [thread overview]
Message-ID: <5240B437.9090201@gmail.com> (raw)
In-Reply-To: <5240AE43.6070708@canonical.com>
On 09/23/2013 04:10 PM, Tim Gardner wrote:
> On 09/23/2013 01:30 PM, Rob Herring wrote:
>> From: Rob Herring <rob.herring@calxeda.com>
>>
>> Enabling the ARM DCC console and using without a JTAG connection will
>> simply hang the system. Since distros like to turn on all options, this
>> is a reoccurring problem to debug. We can do better by checking if
>> anything is attached and handling characters. There is no way to probe
>> this, so send a newline and check that it is handled.
>>
>> Cc: Paolo Pisati <paolo.pisati@canonical.com>
>> Cc: Tim Gardner <tim.gardner@canonical.com>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: Jiri Slaby <jslaby@suse.cz>
>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>> ---
>> drivers/tty/hvc/hvc_dcc.c | 21 +++++++++++++++++++++
>> 1 file changed, 21 insertions(+)
>>
>> diff --git a/drivers/tty/hvc/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c
>> index 44fbeba..44c8aff 100644
>> --- a/drivers/tty/hvc/hvc_dcc.c
>> +++ b/drivers/tty/hvc/hvc_dcc.c
>> @@ -86,6 +86,21 @@ static int hvc_dcc_get_chars(uint32_t vt, char *buf, int count)
>> return i;
>> }
>>
>> +static bool hvc_dcc_check(void)
>> +{
>> + unsigned long time = jiffies;
>> +
>> + /* Write a test character to check if it is handled */
>> + __dcc_putchar('\n');
>> +
>> + while (jiffies < time + (HZ / 10)) {
>> + if (!(__dcc_getstatus() & DCC_STATUS_TX))
>> + return true;
>> + }
>
> I think you should use one of the jiffies time comparison functions, e.g.,
>
> time = jiffies + (HZ / 10);
> while (time_before(jiffies,time) {
> ...
> }
Yes.
>
> What is the possibility that __dcc_getstatus() will return garbage if no
> JTAG is connected ? In that event you're likely to get a false positive
> on DCC_STATUS_TX.
That probably would not be architecturally compliant. The status bits
are cleared by JTAG reading the read side of the register. If the bit
stays set, we'll return false. If the bit is always clear, then we
wouldn't hang in the first place and should be fine. If you get random
values, then I'm sorry and good luck. You are still no worse off than
before this patch.
Rob
next prev parent reply other threads:[~2013-09-23 21:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-23 20:30 [PATCH] TTY: hvc_dcc: probe for a JTAG connection before registering Rob Herring
2013-09-23 21:10 ` Tim Gardner
2013-09-23 21:35 ` Rob Herring [this message]
2013-09-25 2:05 ` [PATCH v2] " Rob Herring
2013-10-17 19:16 ` Rob Herring
2013-10-17 20:20 ` Greg Kroah-Hartman
2013-10-17 20:31 ` Rob Herring
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=5240B437.9090201@gmail.com \
--to=robherring2@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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).