Skip to content

Commit 5712f33

Browse files
author
Martin Schwidefsky
committed
s390/3270: fix lockdep false positive on view->lock
The spinlock in the raw3270_view structure is used by con3270, tty3270 and fs3270 in different ways. For con3270 the lock can be acquired in irq context, for tty3270 and fs3270 the highest context is bh. Lockdep sees the view->lock as a single class and if the 3270 driver is used for the console the following message is generated: WARNING: inconsistent lock state 5.1.0-rc3-05157-g5c168033979d #12 Not tainted -------------------------------- inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. swapper/0/1 [HC0[0]:SC1[1]:HE1:SE0] takes: (____ptrval____) (&(&view->lock)->rlock){?.-.}, at: tty3270_update+0x7c/0x330 Introduce a lockdep subclass for the view lock to distinguish bh from irq locks. Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent 2cc9637 commit 5712f33

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

drivers/s390/char/con3270.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ con3270_init(void)
629629
(void (*)(unsigned long)) con3270_read_tasklet,
630630
(unsigned long) condev->read);
631631

632-
raw3270_add_view(&condev->view, &con3270_fn, 1);
632+
raw3270_add_view(&condev->view, &con3270_fn, 1, RAW3270_VIEW_LOCK_IRQ);
633633

634634
INIT_LIST_HEAD(&condev->freemem);
635635
for (i = 0; i < CON3270_STRING_PAGES; i++) {

drivers/s390/char/fs3270.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ fs3270_open(struct inode *inode, struct file *filp)
463463

464464
init_waitqueue_head(&fp->wait);
465465
fp->fs_pid = get_pid(task_pid(current));
466-
rc = raw3270_add_view(&fp->view, &fs3270_fn, minor);
466+
rc = raw3270_add_view(&fp->view, &fs3270_fn, minor,
467+
RAW3270_VIEW_LOCK_BH);
467468
if (rc) {
468469
fs3270_free_view(&fp->view);
469470
goto out;

drivers/s390/char/raw3270.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ raw3270_deactivate_view(struct raw3270_view *view)
920920
* Add view to device with minor "minor".
921921
*/
922922
int
923-
raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor)
923+
raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor, int subclass)
924924
{
925925
unsigned long flags;
926926
struct raw3270 *rp;
@@ -942,6 +942,7 @@ raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor)
942942
view->cols = rp->cols;
943943
view->ascebc = rp->ascebc;
944944
spin_lock_init(&view->lock);
945+
lockdep_set_subclass(&view->lock, subclass);
945946
list_add(&view->list, &rp->view_list);
946947
rc = 0;
947948
spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);

drivers/s390/char/raw3270.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ struct raw3270_fn {
150150
struct raw3270_view {
151151
struct list_head list;
152152
spinlock_t lock;
153+
#define RAW3270_VIEW_LOCK_IRQ 0
154+
#define RAW3270_VIEW_LOCK_BH 1
153155
atomic_t ref_count;
154156
struct raw3270 *dev;
155157
struct raw3270_fn *fn;
@@ -158,7 +160,7 @@ struct raw3270_view {
158160
unsigned char *ascebc; /* ascii -> ebcdic table */
159161
};
160162

161-
int raw3270_add_view(struct raw3270_view *, struct raw3270_fn *, int);
163+
int raw3270_add_view(struct raw3270_view *, struct raw3270_fn *, int, int);
162164
int raw3270_activate_view(struct raw3270_view *);
163165
void raw3270_del_view(struct raw3270_view *);
164166
void raw3270_deactivate_view(struct raw3270_view *);

drivers/s390/char/tty3270.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,8 @@ static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty)
980980
return PTR_ERR(tp);
981981

982982
rc = raw3270_add_view(&tp->view, &tty3270_fn,
983-
tty->index + RAW3270_FIRSTMINOR);
983+
tty->index + RAW3270_FIRSTMINOR,
984+
RAW3270_VIEW_LOCK_BH);
984985
if (rc) {
985986
tty3270_free_view(tp);
986987
return rc;

0 commit comments

Comments
 (0)