From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC551C433FE for ; Tue, 8 Feb 2022 21:08:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 569BA10E4C1; Tue, 8 Feb 2022 21:08:43 +0000 (UTC) Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4186610E50F for ; Tue, 8 Feb 2022 21:08:40 +0000 (UTC) Received: by mail-wm1-x32c.google.com with SMTP id c192so142064wma.4 for ; Tue, 08 Feb 2022 13:08:40 -0800 (PST) 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=+/n/16RZ52OxmA0UdDabSATFo04ROfy75nWG7tM3V6I=; b=hRasZriqWBEeJzoUOLv/QgNtugplRHjEQRKqik65NeifTKzyRf0hhvBW1KWOkIoadP 3babK90zxgB9jGgUf/UNp4JC9Y+PrFYPgiRob7sYtSxpvX3uoVU0VosLdxIxxSp78Mvv nGxEaJzOsmX/d0hVbISOd5f0gVyHiJlADJFE4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+/n/16RZ52OxmA0UdDabSATFo04ROfy75nWG7tM3V6I=; b=rmIAAiwu1SWTVQTzDJcZ98GnNhGhi8w2bb9lKJmjaLpIfzihK5OIBUV0RLh0Wg+JCb UQ4FaoLc7JsE0jpIXpbIyWJOUww46wogr5UqP23R1e1DEuypaM3Qf0QTS3PqSCqHDYz1 UbWsjtmW9bRXYWWCKFiCJB2kx5eqoVqAZg9bBg7/RXgi3n7x/MHWT+nl2xbhOoBn60Y/ 9Ueh2qnyl0Um0l3Ed0bt+6DWGzQKnrMoXA47VqDy7tMoyYMNW74Lv8AS50TZEZJw4Bqe p3JyiaQSP8b5XBbtRhVFMy3G+ioFGTK1PQu1hu+joXuXy4arEsb2RQ52R2wZvsLpItWs Kqag== X-Gm-Message-State: AOAM530Qrzb2z2UIYVS86UHpnqJlKdNEfySbbC3hMrWebuH21goH5Ys6 91nSV+GZFBlX+Amd2V8xWHkJR7nbTa7Qdg== X-Google-Smtp-Source: ABdhPJxmKGvfzwrGcNB45zpKYvGa2R6htrHXkrCRtBsrNPeFRtFyXvFPfIN1bLeHK+Zv9iVuAwVA7Q== X-Received: by 2002:a1c:f60b:: with SMTP id w11mr2637250wmc.138.1644354518818; Tue, 08 Feb 2022 13:08:38 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id o14sm3033561wmr.3.2022.02.08.13.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 13:08:35 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH v2 05/19] fbdev/sysfs: Fix locking Date: Tue, 8 Feb 2022 22:08:10 +0100 Message-Id: <20220208210824.2238981-6-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220208210824.2238981-1-daniel.vetter@ffwll.ch> References: <20220208210824.2238981-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Daniel Vetter , Intel Graphics Development , LKML , Qing Wang , Daniel Vetter , Sam Ravnborg , Helge Deller Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" fb_set_var requires we hold the fb_info lock. Or at least this now matches what the ioctl does ... Note that ps3fb and sh_mobile_lcdcfb are busted in different ways here, but I will not fix them up. Also in practice this isn't a big deal, because really variable fbdev state is actually protected by console_lock (because fbcon just doesn't bother with lock_fb_info() at all), and lock_fb_info protecting anything is really just a neat lie. But that's a much bigger fish to fry. Acked-by: Sam Ravnborg Signed-off-by: Daniel Vetter Cc: Helge Deller Cc: Daniel Vetter Cc: Qing Wang Cc: Sam Ravnborg --- drivers/video/fbdev/core/fbsysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c index 26892940c213..8c1ee9ecec3d 100644 --- a/drivers/video/fbdev/core/fbsysfs.c +++ b/drivers/video/fbdev/core/fbsysfs.c @@ -91,9 +91,11 @@ static int activate(struct fb_info *fb_info, struct fb_var_screeninfo *var) var->activate |= FB_ACTIVATE_FORCE; console_lock(); + lock_fb_info(fb_info); err = fb_set_var(fb_info, var); if (!err) fbcon_update_vcs(fb_info, var->activate & FB_ACTIVATE_ALL); + unlock_fb_info(fb_info); console_unlock(); if (err) return err; -- 2.34.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF1C2C433F5 for ; Tue, 8 Feb 2022 21:08:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 33AFB10E4AD; Tue, 8 Feb 2022 21:08:42 +0000 (UTC) Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6523810E515 for ; Tue, 8 Feb 2022 21:08:40 +0000 (UTC) Received: by mail-wm1-x330.google.com with SMTP id n8so144347wmk.3 for ; Tue, 08 Feb 2022 13:08:40 -0800 (PST) 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=+/n/16RZ52OxmA0UdDabSATFo04ROfy75nWG7tM3V6I=; b=hRasZriqWBEeJzoUOLv/QgNtugplRHjEQRKqik65NeifTKzyRf0hhvBW1KWOkIoadP 3babK90zxgB9jGgUf/UNp4JC9Y+PrFYPgiRob7sYtSxpvX3uoVU0VosLdxIxxSp78Mvv nGxEaJzOsmX/d0hVbISOd5f0gVyHiJlADJFE4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+/n/16RZ52OxmA0UdDabSATFo04ROfy75nWG7tM3V6I=; b=QwDMSrtdT7iNMiKhKe26dU7ueETGmQ/1cWwyZbhjUjdyrNzFUtawkNKTb++Dfl7DDG yf9VwCkjNaMm3IZQXjg7wwHi66/7c07SC/AUjukvCrPfNdWtup+IG1BSTzqxzo+lUbjz zi8vY2FCsv8xJOxzJsTuHIr/zLXaLQU4Oi2lltyFzahPfqRPJxGurI2dmZF3hxnF0HhB vrA4OVtLccCJdDSqP4PjEMyJJJoTDu0wwiPnxW7RtpVu8ULUbrn5hiEp34g+us9rzc1x QE1qhuhu2hzOdYHQ82A9GGnH4Xa1uRIa3PbDaMbQ1hDbeBhn1FaWkqerGsb4IYdk4rQd FTWA== X-Gm-Message-State: AOAM533cVxQZA1y8y51qMTCJ12E/ETSlA3FkDMVvryRbPSm9dXRow23X 38BqYzvzTdhncy176yw6l/LlrA== X-Google-Smtp-Source: ABdhPJxmKGvfzwrGcNB45zpKYvGa2R6htrHXkrCRtBsrNPeFRtFyXvFPfIN1bLeHK+Zv9iVuAwVA7Q== X-Received: by 2002:a1c:f60b:: with SMTP id w11mr2637250wmc.138.1644354518818; Tue, 08 Feb 2022 13:08:38 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id o14sm3033561wmr.3.2022.02.08.13.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 13:08:35 -0800 (PST) From: Daniel Vetter To: DRI Development Date: Tue, 8 Feb 2022 22:08:10 +0100 Message-Id: <20220208210824.2238981-6-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220208210824.2238981-1-daniel.vetter@ffwll.ch> References: <20220208210824.2238981-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Intel-gfx] [PATCH v2 05/19] fbdev/sysfs: Fix locking X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Daniel Vetter , Intel Graphics Development , LKML , Qing Wang , Daniel Vetter , Sam Ravnborg , Helge Deller Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" fb_set_var requires we hold the fb_info lock. Or at least this now matches what the ioctl does ... Note that ps3fb and sh_mobile_lcdcfb are busted in different ways here, but I will not fix them up. Also in practice this isn't a big deal, because really variable fbdev state is actually protected by console_lock (because fbcon just doesn't bother with lock_fb_info() at all), and lock_fb_info protecting anything is really just a neat lie. But that's a much bigger fish to fry. Acked-by: Sam Ravnborg Signed-off-by: Daniel Vetter Cc: Helge Deller Cc: Daniel Vetter Cc: Qing Wang Cc: Sam Ravnborg --- drivers/video/fbdev/core/fbsysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c index 26892940c213..8c1ee9ecec3d 100644 --- a/drivers/video/fbdev/core/fbsysfs.c +++ b/drivers/video/fbdev/core/fbsysfs.c @@ -91,9 +91,11 @@ static int activate(struct fb_info *fb_info, struct fb_var_screeninfo *var) var->activate |= FB_ACTIVATE_FORCE; console_lock(); + lock_fb_info(fb_info); err = fb_set_var(fb_info, var); if (!err) fbcon_update_vcs(fb_info, var->activate & FB_ACTIVATE_ALL); + unlock_fb_info(fb_info); console_unlock(); if (err) return err; -- 2.34.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29FE7C43219 for ; Tue, 8 Feb 2022 22:26:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386500AbiBHWZr (ORCPT ); Tue, 8 Feb 2022 17:25:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386712AbiBHVIl (ORCPT ); Tue, 8 Feb 2022 16:08:41 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42295C0612B8 for ; Tue, 8 Feb 2022 13:08:40 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id l12-20020a7bc34c000000b003467c58cbdfso1996710wmj.2 for ; Tue, 08 Feb 2022 13:08:40 -0800 (PST) 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=+/n/16RZ52OxmA0UdDabSATFo04ROfy75nWG7tM3V6I=; b=hRasZriqWBEeJzoUOLv/QgNtugplRHjEQRKqik65NeifTKzyRf0hhvBW1KWOkIoadP 3babK90zxgB9jGgUf/UNp4JC9Y+PrFYPgiRob7sYtSxpvX3uoVU0VosLdxIxxSp78Mvv nGxEaJzOsmX/d0hVbISOd5f0gVyHiJlADJFE4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+/n/16RZ52OxmA0UdDabSATFo04ROfy75nWG7tM3V6I=; b=s01LMQKXAEd4+6r0T4GkZlVlHp/QREockh9/wher2pNYIuB7NSNIgvjgZTw4PvABmf 5Dr0DGxtOBS+BL+Y51j39jReNFphdqm0dNqrn2vBiQON4ychWIkG1VPewdb9lfgnmGHf TXZ9xWrlIKrk+2J01nWNTZNB9n3AEsKcJnsci8MUwXMg0TwC2k2XGDu33oQm/9Nel9w6 u51Yp3P6Bk9ANMUrHMX1PoMDnVN4JSYdAL2Zk2WRpWxTwYHUKLjIHvdMaE6ql/UF8nIn PghNb8Dj7Bzfh3AU9uVZX7m7RY+Rigm1lfth5e5vipsK+VYpC9RVKiKx5qfQBcSkG1UC 6Z7Q== X-Gm-Message-State: AOAM5310n/EdBsZhInrdhR8xBFzbW7EckUIjMvKsDq0+MrPMVLpY1inf KIjYYHJtntBt2wuvkTMdx3V54w== X-Google-Smtp-Source: ABdhPJxmKGvfzwrGcNB45zpKYvGa2R6htrHXkrCRtBsrNPeFRtFyXvFPfIN1bLeHK+Zv9iVuAwVA7Q== X-Received: by 2002:a1c:f60b:: with SMTP id w11mr2637250wmc.138.1644354518818; Tue, 08 Feb 2022 13:08:38 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id o14sm3033561wmr.3.2022.02.08.13.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 13:08:35 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Sam Ravnborg , Daniel Vetter , Helge Deller , Daniel Vetter , Qing Wang Subject: [PATCH v2 05/19] fbdev/sysfs: Fix locking Date: Tue, 8 Feb 2022 22:08:10 +0100 Message-Id: <20220208210824.2238981-6-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220208210824.2238981-1-daniel.vetter@ffwll.ch> References: <20220208210824.2238981-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fb_set_var requires we hold the fb_info lock. Or at least this now matches what the ioctl does ... Note that ps3fb and sh_mobile_lcdcfb are busted in different ways here, but I will not fix them up. Also in practice this isn't a big deal, because really variable fbdev state is actually protected by console_lock (because fbcon just doesn't bother with lock_fb_info() at all), and lock_fb_info protecting anything is really just a neat lie. But that's a much bigger fish to fry. Acked-by: Sam Ravnborg Signed-off-by: Daniel Vetter Cc: Helge Deller Cc: Daniel Vetter Cc: Qing Wang Cc: Sam Ravnborg --- drivers/video/fbdev/core/fbsysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c index 26892940c213..8c1ee9ecec3d 100644 --- a/drivers/video/fbdev/core/fbsysfs.c +++ b/drivers/video/fbdev/core/fbsysfs.c @@ -91,9 +91,11 @@ static int activate(struct fb_info *fb_info, struct fb_var_screeninfo *var) var->activate |= FB_ACTIVATE_FORCE; console_lock(); + lock_fb_info(fb_info); err = fb_set_var(fb_info, var); if (!err) fbcon_update_vcs(fb_info, var->activate & FB_ACTIVATE_ALL); + unlock_fb_info(fb_info); console_unlock(); if (err) return err; -- 2.34.1