From: Lukas Wunner <lukas@wunner.de>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: linux-serial <linux-serial@vger.kernel.org>,
Jiri Slaby <jirislaby@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
LKML <linux-kernel@vger.kernel.org>,
Johan Hovold <johan@kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Raymond Tan <raymond.tan@intel.com>,
Heiko Stuebner <heiko@sntech.de>, Rob Herring <robh@kernel.org>
Subject: Re: [PATCH 1/7] serial: 8250_dwlib: RS485 HW half duplex support
Date: Wed, 9 Mar 2022 13:59:08 +0100 [thread overview]
Message-ID: <20220309125908.GA9283@wunner.de> (raw)
In-Reply-To: <9c2d96c0-44cf-c84c-5ff7-34c74716a23b@linux.intel.com>
On Wed, Mar 09, 2022 at 02:19:39PM +0200, Ilpo Järvinen wrote:
> Now that it has been pretty much established that anything called "rts"
> should be applied to DE as well, I took another look on implementing these
> delays.
>
> It turns out to be impractical to do/ineffective because "serial clock
> periods" are used as the unit by the HW ("serial clock periods" is not as
> clearly defined by the datasheet as I'd like but it is most likely based
> on the high-rated uartclk cycles). With the uartclk I've on test HW, the
> combined delay with max turnaround time and DE assert/de-assert timings
> cannot do even the smallest possible non-zero value (1 msec). That's
> because the TAT and DET registers allow only 16-bit and 8-bit values for
> delays.
A mistake was made when RS-485 support was introduced in the kernel
more than 10 years ago with commits c26c56c0 and 93f3350c:
The delays were defined in msec, but if you look at datasheets of
RS-485 transceivers, they only need a delay in the nanosecond or
single-digit usec range.
Here's a collection of delays I compiled two years ago:
DrvEnable-to-Output DriverPropagation
MAX13450E/MAX13451E 5200 ns 800 ns
MAXM22510 2540 ns 1040 ns
MAXM22511 80 ns 65 ns
SN65HVD72 9000 ns 1000 ns
SN65HVD75 7000 ns 17 ns
SN65HVD78 8000 ns 15 ns
SN65HVD485E 2600 ns 30 ns
ADM1486 15 ns 17 ns
ADM3485/ADM3490/ADM3491 900 ns 35 ns
ADM3483/ADM3488 1300 ns 1500 ns
XR33193 2000 ns 1300 ns
Because these delays are so short, it is usually sufficient to set
them to zero in struct serial_rs485.
I've begun a commit to change the delays to nsec, it's still a WIP:
https://github.com/l1k/linux/commit/2c08878b63d6
This is a little tricky because the delays are user-space ABI,
so great care is needed to avoid breakage. Also, every rs485
driver with support for delays needs to be touched. Some
UARTs have fixed delays which depend on different clocks,
other UARTs support configurable delays. Another complication
is that delay calculations easily overflow with nsec because
the numbers become quite large.
A positive side effect of changing the delays to nsec is that
the horrible hrtimer kludge for rs485 software emulation in the
8250_port.c can be eliminated. Also, all the illegal mdelay()s
in spinlocked context (e.g. serial console output) are replaced
by much more reasonable ndelay()s.
Eliminating the hrtimer kludge in 8250_port.c might also make these
runtime PM patches by Andy simpler:
https://lore.kernel.org/linux-serial/20211115084203.56478-8-tony@atomide.com/
My suggestion would be to set the delays to zero for now in 8250_dw.c
and implement proper delay handling after I've finished the conversion
to nsec.
Thanks,
Lukas
next prev parent reply other threads:[~2022-03-09 12:59 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-02 9:55 [PATCH 0/7] Add RS485 support to DW UART Ilpo Järvinen
2022-03-02 9:56 ` [PATCH 1/7] serial: 8250_dwlib: RS485 HW half duplex support Ilpo Järvinen
2022-03-06 18:48 ` Lukas Wunner
2022-03-06 22:07 ` Andy Shevchenko
2022-03-07 9:19 ` Ilpo Järvinen
2022-03-07 19:18 ` Lukas Wunner
2022-03-07 19:39 ` Andy Shevchenko
2022-03-08 12:16 ` Ilpo Järvinen
2022-03-08 12:22 ` Lukas Wunner
2022-03-08 12:59 ` Ilpo Järvinen
2022-03-08 14:50 ` Lukas Wunner
2022-03-08 14:53 ` Andy Shevchenko
2022-03-08 20:30 ` Lukas Wunner
2022-03-09 9:51 ` Ilpo Järvinen
2022-03-07 10:54 ` Ilpo Järvinen
2022-03-09 8:52 ` Lukas Wunner
2022-03-09 12:19 ` Ilpo Järvinen
2022-03-09 12:59 ` Lukas Wunner [this message]
2022-03-02 9:56 ` [PATCH 2/7] serial: 8250_dwlib: RS485 HW full " Ilpo Järvinen
2022-03-06 18:51 ` Lukas Wunner
2022-03-07 9:22 ` Ilpo Järvinen
2022-03-02 9:56 ` [RFC PATCH 3/7] serial: 8250_dwlib: Implement SW half " Ilpo Järvinen
2022-03-06 19:21 ` Lukas Wunner
2022-03-06 22:13 ` Andy Shevchenko
2022-03-02 9:56 ` [PATCH 4/7] dt_bindings: snps-dw-apb-uart: Add RS485 Ilpo Järvinen
2022-03-02 17:47 ` Rob Herring
2022-03-02 9:56 ` [RFC PATCH 5/7] serial: termbits: ADDRB to indicate 9th bit addressing mode Ilpo Järvinen
2022-03-02 9:56 ` Ilpo Järvinen
2022-03-02 9:56 ` Ilpo Järvinen
2022-03-02 9:56 ` [RFC PATCH 6/7] serial: General support for multipoint addresses Ilpo Järvinen
2022-03-02 9:56 ` Ilpo Järvinen
2022-03-02 9:56 ` Ilpo Järvinen
2022-03-06 19:40 ` Lukas Wunner
2022-03-06 19:40 ` Lukas Wunner
2022-03-06 19:40 ` Lukas Wunner
2022-03-07 9:48 ` Ilpo Järvinen
2022-03-07 9:48 ` Ilpo Järvinen
2022-03-07 9:48 ` Ilpo Järvinen
2022-03-09 19:05 ` Lukas Wunner
2022-03-09 19:05 ` Lukas Wunner
2022-03-09 19:05 ` Lukas Wunner
2022-03-10 12:29 ` Ilpo Järvinen
2022-03-10 12:29 ` Ilpo Järvinen
2022-03-10 12:29 ` Ilpo Järvinen
2022-03-10 14:09 ` Andy Shevchenko
2022-03-10 14:09 ` Andy Shevchenko
2022-03-10 14:09 ` Andy Shevchenko
2022-03-02 9:56 ` [RFC PATCH 7/7] serial: 8250_dwlib: Support for 9th bit multipoint addressing Ilpo Järvinen
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=20220309125908.GA9283@wunner.de \
--to=lukas@wunner.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=heiko@sntech.de \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=raymond.tan@intel.com \
--cc=robh@kernel.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.