From patchwork Fri May 24 08:53:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10959379 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E38D5112C for ; Fri, 24 May 2019 08:54:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D13D32884B for ; Fri, 24 May 2019 08:54:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C55E328852; Fri, 24 May 2019 08:54:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 721B62884B for ; Fri, 24 May 2019 08:54:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 10E446E0AD; Fri, 24 May 2019 08:54:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2BE936E04B for ; Fri, 24 May 2019 08:54:07 +0000 (UTC) Received: by mail-ed1-x542.google.com with SMTP id f37so13270850edb.13 for ; Fri, 24 May 2019 01:54:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KbIQNH506d7uyinFmR7MAZcUSMrKczG7pZJTMI8GyjU=; b=AGvy0CCaYc5sQROQwL1oEzJkZQiXq8aiTupZ5/jzLwSw9cv2LkVyn6UoeCqAo7AJM9 fjkzN1ceFlCb81LYncVlXsSOAcHmf4Ze03jyynBVbYOZbEUSsvRlvQUqxuDvw8EzuG5M 9osSubwg3nAxZy92h4spqDVhA06fTWcS4UEEAOLbtAEDMZe2JTYlqEBpOOUf1Ex442md 4XrFphB+afFwYWpFK8dBSXXlUBEnx4q+/ghcdw7+zQTtC3+l5WZQ5IzmoAh32AbtNMCa qn5RF4b6CNJqLdbXgAtoylCJUcTTRRz4PWYG8CSou6l8YMfp7aJQYVP5OmR1qf4p+4nT oPZg== X-Gm-Message-State: APjAAAWyoAKcRM47qxl7XDfYzFWu9ZqfKpdY1y+VCVc4MffFFjKHmJg4 u/RWPKxzSB2+eW8Pdb9ddP8T9A== X-Google-Smtp-Source: APXvYqyiRawT8vC+B4WJM0VQMmLh1LZxOrS19g4BugnYkWojWg1kQxzgMayUAw7FefR44KX3iH56PQ== X-Received: by 2002:a50:e40f:: with SMTP id d15mr103662690edm.0.1558688045814; Fri, 24 May 2019 01:54:05 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id 96sm567082edq.68.2019.05.24.01.54.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 May 2019 01:54:05 -0700 (PDT) From: Daniel Vetter To: LKML Subject: [PATCH 04/33] vt: More locking checks Date: Fri, 24 May 2019 10:53:25 +0200 Message-Id: <20190524085354.27411-5-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190524085354.27411-1-daniel.vetter@ffwll.ch> References: <20190524085354.27411-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KbIQNH506d7uyinFmR7MAZcUSMrKczG7pZJTMI8GyjU=; b=jdtIJI/b2i4YgJlmMYeyZ/qfpIKXC/shH7cE6v5onT6Vdj85CGpPp2AYk0ABglEbnL 1WBMLJMU5Yhlzv5WzFLoLy7XvF4fUM/CPoMTxHwmeJED3X3GASPifwWYAdS3qIAvu44S EtOW0SCOZrzT039kR8G9ic8VrLzWELS/rmWds= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicolas Pitre , Adam Borowski , Daniel Vetter , Intel Graphics Development , DRI Development , Martin Hostettler , Mikulas Patocka , Greg Kroah-Hartman , Daniel Vetter Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP I honestly have no idea what the subtle differences between con_is_visible, con_is_fg (internal to vt.c) and con_is_bound are. But it looks like both vc->vc_display_fg and con_driver_map are protected by the console_lock, so probably better if we hold that when checking this. To do that I had to deinline the con_is_visible function. Signed-off-by: Daniel Vetter Cc: Greg Kroah-Hartman Cc: Nicolas Pitre Cc: Martin Hostettler Cc: Adam Borowski Cc: Daniel Vetter Cc: Mikulas Patocka Acked-by: Greg Kroah-Hartman --- drivers/tty/vt/vt.c | 16 ++++++++++++++++ include/linux/console_struct.h | 5 +---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index bc9813b14c58..a8988a085138 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -3815,6 +3815,8 @@ int con_is_bound(const struct consw *csw) { int i, bound = 0; + WARN_CONSOLE_UNLOCKED(); + for (i = 0; i < MAX_NR_CONSOLES; i++) { if (con_driver_map[i] == csw) { bound = 1; @@ -3826,6 +3828,20 @@ int con_is_bound(const struct consw *csw) } EXPORT_SYMBOL(con_is_bound); +/** + * con_is_visible - checks whether the current console is visible + * @vc: virtual console + * + * RETURNS: zero if not visible, nonzero if visible + */ +bool con_is_visible(const struct vc_data *vc) +{ + WARN_CONSOLE_UNLOCKED(); + + return *vc->vc_display_fg == vc; +} +EXPORT_SYMBOL(con_is_visible); + /** * con_debug_enter - prepare the console for the kernel debugger * @sw: console driver diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h index ed798e114663..24d4c16e3ae0 100644 --- a/include/linux/console_struct.h +++ b/include/linux/console_struct.h @@ -168,9 +168,6 @@ extern void vc_SAK(struct work_struct *work); #define CUR_DEFAULT CUR_UNDERLINE -static inline bool con_is_visible(const struct vc_data *vc) -{ - return *vc->vc_display_fg == vc; -} +bool con_is_visible(const struct vc_data *vc); #endif /* _LINUX_CONSOLE_STRUCT_H */