[PATCH 12/27] tty: hvc: convert to u8 and size_t
Switch character types to u8 and sizes to size_t. To conform to characters/sizes in the rest of the tty layer. Signed-off-by: Jiri Slaby (SUSE) Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: Amit Shah Cc: Arnd Bergmann Cc: Paul Walmsley Cc: Palmer Dabbelt Cc: Albert Ou Cc: linuxppc-...@lists.ozlabs.org Cc: virtualizat...@lists.linux.dev Cc: linux-ri...@lists.infradead.org --- arch/powerpc/include/asm/hvconsole.h | 4 ++-- arch/powerpc/include/asm/hvsi.h| 18 arch/powerpc/include/asm/opal.h| 8 +--- arch/powerpc/platforms/powernv/opal.c | 14 +++-- arch/powerpc/platforms/pseries/hvconsole.c | 4 ++-- drivers/char/virtio_console.c | 10 - drivers/tty/hvc/hvc_console.h | 4 ++-- drivers/tty/hvc/hvc_dcc.c | 24 +++--- drivers/tty/hvc/hvc_iucv.c | 18 drivers/tty/hvc/hvc_opal.c | 5 +++-- drivers/tty/hvc/hvc_riscv_sbi.c| 9 drivers/tty/hvc/hvc_rtas.c | 11 +- drivers/tty/hvc/hvc_udbg.c | 9 drivers/tty/hvc/hvc_vio.c | 18 drivers/tty/hvc/hvc_xen.c | 23 +++-- drivers/tty/hvc/hvsi_lib.c | 20 ++ 16 files changed, 107 insertions(+), 92 deletions(-) diff --git a/arch/powerpc/include/asm/hvconsole.h b/arch/powerpc/include/asm/hvconsole.h index ccb2034506f0..d841a97010a0 100644 --- a/arch/powerpc/include/asm/hvconsole.h +++ b/arch/powerpc/include/asm/hvconsole.h @@ -21,8 +21,8 @@ * Vio firmware always attempts to fetch MAX_VIO_GET_CHARS chars. The 'count' * parm is included to conform to put_chars() function pointer template */ -extern int hvc_get_chars(uint32_t vtermno, char *buf, int count); -extern int hvc_put_chars(uint32_t vtermno, const char *buf, int count); +extern ssize_t hvc_get_chars(uint32_t vtermno, u8 *buf, size_t count); +extern ssize_t hvc_put_chars(uint32_t vtermno, const u8 *buf, size_t count); /* Provided by HVC VIO */ void hvc_vio_init_early(void); diff --git a/arch/powerpc/include/asm/hvsi.h b/arch/powerpc/include/asm/hvsi.h index 464a7519ed64..9058edcb632b 100644 --- a/arch/powerpc/include/asm/hvsi.h +++ b/arch/powerpc/include/asm/hvsi.h @@ -64,7 +64,7 @@ struct hvsi_priv { unsigned intinbuf_len; /* data in input buffer */ unsigned char inbuf[HVSI_INBUF_SIZE]; unsigned intinbuf_cur; /* Cursor in input buffer */ - unsigned intinbuf_pktlen; /* packet length from cursor */ + size_t inbuf_pktlen; /* packet length from cursor */ atomic_tseqno; /* packet sequence number */ unsigned intopened:1; /* driver opened */ unsigned intestablished:1; /* protocol established */ @@ -72,24 +72,26 @@ struct hvsi_priv { unsigned intmctrl_update:1; /* modem control updated */ unsigned short mctrl; /* modem control */ struct tty_struct *tty; /* tty structure */ - int (*get_chars)(uint32_t termno, char *buf, int count); - int (*put_chars)(uint32_t termno, const char *buf, int count); + ssize_t (*get_chars)(uint32_t termno, u8 *buf, size_t count); + ssize_t (*put_chars)(uint32_t termno, const u8 *buf, size_t count); uint32_ttermno; }; /* hvsi lib functions */ struct hvc_struct; extern void hvsilib_init(struct hvsi_priv *pv, -int (*get_chars)(uint32_t termno, char *buf, int count), -int (*put_chars)(uint32_t termno, const char *buf, - int count), +ssize_t (*get_chars)(uint32_t termno, u8 *buf, + size_t count), +ssize_t (*put_chars)(uint32_t termno, const u8 *buf, + size_t count), int termno, int is_console); extern int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp); extern void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp); extern int hvsilib_read_mctrl(struct hvsi_priv *pv); extern int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr); extern void hvsilib_establish(struct hvsi_priv *pv); -extern int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count); -extern int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count); +extern ssize_t hvsilib_get_chars(struct hvsi_priv *pv, u8 *buf, size_t count); +extern ssize_t hvsilib_put_chars(struct hvsi_priv *pv, const u8 *buf, +size_t count); #endif /* _HVSI_H */ diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h index b66b0c615f4f..af304e6cb486 100644 --- a/arch/powerpc/include/asm/opal.h +++ b/ar
Re: [PATCH] tty: synclink_gt: remove redundant initialization of variable count
On 20. 04. 21, 12:57, Colin King wrote: From: Colin Ian King The variable count is being initialized with a value that is never read and it is being updated later with a new value. The initialization is redundant and can be removed. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Reviewed-by: Jiri Slaby --- drivers/tty/synclink_gt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index 994618618466..5523cf7bd1c2 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -4958,7 +4958,7 @@ static int loopback_test(struct slgt_info *info) #define TESTFRAMESIZE 20 unsigned long timeout; - u16 count = TESTFRAMESIZE; + u16 count; unsigned char buf[TESTFRAMESIZE]; int rc = -ENODEV; unsigned long flags; -- js
Re: [PATCH] tty: n_gsm: check error while registering tty devices
On 07. 04. 21, 4:16, Hillf Danton wrote: Add the error path for registering tty devices and roll back in case of error in bid to avoid the UAF like the below one reported. [ cut here ] refcount_t: underflow; use-after-free. WARNING: CPU: 1 PID: 8923 at lib/refcount.c:28 refcount_warn_saturate+0x1cf/0x210 -origin/lib/refcount.c:28 Modules linked in: CPU: 1 PID: 8923 Comm: executor Not tainted 5.12.0-rc5+ #8 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 RIP: 0010:refcount_warn_saturate+0x1cf/0x210 -origin/lib/refcount.c:28 Code: 4f ff ff ff e8 32 fa b5 fe 48 c7 c7 3d f8 f6 86 e8 d6 ab c6 fe c6 05 7c 34 67 04 01 48 c7 c7 68 f8 6d 86 31 c0 e8 81 2e 9d fe <0f> 0b e9 22 ff ff ff e8 05 fa b5 fe 48 c7 c7 3e f8 f6 86 e8 a9 ab RSP: 0018:c90001633c60 EFLAGS: 00010246 RAX: 15d08b2e34b77800 RBX: 0003 RCX: 88804c056c80 RDX: RSI: RDI: RBP: 0003 R08: 813767aa R09: 0001 R10: 0001 R11: 88804c056c80 R12: 888040b7d000 R13: 88804c206938 R14: 88804c206900 R15: 888041b18488 FS: 022c9940() GS:88807ec0() knlGS: CS: 0010 DS: ES: CR0: 80050033 CR2: 7f9f9b122008 CR3: 44b4b000 CR4: 00750ee0 PKRU: 5554 Call Trace: __refcount_sub_and_test -origin/./include/linux/refcount.h:283 [inline] __refcount_dec_and_test -origin/./include/linux/refcount.h:315 [inline] refcount_dec_and_test -origin/./include/linux/refcount.h:333 [inline] kref_put -origin/./include/linux/kref.h:64 [inline] kobject_put+0x17b/0x180 -origin/lib/kobject.c:753 cdev_del+0x4b/0x50 -origin/fs/char_dev.c:597 tty_unregister_device+0x99/0xd0 -origin/drivers/tty/tty_io.c:3343 gsmld_detach_gsm -origin/drivers/tty/n_gsm.c:2409 [inline] gsmld_close+0x6c/0x140 -origin/drivers/tty/n_gsm.c:2478 tty_ldisc_close -origin/drivers/tty/tty_ldisc.c:488 [inline] tty_ldisc_kill -origin/drivers/tty/tty_ldisc.c:636 [inline] tty_ldisc_release+0x1b6/0x400 -origin/drivers/tty/tty_ldisc.c:809 tty_release_struct+0x19/0xb0 -origin/drivers/tty/tty_io.c:1714 tty_release+0x9ad/0xa00 -origin/drivers/tty/tty_io.c:1885 Yes, the fix makes sense. But could you elaborate in the commit log when this happens? I only wonder how real this is. I assume you inject faults to allocations? Reported-and-tested-by: Hao Sun Cc: Jiri Slaby Use my MAINTAINERS e-mail please. Signed-off-by: Hillf Danton --- --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -2384,8 +2384,18 @@ static int gsmld_attach_gsm(struct tty_s /* Don't register device 0 - this is the control channel and not a usable tty interface */ base = mux_num_to_base(gsm); /* Base for this MUX */ - for (i = 1; i < NUM_DLCI; i++) - tty_register_device(gsm_tty_driver, base + i, NULL); + for (i = 1; i < NUM_DLCI; i++) { + struct device *dev; + + dev = tty_register_device(gsm_tty_driver, + base + i, NULL); + if (IS_ERR(dev)) { + for (i--; i >= 1; i--) + tty_unregister_device(gsm_tty_driver, + base + i); + return PTR_ERR(dev); + } + } } return ret; } -- thanks, -- js suse labs
Re: [PATCH v2 04/10] tty: tty_jobctrl: Fix coding style issues of block comments
On 06. 04. 21, 13:24, Xiaofei Tan wrote: Fix coding style issues of block comments, reported by checkpatch.pl. Besides, do some expression optimization for the sentenses. Signed-off-by: Xiaofei Tan --- drivers/tty/tty_jobctrl.c | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c index 86070f7..7003b6b 100644 --- a/drivers/tty/tty_jobctrl.c +++ b/drivers/tty/tty_jobctrl.c @@ -204,8 +204,10 @@ int tty_signal_session_leader(struct tty_struct *tty, int exit_session) spin_lock_irq(&p->sighand->siglock); if (p->signal->tty == tty) { p->signal->tty = NULL; - /* We defer the dereferences outside fo - the tasklist lock */ + /* +* We defer the dereferences outside of +* the tasklist lock period :). No, I meant "period" as this punctuation mark: . +*/ refs++; } if (!p->signal->leader) { @@ -328,9 +330,11 @@ void disassociate_ctty(int on_exit) */ void no_tty(void) { - /* FIXME: Review locking here. The tty_lock never covered any race - between a new association and proc_clear_tty but possible we need - to protect against this anyway */ + /* +* FIXME: Review locking here. The tty_lock never covered any race +* between a new association and proc_clear_tty but possibly we need +* to protect against this period anyway The same here. +*/ struct task_struct *tsk = current; disassociate_ctty(0); @@ -536,7 +540,7 @@ static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t _ /* * (tty == real_tty) is a cheap way of * testing if the tty is NOT a master pty. - */ +*/ if (tty == real_tty && current->signal->tty != real_tty) return -ENOTTY; -- js suse labs
Re: [PATCH -next] tty: n_gsm: use DEFINE_SPINLOCK() for spinlock
On 06. 04. 21, 13:56, Huang Guobin wrote: From: Guobin Huang spinlock can be initialized automatically with DEFINE_SPINLOCK() rather than explicitly calling spin_lock_init(). Reported-by: Hulk Robot Signed-off-by: Guobin Huang Reviewed-by: Jiri Slaby --- drivers/tty/n_gsm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 9e12f9cb1a98..d60cffc70a0c 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -266,7 +266,7 @@ struct gsm_mux { #define MAX_MUX 4 /* 256 minors */ static struct gsm_mux *gsm_mux[MAX_MUX]; /* GSM muxes */ -static spinlock_t gsm_mux_lock; +static DEFINE_SPINLOCK(gsm_mux_lock); static struct tty_driver *gsm_tty_driver; @@ -3257,8 +3257,6 @@ static int __init gsm_init(void) gsm_tty_driver->init_termios.c_lflag &= ~ECHO; tty_set_operations(gsm_tty_driver, &gsmtty_ops); - spin_lock_init(&gsm_mux_lock); - if (tty_register_driver(gsm_tty_driver)) { put_tty_driver(gsm_tty_driver); tty_unregister_ldisc(N_GSM0710); -- js
Re: [PATCH -next] serial: 8250: Make symbol 'brcmuart_debugfs_root' static
On 01. 04. 21, 9:49, Zucheng Zheng wrote: symbol 'brcmuart_debugfs_root' is not used outside of 8250_bcm7271.c, so this commit marks it static. Signed-off-by: Zucheng Zheng Reviewed-by: Jiri Slaby --- drivers/tty/serial/8250/8250_bcm7271.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/8250/8250_bcm7271.c index 63883185fccd..ebba7f2e960c 100644 --- a/drivers/tty/serial/8250/8250_bcm7271.c +++ b/drivers/tty/serial/8250/8250_bcm7271.c @@ -239,7 +239,7 @@ struct brcmuart_priv { u32 rx_abort; }; -struct dentry *brcmuart_debugfs_root; +static struct dentry *brcmuart_debugfs_root; /* * Register access routines -- js
Re: [PATCH] tty: use printk_safe context at tty_msg()
On 03. 04. 21, 6:14, Tetsuo Handa wrote: syzbot is reporting circular locking dependency due to calling printk() with port lock held [1]. When this problem was reported, we worried whether printk_safe context will remain available in future kernels [2], and then this problem was forgotten. But in order to utilize syzbot's resource for finding other bugs/reproducers by closing this one of top crashers, let's apply a patch which counts on availability of printk_safe context. syzbot is also reporting same dependency due to memory allocation fault injection at tty_buffer_alloc(). Although __GFP_NOWARN cannot prevent memory allocation fault injection from calling printk(), let's use __GFP_NOWARN at tty_buffer_alloc() in addition to using printk_safe context, for generating many lines of messages due to warn_alloc() is annoying. If we want to report it, we can use pr_warn() instead. [1] https://syzkaller.appspot.com/bug?id=39ea6caa479af471183997376dc7e90bc7d64a6a [2] https://lkml.kernel.org/r/20190218054649.GA26686@jagdpanzerIV Reported-by: syzbot Reported-by: syzbot Signed-off-by: Tetsuo Handa Fixes: b6da31b2c07c46f2 ("tty: Fix data race in tty_insert_flip_string_fixed_flag") Cc: # 4.18+ --- drivers/tty/tty_buffer.c | 5 - include/linux/tty.h | 9 - 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 6d4995a5f318..d59f7873bc49 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -156,6 +156,7 @@ static struct tty_buffer *tty_buffer_alloc(struct tty_port *port, size_t size) { struct llist_node *free; struct tty_buffer *p; + unsigned long flags; /* Round the buffer size out */ size = __ALIGN_MASK(size, TTYB_ALIGN_MASK); @@ -172,7 +173,9 @@ static struct tty_buffer *tty_buffer_alloc(struct tty_port *port, size_t size) have queued and recycle that ? */ if (atomic_read(&port->buf.mem_used) > port->buf.mem_limit) return NULL; - p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC); + printk_safe_enter_irqsave(flags); + p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC | __GFP_NOWARN); + printk_safe_exit_irqrestore(flags); if (p == NULL) return NULL; diff --git a/include/linux/tty.h b/include/linux/tty.h index 95fc2f100f12..7ae8eb46fec3 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -14,6 +14,7 @@ #include #include #include +#include <../../kernel/printk/internal.h> Including printk's internal header in linux/tty.h doesn't look correct to me. @@ -773,7 +774,13 @@ static inline void proc_tty_unregister_driver(struct tty_driver *d) {} #endif #define tty_msg(fn, tty, f, ...) \ - fn("%s %s: " f, tty_driver_name(tty), tty_name(tty), ##__VA_ARGS__) + do {\ + unsigned long flags;\ + \ + printk_safe_enter_irqsave(flags); \ + fn("%s %s: " f, tty_driver_name(tty), tty_name(tty), ##__VA_ARGS__); \ + printk_safe_exit_irqrestore(flags); \ + } while (0) #define tty_debug(tty, f, ...) tty_msg(pr_debug, tty, f, ##__VA_ARGS__) #define tty_info(tty, f, ...) tty_msg(pr_info, tty, f, ##__VA_ARGS__) -- js
Re: [PATCH 04/10] tty: tty_jobctrl: Fix coding style issues of block comments
On 05. 04. 21, 5:34, Xiaofei Tan wrote: Fix coding style issues of block comments, reported by checkpatch.pl. Signed-off-by: Xiaofei Tan --- drivers/tty/tty_jobctrl.c | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c index 86070f7..4d78422 100644 --- a/drivers/tty/tty_jobctrl.c +++ b/drivers/tty/tty_jobctrl.c @@ -204,8 +204,10 @@ int tty_signal_session_leader(struct tty_struct *tty, int exit_session) spin_lock_irq(&p->sighand->siglock); if (p->signal->tty == tty) { p->signal->tty = NULL; - /* We defer the dereferences outside fo - the tasklist lock */ + /* +* We defer the dereferences outside fo +* the tasklist lock I don't know if it deserves its own patch, but fo -> of fix would be nice. And add a period at the end of the sentence. +*/ refs++; } if (!p->signal->leader) { @@ -328,9 +330,11 @@ void disassociate_ctty(int on_exit) */ void no_tty(void) { - /* FIXME: Review locking here. The tty_lock never covered any race - between a new association and proc_clear_tty but possible we need - to protect against this anyway */ + /* +* FIXME: Review locking here. The tty_lock never covered any race +* between a new association and proc_clear_tty but possible we need "possibly" or "it's possible", I think (as a non-native). +* to protect against this anyway Period. +*/ struct task_struct *tsk = current; disassociate_ctty(0); @@ -536,7 +540,7 @@ static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t _ /* * (tty == real_tty) is a cheap way of * testing if the tty is NOT a master pty. - */ +*/ if (tty == real_tty && current->signal->tty != real_tty) return -ENOTTY; -- js
Re: perf does not resolve plt symbols from libstdc++ right (.plt.sec problem)
On 29. 03. 21, 15:10, H.J. Lu wrote: On Mon, Mar 29, 2021 at 6:06 AM Richard Biener wrote: On Mon, 29 Mar 2021, H.J. Lu wrote: On Mon, Mar 29, 2021 at 2:38 AM Richard Biener wrote: On Mon, 29 Mar 2021, Jiri Slaby wrote: Any ideas on this? On 11. 01. 21, 7:31, Jiri Slaby wrote: Hi, this e-mails is a follow-up of my report at: https://bugzilla.suse.com/show_bug.cgi?id=1180681 There is a problem with *@plt symbols in some libraries, they are unresolved by perf (memcmp@plt in this case): > 0.26% main2/usr/lib64/libstdc++.so.6.0.280xa51a0 l [.] 0x000a51a0 On the other hand, plt symbols in other libraries are fine (memset@plt in this case): > 0.17% main2/usr/lib64/libantlr4-runtime.so.4.8 0x4ed10 l [.] memset@plt I dumped memcmp's .plt.rela entries in perf: /usr/lib64/libantlr4-runtime.so.4.8: 154th addr=4e9d0 plt_off=4e020 hdr=10 entry=10 /usr/lib64/libstdc++.so.6.0.28: 772th addr=a1070 plt_off=9e020 hdr=10 entry=10 The difference (offset) of stdc++'s memcmp is 0xa51a0 (correct) - 0xa1070 (perf's computed) = 0x4130. The problem is perf assumes nth entry of .plt.rela to correspond to nth function in .plt, but memcmp is in .plt.sec in libstdc++.so: >Relocation section '.rela.plt' at offset 0x97900 contains 1018 entries: > Offset Info Type Symbol's Value Symbol's Name + Addend > ... > 001dc838 00780007 R_X86_64_JUMP_SLOT memcmp@GLIBC_2.2.5 + 0 Perf does this with the rela entries: https://github.com/torvalds/linux/blob/f5e6c330254ae691f6d7befe61c786eb5056007e/tools/perf/util/symbol-elf.c#L385 It takes a symbol index from sym.r_info. Then it resolves its name from .dynsym, appending "@plt" to it. Then this name is added to perf's symbol table along with address which is computed as .rela.plt index multiplied by entry size (shdr_plt.sh_entsize) plus plt header (shdr_plt.sh_entsize on x86_64 too). And from this comes (almost) the offset above: >$ objdump -h /usr/lib64/libstdc++.so.6|grep -E ' .plt(\.sec)? ' > 12 .plt 3fb0 0009e020 0009e020 0009e020 2**4 > 14 .plt.sec 3fa0 000a2160 000a2160 000a2160 2**4 0xa2160-0x9e020 = 0x4140. I assume the 0x10 difference is that perf adds shdr_plt.sh_entsize (0x10) to the offset to skip the first .plt entry (header). Richard writes: == .plt.sec is IIRC the "second" (sec) PLT entry - the one that will be used on the second call (and on). This is used / emitted for ELF object instrumented for Intel CET. The details escape me for the moment but I hope the x86 ABI documents this (and the constraints) in detail. I just checked and the x86_64 psABI doesn't say anything about .plt.sec The second PLT is documented in section 13.2 Dynamic Linking in x86-64 psABI. Please see elf_x86_64_get_synthetic_symtab in binutils for PLT symbol processing. Hmm, google pointed me to https://gitlab.com/x86-psABIs/ and that version does not have a section 13 (but the last is section 12 on MPX). There's also references to a pdf which contain the section but that's on github and the github page says gitlab is the home... So I'm a bit confused here. https://gitlab.com/x86-psABIs/x86-64-ABI/-/merge_requests/13 Ok, so it talks only about GOT: === When the IBT-enabled procedure linkage table is used, the initial value of the global offset table entry for the external function is the address of the corresponding entry of the second procedure linkage table. === GOTs are now related to .plt.sec. But my question about .plt.rela remains unanswered by the above: > The problem is perf assumes nth entry of .plt.rela to correspond to nth > function in .plt, but memcmp is in .plt.sec in libstdc++.so So how one finds out whether .rela entries belong to .plt or .plt.sec? Or should we assume that with .plt.sec, .plt.rela always points to .plt.sec? thanks, -- js suse labs
Re: perf does not resolve plt symbols from libstdc++ right (.plt.sec problem)
Any ideas on this? On 11. 01. 21, 7:31, Jiri Slaby wrote: Hi, this e-mails is a follow-up of my report at: https://bugzilla.suse.com/show_bug.cgi?id=1180681 There is a problem with *@plt symbols in some libraries, they are unresolved by perf (memcmp@plt in this case): > 0.26% main2 /usr/lib64/libstdc++.so.6.0.28 0xa51a0 l [.] 0x000a51a0 On the other hand, plt symbols in other libraries are fine (memset@plt in this case): > 0.17% main2 /usr/lib64/libantlr4-runtime.so.4.8 0x4ed10 l [.] memset@plt I dumped memcmp's .plt.rela entries in perf: /usr/lib64/libantlr4-runtime.so.4.8: 154th addr=4e9d0 plt_off=4e020 hdr=10 entry=10 /usr/lib64/libstdc++.so.6.0.28: 772th addr=a1070 plt_off=9e020 hdr=10 entry=10 The difference (offset) of stdc++'s memcmp is 0xa51a0 (correct) - 0xa1070 (perf's computed) = 0x4130. The problem is perf assumes nth entry of .plt.rela to correspond to nth function in .plt, but memcmp is in .plt.sec in libstdc++.so: > Relocation section '.rela.plt' at offset 0x97900 contains 1018 entries: > Offset Info Type Symbol's Value Symbol's Name + Addend > ... > 001dc838 00780007 R_X86_64_JUMP_SLOT memcmp@GLIBC_2.2.5 + 0 Perf does this with the rela entries: https://github.com/torvalds/linux/blob/f5e6c330254ae691f6d7befe61c786eb5056007e/tools/perf/util/symbol-elf.c#L385 It takes a symbol index from sym.r_info. Then it resolves its name from .dynsym, appending "@plt" to it. Then this name is added to perf's symbol table along with address which is computed as .rela.plt index multiplied by entry size (shdr_plt.sh_entsize) plus plt header (shdr_plt.sh_entsize on x86_64 too). And from this comes (almost) the offset above: > $ objdump -h /usr/lib64/libstdc++.so.6|grep -E ' .plt(\.sec)? ' > 12 .plt 3fb0 0009e020 0009e020 0009e020 2**4 > 14 .plt.sec 3fa0 000a2160 000a2160 000a2160 2**4 0xa2160-0x9e020 = 0x4140. I assume the 0x10 difference is that perf adds shdr_plt.sh_entsize (0x10) to the offset to skip the first .plt entry (header). Richard writes: == .plt.sec is IIRC the "second" (sec) PLT entry - the one that will be used on the second call (and on). This is used / emitted for ELF object instrumented for Intel CET. The details escape me for the moment but I hope the x86 ABI documents this (and the constraints) in detail. == How should perf find out whether to consider .plt or .plt.sec? Or generally, how to properly find an address of *@plt symbols like memcmp@plt above? thanks, -- js suse labs
Re: [PATCH] media: videobuf2: Fix integer overrun in vb2_mmap
On 10. 03. 21, 8:40, Ricardo Ribalda wrote: The plane_length is an unsigned integer. So, if we have a size of 0x bytes we incorrectly allocate 0 bytes instead of 1 << 32. Suggested-by: Sergey Senozhatsky Cc: sta...@vger.kernel.org Fixes: 7f8414594e47 ("[media] media: videobuf2: fix the length check for mmap") Signed-off-by: Ricardo Ribalda --- drivers/media/common/videobuf2/videobuf2-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 543da515c761..876db5886867 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -2256,7 +2256,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) * The buffer length was page_aligned at __vb2_buf_mem_alloc(), * so, we need to do the same here. */ - length = PAGE_ALIGN(vb->planes[plane].length); + length = PAGE_ALIGN((unsigned int)vb->planes[plane].length); Hi, I fail to see how case from uint to uint helps -- IOW, did you mean ulong? regards, -- js suse labs
Re: [PATCH] kbuild: dummy-tools: adjust to scripts/cc-version.sh
On 09. 03. 21, 17:25, Masahiro Yamada wrote: Commit aec6c60a01d3 ("kbuild: check the minimum compiler version in Kconfig") changed how the script detects the compiler version. Get 'make CROSS_COMPILE=scripts/dummy-tools/' back working again. Fixes: aec6c60a01d3 ("kbuild: check the minimum compiler version in Kconfig") Signed-off-by: Masahiro Yamada --- Perhaps, Jiri may have already noticed this issue, and have a similar patch. I just checked ML, but I did not find a patch to fix this. No, as I was making it work on 5.11 :). BTW there is one remaining issue I came across: config PAHOLE_HAS_SPLIT_BTF def_bool $(success, test `$(PAHOLE) --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'` -ge "119") and in Makefile we see: PAHOLE = pahole and not something like: PAHOLE = $(CROSS_COMPILE)pahole Any idea how to fix this? scripts/dummy-tools/gcc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/dummy-tools/gcc b/scripts/dummy-tools/gcc index 7b10332b23ba..39e65fee59bd 100755 --- a/scripts/dummy-tools/gcc +++ b/scripts/dummy-tools/gcc @@ -57,9 +57,9 @@ if arg_contain --version "$@"; then fi if arg_contain -E "$@"; then - # For scripts/gcc-version.sh; This emulates GCC 20.0.0 + # For scripts/cc-version.sh; This emulates GCC 20.0.0 if arg_contain - "$@"; then - sed 's/^__GNUC__$/20/; s/^__GNUC_MINOR__$/0/; s/^__GNUC_PATCHLEVEL__$/0/' + sed -n '/^GCC/{s/__GNUC__/20/; s/__GNUC_MINOR__/0/; s/__GNUC_PATCHLEVEL__/0/; p;}' exit 0 else echo "no input files" >&2 -- js suse labs
[PATCH] kbuild: dummy-tools, support MPROFILE_KERNEL checks for ppc
ppc64le checks for -mprofile-kernel to define MPROFILE_KERNEL Kconfig. Kconfig calls arch/powerpc/tools/gcc-check-mprofile-kernel.sh for that purpose. This script performs two checks: 1) build with -mprofile-kernel should contain "_mcount" 2) build with -mprofile-kernel with a function marked as "notrace" should not produce "_mcount" So support this in dummy-tools' gcc, so that we have MPROFILE_KERNEL always true. Signed-off-by: Jiri Slaby Cc: Masahiro Yamada --- scripts/dummy-tools/gcc | 9 + 1 file changed, 9 insertions(+) diff --git a/scripts/dummy-tools/gcc b/scripts/dummy-tools/gcc index 0d0589cf8184..7b10332b23ba 100755 --- a/scripts/dummy-tools/gcc +++ b/scripts/dummy-tools/gcc @@ -73,6 +73,15 @@ if arg_contain -S "$@"; then echo "%gs" exit 0 fi + + # For arch/powerpc/tools/gcc-check-mprofile-kernel.sh + if arg_contain -m64 "$@" && arg_contain -mlittle-endian "$@" && + arg_contain -mprofile-kernel "$@"; then + if ! test -t 0 && ! grep -q notrace; then + echo "_mcount" + fi + exit 0 + fi fi # To set GCC_PLUGINS -- 2.30.1
[tip: x86/vdso] x86/vdso: Use proper modifier for len's format specifier in extract()
The following commit has been merged into the x86/vdso branch of tip: Commit-ID: 70c9d959226b7c5c48c119e2c1cfc1424f87b023 Gitweb: https://git.kernel.org/tip/70c9d959226b7c5c48c119e2c1cfc1424f87b023 Author:Jiri Slaby AuthorDate:Wed, 03 Mar 2021 07:43:57 +01:00 Committer: Borislav Petkov CommitterDate: Sat, 06 Mar 2021 11:34:07 +01:00 x86/vdso: Use proper modifier for len's format specifier in extract() Commit 8382c668ce4f ("x86/vdso: Add support for exception fixup in vDSO functions") prints length "len" which is size_t. Compilers now complain when building on a 32-bit host: HOSTCC arch/x86/entry/vdso/vdso2c ... In file included from arch/x86/entry/vdso/vdso2c.c:162: arch/x86/entry/vdso/vdso2c.h: In function 'extract64': arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of \ type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} So use proper modifier (%zu) for size_t. [ bp: Massage commit message. ] Fixes: 8382c668ce4f ("x86/vdso: Add support for exception fixup in vDSO functions") Signed-off-by: Jiri Slaby Signed-off-by: Borislav Petkov Acked-by: Jarkko Sakkinen Link: https://lkml.kernel.org/r/20210303064357.17056-1-jsl...@suse.cz --- arch/x86/entry/vdso/vdso2c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h index 1c7cfac..5264daa 100644 --- a/arch/x86/entry/vdso/vdso2c.h +++ b/arch/x86/entry/vdso/vdso2c.h @@ -35,7 +35,7 @@ static void BITSFUNC(extract)(const unsigned char *data, size_t data_len, if (offset + len > data_len) fail("section to extract overruns input data"); - fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len); + fprintf(outfile, "static const unsigned char %s[%zu] = {", name, len); BITSFUNC(copy)(outfile, data + offset, len); fprintf(outfile, "\n};\n\n"); }
Re: [PATCH] x86/vdso: Use proper modifier for len's printf in extract
On 04. 03. 21, 11:48, Borislav Petkov wrote: On Thu, Mar 04, 2021 at 06:18:25AM +0100, Jiri Slaby wrote: It's built with gcc 10 from tumbleweed and it's a standard config from kerncvs: https://github.com/openSUSE/kernel-source/blob/stable/config/i386/pae Nope, can't trigger with that one either. :-\ Beware: HOSTCC arch/x86/entry/vdso/vdso2c ^^ You would need to _be_ on i586. Or try with -m32: gcc -m32 -Wp,-MMD,arch/x86/entry/vdso/.vdso2c.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -I/dev/shm/jslaby/linux/tools/include -I/dev/shm/jslaby/linux/include/uapi -I/dev/shm/jslaby/linux/arch/i386/include/uapi -I ./arch/x86/entry/vdso -o /dev/null /dev/shm/jslaby/linux/arch/x86/entry/vdso/vdso2c.c In file included from /dev/shm/jslaby/linux/arch/x86/entry/vdso/vdso2c.c:162:0: /dev/shm/jslaby/linux/arch/x86/entry/vdso/vdso2c.h: In function ‘extract64’: /dev/shm/jslaby/linux/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘size_t {aka unsigned int}’ [-Wformat=] fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len); ~~^ %u In file included from /dev/shm/jslaby/linux/arch/x86/entry/vdso/vdso2c.c:166:0: /dev/shm/jslaby/linux/arch/x86/entry/vdso/vdso2c.h: In function ‘extract32’: /dev/shm/jslaby/linux/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘size_t {aka unsigned int}’ [-Wformat=] fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len); ~~^ %u regards, -- js suse labs
[tip: x86/vdso] x86/vdso: Use proper modifier for len's format specifier in extract()
The following commit has been merged into the x86/vdso branch of tip: Commit-ID: 6bdbe1760651484b0fe6f6d0cc3a2fe8741e6f87 Gitweb: https://git.kernel.org/tip/6bdbe1760651484b0fe6f6d0cc3a2fe8741e6f87 Author:Jiri Slaby AuthorDate:Wed, 03 Mar 2021 07:43:57 +01:00 Committer: Borislav Petkov CommitterDate: Thu, 04 Mar 2021 11:47:01 +01:00 x86/vdso: Use proper modifier for len's format specifier in extract() Commit 8382c668ce4f ("x86/vdso: Add support for exception fixup in vDSO functions") prints length "len" which is size_t. Compilers now complain on 32-bit: In file included from arch/x86/entry/vdso/vdso2c.c:162: arch/x86/entry/vdso/vdso2c.h: In function 'extract64': arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of \ type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} So use proper modifier (%zu) for size_t. [ bp: Massage commit message. ] Fixes: 8382c668ce4f ("x86/vdso: Add support for exception fixup in vDSO functions") Signed-off-by: Jiri Slaby Signed-off-by: Borislav Petkov Acked-by: Jarkko Sakkinen Link: https://lkml.kernel.org/r/20210303064357.17056-1-jsl...@suse.cz --- arch/x86/entry/vdso/vdso2c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h index 1c7cfac..5264daa 100644 --- a/arch/x86/entry/vdso/vdso2c.h +++ b/arch/x86/entry/vdso/vdso2c.h @@ -35,7 +35,7 @@ static void BITSFUNC(extract)(const unsigned char *data, size_t data_len, if (offset + len > data_len) fail("section to extract overruns input data"); - fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len); + fprintf(outfile, "static const unsigned char %s[%zu] = {", name, len); BITSFUNC(copy)(outfile, data + offset, len); fprintf(outfile, "\n};\n\n"); }
Re: [V2][PATCH] vt: keyboard, fix uninitialized variables warning
On 04. 03. 21, 4:10, Li Wang wrote: drivers/tty/vt/keyboard.c: In function 'vt_do_kdgkb_ioctl': drivers/tty/vt/keyboard.c: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized] return ret; ^~~ drivers/tty/vt/keyboard.c: warning: 'kbs' may be used uninitialized in this function [-Wmaybe-uninitialized] kfree(kbs); ^~ Signed-off-by: Li Wang --- drivers/tty/vt/keyboard.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index 7763862..62f1ecb 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c @@ -2090,6 +2090,8 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) ret = 0; break; + default: + return -EINVAL; I am not biased whether to add it or not, but I would return -ENOIOCTLCMD if we do. } kfree(kbs); -- js suse labs
Re: [PATCH] x86/vdso: Use proper modifier for len's printf in extract
On 03. 03. 21, 19:36, Borislav Petkov wrote: On Wed, Mar 03, 2021 at 07:43:57AM +0100, Jiri Slaby wrote: Commit 8382c668ce4f ("x86/vdso: Add support for exception fixup in vDSO functions") added a printf of len which is size_t. Compilers now complain on 32b: In file included from arch/x86/entry/vdso/vdso2c.c:162: arch/x86/entry/vdso/vdso2c.h: In function 'extract64': arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} I know it is obvious but how do you trigger this? A 32-bit allmodconfig with both debian's gcc-10 and leap15's gcc-7 don't trigger that warning. Which might answer your question why I haven't caught it yet. :-) It was caught by suse's build bot while merging the stable branch. But it can be also seen in OBS in Kernel:stable: https://build.opensuse.org/public/build/Kernel:stable/standard/i586/kernel-pae/_log https://build.opensuse.org/public/build/Kernel:stable/standard/i586/kernel-vanilla/_log It's built with gcc 10 from tumbleweed and it's a standard config from kerncvs: https://github.com/openSUSE/kernel-source/blob/stable/config/i386/pae thanks, -- js suse labs
[PATCH] kbuild: dummy-tools, fix inverted tests for gcc
There is a test in Kconfig which takes inverted value of a compiler check: * config CC_HAS_INT128 def_bool !$(cc-option,$(m64-flag) -D__SIZEOF_INT128__=0) This results in CC_HAS_INT128 not being in super-config generated by dummy-tools. So take this into account in the gcc script. Signed-off-by: Jiri Slaby Cc: Masahiro Yamada --- scripts/dummy-tools/gcc | 5 + 1 file changed, 5 insertions(+) diff --git a/scripts/dummy-tools/gcc b/scripts/dummy-tools/gcc index 5c113cad5601..0d0589cf8184 100755 --- a/scripts/dummy-tools/gcc +++ b/scripts/dummy-tools/gcc @@ -85,3 +85,8 @@ if arg_contain -print-file-name=plugin "$@"; then echo $plugin_dir exit 0 fi + +# inverted return value +if arg_contain -D__SIZEOF_INT128__=0 "$@"; then + exit 1 +fi -- 2.30.1
Re: [PATCH v1 1/1] vt: keyboard, Fix typo in the doc for vt_get_shift_state()
On 03. 03. 21, 9:32, Andy Shevchenko wrote: Kernel documentation validator is not happy: .../keyboard.c:2195: warning: expecting prototype for vt_get_shiftstate(). Prototype was for vt_get_shift_state() instead This is due to typo, fix it here. Signed-off-by: Andy Shevchenko Reviewed-by: Jiri Slaby --- drivers/tty/vt/keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index 77638629c562..5d2309742718 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c @@ -2186,7 +2186,7 @@ void vt_reset_unicode(int console) } /** - * vt_get_shiftstate - shift bit state + * vt_get_shift_state - shift bit state * *Report the shift bits from the keyboard state. We have to export *this to support some oddities in the vt layer. -- js
[PATCH] x86/vdso: Use proper modifier for len's printf in extract
Commit 8382c668ce4f ("x86/vdso: Add support for exception fixup in vDSO functions") added a printf of len which is size_t. Compilers now complain on 32b: In file included from arch/x86/entry/vdso/vdso2c.c:162: arch/x86/entry/vdso/vdso2c.h: In function 'extract64': arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} So use proper modifier (%zu) for size_t. Signed-off-by: Jiri Slaby Fixes: 8382c668ce4f ("x86/vdso: Add support for exception fixup in vDSO functions") Cc: Andy Lutomirski Cc: Sean Christopherson Cc: Jarkko Sakkinen Cc: Borislav Petkov Cc: Jethro Beekman Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x...@kernel.org --- arch/x86/entry/vdso/vdso2c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h index 1c7cfac7e64a..5264daa8859f 100644 --- a/arch/x86/entry/vdso/vdso2c.h +++ b/arch/x86/entry/vdso/vdso2c.h @@ -35,7 +35,7 @@ static void BITSFUNC(extract)(const unsigned char *data, size_t data_len, if (offset + len > data_len) fail("section to extract overruns input data"); - fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len); + fprintf(outfile, "static const unsigned char %s[%zu] = {", name, len); BITSFUNC(copy)(outfile, data + offset, len); fprintf(outfile, "\n};\n\n"); } -- 2.30.1
[PATCH 36/44] tty: localise ptychar and make it const
ptychar was not const, so mark it as such. And move this variable to the only place where it's used. Signed-off-by: Jiri Slaby --- drivers/tty/tty_io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index c8cbf08b6dcf..7cf57e6cadbf 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -1196,8 +1196,6 @@ int tty_send_xchar(struct tty_struct *tty, char ch) return 0; } -static char ptychar[] = "pqrstuvwxyzabcde"; - /** * pty_line_name - generate name for a pty * @driver: the tty driver in use @@ -1211,6 +1209,7 @@ static char ptychar[] = "pqrstuvwxyzabcde"; */ static void pty_line_name(struct tty_driver *driver, int index, char *p) { + static const char ptychar[] = "pqrstuvwxyzabcde"; int i = index + driver->name_base; /* ->name is initialized to "ttyp", but "tty" is expected */ sprintf(p, "%s%c%x", -- 2.30.1
[PATCH 43/44] tty: make everyone's chars_in_buffer return >= 0
The tty line disciplines don't expect tty_operations::chars_in_buffer to return negative values. Fix the two drivers which violate this. Signed-off-by: Jiri Slaby --- drivers/tty/n_gsm.c | 2 +- drivers/tty/vcc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 7e1d19805aa4..da10e975829f 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -3056,7 +3056,7 @@ static int gsmtty_chars_in_buffer(struct tty_struct *tty) { struct gsm_dlci *dlci = tty->driver_data; if (dlci->state == DLCI_CLOSED) - return -EINVAL; + return 0; return kfifo_len(&dlci->fifo); } diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c index 04a792749816..3106df98558a 100644 --- a/drivers/tty/vcc.c +++ b/drivers/tty/vcc.c @@ -896,7 +896,7 @@ static int vcc_chars_in_buffer(struct tty_struct *tty) port = vcc_get_ne(tty->index); if (unlikely(!port)) { pr_err("VCC: chars_in_buffer: Failed to find VCC port\n"); - return -ENODEV; + return 0; } num = port->chars_in_buffer; -- 2.30.1
[PATCH 38/44] USB: serial/io_edgeport, drop unneeded forward declarations
Forward declarations make the code larger and rewrites harder. Harder as they are often omitted from global changes. Remove forward declarations which are not really needed, i.e. the definition of the function is before its first use. Signed-off-by: Jiri Slaby Cc: Johan Hovold --- drivers/usb/serial/io_edgeport.c | 41 1 file changed, 41 deletions(-) diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index a493670c06e6..54b476a228d6 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -265,35 +265,7 @@ static atomic_t CmdUrbs = ATOMIC_INIT(0); /* local function prototypes */ -/* function prototypes for all URB callbacks */ -static void edge_interrupt_callback(struct urb *urb); -static void edge_bulk_in_callback(struct urb *urb); -static void edge_bulk_out_data_callback(struct urb *urb); -static void edge_bulk_out_cmd_callback(struct urb *urb); - -/* function prototypes for the usbserial callbacks */ -static int edge_open(struct tty_struct *tty, struct usb_serial_port *port); static void edge_close(struct usb_serial_port *port); -static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, - const unsigned char *buf, int count); -static int edge_write_room(struct tty_struct *tty); -static int edge_chars_in_buffer(struct tty_struct *tty); -static void edge_throttle(struct tty_struct *tty); -static void edge_unthrottle(struct tty_struct *tty); -static void edge_set_termios(struct tty_struct *tty, - struct usb_serial_port *port, - struct ktermios *old_termios); -static int edge_ioctl(struct tty_struct *tty, - unsigned int cmd, unsigned long arg); -static void edge_break(struct tty_struct *tty, int break_state); -static int edge_tiocmget(struct tty_struct *tty); -static int edge_tiocmset(struct tty_struct *tty, - unsigned int set, unsigned int clear); -static int edge_startup(struct usb_serial *serial); -static void edge_disconnect(struct usb_serial *serial); -static void edge_release(struct usb_serial *serial); -static int edge_port_probe(struct usb_serial_port *port); -static void edge_port_remove(struct usb_serial_port *port); /* function prototypes for all of our local functions */ @@ -309,8 +281,6 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, static int send_iosp_ext_cmd(struct edgeport_port *edge_port, __u8 command, __u8 param); static int calc_baud_rate_divisor(struct device *dev, int baud_rate, int *divisor); -static int send_cmd_write_baud_rate(struct edgeport_port *edge_port, - int baudRate); static void change_port_settings(struct tty_struct *tty, struct edgeport_port *edge_port, struct ktermios *old_termios); @@ -321,19 +291,8 @@ static int write_cmd_usb(struct edgeport_port *edge_port, static void send_more_port_data(struct edgeport_serial *edge_serial, struct edgeport_port *edge_port); -static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, - __u16 length, const __u8 *data); -static int rom_read(struct usb_serial *serial, __u16 extAddr, __u16 addr, - __u16 length, __u8 *data); static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, const __u8 *data); -static void get_manufacturing_desc(struct edgeport_serial *edge_serial); -static void get_boot_desc(struct edgeport_serial *edge_serial); -static void load_application_firmware(struct edgeport_serial *edge_serial); - -static void unicode_to_ascii(char *string, int buflen, - __le16 *unicode, int unicode_size); - /* */ /* */ -- 2.30.1
[PATCH 40/44] tty: hvc, drop unneeded forward declarations
Forward declarations make the code larger and rewrites harder. Harder as they are often omitted from global changes. Remove forward declarations which are not really needed, i.e. the definition of the function is before its first use. Signed-off-by: Jiri Slaby Cc: linuxppc-...@lists.ozlabs.org --- drivers/tty/hvc/hvcs.c | 25 - 1 file changed, 25 deletions(-) diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index c90848919644..0b89d878a108 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c @@ -290,36 +290,11 @@ static LIST_HEAD(hvcs_structs); static DEFINE_SPINLOCK(hvcs_structs_lock); static DEFINE_MUTEX(hvcs_init_mutex); -static void hvcs_unthrottle(struct tty_struct *tty); -static void hvcs_throttle(struct tty_struct *tty); -static irqreturn_t hvcs_handle_interrupt(int irq, void *dev_instance); - -static int hvcs_write(struct tty_struct *tty, - const unsigned char *buf, int count); -static int hvcs_write_room(struct tty_struct *tty); -static int hvcs_chars_in_buffer(struct tty_struct *tty); - -static int hvcs_has_pi(struct hvcs_struct *hvcsd); -static void hvcs_set_pi(struct hvcs_partner_info *pi, - struct hvcs_struct *hvcsd); static int hvcs_get_pi(struct hvcs_struct *hvcsd); static int hvcs_rescan_devices_list(void); -static int hvcs_partner_connect(struct hvcs_struct *hvcsd); static void hvcs_partner_free(struct hvcs_struct *hvcsd); -static int hvcs_enable_device(struct hvcs_struct *hvcsd, - uint32_t unit_address, unsigned int irq, struct vio_dev *dev); - -static int hvcs_open(struct tty_struct *tty, struct file *filp); -static void hvcs_close(struct tty_struct *tty, struct file *filp); -static void hvcs_hangup(struct tty_struct * tty); - -static int hvcs_probe(struct vio_dev *dev, - const struct vio_device_id *id); -static int hvcs_remove(struct vio_dev *dev); -static int __init hvcs_module_init(void); -static void __exit hvcs_module_exit(void); static int hvcs_initialize(void); #define HVCS_SCHED_READ0x0001 -- 2.30.1
[PATCH 41/44] tty: n_gsm, remove duplicates of parameters
dp, f, and i are only duplicates of gsmld_receive_buf's parameters. Use the parameters directly (cp, fp, and count) and delete these local variables. Signed-off-by: Jiri Slaby --- drivers/tty/n_gsm.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index b063bc608a8c..7e1d19805aa4 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -2416,27 +2416,24 @@ static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) { struct gsm_mux *gsm = tty->disc_data; - const unsigned char *dp; - char *f; - int i; char flags = TTY_NORMAL; if (debug & 4) print_hex_dump_bytes("gsmld_receive: ", DUMP_PREFIX_OFFSET, cp, count); - for (i = count, dp = cp, f = fp; i; i--, dp++) { - if (f) - flags = *f++; + for (; count; count--, cp++) { + if (fp) + flags = *fp++; switch (flags) { case TTY_NORMAL: - gsm->receive(gsm, *dp); + gsm->receive(gsm, *cp); break; case TTY_OVERRUN: case TTY_BREAK: case TTY_PARITY: case TTY_FRAME: - gsm_error(gsm, *dp, flags); + gsm_error(gsm, *cp, flags); break; default: WARN_ONCE(1, "%s: unknown flag %d\n", -- 2.30.1
[PATCH 42/44] tty: cleanup tty_chars_in_buffer
There is no need for 'else' when the 'if' part already returned. This makes tty_chars_in_buffer similar to tty_write_room too. Signed-off-by: Jiri Slaby --- drivers/tty/tty_ioctl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index 4de1c6ddb8ff..deffaefcf41d 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c @@ -57,8 +57,7 @@ int tty_chars_in_buffer(struct tty_struct *tty) { if (tty->ops->chars_in_buffer) return tty->ops->chars_in_buffer(tty); - else - return 0; + return 0; } EXPORT_SYMBOL(tty_chars_in_buffer); -- 2.30.1
[PATCH 44/44] tty: make everyone's write_room return >= 0
The tty line disciplines don't expect tty_operations::write_room to return negative values. Fix the five drivers which violate this. Signed-off-by: Jiri Slaby --- drivers/staging/gdm724x/gdm_tty.c | 2 +- drivers/tty/ipwireless/tty.c | 4 ++-- drivers/tty/n_gsm.c | 2 +- drivers/tty/vcc.c | 2 +- drivers/usb/serial/mos7720.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index 6e813693a766..0ccc8c24e754 100644 --- a/drivers/staging/gdm724x/gdm_tty.c +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -188,7 +188,7 @@ static int gdm_tty_write_room(struct tty_struct *tty) struct gdm *gdm = tty->driver_data; if (!GDM_TTY_READY(gdm)) - return -ENODEV; + return 0; return WRITE_SIZE; } diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c index 1836746991b5..99bb2f149ff5 100644 --- a/drivers/tty/ipwireless/tty.c +++ b/drivers/tty/ipwireless/tty.c @@ -235,10 +235,10 @@ static int ipw_write_room(struct tty_struct *linux_tty) /* FIXME: Exactly how is the tty object locked here .. */ if (!tty) - return -ENODEV; + return 0; if (!tty->port.count) - return -EINVAL; + return 0; room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued; if (room < 0) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index da10e975829f..9e12f9cb1a98 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -3048,7 +3048,7 @@ static int gsmtty_write_room(struct tty_struct *tty) { struct gsm_dlci *dlci = tty->driver_data; if (dlci->state == DLCI_CLOSED) - return -EINVAL; + return 0; return TX_SIZE - kfifo_len(&dlci->fifo); } diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c index 3106df98558a..0a3a71e14df4 100644 --- a/drivers/tty/vcc.c +++ b/drivers/tty/vcc.c @@ -878,7 +878,7 @@ static int vcc_write_room(struct tty_struct *tty) port = vcc_get_ne(tty->index); if (unlikely(!port)) { pr_err("VCC: write_room: Failed to find VCC port\n"); - return -ENODEV; + return 0; } num = VCC_BUFF_LEN - port->chars_in_buffer; diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 701dfb32b129..bb3d39307d93 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -1042,7 +1042,7 @@ static int mos7720_write_room(struct tty_struct *tty) mos7720_port = usb_get_serial_port_data(port); if (mos7720_port == NULL) - return -ENODEV; + return 0; /* FIXME: Locking */ for (i = 0; i < NUM_URBS; ++i) { -- 2.30.1
[PATCH 39/44] tty: synclink_gt, drop unneeded forward declarations
Forward declarations make the code larger and rewrites harder. Harder as they are often omitted from global changes. Remove forward declarations which are not really needed, i.e. the definition of the function is before its first use. Signed-off-by: Jiri Slaby --- drivers/tty/synclink_gt.c | 57 +-- 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index 4727a41158b0..1db908f62fde 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -137,37 +137,14 @@ MODULE_PARM_DESC(maxframe, "Maximum frame size used by device (4096 to 65535)"); */ static struct tty_driver *serial_driver; -static int open(struct tty_struct *tty, struct file * filp); -static void close(struct tty_struct *tty, struct file * filp); -static void hangup(struct tty_struct *tty); -static void set_termios(struct tty_struct *tty, struct ktermios *old_termios); - -static int write(struct tty_struct *tty, const unsigned char *buf, int count); -static int put_char(struct tty_struct *tty, unsigned char ch); -static void send_xchar(struct tty_struct *tty, char ch); static void wait_until_sent(struct tty_struct *tty, int timeout); -static int write_room(struct tty_struct *tty); -static void flush_chars(struct tty_struct *tty); static void flush_buffer(struct tty_struct *tty); -static void tx_hold(struct tty_struct *tty); static void tx_release(struct tty_struct *tty); -static int ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg); -static int chars_in_buffer(struct tty_struct *tty); -static void throttle(struct tty_struct * tty); -static void unthrottle(struct tty_struct * tty); -static int set_break(struct tty_struct *tty, int break_state); - /* - * generic HDLC support and callbacks + * generic HDLC support */ -#if SYNCLINK_GENERIC_HDLC #define dev_to_port(D) (dev_to_hdlc(D)->priv) -static void hdlcdev_tx_done(struct slgt_info *info); -static void hdlcdev_rx(struct slgt_info *info, char *buf, int size); -static int hdlcdev_init(struct slgt_info *info); -static void hdlcdev_exit(struct slgt_info *info); -#endif /* @@ -186,9 +163,6 @@ struct cond_wait { wait_queue_entry_t wait; unsigned int data; }; -static void init_cond_wait(struct cond_wait *w, unsigned int data); -static void add_cond_wait(struct cond_wait **head, struct cond_wait *w); -static void remove_cond_wait(struct cond_wait **head, struct cond_wait *w); static void flush_cond_wait(struct cond_wait **head); /* @@ -443,12 +417,8 @@ static void shutdown(struct slgt_info *info); static void program_hw(struct slgt_info *info); static void change_params(struct slgt_info *info); -static int register_test(struct slgt_info *info); -static int irq_test(struct slgt_info *info); -static int loopback_test(struct slgt_info *info); static int adapter_test(struct slgt_info *info); -static void reset_adapter(struct slgt_info *info); static void reset_port(struct slgt_info *info); static void async_mode(struct slgt_info *info); static void sync_mode(struct slgt_info *info); @@ -457,14 +427,12 @@ static void rx_stop(struct slgt_info *info); static void rx_start(struct slgt_info *info); static void reset_rbufs(struct slgt_info *info); static void free_rbufs(struct slgt_info *info, unsigned int first, unsigned int last); -static void rdma_reset(struct slgt_info *info); static bool rx_get_frame(struct slgt_info *info); static bool rx_get_buf(struct slgt_info *info); static void tx_start(struct slgt_info *info); static void tx_stop(struct slgt_info *info); static void tx_set_idle(struct slgt_info *info); -static unsigned int free_tbuf_count(struct slgt_info *info); static unsigned int tbuf_bytes(struct slgt_info *info); static void reset_tbufs(struct slgt_info *info); static void tdma_reset(struct slgt_info *info); @@ -472,26 +440,10 @@ static bool tx_load(struct slgt_info *info, const char *buf, unsigned int count) static void get_signals(struct slgt_info *info); static void set_signals(struct slgt_info *info); -static void enable_loopback(struct slgt_info *info); static void set_rate(struct slgt_info *info, u32 data_rate); -static int bh_action(struct slgt_info *info); -static void bh_handler(struct work_struct *work); static void bh_transmit(struct slgt_info *info); -static void isr_serial(struct slgt_info *info); -static void isr_rdma(struct slgt_info *info); static void isr_txeom(struct slgt_info *info, unsigned short status); -static void isr_tdma(struct slgt_info *info); - -static int alloc_dma_bufs(struct slgt_info *info); -static void free_dma_bufs(struct slgt_info *info); -static int alloc_desc(struct slgt_info *info); -static void free_desc(struct slgt_info *info); -static int alloc_bufs(struct slgt_info *info, struct slgt_desc *bufs, int count); -static void free_bufs(struct slgt_info *info, struct slgt_desc *bufs, int count); - -static int alloc_tm
[PATCH 37/44] USB: serial/keyspan, drop unneeded forward declarations
Forward declarations make the code larger, harder to follow and rewrite. Harder as the declarations are often omitted from global changes. Remove forward declarations which are not really needed, i.e. when the definition of the function is before its first use. Signed-off-by: Jiri Slaby Cc: Johan Hovold --- drivers/usb/serial/keyspan.c | 20 1 file changed, 20 deletions(-) diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 622077dcc344..b04a029e3657 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -41,27 +41,7 @@ #define DRIVER_AUTHOR "Hugh Blemings
[PATCH 35/44] tty: let tty_unregister_driver return void
Now that noone checks the return value, switch the return type of tty_unregister_driver to void. We can do that as we always return zero. Generally, drivers are not allowed to call tty_unregister_driver while there are open devices. Signed-off-by: Jiri Slaby --- drivers/tty/tty_io.c | 9 + include/linux/tty.h | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 74733ec8f565..c8cbf08b6dcf 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3525,21 +3525,14 @@ EXPORT_SYMBOL(tty_register_driver); /* * Called by a tty driver to unregister itself. */ -int tty_unregister_driver(struct tty_driver *driver) +void tty_unregister_driver(struct tty_driver *driver) { -#if 0 - /* FIXME */ - if (driver->refcount) - return -EBUSY; -#endif unregister_chrdev_region(MKDEV(driver->major, driver->minor_start), driver->num); mutex_lock(&tty_mutex); list_del(&driver->tty_drivers); mutex_unlock(&tty_mutex); - return 0; } - EXPORT_SYMBOL(tty_unregister_driver); dev_t tty_devnum(struct tty_struct *tty) diff --git a/include/linux/tty.h b/include/linux/tty.h index 95fc2f100f12..51f56e5ec955 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -482,7 +482,7 @@ extern void stop_tty(struct tty_struct *tty); extern void __start_tty(struct tty_struct *tty); extern void start_tty(struct tty_struct *tty); extern int tty_register_driver(struct tty_driver *driver); -extern int tty_unregister_driver(struct tty_driver *driver); +extern void tty_unregister_driver(struct tty_driver *driver); extern struct device *tty_register_device(struct tty_driver *driver, unsigned index, struct device *dev); extern struct device *tty_register_device_attr(struct tty_driver *driver, -- 2.30.1
[PATCH 24/44] tty: nozomi, remove useless debug prints
These are either commented out or can be printed by tracing mechanisms. Signed-off-by: Jiri Slaby --- drivers/tty/nozomi.c | 11 --- 1 file changed, 11 deletions(-) diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index 1ec975d66528..9a2d78ace49b 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c @@ -777,7 +777,6 @@ static int receive_data(enum port_type index, struct nozomi *dc) int i, ret; size = __le32_to_cpu(readl(addr)); - /* DBG1( "%d bytes port: %d", size, index); */ if (tty && tty_throttled(tty)) { DBG1("No room in tty, don't read data, don't ack interrupt, " @@ -1308,8 +1307,6 @@ static int nozomi_card_init(struct pci_dev *pdev, int ndev_idx; int i; - dev_dbg(&pdev->dev, "Init, new card found\n"); - for (ndev_idx = 0; ndev_idx < ARRAY_SIZE(ndevs); ndev_idx++) if (!ndevs[ndev_idx]) break; @@ -1443,8 +1440,6 @@ static void tty_exit(struct nozomi *dc) { unsigned int i; - DBG1(" "); - for (i = 0; i < MAX_PORT; ++i) tty_port_tty_hangup(&dc->port[i].port, false); @@ -1609,8 +1604,6 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer, struct port *port = tty->driver_data; unsigned long flags; - /* DBG1( "WRITEx: %d, index = %d", count, index); */ - if (!dc || !port) return -ENODEV; @@ -1736,8 +1729,6 @@ static int ntty_ioctl(struct tty_struct *tty, struct port *port = tty->driver_data; int rval = -ENOIOCTLCMD; - DBG1(" IOCTL, cmd: %d", cmd); - switch (cmd) { case TIOCMIWAIT: { struct async_icount cprev = port->tty_icount; @@ -1763,7 +1754,6 @@ static void ntty_unthrottle(struct tty_struct *tty) struct nozomi *dc = get_dc_by_tty(tty); unsigned long flags; - DBG1("UNTHROTTLE"); spin_lock_irqsave(&dc->spin_mutex, flags); enable_transmit_dl(tty->index % MAX_PORT, dc); set_rts(tty, 1); @@ -1780,7 +1770,6 @@ static void ntty_throttle(struct tty_struct *tty) struct nozomi *dc = get_dc_by_tty(tty); unsigned long flags; - DBG1("THROTTLE"); spin_lock_irqsave(&dc->spin_mutex, flags); set_rts(tty, 0); spin_unlock_irqrestore(&dc->spin_mutex, flags); -- 2.30.1
[PATCH 30/44] tty: xtensa/iss, don't reassign to tty->port
We already do tty_port_link_device in rs_init, so we don't need to reassign a port to tty->port. It would be too late in tty::ops::open anyway. Signed-off-by: Jiri Slaby Cc: Chris Zankel Cc: Max Filippov Cc: linux-xte...@linux-xtensa.org --- arch/xtensa/platforms/iss/console.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index 1179011044a7..5d7f9c638437 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -48,7 +48,6 @@ static void rs_poll(struct timer_list *); static int rs_open(struct tty_struct *tty, struct file * filp) { - tty->port = &serial_port; spin_lock_bh(&timer_lock); if (tty->count == 1) { timer_setup(&serial_timer, rs_poll, 0); -- 2.30.1
[PATCH 32/44] tty: xtensa/iss, setup the timer statically
Use DEFINE_TIMER and avoid runtime initialization of the serial_timer. Signed-off-by: Jiri Slaby Cc: Chris Zankel Cc: Max Filippov Cc: linux-xte...@linux-xtensa.org --- arch/xtensa/platforms/iss/console.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index 3b89d9ceb06a..8ea261b8c022 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -31,21 +31,18 @@ #define SERIAL_MAX_NUM_LINES 1 #define SERIAL_TIMER_VALUE (HZ / 10) +static void rs_poll(struct timer_list *); + static struct tty_driver *serial_driver; static struct tty_port serial_port; -static struct timer_list serial_timer; - +static DEFINE_TIMER(serial_timer, rs_poll); static DEFINE_SPINLOCK(timer_lock); -static void rs_poll(struct timer_list *); - static int rs_open(struct tty_struct *tty, struct file * filp) { spin_lock_bh(&timer_lock); - if (tty->count == 1) { - timer_setup(&serial_timer, rs_poll, 0); + if (tty->count == 1) mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); - } spin_unlock_bh(&timer_lock); return 0; -- 2.30.1
[PATCH 22/44] tty: nozomi, remove struct buffer
It is unused. Signed-off-by: Jiri Slaby --- drivers/tty/nozomi.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index 861e95043191..83490925a3e2 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c @@ -359,12 +359,6 @@ struct nozomi { u32 open_ttys; }; -/* This is a data packet that is read or written to/from card */ -struct buffer { - u32 size; /* size is the length of the data buffer */ - u8 *data; -} __attribute__ ((packed)); - /* Global variables */ static const struct pci_device_id nozomi_pci_tbl[] = { {PCI_DEVICE(0x1931, 0x000c)}, /* Nozomi HSDPA */ -- 2.30.1
[PATCH 27/44] tty: vcc, use name strings directly
Do not define global variables for driver/device names, use the strings directly. Signed-off-by: Jiri Slaby Cc: "David S. Miller" Cc: sparcli...@vger.kernel.org --- drivers/tty/vcc.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c index 31b8a9a77375..a6cdbd170a61 100644 --- a/drivers/tty/vcc.c +++ b/drivers/tty/vcc.c @@ -52,8 +52,6 @@ struct vcc_port { #define VCC_CTL_BREAK -1 #define VCC_CTL_HUP-2 -static const char vcc_driver_name[] = "vcc"; -static const char vcc_device_node[] = "vcc"; static struct tty_driver *vcc_tty_driver; static struct vcc_port *vcc_table[VCC_MAX_PORTS]; @@ -1065,8 +1063,8 @@ static int vcc_tty_init(void) return PTR_ERR(vcc_tty_driver); } - vcc_tty_driver->driver_name = vcc_driver_name; - vcc_tty_driver->name = vcc_device_node; + vcc_tty_driver->driver_name = "vcc"; + vcc_tty_driver->name = "vcc"; vcc_tty_driver->minor_start = VCC_MINOR_START; vcc_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM; -- 2.30.1
[PATCH 28/44] tty: vcc, remove useless tty checks
All these functions are called with a valid tty pointer, no need to check that. Signed-off-by: Jiri Slaby Cc: "David S. Miller" Cc: sparcli...@vger.kernel.org --- drivers/tty/vcc.c | 45 - 1 file changed, 45 deletions(-) diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c index a6cdbd170a61..04a792749816 100644 --- a/drivers/tty/vcc.c +++ b/drivers/tty/vcc.c @@ -726,11 +726,6 @@ static int vcc_open(struct tty_struct *tty, struct file *vcc_file) { struct vcc_port *port; - if (unlikely(!tty)) { - pr_err("VCC: open: Invalid TTY handle\n"); - return -ENXIO; - } - if (tty->count > 1) return -EBUSY; @@ -764,11 +759,6 @@ static int vcc_open(struct tty_struct *tty, struct file *vcc_file) static void vcc_close(struct tty_struct *tty, struct file *vcc_file) { - if (unlikely(!tty)) { - pr_err("VCC: close: Invalid TTY handle\n"); - return; - } - if (unlikely(tty->count > 1)) return; @@ -796,11 +786,6 @@ static void vcc_hangup(struct tty_struct *tty) { struct vcc_port *port; - if (unlikely(!tty)) { - pr_err("VCC: hangup: Invalid TTY handle\n"); - return; - } - port = vcc_get_ne(tty->index); if (unlikely(!port)) { pr_err("VCC: hangup: Failed to find VCC port\n"); @@ -830,11 +815,6 @@ static int vcc_write(struct tty_struct *tty, const unsigned char *buf, int tosend = 0; int rv = -EINVAL; - if (unlikely(!tty)) { - pr_err("VCC: write: Invalid TTY handle\n"); - return -ENXIO; - } - port = vcc_get_ne(tty->index); if (unlikely(!port)) { pr_err("VCC: write: Failed to find VCC port"); @@ -895,11 +875,6 @@ static int vcc_write_room(struct tty_struct *tty) struct vcc_port *port; u64 num; - if (unlikely(!tty)) { - pr_err("VCC: write_room: Invalid TTY handle\n"); - return -ENXIO; - } - port = vcc_get_ne(tty->index); if (unlikely(!port)) { pr_err("VCC: write_room: Failed to find VCC port\n"); @@ -918,11 +893,6 @@ static int vcc_chars_in_buffer(struct tty_struct *tty) struct vcc_port *port; u64 num; - if (unlikely(!tty)) { - pr_err("VCC: chars_in_buffer: Invalid TTY handle\n"); - return -ENXIO; - } - port = vcc_get_ne(tty->index); if (unlikely(!port)) { pr_err("VCC: chars_in_buffer: Failed to find VCC port\n"); @@ -941,11 +911,6 @@ static int vcc_break_ctl(struct tty_struct *tty, int state) struct vcc_port *port; unsigned long flags; - if (unlikely(!tty)) { - pr_err("VCC: break_ctl: Invalid TTY handle\n"); - return -ENXIO; - } - port = vcc_get_ne(tty->index); if (unlikely(!port)) { pr_err("VCC: break_ctl: Failed to find VCC port\n"); @@ -976,11 +941,6 @@ static int vcc_install(struct tty_driver *driver, struct tty_struct *tty) struct tty_port *port_tty; int ret; - if (unlikely(!tty)) { - pr_err("VCC: install: Invalid TTY handle\n"); - return -ENXIO; - } - if (tty->index >= VCC_MAX_PORTS) return -EINVAL; @@ -1015,11 +975,6 @@ static void vcc_cleanup(struct tty_struct *tty) { struct vcc_port *port; - if (unlikely(!tty)) { - pr_err("VCC: cleanup: Invalid TTY handle\n"); - return; - } - port = vcc_get(tty->index, true); if (port) { port->tty = NULL; -- 2.30.1
[PATCH 20/44] tty: con3215, remove tty->driver_data casts
Casts of 'void *' pointer are superfluous. So remove them. Signed-off-by: Jiri Slaby Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: linux...@de.ibm.com Cc: linux-s...@vger.kernel.org --- drivers/s390/char/con3215.c | 32 +++- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index ae0dd9c1595c..d26947d743bc 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c @@ -911,9 +911,8 @@ static int tty3215_open(struct tty_struct *tty, struct file * filp) */ static void tty3215_close(struct tty_struct *tty, struct file * filp) { - struct raw3215_info *raw; + struct raw3215_info *raw = tty->driver_data; - raw = (struct raw3215_info *) tty->driver_data; if (raw == NULL || tty->count > 1) return; tty->closing = 1; @@ -928,9 +927,7 @@ static void tty3215_close(struct tty_struct *tty, struct file * filp) */ static int tty3215_write_room(struct tty_struct *tty) { - struct raw3215_info *raw; - - raw = (struct raw3215_info *) tty->driver_data; + struct raw3215_info *raw = tty->driver_data; /* Subtract TAB_STOP_SIZE to allow for a tab, 8 <<< 64K */ if ((RAW3215_BUFFER_SIZE - raw->count - TAB_STOP_SIZE) >= 0) @@ -945,10 +942,9 @@ static int tty3215_write_room(struct tty_struct *tty) static int tty3215_write(struct tty_struct * tty, const unsigned char *buf, int count) { - struct raw3215_info *raw; + struct raw3215_info *raw = tty->driver_data; int i, written; - raw = (struct raw3215_info *) tty->driver_data; written = count; while (count > 0) { for (i = 0; i < count; i++) @@ -971,10 +967,10 @@ static int tty3215_write(struct tty_struct * tty, */ static int tty3215_put_char(struct tty_struct *tty, unsigned char ch) { - struct raw3215_info *raw; + struct raw3215_info *raw = tty->driver_data; - raw = (struct raw3215_info *) tty->driver_data; raw3215_putchar(raw, ch); + return 1; } @@ -987,17 +983,15 @@ static void tty3215_flush_chars(struct tty_struct *tty) */ static int tty3215_chars_in_buffer(struct tty_struct *tty) { - struct raw3215_info *raw; + struct raw3215_info *raw = tty->driver_data; - raw = (struct raw3215_info *) tty->driver_data; return raw->count; } static void tty3215_flush_buffer(struct tty_struct *tty) { - struct raw3215_info *raw; + struct raw3215_info *raw = tty->driver_data; - raw = (struct raw3215_info *) tty->driver_data; raw3215_flush_buffer(raw); tty_wakeup(tty); } @@ -1007,9 +1001,8 @@ static void tty3215_flush_buffer(struct tty_struct *tty) */ static void tty3215_throttle(struct tty_struct * tty) { - struct raw3215_info *raw; + struct raw3215_info *raw = tty->driver_data; - raw = (struct raw3215_info *) tty->driver_data; raw->flags |= RAW3215_THROTTLED; } @@ -1018,10 +1011,9 @@ static void tty3215_throttle(struct tty_struct * tty) */ static void tty3215_unthrottle(struct tty_struct * tty) { - struct raw3215_info *raw; + struct raw3215_info *raw = tty->driver_data; unsigned long flags; - raw = (struct raw3215_info *) tty->driver_data; if (raw->flags & RAW3215_THROTTLED) { spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); raw->flags &= ~RAW3215_THROTTLED; @@ -1035,9 +1027,8 @@ static void tty3215_unthrottle(struct tty_struct * tty) */ static void tty3215_stop(struct tty_struct *tty) { - struct raw3215_info *raw; + struct raw3215_info *raw = tty->driver_data; - raw = (struct raw3215_info *) tty->driver_data; raw->flags |= RAW3215_STOPPED; } @@ -1046,10 +1037,9 @@ static void tty3215_stop(struct tty_struct *tty) */ static void tty3215_start(struct tty_struct *tty) { - struct raw3215_info *raw; + struct raw3215_info *raw = tty->driver_data; unsigned long flags; - raw = (struct raw3215_info *) tty->driver_data; if (raw->flags & RAW3215_STOPPED) { spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); raw->flags &= ~RAW3215_STOPPED; -- 2.30.1
[PATCH 25/44] tty: vcc, make globals static
These are used only in this unit, so make them static. Signed-off-by: Jiri Slaby --- drivers/tty/vcc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c index e2d6205f83ce..50bf9011a0c4 100644 --- a/drivers/tty/vcc.c +++ b/drivers/tty/vcc.c @@ -66,9 +66,9 @@ static struct tty_driver *vcc_tty_driver; static struct vcc_port *vcc_table[VCC_MAX_PORTS]; static DEFINE_SPINLOCK(vcc_table_lock); -int vcc_dbg; -int vcc_dbg_ldc; -int vcc_dbg_vio; +static unsigned int vcc_dbg; +static unsigned int vcc_dbg_ldc; +static unsigned int vcc_dbg_vio; module_param(vcc_dbg, uint, 0664); module_param(vcc_dbg_ldc, uint, 0664); -- 2.30.1
[PATCH 26/44] tty: vcc, drop version dump
The version number is artificial, no need to dump it to logs during initialization. Signed-off-by: Jiri Slaby Cc: "David S. Miller" Cc: --- drivers/tty/vcc.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c index 50bf9011a0c4..31b8a9a77375 100644 --- a/drivers/tty/vcc.c +++ b/drivers/tty/vcc.c @@ -14,16 +14,9 @@ #include #include -#define DRV_MODULE_NAME"vcc" -#define DRV_MODULE_VERSION "1.1" -#define DRV_MODULE_RELDATE "July 1, 2017" - -static char version[] = - DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")"; - MODULE_DESCRIPTION("Sun LDOM virtual console concentrator driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_MODULE_VERSION); +MODULE_VERSION("1.1"); struct vcc_port { struct vio_driver_state vio; @@ -1066,8 +1059,6 @@ static int vcc_tty_init(void) { int rv; - pr_info("VCC: %s\n", version); - vcc_tty_driver = tty_alloc_driver(VCC_MAX_PORTS, VCC_TTY_FLAGS); if (IS_ERR(vcc_tty_driver)) { pr_err("VCC: TTY driver alloc failed\n"); -- 2.30.1
[PATCH 17/44] net: nfc: nci: drop nci_uart_default_recv
nci_uart_register returns -EINVAL immediately when nu->ops.recv is not set. So the same 'if' later never triggers so nci_uart_default_recv is never used. Drop it. Signed-off-by: Jiri Slaby Cc: "David S. Miller" Cc: Jakub Kicinski Cc: net...@vger.kernel.org --- net/nfc/nci/uart.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c index 5cf7d3729d5f..9958b37d8f9d 100644 --- a/net/nfc/nci/uart.c +++ b/net/nfc/nci/uart.c @@ -387,12 +387,6 @@ static int nci_uart_send(struct nci_uart *nu, struct sk_buff *skb) return 0; } -/* -- Default recv handler -- */ -static int nci_uart_default_recv(struct nci_uart *nu, struct sk_buff *skb) -{ - return nci_recv_frame(nu->ndev, skb); -} - int nci_uart_register(struct nci_uart *nu) { if (!nu || !nu->ops.open || @@ -402,10 +396,6 @@ int nci_uart_register(struct nci_uart *nu) /* Set the send callback */ nu->ops.send = nci_uart_send; - /* Install default handlers if not overridden */ - if (!nu->ops.recv) - nu->ops.recv = nci_uart_default_recv; - /* Add this driver in the driver list */ if (nci_uart_drivers[nu->driver]) { pr_err("driver %d is already registered\n", nu->driver); -- 2.30.1
[PATCH 19/44] tty: con3215, remove unneeded tty checks
There is no need to check tty in these functions as it's always non-NULL. So remove the tests. Signed-off-by: Jiri Slaby Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: linux...@de.ibm.com Cc: linux-s...@vger.kernel.org --- drivers/s390/char/con3215.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 5923a1f133ef..ae0dd9c1595c 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c @@ -948,8 +948,6 @@ static int tty3215_write(struct tty_struct * tty, struct raw3215_info *raw; int i, written; - if (!tty) - return 0; raw = (struct raw3215_info *) tty->driver_data; written = count; while (count > 0) { @@ -975,8 +973,6 @@ static int tty3215_put_char(struct tty_struct *tty, unsigned char ch) { struct raw3215_info *raw; - if (!tty) - return 0; raw = (struct raw3215_info *) tty->driver_data; raw3215_putchar(raw, ch); return 1; -- 2.30.1
[PATCH 34/44] tty: do not check tty_unregister_driver's return value
These drivers check tty_unregister_driver return value. But they don't handle a failure correctly (they free the driver in any case). So stop checking tty_unregister_driver return value and remove also the prints. In the next patch, tty_unregister_driver's return type will be switched to void. Signed-off-by: Jiri Slaby Cc: Chris Zankel Cc: Max Filippov Cc: linux-xte...@linux-xtensa.org Cc: Jiri Kosina Cc: David Sterba --- arch/xtensa/platforms/iss/console.c | 6 +- drivers/tty/amiserial.c | 8 ++-- drivers/tty/ipwireless/tty.c| 7 +-- drivers/tty/moxa.c | 4 +--- drivers/tty/serial/kgdb_nmi.c | 4 +--- drivers/tty/synclink_gt.c | 5 + 6 files changed, 7 insertions(+), 27 deletions(-) diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index 1e215cf5ad03..a3dda25a4e45 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -171,11 +171,7 @@ static int __init rs_init(void) static __exit void rs_exit(void) { - int error; - - if ((error = tty_unregister_driver(serial_driver))) - pr_err("ISS_SERIAL: failed to unregister serial driver (%d)\n", - error); + tty_unregister_driver(serial_driver); put_tty_driver(serial_driver); tty_port_destroy(&serial_port); } diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index 18b78ea110ef..0c8157fab17f 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c @@ -1622,21 +1622,17 @@ static int __init amiga_serial_probe(struct platform_device *pdev) static int __exit amiga_serial_remove(struct platform_device *pdev) { - int error; struct serial_state *state = platform_get_drvdata(pdev); /* printk("Unloading %s: version %s\n", serial_name, serial_version); */ - error = tty_unregister_driver(serial_driver); - if (error) - printk("SERIAL: failed to unregister serial driver (%d)\n", - error); + tty_unregister_driver(serial_driver); put_tty_driver(serial_driver); tty_port_destroy(&state->tport); free_irq(IRQ_AMIGA_TBE, state); free_irq(IRQ_AMIGA_RBF, state); - return error; + return 0; } static struct platform_driver amiga_serial_driver = { diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c index 6dacbc5e286c..1836746991b5 100644 --- a/drivers/tty/ipwireless/tty.c +++ b/drivers/tty/ipwireless/tty.c @@ -596,13 +596,8 @@ int ipwireless_tty_init(void) void ipwireless_tty_release(void) { - int ret; - - ret = tty_unregister_driver(ipw_tty_driver); + tty_unregister_driver(ipw_tty_driver); put_tty_driver(ipw_tty_driver); - if (ret != 0) - printk(KERN_ERR IPWIRELESS_PCCARD_NAME - ": tty_unregister_driver failed with code %d\n", ret); } int ipwireless_tty_is_modem(struct ipw_tty *tty) diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c index 9f13f7d49dd7..32eb6b5e510f 100644 --- a/drivers/tty/moxa.c +++ b/drivers/tty/moxa.c @@ -1118,9 +1118,7 @@ static void __exit moxa_exit(void) del_timer_sync(&moxaTimer); - if (tty_unregister_driver(moxaDriver)) - printk(KERN_ERR "Couldn't unregister MOXA Intellio family " - "serial driver\n"); + tty_unregister_driver(moxaDriver); put_tty_driver(moxaDriver); } diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c index 6004c0c1d173..db059b66438e 100644 --- a/drivers/tty/serial/kgdb_nmi.c +++ b/drivers/tty/serial/kgdb_nmi.c @@ -373,9 +373,7 @@ int kgdb_unregister_nmi_console(void) if (ret) return ret; - ret = tty_unregister_driver(kgdb_nmi_tty_driver); - if (ret) - return ret; + tty_unregister_driver(kgdb_nmi_tty_driver); put_tty_driver(kgdb_nmi_tty_driver); return 0; diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index 644173786bf0..4727a41158b0 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -3705,7 +3705,6 @@ static const struct tty_operations ops = { static void slgt_cleanup(void) { - int rc; struct slgt_info *info; struct slgt_info *tmp; @@ -3714,9 +3713,7 @@ static void slgt_cleanup(void) if (serial_driver) { for (info=slgt_device_list ; info != NULL ; info=info->next_device) tty_unregister_device(serial_driver, info->line); - rc = tty_unregister_driver(serial_driver); - if (rc) - DBGERR(("tty_unregister_driver error=%d\n", rc)); + tty_unregister_driver(serial_driver); put_tty_driver(serial_driver); } -- 2.30.1
[PATCH 31/44] tty: xtensa/iss, remove stale comments
These are likely taken over from amiserial. iss doesn't do anything of that. Signed-off-by: Jiri Slaby Cc: Chris Zankel Cc: Max Filippov Cc: linux-xte...@linux-xtensa.org --- arch/xtensa/platforms/iss/console.c | 18 -- 1 file changed, 18 deletions(-) diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index 5d7f9c638437..3b89d9ceb06a 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -37,13 +37,6 @@ static struct timer_list serial_timer; static DEFINE_SPINLOCK(timer_lock); -/* - * This routine is called whenever a serial port is opened. It - * enables interrupts for a serial port, linking in its async structure into - * the IRQ chain. It also performs the serial-specific - * initialization for the tty structure. - */ - static void rs_poll(struct timer_list *); static int rs_open(struct tty_struct *tty, struct file * filp) @@ -58,17 +51,6 @@ static int rs_open(struct tty_struct *tty, struct file * filp) return 0; } - -/* - * - * iss_serial_close() - * - * This routine is called when the serial port gets closed. First, we - * wait for the last remaining data to be sent. Then, we unlink its - * async structure from the interrupt chain if necessary, and we free - * that IRQ if nothing is left in the chain. - * - */ static void rs_close(struct tty_struct *tty, struct file * filp) { spin_lock_bh(&timer_lock); -- 2.30.1
[PATCH 33/44] tty: xtensa/iss, make rs_init static
To fix the warning: warning: no previous prototype for 'rs_init' Signed-off-by: Jiri Slaby Cc: Chris Zankel Cc: Max Filippov Cc: linux-xte...@linux-xtensa.org --- arch/xtensa/platforms/iss/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index 8ea261b8c022..1e215cf5ad03 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -141,7 +141,7 @@ static const struct tty_operations serial_ops = { .proc_show = rs_proc_show, }; -int __init rs_init(void) +static int __init rs_init(void) { tty_port_init(&serial_port); -- 2.30.1
[PATCH 16/44] net: nfc: nci: drop nci_uart_ops::recv_buf
There is noone setting nci_uart_ops::recv_buf, so the default one (nci_uart_default_recv_buf) is always used. So drop this hook, move nci_uart_default_recv_buf before the use in nci_uart_tty_receive and remove unused parameter flags. Signed-off-by: Jiri Slaby Cc: "David S. Miller" Cc: Jakub Kicinski Cc: net...@vger.kernel.org --- include/net/nfc/nci_core.h | 2 - net/nfc/nci/uart.c | 136 ++--- 2 files changed, 67 insertions(+), 71 deletions(-) diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index 43c9c5d2bedb..bd76e8e082c0 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h @@ -430,8 +430,6 @@ struct nci_uart_ops { int (*open)(struct nci_uart *nci_uart); void (*close)(struct nci_uart *nci_uart); int (*recv)(struct nci_uart *nci_uart, struct sk_buff *skb); - int (*recv_buf)(struct nci_uart *nci_uart, const u8 *data, char *flags, - int count); int (*send)(struct nci_uart *nci_uart, struct sk_buff *skb); void (*tx_start)(struct nci_uart *nci_uart); void (*tx_done)(struct nci_uart *nci_uart); diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c index c9987d1cccdf..5cf7d3729d5f 100644 --- a/net/nfc/nci/uart.c +++ b/net/nfc/nci/uart.c @@ -229,6 +229,72 @@ static void nci_uart_tty_wakeup(struct tty_struct *tty) nci_uart_tx_wakeup(nu); } +/* -- Default recv_buf handler -- + * + * This handler supposes that NCI frames are sent over UART link without any + * framing. It reads NCI header, retrieve the packet size and once all packet + * bytes are received it passes it to nci_uart driver for processing. + */ +static int nci_uart_default_recv_buf(struct nci_uart *nu, const u8 *data, +int count) +{ + int chunk_len; + + if (!nu->ndev) { + nfc_err(nu->tty->dev, + "receive data from tty but no NCI dev is attached yet, drop buffer\n"); + return 0; + } + + /* Decode all incoming data in packets +* and enqueue then for processing. +*/ + while (count > 0) { + /* If this is the first data of a packet, allocate a buffer */ + if (!nu->rx_skb) { + nu->rx_packet_len = -1; + nu->rx_skb = nci_skb_alloc(nu->ndev, + NCI_MAX_PACKET_SIZE, + GFP_ATOMIC); + if (!nu->rx_skb) + return -ENOMEM; + } + + /* Eat byte after byte till full packet header is received */ + if (nu->rx_skb->len < NCI_CTRL_HDR_SIZE) { + skb_put_u8(nu->rx_skb, *data++); + --count; + continue; + } + + /* Header was received but packet len was not read */ + if (nu->rx_packet_len < 0) + nu->rx_packet_len = NCI_CTRL_HDR_SIZE + + nci_plen(nu->rx_skb->data); + + /* Compute how many bytes are missing and how many bytes can +* be consumed. +*/ + chunk_len = nu->rx_packet_len - nu->rx_skb->len; + if (count < chunk_len) + chunk_len = count; + skb_put_data(nu->rx_skb, data, chunk_len); + data += chunk_len; + count -= chunk_len; + + /* Chcek if packet is fully received */ + if (nu->rx_packet_len == nu->rx_skb->len) { + /* Pass RX packet to driver */ + if (nu->ops.recv(nu, nu->rx_skb) != 0) + nfc_err(nu->tty->dev, "corrupted RX packet\n"); + /* Next packet will be a new one */ + nu->rx_skb = NULL; + } + } + + return 0; +} + /* nci_uart_tty_receive() * * Called by tty low level driver when receive data is @@ -250,7 +316,7 @@ static void nci_uart_tty_receive(struct tty_struct *tty, const u8 *data, return; spin_lock(&nu->rx_lock); - nu->ops.recv_buf(nu, (void *)data, flags, count); + nci_uart_default_recv_buf(nu, data, count); spin_unlock(&nu->rx_lock); tty_unthrottle(tty); @@ -321,72 +387,6 @@ static int nci_uart_send(struct nci_uart *nu, struct sk_buff *skb) return 0; } -/* -- Default recv_buf handler -- - * - * This handler supposes that NCI frames are sent over UART link without any - * framing. It reads NCI header, retrieve the packet size and once all packet - * bytes are received it passes it to nci_uart driver for processing.
[PATCH 29/44] tty: xtensa/iss, drop serial_version & serial_name
There is no need to print the information during module load. Neither to print some artificial version. So drop these strings and a print. Signed-off-by: Jiri Slaby Cc: Chris Zankel Cc: Max Filippov Cc: linux-xte...@linux-xtensa.org --- arch/xtensa/platforms/iss/console.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index af81a62faba6..1179011044a7 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -37,9 +37,6 @@ static struct timer_list serial_timer; static DEFINE_SPINLOCK(timer_lock); -static char *serial_version = "0.1"; -static char *serial_name = "ISS serial driver"; - /* * This routine is called whenever a serial port is opened. It * enables interrupts for a serial port, linking in its async structure into @@ -149,7 +146,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout) static int rs_proc_show(struct seq_file *m, void *v) { - seq_printf(m, "serinfo:1.0 driver:%s\n", serial_version); + seq_printf(m, "serinfo:1.0 driver:0.1\n"); return 0; } @@ -172,8 +169,6 @@ int __init rs_init(void) serial_driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES); - pr_info("%s %s\n", serial_name, serial_version); - /* Initialize the tty_driver structure */ serial_driver->driver_name = "iss_serial"; -- 2.30.1
[PATCH 23/44] tty: nozomi, remove init/exit messages
Remove useless prints from init and exit functions. The version is artificial anyway. Signed-off-by: Jiri Slaby --- drivers/tty/nozomi.c | 9 + 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index 83490925a3e2..1ec975d66528 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c @@ -47,9 +47,6 @@ #include - -#define VERSION_STRING DRIVER_DESC " 2.1d" - /* Default debug printout level */ #define NOZOMI_DEBUG_LEVEL 0x00 static int debug = NOZOMI_DEBUG_LEVEL; @@ -89,7 +86,6 @@ do { \ /*Defines */ #define NOZOMI_NAME"nozomi" #define NOZOMI_NAME_TTY"nozomi_tty" -#define DRIVER_DESC"Nozomi driver" #define NTTY_TTY_MAXMINORS 256 #define NTTY_FIFO_BUFFER_SIZE 8192 @@ -1841,8 +1837,6 @@ static __init int nozomi_init(void) { int ret; - printk(KERN_INFO "Initializing %s\n", VERSION_STRING); - ntty_driver = alloc_tty_driver(NTTY_TTY_MAXMINORS); if (!ntty_driver) return -ENOMEM; @@ -1882,7 +1876,6 @@ static __init int nozomi_init(void) static __exit void nozomi_exit(void) { - printk(KERN_INFO "Unloading %s\n", DRIVER_DESC); pci_unregister_driver(&nozomi_driver); tty_unregister_driver(ntty_driver); put_tty_driver(ntty_driver); @@ -1892,4 +1885,4 @@ module_init(nozomi_init); module_exit(nozomi_exit); MODULE_LICENSE("Dual BSD/GPL"); -MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_DESCRIPTION("Nozomi driver"); -- 2.30.1
[PATCH 21/44] tty: jsm_tty, make char+error handling readable
The code for char+error handling in jsm_input was complete mess of letters. Introduce 3 new local variables and use them with care. Signed-off-by: Jiri Slaby --- drivers/tty/serial/jsm/jsm_tty.c | 24 ++-- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c index 512b77195e9f..8e42a7682c63 100644 --- a/drivers/tty/serial/jsm/jsm_tty.c +++ b/drivers/tty/serial/jsm/jsm_tty.c @@ -603,18 +603,22 @@ void jsm_input(struct jsm_channel *ch) if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { for (i = 0; i < s; i++) { + u8 chr = ch->ch_rqueue[tail + i]; + u8 error = ch->ch_equeue[tail + i]; + char flag = TTY_NORMAL; + /* -* Give the Linux ld the flags in the -* format it likes. +* Give the Linux ld the flags in the format it +* likes. */ - if (*(ch->ch_equeue + tail + i) & UART_LSR_BI) - tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_BREAK); - else if (*(ch->ch_equeue +tail +i) & UART_LSR_PE) - tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_PARITY); - else if (*(ch->ch_equeue +tail +i) & UART_LSR_FE) - tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_FRAME); - else - tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_NORMAL); + if (error & UART_LSR_BI) + flag = TTY_BREAK; + else if (error & UART_LSR_PE) + flag = TTY_PARITY; + else if (error & UART_LSR_FE) + flag = TTY_FRAME; + + tty_insert_flip_char(port, chr, flag); } } else { tty_insert_flip_string(port, ch->ch_rqueue + tail, s); -- 2.30.1
[PATCH 18/44] tty: con3215, remove tasklet for tty_wakeup
tty_wakeup is safe to be called from all contexts. No need to schedule a tasklet for that. Let us call it directly like in other drivers. And delete the tasklet completely. Signed-off-by: Jiri Slaby Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: linux...@de.ibm.com Cc: linux-s...@vger.kernel.org --- drivers/s390/char/con3215.c | 20 +--- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 671efee612af..5923a1f133ef 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c @@ -85,7 +85,6 @@ struct raw3215_info { int written; /* number of bytes in write requests */ struct raw3215_req *queued_read; /* pointer to queued read requests */ struct raw3215_req *queued_write;/* pointer to queued write requests */ - struct tasklet_struct tlet; /* tasklet to invoke tty_wakeup */ wait_queue_head_t empty_wait; /* wait queue for flushing */ struct timer_list timer; /* timer for delayed output */ int line_pos; /* position on the line (for tabs) */ @@ -329,21 +328,6 @@ static inline void raw3215_try_io(struct raw3215_info *raw) } } -/* - * Call tty_wakeup from tasklet context - */ -static void raw3215_wakeup(unsigned long data) -{ - struct raw3215_info *raw = (struct raw3215_info *) data; - struct tty_struct *tty; - - tty = tty_port_tty_get(&raw->port); - if (tty) { - tty_wakeup(tty); - tty_kref_put(tty); - } -} - /* * Try to start the next IO and wake up processes waiting on the tty. */ @@ -352,7 +336,7 @@ static void raw3215_next_io(struct raw3215_info *raw, struct tty_struct *tty) raw3215_mk_write_req(raw); raw3215_try_io(raw); if (tty && RAW3215_BUFFER_SIZE - raw->count >= RAW3215_MIN_SPACE) - tasklet_schedule(&raw->tlet); + tty_wakeup(tty); } /* @@ -644,7 +628,6 @@ static struct raw3215_info *raw3215_alloc_info(void) timer_setup(&info->timer, raw3215_timeout, 0); init_waitqueue_head(&info->empty_wait); - tasklet_init(&info->tlet, raw3215_wakeup, (unsigned long)info); tty_port_init(&info->port); return info; @@ -936,7 +919,6 @@ static void tty3215_close(struct tty_struct *tty, struct file * filp) tty->closing = 1; /* Shutdown the terminal */ raw3215_shutdown(raw); - tasklet_kill(&raw->tlet); tty->closing = 0; tty_port_tty_set(&raw->port, NULL); } -- 2.30.1
[PATCH 15/44] net: nfc: nci: remove memset of nci_uart_drivers
nci_uart_drivers is a global definition, so there is no need to initialize its memory to zero during module load. Signed-off-by: Jiri Slaby Cc: "David S. Miller" Cc: Jakub Kicinski Cc: net...@vger.kernel.org --- net/nfc/nci/uart.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c index 16d009c9b6a0..c9987d1cccdf 100644 --- a/net/nfc/nci/uart.c +++ b/net/nfc/nci/uart.c @@ -468,7 +468,6 @@ static struct tty_ldisc_ops nci_uart_ldisc = { static int __init nci_uart_init(void) { - memset(nci_uart_drivers, 0, sizeof(nci_uart_drivers)); return tty_register_ldisc(N_NCI, &nci_uart_ldisc); } -- 2.30.1
[PATCH 06/44] tty: isicom, remove this orphan
The Isicom driver was orphaned by commit d86b3001a1a6 (MAINTAINERS: orphan isicom) 10 years ago. Noone stepped up to take care of them and to fix all the issues the driver has. So it's time to drop the driver with all its traces. Signed-off-by: Jiri Slaby --- Documentation/admin-guide/devices.txt |2 +- Documentation/process/magic-number.rst|1 - .../it_IT/process/magic-number.rst|1 - .../zh_CN/process/magic-number.rst|1 - MAINTAINERS |5 - drivers/tty/Kconfig | 10 - drivers/tty/Makefile |1 - drivers/tty/isicom.c | 1699 - include/linux/isicom.h| 85 - 9 files changed, 1 insertion(+), 1804 deletions(-) delete mode 100644 drivers/tty/isicom.c delete mode 100644 include/linux/isicom.h diff --git a/Documentation/admin-guide/devices.txt b/Documentation/admin-guide/devices.txt index b5bd9d46e031..ef41f77cb979 100644 --- a/Documentation/admin-guide/devices.txt +++ b/Documentation/admin-guide/devices.txt @@ -289,7 +289,7 @@ 152 = /dev/kpollKernel Poll Driver 153 = /dev/mergemem Memory merge device 154 = /dev/pmu Macintosh PowerBook power manager - 155 = /dev/isictl MultiTech ISICom serial control + 155 = 156 = /dev/lcd Front panel LCD display 157 = /dev/ac Applicom Intl Profibus card 158 = /dev/nwbutton Netwinder external button diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst index d4a30c09bd03..c36f21eecefb 100644 --- a/Documentation/process/magic-number.rst +++ b/Documentation/process/magic-number.rst @@ -77,7 +77,6 @@ DB_MAGIC 0x4442 fc_info ``drivers/net/ip DL_MAGIC 0x444d fc_info ``drivers/net/iph5526_novram.c`` FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h`` FF_MAGIC 0x4646 fc_info ``drivers/net/iph5526_novram.c`` -ISICOM_MAGIC 0x4d54 isi_port ``include/linux/isicom.h`` PTY_MAGIC 0x5001 ``drivers/char/pty.c`` PPP_MAGIC 0x5002 ppp ``include/linux/if_pppvar.h`` SSTATE_MAGIC 0x5302 serial_state ``include/linux/serial.h`` diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst index 0df2e7e32cd8..440087f9f402 100644 --- a/Documentation/translations/it_IT/process/magic-number.rst +++ b/Documentation/translations/it_IT/process/magic-number.rst @@ -83,7 +83,6 @@ DB_MAGIC 0x4442 fc_info ``drivers/net/ip DL_MAGIC 0x444d fc_info ``drivers/net/iph5526_novram.c`` FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h`` FF_MAGIC 0x4646 fc_info ``drivers/net/iph5526_novram.c`` -ISICOM_MAGIC 0x4d54 isi_port ``include/linux/isicom.h`` PTY_MAGIC 0x5001 ``drivers/char/pty.c`` PPP_MAGIC 0x5002 ppp ``include/linux/if_pppvar.h`` SSTATE_MAGIC 0x5302 serial_state ``include/linux/serial.h`` diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst index 82d62f6a4406..e91bec4ec156 100644 --- a/Documentation/translations/zh_CN/process/magic-number.rst +++ b/Documentation/translations/zh_CN/process/magic-number.rst @@ -66,7 +66,6 @@ DB_MAGIC 0x4442 fc_info ``drivers/net/ip DL_MAGIC 0x444d fc_info ``drivers/net/iph5526_novram.c`` FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h`` FF_MAGIC 0x4646 fc_info ``drivers/net/iph5526_novram.c`` -ISICOM_MAGIC 0x4d54 isi_port ``include/linux/isicom.h`` PTY_MAGIC 0x5001 ``drivers/char/pty.c`` PPP_MAGIC 0x5002 ppp ``include/linux/if_pppvar.h`` SSTATE_MAGIC 0x5302 serial_state ``include/linux/serial.h`` diff --git a/MAINTAINERS b/MAINTAINERS index fd45767da24c..549145c5fb0b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12225,11 +12225,6 @@ F: drivers/mux/ F: include/dt-bindings/mux/ F: include/linux/mux/ -MULTITECH MULTIPORT
[PATCH 14/44] net: caif: inline register_ldisc
register_ldisc only calls tty_register_ldisc. Inline register_ldisc into the only caller of register_ldisc, i.e. caif_ser_init. Now, caif_ser_init is symmetric to caif_ser_exit in this regard. Signed-off-by: Jiri Slaby Cc: "David S. Miller" Cc: Jakub Kicinski Cc: net...@vger.kernel.org --- drivers/net/caif/caif_serial.c | 17 - 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c index 675c374b32ee..da6fffb4d5a8 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c @@ -389,18 +389,6 @@ static struct tty_ldisc_ops caif_ldisc = { .write_wakeup = ldisc_tx_wakeup }; -static int register_ldisc(void) -{ - int result; - - result = tty_register_ldisc(N_CAIF, &caif_ldisc); - if (result < 0) { - pr_err("cannot register CAIF ldisc=%d err=%d\n", N_CAIF, - result); - return result; - } - return result; -} static const struct net_device_ops netdev_ops = { .ndo_open = caif_net_open, .ndo_stop = caif_net_close, @@ -443,7 +431,10 @@ static int __init caif_ser_init(void) { int ret; - ret = register_ldisc(); + ret = tty_register_ldisc(N_CAIF, &caif_ldisc); + if (ret < 0) + pr_err("cannot register CAIF ldisc=%d err=%d\n", N_CAIF, ret); + debugfsdir = debugfs_create_dir("caif_serial", NULL); return ret; } -- 2.30.1
[PATCH 08/44] tty: remove TTY_LDISC_MAGIC
First, it is never checked. Second, use of it as a debugging aid is at least questionable. With the current tools, I don't think anyone used this kind of thing for debugging purposes for years. On the top of that, e.g. serdev does not set this field of tty_ldisc_ops at all. So get rid of this legacy. Signed-off-by: Jiri Slaby --- Documentation/process/magic-number.rst| 1 - Documentation/translations/it_IT/process/magic-number.rst | 1 - Documentation/translations/zh_CN/process/magic-number.rst | 1 - drivers/accessibility/speakup/spk_ttyio.c | 1 - drivers/bluetooth/hci_ldisc.c | 1 - drivers/misc/ti-st/st_core.c | 1 - drivers/net/caif/caif_serial.c| 1 - drivers/net/can/slcan.c | 1 - drivers/net/hamradio/6pack.c | 1 - drivers/net/hamradio/mkiss.c | 1 - drivers/net/ppp/ppp_async.c | 1 - drivers/net/ppp/ppp_synctty.c | 1 - drivers/net/slip/slip.c | 1 - drivers/pps/clients/pps-ldisc.c | 3 --- drivers/tty/n_gsm.c | 1 - drivers/tty/n_hdlc.c | 1 - drivers/tty/n_null.c | 1 - drivers/tty/n_r3964.c | 1 - drivers/tty/n_tty.c | 1 - include/linux/tty_ldisc.h | 3 --- net/nfc/nci/uart.c| 1 - sound/soc/codecs/cx20442.c| 1 - sound/soc/ti/ams-delta.c | 1 - 23 files changed, 27 deletions(-) diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst index 89992fe4863f..f5ba36e96461 100644 --- a/Documentation/process/magic-number.rst +++ b/Documentation/process/magic-number.rst @@ -88,7 +88,6 @@ TTY_MAGIC 0x5401 tty_struct ``include/linux/ MGSL_MAGIC0x5401 mgsl_info ``drivers/char/synclink.c`` TTY_DRIVER_MAGIC 0x5402 tty_driver ``include/linux/tty_driver.h`` MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c`` -TTY_LDISC_MAGIC 0x5403 tty_ldisc ``include/linux/tty_ldisc.h`` USB_SERIAL_MAGIC 0x6702 usb_serial ``drivers/usb/serial/usb-serial.h`` FULL_DUPLEX_MAGIC 0x6969 ``drivers/net/ethernet/dec/tulip/de2104x.c`` USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth ``drivers/usb/class/bluetty.c`` diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst index 9be170ec0d02..e8c782d155a3 100644 --- a/Documentation/translations/it_IT/process/magic-number.rst +++ b/Documentation/translations/it_IT/process/magic-number.rst @@ -94,7 +94,6 @@ TTY_MAGIC 0x5401 tty_struct ``include/linux/ MGSL_MAGIC0x5401 mgsl_info ``drivers/char/synclink.c`` TTY_DRIVER_MAGIC 0x5402 tty_driver ``include/linux/tty_driver.h`` MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c`` -TTY_LDISC_MAGIC 0x5403 tty_ldisc ``include/linux/tty_ldisc.h`` USB_SERIAL_MAGIC 0x6702 usb_serial ``drivers/usb/serial/usb-serial.h`` FULL_DUPLEX_MAGIC 0x6969 ``drivers/net/ethernet/dec/tulip/de2104x.c`` USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth ``drivers/usb/class/bluetty.c`` diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst index 191d705349ef..42f0635ca70a 100644 --- a/Documentation/translations/zh_CN/process/magic-number.rst +++ b/Documentation/translations/zh_CN/process/magic-number.rst @@ -77,7 +77,6 @@ TTY_MAGIC 0x5401 tty_struct ``include/linux/ MGSL_MAGIC0x5401 mgsl_info ``drivers/char/synclink.c`` TTY_DRIVER_MAGIC 0x5402 tty_driver ``include/linux/tty_driver.h`` MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c`` -TTY_LDISC_MAGIC 0x5403 tty_ldisc ``include/linux/tty_ldisc.h`` USB_SERIAL_MAGIC 0x6702 usb_serial ``drivers/usb/serial/usb-serial.h`` FULL_DUPLEX_MAGIC 0x6969 ``drivers/net/ethernet/dec/
[PATCH 12/44] tty: 8250, cleanup em485 timers
Initialize the variables directly by initializers in definitions. This is expected/usual for these kind of callback. Signed-off-by: Jiri Slaby --- drivers/tty/serial/8250/8250_port.c | 18 -- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 167c1e3e53bc..9019f8f626bb 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1466,13 +1466,11 @@ EXPORT_SYMBOL_GPL(serial8250_em485_stop_tx); static enum hrtimer_restart serial8250_em485_handle_stop_tx(struct hrtimer *t) { - struct uart_8250_em485 *em485; - struct uart_8250_port *p; + struct uart_8250_em485 *em485 = container_of(t, struct uart_8250_em485, + stop_tx_timer); + struct uart_8250_port *p = em485->port; unsigned long flags; - em485 = container_of(t, struct uart_8250_em485, stop_tx_timer); - p = em485->port; - serial8250_rpm_get(p); spin_lock_irqsave(&p->port.lock, flags); if (em485->active_timer == &em485->stop_tx_timer) { @@ -1482,6 +1480,7 @@ static enum hrtimer_restart serial8250_em485_handle_stop_tx(struct hrtimer *t) } spin_unlock_irqrestore(&p->port.lock, flags); serial8250_rpm_put(p); + return HRTIMER_NORESTART; } @@ -1629,19 +1628,18 @@ static inline void start_tx_rs485(struct uart_port *port) static enum hrtimer_restart serial8250_em485_handle_start_tx(struct hrtimer *t) { - struct uart_8250_em485 *em485; - struct uart_8250_port *p; + struct uart_8250_em485 *em485 = container_of(t, struct uart_8250_em485, + start_tx_timer); + struct uart_8250_port *p = em485->port; unsigned long flags; - em485 = container_of(t, struct uart_8250_em485, start_tx_timer); - p = em485->port; - spin_lock_irqsave(&p->port.lock, flags); if (em485->active_timer == &em485->start_tx_timer) { __start_tx(&p->port); em485->active_timer = NULL; } spin_unlock_irqrestore(&p->port.lock, flags); + return HRTIMER_NORESTART; } -- 2.30.1
[PATCH 11/44] tty: 8250, use ms_to_ktime
This really eliminates multiplications from the assembly. I would have thought they are optimized by inlining ktime_set, but not on x86_64 with gcc 10. Signed-off-by: Jiri Slaby --- drivers/tty/serial/8250/8250_port.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index b0af13074cd3..167c1e3e53bc 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1487,11 +1487,7 @@ static enum hrtimer_restart serial8250_em485_handle_stop_tx(struct hrtimer *t) static void start_hrtimer_ms(struct hrtimer *hrt, unsigned long msec) { - long sec = msec / 1000; - long nsec = (msec % 1000) * 100; - ktime_t t = ktime_set(sec, nsec); - - hrtimer_start(hrt, t, HRTIMER_MODE_REL); + hrtimer_start(hrt, ms_to_ktime(msec), HRTIMER_MODE_REL); } static void __stop_tx_rs485(struct uart_8250_port *p) -- 2.30.1
[PATCH 13/44] tty: 8250/serial_cs, propagate errors in simple_config
The caller expects from the others (pfc_config and multi_config) to return standard error values. So do the same for simple_config too. We invert the if condition to handle the error case. Signed-off-by: Jiri Slaby --- drivers/tty/serial/8250/serial_cs.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/8250/serial_cs.c b/drivers/tty/serial/8250/serial_cs.c index 35ff6627c61b..63ea9c4da3d5 100644 --- a/drivers/tty/serial/8250/serial_cs.c +++ b/drivers/tty/serial/8250/serial_cs.c @@ -456,11 +456,11 @@ static int simple_config(struct pcmcia_device *link) * its base address, then try to grab any standard serial port * address, and finally try to get any free port. */ - if (!pcmcia_loop_config(link, simple_config_check_notpicky, NULL)) - goto found_port; - - dev_warn(&link->dev, "no usable port range found, giving up\n"); - return -1; + ret = pcmcia_loop_config(link, simple_config_check_notpicky, NULL); + if (ret) { + dev_warn(&link->dev, "no usable port range found, giving up\n"); + return ret; + } found_port: if (info->multi && (info->manfid == MANFID_3COM)) @@ -474,7 +474,7 @@ static int simple_config(struct pcmcia_device *link) ret = pcmcia_enable_device(link); if (ret != 0) - return -1; + return ret; return setup_serial(link, info, link->resource[0]->start, link->irq); } -- 2.30.1
[PATCH 09/44] tty: n_tty, set tty_ldisc_ops::owner
Set tty_ldisc_ops::owner to THIS_MODULE. This has no effect currently as n_tty cannot be built as a module. If someone ever tries to modularize tty, we wouldn't manage module's reference count as in other ldiscs. So fix this just in case. Signed-off-by: Jiri Slaby --- drivers/tty/n_tty.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 7c53185bce57..a6f3c5c148eb 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -2488,6 +2488,7 @@ static int n_tty_ioctl(struct tty_struct *tty, struct file *file, } static struct tty_ldisc_ops n_tty_ops = { + .owner = THIS_MODULE, .name= "n_tty", .open= n_tty_open, .close = n_tty_close, -- 2.30.1
[PATCH 10/44] tty: imx, use ms_to_ktime
This really eliminates multiplications from the assembly. I would have thought they are optimized by inlining ktime_set, but not on x86_64 with gcc 10. Signed-off-by: Jiri Slaby Cc: Shawn Guo Cc: Sascha Hauer Cc: Pengutronix Kernel Team Cc: Fabio Estevam Cc: NXP Linux Team --- drivers/tty/serial/imx.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 8257597d034d..3f69356937ef 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -394,11 +394,7 @@ static void imx_uart_rts_inactive(struct imx_port *sport, u32 *ucr2) static void start_hrtimer_ms(struct hrtimer *hrt, unsigned long msec) { - long sec = msec / MSEC_PER_SEC; - long nsec = (msec % MSEC_PER_SEC) * 100; - ktime_t t = ktime_set(sec, nsec); - - hrtimer_start(hrt, t, HRTIMER_MODE_REL); + hrtimer_start(hrt, ms_to_ktime(msec), HRTIMER_MODE_REL); } /* called with port.lock taken and irqs off */ -- 2.30.1
[PATCH 03/44] PCI: remove synclink entries from pci_ids
The drivers were removed in a1f714b44e34 (tty: Remove redundant synclink driver) and 3d608a591b2b (tty: Remove redundant synclinkmp driver). So remove also the PCI ID entries. Signed-off-by: Jiri Slaby Cc: Bjorn Helgaas Cc: linux-...@vger.kernel.org --- include/linux/pci_ids.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index a76ccb697bef..8a18517696c1 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -2065,8 +2065,6 @@ #define PCI_DEVICE_ID_EXAR_XR17V3580x0358 #define PCI_VENDOR_ID_MICROGATE0x13c0 -#define PCI_DEVICE_ID_MICROGATE_USC0x0010 -#define PCI_DEVICE_ID_MICROGATE_SCA0x0030 #define PCI_VENDOR_ID_3WARE0x13C1 #define PCI_DEVICE_ID_3WARE_1000 0x1000 -- 2.30.1
[PATCH 01/44] MAINTAINERS: orphan mxser
I cannot maintain this driver for years due to missing HW. Let's orphan the entry in MAINTAINERS. And likely drop the driver later as these devices are likely gone from this world. Mxser provides different (out-of-tree) drivers for their current devices. Signed-off-by: Jiri Slaby --- MAINTAINERS | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 973a937386fa..24abc010d177 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12089,8 +12089,7 @@ F: drivers/media/pci/meye/ F: include/uapi/linux/meye.h MOXA SMARTIO/INDUSTIO/INTELLIO SERIAL CARD -M: Jiri Slaby -S: Maintained +S: Orphan F: Documentation/driver-api/serial/moxa-smartio.rst F: drivers/tty/mxser.* -- 2.30.1
[PATCH 04/44] vgacon: comment on vga_rolled_over
Long time ago, I figured out what this number is good for and documented that locally. But never submitted, so do it now. Signed-off-by: Jiri Slaby Cc: dri-de...@lists.freedesktop.org Cc: linux-fb...@vger.kernel.org --- drivers/video/console/vgacon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 962c12be9774..0d26e821e73b 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -96,7 +96,7 @@ static bool vga_is_gfx; static boolvga_512_chars; static int vga_video_font_height; static int vga_scan_lines __read_mostly; -static unsigned intvga_rolled_over; +static unsigned intvga_rolled_over; /* last vc_origin offset before wrap */ static bool vgacon_text_mode_force; static bool vga_hardscroll_enabled; -- 2.30.1
[PATCH 02/44] MAINTAINERS: drop cyclades.com reference
cyclades.com is a dead domain. Signed-off-by: Jiri Slaby --- MAINTAINERS | 1 - 1 file changed, 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 24abc010d177..7bfca0e2d5ab 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4885,7 +4885,6 @@ F:include/uapi/linux/cyclades.h CYCLADES PC300 DRIVER S: Orphan -W: http://www.cyclades.com/ F: drivers/net/wan/pc300* CYPRESS_FIRMWARE MEDIA DRIVER -- 2.30.1
Re: Linux 5.11.2
On 26. 02. 21, 12:37, Jörg-Volker Peetz wrote: Jörg-Volker Peetz wrote on 26/02/2021 12.33: Greg KH wrote on 26/02/2021 12.02: On Fri, Feb 26, 2021 at 11:54:07AM +0100, Jörg-Volker Peetz wrote: Hi, thanks for the upgrade. There seems to be a dangling link in the git repository: `scripts/dtc/include-prefixes/c6x` Is that new? What commit caused it? I think it was a removal, commit 584ce3c9b408a89f, which forgot the link. Introduced in 5.11.2. Should be: introduced after 5.11.2. IMO, it would be this commit: commit a579fcfa8e49cc77ad59211bb18bc5004133e6a0 Author: Arnd Bergmann Date: Mon Jan 18 12:45:46 2021 +0100 c6x: remove architecture targetting 5.12-rc1. So unrelated to 5.11.2 at all, right? thanks, -- js suse labs
Re: [PATCH 17/20] vt: Manual replacement of the deprecated strlcpy() with return values
On 22. 02. 21, 16:12, Romain Perier wrote: The strlcpy() reads the entire source buffer first, it is dangerous if the source buffer lenght is unbounded or possibility non NULL-terminated. "length" and it's NUL, not NULL in this case. It can lead to linear read overflows, crashes, etc... As recommended in the deprecated interfaces [1], it should be replaced by strscpy. This commit replaces all calls to strlcpy that handle the return values s/that/which/ ? "handles" "value" by the corresponding strscpy calls with new handling of the return values (as it is quite different between the two functions). Sorry, I have hard times understand the whole sentence. Could you rephrase a bit? [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy Signed-off-by: Romain Perier --- drivers/tty/vt/keyboard.c |5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index 77638629c562..5e20c6c307e0 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c @@ -2067,9 +2067,12 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) return -ENOMEM; spin_lock_irqsave(&func_buf_lock, flags); - len = strlcpy(kbs, func_table[kb_func] ? : "", len); + len = strscpy(kbs, func_table[kb_func] ? : "", len); func_table[kb_func] is NUL-terminated and kbs is of length len anyway, so this is only cosmetical. spin_unlock_irqrestore(&func_buf_lock, flags); + if (len == -E2BIG) + return -E2BIG; + This can never happen, right? ret = copy_to_user(user_kdgkb->kb_string, kbs, len + 1) ? -EFAULT : 0; thanks, -- js
[PATCH] media: atomisp: do not free kmalloc memory by vfree
fw_minibuffer[i].buffer is allocated by kmalloc in sh_css_load_blob_info and by vmalloc in setup_binary. So use kvfree to decide which of those allocators to use for freeing. Also remove the useless cast. Signed-off-by: Jiri Slaby Cc: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/sh_css_firmware.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c b/drivers/staging/media/atomisp/pci/sh_css_firmware.c index db25e39bea88..f4ce8ace9d50 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c +++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c @@ -366,7 +366,7 @@ void sh_css_unload_firmware(void) if (fw_minibuffer[i].name) kfree((void *)fw_minibuffer[i].name); if (fw_minibuffer[i].buffer) - vfree((void *)fw_minibuffer[i].buffer); + kvfree(fw_minibuffer[i].buffer); } kfree(fw_minibuffer); fw_minibuffer = NULL; -- 2.30.1
Re: [PATCH v3 2/2] serial: 8250: Add new 8250-core based Broadcom STB driver
On 12. 02. 21, 20:57, Al Cooper wrote: Add a UART driver for the new Broadcom 8250 based STB UART. The new UART is backward compatible with the standard 8250, but has some additional features. The new features include a high accuracy baud rate clock system and DMA support. The driver will use the new optional BAUD MUX clock to select the best one of the four master clocks (81MHz, 108MHz, 64MHz and 48MHz) to feed the baud rate selection logic for any requested baud rate. This allows for more accurate BAUD rates when high speed baud rates are selected. ... --- /dev/null +++ b/drivers/tty/serial/8250/8250_bcm7271.c ... +static void brcmuart_rx_isr(struct uart_port *up, u32 rx_isr) +{ + struct brcmuart_priv *priv = up->private_data; + struct device *dev = up->dev; + u32 rx_done_isr; + u32 check_isr; + char seq_err[] = "RX buffer ready out of sequence, restarting RX DMA\n"; What's the purpose of this on-stack variable? +static void init_real_clk_rates(struct device *dev, struct brcmuart_priv *priv) +{ + int x; + int rc; + + priv->default_mux_rate = clk_get_rate(priv->baud_mux_clk); + dev_dbg(dev, "Default BAUD MUX Clock rate is %lu\n", + priv->default_mux_rate); + + for (x = 0; x < ARRAY_SIZE(priv->real_rates); x++) { + if (priv->rate_table[x] == 0) { + priv->real_rates[x] = 0; + continue; + } + rc = clk_set_rate(priv->baud_mux_clk, priv->rate_table[x]); + if (rc) { + dev_err(dev, "Error selecting BAUD MUX clock for %u\n", + priv->rate_table[x]); + priv->real_rates[x] = priv->rate_table[x]; + } else { + priv->real_rates[x] = clk_get_rate(priv->baud_mux_clk); + } + } +clk_set_rate(priv->baud_mux_clk, priv->default_mux_rate); This is only weirdly indented. +} + +static void set_clock_mux(struct uart_port *up, struct brcmuart_priv *priv, + u32 baud) +{ + u32 percent; + u32 best_percent = UINT_MAX; + u32 quot; + u32 best_quot = 1; + u32 rate; + int best_index = -1; + u64 hires_rate; + u64 hires_baud; + u64 hires_err; + int rc; + int i; + int real_baud; + + /* If the Baud Mux Clock was not specified, just return */ + if (priv->baud_mux_clk == NULL) + return; + + /* Find the closest match for specified baud */ + for (i = 0; i < ARRAY_SIZE(priv->real_rates); i++) { + if (priv->real_rates[i] == 0) + continue; + rate = priv->real_rates[i] / 16; + quot = DIV_ROUND_CLOSEST(rate, baud); + if (!quot) + continue; + + /* increase resolution to get xx.xx percent */ + hires_rate = (u64)rate * 1; + hires_baud = (u64)baud * 1; + + hires_err = div_u64(hires_rate, (u64)quot); + + /* get the delta */ + if (hires_err > hires_baud) + hires_err = (hires_err - hires_baud); + else + hires_err = (hires_baud - hires_err); + + percent = (unsigned long)DIV_ROUND_CLOSEST_ULL(hires_err, baud); + dev_dbg(up->dev, + "Baud rate: %u, MUX Clk: %u, Error: %u.%u%%\n", + baud, priv->real_rates[i], percent / 100, + percent % 100); + if (percent < best_percent) { + best_percent = percent; + best_index = i; + best_quot = quot; + } + } + if (best_index == -1) { + dev_err(up->dev, "Error, %d BAUD rate is too fast.\n", baud); + return; + } + rate = priv->real_rates[best_index]; + rc = clk_set_rate(priv->baud_mux_clk, rate); + if (rc) + dev_err(up->dev, "Error selecting BAUD MUX clock\n"); + + /* Error over 3 percent will cause data errors */ + if (best_percent > 300) + dev_err(up->dev, "Error, baud: %d has %u.%u%% error\n", + baud, percent / 100, percent % 100); + + real_baud = rate / 16 / best_quot; + dev_dbg(up->dev, "Selecting BAUD MUX rate: %u\n", rate); + dev_dbg(up->dev, "Requested baud: %u, Actual baud: %u\n", + baud, real_baud); + + /* calc nanoseconds for 1.5 characters time at the given baud rate */ + i = 10 / real_baud / 10; NSEC_PER_SEC here? + i += (i / 2); + priv->char_wait = ns_to_ktime(i); + + up->uartclk = rate; +} ... +static int __maybe_unused brcmuart_resume(struct device *dev) +{ + struct brcmuart_priv *priv = dev_get_drvdata(dev); + int ret; +
Re: [PATCH v2] tty: fix when iov_iter_count() returns 0 in tty_write()
On 17. 02. 21, 16:55, Sabyrzhan Tasbolatov wrote: syzbot found WARNING in iov_iter_revert[1] when iov_iter_count() returns 0, therefore INT_MAX is passed to iov_iter_revert() causing > MAX_RW_COUNT warning. static inline ssize_t do_tty_write() { .. size_t count = iov_iter_count(from); .. size_t size = count; if (ret != size) iov_iter_revert(from, size-ret); [1] WARNING: lib/iov_iter.c:1090 Call Trace: do_tty_write drivers/tty/tty_io.c:967 [inline] file_tty_write.constprop.0+0x55f/0x8f0 drivers/tty/tty_io.c:1048 call_write_iter include/linux/fs.h:1901 [inline] new_sync_write+0x426/0x650 fs/read_write.c:518 vfs_write+0x791/0xa30 fs/read_write.c:605 ksys_write+0x12d/0x250 fs/read_write.c:658 Fixes: 9bb48c82aced ("tty: implement write_iter") Reported-by: syzbot+3d2c27c2b7dc2a948...@syzkaller.appspotmail.com Signed-off-by: Sabyrzhan Tasbolatov --- v2: Fixed "Fixed" tag to proper commit and changed write return to -EFAULT as this statement is valid, tested via strace: write(3, NULL, 0) = -1 EFAULT (Bad address) Updated to -EFAULT, should be a valid exit code as copy_from_iter(.., .., from) returns -EFAULT as well if *from is invalid address. Exactly, EFAULT is for invalid memory accesses. But this should be IMO EINVAL as it's an invalid argument. BTW what's the reason vfs calls ->write with zero count of iter? Nit, you need a ' ' before your '(' character here, otherwise the linux-next scripts will complain. Also, you got the git commit id wrong, so this needs to be fixed up anyway. You are pointing to a merge point, I doubt that's what you want to point to here, right? Thanks! --- drivers/tty/tty_io.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 816e709afa56..e1460cad8b7d 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -905,6 +905,9 @@ static inline ssize_t do_tty_write( ssize_t ret, written = 0; unsigned int chunk; + if (!count) + return -EFAULT; + ret = tty_write_lock(tty, file->f_flags & O_NDELAY); if (ret < 0) return ret; -- js
[PATCH v2] perf tools: Resolve symbols against debug file first
With LTO, there are symbols like these: /usr/lib/debug/usr/lib64/libantlr4-runtime.so.4.8-4.8-1.4.x86_64.debug 10305: 00955fa4 0 NOTYPE LOCAL DEFAULT 29 Predicate.cpp.2bc410e7 This comes from a runtime/debug split done by the standard way: objcopy --only-keep-debug $runtime $debug objcopy --add-gnu-debuglink=$debugfn -R .comment -R .GCC.command.line --strip-all $runtime perf currently cannot resolve such symbols (relicts of LTO), as section 29 exists only in the debug file (29 is .debug_info). And perf resolves symbols only against runtime file. This results in all symbols from such a library being unresolved: 0.38% main2libantlr4-runtime.so.4.8 [.] 0x000671e0 So try resolving against the debug file first. And only if it fails (the section has NOBITS set), try runtime file. We can do this, as "objcopy --only-keep-debug" per documentation preserves all sections, but clears data of some of them (the runtime ones) and marks them as NOBITS. The correct result is now: 0.38% main2libantlr4-runtime.so.4.8 [.] antlr4::IntStream::~IntStream Note that these LTO symbols are properly skipped anyway as they belong neither to *text* nor to *data* (is_label && !elf_sec__filter(&shdr, secstrs) is true). Signed-off-by: Jiri Slaby Acked-by: Namhyung Kim Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Mark Rutland Cc: Alexander Shishkin Cc: Jiri Olsa --- [v2] added a comment tools/perf/util/symbol-elf.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index f3577f7d72fe..ecc05aa8399d 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1226,12 +1226,26 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, if (sym.st_shndx == SHN_ABS) continue; - sec = elf_getscn(runtime_ss->elf, sym.st_shndx); + sec = elf_getscn(syms_ss->elf, sym.st_shndx); if (!sec) goto out_elf_end; gelf_getshdr(sec, &shdr); + /* +* We have to fallback to runtime when syms' section header has +* NOBITS set. NOBITS results in file offset (sh_offset) not +* being incremented. So sh_offset used below has different +* values for syms (invalid) and runtime (valid). +*/ + if (shdr.sh_type == SHT_NOBITS) { + sec = elf_getscn(runtime_ss->elf, sym.st_shndx); + if (!sec) + goto out_elf_end; + + gelf_getshdr(sec, &shdr); + } + if (is_label && !elf_sec__filter(&shdr, secstrs)) continue; -- 2.30.1
Re: Kernel version numbers after 4.9.255 and 4.4.255
On 04. 02. 21, 9:51, Greg Kroah-Hartman wrote: It might work somewhere, but there are a lot of (X * 65536 + Y * 256 + Z) assumptions all around the world. So this doesn't look like a good idea. Ok, so what happens if we "wrap"? What will break with that? At first glance, I can't see anything as we keep the padding the same, and our build scripts seem to pick the number up from the Makefile and treat it like a string. It's only the crazy out-of-tree kernel stuff that wants to do minor version checks that might go boom. And frankly, I'm not all that concerned if they have problems :) Agreed. But currently, sublevel won't "wrap", it will "overflow" to patchlevel. And that might be a problem. So we might need to update the header generation using e.g. "sublevel & 0xff" (wrap around) or "sublevel > 255 : 255 : sublevel" (be monotonic and get stuck at 255). In both LINUX_VERSION_CODE generation and KERNEL_VERSION proper. thanks, -- js
Re: Kernel version numbers after 4.9.255 and 4.4.255
On 04. 02. 21, 7:20, Greg Kroah-Hartman wrote: On Thu, Feb 04, 2021 at 05:59:42AM +, Jari Ruusu wrote: Greg, I hope that your linux kernel release scripts are implemented in a way that understands that PATCHLEVEL= and SUBLEVEL= numbers in top-level linux Makefile are encoded as 8-bit numbers for LINUX_VERSION_CODE and KERNEL_VERSION() macros, and must stay in range 0...255. These 8-bit limits are hardcoded in both kernel source and userspace ABI. After 4.9.255 and 4.4.255, your scripts should be incrementing a number in EXTRAVERSION= in top-level linux Makefile. Should already be fixed in linux-next, right? I assume you mean: commit 537896fabed11f8d976d1aacdb977213c7b3 Author: Sasha Levin Date: Mon Jan 18 14:54:53 2021 -0500 kbuild: give the SUBLEVEL more room in KERNEL_VERSION That would IMO break userspace as definition of kernel version has changed. And that one is UAPI/ABI (see include/generated/uapi/linux/version.h) as Jari writes. For example will glibc still work: http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/configure.ac;h=13abda0a51484c5951ffc6d718aa36b72f3a9429;hb=HEAD#l14 ? Or gcc 10 (11 will have this differently): https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/bpf/bpf.c;hb=ee5c3db6c5b2c3332912fb4c9cfa2864569ebd9a#l165 and https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/bpf/bpf-helpers.h;hb=ee5c3db6c5b2c3332912fb4c9cfa2864569ebd9a#l53 It might work somewhere, but there are a lot of (X * 65536 + Y * 256 + Z) assumptions all around the world. So this doesn't look like a good idea. thanks, -- js suse labs
Re: [PATCH 1/3] serial: 8250: Handle UART without interrupt on TEMT using em485
On 29. 01. 21, 0:36, Eric Tremblay wrote: The patch introduce the UART_CAP_TEMT capability which is by default assigned to all 8250 UART since the code assume that device has the interrupt on TEMT In the case where the device does not support it, we calculate the maximum of time it could take for the transmitter to empty the shift register. When we get in the situation where we get the THRE interrupt but the TEMT bit is not set we start the timer and recall __stop_tx after the delay Signed-off-by: Eric Tremblay --- drivers/tty/serial/8250/8250.h| 1 + drivers/tty/serial/8250/8250_bcm2835aux.c | 2 +- drivers/tty/serial/8250/8250_omap.c | 2 +- drivers/tty/serial/8250/8250_port.c | 89 ++- include/linux/serial_8250.h | 2 + 5 files changed, 93 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index 52bb21205bb6..5361b761eed7 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h @@ -82,6 +82,7 @@ struct serial8250_config { #define UART_CAP_MINI (1 << 17) /* Mini UART on BCM283X family lacks: * STOP PARITY EPAR SPAR WLEN5 WLEN6 */ +#define UART_CAP_TEMT (1 << 18) /* UART have interrupt on TEMT */ What about the inversion _NOTEMT? You then set it only on uarts without TEMT and don't need to update every single driver. diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c index fd95860cd661..354faebce885 100644 --- a/drivers/tty/serial/8250/8250_bcm2835aux.c +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c @@ -91,7 +91,7 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev) return -ENOMEM; /* initialize data */ - up.capabilities = UART_CAP_FIFO | UART_CAP_MINI; + data->uart.capabilities = UART_CAP_FIFO | UART_CAP_MINI | UART_CAP_TEMT; This change looks weird and undocumented. Why do you set data->uart suddenly? Actually, does this build? up.port.dev = &pdev->dev; up.port.regshift = 2; up.port.type = PORT_16550; diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index 23e0decde33e..1c21ac68ff37 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -1294,7 +1294,7 @@ static int omap8250_probe(struct platform_device *pdev) up.port.regshift = 2; up.port.fifosize = 64; up.tx_loadsz = 64; - up.capabilities = UART_CAP_FIFO; + up.capabilities = UART_CAP_FIFO | UART_CAP_TEMT; #ifdef CONFIG_PM /* * Runtime PM is mostly transparent. However to do it right we need to a diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index b0af13074cd3..44a54406e4b4 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -558,8 +558,41 @@ static void serial8250_clear_fifos(struct uart_8250_port *p) } } +static inline void serial8250_em485_update_temt_delay(struct uart_8250_port *p, + unsigned int cflag, unsigned int baud) +{ + unsigned int bits; + + if (!p->em485) + return; + + /* byte size and parity */ + switch (cflag & CSIZE) { + case CS5: + bits = 7; + break; + case CS6: + bits = 8; + break; + case CS7: + bits = 9; + break; + default: + bits = 10; + break; /* CS8 */ + } + + if (cflag & CSTOPB) + bits++; + if (cflag & PARENB) + bits++; + + p->em485->no_temt_delay = bits*100/baud; +} + static enum hrtimer_restart serial8250_em485_handle_start_tx(struct hrtimer *t); static enum hrtimer_restart serial8250_em485_handle_stop_tx(struct hrtimer *t); +static enum hrtimer_restart serial8250_em485_handle_no_temt(struct hrtimer *t); void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p) { @@ -618,6 +651,18 @@ static int serial8250_em485_init(struct uart_8250_port *p) HRTIMER_MODE_REL); hrtimer_init(&p->em485->start_tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + + if (!(p->capabilities & UART_CAP_TEMT)) { + struct tty_struct *tty = p->port.state->port.tty; Is this safe? Don't you need a tty reference? Or maybe you need to pass the tty from the TIOCSRS485 ioctl to here. + serial8250_em485_update_temt_delay(p, tty->termios.c_cflag, + tty_get_baud_rate(tty)); + hrtimer_init(&p->em485->no_temt_timer, CLOCK_MONOTONIC, +HRTIMER_MODE_REL); + p->em485->no_temt_timer.function = + &ser
Re: [PATCH] perf tools: Resolve symbols against debug file first
On 13. 01. 21, 11:46, Jiri Olsa wrote: On Wed, Jan 13, 2021 at 09:01:28AM +0100, Jiri Slaby wrote: With LTO, there are symbols like these: /usr/lib/debug/usr/lib64/libantlr4-runtime.so.4.8-4.8-1.4.x86_64.debug 10305: 00955fa4 0 NOTYPE LOCAL DEFAULT 29 Predicate.cpp.2bc410e7 This comes from a runtime/debug split done by the standard way: objcopy --only-keep-debug $runtime $debug objcopy --add-gnu-debuglink=$debugfn -R .comment -R .GCC.command.line --strip-all $runtime perf currently cannot resolve such symbols (relicts of LTO), as section 29 exists only in the debug file (29 is .debug_info). And perf resolves symbols only against runtime file. This results in all symbols from such a library being unresolved: 0.38% main2libantlr4-runtime.so.4.8 [.] 0x000671e0 So try resolving against the debug file first. And only if it fails (the section has NOBITS set), try runtime file. We can do this, as "objcopy --only-keep-debug" per documentation preserves all sections, but clears data of some of them (the runtime ones) and marks them as NOBITS. The correct result is now: 0.38% main2libantlr4-runtime.so.4.8 [.] antlr4::IntStream::~IntStream Note that these LTO symbols are properly skipped anyway as they belong neither to *text* nor to *data* (is_label && !elf_sec__filter(&shdr, secstrs) is true). Signed-off-by: Jiri Slaby Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Mark Rutland Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim --- tools/perf/util/symbol-elf.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index f3577f7d72fe..a31b716fa61c 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1226,12 +1226,20 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, if (sym.st_shndx == SHN_ABS) continue; - sec = elf_getscn(runtime_ss->elf, sym.st_shndx); + sec = elf_getscn(syms_ss->elf, sym.st_shndx); if (!sec) goto out_elf_end; we iterate symbols from syms_ss, so the fix seems to be correct to call elf_getscn on syms_ss, not on runtime_ss as we do now I'd think this worked only when runtime_ss == syms_ss gelf_getshdr(sec, &shdr); + if (shdr.sh_type == SHT_NOBITS) { + sec = elf_getscn(runtime_ss->elf, sym.st_shndx); + if (!sec) + goto out_elf_end; + + gelf_getshdr(sec, &shdr); + } is that fallback necessary? the symbol is from syms_ss To resume this and answer: Yes, the fallback is necessary. It's because syms_ss section header has NOBITS set for the sections, so file offset is not incremented. So shdr.sh_offset (the file offset) used further in dso__load_sym has different values for syms and runtime. The syms_ss (the NOBITS) one is invalid as it has 0x1000 here. The runtime one contains good values (like 000509d0 here): .text 00082560 000509d0 000509d0 [-1000-] {+000509d0+} 2**4 That is, without the fallback, the computed symbol address is wrong. thanks, -- js suse labs
Re: [PATCH 1/6] tty: implement write_iter
On 21. 01. 21, 19:42, Linus Torvalds wrote: On Thu, Jan 21, 2021 at 9:57 AM Greg Kroah-Hartman wrote: Incremental patches please as these are already in my public branches and I would have to revert them and add new ones but that's messy, so fixes on top is fine. Ok. And since I think you put that first tty_write conversion patch in a different branch from the tty_read one, I did the fixup patches for the two as separate patches, even though they really just do the exact same thing. So here's three patches: the two fixups for the hung_up_tty case, and the EOVERFLOW error case that Jiri also noted. I've also updated the 'tty-splice' branch if you prefer them that way. And I *should* say that I still haven't tested _any_ of the HDLC changes. I have no idea how to do that, and if somebody can point to a test-case (or better yet, actually has a real life situation where they use it and can test this all) it would be great. Jiri, any other issues, or any comment of yours I missed? I didn't do the min() thing, I find the explicit conditional more legible myself, but won't complain if somebody else then disagrees and wants to clean it up. I cannot find anything else. All three: Reviewed-by: Jiri Slaby thanks, -- js
Re: [PATCH 1/6] tty: implement write_iter
On 21. 01. 21, 22:09, Linus Torvalds wrote: On Thu, Jan 21, 2021 at 11:43 AM Greg Kroah-Hartman wrote: This works, thanks for these. I'll wait for Jiri to review them before applying them to my branches... Let's hope Jiri sees them, since he had some email issue earlier.. I'll add his suse address here too. Thanks, I am fixed and nothing was lost :). -- js suse labs
Re: [PATCH 2/6] tty: convert tty_ldisc_ops 'read()' function to take a kernel pointer
On 21. 01. 21, 10:00, Greg Kroah-Hartman wrote: From: Linus Torvalds The tty line discipline .read() function was passed the final user pointer destination as an argument, which doesn't match the 'write()' function, and makes it very inconvenient to do a splice method for ttys. This is a conversion to use a kernel buffer instead. NOTE! It does this by passing the tty line discipline ->read() function an additional "cookie" to fill in, and an offset into the cookie data. The line discipline can fill in the cookie data with its own private information, and then the reader will repeat the read until either the cookie is cleared or it runs out of data. The only real user of this is N_HDLC, which can use this to handle big packets, even if the kernel buffer is smaller than the whole packet. Cc: Christoph Hellwig Cc: Greg Kroah-Hartman Cc: Al Viro Signed-off-by: Linus Torvalds ... --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -833,6 +833,65 @@ static void tty_update_time(struct timespec64 *time) time->tv_sec = sec; } +/* + * Iterate on the ldisc ->read() function until we've gotten all + * the data the ldisc has for us. + * + * The "cookie" is something that the ldisc read function can fill + * in to let us know that there is more data to be had. + * + * We promise to continue to call the ldisc until it stops returning + * data or clears the cookie. The cookie may be something that the + * ldisc maintains state for and needs to free. + */ +static int iterate_tty_read(struct tty_ldisc *ld, struct tty_struct *tty, struct file *file, + char __user *buf, size_t count) +{ + int retval = 0; + void *cookie = NULL; + unsigned long offset = 0; + char kernel_buf[64]; + + do { + int size, uncopied; + + size = count > sizeof(kernel_buf) ? sizeof(kernel_buf) : count; Or simply size = min(count, sizeof(kernel_buf)); + size = ld->ops->read(tty, file, kernel_buf, size, &cookie, offset); + if (!size) + break; + + /* +* A ldisc read error return will override any previously copied +* data (eg -EOVERFLOW from HDLC) +*/ + if (size < 0) { + memzero_explicit(kernel_buf, sizeof(kernel_buf)); + return size; + } + + uncopied = copy_to_user(buf+offset, kernel_buf, size); + size -= uncopied; + offset += size; + count -= size; + + /* +* If the user copy failed, we still need to do another ->read() +* call if we had a cookie to let the ldisc clear up. +* +* But make sure size is zeroed. +*/ + if (unlikely(uncopied)) { + count = 0; + retval = -EFAULT; n_hdlc_tty_read will return EOVERFLOW when size is 0, so this EFAULT is never propagated, if I am looking correctly? n_tty seems to be fine (returns zero for zeroed size). + } + } while (cookie); + + /* We always clear tty buffer in case they contained passwords */ + memzero_explicit(kernel_buf, sizeof(kernel_buf)); + return offset ? offset : retval; +} thanks, -- js
Re: [PATCH 3/6] tty: implement read_iter
On 21. 01. 21, 10:00, Greg Kroah-Hartman wrote: From: Linus Torvalds Now that the ldisc read() function takes kernel pointers, it's fairly straightforward to make the tty file operations use .read_iter() instead of .read(). That automatically gives us vread() and friends, and also makes it possible to do .splice_read() on ttys again. Fixes: 36e2c7421f02 ("fs: don't allow splice read/write without explicit ops") Reported-by: Oliver Giles Cc: Christoph Hellwig Cc: Greg Kroah-Hartman Cc: Al Viro Signed-off-by: Linus Torvalds --- drivers/tty/tty_io.c | 36 ++-- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index a34f8bcf875e..8846d3b99845 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c ... @@ -907,10 +909,10 @@ static int iterate_tty_read(struct tty_ldisc *ld, struct tty_struct *tty, struct *read calls may be outstanding in parallel. */ -static ssize_t tty_read(struct file *file, char __user *buf, size_t count, - loff_t *ppos) +static ssize_t tty_read(struct kiocb *iocb, struct iov_iter *to) { int i; + struct file *file = iocb->ki_filp; struct inode *inode = file_inode(file); struct tty_struct *tty = file_tty(file); struct tty_ldisc *ld; @@ -923,11 +925,9 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count, /* We want to wait for the line discipline to sort out in this situation */ ld = tty_ldisc_ref_wait(tty); - if (!ld) - return hung_up_tty_read(file, buf, count, ppos); i = -EIO; - if (ld->ops->read) - i = iterate_tty_read(ld, tty, file, buf, count); + if (ld && ld->ops->read) + i = iterate_tty_read(ld, tty, file, to); tty_ldisc_deref(ld); Here we have the same problem as in tty_write. And also the other one with hung_up_tty_read not converted. thanks, -- js
Re: [PATCH 1/6] tty: implement write_iter
On 21. 01. 21, 10:00, Greg Kroah-Hartman wrote: From: Linus Torvalds This makes the tty layer use the .write_iter() function instead of the traditional .write() functionality. That allows writev(), but more importantly also makes it possible to enable .splice_write() for ttys, reinstating the "splice to tty" functionality that was lost in commit 36e2c7421f02 ("fs: don't allow splice read/write without explicit ops"). Fixes: 36e2c7421f02 ("fs: don't allow splice read/write without explicit ops") Reported-by: Oliver Giles Cc: Christoph Hellwig Cc: Greg Kroah-Hartman Cc: Al Viro Signed-off-by: Linus Torvalds --- drivers/tty/tty_io.c | 48 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 56ade99ef99f..338bc4ef5549 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -143,9 +143,8 @@ LIST_HEAD(tty_drivers); /* linked list of tty drivers */ DEFINE_MUTEX(tty_mutex); static ssize_t tty_read(struct file *, char __user *, size_t, loff_t *); -static ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *); -ssize_t redirected_tty_write(struct file *, const char __user *, - size_t, loff_t *); +static ssize_t tty_write(struct kiocb *, struct iov_iter *); +ssize_t redirected_tty_write(struct kiocb *, struct iov_iter *); static __poll_t tty_poll(struct file *, poll_table *); static int tty_open(struct inode *, struct file *); long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg); @@ -478,7 +477,8 @@ static void tty_show_fdinfo(struct seq_file *m, struct file *file) static const struct file_operations tty_fops = { .llseek = no_llseek, .read = tty_read, - .write = tty_write, + .write_iter = tty_write, + .splice_write = iter_file_splice_write, .poll = tty_poll, .unlocked_ioctl = tty_ioctl, .compat_ioctl = tty_compat_ioctl, @@ -491,7 +491,8 @@ static const struct file_operations tty_fops = { static const struct file_operations console_fops = { .llseek = no_llseek, .read = tty_read, - .write = redirected_tty_write, + .write_iter = redirected_tty_write, + .splice_write = iter_file_splice_write, .poll = tty_poll, .unlocked_ioctl = tty_ioctl, .compat_ioctl = tty_compat_ioctl, @@ -607,9 +608,9 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session) /* This breaks for file handles being sent over AF_UNIX sockets ? */ list_for_each_entry(priv, &tty->tty_files, list) { filp = priv->file; - if (filp->f_op->write == redirected_tty_write) + if (filp->f_op->write_iter == redirected_tty_write) cons_filp = filp; - if (filp->f_op->write != tty_write) + if (filp->f_op->write_iter != tty_write) This now relies on implicit value of hung_up_tty_fops.write_iter (i.e. NULL), okay. continue; closecount++; __tty_fasync(-1, filp, 0); /* can't block */ >filp->f_op = &hung_up_tty_fops; Isn't this racy with VFS layer in vfs_write: if (file->f_op->write) ret = file->f_op->write(file, buf, count, pos); else if (file->f_op->write_iter) ret = new_sync_write(file, buf, count, pos); ? hung_up_tty_fops do not set iter_write and tty_fops do not set write. When we switch from one to the other here, right after the 'if', but before the call, what happens? Likely nothing for the ->write case immediately as compilers cache the value, but for ->write_iter, I'm not sure. Anyway, this looks broken to me. (Read on.) @@ -956,14 +957,20 @@ static inline ssize_t do_tty_write( size_t size = count; if (size > chunk) size = chunk; + ret = -EFAULT; - if (copy_from_user(tty->write_buf, buf, size)) + if (copy_from_iter(tty->write_buf, size, from) != size) break; + ret = write(tty, file, tty->write_buf, size); if (ret <= 0) break; + + /* FIXME! Have Al check this! */ + if (ret != size) + iov_iter_revert(from, size-ret); + written += ret; - buf += ret; count -= ret; if (!count) break; @@ -1023,9 +1030,9 @@ void tty_write_message(struct tty_struct *tty, char *msg) *write method will not be invoked in parallel for each device. */ -static ssize_t tty_write(struct file *file, const char __user *buf, -
Re: tty splice branch (was "Re: Splicing to/from a tty")
On 21. 01. 21, 9:50, Jiri Slaby wrote: Hm, I would like to review this first. I noticed the changes only because a new branch appeared when I grabbed your tree and the branch has "tty" in its name. Which is weird as you Cced me. Let me check what is wrong with my e-mail setup. thanks, -- js
Re: tty splice branch (was "Re: Splicing to/from a tty")
On 21. 01. 21, 2:18, Linus Torvalds wrote: On Tue, Jan 19, 2021 at 8:44 PM Linus Torvalds wrote: I'll come back to this tomorrow and do the line-buffered icanon case too (unless pull requests pile up), and then I'll be happy with the tty changes, and I think I can submit this series for real to Greg. Greg, I don't know how you want to handle this. I have a branch with my tty splice patches at git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git tty-splice and that now includes doing that "cookie continuation" thing even for the N_TTY icanon modes. It passes my local tests, and I did try a few rather odd things. And Oliver tested an ealier version without that final commit on his load. But... Hm, I would like to review this first. I noticed the changes only because a new branch appeared when I grabbed your tree and the branch has "tty" in its name. So for example: @@ -1038,18 +1045,15 @@ static ssize_t tty_write(struct file *file, const char __user *buf, if (tty->ops->write_room == NULL) tty_err(tty, "missing write_room method\n"); ld = tty_ldisc_ref_wait(tty); - if (!ld) - return hung_up_tty_write(file, buf, count, ppos); - if (!ld->ops->write) + if (!ld || !ld->ops->write) ret = -EIO; else - ret = do_tty_write(ld->ops->write, tty, file, buf, count); + ret = do_tty_write(ld->ops->write, tty, file, from); tty_ldisc_deref(ld); if ld == NULL => crash here. So can you send the patches to the list and Cc me too? return ret; } thanks, -- js
Re: [PATCH 3/3] tty: vcc: Drop impossible to hit WARN_ON
On 14. 01. 21, 18:57, Uwe Kleine-König wrote: vcc_get() returns the port that has provided port->index. As the port that is about to be removed isn't removed yet this trivially will find this port. So simplify the call to not assign an identical value to the port pointer and drop the warning that is never hit. Signed-off-by: Uwe Kleine-König Reviewed-by: Jiri Slaby --- drivers/tty/vcc.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c index d9b0dc6deae9..e2d6205f83ce 100644 --- a/drivers/tty/vcc.c +++ b/drivers/tty/vcc.c @@ -692,12 +692,9 @@ static int vcc_remove(struct vio_dev *vdev) tty_vhangup(port->tty); /* Get exclusive reference to VCC, ensures that there are no other -* clients to this port +* clients to this port. This cannot fail. */ - port = vcc_get(port->index, true); - - if (WARN_ON(!port)) - return -ENODEV; + vcc_get(port->index, true); tty_unregister_device(vcc_tty_driver, port->index); -- js
Re: [PATCH 2/3] tty: vcc: Drop unnecessary if block
On 14. 01. 21, 18:57, Uwe Kleine-König wrote: If vcc_probe() succeeded dev_set_drvdata() is called with a non-NULL value, and if vcc_probe() failed vcc_remove() isn't called. So there is no way dev_get_drvdata() can return NULL in vcc_remove() and the check can just go away. Signed-off-by: Uwe Kleine-König Reviewed-by: Jiri Slaby --- drivers/tty/vcc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c index 9ffd42e333b8..d9b0dc6deae9 100644 --- a/drivers/tty/vcc.c +++ b/drivers/tty/vcc.c @@ -681,9 +681,6 @@ static int vcc_remove(struct vio_dev *vdev) { struct vcc_port *port = dev_get_drvdata(&vdev->dev); - if (!port) - return -ENODEV; - del_timer_sync(&port->rx_timer); del_timer_sync(&port->tx_timer); -- js
Re: [PATCH 1/3] tty: hvcs: Drop unnecessary if block
On 14. 01. 21, 18:57, Uwe Kleine-König wrote: If hvcs_probe() succeeded dev_set_drvdata() is called with a non-NULL value, and if hvcs_probe() failed hvcs_remove() isn't called. So there is no way dev_get_drvdata() can return NULL in hvcs_remove() and the check can just go away. Signed-off-by: Uwe Kleine-König Reviewed-by: Jiri Slaby --- drivers/tty/hvc/hvcs.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index 509d1042825a..3e0461285c34 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c @@ -825,9 +825,6 @@ static int hvcs_remove(struct vio_dev *dev) unsigned long flags; struct tty_struct *tty; - if (!hvcsd) - return -ENODEV; - /* By this time the vty-server won't be getting any more interrupts */ spin_lock_irqsave(&hvcsd->lock, flags); -- js
Re: [PATCH] perf tools: Resolve symbols against debug file first
On 13. 01. 21, 11:46, Jiri Olsa wrote: On Wed, Jan 13, 2021 at 09:01:28AM +0100, Jiri Slaby wrote: With LTO, there are symbols like these: /usr/lib/debug/usr/lib64/libantlr4-runtime.so.4.8-4.8-1.4.x86_64.debug 10305: 00955fa4 0 NOTYPE LOCAL DEFAULT 29 Predicate.cpp.2bc410e7 This comes from a runtime/debug split done by the standard way: objcopy --only-keep-debug $runtime $debug objcopy --add-gnu-debuglink=$debugfn -R .comment -R .GCC.command.line --strip-all $runtime perf currently cannot resolve such symbols (relicts of LTO), as section 29 exists only in the debug file (29 is .debug_info). And perf resolves symbols only against runtime file. This results in all symbols from such a library being unresolved: 0.38% main2libantlr4-runtime.so.4.8 [.] 0x000671e0 So try resolving against the debug file first. And only if it fails (the section has NOBITS set), try runtime file. We can do this, as "objcopy --only-keep-debug" per documentation preserves all sections, but clears data of some of them (the runtime ones) and marks them as NOBITS. The correct result is now: 0.38% main2libantlr4-runtime.so.4.8 [.] antlr4::IntStream::~IntStream Note that these LTO symbols are properly skipped anyway as they belong neither to *text* nor to *data* (is_label && !elf_sec__filter(&shdr, secstrs) is true). Signed-off-by: Jiri Slaby Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Mark Rutland Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim --- tools/perf/util/symbol-elf.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index f3577f7d72fe..a31b716fa61c 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1226,12 +1226,20 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, if (sym.st_shndx == SHN_ABS) continue; - sec = elf_getscn(runtime_ss->elf, sym.st_shndx); + sec = elf_getscn(syms_ss->elf, sym.st_shndx); if (!sec) goto out_elf_end; we iterate symbols from syms_ss, so the fix seems to be correct to call elf_getscn on syms_ss, not on runtime_ss as we do now I'd think this worked only when runtime_ss == syms_ss No, because the headers are copied 1:1 from runtime_ss to syms_ss. And runtime_ss is then stripped, so only .debug* sections are removed there. (And syms_ss's are set as NOBITS.) We iterated .debug* sections in syms_ss and used runtime_ss section _headers_ only to adjust symbols (sometimes). That worked. gelf_getshdr(sec, &shdr); + if (shdr.sh_type == SHT_NOBITS) { + sec = elf_getscn(runtime_ss->elf, sym.st_shndx); + if (!sec) + goto out_elf_end; + + gelf_getshdr(sec, &shdr); + } is that fallback necessary? the symbol is from syms_ss Provided the above, we don't need the section data here, only headers, so the NOBITS test is superfluous and the fallback shouldn't be needed. Let me test it. thanks, -- js suse labs
[PATCH] perf tools: Resolve symbols against debug file first
With LTO, there are symbols like these: /usr/lib/debug/usr/lib64/libantlr4-runtime.so.4.8-4.8-1.4.x86_64.debug 10305: 00955fa4 0 NOTYPE LOCAL DEFAULT 29 Predicate.cpp.2bc410e7 This comes from a runtime/debug split done by the standard way: objcopy --only-keep-debug $runtime $debug objcopy --add-gnu-debuglink=$debugfn -R .comment -R .GCC.command.line --strip-all $runtime perf currently cannot resolve such symbols (relicts of LTO), as section 29 exists only in the debug file (29 is .debug_info). And perf resolves symbols only against runtime file. This results in all symbols from such a library being unresolved: 0.38% main2libantlr4-runtime.so.4.8 [.] 0x000671e0 So try resolving against the debug file first. And only if it fails (the section has NOBITS set), try runtime file. We can do this, as "objcopy --only-keep-debug" per documentation preserves all sections, but clears data of some of them (the runtime ones) and marks them as NOBITS. The correct result is now: 0.38% main2libantlr4-runtime.so.4.8 [.] antlr4::IntStream::~IntStream Note that these LTO symbols are properly skipped anyway as they belong neither to *text* nor to *data* (is_label && !elf_sec__filter(&shdr, secstrs) is true). Signed-off-by: Jiri Slaby Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Mark Rutland Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim --- tools/perf/util/symbol-elf.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index f3577f7d72fe..a31b716fa61c 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1226,12 +1226,20 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, if (sym.st_shndx == SHN_ABS) continue; - sec = elf_getscn(runtime_ss->elf, sym.st_shndx); + sec = elf_getscn(syms_ss->elf, sym.st_shndx); if (!sec) goto out_elf_end; gelf_getshdr(sec, &shdr); + if (shdr.sh_type == SHT_NOBITS) { + sec = elf_getscn(runtime_ss->elf, sym.st_shndx); + if (!sec) + goto out_elf_end; + + gelf_getshdr(sec, &shdr); + } + if (is_label && !elf_sec__filter(&shdr, secstrs)) continue; -- 2.30.0
Re: [PATCH v2 4/8] serial: stm32: add author
On 06. 01. 21, 17:21, Erwan Le Ray wrote: Update email address add new author in authors list. Parsing error :). Signed-off-by: Erwan Le Ray diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 717a97759928..938d2c4aeaed 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -3,7 +3,8 @@ * Copyright (C) Maxime Coquelin 2015 * Copyright (C) STMicroelectronics SA 2017 * Authors: Maxime Coquelin - * Gerald Baeza + * Gerald Baeza + * Erwan Le Ray * * Inspired by st-asc.c from STMicroelectronics (c) */ -- js suse labs
Re: [PATCH v2 2/8] serial: stm32: fix code cleaning warnings and checks
On 06. 01. 21, 17:21, Erwan Le Ray wrote: --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c ... @@ -973,18 +971,17 @@ static int stm32_init_port(struct stm32_port *stm32port, struct resource *res; int ret; + ret = platform_get_irq(pdev, 0); + if (ret <= 0) + return ret ? : -ENODEV; + port->iotype = UPIO_MEM; port->flags = UPF_BOOT_AUTOCONF; port->ops= &stm32_uart_ops; port->dev= &pdev->dev; port->fifosize = stm32port->info->cfg.fifosize; port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_STM32_CONSOLE); - - ret = platform_get_irq(pdev, 0); - if (ret <= 0) - return ret ? : -ENODEV; port->irq = ret; I would move this set from ret above too. Or introduce a new variable, e.g. "irq". thanks, -- js suse labs
perf does not resolve plt symbols from libstdc++ right (.plt.sec problem)
Hi, this e-mails is a follow-up of my report at: https://bugzilla.suse.com/show_bug.cgi?id=1180681 There is a problem with *@plt symbols in some libraries, they are unresolved by perf (memcmp@plt in this case): > 0.26% main2/usr/lib64/libstdc++.so.6.0.280xa51a0 l [.] 0x000a51a0 On the other hand, plt symbols in other libraries are fine (memset@plt in this case): > 0.17% main2/usr/lib64/libantlr4-runtime.so.4.8 0x4ed10 l [.] memset@plt I dumped memcmp's .plt.rela entries in perf: /usr/lib64/libantlr4-runtime.so.4.8: 154th addr=4e9d0 plt_off=4e020 hdr=10 entry=10 /usr/lib64/libstdc++.so.6.0.28: 772th addr=a1070 plt_off=9e020 hdr=10 entry=10 The difference (offset) of stdc++'s memcmp is 0xa51a0 (correct) - 0xa1070 (perf's computed) = 0x4130. The problem is perf assumes nth entry of .plt.rela to correspond to nth function in .plt, but memcmp is in .plt.sec in libstdc++.so: > Relocation section '.rela.plt' at offset 0x97900 contains 1018 entries: > Offset Info Type Symbol's Value Symbol's Name + Addend > ... > 001dc838 00780007 R_X86_64_JUMP_SLOT memcmp@GLIBC_2.2.5 + 0 Perf does this with the rela entries: https://github.com/torvalds/linux/blob/f5e6c330254ae691f6d7befe61c786eb5056007e/tools/perf/util/symbol-elf.c#L385 It takes a symbol index from sym.r_info. Then it resolves its name from .dynsym, appending "@plt" to it. Then this name is added to perf's symbol table along with address which is computed as .rela.plt index multiplied by entry size (shdr_plt.sh_entsize) plus plt header (shdr_plt.sh_entsize on x86_64 too). And from this comes (almost) the offset above: > $ objdump -h /usr/lib64/libstdc++.so.6|grep -E ' .plt(\.sec)? ' > 12 .plt 3fb0 0009e020 0009e020 0009e020 2**4 > 14 .plt.sec 3fa0 000a2160 000a2160 000a2160 2**4 0xa2160-0x9e020 = 0x4140. I assume the 0x10 difference is that perf adds shdr_plt.sh_entsize (0x10) to the offset to skip the first .plt entry (header). Richard writes: == .plt.sec is IIRC the "second" (sec) PLT entry - the one that will be used on the second call (and on). This is used / emitted for ELF object instrumented for Intel CET. The details escape me for the moment but I hope the x86 ABI documents this (and the constraints) in detail. == How should perf find out whether to consider .plt or .plt.sec? Or generally, how to properly find an address of *@plt symbols like memcmp@plt above? thanks, -- js suse labs
Re: [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger
On 07. 01. 21, 19:16, Cristian Ciocaltea wrote: Hi Greg, Thank you for the review! On Thu, Jan 07, 2021 at 04:20:55PM +0100, Greg Kroah-Hartman wrote: On Tue, Jan 05, 2021 at 07:02:02PM +0200, Cristian Ciocaltea wrote: Implement 'poll_put_char' and 'poll_get_char' callbacks in struct 'owl_uart_ops' that enables OWL UART to be used for kernel debugging over serial line. Signed-off-by: Cristian Ciocaltea [...] + +static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch) +{ + while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU) + cpu_relax(); Unbounded loops? What could possibly go wrong? :( Please don't do that in the kernel, put a max bound on this. I didn't realize the issue since I had encountered this pattern in many other serial drivers, as well: altera_uart, arc_uart, atmel_serial, etc. And are you _SURE_ that cpu_relax() is what you want to call here? I'm thinking of replacing the loop with 'readl_poll_timeout_atomic()', if that would be a better approach. It might be better, yes. Either way, if you add a bound to the loop, you definitely need a more precise timing, so ndelay/udelay instead of cpu_relax. thanks, -- js
[PATCH 06/12] 8250_tegra: clean up tegra_uart_handle_break
* switch "do { A; } while (1)" to "while (1) { A; }" * switch "if (A) B; else break;" to "if (!A) break; B;" * remove unused assignment from p->serial_in() to status Objdump -d shows no difference. Signed-off-by: Jiri Slaby Cc: Thierry Reding Cc: Jonathan Hunter --- drivers/tty/serial/8250/8250_tegra.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/8250/8250_tegra.c b/drivers/tty/serial/8250/8250_tegra.c index c0ffad1572c6..e13ae18b0713 100644 --- a/drivers/tty/serial/8250/8250_tegra.c +++ b/drivers/tty/serial/8250/8250_tegra.c @@ -26,16 +26,17 @@ static void tegra_uart_handle_break(struct uart_port *p) { unsigned int status, tmout = 1; - do { + while (1) { status = p->serial_in(p, UART_LSR); - if (status & (UART_LSR_FIFOE | UART_LSR_BRK_ERROR_BITS)) - status = p->serial_in(p, UART_RX); - else + if (!(status & (UART_LSR_FIFOE | UART_LSR_BRK_ERROR_BITS))) break; + + p->serial_in(p, UART_RX); + if (--tmout == 0) break; udelay(1); - } while (1); + } } static int tegra_uart_probe(struct platform_device *pdev) -- 2.30.0
[PATCH 10/12] tty: cpm_uart, use port->flags instead of low_latency
This is the only in-kernel user of tty_port::low_latency. Switch this last one to test uport->flags directly as tty_port::low_latency is going away in the next patch. Signed-off-by: Jiri Slaby --- drivers/tty/serial/cpm_uart/cpm_uart_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c index 3b899cc7e362..58aaa533203b 100644 --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c @@ -499,8 +499,7 @@ static void cpm_uart_set_termios(struct uart_port *port, pr_debug("CPM uart[%d]:set_termios\n", port->line); baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); - if (baud < HW_BUF_SPD_THRESHOLD || - (pinfo->port.state && pinfo->port.state->port.low_latency)) + if (baud < HW_BUF_SPD_THRESHOLD || port->flags & UPF_LOW_LATENCY) pinfo->rx_fifosize = 1; else pinfo->rx_fifosize = RX_BUF_SIZE; -- 2.30.0
[PATCH 12/12] tty: drop termiox user definitions
As was concluded in a follow-up discussion of commit e0efb3168d34 (tty: Remove dead termiox code) [1], termiox ioctls never worked, so there is barely anyone using this interface. We can safely remove the user definitions for this never adopted interface. [1] https://lore.kernel.org/lkml/c1c9fc04-02eb-2260-195b-44c357f05...@kernel.org/t/#u Signed-off-by: Jiri Slaby --- include/uapi/linux/termios.h | 15 --- 1 file changed, 15 deletions(-) diff --git a/include/uapi/linux/termios.h b/include/uapi/linux/termios.h index 33961d4e4de0..e6da9d4433d1 100644 --- a/include/uapi/linux/termios.h +++ b/include/uapi/linux/termios.h @@ -5,19 +5,4 @@ #include #include -#define NFF5 - -struct termiox -{ - __u16 x_hflag; - __u16 x_cflag; - __u16 x_rflag[NFF]; - __u16 x_sflag; -}; - -#defineRTSXOFF 0x0001 /* RTS flow control on input */ -#defineCTSXON 0x0002 /* CTS flow control on output */ -#defineDTRXOFF 0x0004 /* DTR flow control on input */ -#define DSRXON 0x0008 /* DCD flow control on output */ - #endif -- 2.30.0
[PATCH 01/12] vt: move set_leds to keyboard.c
set_leds and compute_shiftstate are called from a single place in vt.c. Let's combine these two into vt_set_leds_compute_shiftstate. This allows for making keyboard_tasklet local in the next patch. Signed-off-by: Jiri Slaby --- drivers/tty/vt/keyboard.c | 11 ++- drivers/tty/vt/vt.c | 3 +-- include/linux/kbd_kern.h | 8 +--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index 52922d21a49f..32ec4242b1f2 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c @@ -372,6 +372,12 @@ static void to_utf8(struct vc_data *vc, uint c) } } +/* FIXME: review locking for vt.c callers */ +static void set_leds(void) +{ + tasklet_schedule(&keyboard_tasklet); +} + /* * Called after returning from RAW mode or when changing consoles - recompute * shift_down[] and shift_state from key_down[] maybe called when keymap is @@ -401,9 +407,12 @@ static void do_compute_shiftstate(void) } /* We still have to export this method to vt.c */ -void compute_shiftstate(void) +void vt_set_leds_compute_shiftstate(void) { unsigned long flags; + + set_leds(); + spin_lock_irqsave(&kbd_event_lock, flags); do_compute_shiftstate(); spin_unlock_irqrestore(&kbd_event_lock, flags); diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index d04a162939a4..fe4fedbc0386 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1036,8 +1036,7 @@ void redraw_screen(struct vc_data *vc, int is_switch) } set_cursor(vc); if (is_switch) { - set_leds(); - compute_shiftstate(); + vt_set_leds_compute_shiftstate(); notify_update(vc); } } diff --git a/include/linux/kbd_kern.h b/include/linux/kbd_kern.h index 82f29aa35062..adf98004624b 100644 --- a/include/linux/kbd_kern.h +++ b/include/linux/kbd_kern.h @@ -71,12 +71,6 @@ extern void (*kbd_ledfunc)(unsigned int led); extern int set_console(int nr); extern void schedule_console_callback(void); -/* FIXME: review locking for vt.c callers */ -static inline void set_leds(void) -{ - tasklet_schedule(&keyboard_tasklet); -} - static inline int vc_kbd_mode(struct kbd_struct * kbd, int flag) { return ((kbd->modeflags >> flag) & 1); @@ -135,7 +129,7 @@ static inline void chg_vc_kbd_led(struct kbd_struct * kbd, int flag) struct console; -void compute_shiftstate(void); +void vt_set_leds_compute_shiftstate(void); /* defkeymap.c */ -- 2.30.0
[PATCH 07/12] vt/consolemap: do font sum unsigned
The constant 20 makes the font sum computation signed which can lead to sign extensions and signed wraps. It's not much of a problem as we build with -fno-strict-overflow. But if we ever decide not to, be ready, so switch the constant to unsigned. Signed-off-by: Jiri Slaby --- drivers/tty/vt/consolemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c index f7d015c67963..d815ac98b39e 100644 --- a/drivers/tty/vt/consolemap.c +++ b/drivers/tty/vt/consolemap.c @@ -495,7 +495,7 @@ con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos) p2[unicode & 0x3f] = fontpos; - p->sum += (fontpos << 20) + unicode; + p->sum += (fontpos << 20U) + unicode; return 0; } -- 2.30.0
[PATCH 11/12] tty_port: drop last traces of low_latency
The main purpose of tty_port::low_latency was removed in commit a9c3f68f3cd8 (tty: Fix low_latency BUG) back in 2014. It was left in place for drivers as an optional tune knob. But only one driver has been using it until the previous commit. So remove this misconcept completely, given there are no users. Signed-off-by: Jiri Slaby --- Documentation/networking/caif/caif.rst | 1 - drivers/char/pcmcia/synclink_cs.c | 2 -- drivers/net/caif/caif_serial.c | 3 +-- drivers/s390/char/con3215.c| 1 - drivers/s390/char/sclp_tty.c | 1 - drivers/s390/char/sclp_vt220.c | 1 - drivers/s390/char/tty3270.c| 2 -- drivers/tty/amiserial.c| 3 --- drivers/tty/hvc/hvcs.c | 2 +- drivers/tty/ipwireless/tty.c | 1 - drivers/tty/mxser.c| 1 - drivers/tty/serial/ifx6x60.c | 3 --- drivers/tty/serial/max3100.c | 3 --- drivers/tty/serial/serial_core.c | 3 --- drivers/tty/synclink_gt.c | 1 - include/linux/tty.h| 3 +-- 16 files changed, 3 insertions(+), 28 deletions(-) diff --git a/Documentation/networking/caif/caif.rst b/Documentation/networking/caif/caif.rst index a07213030ccf..81a14373d780 100644 --- a/Documentation/networking/caif/caif.rst +++ b/Documentation/networking/caif/caif.rst @@ -68,7 +68,6 @@ There are debugfs parameters provided for serial communication. * tty_status: Prints the bit-mask tty status information - 0x01 - tty->warned is on. - - 0x02 - tty->low_latency is on. - 0x04 - tty->packed is on. - 0x08 - tty->flow_stopped is on. - 0x10 - tty->hw_stopped is on. diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index e342daa73d1b..2be8d9a8eec5 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -2494,8 +2494,6 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) printk("%s(%d):mgslpc_open(%s), old ref count = %d\n", __FILE__, __LINE__, tty->driver->name, port->count); - port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; - spin_lock_irqsave(&info->netlock, flags); if (info->netcount) { retval = -EBUSY; diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c index bcc14c5875bf..8215cd77301f 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c @@ -89,8 +89,7 @@ static inline void update_tty_status(struct ser_device *ser) ser->tty_status = ser->tty->stopped << 5 | ser->tty->flow_stopped << 3 | - ser->tty->packet << 2 | - ser->tty->port->low_latency << 1; + ser->tty->packet << 2; } static inline void debugfs_init(struct ser_device *ser, struct tty_struct *tty) { diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 1354c42d95aa..671efee612af 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c @@ -914,7 +914,6 @@ static int tty3215_open(struct tty_struct *tty, struct file * filp) tty_port_tty_set(&raw->port, tty); - raw->port.low_latency = 0; /* don't use bottom half for pushing chars */ /* * Start up 3215 device */ diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c index 5aff8b684eb2..013bcc331305 100644 --- a/drivers/s390/char/sclp_tty.c +++ b/drivers/s390/char/sclp_tty.c @@ -65,7 +65,6 @@ sclp_tty_open(struct tty_struct *tty, struct file *filp) { tty_port_tty_set(&sclp_port, tty); tty->driver_data = NULL; - sclp_port.low_latency = 0; return 0; } diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c index 3f9a6ef650fa..047f812d1a1c 100644 --- a/drivers/s390/char/sclp_vt220.c +++ b/drivers/s390/char/sclp_vt220.c @@ -560,7 +560,6 @@ sclp_vt220_open(struct tty_struct *tty, struct file *filp) { if (tty->count == 1) { tty_port_tty_set(&sclp_vt220_port, tty); - sclp_vt220_port.low_latency = 0; if (!tty->winsize.ws_row && !tty->winsize.ws_col) { tty->winsize.ws_row = 24; tty->winsize.ws_col = 80; diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c index aec996de44d9..15692449a1c3 100644 --- a/drivers/s390/char/tty3270.c +++ b/drivers/s390/char/tty3270.c @@ -967,7 +967,6 @@ static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty) tty->driver_data = tp; tty->winsize.ws_row = tp->view.rows - 2; tty->winsize.ws_col = tp->view.cols; - tp->port.low_latency
[PATCH 08/12] vt: drop old FONT ioctls
Drop support for these ioctls: * PIO_FONT, PIO_FONTX * GIO_FONT, GIO_FONTX * PIO_FONTRESET As was demonstrated by commit 90bfdeef83f1 (tty: make FONTX ioctl use the tty pointer they were actually passed), these ioctls are not used from userspace, as: 1) they used to be broken (set up font on current console, not the open one) and racy (before the commit above) 2) KDFONTOP ioctl is used for years instead Note that PIO_FONTRESET is defunct on most systems as VGA_CONSOLE is set on them for ages. That turns on BROKEN_GRAPHICS_PROGRAMS which makes PIO_FONTRESET just return an error. We are removing KD_FONT_FLAG_OLD here as it was used only by these removed ioctls. kd.h header exists both in kernel and uapi headers, so we can remove the kernel one completely. Everyone includeing kd.h will now automatically get the uapi one. There are now unused definitions of the ioctl numbers and "struct consolefontdesc" in kd.h, but as it is a uapi header, I am not touching these. Signed-off-by: Jiri Slaby --- drivers/tty/vt/vt.c | 39 +- drivers/tty/vt/vt_ioctl.c | 151 -- include/linux/kd.h| 8 -- 3 files changed, 3 insertions(+), 195 deletions(-) delete mode 100644 include/linux/kd.h diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index fe4fedbc0386..284b07224c55 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4583,16 +4583,8 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op) if (op->data && font.charcount > op->charcount) rc = -ENOSPC; - if (!(op->flags & KD_FONT_FLAG_OLD)) { - if (font.width > op->width || font.height > op->height) - rc = -ENOSPC; - } else { - if (font.width != 8) - rc = -EIO; - else if ((op->height && font.height > op->height) || -font.height > 32) - rc = -ENOSPC; - } + if (font.width > op->width || font.height > op->height) + rc = -ENOSPC; if (rc) goto out; @@ -4620,7 +4612,7 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op) return -EINVAL; if (op->charcount > 512) return -EINVAL; - if (op->width <= 0 || op->width > 32 || op->height > 32) + if (op->width <= 0 || op->width > 32 || !op->height || op->height > 32) return -EINVAL; size = (op->width+7)/8 * 32 * op->charcount; if (size > max_font_size) @@ -4630,31 +4622,6 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op) if (IS_ERR(font.data)) return PTR_ERR(font.data); - if (!op->height) { /* Need to guess font height [compat] */ - int h, i; - u8 *charmap = font.data; - - /* -* If from KDFONTOP ioctl, don't allow things which can be done -* in userland,so that we can get rid of this soon -*/ - if (!(op->flags & KD_FONT_FLAG_OLD)) { - kfree(font.data); - return -EINVAL; - } - - for (h = 32; h > 0; h--) - for (i = 0; i < op->charcount; i++) - if (charmap[32*i+h-1]) - goto nonzero; - - kfree(font.data); - return -EINVAL; - - nonzero: - op->height = h; - } - font.charcount = op->charcount; font.width = op->width; font.height = op->height; diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c index 3813c40f1b48..4a4cbd4a5f37 100644 --- a/drivers/tty/vt/vt_ioctl.c +++ b/drivers/tty/vt/vt_ioctl.c @@ -484,70 +484,6 @@ static int vt_k_ioctl(struct tty_struct *tty, unsigned int cmd, return 0; } -static inline int do_fontx_ioctl(struct vc_data *vc, int cmd, - struct consolefontdesc __user *user_cfd, - struct console_font_op *op) -{ - struct consolefontdesc cfdarg; - int i; - - if (copy_from_user(&cfdarg, user_cfd, sizeof(struct consolefontdesc))) - return -EFAULT; - - switch (cmd) { - case PIO_FONTX: - op->op = KD_FONT_OP_SET; - op->flags = KD_FONT_FLAG_OLD; - op->width = 8; - op->height = cfdarg.charheight; - op->charcount = cfdarg.charcount; - op->data = cfdarg.chardata; - return con_font_op(vc, op); - - case GIO_FONTX: - op->op = KD_FONT_OP_GET; - op->flags = KD_FONT_FLAG_OLD; -
[PATCH 04/12] vt: keyboard, defkeymap.c_shipped, approach the unicode table
Commit 5ce2087ed0eb (Fix default compose table initialization) fixed unicode table so that the values are not sign extended. The upstream (kbd package) chose a different approach. They use hexadecimal values. So use the same, so that the output of loadkeys and our shipped file correspond more to each other. Signed-off-by: Jiri Slaby --- drivers/tty/vt/defkeymap.c_shipped | 68 +++--- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/tty/vt/defkeymap.c_shipped b/drivers/tty/vt/defkeymap.c_shipped index cac1fcbd55c7..094d95bf0005 100644 --- a/drivers/tty/vt/defkeymap.c_shipped +++ b/drivers/tty/vt/defkeymap.c_shipped @@ -224,40 +224,40 @@ char *func_table[MAX_NR_FUNC] = { }; struct kbdiacruc accent_table[MAX_DIACR] = { - {'`', 'A', 0300}, {'`', 'a', 0340}, - {'\'', 'A', 0301}, {'\'', 'a', 0341}, - {'^', 'A', 0302}, {'^', 'a', 0342}, - {'~', 'A', 0303}, {'~', 'a', 0343}, - {'"', 'A', 0304}, {'"', 'a', 0344}, - {'O', 'A', 0305}, {'o', 'a', 0345}, - {'0', 'A', 0305}, {'0', 'a', 0345}, - {'A', 'A', 0305}, {'a', 'a', 0345}, - {'A', 'E', 0306}, {'a', 'e', 0346}, - {',', 'C', 0307}, {',', 'c', 0347}, - {'`', 'E', 0310}, {'`', 'e', 0350}, - {'\'', 'E', 0311}, {'\'', 'e', 0351}, - {'^', 'E', 0312}, {'^', 'e', 0352}, - {'"', 'E', 0313}, {'"', 'e', 0353}, - {'`', 'I', 0314}, {'`', 'i', 0354}, - {'\'', 'I', 0315}, {'\'', 'i', 0355}, - {'^', 'I', 0316}, {'^', 'i', 0356}, - {'"', 'I', 0317}, {'"', 'i', 0357}, - {'-', 'D', 0320}, {'-', 'd', 0360}, - {'~', 'N', 0321}, {'~', 'n', 0361}, - {'`', 'O', 0322}, {'`', 'o', 0362}, - {'\'', 'O', 0323}, {'\'', 'o', 0363}, - {'^', 'O', 0324}, {'^', 'o', 0364}, - {'~', 'O', 0325}, {'~', 'o', 0365}, - {'"', 'O', 0326}, {'"', 'o', 0366}, - {'/', 'O', 0330}, {'/', 'o', 0370}, - {'`', 'U', 0331}, {'`', 'u', 0371}, - {'\'', 'U', 0332}, {'\'', 'u', 0372}, - {'^', 'U', 0333}, {'^', 'u', 0373}, - {'"', 'U', 0334}, {'"', 'u', 0374}, - {'\'', 'Y', 0335}, {'\'', 'y', 0375}, - {'T', 'H', 0336}, {'t', 'h', 0376}, - {'s', 's', 0337}, {'"', 'y', 0377}, - {'s', 'z', 0337}, {'i', 'j', 0377}, + {'`', 'A', 0x00c0}, {'`', 'a', 0x00e0}, + {'\'', 'A', 0x00c1},{'\'', 'a', 0x00e1}, + {'^', 'A', 0x00c2}, {'^', 'a', 0x00e2}, + {'~', 'A', 0x00c3}, {'~', 'a', 0x00e3}, + {'"', 'A', 0x00c4}, {'"', 'a', 0x00e4}, + {'O', 'A', 0x00c5}, {'o', 'a', 0x00e5}, + {'0', 'A', 0x00c5}, {'0', 'a', 0x00e5}, + {'A', 'A', 0x00c5}, {'a', 'a', 0x00e5}, + {'A', 'E', 0x00c6}, {'a', 'e', 0x00e6}, + {',', 'C', 0x00c7}, {',', 'c', 0x00e7}, + {'`', 'E', 0x00c8}, {'`', 'e', 0x00e8}, + {'\'', 'E', 0x00c9},{'\'', 'e', 0x00e9}, + {'^', 'E', 0x00ca}, {'^', 'e', 0x00ea}, + {'"', 'E', 0x00cb}, {'"', 'e', 0x00eb}, + {'`', 'I', 0x00cc}, {'`', 'i', 0x00ec}, + {'\'', 'I', 0x00cd},{'\'', 'i', 0x00ed}, + {'^', 'I', 0x00ce}, {'^', 'i', 0x00ee}, + {'"', 'I', 0x00cf}, {'"', 'i', 0x00ef}, + {'-', 'D', 0x00d0}, {'-', 'd', 0x00f0}, + {'~', 'N', 0x00d1}, {'~', 'n', 0x00f1}, + {'`', 'O', 0x00d2}, {'`', 'o', 0x00f2}, + {'\'', 'O', 0x00d3},{'\'', 'o', 0x00f3}, + {'^', 'O', 0x00d4}, {'^', 'o', 0x00f4}, + {'~', 'O', 0x00d5}, {'~', 'o', 0x00f5}, + {'"', 'O', 0x00d6}, {'"', 'o', 0x00f6}, + {'/', 'O', 0x00d8}, {'/', 'o', 0x00f8}, + {'`', 'U', 0x00d9}, {'`', 'u', 0x00f9}, + {'\'', 'U', 0x00da},{'\'', 'u', 0x00fa}, + {'^', 'U', 0x00db}, {'^', 'u', 0x00fb}, + {'"', 'U', 0x00dc}, {'"', 'u', 0x00fc}, + {'\'', 'Y', 0x00dd},{'\'', 'y', 0x00fd}, + {'T', 'H', 0x00de}, {'t', 'h', 0x00fe}, + {'s', 's', 0x00df}, {'"', 'y', 0x00ff}, + {'s', 'z', 0x00df}, {'i', 'j', 0x00ff}, }; unsigned int accent_table_size = 68; -- 2.30.0
[PATCH 09/12] vgacon: drop BROKEN_GRAPHICS_PROGRAMS
BROKEN_GRAPHICS_PROGRAMS is defined when CONFIG_VGA_CONSOLE=y. And vgacon.c is built exclusively in that case too. So the check for BROKEN_GRAPHICS_PROGRAMS is pointless in vgacon.c as it is always true. So remove the test and BROKEN_GRAPHICS_PROGRAMS completely. This also eliminates the need for vga_font_is_default global as it is only set and never read. Signed-off-by: Jiri Slaby Cc: dri-de...@lists.freedesktop.org Cc: linux-fb...@vger.kernel.org --- drivers/video/console/vgacon.c | 19 --- include/linux/vt_kern.h| 12 2 files changed, 31 deletions(-) diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 17876f0179b5..962c12be9774 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -90,7 +90,6 @@ static unsigned int vga_video_num_lines; /* Number of text lines */ static boolvga_can_do_color; /* Do we support colors? */ static unsigned intvga_default_font_height __read_mostly; /* Height of default screen font */ static unsigned char vga_video_type __read_mostly; /* Card type */ -static boolvga_font_is_default = true; static int vga_vesa_blanked; static boolvga_palette_blanked; static boolvga_is_gfx; @@ -878,7 +877,6 @@ static int vgacon_do_font_op(struct vgastate *state, char *arg, int set, beg = 0x0a; } -#ifdef BROKEN_GRAPHICS_PROGRAMS /* * All fonts are loaded in slot 0 (0:1 for 512 ch) */ @@ -886,24 +884,7 @@ static int vgacon_do_font_op(struct vgastate *state, char *arg, int set, if (!arg) return -EINVAL; /* Return to default font not supported */ - vga_font_is_default = false; font_select = ch512 ? 0x04 : 0x00; -#else - /* -* The default font is kept in slot 0 and is never touched. -* A custom font is loaded in slot 2 (256 ch) or 2:3 (512 ch) -*/ - - if (set) { - vga_font_is_default = !arg; - if (!arg) - ch512 = false; /* Default font is always 256 */ - font_select = arg ? (ch512 ? 0x0e : 0x0a) : 0x00; - } - - if (!vga_font_is_default) - charmap += 4 * cmapsz; -#endif raw_spin_lock_irq(&vga_lock); /* First, the Sequencer */ diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h index 349e39c3ab60..94e7a315479c 100644 --- a/include/linux/vt_kern.h +++ b/include/linux/vt_kern.h @@ -16,18 +16,6 @@ #include #include -/* - * Presently, a lot of graphics programs do not restore the contents of - * the higher font pages. Defining this flag will avoid use of them, but - * will lose support for PIO_FONTRESET. Note that many font operations are - * not likely to work with these programs anyway; they need to be - * fixed. The linux/Documentation directory includes a code snippet - * to save and restore the text font. - */ -#ifdef CONFIG_VGA_CONSOLE -#define BROKEN_GRAPHICS_PROGRAMS 1 -#endif - void kd_mksound(unsigned int hz, unsigned int ticks); int kbd_rate(struct kbd_repeat *rep); -- 2.30.0
[PATCH 02/12] vt: keyboard, make keyboard_tasklet local
Now that the last extern user of the tasklet (set_leds) is in keyboard.c, we can make keyboard_tasklet local to this unit too. Signed-off-by: Jiri Slaby --- drivers/tty/vt/keyboard.c | 5 +++-- include/linux/kbd_kern.h | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index 32ec4242b1f2..9f2eaa104ebc 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c @@ -131,6 +131,9 @@ static const unsigned char max_vals[] = { static const int NR_TYPES = ARRAY_SIZE(max_vals); +static void kbd_bh(unsigned long dummy); +static DECLARE_TASKLET_DISABLED_OLD(keyboard_tasklet, kbd_bh); + static struct input_handler kbd_handler; static DEFINE_SPINLOCK(kbd_event_lock); static DEFINE_SPINLOCK(led_lock); @@ -1258,8 +1261,6 @@ static void kbd_bh(unsigned long dummy) } } -DECLARE_TASKLET_DISABLED_OLD(keyboard_tasklet, kbd_bh); - #if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\ defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) ||\ defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\ diff --git a/include/linux/kbd_kern.h b/include/linux/kbd_kern.h index adf98004624b..c40811d79769 100644 --- a/include/linux/kbd_kern.h +++ b/include/linux/kbd_kern.h @@ -6,8 +6,6 @@ #include #include -extern struct tasklet_struct keyboard_tasklet; - extern char *func_table[MAX_NR_FUNC]; /* -- 2.30.0
[PATCH 05/12] tty: pty, remove BUG_ON from pty_close
tty->ops->close is always called with a valid tty, so the BUG_ON cannot trigger. Signed-off-by: Jiri Slaby --- drivers/tty/pty.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index a59f1e062bc6..5e2374580e27 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -45,7 +45,6 @@ static DEFINE_MUTEX(devpts_mutex); static void pty_close(struct tty_struct *tty, struct file *filp) { - BUG_ON(!tty); if (tty->driver->subtype == PTY_TYPE_MASTER) WARN_ON(tty->count > 1); else { -- 2.30.0