Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2743449imj; Mon, 11 Feb 2019 07:50:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IaeNFcRmBtmdHnqrPWPP9ym67sbFMl775Kmw2xQDhs3u4vQWi6m4NThOH6H/WdUhjWcmHBc X-Received: by 2002:a65:6298:: with SMTP id f24mr34156669pgv.183.1549900236062; Mon, 11 Feb 2019 07:50:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900236; cv=none; d=google.com; s=arc-20160816; b=tuwiX/lDrdZEQHZravo39LY9jWfBNh2g1OUSpbbfS5mEtggry07qx3YINF7iYs+d8m 2txTUjpoMlvHlPXY/edmjo2w+teZ+LNzM9kOH98o/7zWO9ytHfdB2qUYSwNjtgizzlLy aRaorI1Ug6JIjzTTLTb1T4NYJTDZ2UFzFQ2X0q2FHGGHJrjCKbhoDCcT4KWGY14od3lt SOHpfoDMQ7jlXYOvSjHr0Ou6CiBoGhOlt6tYypmbH6oNnIkAuHGNXogn83H/wtN3fPGk F7e6x1YyEvn64l1QV0nOVEDGxwjg41uDnw3OKsLzEZ/dEXUv70yK9NbJgKJiF/98HU96 y5zA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gfvINp1zO69sz2frHY963Yifa/VEDIrOtBZ+crF8FVo=; b=IgGPBiXXJq4m+ZOeXJgWmoltJWgEip4BkGfVe6CV59SrhL8snnz8aJipHGGacmXoHP Z09AE/I2qLacWdql2sCNNkI9zKtsirwM8jQrs37KfSVjtV6zHIsteuEDbAA215h/vedD bjtwHkYg87Tjnf4v2rlWiQ+J1TrnmbkAGLBDk2M/2h2ukNk8J42m126O8s7C15Fw71w3 0sk3x6zHW5ronuSmpjN8IAi3nKb63Sa02vCq49i8anUOg+TS8T/28cFLvVIssvzB1RKo d/hTmy9JHXdO1+17jDMbXvnYq4hdC9OyZe+wslBCLVCv9iGCuOWOhxec4EdaX1xYcSAx 3REg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FWuVOWLV; 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 s9si4442918plr.316.2019.02.11.07.50.20; Mon, 11 Feb 2019 07:50:36 -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=@kernel.org header.s=default header.b=FWuVOWLV; 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 S1732351AbfBKPt2 (ORCPT + 99 others); Mon, 11 Feb 2019 10:49:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:50290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731932AbfBKOjr (ORCPT ); Mon, 11 Feb 2019 09:39:47 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 172B420838; Mon, 11 Feb 2019 14:39:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895986; bh=r73udR+Q3mSYZcz3Om2YB86lATPMF149DBRO4gpBFyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FWuVOWLVeIkKTIIVbNafeckgzR5NnAGHVLpzR7sM47llajyH5wKIoVyedQI/dWEEV sa2+vl25ijAe6b+mJRv8jPhidl6avWWpYUkLQHivtOJ6BkQI7oB3QpKuXh7ui//bXe xXV6EVdu6rLdfmFB5LEEGoUQFIwYSsmr3hD7K6Hw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Norris , Benson Leung , Sasha Levin Subject: [PATCH 4.19 036/313] platform/chrome: dont report EC_MKBP_EVENT_SENSOR_FIFO as wakeup Date: Mon, 11 Feb 2019 15:15:16 +0100 Message-Id: <20190211141855.892355941@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141852.749630980@linuxfoundation.org> References: <20190211141852.749630980@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 6ad16b78a039b45294b1ad5d69c14ac57b2fe706 ] EC_MKBP_EVENT_SENSOR_FIFO events can be triggered for a variety of reasons, and there are very few cases in which they should be treated as wakeup interrupts (particularly, when a certain MOTIONSENSE_MODULE_FLAG_* is set, but this is not even supported in the mainline cros_ec_sensor driver yet). Most of the time, they are benign sensor readings. In any case, the top-level cros_ec device doesn't know enough to determine that they should wake the system, and so it should not report the event. This would be the job of the cros_ec_sensors driver to parse. This patch adds checks to cros_ec_get_next_event() such that it doesn't signal 'wakeup' for events of type EC_MKBP_EVENT_SENSOR_FIFO. This patch is particularly relevant on devices like Scarlet (Rockchip RK3399 tablet, known as Acer Chromebook Tab 10), where the EC firmware reports sensor events much more frequently. This was causing /sys/power/wakeup_count to increase very frequently, often needlessly interrupting our ability to suspend the system. Signed-off-by: Brian Norris Signed-off-by: Benson Leung Signed-off-by: Sasha Levin --- drivers/platform/chrome/cros_ec_proto.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c index b6fd4838f60f..e5d5b1adb5a9 100644 --- a/drivers/platform/chrome/cros_ec_proto.c +++ b/drivers/platform/chrome/cros_ec_proto.c @@ -575,6 +575,7 @@ static int get_keyboard_state_event(struct cros_ec_device *ec_dev) int cros_ec_get_next_event(struct cros_ec_device *ec_dev, bool *wake_event) { + u8 event_type; u32 host_event; int ret; @@ -594,11 +595,22 @@ int cros_ec_get_next_event(struct cros_ec_device *ec_dev, bool *wake_event) return ret; if (wake_event) { + event_type = ec_dev->event_data.event_type; host_event = cros_ec_get_host_event(ec_dev); - /* Consider non-host_event as wake event */ - *wake_event = !host_event || - !!(host_event & ec_dev->host_event_wake_mask); + /* + * Sensor events need to be parsed by the sensor sub-device. + * Defer them, and don't report the wakeup here. + */ + if (event_type == EC_MKBP_EVENT_SENSOR_FIFO) + *wake_event = false; + /* Masked host-events should not count as wake events. */ + else if (host_event && + !(host_event & ec_dev->host_event_wake_mask)) + *wake_event = false; + /* Consider all other events as wake events. */ + else + *wake_event = true; } return ret; -- 2.19.1