* [PATCH 1/2] tty: wipe buffer.
From: Greg Kroah-Hartman @ 2018-10-02 17:17 UTC (permalink / raw)
To: linux-serial
Cc: linux-kernel, jslaby, aszlig, gmazyland, torvalds, w,
Greg Kroah-Hartman
In-Reply-To: <20181002171708.1311-1-gregkh@linuxfoundation.org>
From: Linus Torvalds <torvalds@linux-foundation.org>
After we are done with the tty buffer, zero it out.
Reported-by: aszlig <aszlig@nix.build>
Tested-by: Milan Broz <gmazyland@gmail.com>
Tested-by: aszlig <aszlig@nix.build>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/tty/tty_buffer.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index c996b6859c5e..ae3ce330200e 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -468,11 +468,15 @@ receive_buf(struct tty_port *port, struct tty_buffer *head, int count)
{
unsigned char *p = char_buf_ptr(head, head->read);
char *f = NULL;
+ int n;
if (~head->flags & TTYB_NORMAL)
f = flag_buf_ptr(head, head->read);
- return port->client_ops->receive_buf(port, p, f, count);
+ n = port->client_ops->receive_buf(port, p, f, count);
+ if (n > 0)
+ memset(p, 0, n);
+ return n;
}
/**
--
2.19.0
^ permalink raw reply related
* [PATCH 2/2] tty: wipe buffer if not echoing data
From: Greg Kroah-Hartman @ 2018-10-02 17:17 UTC (permalink / raw)
To: linux-serial
Cc: linux-kernel, jslaby, aszlig, gmazyland, torvalds, w, Greg KH,
Greg Kroah-Hartman
In-Reply-To: <20181002171708.1311-1-gregkh@linuxfoundation.org>
From: Greg KH <greg@kroah.com>
If we are not echoing the data to userspace, then perhaps it is a
"secret" so we should wipe it once we are done with it.
This mirrors the logic that the audit code has.
Reported-by: aszlig <aszlig@nix.build>
Tested-by: Milan Broz <gmazyland@gmail.com>
Tested-by: aszlig <aszlig@nix.build>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/tty/n_tty.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 431742201709..d259a6585dbe 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -152,17 +152,28 @@ static inline unsigned char *echo_buf_addr(struct n_tty_data *ldata, size_t i)
return &ldata->echo_buf[i & (N_TTY_BUF_SIZE - 1)];
}
+/* If we are not echoing the data, perhaps this is a secret so erase it */
+static void zero_buffer(struct tty_struct *tty, u8 *buffer, int size)
+{
+ bool icanon = !!L_ICANON(tty);
+ bool no_echo = !L_ECHO(tty);
+
+ if (icanon && no_echo)
+ memset(buffer, 0x00, size);
+}
+
static int tty_copy_to_user(struct tty_struct *tty, void __user *to,
size_t tail, size_t n)
{
struct n_tty_data *ldata = tty->disc_data;
size_t size = N_TTY_BUF_SIZE - tail;
- const void *from = read_buf_addr(ldata, tail);
+ void *from = read_buf_addr(ldata, tail);
int uncopied;
if (n > size) {
tty_audit_add_data(tty, from, size);
uncopied = copy_to_user(to, from, size);
+ zero_buffer(tty, from, size);
if (uncopied)
return uncopied;
to += size;
@@ -171,7 +182,9 @@ static int tty_copy_to_user(struct tty_struct *tty, void __user *to,
}
tty_audit_add_data(tty, from, n);
- return copy_to_user(to, from, n);
+ uncopied = copy_to_user(to, from, n);
+ zero_buffer(tty, from, n);
+ return uncopied;
}
/**
@@ -1960,11 +1973,12 @@ static int copy_from_read_buf(struct tty_struct *tty,
n = min(head - ldata->read_tail, N_TTY_BUF_SIZE - tail);
n = min(*nr, n);
if (n) {
- const unsigned char *from = read_buf_addr(ldata, tail);
+ unsigned char *from = read_buf_addr(ldata, tail);
retval = copy_to_user(*b, from, n);
n -= retval;
is_eof = n == 1 && *from == EOF_CHAR(tty);
tty_audit_add_data(tty, from, n);
+ zero_buffer(tty, from, n);
smp_store_release(&ldata->read_tail, ldata->read_tail + n);
/* Turn single EOF into zero-length read */
if (L_EXTPROC(tty) && ldata->icanon && is_eof &&
--
2.19.0
^ permalink raw reply related
* Re: [PATCH 1/2] sc16is7xx: Fix for multi-channel stall
From: Greg Kroah-Hartman @ 2018-10-02 20:36 UTC (permalink / raw)
To: Andreas Färber
Cc: Phil Elwell, Jiri Slaby, linux-serial, linux-kernel,
Alexander Graf, Stefan Wahren, Mian Yousaf Kaukab,
Matthias Brugger, Michael Allwright, Jakub Kicinski, Xue Liu
In-Reply-To: <6028e8e5-f8a6-fbe0-8d2a-b6bb3c91aa14@suse.de>
On Sat, Sep 29, 2018 at 04:04:48PM +0200, Andreas Färber wrote:
> Hi Phil and Greg,
>
> Am 12.09.18 um 16:31 schrieb Phil Elwell:
> > The SC16IS752 is a dual-channel device. The two channels are largely
> > independent, but the IRQ signals are wired together as an open-drain,
> > active low signal which will be driven low while either of the
> > channels requires attention, which can be for significant periods of
> > time until operations complete and the interrupt can be acknowledged.
> > In that respect it is should be treated as a true level-sensitive IRQ.
> >
> > The kernel, however, needs to be able to exit interrupt context in
> > order to use I2C or SPI to access the device registers (which may
> > involve sleeping). Therefore the interrupt needs to be masked out or
> > paused in some way.
> >
> > The usual way to manage sleeping from within an interrupt handler
> > is to use a threaded interrupt handler - a regular interrupt routine
> > does the minimum amount of work needed to triage the interrupt before
> > waking the interrupt service thread. If the threaded IRQ is marked as
> > IRQF_ONESHOT the kernel will automatically mask out the interrupt
> > until the thread runs to completion. The sc16is7xx driver used to
> > use a threaded IRQ, but a patch switched to using a kthread_worker
> > in order to set realtime priorities on the handler thread and for
> > other optimisations. The end result is non-threaded IRQ that
> > schedules some work then returns IRQ_HANDLED, making the kernel
> > think that all IRQ processing has completed.
> >
> > The work-around to prevent a constant stream of interrupts is to
> > mark the interrupt as edge-sensitive rather than level-sensitive,
> > but interpreting an active-low source as a falling-edge source
> > requires care to prevent a total cessation of interrupts. Whereas
> > an edge-triggering source will generate a new edge for every interrupt
> > condition a level-triggering source will keep the signal at the
> > interrupting level until it no longer requires attention; in other
> > words, the host won't see another edge until all interrupt conditions
> > are cleared. It is therefore vital that the interrupt handler does not
> > exit with an outstanding interrupt condition, otherwise the kernel
> > will not receive another interrupt unless some other operation causes
> > the interrupt state on the device to be cleared.
> >
> > The existing sc16is7xx driver has a very simple interrupt "thread"
> > (kthread_work job) that processes interrupts on each channel in turn
> > until there are no more. If both channels are active and the first
> > channel starts interrupting while the handler for the second channel
> > is running then it will not be detected and an IRQ stall ensues. This
> > could be handled easily if there was a shared IRQ status register, or
> > a convenient way to determine if the IRQ had been deasserted for any
> > length of time, but both appear to be lacking.
> >
> > Avoid this problem (or at least make it much less likely to happen)
> > by reducing the granularity of per-channel interrupt processing
> > to one condition per iteration, only exiting the overall loop when
> > both channels are no longer interrupting.
> >
> > Signed-off-by: Phil Elwell <phil@raspberrypi.org>
> > ---
> > drivers/tty/serial/sc16is7xx.c | 19 +++++++++++++------
> > 1 file changed, 13 insertions(+), 6 deletions(-)
>
> These two patches seem to be applied in linux-next tree, but are lacking
> a Fixes: header for backporting to affected stable trees.
>
> openSUSE Tumbleweed's 4.18 appears to be affected, and I didn't see it
> in linux.git for upcoming 4.19 either.
>
> Can the commit message still be updated to get this fixed everywhere?
I can't change the tree, sorry, I can not rebase.
If you want these applied to the stable tree, please email
stable@vger.kernel.org when they hit Linus's tree with the git commit
ids and I will be glad to queue them up then.
thanks,
greg k-h
^ permalink raw reply
* Re: Re: [PATCH] tty:serial:imx: use spin_lock instead of spin_lock_irqsave in isr
From: Greg Kroah-Hartman @ 2018-10-02 20:37 UTC (permalink / raw)
To: 钱君
Cc: Uwe Kleine-König, Barry song, Jiri Slaby, linux-serial,
linux-kernel, kernel
In-Reply-To: <5205c4b4.20a1.166326bb238.Coremail.hangdianqj@163.com>
On Tue, Oct 02, 2018 at 09:36:50AM +0800, 钱君 wrote:
>
>
> I have changed the description content, please refer to the patch file, thanks a lot
I can not apply patches from attachments like this, please resend it
properly and I will be glad to review it.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH 0/2] serial: sh-sci: Fix earlycon on Renesas ARM platforms
From: Greg KH @ 2018-10-02 21:38 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Jiri Slaby, Chris Brandt, Wolfram Sang, uli+renesas,
open list:SERIAL DRIVERS, Linux-Renesas,
Linux Kernel Mailing List, Geert Uytterhoeven
In-Reply-To: <CAMuHMdWdByKxivbQwWL9yF9_r8XObnZuXEZvf_9ZWKYYLWr1bQ@mail.gmail.com>
On Thu, Sep 27, 2018 at 09:38:19AM +0200, Geert Uytterhoeven wrote:
> Hi Greg,
>
> On Thu, Aug 30, 2018 at 2:54 PM Geert Uytterhoeven
> <geert+renesas@glider.be> wrote:
> > Due to an unfortunate oversight, commit 2d4dd0da45401c7a ("serial: sh-sci:
> > Allow for compressed SCIF address") broke earlycon on all Renesas ARM
> > platforms using a SCIF port for the serial console (R-Car, RZ/A1, RZ/G1,
> > RZ/G2 SoCs), due to an incorrect value of port->regshift.
> >
> > This patch series fixes that by reverting that commit, and a (reverse)
> > dependency.
> >
> > Earlycon for RZ/A2 (which is a new platform) will be fixed later in a
> > separate patch.
> >
> > Thanks for applying!
> >
> > Geert Uytterhoeven (2):
> > Revert "serial: sh-sci: Remove SCIx_RZ_SCIFA_REGTYPE"
> > Revert "serial: sh-sci: Allow for compressed SCIF address"
> >
> > drivers/tty/serial/sh-sci.c | 56 +++++++++++++++++++++++++++----------
> > include/linux/serial_sci.h | 1 +
> > 2 files changed, 42 insertions(+), 15 deletions(-)
>
> These are now in tty-next:
>
> 10c63443b74d1ef5 Revert "serial: sh-sci: Remove SCIx_RZ_SCIFA_REGTYPE"
> a1c2fd7e1098ea49 Revert "serial: sh-sci: Allow for compressed SCIF address"
>
> Can you please include them in v4.19-rc6, as they fix a regression introduced
> in v4.19-rc1?
>
> In addition:
>
> 3d8b43ad9c0cf023 serial: sh-sci: Add earlycon for R7S9210
>
> (also in tty-next) enables earlycon on RZ/A2 again, as it was disabled
> by the two
> reverts above.
>
> Thanks a lot!
Now fixed up, thanks.
greg k-h
^ permalink raw reply
* Re: [PATCH 2/2] tty: wipe buffer if not echoing data
From: Milan Broz @ 2018-10-03 6:55 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-serial
Cc: linux-kernel, jslaby, aszlig, torvalds, w, Greg KH
In-Reply-To: <20181002171708.1311-3-gregkh@linuxfoundation.org>
On 02/10/2018 19:17, Greg Kroah-Hartman wrote:
> From: Greg KH <greg@kroah.com>
>
> If we are not echoing the data to userspace, then perhaps it is a
> "secret" so we should wipe it once we are done with it.
Just to explain our test case for cryptsetup, where aszlig initially reported it:
cryptsetup reads a passphrase from terminal, derives a candidate key for keyslot
decryption and immediately wipes the passphrase from memory, because it is
not needed anymore.
And here is the problem - the kernel keeps this passphrase in a tty buffer memory
that is no longer available to userspace. It can be retrieved from memory dump
later, even after the crypt mapping is destroyed.
Almost all userspace tools working with passphrases through tty access have
the same problem here.
> This mirrors the logic that the audit code has.
>
> Reported-by: aszlig <aszlig@nix.build>
> Tested-by: Milan Broz <gmazyland@gmail.com>
> Tested-by: aszlig <aszlig@nix.build>
> Cc: Willy Tarreau <w@1wt.eu>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> drivers/tty/n_tty.c | 20 +++++++++++++++++---
...
> static int tty_copy_to_user(struct tty_struct *tty, void __user *to,
> size_t tail, size_t n)
> {
> struct n_tty_data *ldata = tty->disc_data;
> size_t size = N_TTY_BUF_SIZE - tail;
> - const void *from = read_buf_addr(ldata, tail);
> + void *from = read_buf_addr(ldata, tail);
> int uncopied;
>
> if (n > size) {
> tty_audit_add_data(tty, from, size);
> uncopied = copy_to_user(to, from, size);
> + zero_buffer(tty, from, size);
I think Linus mentioned in some previous mail that there should be
zero_buffer(tty, from, size - uncopied);
to avoid wiping of yet uncopied data.
I tested the unmodified version though...
> if (uncopied)
> return uncopied;
> to += size;
> @@ -171,7 +182,9 @@ static int tty_copy_to_user(struct tty_struct *tty, void __user *to,
> }
>
> tty_audit_add_data(tty, from, n);
> - return copy_to_user(to, from, n);
> + uncopied = copy_to_user(to, from, n);
> + zero_buffer(tty, from, n);
> + return uncopied;
> }
Milan
^ permalink raw reply
* [PATCH] TTY: Replace spin_is_locked() with spin_trylock()
From: Lance Roy @ 2018-10-04 7:14 UTC (permalink / raw)
To: linux-kernel
Cc: Paul E. McKenney, Lance Roy, Greg Kroah-Hartman, Jiri Slaby,
linux-serial
sn_sal_console_write() used spin_is_locked() + spin_lock() to get
achieve the same thing as a spin_trylock(), so simplify it by using that
instead. This is also a step towards possibly removing spin_is_locked().
Signed-off-by: Lance Roy <ldr709@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: <linux-serial@vger.kernel.org>
---
drivers/tty/serial/sn_console.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/tty/serial/sn_console.c b/drivers/tty/serial/sn_console.c
index 42b9aded4eb1..fe9170731c16 100644
--- a/drivers/tty/serial/sn_console.c
+++ b/drivers/tty/serial/sn_console.c
@@ -888,7 +888,7 @@ sn_sal_console_write(struct console *co, const char *s, unsigned count)
/* somebody really wants this output, might be an
* oops, kdb, panic, etc. make sure they get it. */
- if (spin_is_locked(&port->sc_port.lock)) {
+ if (!spin_trylock_irqsave(&port->sc_port.lock, flags)) {
int lhead = port->sc_port.state->xmit.head;
int ltail = port->sc_port.state->xmit.tail;
int counter, got_lock = 0;
@@ -905,13 +905,11 @@ sn_sal_console_write(struct console *co, const char *s, unsigned count)
*/
for (counter = 0; counter < 150; mdelay(125), counter++) {
- if (!spin_is_locked(&port->sc_port.lock)
- || stole_lock) {
- if (!stole_lock) {
- spin_lock_irqsave(&port->sc_port.lock,
- flags);
- got_lock = 1;
- }
+ if (stole_lock)
+ break;
+
+ if (spin_trylock_irqsave(&port->sc_port.lock, flags)) {
+ got_lock = 1;
break;
} else {
/* still locked */
@@ -938,7 +936,6 @@ sn_sal_console_write(struct console *co, const char *s, unsigned count)
puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
} else {
stole_lock = 0;
- spin_lock_irqsave(&port->sc_port.lock, flags);
sn_transmit_chars(port, 1);
spin_unlock_irqrestore(&port->sc_port.lock, flags);
--
2.19.0
^ permalink raw reply related
* Re: [PATCH] Revert "serial: 8250_dw: Fix runtime PM handling"
From: Andy Shevchenko @ 2018-10-04 8:54 UTC (permalink / raw)
To: Guenter Roeck
Cc: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel,
Tony Lindgren, Phil Edworthy
In-Reply-To: <1538455357-16344-1-git-send-email-linux@roeck-us.net>
On Mon, Oct 01, 2018 at 09:42:37PM -0700, Guenter Roeck wrote:
> This reverts commit d76c74387e1c978b6c5524a146ab0f3f72206f98.
>
> While commit d76c74387e1c ("serial: 8250_dw: Fix runtime PM handling")
> fixes runtime PM handling when using kgdb, it introduces a traceback for
> everyone else.
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
However, I would prefer to have a better solution as Tony already spelled out.
>
> BUG: sleeping function called from invalid context at
> /mnt/host/source/src/third_party/kernel/next/drivers/base/power/runtime.c:1034
> in_atomic(): 1, irqs_disabled(): 1, pid: 1, name: swapper/0
> 7 locks held by swapper/0/1:
> #0: 000000005ec5bc72 (&dev->mutex){....}, at: __driver_attach+0xb5/0x12b
> #1: 000000005d5fa9e5 (&dev->mutex){....}, at: __device_attach+0x3e/0x15b
> #2: 0000000047e93286 (serial_mutex){+.+.}, at: serial8250_register_8250_port+0x51/0x8bb
> #3: 000000003b328f07 (port_mutex){+.+.}, at: uart_add_one_port+0xab/0x8b0
> #4: 00000000fa313d4d (&port->mutex){+.+.}, at: uart_add_one_port+0xcc/0x8b0
> #5: 00000000090983ca (console_lock){+.+.}, at: vprintk_emit+0xdb/0x217
> #6: 00000000c743e583 (console_owner){-...}, at: console_unlock+0x211/0x60f
> irq event stamp: 735222
> __down_trylock_console_sem+0x4a/0x84
> console_unlock+0x338/0x60f
> __do_softirq+0x4a4/0x50d
> irq_exit+0x64/0xe2
> CPU: 2 PID: 1 Comm: swapper/0 Not tainted 4.19.0-rc5 #6
> Hardware name: Google Caroline/Caroline, BIOS Google_Caroline.7820.286.0 03/15/2017
> Call Trace:
> dump_stack+0x7d/0xbd
> ___might_sleep+0x238/0x259
> __pm_runtime_resume+0x4e/0xa4
> ? serial8250_rpm_get+0x2e/0x44
> serial8250_console_write+0x44/0x301
> ? lock_acquire+0x1b8/0x1fa
> console_unlock+0x577/0x60f
> vprintk_emit+0x1f0/0x217
> printk+0x52/0x6e
> register_console+0x43b/0x524
> uart_add_one_port+0x672/0x8b0
> ? set_io_from_upio+0x150/0x162
> serial8250_register_8250_port+0x825/0x8bb
> dw8250_probe+0x80c/0x8b0
> ? dw8250_serial_inq+0x8e/0x8e
> ? dw8250_check_lcr+0x108/0x108
> ? dw8250_runtime_resume+0x5b/0x5b
> ? dw8250_serial_outq+0xa1/0xa1
> ? dw8250_remove+0x115/0x115
> platform_drv_probe+0x76/0xc5
> really_probe+0x1f1/0x3ee
> ? driver_allows_async_probing+0x5d/0x5d
> driver_probe_device+0xd6/0x112
> ? driver_allows_async_probing+0x5d/0x5d
> bus_for_each_drv+0xbe/0xe5
> __device_attach+0xdd/0x15b
> bus_probe_device+0x5a/0x10b
> device_add+0x501/0x894
> ? _raw_write_unlock+0x27/0x3a
> platform_device_add+0x224/0x2b7
> mfd_add_device+0x718/0x75b
> ? __kmalloc+0x144/0x16a
> ? mfd_add_devices+0x38/0xdb
> mfd_add_devices+0x9b/0xdb
> intel_lpss_probe+0x7d4/0x8ee
> intel_lpss_pci_probe+0xac/0xd4
> pci_device_probe+0x101/0x18e
> ...
>
> Revert the offending patch until a more comprehensive solution
> is available.
>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Phil Edworthy <phil.edworthy@renesas.com>
> Fixes: d76c74387e1c ("serial: 8250_dw: Fix runtime PM handling")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/tty/serial/8250/8250_dw.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
> index fa8dcb470640..d31b975dd3fd 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
> @@ -630,10 +630,6 @@ static int dw8250_probe(struct platform_device *pdev)
> if (!data->skip_autocfg)
> dw8250_setup_port(p);
>
> -#ifdef CONFIG_PM
> - uart.capabilities |= UART_CAP_RPM;
> -#endif
> -
> /* If we have a valid fifosize, try hooking up DMA */
> if (p->fifosize) {
> data->dma.rxconf.src_maxburst = p->fifosize / 4;
> --
> 2.7.4
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* [PATCH v2 0/2] tty: erase buffers when the kernel is done with it.
From: Greg Kroah-Hartman @ 2018-10-04 18:06 UTC (permalink / raw)
To: linux-serial
Cc: linux-kernel, jslaby, aszlig, gmazyland, torvalds, w,
Greg Kroah-Hartman
azlig and Milan Broz reported that when the tty layer is done with a
buffer, the data can hang around in it for a very long time. That
sometimes can "leak" to userspace under some conditions.
Because of this, just zero out the data after the tty layer is finished
with it, for buffers that we "think" should be zeroed out.
v2 - addressed some review comments on the 2/2 patch.
Greg Kroah-Hartman (1):
tty: wipe buffer if not echoing data
Linus Torvalds (1):
tty: wipe buffer.
drivers/tty/n_tty.c | 20 +++++++++++++++++---
drivers/tty/tty_buffer.c | 6 +++++-
2 files changed, 22 insertions(+), 4 deletions(-)
--
2.19.0
^ permalink raw reply
* [PATCH v2 1/2] tty: wipe buffer.
From: Greg Kroah-Hartman @ 2018-10-04 18:06 UTC (permalink / raw)
To: linux-serial
Cc: linux-kernel, jslaby, aszlig, gmazyland, torvalds, w,
Greg Kroah-Hartman
In-Reply-To: <20181004180614.25619-1-gregkh@linuxfoundation.org>
From: Linus Torvalds <torvalds@linux-foundation.org>
After we are done with the tty buffer, zero it out.
Reported-by: aszlig <aszlig@nix.build>
Tested-by: Milan Broz <gmazyland@gmail.com>
Tested-by: aszlig <aszlig@nix.build>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
v2 - no change
drivers/tty/tty_buffer.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index c996b6859c5e..ae3ce330200e 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -468,11 +468,15 @@ receive_buf(struct tty_port *port, struct tty_buffer *head, int count)
{
unsigned char *p = char_buf_ptr(head, head->read);
char *f = NULL;
+ int n;
if (~head->flags & TTYB_NORMAL)
f = flag_buf_ptr(head, head->read);
- return port->client_ops->receive_buf(port, p, f, count);
+ n = port->client_ops->receive_buf(port, p, f, count);
+ if (n > 0)
+ memset(p, 0, n);
+ return n;
}
/**
--
2.19.0
^ permalink raw reply related
* [PATCH v2 2/2] tty: wipe buffer if not echoing data
From: Greg Kroah-Hartman @ 2018-10-04 18:06 UTC (permalink / raw)
To: linux-serial
Cc: linux-kernel, jslaby, aszlig, gmazyland, torvalds, w, Greg KH,
Greg Kroah-Hartman
In-Reply-To: <20181004180614.25619-1-gregkh@linuxfoundation.org>
From: Greg KH <greg@kroah.com>
If we are not echoing the data to userspace or the console is in icanon
mode, then perhaps it is a "secret" so we should wipe it once we are
done with it.
This mirrors the logic that the audit code has.
Reported-by: aszlig <aszlig@nix.build>
Tested-by: Milan Broz <gmazyland@gmail.com>
Tested-by: aszlig <aszlig@nix.build>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
v2 - update changelog comment to mention icanon
address the fact that copy_to_user() might not copy the whole buffer
drivers/tty/n_tty.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 431742201709..3ad460219fd6 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -152,17 +152,28 @@ static inline unsigned char *echo_buf_addr(struct n_tty_data *ldata, size_t i)
return &ldata->echo_buf[i & (N_TTY_BUF_SIZE - 1)];
}
+/* If we are not echoing the data, perhaps this is a secret so erase it */
+static void zero_buffer(struct tty_struct *tty, u8 *buffer, int size)
+{
+ bool icanon = !!L_ICANON(tty);
+ bool no_echo = !L_ECHO(tty);
+
+ if (icanon && no_echo)
+ memset(buffer, 0x00, size);
+}
+
static int tty_copy_to_user(struct tty_struct *tty, void __user *to,
size_t tail, size_t n)
{
struct n_tty_data *ldata = tty->disc_data;
size_t size = N_TTY_BUF_SIZE - tail;
- const void *from = read_buf_addr(ldata, tail);
+ void *from = read_buf_addr(ldata, tail);
int uncopied;
if (n > size) {
tty_audit_add_data(tty, from, size);
uncopied = copy_to_user(to, from, size);
+ zero_buffer(tty, from, size - uncopied);
if (uncopied)
return uncopied;
to += size;
@@ -171,7 +182,9 @@ static int tty_copy_to_user(struct tty_struct *tty, void __user *to,
}
tty_audit_add_data(tty, from, n);
- return copy_to_user(to, from, n);
+ uncopied = copy_to_user(to, from, n);
+ zero_buffer(tty, from, n - uncopied);
+ return uncopied;
}
/**
@@ -1960,11 +1973,12 @@ static int copy_from_read_buf(struct tty_struct *tty,
n = min(head - ldata->read_tail, N_TTY_BUF_SIZE - tail);
n = min(*nr, n);
if (n) {
- const unsigned char *from = read_buf_addr(ldata, tail);
+ unsigned char *from = read_buf_addr(ldata, tail);
retval = copy_to_user(*b, from, n);
n -= retval;
is_eof = n == 1 && *from == EOF_CHAR(tty);
tty_audit_add_data(tty, from, n);
+ zero_buffer(tty, from, n);
smp_store_release(&ldata->read_tail, ldata->read_tail + n);
/* Turn single EOF into zero-length read */
if (L_EXTPROC(tty) && ldata->icanon && is_eof &&
--
2.19.0
^ permalink raw reply related
* [PATCH 0/5] termios: remove arch redundancy in <asm/termbits.h>
From: H. Peter Anvin (Intel) @ 2018-10-04 22:29 UTC (permalink / raw)
To: linux-kernel, linux-arch, linux-serial
Cc: H. Peter Anvin (Intel), James E.J. Bottomley, Arnd Bergmann,
Chris Zankel, Fenghua Yu, Greg Kroah-Hartman, Helge Deller,
James Hogan, Jiri Slaby, Kate Stewart, Max Filippov, Paul Burton,
Philippe Ombredanne, Ralf Baechle, Thomas Gleixner, Tony Luck,
linux-ia64, linux-mips, linux-parisc, linux-xtensa
<asm/termbits.h> is one of those files which define an ABI. Some were
made different due to the desire to be compatible with legacy
architectures, others were mostly direct copies of the i386
definitions, which are now in asm-generic.
This folds the IA64, MIPS, PA-RISC, and Xtensa implementations into
the generic one. IA64 and Xtensa are identical, MIPS and PA-RISC are
trivially different and just need a handful of constants redefined.
<asm-generic/termbits.h> has a few very minor adjustments to allow this.
arch/ia64/include/uapi/asm/termbits.h | 210 +-----------------------------
arch/mips/include/uapi/asm/ioctls.h | 2 +
arch/mips/include/uapi/asm/termbits.h | 213 ++----------------------------
arch/parisc/include/uapi/asm/termbits.h | 197 +---------------------------
arch/xtensa/include/uapi/asm/termbits.h | 222 +-------------------------------
include/uapi/asm-generic/termbits.h | 7 +-
6 files changed, 27 insertions(+), 824 deletions(-)
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Chris Zankel <chris@zankel.net>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Helge Deller <deller@gmx.de>
Cc: James Hogan <jhogan@kernel.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Paul Burton <paul.burton@mips.com>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: <linux-ia64@vger.kernel.org>
Cc: <linux-mips@linux-mips.org>
Cc: <linux-parisc@vger.kernel.org>
Cc: <linux-xtensa@linux-xtensa.org>
^ permalink raw reply
* [PATCH 1/5] asm-generic, termios: add alias constants from MIPS
From: H. Peter Anvin (Intel) @ 2018-10-04 22:29 UTC (permalink / raw)
To: linux-kernel, linux-arch, linux-serial
Cc: H. Peter Anvin (Intel), Arnd Bergmann, Greg Kroah-Hartman,
Jiri Slaby
In-Reply-To: <20181004222953.2229-1-hpa@zytor.com>
Some architectures, in this case MIPS, need a couple of legacy alias
constants for bits. There really is no reason why we can't define them
generically for all architectures.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
linux-kernel@vger.kernel.org (open list)
---
include/uapi/asm-generic/termbits.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/uapi/asm-generic/termbits.h b/include/uapi/asm-generic/termbits.h
index 2fbaf9ae89dd..96ae175eec5b 100644
--- a/include/uapi/asm-generic/termbits.h
+++ b/include/uapi/asm-generic/termbits.h
@@ -8,7 +8,10 @@ typedef unsigned char cc_t;
typedef unsigned int speed_t;
typedef unsigned int tcflag_t;
-#define NCCS 19
+#ifndef NCCS
+# define NCCS 19
+#endif
+
struct termios {
tcflag_t c_iflag; /* input mode flags */
tcflag_t c_oflag; /* output mode flags */
@@ -49,6 +52,7 @@ struct ktermios {
#define VTIME 5
#define VMIN 6
#define VSWTC 7
+#define VSWTCH VSWTC
#define VSTART 8
#define VSTOP 9
#define VSUSP 10
@@ -173,6 +177,7 @@ struct ktermios {
#define ECHONL 0000100
#define NOFLSH 0000200
#define TOSTOP 0000400
+#define ITOSTOP TOSTOP
#define ECHOCTL 0001000
#define ECHOPRT 0002000
#define ECHOKE 0004000
--
2.14.4
^ permalink raw reply related
* [PATCH 2/5] arch/ia64, termios: use <asm-generic/termbits.h>
From: H. Peter Anvin (Intel) @ 2018-10-04 22:29 UTC (permalink / raw)
To: linux-kernel, linux-arch, linux-serial
Cc: H. Peter Anvin (Intel), Tony Luck, Fenghua Yu, Kate Stewart,
Philippe Ombredanne, Greg Kroah-Hartman, Thomas Gleixner,
linux-ia64, Jiri Slaby
In-Reply-To: <20181004222953.2229-1-hpa@zytor.com>
The IA64 definition of termbits.h is identical to the generic.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: <linux-ia64@vger.kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: Jiri Slaby <jslaby@suse.com>
---
arch/ia64/include/uapi/asm/termbits.h | 210 +---------------------------------
1 file changed, 1 insertion(+), 209 deletions(-)
diff --git a/arch/ia64/include/uapi/asm/termbits.h b/arch/ia64/include/uapi/asm/termbits.h
index 000a1a297c75..3935b106de79 100644
--- a/arch/ia64/include/uapi/asm/termbits.h
+++ b/arch/ia64/include/uapi/asm/termbits.h
@@ -1,209 +1 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _ASM_IA64_TERMBITS_H
-#define _ASM_IA64_TERMBITS_H
-
-/*
- * Based on <asm-i386/termbits.h>.
- *
- * Modified 1999
- * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
- *
- * 99/01/28 Added new baudrates
- */
-
-#include <linux/posix_types.h>
-
-typedef unsigned char cc_t;
-typedef unsigned int speed_t;
-typedef unsigned int tcflag_t;
-
-#define NCCS 19
-struct termios {
- tcflag_t c_iflag; /* input mode flags */
- tcflag_t c_oflag; /* output mode flags */
- tcflag_t c_cflag; /* control mode flags */
- tcflag_t c_lflag; /* local mode flags */
- cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
-};
-
-struct termios2 {
- tcflag_t c_iflag; /* input mode flags */
- tcflag_t c_oflag; /* output mode flags */
- tcflag_t c_cflag; /* control mode flags */
- tcflag_t c_lflag; /* local mode flags */
- cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
- speed_t c_ispeed; /* input speed */
- speed_t c_ospeed; /* output speed */
-};
-
-struct ktermios {
- tcflag_t c_iflag; /* input mode flags */
- tcflag_t c_oflag; /* output mode flags */
- tcflag_t c_cflag; /* control mode flags */
- tcflag_t c_lflag; /* local mode flags */
- cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
- speed_t c_ispeed; /* input speed */
- speed_t c_ospeed; /* output speed */
-};
-
-/* c_cc characters */
-#define VINTR 0
-#define VQUIT 1
-#define VERASE 2
-#define VKILL 3
-#define VEOF 4
-#define VTIME 5
-#define VMIN 6
-#define VSWTC 7
-#define VSTART 8
-#define VSTOP 9
-#define VSUSP 10
-#define VEOL 11
-#define VREPRINT 12
-#define VDISCARD 13
-#define VWERASE 14
-#define VLNEXT 15
-#define VEOL2 16
-
-/* c_iflag bits */
-#define IGNBRK 0000001
-#define BRKINT 0000002
-#define IGNPAR 0000004
-#define PARMRK 0000010
-#define INPCK 0000020
-#define ISTRIP 0000040
-#define INLCR 0000100
-#define IGNCR 0000200
-#define ICRNL 0000400
-#define IUCLC 0001000
-#define IXON 0002000
-#define IXANY 0004000
-#define IXOFF 0010000
-#define IMAXBEL 0020000
-#define IUTF8 0040000
-
-/* c_oflag bits */
-#define OPOST 0000001
-#define OLCUC 0000002
-#define ONLCR 0000004
-#define OCRNL 0000010
-#define ONOCR 0000020
-#define ONLRET 0000040
-#define OFILL 0000100
-#define OFDEL 0000200
-#define NLDLY 0000400
-#define NL0 0000000
-#define NL1 0000400
-#define CRDLY 0003000
-#define CR0 0000000
-#define CR1 0001000
-#define CR2 0002000
-#define CR3 0003000
-#define TABDLY 0014000
-#define TAB0 0000000
-#define TAB1 0004000
-#define TAB2 0010000
-#define TAB3 0014000
-#define XTABS 0014000
-#define BSDLY 0020000
-#define BS0 0000000
-#define BS1 0020000
-#define VTDLY 0040000
-#define VT0 0000000
-#define VT1 0040000
-#define FFDLY 0100000
-#define FF0 0000000
-#define FF1 0100000
-
-/* c_cflag bit meaning */
-#define CBAUD 0010017
-#define B0 0000000 /* hang up */
-#define B50 0000001
-#define B75 0000002
-#define B110 0000003
-#define B134 0000004
-#define B150 0000005
-#define B200 0000006
-#define B300 0000007
-#define B600 0000010
-#define B1200 0000011
-#define B1800 0000012
-#define B2400 0000013
-#define B4800 0000014
-#define B9600 0000015
-#define B19200 0000016
-#define B38400 0000017
-#define EXTA B19200
-#define EXTB B38400
-#define CSIZE 0000060
-#define CS5 0000000
-#define CS6 0000020
-#define CS7 0000040
-#define CS8 0000060
-#define CSTOPB 0000100
-#define CREAD 0000200
-#define PARENB 0000400
-#define PARODD 0001000
-#define HUPCL 0002000
-#define CLOCAL 0004000
-#define CBAUDEX 0010000
-#define BOTHER 0010000
-#define B57600 0010001
-#define B115200 0010002
-#define B230400 0010003
-#define B460800 0010004
-#define B500000 0010005
-#define B576000 0010006
-#define B921600 0010007
-#define B1000000 0010010
-#define B1152000 0010011
-#define B1500000 0010012
-#define B2000000 0010013
-#define B2500000 0010014
-#define B3000000 0010015
-#define B3500000 0010016
-#define B4000000 0010017
-#define CIBAUD 002003600000 /* input baud rate */
-#define CMSPAR 010000000000 /* mark or space (stick) parity */
-#define CRTSCTS 020000000000 /* flow control */
-
-#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
-
-/* c_lflag bits */
-#define ISIG 0000001
-#define ICANON 0000002
-#define XCASE 0000004
-#define ECHO 0000010
-#define ECHOE 0000020
-#define ECHOK 0000040
-#define ECHONL 0000100
-#define NOFLSH 0000200
-#define TOSTOP 0000400
-#define ECHOCTL 0001000
-#define ECHOPRT 0002000
-#define ECHOKE 0004000
-#define FLUSHO 0010000
-#define PENDIN 0040000
-#define IEXTEN 0100000
-#define EXTPROC 0200000
-
-/* tcflow() and TCXONC use these */
-#define TCOOFF 0
-#define TCOON 1
-#define TCIOFF 2
-#define TCION 3
-
-/* tcflush() and TCFLSH use these */
-#define TCIFLUSH 0
-#define TCOFLUSH 1
-#define TCIOFLUSH 2
-
-/* tcsetattr uses these */
-#define TCSANOW 0
-#define TCSADRAIN 1
-#define TCSAFLUSH 2
-
-#endif /* _ASM_IA64_TERMBITS_H */
+#include <asm-generic/termbits.h>
--
2.14.4
^ permalink raw reply related
* [PATCH 3/5] arch/mips, termios: use <asm-generic/termbits.h>
From: H. Peter Anvin (Intel) @ 2018-10-04 22:29 UTC (permalink / raw)
To: linux-kernel, linux-arch, linux-serial
Cc: H. Peter Anvin (Intel), Ralf Baechle, Paul Burton, James Hogan,
Philippe Ombredanne, Greg Kroah-Hartman, Kate Stewart,
Thomas Gleixner, linux-mips, Jiri Slaby
In-Reply-To: <20181004222953.2229-1-hpa@zytor.com>
The MIPS definition of termbits.h is almost identical to the generic
one, so use the generic one and only redefine a handful of constants.
Move TIOCSER_TEMT to ioctls.h where it lives for all other
architectures.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@mips.com>
Cc: James Hogan <jhogan@kernel.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: <linux-mips@linux-mips.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
---
arch/mips/include/uapi/asm/ioctls.h | 2 +
arch/mips/include/uapi/asm/termbits.h | 213 +++-------------------------------
2 files changed, 15 insertions(+), 200 deletions(-)
diff --git a/arch/mips/include/uapi/asm/ioctls.h b/arch/mips/include/uapi/asm/ioctls.h
index 890245a9f0c4..a4e11e1438b5 100644
--- a/arch/mips/include/uapi/asm/ioctls.h
+++ b/arch/mips/include/uapi/asm/ioctls.h
@@ -114,4 +114,6 @@
#define TIOCMIWAIT 0x5491 /* wait for a change on serial input line(s) */
#define TIOCGICOUNT 0x5492 /* read serial port inline interrupt counts */
+#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
+
#endif /* __ASM_IOCTLS_H */
diff --git a/arch/mips/include/uapi/asm/termbits.h b/arch/mips/include/uapi/asm/termbits.h
index dfeffba729b7..a08fa0a697f5 100644
--- a/arch/mips/include/uapi/asm/termbits.h
+++ b/arch/mips/include/uapi/asm/termbits.h
@@ -11,218 +11,31 @@
#ifndef _ASM_TERMBITS_H
#define _ASM_TERMBITS_H
-#include <linux/posix_types.h>
+#define NCCS 23
+#include <asm-generic/termbits.h>
-typedef unsigned char cc_t;
-typedef unsigned int speed_t;
-typedef unsigned int tcflag_t;
-
-/*
- * The ABI says nothing about NCC but seems to use NCCS as
- * replacement for it in struct termio
- */
-#define NCCS 23
-struct termios {
- tcflag_t c_iflag; /* input mode flags */
- tcflag_t c_oflag; /* output mode flags */
- tcflag_t c_cflag; /* control mode flags */
- tcflag_t c_lflag; /* local mode flags */
- cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
-};
-
-struct termios2 {
- tcflag_t c_iflag; /* input mode flags */
- tcflag_t c_oflag; /* output mode flags */
- tcflag_t c_cflag; /* control mode flags */
- tcflag_t c_lflag; /* local mode flags */
- cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
- speed_t c_ispeed; /* input speed */
- speed_t c_ospeed; /* output speed */
-};
-
-struct ktermios {
- tcflag_t c_iflag; /* input mode flags */
- tcflag_t c_oflag; /* output mode flags */
- tcflag_t c_cflag; /* control mode flags */
- tcflag_t c_lflag; /* local mode flags */
- cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
- speed_t c_ispeed; /* input speed */
- speed_t c_ospeed; /* output speed */
-};
-
-/* c_cc characters */
-#define VINTR 0 /* Interrupt character [ISIG]. */
-#define VQUIT 1 /* Quit character [ISIG]. */
-#define VERASE 2 /* Erase character [ICANON]. */
-#define VKILL 3 /* Kill-line character [ICANON]. */
+/* c_cc characters that differ from the generic ABI */
+#undef VMIN
#define VMIN 4 /* Minimum number of bytes read at once [!ICANON]. */
-#define VTIME 5 /* Time-out value (tenths of a second) [!ICANON]. */
+#undef VEOL2
#define VEOL2 6 /* Second EOL character [ICANON]. */
-#define VSWTC 7 /* ??? */
-#define VSWTCH VSWTC
-#define VSTART 8 /* Start (X-ON) character [IXON, IXOFF]. */
-#define VSTOP 9 /* Stop (X-OFF) character [IXON, IXOFF]. */
-#define VSUSP 10 /* Suspend character [ISIG]. */
-#if 0
-/*
- * VDSUSP is not supported
- */
-#define VDSUSP 11 /* Delayed suspend character [ISIG]. */
-#endif
-#define VREPRINT 12 /* Reprint-line character [ICANON]. */
-#define VDISCARD 13 /* Discard character [IEXTEN]. */
-#define VWERASE 14 /* Word-erase character [ICANON]. */
-#define VLNEXT 15 /* Literal-next character [IEXTEN]. */
+#undef VEOF
#define VEOF 16 /* End-of-file character [ICANON]. */
+#undef VEOL
#define VEOL 17 /* End-of-line character [ICANON]. */
-/* c_iflag bits */
-#define IGNBRK 0000001 /* Ignore break condition. */
-#define BRKINT 0000002 /* Signal interrupt on break. */
-#define IGNPAR 0000004 /* Ignore characters with parity errors. */
-#define PARMRK 0000010 /* Mark parity and framing errors. */
-#define INPCK 0000020 /* Enable input parity check. */
-#define ISTRIP 0000040 /* Strip 8th bit off characters. */
-#define INLCR 0000100 /* Map NL to CR on input. */
-#define IGNCR 0000200 /* Ignore CR. */
-#define ICRNL 0000400 /* Map CR to NL on input. */
-#define IUCLC 0001000 /* Map upper case to lower case on input. */
-#define IXON 0002000 /* Enable start/stop output control. */
-#define IXANY 0004000 /* Any character will restart after stop. */
-#define IXOFF 0010000 /* Enable start/stop input control. */
-#define IMAXBEL 0020000 /* Ring bell when input queue is full. */
-#define IUTF8 0040000 /* Input is UTF-8 */
-
-/* c_oflag bits */
-#define OPOST 0000001 /* Perform output processing. */
-#define OLCUC 0000002 /* Map lower case to upper case on output. */
-#define ONLCR 0000004 /* Map NL to CR-NL on output. */
-#define OCRNL 0000010
-#define ONOCR 0000020
-#define ONLRET 0000040
-#define OFILL 0000100
-#define OFDEL 0000200
-#define NLDLY 0000400
-#define NL0 0000000
-#define NL1 0000400
-#define CRDLY 0003000
-#define CR0 0000000
-#define CR1 0001000
-#define CR2 0002000
-#define CR3 0003000
-#define TABDLY 0014000
-#define TAB0 0000000
-#define TAB1 0004000
-#define TAB2 0010000
-#define TAB3 0014000
-#define XTABS 0014000
-#define BSDLY 0020000
-#define BS0 0000000
-#define BS1 0020000
-#define VTDLY 0040000
-#define VT0 0000000
-#define VT1 0040000
-#define FFDLY 0100000
-#define FF0 0000000
-#define FF1 0100000
-/*
-#define PAGEOUT ???
-#define WRAP ???
- */
-
-/* c_cflag bit meaning */
-#define CBAUD 0010017
-#define B0 0000000 /* hang up */
-#define B50 0000001
-#define B75 0000002
-#define B110 0000003
-#define B134 0000004
-#define B150 0000005
-#define B200 0000006
-#define B300 0000007
-#define B600 0000010
-#define B1200 0000011
-#define B1800 0000012
-#define B2400 0000013
-#define B4800 0000014
-#define B9600 0000015
-#define B19200 0000016
-#define B38400 0000017
-#define EXTA B19200
-#define EXTB B38400
-#define CSIZE 0000060 /* Number of bits per byte (mask). */
-#define CS5 0000000 /* 5 bits per byte. */
-#define CS6 0000020 /* 6 bits per byte. */
-#define CS7 0000040 /* 7 bits per byte. */
-#define CS8 0000060 /* 8 bits per byte. */
-#define CSTOPB 0000100 /* Two stop bits instead of one. */
-#define CREAD 0000200 /* Enable receiver. */
-#define PARENB 0000400 /* Parity enable. */
-#define PARODD 0001000 /* Odd parity instead of even. */
-#define HUPCL 0002000 /* Hang up on last close. */
-#define CLOCAL 0004000 /* Ignore modem status lines. */
-#define CBAUDEX 0010000
-#define BOTHER 0010000
-#define B57600 0010001
-#define B115200 0010002
-#define B230400 0010003
-#define B460800 0010004
-#define B500000 0010005
-#define B576000 0010006
-#define B921600 0010007
-#define B1000000 0010010
-#define B1152000 0010011
-#define B1500000 0010012
-#define B2000000 0010013
-#define B2500000 0010014
-#define B3000000 0010015
-#define B3500000 0010016
-#define B4000000 0010017
-#define CIBAUD 002003600000 /* input baud rate */
-#define CMSPAR 010000000000 /* mark or space (stick) parity */
-#define CRTSCTS 020000000000 /* flow control */
-
-#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
-
-/* c_lflag bits */
-#define ISIG 0000001 /* Enable signals. */
-#define ICANON 0000002 /* Do erase and kill processing. */
-#define XCASE 0000004
-#define ECHO 0000010 /* Enable echo. */
-#define ECHOE 0000020 /* Visual erase for ERASE. */
-#define ECHOK 0000040 /* Echo NL after KILL. */
-#define ECHONL 0000100 /* Echo NL even if ECHO is off. */
-#define NOFLSH 0000200 /* Disable flush after interrupt. */
+/* c_lflag bits that differ from the generic ABI */
+#undef IEXTEN
#define IEXTEN 0000400 /* Enable DISCARD and LNEXT. */
-#define ECHOCTL 0001000 /* Echo control characters as ^X. */
-#define ECHOPRT 0002000 /* Hardcopy visual erase. */
-#define ECHOKE 0004000 /* Visual erase for KILL. */
-#define FLUSHO 0020000
-#define PENDIN 0040000 /* Retype pending input (state). */
+#undef TOSTOP
#define TOSTOP 0100000 /* Send SIGTTOU for background output. */
-#define ITOSTOP TOSTOP
-#define EXTPROC 0200000 /* External processing on pty */
-
-/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
-#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
-
-/* tcflow() and TCXONC use these */
-#define TCOOFF 0 /* Suspend output. */
-#define TCOON 1 /* Restart suspended output. */
-#define TCIOFF 2 /* Send a STOP character. */
-#define TCION 3 /* Send a START character. */
-
-/* tcflush() and TCFLSH use these */
-#define TCIFLUSH 0 /* Discard data received but not yet read. */
-#define TCOFLUSH 1 /* Discard data written but not yet sent. */
-#define TCIOFLUSH 2 /* Discard all pending data. */
/* tcsetattr uses these */
+#undef TCSANOW
#define TCSANOW TCSETS /* Change immediately. */
+#undef TCSADRAIN
#define TCSADRAIN TCSETSW /* Change when pending output is written. */
+#undef TCSAFLUSH
#define TCSAFLUSH TCSETSF /* Flush pending input before changing. */
#endif /* _ASM_TERMBITS_H */
--
2.14.4
^ permalink raw reply related
* [PATCH 4/5] arch/parisc, termios: use <asm-generic/termios.h>
From: H. Peter Anvin (Intel) @ 2018-10-04 22:29 UTC (permalink / raw)
To: linux-kernel, linux-arch, linux-serial
Cc: H. Peter Anvin (Intel), James E.J. Bottomley, Helge Deller,
Kate Stewart, Thomas Gleixner, Philippe Ombredanne,
Greg Kroah-Hartman, linux-parisc, Jiri Slaby
In-Reply-To: <20181004222953.2229-1-hpa@zytor.com>
The PARISC definition of termbits.h is almost identical to the generic
one, so use the generic one and only redefine a handful of constants.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: <linux-parisc@vger.kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
---
arch/parisc/include/uapi/asm/termbits.h | 197 +-------------------------------
1 file changed, 4 insertions(+), 193 deletions(-)
diff --git a/arch/parisc/include/uapi/asm/termbits.h b/arch/parisc/include/uapi/asm/termbits.h
index 40e920f8d683..28ce9067f2e0 100644
--- a/arch/parisc/include/uapi/asm/termbits.h
+++ b/arch/parisc/include/uapi/asm/termbits.h
@@ -2,201 +2,12 @@
#ifndef __ARCH_PARISC_TERMBITS_H__
#define __ARCH_PARISC_TERMBITS_H__
-#include <linux/posix_types.h>
+#include <asm-generic/termbits.h>
-typedef unsigned char cc_t;
-typedef unsigned int speed_t;
-typedef unsigned int tcflag_t;
-
-#define NCCS 19
-struct termios {
- tcflag_t c_iflag; /* input mode flags */
- tcflag_t c_oflag; /* output mode flags */
- tcflag_t c_cflag; /* control mode flags */
- tcflag_t c_lflag; /* local mode flags */
- cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
-};
-
-struct termios2 {
- tcflag_t c_iflag; /* input mode flags */
- tcflag_t c_oflag; /* output mode flags */
- tcflag_t c_cflag; /* control mode flags */
- tcflag_t c_lflag; /* local mode flags */
- cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
- speed_t c_ispeed; /* input speed */
- speed_t c_ospeed; /* output speed */
-};
-
-struct ktermios {
- tcflag_t c_iflag; /* input mode flags */
- tcflag_t c_oflag; /* output mode flags */
- tcflag_t c_cflag; /* control mode flags */
- tcflag_t c_lflag; /* local mode flags */
- cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
- speed_t c_ispeed; /* input speed */
- speed_t c_ospeed; /* output speed */
-};
-
-/* c_cc characters */
-#define VINTR 0
-#define VQUIT 1
-#define VERASE 2
-#define VKILL 3
-#define VEOF 4
-#define VTIME 5
-#define VMIN 6
-#define VSWTC 7
-#define VSTART 8
-#define VSTOP 9
-#define VSUSP 10
-#define VEOL 11
-#define VREPRINT 12
-#define VDISCARD 13
-#define VWERASE 14
-#define VLNEXT 15
-#define VEOL2 16
-
-
-/* c_iflag bits */
-#define IGNBRK 0000001
-#define BRKINT 0000002
-#define IGNPAR 0000004
-#define PARMRK 0000010
-#define INPCK 0000020
-#define ISTRIP 0000040
-#define INLCR 0000100
-#define IGNCR 0000200
-#define ICRNL 0000400
-#define IUCLC 0001000
-#define IXON 0002000
-#define IXANY 0004000
-#define IXOFF 0010000
+/* c_iflag bits that differ from the generic ABI */
+#undef IMAXBEL
#define IMAXBEL 0040000
+#undef IUTF8
#define IUTF8 0100000
-/* c_oflag bits */
-#define OPOST 0000001
-#define OLCUC 0000002
-#define ONLCR 0000004
-#define OCRNL 0000010
-#define ONOCR 0000020
-#define ONLRET 0000040
-#define OFILL 0000100
-#define OFDEL 0000200
-#define NLDLY 0000400
-#define NL0 0000000
-#define NL1 0000400
-#define CRDLY 0003000
-#define CR0 0000000
-#define CR1 0001000
-#define CR2 0002000
-#define CR3 0003000
-#define TABDLY 0014000
-#define TAB0 0000000
-#define TAB1 0004000
-#define TAB2 0010000
-#define TAB3 0014000
-#define XTABS 0014000
-#define BSDLY 0020000
-#define BS0 0000000
-#define BS1 0020000
-#define VTDLY 0040000
-#define VT0 0000000
-#define VT1 0040000
-#define FFDLY 0100000
-#define FF0 0000000
-#define FF1 0100000
-
-/* c_cflag bit meaning */
-#define CBAUD 0010017
-#define B0 0000000 /* hang up */
-#define B50 0000001
-#define B75 0000002
-#define B110 0000003
-#define B134 0000004
-#define B150 0000005
-#define B200 0000006
-#define B300 0000007
-#define B600 0000010
-#define B1200 0000011
-#define B1800 0000012
-#define B2400 0000013
-#define B4800 0000014
-#define B9600 0000015
-#define B19200 0000016
-#define B38400 0000017
-#define EXTA B19200
-#define EXTB B38400
-#define CSIZE 0000060
-#define CS5 0000000
-#define CS6 0000020
-#define CS7 0000040
-#define CS8 0000060
-#define CSTOPB 0000100
-#define CREAD 0000200
-#define PARENB 0000400
-#define PARODD 0001000
-#define HUPCL 0002000
-#define CLOCAL 0004000
-#define CBAUDEX 0010000
-#define BOTHER 0010000
-#define B57600 0010001
-#define B115200 0010002
-#define B230400 0010003
-#define B460800 0010004
-#define B500000 0010005
-#define B576000 0010006
-#define B921600 0010007
-#define B1000000 0010010
-#define B1152000 0010011
-#define B1500000 0010012
-#define B2000000 0010013
-#define B2500000 0010014
-#define B3000000 0010015
-#define B3500000 0010016
-#define B4000000 0010017
-#define CIBAUD 002003600000 /* input baud rate */
-#define CMSPAR 010000000000 /* mark or space (stick) parity */
-#define CRTSCTS 020000000000 /* flow control */
-
-#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
-
-
-/* c_lflag bits */
-#define ISIG 0000001
-#define ICANON 0000002
-#define XCASE 0000004
-#define ECHO 0000010
-#define ECHOE 0000020
-#define ECHOK 0000040
-#define ECHONL 0000100
-#define NOFLSH 0000200
-#define TOSTOP 0000400
-#define ECHOCTL 0001000
-#define ECHOPRT 0002000
-#define ECHOKE 0004000
-#define FLUSHO 0010000
-#define PENDIN 0040000
-#define IEXTEN 0100000
-#define EXTPROC 0200000
-
-/* tcflow() and TCXONC use these */
-#define TCOOFF 0
-#define TCOON 1
-#define TCIOFF 2
-#define TCION 3
-
-/* tcflush() and TCFLSH use these */
-#define TCIFLUSH 0
-#define TCOFLUSH 1
-#define TCIOFLUSH 2
-
-/* tcsetattr uses these */
-#define TCSANOW 0
-#define TCSADRAIN 1
-#define TCSAFLUSH 2
-
#endif
--
2.14.4
^ permalink raw reply related
* [PATCH 5/5] arch/xtensa, termios: use <asm-generic/termbits.h>
From: H. Peter Anvin (Intel) @ 2018-10-04 22:29 UTC (permalink / raw)
To: linux-kernel, linux-arch, linux-serial
Cc: H. Peter Anvin (Intel), Chris Zankel, Max Filippov,
Thomas Gleixner, Greg Kroah-Hartman, Philippe Ombredanne,
Kate Stewart, linux-xtensa, Jiri Slaby
In-Reply-To: <20181004222953.2229-1-hpa@zytor.com>
The Xtensa definition of termbits.h is identical to the generic one.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: <linux-xtensa@linux-xtensa.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
---
arch/xtensa/include/uapi/asm/termbits.h | 222 +-------------------------------
1 file changed, 1 insertion(+), 221 deletions(-)
diff --git a/arch/xtensa/include/uapi/asm/termbits.h b/arch/xtensa/include/uapi/asm/termbits.h
index d4206a7c5138..3935b106de79 100644
--- a/arch/xtensa/include/uapi/asm/termbits.h
+++ b/arch/xtensa/include/uapi/asm/termbits.h
@@ -1,221 +1 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/*
- * include/asm-xtensa/termbits.h
- *
- * Copied from SH.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2001 - 2005 Tensilica Inc.
- */
-
-#ifndef _XTENSA_TERMBITS_H
-#define _XTENSA_TERMBITS_H
-
-
-#include <linux/posix_types.h>
-
-typedef unsigned char cc_t;
-typedef unsigned int speed_t;
-typedef unsigned int tcflag_t;
-
-#define NCCS 19
-struct termios {
- tcflag_t c_iflag; /* input mode flags */
- tcflag_t c_oflag; /* output mode flags */
- tcflag_t c_cflag; /* control mode flags */
- tcflag_t c_lflag; /* local mode flags */
- cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
-};
-
-struct termios2 {
- tcflag_t c_iflag; /* input mode flags */
- tcflag_t c_oflag; /* output mode flags */
- tcflag_t c_cflag; /* control mode flags */
- tcflag_t c_lflag; /* local mode flags */
- cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
- speed_t c_ispeed; /* input speed */
- speed_t c_ospeed; /* output speed */
-};
-
-struct ktermios {
- tcflag_t c_iflag; /* input mode flags */
- tcflag_t c_oflag; /* output mode flags */
- tcflag_t c_cflag; /* control mode flags */
- tcflag_t c_lflag; /* local mode flags */
- cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
- speed_t c_ispeed; /* input speed */
- speed_t c_ospeed; /* output speed */
-};
-
-/* c_cc characters */
-
-#define VINTR 0
-#define VQUIT 1
-#define VERASE 2
-#define VKILL 3
-#define VEOF 4
-#define VTIME 5
-#define VMIN 6
-#define VSWTC 7
-#define VSTART 8
-#define VSTOP 9
-#define VSUSP 10
-#define VEOL 11
-#define VREPRINT 12
-#define VDISCARD 13
-#define VWERASE 14
-#define VLNEXT 15
-#define VEOL2 16
-
-/* c_iflag bits */
-
-#define IGNBRK 0000001
-#define BRKINT 0000002
-#define IGNPAR 0000004
-#define PARMRK 0000010
-#define INPCK 0000020
-#define ISTRIP 0000040
-#define INLCR 0000100
-#define IGNCR 0000200
-#define ICRNL 0000400
-#define IUCLC 0001000
-#define IXON 0002000
-#define IXANY 0004000
-#define IXOFF 0010000
-#define IMAXBEL 0020000
-#define IUTF8 0040000
-
-/* c_oflag bits */
-
-#define OPOST 0000001
-#define OLCUC 0000002
-#define ONLCR 0000004
-#define OCRNL 0000010
-#define ONOCR 0000020
-#define ONLRET 0000040
-#define OFILL 0000100
-#define OFDEL 0000200
-#define NLDLY 0000400
-#define NL0 0000000
-#define NL1 0000400
-#define CRDLY 0003000
-#define CR0 0000000
-#define CR1 0001000
-#define CR2 0002000
-#define CR3 0003000
-#define TABDLY 0014000
-#define TAB0 0000000
-#define TAB1 0004000
-#define TAB2 0010000
-#define TAB3 0014000
-#define XTABS 0014000
-#define BSDLY 0020000
-#define BS0 0000000
-#define BS1 0020000
-#define VTDLY 0040000
-#define VT0 0000000
-#define VT1 0040000
-#define FFDLY 0100000
-#define FF0 0000000
-#define FF1 0100000
-
-/* c_cflag bit meaning */
-
-#define CBAUD 0010017
-#define B0 0000000 /* hang up */
-#define B50 0000001
-#define B75 0000002
-#define B110 0000003
-#define B134 0000004
-#define B150 0000005
-#define B200 0000006
-#define B300 0000007
-#define B600 0000010
-#define B1200 0000011
-#define B1800 0000012
-#define B2400 0000013
-#define B4800 0000014
-#define B9600 0000015
-#define B19200 0000016
-#define B38400 0000017
-#define EXTA B19200
-#define EXTB B38400
-#define CSIZE 0000060
-#define CS5 0000000
-#define CS6 0000020
-#define CS7 0000040
-#define CS8 0000060
-#define CSTOPB 0000100
-#define CREAD 0000200
-#define PARENB 0000400
-#define PARODD 0001000
-#define HUPCL 0002000
-#define CLOCAL 0004000
-#define CBAUDEX 0010000
-#define BOTHER 0010000
-#define B57600 0010001
-#define B115200 0010002
-#define B230400 0010003
-#define B460800 0010004
-#define B500000 0010005
-#define B576000 0010006
-#define B921600 0010007
-#define B1000000 0010010
-#define B1152000 0010011
-#define B1500000 0010012
-#define B2000000 0010013
-#define B2500000 0010014
-#define B3000000 0010015
-#define B3500000 0010016
-#define B4000000 0010017
-#define CIBAUD 002003600000 /* input baud rate */
-#define CMSPAR 010000000000 /* mark or space (stick) parity */
-#define CRTSCTS 020000000000 /* flow control */
-
-#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
-
-/* c_lflag bits */
-
-#define ISIG 0000001
-#define ICANON 0000002
-#define XCASE 0000004
-#define ECHO 0000010
-#define ECHOE 0000020
-#define ECHOK 0000040
-#define ECHONL 0000100
-#define NOFLSH 0000200
-#define TOSTOP 0000400
-#define ECHOCTL 0001000
-#define ECHOPRT 0002000
-#define ECHOKE 0004000
-#define FLUSHO 0010000
-#define PENDIN 0040000
-#define IEXTEN 0100000
-#define EXTPROC 0200000
-
-/* tcflow() and TCXONC use these */
-
-#define TCOOFF 0
-#define TCOON 1
-#define TCIOFF 2
-#define TCION 3
-
-/* tcflush() and TCFLSH use these */
-
-#define TCIFLUSH 0
-#define TCOFLUSH 1
-#define TCIOFLUSH 2
-
-/* tcsetattr uses these */
-
-#define TCSANOW 0
-#define TCSADRAIN 1
-#define TCSAFLUSH 2
-
-#endif /* _XTENSA_TERMBITS_H */
+#include <asm-generic/termbits.h>
--
2.14.4
^ permalink raw reply related
* Re: [PATCH 5/5] arch/xtensa, termios: use <asm-generic/termbits.h>
From: Max Filippov @ 2018-10-04 22:35 UTC (permalink / raw)
To: H. Peter Anvin
Cc: LKML, Linux-Arch, linux-serial, Chris Zankel, Thomas Gleixner,
Greg Kroah-Hartman, pombredanne, kstewart, linux-xtensa,
Jiri Slaby
In-Reply-To: <20181004222953.2229-6-hpa@zytor.com>
On Thu, Oct 4, 2018 at 3:30 PM H. Peter Anvin (Intel) <hpa@zytor.com> wrote:
>
> The Xtensa definition of termbits.h is identical to the generic one.
>
> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
> Cc: Chris Zankel <chris@zankel.net>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Philippe Ombredanne <pombredanne@nexb.com>
> Cc: Kate Stewart <kstewart@linuxfoundation.org>
> Cc: <linux-xtensa@linux-xtensa.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jiri Slaby <jslaby@suse.com>
> ---
> arch/xtensa/include/uapi/asm/termbits.h | 222 +-------------------------------
> 1 file changed, 1 insertion(+), 221 deletions(-)
Looks good. But why not removing the header entirely and adding
generic-y += termbits.h
to arch/xtensa/include/uapi/asm/Kbuild?
--
Thanks.
-- Max
^ permalink raw reply
* Re: [PATCH 5/5] arch/xtensa, termios: use <asm-generic/termbits.h>
From: H. Peter Anvin @ 2018-10-04 23:08 UTC (permalink / raw)
To: Max Filippov
Cc: LKML, Linux-Arch, linux-serial, Chris Zankel, Thomas Gleixner,
Greg Kroah-Hartman, pombredanne, kstewart, linux-xtensa,
Jiri Slaby
In-Reply-To: <CAMo8BfJRvmNu=oHb4MaB_M7mdR5dMZRgfHb-Me8En3OoUe5m8g@mail.gmail.com>
On 10/04/18 15:35, Max Filippov wrote:
>
> Looks good. But why not removing the header entirely and adding
> generic-y += termbits.h
> to arch/xtensa/include/uapi/asm/Kbuild?
>
Good idea. Should do that for others that also have the same #include.
-hpa
^ permalink raw reply
* Re: [PATCH 1/5] asm-generic, termios: add alias constants from MIPS
From: Geert Uytterhoeven @ 2018-10-05 7:30 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Linux Kernel Mailing List, Linux-Arch, open list:SERIAL DRIVERS,
Arnd Bergmann, Greg KH, Jiri Slaby
In-Reply-To: <20181004222953.2229-2-hpa@zytor.com>
Hi Peter,
Thanks for your patch!
On Fri, Oct 5, 2018 at 12:30 AM H. Peter Anvin (Intel) <hpa@zytor.com> wrote:
> Some architectures, in this case MIPS, need a couple of legacy alias
> constants for bits. There really is no reason why we can't define them
> generically for all architectures.
To avoid polluting namespace?
To avoid people using them in a context not specific to MIPS?
> --- a/include/uapi/asm-generic/termbits.h
> +++ b/include/uapi/asm-generic/termbits.h
> @@ -8,7 +8,10 @@ typedef unsigned char cc_t;
> typedef unsigned int speed_t;
> typedef unsigned int tcflag_t;
>
> -#define NCCS 19
> +#ifndef NCCS
> +# define NCCS 19
> +#endif
> +
> struct termios {
> tcflag_t c_iflag; /* input mode flags */
> tcflag_t c_oflag; /* output mode flags */
> @@ -49,6 +52,7 @@ struct ktermios {
> #define VTIME 5
> #define VMIN 6
> #define VSWTC 7
> +#define VSWTCH VSWTC
I'd at least add a comment /* legacy MIPS */ here.
> #define VSTART 8
> #define VSTOP 9
> #define VSUSP 10
> @@ -173,6 +177,7 @@ struct ktermios {
> #define ECHONL 0000100
> #define NOFLSH 0000200
> #define TOSTOP 0000400
> +#define ITOSTOP TOSTOP
Likewise.
> #define ECHOCTL 0001000
> #define ECHOPRT 0002000
> #define ECHOKE 0004000
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 v2 2/3] dmaengine: Add Slave and Cyclic mode support for Actions Semi Owl S900 SoC
From: Vinod @ 2018-10-05 15:01 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: dan.j.williams, afaerber, robh+dt, gregkh, jslaby, linux-serial,
dmaengine, liuwei, 96boards, devicetree, daniel.thompson,
amit.kucheria, linux-arm-kernel, linux-kernel, hzhang, bdong,
manivannanece23, thomas.liau, jeff.chen, pn, edgar.righi
In-Reply-To: <20180929074637.9766-3-manivannan.sadhasivam@linaro.org>
On 29-09-18, 13:16, Manivannan Sadhasivam wrote:
> Add Slave and Cyclic mode support for Actions Semi Owl S900 SoC. The slave
> mode supports bus width of 4 bytes common for all peripherals and 1 byte
> specific for UART.
>
> The cyclic mode supports only block mode transfer.
Applied after adding driver tag, thanks
--
~Vinod
^ permalink raw reply
* [PATCH stable 0/2] termios: Alpha BOTHER/IBSHIFT, tty_baudrate fix
From: H. Peter Anvin @ 2018-10-07 3:37 UTC (permalink / raw)
To: linux-kernel
Cc: H. Peter Anvin (Intel), Greg Kroah-Hartman, Jiri Slaby, Al Viro,
Richard Henderson, Ivan Kokshaysky, Matt Turner, Thomas Gleixner,
Kate Stewart, Philippe Ombredanne, Eugene Syromiatnikov,
linux-alpha, linux-serial, Johan Hovold, Alan Cox,
Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, stable
From: "H. Peter Anvin (Intel)" <hpa@zytor.com>
It turns out that Alpha is the only architecture that never
implemented BOTHER and IBSHIFT, which is otherwise ages old. This is
one thing that has held up glibc support for this feature (all other
architectures have supported these for about a decade, at least before
the current 3.2 glibc cutoff.)
Furthermore, in the process of dealing with this, I discovered that
the current code in tty_baudrate.c can read past the end of the
baud_table[] on Alpha and PowerPC. The second patch in this series
fixes that, but it also cleans up the code substantially by
auto-generating the table and, since all architectures now have them,
removing all conditionals for BOTHER and IBSHIFT existing.
Tagging for stable because these are concrete problems. I have a much
bigger update in process, nearly done, which will clean up a lot of
duplicated code and make the uapi headers usable for libc, but that is
not critical on the same level.
Tested on x86, compile-tested on Alpha.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Eugene Syromiatnikov <esyr@redhat.com>
Cc: <linux-alpha@vger.kernel.org>
Cc: <linux-serial@vger.kernel.org>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: <stable@vger.kernel.org>
---
arch/alpha/include/asm/termios.h | 8 +-
arch/alpha/include/uapi/asm/ioctls.h | 5 +
arch/alpha/include/uapi/asm/termbits.h | 17 +++
drivers/tty/.gitignore | 1 +
drivers/tty/Makefile | 16 +++
drivers/tty/bmacros.c | 2 +
drivers/tty/tty_baudrate.c | 190 +++++++++++++--------------------
7 files changed, 122 insertions(+), 117 deletions(-)
^ permalink raw reply
* [PATCH stable 1/2] arch/alpha, termios: implement BOTHER, IBSHIFT and termios2
From: H. Peter Anvin @ 2018-10-07 3:37 UTC (permalink / raw)
To: linux-kernel
Cc: H. Peter Anvin (Intel), Greg Kroah-Hartman, Jiri Slaby, Al Viro,
Richard Henderson, Ivan Kokshaysky, Matt Turner, Thomas Gleixner,
Kate Stewart, Philippe Ombredanne, Eugene Syromiatnikov,
linux-alpha, linux-serial, Johan Hovold, Alan Cox, stable
In-Reply-To: <20181007033748.224461-1-hpa@zytor.com>
From: "H. Peter Anvin (Intel)" <hpa@zytor.com>
Alpha has had c_ispeed and c_ospeed, but still set speeds in c_cflags
using arbitrary flags. Because BOTHER is not defined, the general
Linux code doesn't allow setting arbitrary baud rates, and because
CBAUDEX == 0, we can have an array overrun of the baud_rate[] table in
drivers/tty/tty_baudrate.c if (c_cflags & CBAUD) == 037.
Resolve both problems by #defining BOTHER to 037 on Alpha.
However, userspace still needs to know if setting BOTHER is actually
safe given legacy kernels (does anyone actually care about that on
Alpha anymore?), so enable the TCGETS2/TCSETS*2 ioctls on Alpha, even
though they use the same structure. Define struct termios2 just for
compatibility; it is the exact same structure as struct termios. In a
future patchset, this will be cleaned up so the uapi headers are
usable from libc.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Eugene Syromiatnikov <esyr@redhat.com>
Cc: <linux-alpha@vger.kernel.org>
Cc: <linux-serial@vger.kernel.org>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: <stable@vger.kernel.org>
---
arch/alpha/include/asm/termios.h | 8 +++++++-
arch/alpha/include/uapi/asm/ioctls.h | 5 +++++
arch/alpha/include/uapi/asm/termbits.h | 17 +++++++++++++++++
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/arch/alpha/include/asm/termios.h b/arch/alpha/include/asm/termios.h
index 6a8c53dec57e..b7c77bb1bfd2 100644
--- a/arch/alpha/include/asm/termios.h
+++ b/arch/alpha/include/asm/termios.h
@@ -73,9 +73,15 @@
})
#define user_termios_to_kernel_termios(k, u) \
- copy_from_user(k, u, sizeof(struct termios))
+ copy_from_user(k, u, sizeof(struct termios2))
#define kernel_termios_to_user_termios(u, k) \
+ copy_to_user(u, k, sizeof(struct termios2))
+
+#define user_termios_to_kernel_termios_1(k, u) \
+ copy_from_user(k, u, sizeof(struct termios))
+
+#define kernel_termios_to_user_termios_1(u, k) \
copy_to_user(u, k, sizeof(struct termios))
#endif /* _ALPHA_TERMIOS_H */
diff --git a/arch/alpha/include/uapi/asm/ioctls.h b/arch/alpha/include/uapi/asm/ioctls.h
index 3729d92d3fa8..dc8c20ac7191 100644
--- a/arch/alpha/include/uapi/asm/ioctls.h
+++ b/arch/alpha/include/uapi/asm/ioctls.h
@@ -32,6 +32,11 @@
#define TCXONC _IO('t', 30)
#define TCFLSH _IO('t', 31)
+#define TCGETS2 _IOR('T', 42, struct termios2)
+#define TCSETS2 _IOW('T', 43, struct termios2)
+#define TCSETSW2 _IOW('T', 44, struct termios2)
+#define TCSETSF2 _IOW('T', 45, struct termios2)
+
#define TIOCSWINSZ _IOW('t', 103, struct winsize)
#define TIOCGWINSZ _IOR('t', 104, struct winsize)
#define TIOCSTART _IO('t', 110) /* start output, like ^Q */
diff --git a/arch/alpha/include/uapi/asm/termbits.h b/arch/alpha/include/uapi/asm/termbits.h
index de6c8360fbe3..4575ba34a0ea 100644
--- a/arch/alpha/include/uapi/asm/termbits.h
+++ b/arch/alpha/include/uapi/asm/termbits.h
@@ -26,6 +26,19 @@ struct termios {
speed_t c_ospeed; /* output speed */
};
+/* Alpha has identical termios and termios2 */
+
+struct termios2 {
+ tcflag_t c_iflag; /* input mode flags */
+ tcflag_t c_oflag; /* output mode flags */
+ tcflag_t c_cflag; /* control mode flags */
+ tcflag_t c_lflag; /* local mode flags */
+ cc_t c_cc[NCCS]; /* control characters */
+ cc_t c_line; /* line discipline (== c_cc[19]) */
+ speed_t c_ispeed; /* input speed */
+ speed_t c_ospeed; /* output speed */
+};
+
/* Alpha has matching termios and ktermios */
struct ktermios {
@@ -152,6 +165,7 @@ struct ktermios {
#define B3000000 00034
#define B3500000 00035
#define B4000000 00036
+#define BOTHER 00037
#define CSIZE 00001400
#define CS5 00000000
@@ -169,6 +183,9 @@ struct ktermios {
#define CMSPAR 010000000000 /* mark or space (stick) parity */
#define CRTSCTS 020000000000 /* flow control */
+#define CIBAUD 07600000
+#define IBSHIFT 16
+
/* c_lflag bits */
#define ISIG 0x00000080
#define ICANON 0x00000100
--
2.17.1
^ permalink raw reply related
* [PATCH stable 2/2] termios, tty/tty_baudrate.c: simplify, auto-generate baud table
From: H. Peter Anvin @ 2018-10-07 3:37 UTC (permalink / raw)
To: linux-kernel
Cc: H. Peter Anvin (Intel), Greg Kroah-Hartman, Jiri Slaby, Al Viro,
Richard Henderson, Ivan Kokshaysky, Matt Turner, Thomas Gleixner,
Kate Stewart, Philippe Ombredanne, Eugene Syromiatnikov,
linux-alpha, linux-serial, Johan Hovold, Alan Cox,
Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, stable
In-Reply-To: <20181007033748.224461-1-hpa@zytor.com>
From: "H. Peter Anvin (Intel)" <hpa@zytor.com>
Now when all architectures define BOTHER and IBSHIFT, we can
unconditionally rely on these constants. Furthermore, the code can be
significantly simplified in a number of places.
Finally, rather than having two tables and needing to be able to keep
them in sync at all times, have one auto-generated table. This also
lets us avoid the fact that architectures that have CBAUDEX == 0 have
BOTHER in a different location that those that don't.
Finally, this patch avoids overrunning the baud_table[] for
architectures with CBAUDEX == 0 (Alpha and PowerPC).
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Eugene Syromiatnikov <esyr@redhat.com>
Cc: <linux-alpha@vger.kernel.org>
Cc: <linux-serial@vger.kernel.org>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: <stable@vger.kernel.org>
---
drivers/tty/.gitignore | 1 +
drivers/tty/Makefile | 16 ++++
drivers/tty/bmacros.c | 2 +
drivers/tty/tty_baudrate.c | 190 +++++++++++++++----------------------
4 files changed, 93 insertions(+), 116 deletions(-)
create mode 100644 drivers/tty/.gitignore
create mode 100644 drivers/tty/bmacros.c
diff --git a/drivers/tty/.gitignore b/drivers/tty/.gitignore
new file mode 100644
index 000000000000..d436c18a912c
--- /dev/null
+++ b/drivers/tty/.gitignore
@@ -0,0 +1 @@
+bmacros.h
diff --git a/drivers/tty/Makefile b/drivers/tty/Makefile
index c72cafdf32b4..489b222ab1ce 100644
--- a/drivers/tty/Makefile
+++ b/drivers/tty/Makefile
@@ -35,3 +35,19 @@ obj-$(CONFIG_MIPS_EJTAG_FDC_TTY) += mips_ejtag_fdc.o
obj-$(CONFIG_VCC) += vcc.o
obj-y += ipwireless/
+
+#
+# Rules for generating the baud rate table
+#
+CFLAGS_bmacros.o += -Wp,-dM
+
+$(obj)/tty_baudrate.o: $(obj)/bmacros.h
+
+quiet_cmd_bmacros = BMACROS $@
+ cmd_bmacros = ( \
+ sed -nr -e 's/^.define B([0-9]+) .*$$/BTBL(B\1,\1)/p' $< \
+ | sort -n -k1.7 > $@ ) || (rm -f $@ ; echo false)
+
+targets += bmacros.h
+$(obj)/bmacros.h: $(obj)/bmacros.i FORCE
+ $(call if_changed,bmacros)
diff --git a/drivers/tty/bmacros.c b/drivers/tty/bmacros.c
new file mode 100644
index 000000000000..0af865ff00de
--- /dev/null
+++ b/drivers/tty/bmacros.c
@@ -0,0 +1,2 @@
+/* This file is used to extract the B... macros from header files */
+#include <linux/termios.h>
diff --git a/drivers/tty/tty_baudrate.c b/drivers/tty/tty_baudrate.c
index 7576ceace571..5a41eda7912a 100644
--- a/drivers/tty/tty_baudrate.c
+++ b/drivers/tty/tty_baudrate.c
@@ -9,43 +9,56 @@
#include <linux/tty.h>
#include <linux/export.h>
-
/*
- * Routine which returns the baud rate of the tty
- *
- * Note that the baud_table needs to be kept in sync with the
- * include/asm/termbits.h file.
+ * Routine which returns the baud rate of the tty. The B... constants
+ * are extracted from the appropriate header files via
+ * bmacros.c -> bmacros.h.
*/
-static const speed_t baud_table[] = {
- 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
- 9600, 19200, 38400, 57600, 115200, 230400, 460800,
-#ifdef __sparc__
- 76800, 153600, 307200, 614400, 921600
-#else
- 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000,
- 2500000, 3000000, 3500000, 4000000
+
+/* CBAUD mask with CBAUDEX removed */
+#define CBAUDNX (CBAUD & ~CBAUDEX)
+
+/* Lowest bit in CBAUDEX, if any. CBAUDEX is assumed contiguous. */
+#define CBAUDEL (CBAUDEX & ~(CBAUDEX << 1))
+#if CBAUDEL & (CBAUDEL-1)
+# error "CBAUDEX is not contiguous"
#endif
-};
-#ifndef __sparc__
-static const tcflag_t baud_bits[] = {
- B0, B50, B75, B110, B134, B150, B200, B300, B600,
- B1200, B1800, B2400, B4800, B9600, B19200, B38400,
- B57600, B115200, B230400, B460800, B500000, B576000,
- B921600, B1000000, B1152000, B1500000, B2000000, B2500000,
- B3000000, B3500000, B4000000
-};
-#else
-static const tcflag_t baud_bits[] = {
- B0, B50, B75, B110, B134, B150, B200, B300, B600,
- B1200, B1800, B2400, B4800, B9600, B19200, B38400,
- B57600, B115200, B230400, B460800, B76800, B153600,
- B307200, B614400, B921600
+/* Convert from B... constant to table position */
+#define BPOS(x) (((x) & CBAUDNX) + \
+ (CBAUDEX ? ((x) & CBAUDEX)/CBAUDEL*(CBAUDNX+1) : 0))
+
+/* Convert from table position to B... constant */
+#define BVAL(x) (((x) & CBAUDNX) + (((x)/(CBAUDNX+1)*CBAUDEX) & CBAUDEX))
+
+/* Entry into the baud_table */
+#define BTBL(b,v) [BPOS(b)] = (v),
+
+static const speed_t baud_table[] = {
+#include "bmacros.h"
};
-#endif
static int n_baud_table = ARRAY_SIZE(baud_table);
+/* Helper function; will be called with cbaud already masked */
+static speed_t _tty_termios_baud_rate(unsigned int cbaud, speed_t bother_speed)
+{
+ /* Magic token for arbitrary speed via c_ispeed/c_ospeed */
+ if (cbaud == BOTHER)
+ return bother_speed;
+
+ cbaud = BPOS(cbaud);
+
+ /* If CBAUDEX != 0, and we overrun the table, try dropping CBAUDEX */
+ if (cbaud & ~CBAUDNX) {
+ if (BPOS(cbaud) >= n_baud_table) {
+ /* Try without CBAUDEX */
+ cbaud &= ~CBAUDNX;
+ }
+ }
+ return (cbaud >= n_baud_table) ? 0 : baud_table[cbaud];
+}
+
/**
* tty_termios_baud_rate
* @termios: termios structure
@@ -60,24 +73,8 @@ static int n_baud_table = ARRAY_SIZE(baud_table);
speed_t tty_termios_baud_rate(struct ktermios *termios)
{
- unsigned int cbaud;
-
- cbaud = termios->c_cflag & CBAUD;
-
-#ifdef BOTHER
- /* Magic token for arbitrary speed via c_ispeed/c_ospeed */
- if (cbaud == BOTHER)
- return termios->c_ospeed;
-#endif
- if (cbaud & CBAUDEX) {
- cbaud &= ~CBAUDEX;
-
- if (cbaud < 1 || cbaud + 15 > n_baud_table)
- termios->c_cflag &= ~CBAUDEX;
- else
- cbaud += 15;
- }
- return baud_table[cbaud];
+ return _tty_termios_baud_rate(termios->c_cflag & CBAUD,
+ termios->c_ospeed);
}
EXPORT_SYMBOL(tty_termios_baud_rate);
@@ -95,28 +92,15 @@ EXPORT_SYMBOL(tty_termios_baud_rate);
speed_t tty_termios_input_baud_rate(struct ktermios *termios)
{
-#ifdef IBSHIFT
- unsigned int cbaud = (termios->c_cflag >> IBSHIFT) & CBAUD;
-
- if (cbaud == B0)
- return tty_termios_baud_rate(termios);
-#ifdef BOTHER
- /* Magic token for arbitrary speed via c_ispeed*/
- if (cbaud == BOTHER)
- return termios->c_ispeed;
-#endif
- if (cbaud & CBAUDEX) {
- cbaud &= ~CBAUDEX;
+ unsigned int cbaud;
+ speed_t bother_speed = termios->c_ispeed;
- if (cbaud < 1 || cbaud + 15 > n_baud_table)
- termios->c_cflag &= ~(CBAUDEX << IBSHIFT);
- else
- cbaud += 15;
+ cbaud = (termios->c_cflag >> IBSHIFT) & CBAUD;
+ if (cbaud == B0) {
+ cbaud = termios->c_cflag & CBAUD;
+ bother_speed = termios->c_ospeed;
}
- return baud_table[cbaud];
-#else /* IBSHIFT */
- return tty_termios_baud_rate(termios);
-#endif /* IBSHIFT */
+ return _tty_termios_baud_rate(cbaud, bother_speed);
}
EXPORT_SYMBOL(tty_termios_input_baud_rate);
@@ -145,38 +129,27 @@ EXPORT_SYMBOL(tty_termios_input_baud_rate);
void tty_termios_encode_baud_rate(struct ktermios *termios,
speed_t ibaud, speed_t obaud)
{
- int i = 0;
- int ifound = -1, ofound = -1;
+ int i;
+ unsigned int ifound, ofound;
int iclose = ibaud/50, oclose = obaud/50;
- int ibinput = 0;
+ bool ibinput = false;
- if (obaud == 0) /* CD dropped */
+ if (obaud == 0) /* CD dropped */
ibaud = 0; /* Clear ibaud to be sure */
termios->c_ispeed = ibaud;
termios->c_ospeed = obaud;
-#ifdef IBSHIFT
- if ((termios->c_cflag >> IBSHIFT) & CBAUD)
- ibinput = 1; /* An input speed was specified */
-#endif
-#ifdef BOTHER
+ ibinput = ((termios->c_cflag >> IBSHIFT) & CBAUD) != B0;
+
/* If the user asked for a precise weird speed give a precise weird
answer. If they asked for a Bfoo speed they may have problems
digesting non-exact replies so fuzz a bit */
- if ((termios->c_cflag & CBAUD) == BOTHER) {
+ if ((termios->c_cflag & CBAUD) == BOTHER)
oclose = 0;
- if (!ibinput)
- iclose = 0;
- }
if (((termios->c_cflag >> IBSHIFT) & CBAUD) == BOTHER)
iclose = 0;
-#endif
- termios->c_cflag &= ~CBAUD;
-#ifdef IBSHIFT
- termios->c_cflag &= ~(CBAUD << IBSHIFT);
-#endif
/*
* Our goal is to find a close match to the standard baud rate
@@ -184,43 +157,28 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
* match then report back the speed as a POSIX Bxxxx value by
* preference
*/
-
- do {
+ ofound = ifound = BOTHER;
+ for (i = 0; i < n_baud_table; i++) {
if (obaud - oclose <= baud_table[i] &&
obaud + oclose >= baud_table[i]) {
- termios->c_cflag |= baud_bits[i];
- ofound = i;
+ ofound = BVAL(i);
+ break;
}
- if (ibaud - iclose <= baud_table[i] &&
- ibaud + iclose >= baud_table[i]) {
- /* For the case input == output don't set IBAUD bits
- if the user didn't do so */
- if (ofound == i && !ibinput)
- ifound = i;
-#ifdef IBSHIFT
- else {
- ifound = i;
- termios->c_cflag |= (baud_bits[i] << IBSHIFT);
+ }
+ if (!ibinput) {
+ ifound = 0;
+ } else {
+ for (i = 0; i < n_baud_table; i++) {
+ if (ibaud - iclose <= baud_table[i] &&
+ ibaud + iclose >= baud_table[i]) {
+ ifound = BVAL(i);
+ break;
}
-#endif
}
- } while (++i < n_baud_table);
+ }
- /*
- * If we found no match then use BOTHER if provided or warn
- * the user their platform maintainer needs to wake up if not.
- */
-#ifdef BOTHER
- if (ofound == -1)
- termios->c_cflag |= BOTHER;
- /* Set exact input bits only if the input and output differ or the
- user already did */
- if (ifound == -1 && (ibaud != obaud || ibinput))
- termios->c_cflag |= (BOTHER << IBSHIFT);
-#else
- if (ifound == -1 || ofound == -1)
- pr_warn_once("tty: Unable to return correct speed data as your architecture needs updating.\n");
-#endif
+ termios->c_cflag &= ~(CBAUD | (CBAUD << IBSHIFT));
+ termios->c_cflag |= ofound | (ifound << IBSHIFT);
}
EXPORT_SYMBOL_GPL(tty_termios_encode_baud_rate);
--
2.17.1
^ permalink raw reply related
* [GIT PULL] TTY/Serial fixes for 4.19-rc7
From: Greg KH @ 2018-10-07 6:07 UTC (permalink / raw)
To: Greg KH
Cc: Linus Torvalds, Jiri Slaby, Stephen Rothwell, Andrew Morton,
linux-kernel, linux-serial
The following changes since commit 17b57b1883c1285f3d0dc2266e8f79286a7bef38:
Linux 4.19-rc6 (2018-09-30 07:15:35 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tags/tty-4.19-rc7
for you to fetch changes up to 5b162cc4ac27ba76e576abc9090c54cf90a17980:
Revert "serial: sh-sci: Allow for compressed SCIF address" (2018-10-02 14:38:16 -0700)
----------------------------------------------------------------
Serial driver fixes for 4.19-rc7
Here are 3 small serial driver fixes for 4.19-rc7
- 2 sh-sci bugfixes for reported issues
- a revert of the PM handling for the 8250_dw code
All of these have been in linux-next with no reported issues.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
----------------------------------------------------------------
Geert Uytterhoeven (2):
Revert "serial: sh-sci: Remove SCIx_RZ_SCIFA_REGTYPE"
Revert "serial: sh-sci: Allow for compressed SCIF address"
Guenter Roeck (1):
Revert "serial: 8250_dw: Fix runtime PM handling"
drivers/tty/serial/8250/8250_dw.c | 4 ---
drivers/tty/serial/sh-sci.c | 56 ++++++++++++++++++++++++++++-----------
include/linux/serial_sci.h | 1 +
3 files changed, 42 insertions(+), 19 deletions(-)
^ 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