Received: by 10.213.65.68 with SMTP id h4csp1325806imn; Mon, 19 Mar 2018 00:31:04 -0700 (PDT) X-Google-Smtp-Source: AG47ELuTtj5MENUz7hFJMQptRGYnwHJve8b6VcLAJFaCk7QFlyonb68fnOM9oao0tGJQs7LAklN/ X-Received: by 10.98.96.133 with SMTP id u127mr9468445pfb.48.1521444664859; Mon, 19 Mar 2018 00:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521444664; cv=none; d=google.com; s=arc-20160816; b=0D3A4A2x0EapNHmqgKpPSv8WzNrGmxMKHnF0ZzNqEKp4++VCt0fC2xiMMDl5PhE2lg ghuggapWLXT+FAg9V2k1S7zdt/KdoYdhJBlyUycb6aCo5Te4Ay7wC3Y4MIkH62t5POR6 93fQv+8Lg/Pkhg93NEy1oYr5FlifsOzx/fJ4PShhWlqEPsun4oCQuV08Qz1tShC/7+JT a+hGwFWCZOlGKcGLLdJFVXu61q6hC3+dl9mySF1XBwvRNPq7Fx4G9T+YRRHUsXlWsEbb hdwxXscjtgFxrVDJQW5L2IsbB99Nd2XUAJICmYkMQiDH+tWqibZIh20zFYhLw43cf+RB Ev5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=JCnXUzMgsAbbACHs0AXeWNJgXXbd846wFICmINucZ2I=; b=azyqb29C59MCnXyG83AdmXFdAmq9PKbZXvZo/h/kw9PHGYbhbKTjjT2iDNSNXKU46C wrSvqq6rmTd04/guaPsliKYqttGXBXQvwhkONTsBZQfXR0yz8BPaOjjOc+mvcA5oo2km dmkWIExhdWc1S5/N+cvY3zbbSHI8K+wk8Ztc+kk3rDTjng8z2HLn5RbkNOywPOpJs5tw Wglu2TP1hq8LnBpDrx6nOFqPGaAiQ+DEL8GFq6BX+x+smkyYBz9lNttLepc1F9dxozzp MAmZWHvY6pMwgw5jrqZluXWkcWBv3iXRLffzOKDeBWcsSe8tpWdj8JmyiLgCk8xI6BeQ fAFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@endlessm-com.20150623.gappssmtp.com header.s=20150623 header.b=Z+OsGFCi; 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 67-v6si11795790pla.612.2018.03.19.00.30.50; Mon, 19 Mar 2018 00:31:04 -0700 (PDT) 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=@endlessm-com.20150623.gappssmtp.com header.s=20150623 header.b=Z+OsGFCi; 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 S1755332AbeCSH3x (ORCPT + 99 others); Mon, 19 Mar 2018 03:29:53 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:41829 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755058AbeCSH3s (ORCPT ); Mon, 19 Mar 2018 03:29:48 -0400 Received: by mail-pf0-f195.google.com with SMTP id f80so6702363pfa.8 for ; Mon, 19 Mar 2018 00:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessm-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=JCnXUzMgsAbbACHs0AXeWNJgXXbd846wFICmINucZ2I=; b=Z+OsGFCi4E4uzU0c8EKKoKAyezz1nkhB59nBdG9iKf50gKOxASa0nrfvrcDOGWWd+2 CQUeXqdhyfst54wWt65XFoVpzUaLLTqlO2xdF6mkwEHFZ/5sEXBQPSTprL3RS4JbGcgi 7oqZJFRhjDGz0R7JqdAjLUZkQP1Owvm7sii3gA+/K/I3TgfxgWIfDo+kWAe1DPc1EZ9o U/aJ3o7HXFPoIcgE8O/hCSot376UP4OXUpWtvNsX3bTjiWYcPS/l95qkoeNIUWBGrDVc SDOg3UZrTiR+ltMm9QH+REC2nt8iKOo1La/l07zuN57Ic4l4Me/a3IEH60MBZAjRL5f3 Xzhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JCnXUzMgsAbbACHs0AXeWNJgXXbd846wFICmINucZ2I=; b=It84qMbizHKE4UJXZ9vXaxPkGHOWZEsy8f1qP6BjPHcBcL7+1T0ju41Xg7VkyRo2EL O1Bm6GZnwGQorM0Qo/lRfcHVsXfU4IJvsrznGXTCHHE9sC3WYg+T8+Oq+U3vBxd5HgQo hKDtJimWTEVtlxlnk/YuCNqpfT46mPQ5MoFAgT25Zk6JOyM8uqXIfhQY6bSPZguhu+1I atonftndZqhw2HYXbDTfEUqkmv632yYyoP6ijCYsAlGeTfN9rDy3gpIw/5hQsy/w0X+q pfu6KwZRAnbu79wJpY8qgnQN+9+eQC8qmTxlG9tXOxoU8it5IQqZjs/HPYNyRbpuDjB7 vkLw== X-Gm-Message-State: AElRT7EUnjySC2hXPsTCFb5/exzQi93pxeB9mczD3ZMDdpQF7pOJRsmG xdJ7EGtNQyd45z+HFgCg/YdvvA== X-Received: by 10.99.96.193 with SMTP id u184mr8566495pgb.103.1521444587567; Mon, 19 Mar 2018 00:29:47 -0700 (PDT) Received: from limbo.local (125-227-158-176.HINET-IP.hinet.net. [125.227.158.176]) by smtp.gmail.com with ESMTPSA id b18sm25788875pfi.34.2018.03.19.00.29.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Mar 2018 00:29:46 -0700 (PDT) From: Daniel Drake To: rjw@rjwysocki.net, lenb@kernel.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux@endlessm.com, chiu@endlessm.com, mathias.nyman@intel.com, linux-usb@vger.kernel.org Subject: [PATCH] ACPI / PM: allow deeper wakeup power states with no _SxD nor _SxW Date: Mon, 19 Mar 2018 15:29:41 +0800 Message-Id: <20180319072941.22767-1-drake@endlessm.com> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org acpi_dev_pm_get_state() is used to determine the range of allowable device power states when going into S3 suspend. This is implemented by executing the _S3D and _S3W ACPI methods. Linux follows the ACPI spec behaviour in that when _S3D is implemented and _S3W is not, Linux will not go into a power state deeper than the one returned by _S3D for a wakeup-enabled device. However, this same logic is being applied to the case when neither _S3D nor _S3W are present, and the result is that this function decides that the device must stay in D0 (fully on) state. This is breaking USB wakeups on Asus V222GA and Acer XC-830. _S3D and _S3W are not present, so the USB controller is left in the D0 running state during S3, and hence it is unable to generate a PME# wake event. The ACPI spec is unclear on which power states are permissable for wakeup-enabled devices when both _S3D and _S3W are missing. However, USB wakeups work fine on these platforms under Windows, where device manager shows that they are using D3 device state for the USB controller in S3. I assume that the "max = min" clamping done by the code here is specifically written for the _S3D but no _S3W case. By making the code true to those conditions, avoiding them on these platforms, the controller will be put into D3 state and USB wakeups start working. Additionally I feel that this change makes the code more directly mirror the wording of the ACPI spec and it's associated lack of clarity. Thanks to Mathias Nyman for pointing us in the right direction. Signed-off-by: Daniel Drake Link: http://lkml.kernel.org/r/CAB4CAwf_k-WsF3zL4epm9TKAOu0h=Bv1XhXV_gY3bziOo_NPKA@mail.gmail.com --- drivers/acpi/device_pm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index c4d0a1c912f0..b945e37bcac0 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -543,6 +543,7 @@ static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev, unsigned long long ret; int d_min, d_max; bool wakeup = false; + acpi_status sxd_status; acpi_status status; /* @@ -565,8 +566,8 @@ static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev, * provided if AE_NOT_FOUND is returned. */ ret = d_min; - status = acpi_evaluate_integer(handle, method, NULL, &ret); - if ((ACPI_FAILURE(status) && status != AE_NOT_FOUND) + sxd_status = acpi_evaluate_integer(handle, method, NULL, &ret); + if ((ACPI_FAILURE(sxd_status) && sxd_status != AE_NOT_FOUND) || ret > ACPI_STATE_D3_COLD) return -ENODATA; @@ -599,7 +600,11 @@ static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev, method[3] = 'W'; status = acpi_evaluate_integer(handle, method, NULL, &ret); if (status == AE_NOT_FOUND) { - if (target_state > ACPI_STATE_S0) + /* No _SxW. In this case, the ACPI spec says that we + * must not go into any power state deeper than the + * value returned from _SxD. + */ + if (sxd_status == AE_OK && target_state > ACPI_STATE_S0) d_max = d_min; } else if (ACPI_SUCCESS(status) && ret <= ACPI_STATE_D3_COLD) { /* Fall back to D3cold if ret is not a valid state. */ -- 2.14.1