Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp171289ybi; Fri, 24 May 2019 01:57:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTcNhwdfnOhSc2RbVLH90ntah2xb3bSOnDRU4D8f7H0GMW5BQtB1pEr6zbBmeCzizglXfk X-Received: by 2002:a17:902:b094:: with SMTP id p20mr80049414plr.164.1558688221103; Fri, 24 May 2019 01:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558688221; cv=none; d=google.com; s=arc-20160816; b=BK2nzSRMyV4sa5/lTtNQP/k/j+CfXrsVEH5ZETMN5PQax9CvVQsxqtiwZb86UcDG/t 3zddFjNzYhx+qPsPafm7Sj0JfyVtrKwAHCqf40eHLx/EkQl3/V61quezvGNnMDpErBEP nscw4O2BY+eN7mJ36OTfB1P1JXtoodkdtRnEfrsugN0mo6aWfgFOL5BEJiSjnW6888nu eHatUGZJejCEp5HHqz3TJH+6w64CBeoZ/4ricOXtMpOjYszFxCEd6+atV01s5vUMzyUG xnLwLhUAkfHVWO2dlluG5fLMxdF8sKEZAhMNBcTkKRYsJ4AyCNzJUFfCpgP9tzo9m6qI xPDw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3VFKuM3MW7HhJw8g+F0ZAMGgocYe76vTXpU+uF+1TQo=; b=RgrixLrJyH5zZJZjBvhrEubAjycHiWYOwam4Iv+P2DVjXLODyoXMgbe3fujDCP5wcr oGj/ngMmEJeURG2E6vwr2dqyXWITFp3UB6Jd/BjVkv4NfNFEgkIX7+1PKJJBuq+xdeS3 0EMvy9hNAuGGbczBoqzEDVNX4p7h3p2HUchCPaJCxoUNSwGwcEnVmNnwIyI4juyr4nVs JaHBaNrUV15BkOAKtu5m5IYxdvB5sfD50nCFPretVMdqnDKi3LdvfkEAukW+eIvwoUj2 GZ1Zv3Gu/8JH4KtoX8MM4SKuFkfciCElvx2fajN5HeDSA/PwN4EX7kEhiJndyAC91ae2 wwVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=cvyCEwSj; 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 q3si2959930pgg.407.2019.05.24.01.56.42; Fri, 24 May 2019 01:57:01 -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=@ffwll.ch header.s=google header.b=cvyCEwSj; 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 S2390272AbfEXIyr (ORCPT + 99 others); Fri, 24 May 2019 04:54:47 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:34401 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390179AbfEXIyo (ORCPT ); Fri, 24 May 2019 04:54:44 -0400 Received: by mail-ed1-f68.google.com with SMTP id p27so13377867eda.1 for ; Fri, 24 May 2019 01:54:43 -0700 (PDT) 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=3VFKuM3MW7HhJw8g+F0ZAMGgocYe76vTXpU+uF+1TQo=; b=cvyCEwSj1QIHhiUcfE6glzcCA2U8gdeQg0UJH+eLHNVqhr9yA74lr76XhDC68i/K4s ySqXKthJaclCts4kf7qGy4NZyjN9KsaoOAoblQUPftMCEF/SeQQBYvkHtmqPvnJ5Mrm+ 4wMOGUPvzJhyy1ifC2pEL2npDGzuVq8hf/6JQ= 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=3VFKuM3MW7HhJw8g+F0ZAMGgocYe76vTXpU+uF+1TQo=; b=nhFCWMM3Ev89fmil6EFcmhCv9QF84ewowXfBgvDjk2gubUp35YRAPSSElEXJiQ/0nH jfOLfoyQ7JC9BqgQ8KSTPDhCO+S9eCnXy0OwgGnHM/LpGsOCgAyvbBwgb0z2KK/HdJAv uVTBIXumLbzFdVF+6MPRu48xios0r84Xxl+iFg2hNVrtACKAFSemtvpdn+Hq/irSdymz Y/ihycBRH9r/uC7WIKWAmHtu84+KCIaqDVMSU/sAeHKiiEUodydQFz7Zm/+gm40ZOTD6 Eq3O+/BVf0MEvecXEq4iT+XxUEbGxdg6equoDW6phgzZ9zaoAx2HhNtcIc7yhYQAtUSl A72w== X-Gm-Message-State: APjAAAXx1ML3DTLcX4rKt1ya5lSQIl0+9SZGq4qP9zBpni15cmTq8iF5 /6sxMecTYf8N7YRmsa+RreWCOYIr4Jc= X-Received: by 2002:a17:906:2ac5:: with SMTP id m5mr81917352eje.71.1558688082399; Fri, 24 May 2019 01:54:42 -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.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 May 2019 01:54:41 -0700 (PDT) From: Daniel Vetter To: LKML Cc: Intel Graphics Development , DRI Development , Daniel Vetter , Daniel Vetter , Bartlomiej Zolnierkiewicz , Hans de Goede , Yisheng Xie Subject: [PATCH 31/33] fbcon: Document what I learned about fbcon locking Date: Fri, 24 May 2019 10:53:52 +0200 Message-Id: <20190524085354.27411-32-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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's not pretty. Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Bartlomiej Zolnierkiewicz Cc: Hans de Goede Cc: Yisheng Xie --- drivers/video/fbdev/core/fbcon.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 6a4bbb8407c0..8444d5151c2d 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -88,6 +88,25 @@ # define DPRINTK(fmt, args...) #endif +/* + * FIXME: Locking + * + * - fbcon state itself is protected by the console_lock, and the code does a + * pretty good job at making sure that lock is held everywhere it's needed. + * + * - access to the registered_fb array is entirely unprotected. This should use + * proper object lifetime handling, i.e. get/put_fb_info. This also means + * switching from indices to proper pointers for fb_info everywhere. + * + * - fbcon doesn't bother with fb_lock/unlock at all. This is buggy, since it + * means concurrent access to the same fbdev from both fbcon and userspace + * will blow up. To fix this all fbcon calls from fbmem.c need to be moved out + * of fb_lock/unlock protected sections, since otherwise we'll recurse and + * deadlock eventually. Aside: Due to these deadlock issues the fbdev code in + * fbmem.c cannot use locking asserts, and there's lots of callers which get + * the rules wrong, e.g. fbsysfs.c entirely missed fb_lock/unlock calls too. + */ + enum { FBCON_LOGO_CANSHOW = -1, /* the logo can be shown */ FBCON_LOGO_DRAW = -2, /* draw the logo to a console */ -- 2.20.1