* [PATCH 2/4] thermal: bcm2835: Stop using printk format %pCr
From: Geert Uytterhoeven @ 2018-06-01 9:28 UTC (permalink / raw)
To: Jia-Ju Bai, Jonathan Corbet, Michael Turquette, Stephen Boyd,
Zhang Rui, Eduardo Valentin, Eric Anholt, Stefan Wahren,
Greg Kroah-Hartman
Cc: Sergey Senozhatsky, Petr Mladek, Linus Torvalds, Steven Rostedt,
linux-doc, linux-clk, linux-pm, linux-serial, linux-arm-kernel,
linux-renesas-soc, linux-kernel, Geert Uytterhoeven
In-Reply-To: <1527845302-12159-1-git-send-email-geert+renesas@glider.be>
Printk format "%pCr" will be removed soon, as clk_get_rate() must not be
called in atomic context.
Replace it by printing the variable that already holds the clock rate.
Note that calling clk_get_rate() is safe here, as the code runs in task
context.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/thermal/broadcom/bcm2835_thermal.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/broadcom/bcm2835_thermal.c
index a4d6a0e2e9938190..23ad4f9f21438e45 100644
--- a/drivers/thermal/broadcom/bcm2835_thermal.c
+++ b/drivers/thermal/broadcom/bcm2835_thermal.c
@@ -213,8 +213,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
rate = clk_get_rate(data->clk);
if ((rate < 1920000) || (rate > 5000000))
dev_warn(&pdev->dev,
- "Clock %pCn running at %pCr Hz is outside of the recommended range: 1.92 to 5MHz\n",
- data->clk, data->clk);
+ "Clock %pCn running at %lu Hz is outside of the recommended range: 1.92 to 5MHz\n",
+ data->clk, rate);
/* register of thermal sensor and get info from DT */
tz = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
--
2.7.4
^ permalink raw reply related
* [PATCH 3/4] serial: sh-sci: Stop using printk format %pCr
From: Geert Uytterhoeven @ 2018-06-01 9:28 UTC (permalink / raw)
To: Jia-Ju Bai, Jonathan Corbet, Michael Turquette, Stephen Boyd,
Zhang Rui, Eduardo Valentin, Eric Anholt, Stefan Wahren,
Greg Kroah-Hartman
Cc: Sergey Senozhatsky, Petr Mladek, Linus Torvalds, Steven Rostedt,
linux-doc, linux-clk, linux-pm, linux-serial, linux-arm-kernel,
linux-renesas-soc, linux-kernel, Geert Uytterhoeven
In-Reply-To: <1527845302-12159-1-git-send-email-geert+renesas@glider.be>
Printk format "%pCr" will be removed soon, as clk_get_rate() must not be
called in atomic context.
Replace it by open-coding the operation. This is safe here, as the code
runs in task context.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/tty/serial/sh-sci.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index b46b146524ce7495..c181eb37f98509e6 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -2724,8 +2724,8 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)
dev_dbg(dev, "failed to get %s (%ld)\n", clk_names[i],
PTR_ERR(clk));
else
- dev_dbg(dev, "clk %s is %pC rate %pCr\n", clk_names[i],
- clk, clk);
+ dev_dbg(dev, "clk %s is %pC rate %lu\n", clk_names[i],
+ clk, clk_get_rate(clk));
sci_port->clks[i] = IS_ERR(clk) ? NULL : clk;
}
return 0;
--
2.7.4
^ permalink raw reply related
* [PATCH 4/4] lib/vsprintf: Remove atomic-unsafe support for %pCr
From: Geert Uytterhoeven @ 2018-06-01 9:28 UTC (permalink / raw)
To: Jia-Ju Bai, Jonathan Corbet, Michael Turquette, Stephen Boyd,
Zhang Rui, Eduardo Valentin, Eric Anholt, Stefan Wahren,
Greg Kroah-Hartman
Cc: Sergey Senozhatsky, Petr Mladek, Linus Torvalds, Steven Rostedt,
linux-doc, linux-clk, linux-pm, linux-serial, linux-arm-kernel,
linux-renesas-soc, linux-kernel, Geert Uytterhoeven
In-Reply-To: <1527845302-12159-1-git-send-email-geert+renesas@glider.be>
"%pCr" formats the current rate of a clock, and calls clk_get_rate().
The latter obtains a mutex, hence it must not be called from atomic
context.
Remove support for this rarely-used format, as vsprintf() (and e.g.
printk()) must be callable from any context.
Any remaining out-of-tree users will start seeing the clock's name
printed instead of its rate.
Reported-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Fixes: 900cca2944254edd ("lib/vsprintf: add %pC{,n,r} format specifiers for clocks")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Documentation/core-api/printk-formats.rst | 3 +--
lib/vsprintf.c | 3 ---
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
index eb30efdd2e789616..25dc591cb1108790 100644
--- a/Documentation/core-api/printk-formats.rst
+++ b/Documentation/core-api/printk-formats.rst
@@ -419,11 +419,10 @@ struct clk
%pC pll1
%pCn pll1
- %pCr 1560000000
For printing struct clk structures. %pC and %pCn print the name
(Common Clock Framework) or address (legacy clock framework) of the
-structure; %pCr prints the current clock rate.
+structure.
Passed by reference.
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 247a7e0bf24f6f74..a48aaa79d352313a 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1469,9 +1469,6 @@ char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
return string(buf, end, NULL, spec);
switch (fmt[1]) {
- case 'r':
- return number(buf, end, clk_get_rate(clk), spec);
-
case 'n':
default:
#ifdef CONFIG_COMMON_CLK
--
2.7.4
^ permalink raw reply related
* Re: [PATCH 2/4] thermal: bcm2835: Stop using printk format %pCr
From: Stefan Wahren @ 2018-06-01 9:35 UTC (permalink / raw)
To: Geert Uytterhoeven, Jia-Ju Bai, Jonathan Corbet,
Michael Turquette, Stephen Boyd, Zhang Rui, Eduardo Valentin,
Eric Anholt, Greg Kroah-Hartman
Cc: Sergey Senozhatsky, Petr Mladek, Linus Torvalds, Steven Rostedt,
linux-doc, linux-clk, linux-pm, linux-serial, linux-arm-kernel,
linux-renesas-soc, linux-kernel
In-Reply-To: <1527845302-12159-3-git-send-email-geert+renesas@glider.be>
Am 01.06.2018 um 11:28 schrieb Geert Uytterhoeven:
> Printk format "%pCr" will be removed soon, as clk_get_rate() must not be
> called in atomic context.
>
> Replace it by printing the variable that already holds the clock rate.
> Note that calling clk_get_rate() is safe here, as the code runs in task
> context.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Stefan Wahren <stefan.wahren@i2se.com>
Thanks
^ permalink raw reply
* Re: [PATCH 0/4] lib/vsprintf: Remove atomic-unsafe support for printk format %pCr
From: Linus Torvalds @ 2018-06-01 11:00 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: baijiaju1990, Jonathan Corbet, Michael Turquette, sboyd,
Zhang Rui, Eduardo Valentin, Eric Anholt, Stefan Wahren,
Greg Kroah-Hartman, Sergey Senozhatsky, Petr Mladek,
Steven Rostedt, open list:DOCUMENTATION, linux-clk, Linux PM,
linux-serial, linux-arm-kernel, Linux-Renesas,
Linux Kernel Mailing List
In-Reply-To: <1527845302-12159-1-git-send-email-geert+renesas@glider.be>
On Fri, Jun 1, 2018 at 4:29 AM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
>
> This patch series:
> - Changes all existing users of "%pCr" to print the result of
> clk_get_rate() directly, which is safe as they all do this in task
> context only,
> - Removes support for the "%pCr" printk format.
Looks good to me.
What tree will this go through? The normal printk one? Just checking
that this doesn't end up falling through the cracks because nobody
knows who would take it...
Linus
^ permalink raw reply
* Re: [PATCH 0/4] lib/vsprintf: Remove atomic-unsafe support for printk format %pCr
From: Andy Shevchenko @ 2018-06-01 11:04 UTC (permalink / raw)
To: Linus Torvalds
Cc: Geert Uytterhoeven, Jia-Ju Bai, Jonathan Corbet,
Michael Turquette, Stephen Boyd, Zhang Rui, Eduardo Valentin,
Eric Anholt, Stefan Wahren, Greg Kroah-Hartman,
Sergey Senozhatsky, Petr Mladek, Steven Rostedt,
open list:DOCUMENTATION, linux-clk, Linux PM, linux-serial,
linux-arm-kernel, Linux-Renesas <linux-rene>
In-Reply-To: <CA+55aFxHHSRnDbbNGq6SwNAwEt0EhX15n_pNqon3MzGYJgMJmA@mail.gmail.com>
On Fri, Jun 1, 2018 at 2:00 PM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
> On Fri, Jun 1, 2018 at 4:29 AM Geert Uytterhoeven
> <geert+renesas@glider.be> wrote:
>>
>> This patch series:
>> - Changes all existing users of "%pCr" to print the result of
>> clk_get_rate() directly, which is safe as they all do this in task
>> context only,
>> - Removes support for the "%pCr" printk format.
>
> Looks good to me.
>
> What tree will this go through? The normal printk one? Just checking
> that this doesn't end up falling through the cracks because nobody
> knows who would take it...
We discussed few month before with Petr that he would take care of the
patches against vsprintf.c.
I think this is the case here.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH 0/4] lib/vsprintf: Remove atomic-unsafe support for printk format %pCr
From: Petr Mladek @ 2018-06-01 11:47 UTC (permalink / raw)
To: Linus Torvalds
Cc: Geert Uytterhoeven, baijiaju1990, Jonathan Corbet,
Michael Turquette, sboyd, Zhang Rui, Eduardo Valentin,
Eric Anholt, Stefan Wahren, Greg Kroah-Hartman,
Sergey Senozhatsky, Steven Rostedt, open list:DOCUMENTATION,
linux-clk, Linux PM, linux-serial, linux-arm-kernel,
Linux-Renesas, Linux Kernel Mailing List
In-Reply-To: <CA+55aFxHHSRnDbbNGq6SwNAwEt0EhX15n_pNqon3MzGYJgMJmA@mail.gmail.com>
On Fri 2018-06-01 06:00:47, Linus Torvalds wrote:
> On Fri, Jun 1, 2018 at 4:29 AM Geert Uytterhoeven
> <geert+renesas@glider.be> wrote:
> >
> > This patch series:
> > - Changes all existing users of "%pCr" to print the result of
> > clk_get_rate() directly, which is safe as they all do this in task
> > context only,
> > - Removes support for the "%pCr" printk format.
>
> Looks good to me.
>
> What tree will this go through? The normal printk one? Just checking
> that this doesn't end up falling through the cracks because nobody
> knows who would take it...
I will take it via printk.git. There already is bunch of vsprintf
changes for-4.18.
Best Regards,
Petr
^ permalink raw reply
* [PATCH 0/8] serial: 8250: Add 485 emulation to 8250_dw.
From: Giulio Benetti @ 2018-06-01 12:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Andy Shevchenko, Kees Cook, Matthias Brugger,
Allen Pais, Sean Young, Ed Blake, Stefan Potyra, Philipp Zabel,
Joshua Scott, Vignesh R, Rolf Evers-Fischer, Aaron Sierra,
Rafael Gago, Joel Stanley, Sean Wang, linux-serial, linux-kernel,
Giulio Benetti
Need to handle rs485 with 8250_dw port.
Use existing em485 emulation layer for 8250 taking care to fix some bug
and taking care especially of RTS_AFTER_SEND case.
Giulio Benetti (8):
serial: 8250_dw: add em485 support
serial: 8250_dw: allow enable rs485 at boot time
serial: 8250: Copy em485 from port to real port.
serial: 8250: Handle case port doesn't have TEMT interrupt using
em485.
serial: 8250_dw: treat rpm suspend with -EBUSY if RS485 ON and
RTS_AFTER_SEND
serial: 8250: Copy mctrl when register port.
serial: 8250: Make em485_rts_after_send() set mctrl according to rts
state.
serial: core: Mask mctrl with TIOCM_RTS too if rs485 on and
RTS_AFTER_SEND set.
drivers/tty/serial/8250/8250.h | 2 +-
drivers/tty/serial/8250/8250_core.c | 2 ++
drivers/tty/serial/8250/8250_dw.c | 41 ++++++++++++++++++++++++++++-
drivers/tty/serial/8250/8250_omap.c | 2 +-
drivers/tty/serial/8250/8250_port.c | 33 ++++++++++++++++-------
drivers/tty/serial/serial_core.c | 12 ++++++++-
include/linux/serial_8250.h | 1 +
7 files changed, 79 insertions(+), 14 deletions(-)
--
2.17.0
^ permalink raw reply
* [PATCH 1/8] serial: 8250_dw: add em485 support
From: Giulio Benetti @ 2018-06-01 12:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Andy Shevchenko, Kees Cook, Matthias Brugger,
Allen Pais, Sean Young, Ed Blake, Stefan Potyra, Philipp Zabel,
Joshua Scott, Vignesh R, Rolf Evers-Fischer, Aaron Sierra,
Rafael Gago, Joel Stanley, Sean Wang, linux-serial, linux-kernel,
Giulio Benetti
In-Reply-To: <20180601124021.102970-1-giulio.benetti@micronovasrl.com>
Need to use rs485 transceiver so let's use existing em485 485 emulation
layer on top of 8250.
Add rs485_config callback to port.
Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
drivers/tty/serial/8250/8250_dw.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 6fcdb90f616a..45366e6e5411 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -314,6 +314,36 @@ static void dw8250_set_ldisc(struct uart_port *p, struct ktermios *termios)
serial8250_do_set_ldisc(p, termios);
}
+static int dw8250_rs485_config(struct uart_port *p,
+ struct serial_rs485 *rs485)
+{
+ struct uart_8250_port *up = up_to_u8250p(p);
+
+ /* Clamp the delays to [0, 100ms] */
+ rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U);
+ rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U);
+
+ p->rs485 = *rs485;
+
+ /*
+ * Both serial8250_em485_init and serial8250_em485_destroy
+ * are idempotent
+ */
+ if (rs485->flags & SER_RS485_ENABLED) {
+ int ret = serial8250_em485_init(up);
+
+ if (ret) {
+ rs485->flags &= ~SER_RS485_ENABLED;
+ p->rs485.flags &= ~SER_RS485_ENABLED;
+ }
+ return ret;
+ }
+
+ serial8250_em485_destroy(up);
+
+ return 0;
+}
+
/*
* dw8250_fallback_dma_filter will prevent the UART from getting just any free
* channel on platforms that have DMA engines, but don't have any channels
@@ -449,6 +479,7 @@ static int dw8250_probe(struct platform_device *pdev)
p->serial_out = dw8250_serial_out;
p->set_ldisc = dw8250_set_ldisc;
p->set_termios = dw8250_set_termios;
+ p->rs485_config = dw8250_rs485_config;
p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
if (!p->membase)
--
2.17.0
^ permalink raw reply related
* [PATCH 2/8] serial: 8250_dw: allow enable rs485 at boot time
From: Giulio Benetti @ 2018-06-01 12:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Andy Shevchenko, Kees Cook, Matthias Brugger,
Allen Pais, Sean Young, Ed Blake, Stefan Potyra, Philipp Zabel,
Joshua Scott, Vignesh R, Rolf Evers-Fischer, Aaron Sierra,
Rafael Gago, Joel Stanley, Sean Wang, linux-serial, linux-kernel,
Giulio Benetti
In-Reply-To: <20180601124021.102970-1-giulio.benetti@micronovasrl.com>
If "linux,rs485-enabled-at-boot-time" is specified need to setup 485
in probe function.
Call uart_get_rs485_mode() to get rs485 configuration, then call
rs485_config() callback directly to setup port as rs485.
Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
drivers/tty/serial/8250/8250_dw.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 45366e6e5411..0f8b4da03d4e 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -582,8 +582,11 @@ static int dw8250_probe(struct platform_device *pdev)
if (data->uart_16550_compatible)
p->handle_irq = NULL;
- if (!data->skip_autocfg)
+ if (!data->skip_autocfg) {
dw8250_setup_port(p);
+ uart_get_rs485_mode(dev, &p->rs485);
+ dw8250_rs485_config(p, &p->rs485);
+ }
/* If we have a valid fifosize, try hooking up DMA */
if (p->fifosize) {
--
2.17.0
^ permalink raw reply related
* [PATCH 3/8] serial: 8250: Copy em485 from port to real port.
From: Giulio Benetti @ 2018-06-01 12:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Andy Shevchenko, Kees Cook, Matthias Brugger,
Allen Pais, Sean Young, Ed Blake, Stefan Potyra, Philipp Zabel,
Joshua Scott, Vignesh R, Rolf Evers-Fischer, Aaron Sierra,
Rafael Gago, Joel Stanley, Sean Wang, linux-serial, linux-kernel,
Giulio Benetti
In-Reply-To: <20180601124021.102970-1-giulio.benetti@micronovasrl.com>
em485 gets lost during serial8250_register_8250_port().
Copy em485 to final uart port.
Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
drivers/tty/serial/8250/8250_core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 9342fc2ee7df..c8c2b260c681 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -994,6 +994,7 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
uart->port.rs485_config = up->port.rs485_config;
uart->port.rs485 = up->port.rs485;
uart->dma = up->dma;
+ uart->em485 = up->em485;
/* Take tx_loadsz from fifosize if it wasn't set separately */
if (uart->port.fifosize && !uart->tx_loadsz)
--
2.17.0
^ permalink raw reply related
* [PATCH 4/8] serial: 8250: Handle case port doesn't have TEMT interrupt using em485.
From: Giulio Benetti @ 2018-06-01 12:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Andy Shevchenko, Kees Cook, Matthias Brugger,
Allen Pais, Sean Young, Ed Blake, Stefan Potyra, Philipp Zabel,
Joshua Scott, Vignesh R, Rolf Evers-Fischer, Aaron Sierra,
Rafael Gago, Joel Stanley, Sean Wang, linux-serial, linux-kernel,
Giulio Benetti
In-Reply-To: <20180601124021.102970-1-giulio.benetti@micronovasrl.com>
Some 8250 ports only have TEMT interrupt, so current implementation
can't work for ports without it. The only chance to make it work is to
loop-read on LSR register.
With NO TEMT interrupt check if both TEMT and THRE are set looping on
LSR register.
Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
drivers/tty/serial/8250/8250.h | 2 +-
drivers/tty/serial/8250/8250_dw.c | 2 +-
drivers/tty/serial/8250/8250_omap.c | 2 +-
drivers/tty/serial/8250/8250_port.c | 26 ++++++++++++++++++--------
include/linux/serial_8250.h | 1 +
5 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index ebfb0bd5bef5..5c6ae5f69432 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -136,7 +136,7 @@ void serial8250_rpm_put(struct uart_8250_port *p);
void serial8250_rpm_get_tx(struct uart_8250_port *p);
void serial8250_rpm_put_tx(struct uart_8250_port *p);
-int serial8250_em485_init(struct uart_8250_port *p);
+int serial8250_em485_init(struct uart_8250_port *p, bool has_temt_isr);
void serial8250_em485_destroy(struct uart_8250_port *p);
static inline void serial8250_out_MCR(struct uart_8250_port *up, int value)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 0f8b4da03d4e..888280ff5451 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -330,7 +330,7 @@ static int dw8250_rs485_config(struct uart_port *p,
* are idempotent
*/
if (rs485->flags & SER_RS485_ENABLED) {
- int ret = serial8250_em485_init(up);
+ int ret = serial8250_em485_init(up, false);
if (ret) {
rs485->flags &= ~SER_RS485_ENABLED;
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index 624b501fd253..ab483c8b30c8 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -725,7 +725,7 @@ static int omap_8250_rs485_config(struct uart_port *port,
* are idempotent
*/
if (rs485->flags & SER_RS485_ENABLED) {
- int ret = serial8250_em485_init(up);
+ int ret = serial8250_em485_init(up, true);
if (ret) {
rs485->flags &= ~SER_RS485_ENABLED;
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 95833cbc4338..e14badbbf181 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -599,15 +599,16 @@ EXPORT_SYMBOL_GPL(serial8250_rpm_put);
/**
* serial8250_em485_init() - put uart_8250_port into rs485 emulating
* @p: uart_8250_port port instance
+ * @p: bool specify if 8250 port has TEMT interrupt or not
*
* The function is used to start rs485 software emulating on the
* &struct uart_8250_port* @p. Namely, RTS is switched before/after
* transmission. The function is idempotent, so it is safe to call it
* multiple times.
*
- * The caller MUST enable interrupt on empty shift register before
- * calling serial8250_em485_init(). This interrupt is not a part of
- * 8250 standard, but implementation defined.
+ * If has_temt_isr is passed as true, the caller MUST enable interrupt
+ * on empty shift register before calling serial8250_em485_init().
+ * This interrupt is not a part of 8250 standard, but implementation defined.
*
* The function is supposed to be called from .rs485_config callback
* or from any other callback protected with p->port.lock spinlock.
@@ -616,7 +617,7 @@ EXPORT_SYMBOL_GPL(serial8250_rpm_put);
*
* Return 0 - success, -errno - otherwise
*/
-int serial8250_em485_init(struct uart_8250_port *p)
+int serial8250_em485_init(struct uart_8250_port *p, bool has_temt_isr)
{
if (p->em485)
return 0;
@@ -633,6 +634,7 @@ int serial8250_em485_init(struct uart_8250_port *p)
p->em485->start_tx_timer.function = &serial8250_em485_handle_start_tx;
p->em485->port = p;
p->em485->active_timer = NULL;
+ p->em485->has_temt_isr = has_temt_isr;
serial8250_em485_rts_after_send(p);
return 0;
@@ -1517,11 +1519,19 @@ static inline void __stop_tx(struct uart_8250_port *p)
/*
* To provide required timeing and allow FIFO transfer,
* __stop_tx_rs485() must be called only when both FIFO and
- * shift register are empty. It is for device driver to enable
- * interrupt on TEMT.
+ * shift register are empty. If 8250 port supports it,
+ * it is for device driver to enable interrupt on TEMT.
+ * Otherwise must loop-read until TEMT and THRE flags are set.
*/
- if ((lsr & BOTH_EMPTY) != BOTH_EMPTY)
- return;
+ if (em485->has_temt_isr) {
+ if ((lsr & BOTH_EMPTY) != BOTH_EMPTY)
+ return;
+ } else {
+ while ((lsr & BOTH_EMPTY) != BOTH_EMPTY) {
+ lsr = serial_in(p, UART_LSR);
+ cpu_relax();
+ }
+ }
em485->active_timer = NULL;
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index a27ef5f56431..9b13cf59726b 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -83,6 +83,7 @@ struct uart_8250_em485 {
struct hrtimer start_tx_timer; /* "rs485 start tx" timer */
struct hrtimer stop_tx_timer; /* "rs485 stop tx" timer */
struct hrtimer *active_timer; /* pointer to active timer */
+ bool has_temt_isr; /* say if 8250 has TEMT interrupt or no */
struct uart_8250_port *port; /* for hrtimer callbacks */
};
--
2.17.0
^ permalink raw reply related
* [PATCH 5/8] serial: 8250_dw: treat rpm suspend with -EBUSY if RS485 ON and RTS_AFTER_SEND
From: Giulio Benetti @ 2018-06-01 12:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Andy Shevchenko, Kees Cook, Matthias Brugger,
Allen Pais, Sean Young, Ed Blake, Stefan Potyra, Philipp Zabel,
Joshua Scott, Vignesh R, Rolf Evers-Fischer, Aaron Sierra,
Rafael Gago, Joel Stanley, Sean Wang, linux-serial, linux-kernel,
Giulio Benetti
In-Reply-To: <20180601124021.102970-1-giulio.benetti@micronovasrl.com>
If rs485 is on and RTS_AFTER_SEND it means that in idle state rts pin
must be asserted, othwerwise rs485 transceiver will enter tx state.
dw8250 when clocks are stopped keeps rts line de-asserted(high),
resulting in keeping rs485 transceiver in tx state when port is idle.
Check if rs485 is on with RTS_AFTER_SEND set, if so return -EBUSY in
rpm_suspend,
Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
drivers/tty/serial/8250/8250_dw.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 888280ff5451..6b0ee6dc8ad0 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -668,6 +668,11 @@ static int dw8250_resume(struct device *dev)
static int dw8250_runtime_suspend(struct device *dev)
{
struct dw8250_data *data = dev_get_drvdata(dev);
+ struct uart_8250_port *up = serial8250_get_port(data->line);
+ struct uart_port *p = &up->port;
+
+ if (p->rs485.flags & (SER_RS485_ENABLED | SER_RS485_RTS_AFTER_SEND))
+ return -EBUSY;
if (!IS_ERR(data->clk))
clk_disable_unprepare(data->clk);
--
2.17.0
^ permalink raw reply related
* [PATCH 6/8] serial: 8250: Copy mctrl when register port.
From: Giulio Benetti @ 2018-06-01 12:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Andy Shevchenko, Kees Cook, Matthias Brugger,
Allen Pais, Sean Young, Ed Blake, Stefan Potyra, Philipp Zabel,
Joshua Scott, Vignesh R, Rolf Evers-Fischer, Aaron Sierra,
Rafael Gago, Joel Stanley, Sean Wang, linux-serial, linux-kernel,
Giulio Benetti
In-Reply-To: <20180601124021.102970-1-giulio.benetti@micronovasrl.com>
RS485 can modify mctrl on startup, especially when RTS_AFTER_SEND is on
TIOCM_RTS is set, then need to keep it set when registering port.
Copy mctrl to new port too.
Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
drivers/tty/serial/8250/8250_core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index c8c2b260c681..c8e62fbd6570 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -993,6 +993,7 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
uart->port.unthrottle = up->port.unthrottle;
uart->port.rs485_config = up->port.rs485_config;
uart->port.rs485 = up->port.rs485;
+ uart->port.mctrl = up->port.mctrl;
uart->dma = up->dma;
uart->em485 = up->em485;
--
2.17.0
^ permalink raw reply related
* [PATCH 7/8] serial: 8250: Make em485_rts_after_send() set mctrl according to rts state.
From: Giulio Benetti @ 2018-06-01 12:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Andy Shevchenko, Kees Cook, Matthias Brugger,
Allen Pais, Sean Young, Ed Blake, Stefan Potyra, Philipp Zabel,
Joshua Scott, Vignesh R, Rolf Evers-Fischer, Aaron Sierra,
Rafael Gago, Joel Stanley, Sean Wang, linux-serial, linux-kernel,
Giulio Benetti
In-Reply-To: <20180601124021.102970-1-giulio.benetti@micronovasrl.com>
When rs485 enabled and RTS_AFTER_SEND set on startup, need to preserve
mctrl status, because later functions will call set_mctrl passing
port->mctrl=0 overriding rts status, resulting in rts pin in
transmission when idle.
Make mctrl reflect rts pin state.
Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
drivers/tty/serial/8250/8250_port.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index e14badbbf181..8432445c80e5 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -562,10 +562,13 @@ static inline void serial8250_em485_rts_after_send(struct uart_8250_port *p)
{
unsigned char mcr = serial8250_in_MCR(p);
- if (p->port.rs485.flags & SER_RS485_RTS_AFTER_SEND)
+ if (p->port.rs485.flags & SER_RS485_RTS_AFTER_SEND) {
mcr |= UART_MCR_RTS;
- else
+ p->port.mctrl |= TIOCM_RTS;
+ } else {
mcr &= ~UART_MCR_RTS;
+ p->port.mctrl &= ~TIOCM_RTS;
+ }
serial8250_out_MCR(p, mcr);
}
--
2.17.0
^ permalink raw reply related
* [PATCH 8/8] serial: core: Mask mctrl with TIOCM_RTS too if rs485 on and RTS_AFTER_SEND set.
From: Giulio Benetti @ 2018-06-01 12:40 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Andy Shevchenko, Kees Cook, Matthias Brugger,
Allen Pais, Sean Young, Ed Blake, Stefan Potyra, Philipp Zabel,
Joshua Scott, Vignesh R, Rolf Evers-Fischer, Aaron Sierra,
Rafael Gago, Joel Stanley, Sean Wang, linux-serial, linux-kernel,
Giulio Benetti
In-Reply-To: <20180601124021.102970-1-giulio.benetti@micronovasrl.com>
If rs485 is enabled and RTS_AFTER_SEND is set on startup need to keep
TIOCM_RTS asserted to keep rs485 transceiver in RX when idle.
Check if rs485 is on and RTS_AFTER_SEND is set and mask port->mctrl with
TIOCM_RTS too and not only TIOCM_DTR.
Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
drivers/tty/serial/serial_core.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 0466f9f08a91..06d9441f6d20 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2288,6 +2288,16 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state,
if (port->type != PORT_UNKNOWN) {
unsigned long flags;
+ int rs485_on = port->rs485_config &&
+ (port->rs485.flags & SER_RS485_ENABLED);
+ int RTS_after_send = !!(port->rs485.flags &
+ SER_RS485_RTS_AFTER_SEND);
+ int mctrl;
+
+ if (rs485_on && RTS_after_send)
+ mctrl = port->mctrl & (TIOCM_DTR | TIOCM_RTS);
+ else
+ mctrl = port->mctrl & TIOCM_DTR;
uart_report_port(drv, port);
@@ -2300,7 +2310,7 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state,
* We probably don't need a spinlock around this, but
*/
spin_lock_irqsave(&port->lock, flags);
- port->ops->set_mctrl(port, port->mctrl & TIOCM_DTR);
+ port->ops->set_mctrl(port, mctrl);
spin_unlock_irqrestore(&port->lock, flags);
/*
--
2.17.0
^ permalink raw reply related
* [PATCH 1/2] serial: 8250: enable SERIAL_MCTRL_GPIO by default.
From: Giulio Benetti @ 2018-06-01 14:11 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Andy Shevchenko, Kees Cook, Matthias Brugger,
Allen Pais, Sean Young, Ed Blake, Stefan Potyra, Philipp Zabel,
Joshua Scott, Vignesh R, Rolf Evers-Fischer, Aaron Sierra,
Rafael Gago, Joel Stanley, Sean Wang, linux-serial, linux-kernel,
Giulio Benetti
It can be useful to override 8250 mctrl lines with gpios, for rts on
rs485 for example, when rts is not mapped correctly to HW RTS pin.
Enable SERIAL_MCTRL_GPIO by default.
Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
drivers/tty/serial/8250/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig
index f005eaf8bc57..c7992b94fece 100644
--- a/drivers/tty/serial/8250/Kconfig
+++ b/drivers/tty/serial/8250/Kconfig
@@ -7,6 +7,7 @@ config SERIAL_8250
tristate "8250/16550 and compatible serial support"
depends on !S390
select SERIAL_CORE
+ select SERIAL_MCTRL_GPIO if GPIOLIB
---help---
This selects whether you want to include the driver for the standard
serial ports. The standard answer is Y. People who might say N
--
2.17.0
^ permalink raw reply related
* [PATCH 2/2] serial: 8250: Add SERIAL_MCTRL_GPIO support to 8250.
From: Giulio Benetti @ 2018-06-01 14:11 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Andy Shevchenko, Kees Cook, Matthias Brugger,
Allen Pais, Sean Young, Ed Blake, Stefan Potyra, Philipp Zabel,
Joshua Scott, Vignesh R, Rolf Evers-Fischer, Aaron Sierra,
Rafael Gago, Joel Stanley, Sean Wang, linux-serial, linux-kernel,
Giulio Benetti
In-Reply-To: <20180601141158.93817-1-giulio.benetti@micronovasrl.com>
Sometimes mctrl signals can be connected to pins different from HW ones.
User serial_mctrl_gpio helpers to align HW signals(RTS, CTS, etc.) with
gpios-rts, gpios-cts etc.
Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
drivers/tty/serial/8250/8250_core.c | 6 ++++++
drivers/tty/serial/8250/8250_port.c | 18 +++++++++++++++---
include/linux/serial_8250.h | 2 ++
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 9342fc2ee7df..c2bc906ffdf4 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -41,6 +41,8 @@
#include "8250.h"
+#include "../serial_mctrl_gpio.h"
+
/*
* Configuration:
* share_irqs - whether we pass IRQF_SHARED to request_irq(). This option
@@ -1036,6 +1038,10 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
if (up->dl_write)
uart->dl_write = up->dl_write;
+ uart->gpios = mctrl_gpio_init(&up->port, 0);
+ if (IS_ERR(uart->gpios))
+ return PTR_ERR(uart->gpios);
+
if (uart->port.type != PORT_8250_CIR) {
if (serial8250_isa_config != NULL)
serial8250_isa_config(0, &uart->port,
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 95833cbc4338..3004aa3ef4e5 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -40,6 +40,8 @@
#include "8250.h"
+#include "../serial_mctrl_gpio.h"
+
/*
* These are definitions for the Exar XR17V35X and XR17(C|D)15X
*/
@@ -567,6 +569,8 @@ static inline void serial8250_em485_rts_after_send(struct uart_8250_port *p)
else
mcr &= ~UART_MCR_RTS;
serial8250_out_MCR(p, mcr);
+
+ mctrl_gpio_set(p->gpios, p->port.mctrl);
}
static enum hrtimer_restart serial8250_em485_handle_start_tx(struct hrtimer *t);
@@ -1591,12 +1595,17 @@ static inline void start_tx_rs485(struct uart_port *port)
mcr = serial8250_in_MCR(up);
if (!!(up->port.rs485.flags & SER_RS485_RTS_ON_SEND) !=
!!(mcr & UART_MCR_RTS)) {
- if (up->port.rs485.flags & SER_RS485_RTS_ON_SEND)
+ if (up->port.rs485.flags & SER_RS485_RTS_ON_SEND) {
mcr |= UART_MCR_RTS;
- else
+ up->port.mctrl |= TIOCM_RTS;
+ } else {
mcr &= ~UART_MCR_RTS;
+ up->port.mctrl &= ~TIOCM_RTS;
+ }
serial8250_out_MCR(up, mcr);
+ mctrl_gpio_set(up->gpios, up->port.mctrl);
+
if (up->port.rs485.delay_rts_before_send > 0) {
em485->active_timer = &em485->start_tx_timer;
start_hrtimer_ms(&em485->start_tx_timer,
@@ -1957,7 +1966,8 @@ unsigned int serial8250_do_get_mctrl(struct uart_port *port)
ret |= TIOCM_DSR;
if (status & UART_MSR_CTS)
ret |= TIOCM_CTS;
- return ret;
+
+ return mctrl_gpio_get(up->gpios, &ret);
}
EXPORT_SYMBOL_GPL(serial8250_do_get_mctrl);
@@ -1987,6 +1997,8 @@ void serial8250_do_set_mctrl(struct uart_port *port, unsigned int mctrl)
mcr = (mcr & up->mcr_mask) | up->mcr_force | up->mcr;
serial8250_out_MCR(up, mcr);
+
+ mctrl_gpio_set(up->gpios, mctrl);
}
EXPORT_SYMBOL_GPL(serial8250_do_set_mctrl);
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index a27ef5f56431..7872f11d4b04 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -134,6 +134,8 @@ struct uart_8250_port {
void (*dl_write)(struct uart_8250_port *, int);
struct uart_8250_em485 *em485;
+
+ struct mctrl_gpios *gpios;
};
static inline struct uart_8250_port *up_to_u8250p(struct uart_port *up)
--
2.17.0
^ permalink raw reply related
* Re: [PATCH 0/4] lib/vsprintf: Remove atomic-unsafe support for printk format %pCr
From: Petr Mladek @ 2018-06-01 15:19 UTC (permalink / raw)
To: Linus Torvalds
Cc: Geert Uytterhoeven, baijiaju1990, Jonathan Corbet,
Michael Turquette, sboyd, Zhang Rui, Eduardo Valentin,
Eric Anholt, Stefan Wahren, Greg Kroah-Hartman,
Sergey Senozhatsky, Steven Rostedt, open list:DOCUMENTATION,
linux-clk, Linux PM, linux-serial, linux-arm-kernel,
Linux-Renesas, Linux Kernel Mailing List
In-Reply-To: <20180601114738.kdoggkha2yosjgbv@pathway.suse.cz>
On Fri 2018-06-01 13:47:38, Petr Mladek wrote:
> On Fri 2018-06-01 06:00:47, Linus Torvalds wrote:
> > On Fri, Jun 1, 2018 at 4:29 AM Geert Uytterhoeven
> > <geert+renesas@glider.be> wrote:
> > >
> > > This patch series:
> > > - Changes all existing users of "%pCr" to print the result of
> > > clk_get_rate() directly, which is safe as they all do this in task
> > > context only,
> > > - Removes support for the "%pCr" printk format.
> >
> > Looks good to me.
> >
> > What tree will this go through? The normal printk one? Just checking
> > that this doesn't end up falling through the cracks because nobody
> > knows who would take it...
>
> I will take it via printk.git. There already is bunch of vsprintf
> changes for-4.18.
It is in printk.git, branch for-4.18-vsprintf-pcr-removal now.
Also I have added Cc: stable@vger.kernel.org into the commit messages.
Best Regards,
Petr
^ permalink raw reply
* Re: [PATCH 0/4] lib/vsprintf: Remove atomic-unsafe support for printk format %pCr
From: Geert Uytterhoeven @ 2018-06-01 15:28 UTC (permalink / raw)
To: Petr Mladek
Cc: Linus Torvalds, Geert Uytterhoeven, Jia-Ju Bai, Jonathan Corbet,
Michael Turquette, Stephen Boyd, Zhang Rui, Eduardo Valentin,
Eric Anholt, Stefan Wahren, Greg Kroah-Hartman,
Sergey Senozhatsky, Steven Rostedt, open list:DOCUMENTATION,
linux-clk, Linux PM, linux-serial, linux-arm-kernel
In-Reply-To: <20180601151905.yilldc6vbachfw4k@pathway.suse.cz>
Hi Petr,
On Fri, Jun 1, 2018 at 5:19 PM, Petr Mladek <pmladek@suse.com> wrote:
> On Fri 2018-06-01 13:47:38, Petr Mladek wrote:
>> On Fri 2018-06-01 06:00:47, Linus Torvalds wrote:
>> > On Fri, Jun 1, 2018 at 4:29 AM Geert Uytterhoeven
>> > <geert+renesas@glider.be> wrote:
>> > >
>> > > This patch series:
>> > > - Changes all existing users of "%pCr" to print the result of
>> > > clk_get_rate() directly, which is safe as they all do this in task
>> > > context only,
>> > > - Removes support for the "%pCr" printk format.
>> >
>> > Looks good to me.
>> >
>> > What tree will this go through? The normal printk one? Just checking
>> > that this doesn't end up falling through the cracks because nobody
>> > knows who would take it...
>>
>> I will take it via printk.git. There already is bunch of vsprintf
>> changes for-4.18.
>
> It is in printk.git, branch for-4.18-vsprintf-pcr-removal now.
Thank you.
> Also I have added Cc: stable@vger.kernel.org into the commit messages.
I can confirm all stable version references ("v4.x+") match.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply
* Re: [PATCH 1/4] clk: renesas: cpg-mssr: Stop using printk format %pCr
From: Stephen Boyd @ 2018-06-01 16:37 UTC (permalink / raw)
To: Eduardo Valentin, Eric Anholt, Greg Kroah-Hartman, Jia-Ju Bai,
Jonathan Corbet, Michael Turquette, Stefan Wahren, Zhang Rui
Cc: Petr Mladek, Sergey Senozhatsky, Geert Uytterhoeven, linux-doc,
linux-pm, linux-kernel, Steven Rostedt, linux-renesas-soc,
linux-serial, Linus Torvalds, linux-clk, linux-arm-kernel
In-Reply-To: <1527845302-12159-2-git-send-email-geert+renesas@glider.be>
Quoting Geert Uytterhoeven (2018-06-01 02:28:19)
> Printk format "%pCr" will be removed soon, as clk_get_rate() must not be
> called in atomic context.
>
> Replace it by open-coding the operation. This is safe here, as the code
> runs in task context.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
Acked-by: Stephen Boyd <sboyd@kernel.org>
^ permalink raw reply
* Re: [PATCH 0/8] serial: 8250: Add 485 emulation to 8250_dw.
From: Andy Shevchenko @ 2018-06-04 10:12 UTC (permalink / raw)
To: Giulio Benetti, Greg Kroah-Hartman, Matwey V.Kornilov
Cc: Jiri Slaby, Kees Cook, Matthias Brugger, Allen Pais, Sean Young,
Ed Blake, Stefan Potyra, Philipp Zabel, Joshua Scott, Vignesh R,
Rolf Evers-Fischer, Aaron Sierra, Rafael Gago, Joel Stanley,
Sean Wang, linux-serial, linux-kernel
In-Reply-To: <20180601124021.102970-1-giulio.benetti@micronovasrl.com>
On Fri, 2018-06-01 at 14:40 +0200, Giulio Benetti wrote:
> Need to handle rs485 with 8250_dw port.
>
> Use existing em485 emulation layer for 8250 taking care to fix some
> bug
> and taking care especially of RTS_AFTER_SEND case.
>
I don't see in Cc list author of rs485 code, who might be interested in
this.
So, added him here.
> Giulio Benetti (8):
> serial: 8250_dw: add em485 support
> serial: 8250_dw: allow enable rs485 at boot time
> serial: 8250: Copy em485 from port to real port.
> serial: 8250: Handle case port doesn't have TEMT interrupt using
> em485.
> serial: 8250_dw: treat rpm suspend with -EBUSY if RS485 ON and
> RTS_AFTER_SEND
> serial: 8250: Copy mctrl when register port.
> serial: 8250: Make em485_rts_after_send() set mctrl according to rts
> state.
> serial: core: Mask mctrl with TIOCM_RTS too if rs485 on and
> RTS_AFTER_SEND set.
>
> drivers/tty/serial/8250/8250.h | 2 +-
> drivers/tty/serial/8250/8250_core.c | 2 ++
> drivers/tty/serial/8250/8250_dw.c | 41
> ++++++++++++++++++++++++++++-
> drivers/tty/serial/8250/8250_omap.c | 2 +-
> drivers/tty/serial/8250/8250_port.c | 33 ++++++++++++++++-------
> drivers/tty/serial/serial_core.c | 12 ++++++++-
> include/linux/serial_8250.h | 1 +
> 7 files changed, 79 insertions(+), 14 deletions(-)
>
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply
* Re: [PATCH 3/8] serial: 8250: Copy em485 from port to real port.
From: Andy Shevchenko @ 2018-06-04 10:13 UTC (permalink / raw)
To: Giulio Benetti, Greg Kroah-Hartman
Cc: Jiri Slaby, Kees Cook, Matthias Brugger, Allen Pais, Sean Young,
Ed Blake, Stefan Potyra, Philipp Zabel, Joshua Scott, Vignesh R,
Rolf Evers-Fischer, Aaron Sierra, Rafael Gago, Joel Stanley,
Sean Wang, linux-serial, linux-kernel
In-Reply-To: <20180601124021.102970-4-giulio.benetti@micronovasrl.com>
On Fri, 2018-06-01 at 14:40 +0200, Giulio Benetti wrote:
> em485 gets lost during serial8250_register_8250_port().
>
> Copy em485 to final uart port.
Fixes better to go first.
I think you need to reorder the series.
>
> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
> ---
> drivers/tty/serial/8250/8250_core.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/tty/serial/8250/8250_core.c
> b/drivers/tty/serial/8250/8250_core.c
> index 9342fc2ee7df..c8c2b260c681 100644
> --- a/drivers/tty/serial/8250/8250_core.c
> +++ b/drivers/tty/serial/8250/8250_core.c
> @@ -994,6 +994,7 @@ int serial8250_register_8250_port(struct
> uart_8250_port *up)
> uart->port.rs485_config = up-
> >port.rs485_config;
> uart->port.rs485 = up->port.rs485;
> uart->dma = up->dma;
> + uart->em485 = up->em485;
>
> /* Take tx_loadsz from fifosize if it wasn't set
> separately */
> if (uart->port.fifosize && !uart->tx_loadsz)
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply
* Re: [PATCH 4/8] serial: 8250: Handle case port doesn't have TEMT interrupt using em485.
From: Andy Shevchenko @ 2018-06-04 10:17 UTC (permalink / raw)
To: Giulio Benetti, Greg Kroah-Hartman
Cc: Jiri Slaby, Kees Cook, Matthias Brugger, Allen Pais, Sean Young,
Ed Blake, Stefan Potyra, Philipp Zabel, Joshua Scott, Vignesh R,
Rolf Evers-Fischer, Aaron Sierra, Rafael Gago, Joel Stanley,
Sean Wang, linux-serial, linux-kernel
In-Reply-To: <20180601124021.102970-5-giulio.benetti@micronovasrl.com>
On Fri, 2018-06-01 at 14:40 +0200, Giulio Benetti wrote:
> Some 8250 ports only have TEMT interrupt, so current implementation
> can't work for ports without it. The only chance to make it work is to
> loop-read on LSR register.
>
> With NO TEMT interrupt check if both TEMT and THRE are set looping on
> LSR register.
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
> - int ret = serial8250_em485_init(up);
> + int ret = serial8250_em485_init(up, false);
Is true for all possible DW configured types? Or it's your particular
case?
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply
* [PATCH v3 0/3] serial: xuartps: hardware race condition and cleanup
From: Helmut Grohne @ 2018-06-04 10:21 UTC (permalink / raw)
To: Greg Kroah-Hartman, Michal Simek, linux-serial
Cc: linux-arm-kernel, Uwe Kleine-König
The character transmission in xuartps is racy. If the transmitter is disabled
early, the device is confused and produces a desync. Garbage on the remote end
can be a visible symptom. The second patch in this series tries to reduce that
race condition in accordance with the hardware documentation, but it cannot
remove it entirely. The first and third patches are code cleanup.
Changes since v2:
* Do not attempt to disable the transmitter after a transmission (original
behaviour around 3.14). These patches no longer touch with the transmitter
state at all as requested by Sören Brinkmann.
* Add Acked-by/Reviewed-by tags from Sören Brinkmann after addressing his
remarks.
Earlier patches/discussion at:
https://www.spinics.net/lists/linux-serial/msg23145.html
https://www.spinics.net/lists/linux-serial/msg23156.html
https://www.spinics.net/lists/linux-serial/msg23157.html
Helmut Grohne (3):
serial: xuartps: fix typo in cdns_uart_startup
serial: xuartps: reduce hardware TX race condition
serial: xuartps: remove unnecessary register write
drivers/tty/serial/xilinx_uartps.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
--
2.11.0
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox