Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp489301yba; Wed, 15 May 2019 05:03:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJW9QoMGr+dK/4w8iSKdke3PC7B2KZEdq9JxWPpD8Gv/PA1UFdJp0UwI72ZW5v6ZjGTZdV X-Received: by 2002:a62:1c06:: with SMTP id c6mr35746307pfc.168.1557921834074; Wed, 15 May 2019 05:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557921834; cv=none; d=google.com; s=arc-20160816; b=rEKqHyaUwS+HzGSrSldSbaM6v2U/B50hM4Md4VN2M5FTtkP2gKQ2dQCr9a7B4tcKQ9 l5jaF0UgOCeDOpaGm/iL3ilNIfsUXjyiANn/jKTIIR9CFX+f3E2AkpAlth2k302rZNB/ X7JIQazIVn72nEV4hkjtOLuuZlvMt7Oe+243sAhI2Eaw3Ca+GIGjAacyCKl3eJ3/8v1y nXEat8BATWuiIzzCJs2P3TDiXizNkabWFalvDvLNxOGbvIYZR6ObZqNrkM0jQsUsGQsm xLUyCs6TpAMesoZmi5TALVS9mF9BbWUT7EWIQE2frt1NizNs5Th9eSfHCLCVwE0eTY/Z bXEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WAd76JzWeeh6GAn+t6KLfkl8hlPd6KKbHg0rrFR2Hgg=; b=YFA4Pci/qnaKb28Vb6tSlPrwL7rejxdHBI7KfsISqJ5WB+zLOWw58mzI0bx9spftBK WiDAVd0TjJRtArhd4ZDmkLZ9kr+/qss1XHEcM384FvSc92ZBz9wTnrdaY9tCRspYlxiB pyznEPZHas8owxn0agOUrJQVvuwkhY+WLnbm2jdGgHKgh0Warm8R2tFH1PUjSyIFy9DN mBq3sFx2Ct+Z3B3E3dxRpYA68sgfR1IW4tun3OJOA5W1In/M7Tydofzn5QGqARmWBRTW CoQQgx1v0qNnR4F5bnNbMqCUQvX7Wh8jpMCPHje40v8WLdVmBDDfrU2IIDJQNWKF8o1J NEvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fQxphLEb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q3si1901975pfc.89.2019.05.15.05.03.38; Wed, 15 May 2019 05:03:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fQxphLEb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730275AbfEOMBr (ORCPT + 99 others); Wed, 15 May 2019 08:01:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:49530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729514AbfEOLNp (ORCPT ); Wed, 15 May 2019 07:13:45 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D10652084E; Wed, 15 May 2019 11:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918824; bh=vh6pNQ/LJmID+Mg91bzB6nBHD3tR33/G4T+7k2YMbME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fQxphLEb48siaUXdtQPM42cHex4XQKlSYQ77Ph5/SHDlgYnsY2jFMvx0CZJxfAMeM UJbPBiQ/kCXJsRiEW3pJdxLMkbXcVFyikcVLXV22W8HemD+yKCN+eIeQEmJlZC5dml VjNowPzCEbIFwRD5YGHlgiZkgF5I/C6hDYwkqlnA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Schwidefsky , Sasha Levin Subject: [PATCH 4.9 14/51] s390/3270: fix lockdep false positive on view->lock Date: Wed, 15 May 2019 12:55:49 +0200 Message-Id: <20190515090621.828009478@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090616.669619870@linuxfoundation.org> References: <20190515090616.669619870@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 5712f3301a12c0c3de9cc423484496b0464f2faf ] 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 Signed-off-by: Sasha Levin --- drivers/s390/char/con3270.c | 2 +- drivers/s390/char/fs3270.c | 3 ++- drivers/s390/char/raw3270.c | 3 ++- drivers/s390/char/raw3270.h | 4 +++- drivers/s390/char/tty3270.c | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c index 285b4006f44bb..5d5e78afde88a 100644 --- a/drivers/s390/char/con3270.c +++ b/drivers/s390/char/con3270.c @@ -628,7 +628,7 @@ con3270_init(void) (void (*)(unsigned long)) con3270_read_tasklet, (unsigned long) condev->read); - raw3270_add_view(&condev->view, &con3270_fn, 1); + raw3270_add_view(&condev->view, &con3270_fn, 1, RAW3270_VIEW_LOCK_IRQ); INIT_LIST_HEAD(&condev->freemem); for (i = 0; i < CON3270_STRING_PAGES; i++) { diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c index 85eca1cef0630..04a6810a4298c 100644 --- a/drivers/s390/char/fs3270.c +++ b/drivers/s390/char/fs3270.c @@ -462,7 +462,8 @@ fs3270_open(struct inode *inode, struct file *filp) init_waitqueue_head(&fp->wait); fp->fs_pid = get_pid(task_pid(current)); - rc = raw3270_add_view(&fp->view, &fs3270_fn, minor); + rc = raw3270_add_view(&fp->view, &fs3270_fn, minor, + RAW3270_VIEW_LOCK_BH); if (rc) { fs3270_free_view(&fp->view); goto out; diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c index a2da898ce90fd..1ebf632e327b9 100644 --- a/drivers/s390/char/raw3270.c +++ b/drivers/s390/char/raw3270.c @@ -919,7 +919,7 @@ raw3270_deactivate_view(struct raw3270_view *view) * Add view to device with minor "minor". */ int -raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor) +raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor, int subclass) { unsigned long flags; struct raw3270 *rp; @@ -941,6 +941,7 @@ raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor) view->cols = rp->cols; view->ascebc = rp->ascebc; spin_lock_init(&view->lock); + lockdep_set_subclass(&view->lock, subclass); list_add(&view->list, &rp->view_list); rc = 0; spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); diff --git a/drivers/s390/char/raw3270.h b/drivers/s390/char/raw3270.h index 56519cbb165c7..7577d7d0ad486 100644 --- a/drivers/s390/char/raw3270.h +++ b/drivers/s390/char/raw3270.h @@ -149,6 +149,8 @@ struct raw3270_fn { struct raw3270_view { struct list_head list; spinlock_t lock; +#define RAW3270_VIEW_LOCK_IRQ 0 +#define RAW3270_VIEW_LOCK_BH 1 atomic_t ref_count; struct raw3270 *dev; struct raw3270_fn *fn; @@ -157,7 +159,7 @@ struct raw3270_view { unsigned char *ascebc; /* ascii -> ebcdic table */ }; -int raw3270_add_view(struct raw3270_view *, struct raw3270_fn *, int); +int raw3270_add_view(struct raw3270_view *, struct raw3270_fn *, int, int); int raw3270_activate_view(struct raw3270_view *); void raw3270_del_view(struct raw3270_view *); void raw3270_deactivate_view(struct raw3270_view *); diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c index 272cb6cd1b2ac..6dd6f9ff7de56 100644 --- a/drivers/s390/char/tty3270.c +++ b/drivers/s390/char/tty3270.c @@ -978,7 +978,8 @@ static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty) return PTR_ERR(tp); rc = raw3270_add_view(&tp->view, &tty3270_fn, - tty->index + RAW3270_FIRSTMINOR); + tty->index + RAW3270_FIRSTMINOR, + RAW3270_VIEW_LOCK_BH); if (rc) { tty3270_free_view(tp); return rc; -- 2.20.1