From: Peter Hurley <peter@hurleysoftware.com>
To: Stanislav Meduna <stano@meduna.org>
Cc: linux-serial@vger.kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Greg KH <gregkh@linuxfoundation.org>,
Linux ARM Kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: mxs-auart gives data from previous run after close and reopen
Date: Thu, 20 Mar 2014 21:39:38 -0400 [thread overview]
Message-ID: <532B985A.7060505@hurleysoftware.com> (raw)
In-Reply-To: <5323625B.4010203@meduna.org>
On 03/14/2014 04:11 PM, Stanislav Meduna wrote:
> Hi,
>
> following scenario:
>
> - a Freescale i.MX28 machine
> - RS232 AUART looped back Rx - Tx or two different ports cross-connected
> - a test program sending data in one thread and receiving in the other:
> thread A periodically sends "Quick brown fox jumps over the lazy dog",
> thread B receives
> - stop the program using ctrl-C
> - restart
>
> => sometimes the receiving thread gets "dogQuick", receiving
> characters from the previous transmission
>
> The extra characters definitely come from the receiver - the transmission
> is OK. This was verified by a scope.
>
> My theory is that this behaviour is caused by mxs_auart_shutdown
> function gating and mxs_auart_startup reenabling the clock instead
> of doing a soft reset. If the clock is gated while the AUART already
> has something in the FIFO, but did not generate the interrupt yet,
> the internal state machine is frozen in this state. As soon as it
> is reenabled, the characters are delivered to a new user.
>
> I am using a 3.4.77 kernel, but the relevant code looks the same in
> the recent kernels (when not using DMA). I also backported patches
> waiting for the transmission FIFO to clear at mxs_auart_shutdown.
>
> I did not find any possibility to fully clear the receiver - even
> if one disables the AUART and reads everything from the FIFO,
> the character currently in transmit might be still somewhere (the
> reference manual states that disabling is effective after the
> current character is received). Which might be 1 ms at 9600 and one
> has no clue whether it is the case.
>
> Also note that the function mxs_auart_reset is in fact not doing
> a reset - it just makes sure that the AUART comes out of one after
> the initialization. Maybe a full reset at startup is the solution...
>
> Pleas Cc: me when answering.
Does disabling the fifo on shutdown clear the fifo?
WARNING: multiple messages have this Message-ID (diff)
From: peter@hurleysoftware.com (Peter Hurley)
To: linux-arm-kernel@lists.infradead.org
Subject: mxs-auart gives data from previous run after close and reopen
Date: Thu, 20 Mar 2014 21:39:38 -0400 [thread overview]
Message-ID: <532B985A.7060505@hurleysoftware.com> (raw)
In-Reply-To: <5323625B.4010203@meduna.org>
On 03/14/2014 04:11 PM, Stanislav Meduna wrote:
> Hi,
>
> following scenario:
>
> - a Freescale i.MX28 machine
> - RS232 AUART looped back Rx - Tx or two different ports cross-connected
> - a test program sending data in one thread and receiving in the other:
> thread A periodically sends "Quick brown fox jumps over the lazy dog",
> thread B receives
> - stop the program using ctrl-C
> - restart
>
> => sometimes the receiving thread gets "dogQuick", receiving
> characters from the previous transmission
>
> The extra characters definitely come from the receiver - the transmission
> is OK. This was verified by a scope.
>
> My theory is that this behaviour is caused by mxs_auart_shutdown
> function gating and mxs_auart_startup reenabling the clock instead
> of doing a soft reset. If the clock is gated while the AUART already
> has something in the FIFO, but did not generate the interrupt yet,
> the internal state machine is frozen in this state. As soon as it
> is reenabled, the characters are delivered to a new user.
>
> I am using a 3.4.77 kernel, but the relevant code looks the same in
> the recent kernels (when not using DMA). I also backported patches
> waiting for the transmission FIFO to clear at mxs_auart_shutdown.
>
> I did not find any possibility to fully clear the receiver - even
> if one disables the AUART and reads everything from the FIFO,
> the character currently in transmit might be still somewhere (the
> reference manual states that disabling is effective after the
> current character is received). Which might be 1 ms at 9600 and one
> has no clue whether it is the case.
>
> Also note that the function mxs_auart_reset is in fact not doing
> a reset - it just makes sure that the AUART comes out of one after
> the initialization. Maybe a full reset at startup is the solution...
>
> Pleas Cc: me when answering.
Does disabling the fifo on shutdown clear the fifo?
next prev parent reply other threads:[~2014-03-21 1:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-14 20:11 mxs-auart gives data from previous run after close and reopen Stanislav Meduna
2014-03-14 20:11 ` Stanislav Meduna
2014-03-21 1:39 ` Peter Hurley [this message]
2014-03-21 1:39 ` Peter Hurley
2014-03-21 8:21 ` Stanislav Meduna
2014-03-21 8:21 ` Stanislav Meduna
2014-03-21 10:17 ` Peter Hurley
2014-03-21 10:17 ` Peter Hurley
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=532B985A.7060505@hurleysoftware.com \
--to=peter@hurleysoftware.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=stano@meduna.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.