Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4766495ybi; Tue, 28 May 2019 02:06:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyu6RDbGGmaD9w6kdkAZ4KUV5nSeErHwMg/DMmt/qmrF2Z7QqVb5WrNY4mBoCNrM+/BaJzN X-Received: by 2002:aa7:90ca:: with SMTP id k10mr141573481pfk.20.1559034372723; Tue, 28 May 2019 02:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559034372; cv=none; d=google.com; s=arc-20160816; b=Pj4r9LRrtJCkVY7EJ9WouvPdQZngkn3sCI6/eYv7v8k2IzNDByVSIKYNCc002d/Bv2 VmWSze1GFnwj1WLCOCAWDAV/5orcnxfUracBcU7nNN/IdczDh+RqKHLByE23Yo1gxPgQ T4+dXtjMrHYegn0Vp3/mEJ9pVQr0tv8T42dLSUtrytc300+FlmsNlzO02u6iThjqc7RZ IMeGul2CCqJ+Mh4+N6/82SWvkr1mxLz3SbV7QmVbOiICnUvu/aMnKac+H9eIClS8vJUH g7rUQ6zqg3XQU+kubNE5fNIenlRzcurPVaQgf0PSjDXKz6nUPKsSCBKpzEN6Z+MF44Kt nEBA== 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=KOGyYDuulYoZlGMMrGlYnho9Xow/hNHN2r6g5KqqxbA=; b=aLv9u8ryC3PIGtpeA9rXpuk6XEq45F+3btBThKm7b5BV25m9JjAJhb08P5k6GIO0s2 Vz6AHdpetARZIV3munHyD+OVknp63LHiEDIlIeqm9J9Xr4jWeC9dGSnB30hA/ATWqgd6 WBH//nfCraoeQIysVoNkwtQCZnNa6SBYJOWq5B8cMWdg/eNNx03kpdwPUvFKLRPrvJz0 Lr6F1oDL+Gsn6WjPkiMAYBhQKElfsTKEpLmOVXnLMyqFO5z+eFszjAv/X9OIvgVdw4ia lKYey2orLvzxh+tDMCagYuS+WdhIixNW8t7tO81G3X25teFXNfTc7RIMQM6wsEzZVzBT RfCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=LmD9YyG7; 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 d62si21161181pga.447.2019.05.28.02.05.55; Tue, 28 May 2019 02:06:12 -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=LmD9YyG7; 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 S1727356AbfE1JEJ (ORCPT + 99 others); Tue, 28 May 2019 05:04:09 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:36052 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727296AbfE1JD5 (ORCPT ); Tue, 28 May 2019 05:03:57 -0400 Received: by mail-ed1-f67.google.com with SMTP id a8so30641126edx.3 for ; Tue, 28 May 2019 02:03:57 -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=KOGyYDuulYoZlGMMrGlYnho9Xow/hNHN2r6g5KqqxbA=; b=LmD9YyG7s+OqvV8GaC+iTvVDRdtjPeq/zghiL4J+/ZI7u5Eg21vxnuzwTFovpBti8O 3LjHgkfSbO5QNC3qJK3ek9epxYfj2V3oUkdq1yYwA2dDDqa0UrVbBDP43PYt6yNfhlLc AWLn+vFL5yhJ8lJhJdU43jJDDzQDEKyiJifa4= 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=KOGyYDuulYoZlGMMrGlYnho9Xow/hNHN2r6g5KqqxbA=; b=NiNbkrbQ28lP+njWdmc23AOOzDj7cLEGYsZPwEjZAx5zO87rvixxhs5I9CO9UXBZ1l im61ciwBghAoynJh7qVE2YQIuMzfw+1ScRzy13DX1/0tLreZ0glR5pj80ost1nIvA0S3 KdfidlVTCY40z+o/qRNtA5JgtqVME4BCEkFREadAr2uI8WnI4pmwEiYrN3sOYguOZzhS fJtzLwXvhwF6/HG6F9BGjykDMAB25xn0A5vHLpYQgyjfZYViSdE2AvpJMNUw53qwMC3N g4tTy4EfGdrbDZdf7SfOiA3BXh7ojUEgpVELvfeQJDB9nmc86c06MVhkH/Lo4RTcVycI W8NA== X-Gm-Message-State: APjAAAWwFzsjj4BuZNxi4Wgjtp5vJZ+0HHtAVrNsiYEO/I+Midmj1XC2 pamA2EQtEaJv7o4Xek9xNhUupz6b+N8= X-Received: by 2002:a50:e048:: with SMTP id g8mr128055262edl.26.1559034236177; Tue, 28 May 2019 02:03:56 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id x49sm4072656edm.25.2019.05.28.02.03.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 02:03:55 -0700 (PDT) From: Daniel Vetter To: LKML Cc: DRI Development , Intel Graphics Development , linux-fbdev@vger.kernel.org, Daniel Thompson , Bartlomiej Zolnierkiewicz , Daniel Vetter , Daniel Vetter , Sam Ravnborg , Maarten Lankhorst , Hans de Goede , Yisheng Xie Subject: [PATCH 31/33] fbcon: Document what I learned about fbcon locking Date: Tue, 28 May 2019 11:03:02 +0200 Message-Id: <20190528090304.9388-32-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190528090304.9388-1-daniel.vetter@ffwll.ch> References: <20190528090304.9388-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 Reviewed-by: Sam Ravnborg Reviewed-by: Maarten Lankhorst 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 fbd28aeff307..d6ba3610ee83 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