From patchwork Tue Feb 25 10:27:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 1243975 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=X7gD5Pks; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48RZrg5tpQz9sQt for ; Tue, 25 Feb 2020 21:28:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730228AbgBYK2D (ORCPT ); Tue, 25 Feb 2020 05:28:03 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47819 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730175AbgBYK2D (ORCPT ); Tue, 25 Feb 2020 05:28:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582626482; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1VQ58Wza24YoM9bXucQG3jRahsq1uGn6XDOhu9mOIIA=; b=X7gD5Pks/7KgyGQIs3/f5LyNLJB/FSIaTSW4W5UPf+RMxvTx5Tx5MTJrZuVgm+OLQl66Lh SkCdhEwaWGSah0I9gRdxM7y3Vf192dCjBfLFOutB3A+eJZBX3ebERNyBMSa2YIiwyWwOuM dEsVZ6iqEA4IvGlJaN4k4+UrthcJ7Ms= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-34-JF2xeWW3NrCKXpcE8HT5Lg-1; Tue, 25 Feb 2020 05:28:00 -0500 X-MC-Unique: JF2xeWW3NrCKXpcE8HT5Lg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2B4C718FE862; Tue, 25 Feb 2020 10:27:59 +0000 (UTC) Received: from x1.localdomain.com (unknown [10.36.118.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95AE21001DDE; Tue, 25 Feb 2020 10:27:57 +0000 (UTC) From: Hans de Goede To: Mika Westerberg , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij Cc: Hans de Goede , Marc Lehmann , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH resend 1/3] gpiolib: acpi: Correct comment for HP x2 10 honor_wakeup quirk Date: Tue, 25 Feb 2020 11:27:51 +0100 Message-Id: <20200225102753.8351-2-hdegoede@redhat.com> In-Reply-To: <20200225102753.8351-1-hdegoede@redhat.com> References: <20200225102753.8351-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Commit aa23ca3d98f7 ("gpiolib: acpi: Add honor_wakeup module-option + quirk mechanism") added a quirk for some models of the HP x2 10 series. There are 2 issues with the comment describing the quirk: 1) The comment claims the DMI quirk applies to all Cherry Trail based HP x2 10 models. In the mean time I have learned that there are at least 3 variants of the HP x2 10 models: Bay Trail SoC + AXP288 PMIC Cherry Trail SoC + AXP288 PMIC Cherry Trail SoC + TI PMIC And this quirk's DMI matches only match the Cherry Trail SoC + TI PMIC SoC, which is good because we want a slightly different quirk for the others. This commit updates the comment to make it clear that the quirk is only for the Cherry Trail SoC + TI PMIC variants. 2) The comment says that it is ok to disable wakeup on all ACPI GPIO event handlers, because there is only the one for the embedded-controller events. This is not true, there also is a handler for the special INT0002 device which is related to USB wakeups. We need to also disable wakeups on that one because the device turns of the USB-keyboard built into the dock when closing the lid. The XHCI controller takes a while to notice this, so it only notices it when already suspended, causing a spurious wakeup because of this. So disabling wakeup on all handlers is the right thing to do, but not because there only is the one handler for the EC events. This commit updates the comment to correctly reflect this. Fixes: aa23ca3d98f7 ("gpiolib: acpi: Add honor_wakeup module-option + quirk mechanism") Signed-off-by: Hans de Goede --- drivers/gpio/gpiolib-acpi.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 31fee5e918b7..bc96f28d4807 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -1345,11 +1345,16 @@ static const struct dmi_system_id gpiolib_acpi_quirks[] = { }, { /* - * Various HP X2 10 Cherry Trail models use an external - * embedded-controller connected via I2C + an ACPI GPIO - * event handler. The embedded controller generates various - * spurious wakeup events when suspended. So disable wakeup - * for its handler (it uses the only ACPI GPIO event handler). + * HP X2 10 models with Cherry Trail SoC + TI PMIC use an + * external embedded-controller connected via I2C + an ACPI + * GPIO event handler. The embedded controller generates + * various spurious wakeup events when suspended. + * When suspending by closing the LID, the power to the USB + * keyboard is turned off, causing INT0002 ACPI events to + * trigger once the XHCI controller notices the keyboard is + * gone. So INT0002 events cause spurious wakeups too. + * These are the only 2 ACPI event handlers, so we disable + * wakeups for all event handlers to fix the spurious wakeups. * This breaks wakeup when opening the lid, the user needs * to press the power-button to wakeup the system. The * alternative is suspend simply not working, which is worse. From patchwork Tue Feb 25 10:27:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 1243976 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JpWNV9SL; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48RZrl32RFz9sP7 for ; Tue, 25 Feb 2020 21:28:07 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730251AbgBYK2G (ORCPT ); Tue, 25 Feb 2020 05:28:06 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:59979 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730175AbgBYK2G (ORCPT ); Tue, 25 Feb 2020 05:28:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582626484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1+176jSPRXbnwscrhWa+EjnBARcoj+azxUULJIshoqo=; b=JpWNV9SLsX+oqXvAK4fhHqmSwlCw0Bry07nNpIAZU0YME3ptthGKJmud3YXuMQJP7oJqfW fJvn5Tm9cVUS+FJkYNmytfTWTgNt1RjYj+mC9daau9TXOxp0Xs06mAvo3Cy7kg40CelLLY YQT7IOYbLTq4u/FQ8SbXsUK8k8ED3Rg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-5-NfLwfEaeP2O-qbs6gn4xdQ-1; Tue, 25 Feb 2020 05:28:02 -0500 X-MC-Unique: NfLwfEaeP2O-qbs6gn4xdQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0B46D18FE863; Tue, 25 Feb 2020 10:28:01 +0000 (UTC) Received: from x1.localdomain.com (unknown [10.36.118.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C7731001902; Tue, 25 Feb 2020 10:27:59 +0000 (UTC) From: Hans de Goede To: Mika Westerberg , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij Cc: Hans de Goede , Marc Lehmann , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH resend 2/3] gpiolib: acpi: Rename honor_wakeup option to ignore_wake, add extra quirk Date: Tue, 25 Feb 2020 11:27:52 +0100 Message-Id: <20200225102753.8351-3-hdegoede@redhat.com> In-Reply-To: <20200225102753.8351-1-hdegoede@redhat.com> References: <20200225102753.8351-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Commit aa23ca3d98f7 ("gpiolib: acpi: Add honor_wakeup module-option + quirk mechanism") was added to deal with spurious wakeups on one specific model of the HP x2 10 series. In the mean time I have learned that there are at least 3 variants of the HP x2 10 models: Bay Trail SoC + AXP288 PMIC Cherry Trail SoC + AXP288 PMIC Cherry Trail SoC + TI PMIC It turns out that the need to ignore wakeup on *all* ACPI GPIO event handlers is unique to the Cherry Trail SoC + TI PMIC variant for which the first quirk was added. The 2 variants with the AXP288 PMIC only need to have wakeup disabled on the embedded-controller event handler. We want to e.g. keep wakeup on the event handler connected to the GPIO for the lid open/closed sensor. Since the honor_wakeup option was added to be able to ignore wake events, the name was perhaps not the best, this commit renames it to ignore_wake, this version of the option has te following possible values: values >= 0: a pin number on which to ignore wakeups, the ACPI wake flag will still be honored on all other pins value -1: auto: check for DMI quirk, otherwise honor the flag on all pins value -2: all: ignore the flag on all pins value -3: none: honor wakeups on all pins Note that it is possible for an ACPI table to request events on the same pin-number on multiple GPIO controllers, in that case if such a pin-number is used as ignore_wake value then wakeups will be ignored for that pin on all GPIO controllers. The existing quirk for the Cherry Trail + TI PMIC models is changed to IGNORE_WAKE_ALL, keeping the current behavior; and a new quirk is added for the Bay Trail + AXP288 model, ignoring wakeups on the EC GPIO pin only. Fixes: aa23ca3d98f7 ("gpiolib: acpi: Add honor_wakeup module-option + quirk mechanism") Signed-off-by: Hans de Goede --- drivers/gpio/gpiolib-acpi.c | 59 +++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index bc96f28d4807..83103efa5862 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -21,19 +21,27 @@ #include "gpiolib.h" #include "gpiolib-acpi.h" -#define QUIRK_NO_EDGE_EVENTS_ON_BOOT 0x01l -#define QUIRK_NO_WAKEUP 0x02l +#define QUIRK_IGNORE_WAKE_MASK GENMASK(15, 0) +#define QUIRK_IGNORE_WAKE_SET BIT(16) +#define QUIRK_NO_EDGE_EVENTS_ON_BOOT BIT(17) + +#define QUIRK_IGNORE_WAKE(x) \ + (((x) & QUIRK_IGNORE_WAKE_MASK) | QUIRK_IGNORE_WAKE_SET) + +#define IGNORE_WAKE_AUTO -1 +#define IGNORE_WAKE_ALL -2 +#define IGNORE_WAKE_NONE -3 + +static int ignore_wake = IGNORE_WAKE_AUTO; +module_param(ignore_wake, int, 0444); +MODULE_PARM_DESC(ignore_wake, + "Ignore ACPI wake flag: x=ignore-for-pin-x, -1=auto, -2=all, -3=none"); static int run_edge_events_on_boot = -1; module_param(run_edge_events_on_boot, int, 0444); MODULE_PARM_DESC(run_edge_events_on_boot, "Run edge _AEI event-handlers at boot: 0=no, 1=yes, -1=auto"); -static int honor_wakeup = -1; -module_param(honor_wakeup, int, 0444); -MODULE_PARM_DESC(honor_wakeup, - "Honor the ACPI wake-capable flag: 0=no, 1=yes, -1=auto"); - /** * struct acpi_gpio_event - ACPI GPIO event handler data * @@ -214,6 +222,7 @@ static acpi_status acpi_gpiochip_alloc_event(struct acpi_resource *ares, irq_handler_t handler = NULL; struct gpio_desc *desc; int ret, pin, irq; + bool honor_wakeup; if (!acpi_gpio_get_irq_resource(ares, &agpio)) return AE_OK; @@ -286,6 +295,17 @@ static acpi_status acpi_gpiochip_alloc_event(struct acpi_resource *ares, } } + switch (ignore_wake) { + case IGNORE_WAKE_ALL: + honor_wakeup = false; + break; + case IGNORE_WAKE_NONE: + honor_wakeup = true; + break; + default: + honor_wakeup = ignore_wake != pin; + } + event->handle = evt_handle; event->handler = handler; event->irq = irq; @@ -1363,7 +1383,22 @@ static const struct dmi_system_id gpiolib_acpi_quirks[] = { DMI_MATCH(DMI_SYS_VENDOR, "HP"), DMI_MATCH(DMI_PRODUCT_NAME, "HP x2 Detachable 10-p0XX"), }, - .driver_data = (void *)QUIRK_NO_WAKEUP, + .driver_data = (void *)QUIRK_IGNORE_WAKE(IGNORE_WAKE_ALL), + }, + { + /* + * HP X2 10 models with Bay Trail SoC + AXP288 PMIC use an + * external embedded-controller connected via I2C + an ACPI + * GPIO event handler for pin 0x1c, causing spurious wakeups. + * Unlike the Cherry Trail + TI PMIC models, we do want to + * honor the ACPI wake flag on the other GPIOs. + */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), + DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion x2 Detachable"), + DMI_MATCH(DMI_BOARD_NAME, "815D"), + }, + .driver_data = (void *)QUIRK_IGNORE_WAKE(0x1c), }, {} /* Terminating entry */ }; @@ -1384,11 +1419,11 @@ static int acpi_gpio_setup_params(void) run_edge_events_on_boot = 1; } - if (honor_wakeup < 0) { - if (quirks & QUIRK_NO_WAKEUP) - honor_wakeup = 0; + if (ignore_wake == IGNORE_WAKE_AUTO) { + if (quirks & QUIRK_IGNORE_WAKE_SET) + ignore_wake = (s16)(quirks & QUIRK_IGNORE_WAKE_MASK); else - honor_wakeup = 1; + ignore_wake = IGNORE_WAKE_NONE; } return 0; From patchwork Tue Feb 25 10:27:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 1243977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LN1Bc3VB; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48RZrm3z8tz9sQt for ; Tue, 25 Feb 2020 21:28:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730283AbgBYK2I (ORCPT ); Tue, 25 Feb 2020 05:28:08 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:21448 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730258AbgBYK2H (ORCPT ); Tue, 25 Feb 2020 05:28:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582626486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FW3JytNzre5px7xTb4SFkBL4h8KNuQAlJJzUt+mc2q8=; b=LN1Bc3VBU0oOEx07ZGcV14G1A7m0PSTWSWTT41lwhmA6qjhTyjpOK86geJXlOyLGj1dhH6 DDsHnfsN3cyUNTpqgCDPjVNrOGv/qYarZHgGhlGGLiEYEa/TJdDwHc1h7RHUBVP+Ash3rw zQR/zC7v6jSQJ1c+kI09m2zClJndgGo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-1-Svm5HHX3PvGza0KcTE4XFQ-1; Tue, 25 Feb 2020 05:28:04 -0500 X-MC-Unique: Svm5HHX3PvGza0KcTE4XFQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CF76F107ACC9; Tue, 25 Feb 2020 10:28:02 +0000 (UTC) Received: from x1.localdomain.com (unknown [10.36.118.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44CB5101E811; Tue, 25 Feb 2020 10:28:01 +0000 (UTC) From: Hans de Goede To: Mika Westerberg , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij Cc: Hans de Goede , Marc Lehmann , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH resend 3/3] gpiolib: acpi: Add quirk to ignore EC gpio wakeups for 1 more HP x2 10 model Date: Tue, 25 Feb 2020 11:27:53 +0100 Message-Id: <20200225102753.8351-4-hdegoede@redhat.com> In-Reply-To: <20200225102753.8351-1-hdegoede@redhat.com> References: <20200225102753.8351-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org There are at least 3 variants of the HP x2 10 models: Bay Trail SoC + AXP288 PMIC Cherry Trail SoC + AXP288 PMIC Cherry Trail SoC + TI PMIC Like on the Bay Trail + AXP288 PMIC model, we also need to ignore wakeups for the GPIO which is (ab)used for embedded-controller events on the Cherry Trail + AXP288 PMIC model. Fixes: aa23ca3d98f7 ("gpiolib: acpi: Add honor_wakeup module-option + quirk mech Reported-and-tested-by: Marc Lehmann Signed-off-by: Hans de Goede --- drivers/gpio/gpiolib-acpi.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 83103efa5862..46b2d74c610c 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -1400,6 +1400,21 @@ static const struct dmi_system_id gpiolib_acpi_quirks[] = { }, .driver_data = (void *)QUIRK_IGNORE_WAKE(0x1c), }, + { + /* + * HP X2 10 models with Cherry Trail SoC + AXP288 PMIC use an + * external embedded-controller connected via I2C + an ACPI + * GPIO event handler for pin 0x00, causing spurious wakeups. + * Unlike the Cherry Trail + TI PMIC models, we do want to + * honor the ACPI wake flag on the other GPIOs. + */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "HP"), + DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion x2 Detachable"), + DMI_MATCH(DMI_BOARD_NAME, "813E"), + }, + .driver_data = (void *)QUIRK_IGNORE_WAKE(0x00), + }, {} /* Terminating entry */ };