From patchwork Fri May 24 08:53:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10959477 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 AFEBD112C for ; Fri, 24 May 2019 08:55:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CC692884B for ; Fri, 24 May 2019 08:55:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90F9028852; Fri, 24 May 2019 08:55:36 +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=unavailable 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 406BA2884B for ; Fri, 24 May 2019 08:55:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 87A8E6E0E2; Fri, 24 May 2019 08:54:42 +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 CB3406E0E2 for ; Fri, 24 May 2019 08:54:37 +0000 (UTC) Received: by mail-ed1-x542.google.com with SMTP id w33so9959751edb.10 for ; Fri, 24 May 2019 01:54:37 -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=P4e/xA+I/fhaekwevrCcRa/WCV1s4I3VGahknPkyNJ8=; b=TNuk8mRye/7gSIs74tRSLLzaLAI9M5xi5EStALfrOm9m5I4iRpx0FmSHKFTdrnNu+w sKH8RWLNmKG8KL0YC2XcQ8nPPC4KWJzuypLLbZNipLEvP7ldGM7/JRWeRZqm6gqccjmV uilmTsMJfPBEEp34J884EK2HqEs9KmSTm9X4n60hfVTuPaN7BH2f8sSGF5W+dlZcvMai tngF3L7vZ+UGYZENHA2M9BaX4WCNoZCW21jy33UO8RjX9llOGaI7/C0uXkd3Jwdp5JaI 2PkUlbUdProTW5v2Bd7uw23cSekoPrrg7LZ7dlfct7U8WeyOq3wz5zHcWVvDRYfP/Yjl 8Vdg== X-Gm-Message-State: APjAAAUxHrdGZq3+3/bC94QHf0PwtRqI2YT6R1JqoFIWpkl5mTaScHT/ jcUJlbqNcno13yMdBlIKzSxX/Q== X-Google-Smtp-Source: APXvYqztLw67egkehMcTC0D7aOOl7kCrsaIONdyJQbJTsWM2Ee6cU0j3VtnNtoIBnwoKKiPK9mYc7Q== X-Received: by 2002:a17:906:118b:: with SMTP id n11mr36452581eja.291.1558688074794; Fri, 24 May 2019 01:54:34 -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.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 May 2019 01:54:34 -0700 (PDT) From: Daniel Vetter To: LKML Subject: [PATCH 25/33] fbmem: pull fbcon_fb_blanked out of fb_blank Date: Fri, 24 May 2019 10:53:46 +0200 Message-Id: <20190524085354.27411-26-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=P4e/xA+I/fhaekwevrCcRa/WCV1s4I3VGahknPkyNJ8=; b=A810gJ8GWO9JLhgelYpMe4TFBMIXycWgLfaVkfbkrCaTrhQyLYDXyGKqEYi8kAoorq cem9TmtMm1kAJpudc2v48wVUDX0URGUmSrceRicZ6S5+lhwS3NmeqM6dW/CWgqaYzVl+ rrdaVd8vNUpg0Dm2LN9ltsyau6kQbSdhChOFM= 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: Bartlomiej Zolnierkiewicz , Daniel Vetter , Intel Graphics Development , DRI Development , =?utf-8?b?TWljaGHFgiBN?= =?utf-8?b?aXJvc8WCYXc=?= , Hans de Goede , Mikulas Patocka , Daniel Vetter , Peter Rosin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP There's a callchain of: fbcon_fb_blaned -> do_(un)blank_screen -> consw->con_blank -> fbcon_blank -> fb_blank Things don't go horribly wrong because the BKL console_lock safes the day, but that's about it. And the seeming recursion is broken in 2 ways: - Starting from the fbdev ioctl we set FBINFO_MISC_USEREVENT, which tells the fbcon_blank code to not call fb_blank. This was required to not deadlock when recursing on the fb_notifier_chain mutex. - Starting from the con_blank hook we're getting saved by the console_blanked checks in do_blank/unblank_screen. Or at least that's my theory. Anyway, recursion isn't awesome, so let's stop it. Breaking the recursion avoids the need to be in the FBINFO_MISC_USEREVENT critical section, so lets move it out of that too. The astute reader will notice that fb_blank seems to require lock_fb_info(), which the fbcon code seems to ignore. I have no idea how to fix that problem, so let's keep ignoring it. v2: I forgot the sysfs blanking code. Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Bartlomiej Zolnierkiewicz Cc: "Michał Mirosław" Cc: Peter Rosin Cc: Hans de Goede Cc: Mikulas Patocka Cc: Rob Clark --- drivers/video/fbdev/core/fbmem.c | 4 +++- drivers/video/fbdev/core/fbsysfs.c | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 9366fbe99a58..d6713dce9e31 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1068,7 +1068,6 @@ fb_blank(struct fb_info *info, int blank) event.data = ␣ early_ret = fb_notifier_call_chain(FB_EARLY_EVENT_BLANK, &event); - fbcon_fb_blanked(info, blank); if (info->fbops->fb_blank) ret = info->fbops->fb_blank(blank, info); @@ -1198,6 +1197,9 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd, info->flags |= FBINFO_MISC_USEREVENT; ret = fb_blank(info, arg); info->flags &= ~FBINFO_MISC_USEREVENT; + + /* might again call into fb_blank */ + fbcon_fb_blanked(info, arg); unlock_fb_info(info); console_unlock(); break; diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c index 5f329278e55f..252d4f52d2a5 100644 --- a/drivers/video/fbdev/core/fbsysfs.c +++ b/drivers/video/fbdev/core/fbsysfs.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -305,12 +306,15 @@ static ssize_t store_blank(struct device *device, { struct fb_info *fb_info = dev_get_drvdata(device); char *last = NULL; - int err; + int err, arg; + arg = simple_strtoul(buf, &last, 0); console_lock(); fb_info->flags |= FBINFO_MISC_USEREVENT; - err = fb_blank(fb_info, simple_strtoul(buf, &last, 0)); + err = fb_blank(fb_info, arg); fb_info->flags &= ~FBINFO_MISC_USEREVENT; + /* might again call into fb_blank */ + fbcon_fb_blanked(fb_info, arg); console_unlock(); if (err < 0) return err;