Received: by 10.213.65.68 with SMTP id h4csp242111imn; Fri, 16 Mar 2018 01:25:04 -0700 (PDT) X-Google-Smtp-Source: AG47ELsyC9wxpJaRiIYsyR+mAJVZMKx/ccH3vxY+VnAe2sfWWEUVGdUHoYBr2iWloMxc50qz2YwL X-Received: by 2002:a17:902:183:: with SMTP id b3-v6mr1194818plb.80.1521188704449; Fri, 16 Mar 2018 01:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521188704; cv=none; d=google.com; s=arc-20160816; b=UO8to3TdToSweM4+n1wKwHhbmTgIxTKIoQ5I3hlF/UhWiEwjvQBqmQ7AQKtJVApvma ZfAEQew7mIdUtvZ0i8bhNIl3JU6LKvJ+Ksut+IZeNxWZk1it/Dm2gawsRSoiP1/clL6W y4NktTYe3vUIebPByK9nD6RDpB+Id5g6bpCM9pfc5H1zRz5RBopFQpNzrCRTJNaD5XS+ ozy8GnpR9WCvo7KbnTVzf1cLgFIBNVRnCPkyERDBIkEQALBi5WffijIaPcPW0CL7ThAm ge2p07vNyp8h/Idn7E9ekdmaa2pzw3w28wOglHGhZhbRQsEy0lVMCFEGalq2L3WVHyMI +xAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=4i5siEwaUSGR3LyEy0tCpOsUzypoVAOFbD6wLBjr4M8=; b=ic3JMe0tNowKKK/pB0hK1cu+VxJ4pR6Es51CvCpVqnsApZEVLuSY8Hb6V+UvttCne0 s8eXBn05q+HVZ+1T8SKAKUl8+H1/NjxLmW/l6Sx+L5nwATnrXHnQ1AJCWvxutbs5BhqC oTJZuDvDCXnem6lVlk+iACnm3uS8mOx3uWCRdRgcEvjNV9xGETFjekCC/Yr859vyFYcr u6dTBcBox8FpLRmgZy7hHKiUECm3m+XlDwJa6b5iD5UKtl9IozC20bhPJ5tnzUILxU85 YpS2NgWnzeS00/LqWCtbg0S8K5JFqq+EMB592Pv/vCGIEWkVI1pYZfrrfazgka626lBt p9xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@endlessm-com.20150623.gappssmtp.com header.s=20150623 header.b=N47b7qDm; 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 e3si4620573pgs.809.2018.03.16.01.24.50; Fri, 16 Mar 2018 01:25: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=N47b7qDm; 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 S1753194AbeCPIXa (ORCPT + 99 others); Fri, 16 Mar 2018 04:23:30 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:42148 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752958AbeCPIX1 (ORCPT ); Fri, 16 Mar 2018 04:23:27 -0400 Received: by mail-pl0-f66.google.com with SMTP id w15-v6so5481874plq.9 for ; Fri, 16 Mar 2018 01:23:26 -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:in-reply-to:references; bh=4i5siEwaUSGR3LyEy0tCpOsUzypoVAOFbD6wLBjr4M8=; b=N47b7qDm7bqBuNHoiwKW5UVLECQBhD+K4KCWrkTvdOd0ADga+httrspSMFzRXL+cDC YK+Ov2FdoC5herXvI8aSGonJmyQtkeTuzhRFXFZ+FbJb1oOeUV/oZ6vfiy2lrckdhODq 6CKtLYLgQ2zuxY7lEC+3CihrwWdCfPa/F9d0d/BFAu/+K4Fc1rA2sduE23elS5TLCYpF 0wJ9+8N+9X4BHqn03g7rrp2F4g+3hIdSZVBtdBvGtsScECvD1eHJvv/BB5vmITH8Qp6K +UW6QkEOrHgjPSfT8PYOx8ez7m6LUHz0Ee9hKXjNhUhvrHvwFoM/+t+o0jHUE3oFWT9H UOHg== 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:in-reply-to :references; bh=4i5siEwaUSGR3LyEy0tCpOsUzypoVAOFbD6wLBjr4M8=; b=SNYgns8DR+Wm8i6XzAy5cloNxrFFlZVKOufAnxz4zgWeE0jUgx0LpxgCO5CoUxqx9i vGgFRRZ+P2LRS7mGBw+wX6av880DCIobcsfq8LsRHKzt9k3cYEygNnaHbMbajd4a+V5/ WyEdSz31g859W629gF3shJqlQuQXhTU2sxcaqdHKvJmO5Qf/fhKUjoFAFnntlllpbye2 K3FdGkBSv5Z/fXL7bjfyEruXX55uTLk2oWdNd+oi9RUdN4b8FVMaVU0dT6yj3/VTY+zy +f6s6odnIa+xCvK8Hool1XTRoFJNg/T0WbOvag3YSPM0DbWWwavU6tOdcsGepBXWLWfx DyAw== X-Gm-Message-State: AElRT7GRd7/SpgqfCXex32mWY91TTaER2KqX6LJk7qmWyoC4q21t6WD5 fRZx4GxJlmEBkGgIfrO8g/sFwA== X-Received: by 2002:a17:902:407:: with SMTP id 7-v6mr1133658ple.47.1521188606217; Fri, 16 Mar 2018 01:23:26 -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 p9sm12798997pff.173.2018.03.16.01.23.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Mar 2018 01:23:25 -0700 (PDT) From: Daniel Drake To: mathias.nyman@linux.intel.com Cc: chiu@endlessm.com, mathias.nyman@intel.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux@endlessm.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Subject: Re: Intel GemniLake xHCI connected devices can never wake up the system from suspend Date: Fri, 16 Mar 2018 16:23:20 +0800 Message-Id: <20180316082320.12636-1-drake@endlessm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > I've studied the ACPI spec trying to understand better, but I'm > struggling with the question: > What is the maximum number (lowest power) permitted device power state > for a device that is configured as able to wake the system from S3, > **that does not implement the _S3W method**? Actually the ACPI spec has an answer for the case when _S3D is present. The lack of clarity is only over the situation when both _S3D and _S3W are missing - like on the platforms being worked on here. The _S3D docs say: > If the device can wake the system from the S3 system sleeping state (see > _PRW) then the device must support wake in the D-state returned by this > object. However, OSPM cannot assume wake from the S3 system sleeping state > is supported in any deeper D-state unless specified by a corresponding > _S3W object Looking at the design of the existing Linux code, it seems like this "max = min" assignment that is causing us trouble originates directly from an attempt to implement that logic: if we didn't get a response from _S3W, then we must clamp ourselves to the data we got from _S3D. If I modify the Linux code to be a little more specific in that logic (only applying when we actually got something from _S3D) then the problematic behaviour is avoided and USB wakeups work. I feel that this change makes the Linux implementation more directly mirror the wording in the ACPI spec and it's associated lack of clarity for when both methods are missing. Thoughts? --- 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 a4c8ad98560d..44f12c5c75ee 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