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

hvc_console: Provide (un)locked version for hvc_resize()

Rename the locking free hvc_resize() function to __hvc_resize() and
provide an inline function that locks the hvc_struct and calls
__hvc_resize().

The rationale for this patch is that virtio_console calls the hvc_resize()
function without locking the hvc_struct. So it needs to call the lock
itself.

According to naming rules, the unlocked version is renamed and
prefixed with "__".
References to unlocked function calls in hvc back-ends has been updated.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Hendrik Brueckner and committed by
Benjamin Herrenschmidt
254be490 94a8d5ca

+17 -5
+3 -3
drivers/char/hvc_console.c
··· 678 678 EXPORT_SYMBOL_GPL(hvc_poll); 679 679 680 680 /** 681 - * hvc_resize() - Update terminal window size information. 681 + * __hvc_resize() - Update terminal window size information. 682 682 * @hp: HVC console pointer 683 683 * @ws: Terminal window size structure 684 684 * ··· 687 687 * 688 688 * Locking: Locking free; the function MUST be called holding hp->lock 689 689 */ 690 - void hvc_resize(struct hvc_struct *hp, struct winsize ws) 690 + void __hvc_resize(struct hvc_struct *hp, struct winsize ws) 691 691 { 692 692 hp->ws = ws; 693 693 schedule_work(&hp->tty_resize); 694 694 } 695 - EXPORT_SYMBOL_GPL(hvc_resize); 695 + EXPORT_SYMBOL_GPL(__hvc_resize); 696 696 697 697 /* 698 698 * This kthread is either polling or interrupt driven. This is determined by
+11 -1
drivers/char/hvc_console.h
··· 28 28 #define HVC_CONSOLE_H 29 29 #include <linux/kref.h> 30 30 #include <linux/tty.h> 31 + #include <linux/spinlock.h> 31 32 32 33 /* 33 34 * This is the max number of console adapters that can/will be found as ··· 89 88 void hvc_kick(void); 90 89 91 90 /* Resize hvc tty terminal window */ 92 - extern void hvc_resize(struct hvc_struct *hp, struct winsize ws); 91 + extern void __hvc_resize(struct hvc_struct *hp, struct winsize ws); 92 + 93 + static inline void hvc_resize(struct hvc_struct *hp, struct winsize ws) 94 + { 95 + unsigned long flags; 96 + 97 + spin_lock_irqsave(&hp->lock, flags); 98 + __hvc_resize(hp, ws); 99 + spin_unlock_irqrestore(&hp->lock, flags); 100 + } 93 101 94 102 /* default notifier for irq based notification */ 95 103 extern int notifier_add_irq(struct hvc_struct *hp, int data);
+3 -1
drivers/char/hvc_iucv.c
··· 273 273 case MSG_TYPE_WINSIZE: 274 274 if (rb->mbuf->datalen != sizeof(struct winsize)) 275 275 break; 276 - hvc_resize(priv->hvc, *((struct winsize *) rb->mbuf->data)); 276 + /* The caller must ensure that the hvc is locked, which 277 + * is the case when called from hvc_iucv_get_chars() */ 278 + __hvc_resize(priv->hvc, *((struct winsize *) rb->mbuf->data)); 277 279 break; 278 280 279 281 case MSG_TYPE_ERROR: /* ignored ... */