Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2809914imb; Mon, 4 Mar 2019 15:04:07 -0800 (PST) X-Google-Smtp-Source: APXvYqxXjaWT1e2bW978imh7RXn2wLTSRg/fUiPmA81YZ8M5eYzUOZiXBxmQ4KXS7/nmkqSGod3G X-Received: by 2002:a63:f648:: with SMTP id u8mr20235048pgj.91.1551740647352; Mon, 04 Mar 2019 15:04:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551740647; cv=none; d=google.com; s=arc-20160816; b=uY+DXIEsWLw8fj49e1AqDfyABotBawk45RgmBCFXukiXKiq/wAbIZX7ZOwEQ8DJpji MAw5p+ExddsTSkzB43Mo6KsFanEyYPuVH7LBpYA+h4QWmPHDKol2MkNIjugn+39KMdva EsHeMo1MX6J3UD6p6FHdienE/CK6/V2n1BV7HKTgQBWuzCpK3S2Cwm1QkORUOjnbuMe1 5lAy3x66B4t/UtitPxUyQ1Mn3A+1C5K0PQ0kWlaI4bt/fd3TeogeaeNOtIigSfJv0YaA dXm1ANT9v5NZl6SGyR27LcdeCpdQCbrV5+LGI5gftUh0a3LXxAckYVGbNawquRRhgIRz xECw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=lOequsK7U6pqiLjdzbs1qq71XmnKT9STdt3Jb7jtbfE=; b=uAJGKPyCEMYgQr7LmsA1xQKBNz0uP1QZQdaz6MgByig4+SdTX7HJHe6QsTcfczAqQ/ EGM+d+4d0/9MSP+tQqlKmRrrKd+3D7rNNsPgpjTaT8PoHRGi2BwXKXIWjaxsg4uTcsRD 6Wpe6DiONKj5LK/nHUjPDXtTVfQg2gA/vH7WSKSm05OV/OYcDda9xAeIwnXz4qH0nE+z 1sYd04PMVKnFzUJZKXyKIiMcYpfmyDnajUbmtr4srw14TQAHpvLeH5PKKYVbxfsgDivv j93dtXmJVu3cPylxcl150n+9vBm3GAOH4BYZJa/Vj2tcbWkIAv0D5RzH5invtiiMXoQ7 +ABA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tomli.me header.s=1490979754 header.b=Jq6CjdVv; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tomli.me Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si6991135pln.403.2019.03.04.15.03.50; Mon, 04 Mar 2019 15:04:07 -0800 (PST) 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=@tomli.me header.s=1490979754 header.b=Jq6CjdVv; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tomli.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726683AbfCDXDE (ORCPT + 99 others); Mon, 4 Mar 2019 18:03:04 -0500 Received: from tomli.me ([153.92.126.73]:44234 "EHLO tomli.me" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726101AbfCDXDE (ORCPT ); Mon, 4 Mar 2019 18:03:04 -0500 Received: from tomli.me (localhost [127.0.0.1]) by tomli.me (OpenSMTPD) with ESMTP id 35d58dcf; Mon, 4 Mar 2019 23:03:02 +0000 (UTC) X-HELO: localhost.lan Authentication-Results: tomli.me; auth=pass (login) smtp.auth=tomli Received: from Unknown (HELO localhost.lan) (2402:f000:1:1501:200:5efe:72f4:b31) by tomli.me (qpsmtpd/0.95) with ESMTPSA (DHE-RSA-CHACHA20-POLY1305 encrypted); Mon, 04 Mar 2019 23:03:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=tomli.me; h=from:to:cc:subject:date:message-id:mime-version:content-transfer-encoding; s=1490979754; bh=80yglazwl3UL+DZyu+wSlOx1EjgHcRsO49j0Mo81qIE=; b=Jq6CjdVvCSzwVM/fKXoHPpoO1tJc4LC3l9jtqPoF+8PJEcnY5Q5z7Ohlu/udCSfmJjtezAX757H+BYmFtpUYpSUoBQ16z++NNQ2GsmdyzuFlZ1JjUXg8/T4lHd9ZtC76wyT1p/mljqh/QvrVAf1mPmXTgqtBb4BYmYktIx5vudh7oLikkdMn6OPmd/wZPRQPXu/tD9Oza8zZbBt+XJtypTBgKebjnD3Cum0lASXyjFyF8sjCk9hF5h1R+/3fAzKOIsXTdZ8PWlmlmGa0zDWU13EeWkgOj+3sThG1EordVcDQdQknNTG4lx05GLv8dI0tt6O+QmQDwQ1uonx6lQsWlw== From: Yifeng Li To: Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org Cc: Yifeng Li , Nicolas Pitre , Adam Borowski , Mikulas Patocka , Alexander Potapenko , Mike Frysinger , Daniel Vetter Subject: [PATCH RESEND] tty: vt.c: Fix TIOCL_BLANKSCREEN console blanking if blankinterval == 0 Date: Tue, 5 Mar 2019 07:02:49 +0800 Message-Id: <20190304230249.26143-1-tomli@tomli.me> X-Mailer: git-send-email 2.20.1 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 Previously, in the userspace, it was possible to use the "setterm" command from util-linux to blank the VT console by default, using the following command. According to the man page, > The force option keeps the screen blank even if a key is pressed. It was implemented by calling TIOCL_BLANKSCREEN. case BLANKSCREEN: ioctlarg = TIOCL_BLANKSCREEN; if (ioctl(STDIN_FILENO, TIOCLINUX, &ioctlarg)) warn(_("cannot force blank")); break; However, after Linux 4.12, this command ceased to work anymore, which is unexpected. By inspecting the kernel source, it shows that the issue was triggered by the side-effect from commit a4199f5eb809 ("tty: Disable default console blanking interval"). The console blanking is implemented by function do_blank_screen() in vt.c: "blank_state" will be initialized to "blank_normal_wait" in con_init() if AND ONLY IF ("blankinterval" > 0). If "blankinterval" is 0, "blank_state" will be "blank_off" (== 0), and a call to do_blank_screen() will always abort, even if a forced blanking is required from the user by calling TIOCL_BLANKSCREEN, the console won't be blanked. This behavior is unexpected from a user's point-of-view, since it's not mentioned in any documentation. The setterm man page suggests it will always work, and the kernel comments in uapi/linux/tiocl.h says > /* keep screen blank even if a key is pressed */ > #define TIOCL_BLANKSCREEN 14 To fix it, we simply remove the "blank_state != blank_off" check, as pointed out by Nicolas Pitre, this check doesn't logically make sense and it's safe to remove. Suggested-by: Nicolas Pitre Fixes: a4199f5eb809 ("tty: Disable default console blanking interval") Signed-off-by: Yifeng Li --- drivers/tty/vt/vt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 41ec8e5010f3..279f5b2ac44a 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4168,8 +4168,6 @@ void do_blank_screen(int entering_gfx) return; } - if (blank_state != blank_normal_wait) - return; blank_state = blank_off; /* don't blank graphics */ -- 2.20.1