Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "tty: hvc: pass DMA capable memory to put_chars()"

This reverts commit 0986d7bc5598f5df30e3db777d00e73890c97627.

It still has some issues and needs to be dropped at this point in time.

Link: https://lore.kernel.org/r/208f7a41-a9fa-630c-cb44-c37c503f3a72@kernel.org
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Cc: Xianting Tian <xianting.tian@linux.alibaba.com>
Cc: Shile Zhang <shile.zhang@linux.alibaba.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+16 -41
+15 -21
drivers/tty/hvc/hvc_console.c
··· 41 41 */ 42 42 #define HVC_CLOSE_WAIT (HZ/100) /* 1/10 of a second */ 43 43 44 + /* 45 + * These sizes are most efficient for vio, because they are the 46 + * native transfer size. We could make them selectable in the 47 + * future to better deal with backends that want other buffer sizes. 48 + */ 49 + #define N_OUTBUF 16 50 + #define N_INBUF 16 51 + 52 + #define __ALIGNED__ __attribute__((__aligned__(L1_CACHE_BYTES))) 53 + 44 54 static struct tty_driver *hvc_driver; 45 55 static struct task_struct *hvc_task; 46 56 ··· 142 132 static const struct hv_ops *cons_ops[MAX_NR_HVC_CONSOLES]; 143 133 static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] = 144 134 {[0 ... MAX_NR_HVC_CONSOLES - 1] = -1}; 145 - static struct hvc_struct *cons_hvcs[MAX_NR_HVC_CONSOLES]; 146 135 147 136 /* 148 137 * Console APIs, NOT TTY. These APIs are available immediately when ··· 151 142 static void hvc_console_print(struct console *co, const char *b, 152 143 unsigned count) 153 144 { 154 - char *c; 145 + char c[N_OUTBUF] __ALIGNED__; 155 146 unsigned i = 0, n = 0; 156 147 int r, donecr = 0, index = co->index; 157 - unsigned long flags; 158 - struct hvc_struct *hp; 159 148 160 149 /* Console access attempt outside of acceptable console range. */ 161 150 if (index >= MAX_NR_HVC_CONSOLES) ··· 163 156 if (vtermnos[index] == -1) 164 157 return; 165 158 166 - hp = cons_hvcs[index]; 167 - if (!hp) 168 - return; 169 - 170 - c = hp->cons_outbuf; 171 - 172 - spin_lock_irqsave(&hp->cons_outbuf_lock, flags); 173 159 while (count > 0 || i > 0) { 174 160 if (count > 0 && i < sizeof(c)) { 175 161 if (b[n] == '\n' && !donecr) { ··· 191 191 } 192 192 } 193 193 } 194 - spin_unlock_irqrestore(&hp->cons_outbuf_lock, flags); 195 194 hvc_console_flush(cons_ops[index], vtermnos[index]); 196 195 } 197 196 ··· 878 879 struct tty_struct *tty = driver->ttys[0]; 879 880 struct hvc_struct *hp = tty->driver_data; 880 881 int n; 881 - unsigned long flags; 882 882 883 883 do { 884 - spin_lock_irqsave(&hp->cons_outbuf_lock, flags); 885 - hp->cons_outbuf[0] = ch; 886 - n = hp->ops->put_chars(hp->vtermno, &hp->cons_outbuf[0], 1); 887 - spin_unlock_irqrestore(&hp->cons_outbuf_lock, flags); 884 + n = hp->ops->put_chars(hp->vtermno, &ch, 1); 888 885 } while (n <= 0); 889 886 } 890 887 #endif ··· 922 927 return ERR_PTR(err); 923 928 } 924 929 925 - hp = kzalloc(struct_size(hp, outbuf, outbuf_size), GFP_KERNEL); 930 + hp = kzalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size, 931 + GFP_KERNEL); 926 932 if (!hp) 927 933 return ERR_PTR(-ENOMEM); 928 934 ··· 931 935 hp->data = data; 932 936 hp->ops = ops; 933 937 hp->outbuf_size = outbuf_size; 938 + hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))]; 934 939 935 940 tty_port_init(&hp->port); 936 941 hp->port.ops = &hvc_port_ops; 937 942 938 943 INIT_WORK(&hp->tty_resize, hvc_set_winsz); 939 944 spin_lock_init(&hp->lock); 940 - spin_lock_init(&hp->cons_outbuf_lock); 941 945 mutex_lock(&hvc_structs_mutex); 942 946 943 947 /* ··· 964 968 if (i < MAX_NR_HVC_CONSOLES) { 965 969 cons_ops[i] = ops; 966 970 vtermnos[i] = vtermno; 967 - cons_hvcs[i] = hp; 968 971 } 969 972 970 973 list_add_tail(&(hp->next), &hvc_structs); ··· 988 993 if (hp->index < MAX_NR_HVC_CONSOLES) { 989 994 vtermnos[hp->index] = -1; 990 995 cons_ops[hp->index] = NULL; 991 - cons_hvcs[hp->index] = NULL; 992 996 } 993 997 994 998 /* Don't whack hp->irq because tty_hangup() will need to free the irq. */
+1 -20
drivers/tty/hvc/hvc_console.h
··· 32 32 */ 33 33 #define HVC_ALLOC_TTY_ADAPTERS 8 34 34 35 - /* 36 - * These sizes are most efficient for vio, because they are the 37 - * native transfer size. We could make them selectable in the 38 - * future to better deal with backends that want other buffer sizes. 39 - */ 40 - #define N_OUTBUF 16 41 - #define N_INBUF 16 42 - 43 - #define __ALIGNED__ __attribute__((__aligned__(L1_CACHE_BYTES))) 44 - 45 35 struct hvc_struct { 46 36 struct tty_port port; 47 37 spinlock_t lock; 48 38 int index; 49 39 int do_wakeup; 40 + char *outbuf; 50 41 int outbuf_size; 51 42 int n_outbuf; 52 43 uint32_t vtermno; ··· 48 57 struct work_struct tty_resize; 49 58 struct list_head next; 50 59 unsigned long flags; 51 - 52 - /* 53 - * the buf and its lock are used in hvc console api for putting chars, 54 - * and also used in hvc_poll_put_char() for putting single char. 55 - */ 56 - spinlock_t cons_outbuf_lock; 57 - char cons_outbuf[N_OUTBUF] __ALIGNED__; 58 - 59 - /* the buf is used for putting chars to tty */ 60 - char outbuf[] __ALIGNED__; 61 60 }; 62 61 63 62 /* implemented by a low level driver */