From patchwork Thu Jan 10 00:17:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 155111 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1294109jaa; Wed, 9 Jan 2019 16:17:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN5bFa8RJTHgkmJzbFtRI+wmOMgQGGo98MxMn6CW4WUCZ0YF9ZqXx20ptfL/1k6eR6hiuvq1 X-Received: by 2002:a17:902:3181:: with SMTP id x1mr8082366plb.58.1547079446293; Wed, 09 Jan 2019 16:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547079446; cv=none; d=google.com; s=arc-20160816; b=QNADI81NuUI1pBfpOjH9qJSfjKEQzn6R8VQazp/suZuUK48o8JZiZTWCafmgrKSuOs vpN53bx30/rvpaEWQSqCs6EKJI4CHCb4cq/U6g4YgEkTochVKycdO0xwgrcur5S/d77e xFY+kNXhfsJMNKqfzsNt9ZSwK/ObPGP+NcDdBJnEX8WPL+yFDkcO1d/NKA0ekRHdOomi MnY/FRyHI53wW0GyWBMspGQ2zt3DeGpsI3qFz9TRYX/JoRDrx7MpOK+v/HjFmfIMU09Z 5sutMrrh0hKOV4c7ZYJR6SgbAUmnysfAlzFOr6X9Q7ZGeoRc9/smDT4qwNZNabRKve37 YeNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:dkim-signature; bh=qcc0vpPwlj953Qdb+Xr4syq8PvGm8X0FWC3fECLLsco=; b=m2DWNhJ5O+fmvjbCLYktcfWHKzjrJt98gHeelrmtUQey/PWIdtLuJf7ROBW26oU5KU 6KwtMh/hc3hbxZWzEA/f1KDuFIlEB8F74RxEK848jYzfjBPXKiUwFf/kgc7BhVc/mvQ8 Xy5FUqbSVyoQdhq0LE/9vF/zgD6WuaezKMCT0UJms1fqDzYzGyNbSVobf+RS0UDhWI/W kk6bdHozYBP+na/3MfITZLPz5QJ3paRKVX3bH0gvMmIihf00HNtKgGCqpIDxFDYB12IG wed3qNYeMm5Yl9HtAJ0wsYckuBk26YtueoZizoWhhOVB5PxaPMBahuz2HhUUEaFyoIrY FvKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EpUkk7gO; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7si25859815pll.297.2019.01.09.16.17.25; Wed, 09 Jan 2019 16:17:26 -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=@linaro.org header.s=google header.b=EpUkk7gO; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726887AbfAJARY (ORCPT + 31 others); Wed, 9 Jan 2019 19:17:24 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:47045 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726286AbfAJARY (ORCPT ); Wed, 9 Jan 2019 19:17:24 -0500 Received: by mail-qt1-f196.google.com with SMTP id y20so10467631qtm.13 for ; Wed, 09 Jan 2019 16:17:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=qcc0vpPwlj953Qdb+Xr4syq8PvGm8X0FWC3fECLLsco=; b=EpUkk7gO8LP9EZD/RPXcBb0ugDtO98RYty44nI7wqwvlkuvp9J56zY/T5WhEhzOjLu Oo9c1257iH6VrPDQzY3Oy17MVXzF43J6lpxFXj81qyapfA2WCyllb5qrgiBS3PbnuZtc q0CiIUPDVo1ZZpm0z4J0u0n/0S03OPqwBBBMY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version; bh=qcc0vpPwlj953Qdb+Xr4syq8PvGm8X0FWC3fECLLsco=; b=ieL1JMrBFXmdHsintgukzNeA1Tf47b0M61yG/tqSwO1+jtu/rzd9meoGBBdcgQ5Ham +VVk1oXwacdkA1UtVgNMQtBT47oxVdyial/pTfu64luJGFgBy/UgsxVcW/taG/6NSj1J TYg6xCbNFoXvlpf9DSBlAWzHtvE9sgZZMzsh1SRBcEDQU8teJmPGcld2YvozRakXzA67 9NkLbHkxYdsKIvY+QB+jK+2vByTDLil7dZwWdCEuj7b6skOXbJSdSJME5NGYo78ilEM7 Z6nReGEMBJ/xDnB0bk+hNSwlkVaj7e0i85uke3RdG5xeu2UicyJ5zcAxzQFkEbxGKHJj 0y5Q== X-Gm-Message-State: AJcUukfjrMuJloVXWatL4Zcplm0QSy9k3E/9yDIkpE0CWVtwdL7f4DSn SE1MZDtj0gy6qQbzfcpFjZiZhlXTrMk= X-Received: by 2002:aed:2558:: with SMTP id w24mr7626698qtc.183.1547079443457; Wed, 09 Jan 2019 16:17:23 -0800 (PST) Received: from xanadu.home (modemcable228.104-82-70.mc.videotron.ca. [70.82.104.228]) by smtp.gmail.com with ESMTPSA id d199sm33404852qkc.76.2019.01.09.16.17.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Jan 2019 16:17:22 -0800 (PST) Date: Wed, 9 Jan 2019 19:17:20 -0500 (EST) From: Nicolas Pitre To: Greg Kroah-Hartman cc: Dave Mielke , linux-kernel@vger.kernel.org Subject: [PATCH 7/6] vcs: restore and document initial POLLPRI event Message-ID: User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Restore and document the forced initial POLLPRI event reporting when poll() is used for the first time. This used to be the implemented behavior before recent changes. Because of the way poll() is implemented, this prevents losing an event happening between the last read() and the first poll() invocation. Since poll() for /dev/vcs* was not always supported, user space probes for its availability as follows: int fd = open("/dev/vcsa", O_RDONLY); struct pollfd p = { .fd = fd, .events = POLLPRI }; available = (poll(&p, 1, 0) == 1); Semantically, it makes sense to signal the first event as such even if it might be spurious. The screen could be modified, and modified back to its initial state before we get to read it, so users must be prepared for that anyway. Signed-off-by: Nicolas Pitre diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c index 1d887113ff..160f46115a 100644 --- a/drivers/tty/vt/vc_screen.c +++ b/drivers/tty/vt/vc_screen.c @@ -140,6 +140,15 @@ vcs_poll_data_get(struct file *file) poll->cons_num = console(file_inode(file)); init_waitqueue_head(&poll->waitq); poll->notifier.notifier_call = vcs_notifier; + /* + * In order not to lose any update event, we must pretend one might + * have occurred before we have a chance to register our notifier. + * This is also how user space has come to detect which kernels + * support POLLPRI on /dev/vcs* devices i.e. using poll() with + * POLLPRI and a zero timeout. + */ + poll->event = VT_UPDATE; + if (register_vt_notifier(&poll->notifier) != 0) { kfree(poll); return NULL;