Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6095083pxv; Thu, 29 Jul 2021 06:25:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWNcwBm5kMINEHNoAVjKj846HHJNAR4AdS3HoQHACFvsS9vniyvz7RFY0KhEyv2MBTBEzW X-Received: by 2002:a5e:9747:: with SMTP id h7mr4166957ioq.92.1627565130930; Thu, 29 Jul 2021 06:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627565130; cv=none; d=google.com; s=arc-20160816; b=QdB4i3cLU9AcwJcfwFlfJuwpAC6SyFv0DCi20vnJ9OYimyADHGW8xJtgX/5MzIQ8vb zI9tDlmQ70QtQ9+JS3wJ8AR7KhimyQOTiAONbFmo7+gIfnuBgkxNNYn4cfUpLdblhayk Z5H6iJrA3aqDO0YoPrWoeOucbUszjAhkcHCI659gQE2JCB0RKqz6tcbvB0vw5E92HXP6 xwuCUGhYA+0dxtBHqZVV3VBYpWgUe2lrL/mi647xaXrF1e4C6NzZeQgxYqAPm2gtz27o 1giB6vAb8xzwoA6Jmrq69++psY0qx01K4PI5q9++OOHGFCXNCfyeEDznnQg4quoHGnrF jl4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=1a3wG1scJcs0b5d/83sNOvLttOBKxFNgzH8fEgxyy+Y=; b=ugtnEWqPQkXWxtc0zUvO0AK/sOWRhGCCDCXb3uKXwyyk2JujfuPd+e7H96lNtsfFjk g3DoDspzFm2+F/dFx8OpkfCLN8qJTnZYuWnrSaHiNDRHlIn/9qdN0tGrBTDKbpq4PQv3 3py1U5wZ0uic0hUdjXtthsz4CorABv/5nd6Rqrt+7Qik85sIt7WaLD3RmsyGXHX3v9F/ g8iWb8H5MrAVtnp4BXH+AicJEZAXJv1/eaIW2o4vl/pZ7fCQOXha5XGLIU1yi8RF6adc FYt7ERTqzfGnuebnLIirogCzq5kQXdIMjbbqN7OPSiYfPJXgUND4YsSXarqlJD/7TZwl Gf4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si3954800iow.27.2021.07.29.06.25.20; Thu, 29 Jul 2021 06:25:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237644AbhG2NYd (ORCPT + 99 others); Thu, 29 Jul 2021 09:24:33 -0400 Received: from mga04.intel.com ([192.55.52.120]:26503 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237688AbhG2NXQ (ORCPT ); Thu, 29 Jul 2021 09:23:16 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10059"; a="210996468" X-IronPort-AV: E=Sophos;i="5.84,278,1620716400"; d="scan'208";a="210996468" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2021 06:23:11 -0700 X-IronPort-AV: E=Sophos;i="5.84,278,1620716400"; d="scan'208";a="581334914" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.163]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2021 06:23:08 -0700 Received: by lahna (sSMTP sendmail emulation); Thu, 29 Jul 2021 16:23:05 +0300 Date: Thu, 29 Jul 2021 16:23:05 +0300 From: Mika Westerberg To: "Rafael J. Wysocki" Cc: Linux PCI , Linux ACPI , Linux PM , LKML , Bjorn Helgaas , Kai-Heng Feng , Utkarsh H Patel , Koba Ko Subject: Re: [PATCH v2] PCI: PM: Add special case handling for PCIe device wakeup Message-ID: References: <3149540.aeNJFYEL58@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3149540.aeNJFYEL58@kreacher> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rafael, On Wed, Jul 28, 2021 at 07:25:04PM +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Some PCIe devices only support PME (Power Management Event) from > D3cold. One example is the ASMedia xHCI controller: > > 11:00.0 USB controller: ASMedia Technology Inc. ASM1042A USB 3.0 Host Controller (prog-if 30 [XHCI]) > ... > Capabilities: [78] Power Management version 3 > Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0-,D1-,D2-,D3hot-,D3cold+) > Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME- > > In those cases, if the device is expected to generate wakeup events > from its final power state, pci_target_state() returns D0, which > prevents the PCIe hierarchy above the device from entering any > low-power states too, but the device cannot signal PME from D0 > either. However, if the device were allowed to go into D3hot, its > parent PCIe port and its ancestors would also be able to go into D3 > and if any of them goes into D3cold, the device would end up in > D3cold too (as per the PCI PM spec v1.2, Table 6-1), in which case > it would be able to signal PME. > > This means that the system could be put into a lower-power > configuration while meeting the requirement to enable the device to > generate PME from the final state (which is not the case if the > device stays in D0 along with the entire hierarchy above it). > > In order to avoid missing that opportunity, extend pci_pme_capable() > to return 'true' in the special case when the target state is D3hot > and the device can only signal PME from D3cold and update > pci_target_state() to return the current target state if > pci_pme_capable() returns 'true' for it. > > This change can be regarded as a pci_target_state() fix, because that > function should ignore its 'wakeup' argument if signaling PME from > any power states shallower than the current candidate one (including > D0) is not supported. > > Link: https://lore.kernel.org/linux-pm/20210617123653.58640-1-mika.westerberg@linux.intel.com > Fixes: 666ff6f83e1d ("PCI/PM: Avoid using device_may_wakeup() for runtime PM") > Reported-by: Mika Westerberg > Reported-by: Utkarsh H Patel > Reported-by: Koba Ko > Signed-off-by: Rafael J. Wysocki Tried this now and it fixes the issue! Also checked with another device that actually supports PME from other states than D3cold and it also works (as expected). Feel free to add my, Tested-by: Mika Westerberg Thanks!