From: baruch@tkos.co.il (Baruch Siach)
To: linux-arm-kernel@lists.infradead.org
Subject: imx: Race when disabling RX in IMX.6 UART in half duplex
Date: Mon, 20 Feb 2017 21:20:01 +0200 [thread overview]
Message-ID: <20170220192001.eqomprbgrqkefkas@tarshish> (raw)
In-Reply-To: <c07c95e2-3463-222b-c78a-b5716b4c5a14@camlintechnologies.com>
Hi Piotr,
On Mon, Feb 20, 2017 at 02:54:02PM +0100, Piotr Figiel wrote:
> I'm looking to find a correct way to disable RX in the I.MX6 UART during
> TX-ing. I stumbled on the issue described below when working on
> ~SER_RS485_RX_DURING_TX on custom 3.10 tree (branched from Freescale's/NXP's
> BSP release) independently to what is now in the main line imx.c, but I see
> now that the implementation in mainline also seem to have the same problem
> I'm trying to solve now. I would like to request for comments to
> confirm/deny whether the issue I raise here is valid and how to best
> approach this.
>
> I'm mostly concerned about the fact that the URXD register must not be
> accessed (as documented in IMX.6 RM) when RX is disabled (RXEN=0). The issue
> is that in the following sequence happening during imx_start_tx with
> ~SER_RS485_RX_DURING_TX set:
>
> 1. Acquire spinlock, disable local interrupts (from serial_core.c),
> 2. Disable RX receiver (RXEN=0 in UCR2),
> 3. Release spinlock, reenable interrupts.
>
> The RX fifo may become not empty between #1 and #2. This will raise
> interrupt which will be handled after re-enabling interrupts (after #3). ISR
> in this case will check the status bit of the interrupt and fetch RX FIFO
> contents, which I understand is forbidden by the documentation and may raise
> error on the bus [1]. In addition disabling RX IRQ in this procedure, e.g.
> after #1 doesn't seem to be enough, as the IRQ still may trigger after #1
> and will need to be serviced.
As I understand it, SER_RS485_RX_DURING_TX is for half-duplex RS-485 where
only one device is allowed to transmit at any given time. Higher level code
determines when any given device on the bus is allowed to transmit. If Rx FIFO
becomes non-empty during Tx enable, you have a contention problem to solve.
What is your use case?
baruch
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
next prev parent reply other threads:[~2017-02-20 19:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-20 13:54 imx: Race when disabling RX in IMX.6 UART in half duplex Piotr Figiel
2017-02-20 19:20 ` Baruch Siach [this message]
2017-02-21 8:00 ` Piotr Figiel
2017-02-21 8:18 ` Baruch Siach
2017-02-21 8:48 ` Piotr Figiel
2017-02-21 13:09 ` Fabio Estevam
2017-02-22 10:44 ` Sascha Hauer
2017-02-22 11:16 ` Piotr Figiel
2017-02-21 13:30 ` Uwe Kleine-König
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=20170220192001.eqomprbgrqkefkas@tarshish \
--to=baruch@tkos.co.il \
--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