Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3623738imu; Mon, 28 Jan 2019 08:02:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN4jvogwWMFjegJUdmXVNqgPBaL+7rvG9Cm34pmj5anHAQy1GdKh4GwaGFtTbNzeOH/3QMht X-Received: by 2002:a62:f54f:: with SMTP id n76mr22459790pfh.59.1548691328315; Mon, 28 Jan 2019 08:02:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691328; cv=none; d=google.com; s=arc-20160816; b=PyYkKsFBXTBOcVMdzIpLi/1/18ouV2uwENpRjr30bVnbtCa7FORY9O7GNL9PgiOiBJ 48cKbvbBARf0Tk6Sj/Maib/KzKVyylNjCEvndSf8QQJsp644uMpX9UjSR3FZHOj0zgBA XASJ7i2z5CbiTgy0Tt6bMMaud1zAnr/Yy3q02/uz7SvzDc2j/er/WIUB3CJtG00rgGqp EdpY7ql2tHc7r/aNiC+vhBBxQs4v0ft0OzKW4PvfICngIMhMrtqaznbGJzl55t3GjJk8 rysWO4TuunwPt3cs9SufoAzHwDjQGqldNn7D8OwYXIuX8Yi9gsO0QAb0i1VgBptKDQBw /e9w== 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=1ZfZlhhzaRs/lo4YVZCTT3rmrg0ePXg+t/xeyoUmX30=; b=MIq33NXcZ2ZyKdiPQ/LuA0ardAUHlCO4HtpAkk33aTDszyWvhUbhx0CBRg5VYVXu8o OGqHsF+a1DsnKrU0Nbd2c6MLQv7rfg3aT58y/2JMlDl7kMf9FXURLnG4Nx97usdBvapk LpriK+E5yi9iD/EcWhqjwPvTZxVvxKuITC3EJ++v3MwLjyTp24dNIais8JAlveHUFUzx G8/RO0Speu1Ad3LKauPN4meMagkVeHkrqdge/p67u+ICMYT+2Fz67oDG610BIo1V2SyT OY2F93rK5JizZbzO9aNke2LAkh8SdG0fJCwDQVyHDw+lwecUurmabxPn43NZmITN/PU7 O0ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ejeB+Bll; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b11si1080975pfo.240.2019.01.28.08.01.52; Mon, 28 Jan 2019 08:02:08 -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=ejeB+Bll; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730984AbfA1QBP (ORCPT + 99 others); Mon, 28 Jan 2019 11:01:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:46522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730946AbfA1QBO (ORCPT ); Mon, 28 Jan 2019 11:01:14 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A7CDD2175B; Mon, 28 Jan 2019 16:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691273; bh=Z7ALoxnJg3T5Ud46HOi/UoMMW9X9EWYkhMLhDPbsEoc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ejeB+BllC+dsFCY+Kz4l5mQMTtd9HqoA5c5jjeFEHcX1sqRUzeWlKsYzjYI5DbMZ4 ipuMqRGCb5CHFec4SRWAQw4DbHzDrP3dXdUzASr3OGLyGCOtJjXXimocdYuFz8vXj5 BRGUlyPYKrKbmhq4IDkt4NbmXjIb0exlurq1+LXM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Brian Norris , Benson Leung , Sasha Levin Subject: [PATCH AUTOSEL 4.19 041/258] platform/chrome: don't report EC_MKBP_EVENT_SENSOR_FIFO as wakeup Date: Mon, 28 Jan 2019 10:55:47 -0500 Message-Id: <20190128155924.51521-41-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brian Norris [ 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