Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4432403rwe; Tue, 30 Aug 2022 09:59:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR7PnWazGowQ4fp7sl8bwuMea6//YJnfFtsNV0Gz8Ym/FfJXjFJrb1plN03U0cFyi85hC1tK X-Received: by 2002:a63:6b81:0:b0:41c:3a8c:b4fe with SMTP id g123-20020a636b81000000b0041c3a8cb4femr18526433pgc.84.1661878792486; Tue, 30 Aug 2022 09:59:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661878792; cv=none; d=google.com; s=arc-20160816; b=XKA7/c5MTMNHdfQaW4T0Z8sp+NIN+YbFSDz+nSa1fB8yLLihKxBouuLT9PG1vQiEHB Udx7RV3+TDnHdEhqE+9UIuVv8rQtZDOh6l3+QRTROLIqBcWYgp2TKpKiF+aS+xjUnZDK 6TdcCZTzHRDAruCNSbTRuf9n7iAsJZVznrtFfbZY+ETDL+h512VnP5EvRmHaqqUSki8T 21J3U+iLI9+ikyB1wI3ZPucoyxpO6WFmUySVdS3sGyBVzzuxrirfC1+Wh8PxXI/mENPr R5R6KO9LGWUvDLOSFvPhybSvG7RX8bZM55xx27P+BF0h606TMa1m5gvUYPQm8wWNMFJ5 4Prg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=nJgvuRWdyzPElHXD9yyr3Tib1eF04YZWzOJN8SxuXfM=; b=pU1j1RgIOhxhlaF7x5U6vvfcOcf2wh723PRyZC16HW0I8u2cauWZTtJX53GF7jVUhW W02CIngcRCuzOXTep2M4Rk8EQJ8+j0d/fvd1HJQSPnuhspKjQ5FYIp4kf23M/tGNt5bs 47G2udisjuulTNfAJbYWJp8lhdmhjdKslLXl5MGvrlk0U4k+e74UiNlzg+4WR4kkKWUT 1byaiMS2dkP8vPY8KHz7o6kZbRlUjm3bfp1nR/CJbZQ+6dje8Zb1q1x2Y/ZtQT/h8TIh nrlH8ngCmZdYF4/boJ3sCGyqoM4dF1ZpaG9lqtSKq6Xmet34Knu+z9ii/pOu1p5hmRdV xkTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UfFfzEYm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a656251000000b0042204aef44bsi2416464pgv.54.2022.08.30.09.59.41; Tue, 30 Aug 2022 09:59:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UfFfzEYm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229990AbiH3Qg3 (ORCPT + 99 others); Tue, 30 Aug 2022 12:36:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbiH3Qg1 (ORCPT ); Tue, 30 Aug 2022 12:36:27 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41753A9C24; Tue, 30 Aug 2022 09:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661877386; x=1693413386; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=JQcuXMXfnMd8wurcg9NxfmRdRvyNP0uZVbqes8AUE34=; b=UfFfzEYmFNND2ohydjDAyLhZHIx334fOj6ktvvU45+XSIWhMK7XZ7Cad u2AkUwZMyAKEbltb9rwoKn+GTyQ86Nv633Gp5/cQgpphDHQ+NAfTORdWc M6GYjqTk2JV1Y2zif1CjE9oFrzlC3Fv+lMbMMIQZELABAwgbaTAjigPt0 7PHShfKGAxOcWMhjjuw1B5jDsH5FxPR7lDKR8r2s9IgwUJ48l0Q3PMaFC Bm9JpSMpoyEUsq0SoFRaOTEaWGqNIifv2bdukwhtjX/cKF5+j/7Map/Nt Y4yLY4r8wh4I9dTr3C4SYbjwW7judGHlQOKsB8/Qd0zUoL69xvAFOKW5O g==; X-IronPort-AV: E=McAfee;i="6500,9779,10455"; a="278251872" X-IronPort-AV: E=Sophos;i="5.93,275,1654585200"; d="scan'208";a="278251872" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2022 09:30:32 -0700 X-IronPort-AV: E=Sophos;i="5.93,275,1654585200"; d="scan'208";a="588678249" Received: from lzaino-mobl1.amr.corp.intel.com (HELO [10.212.130.115]) ([10.212.130.115]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2022 09:30:32 -0700 Message-ID: <1edc5cf3-c629-a7ed-4531-3c814367c004@linux.intel.com> Date: Tue, 30 Aug 2022 09:30:32 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.11.0 Subject: Re: [PATCH] PCI: Disable PTM on Upstream Ports during suspend Content-Language: en-US To: Bjorn Helgaas , Kai-Heng Feng Cc: Koba Ko , Mika Westerberg , "David E . Box" , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Helgaas References: <20220830155224.103907-1-helgaas@kernel.org> From: Sathyanarayanan Kuppuswamy In-Reply-To: <20220830155224.103907-1-helgaas@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/30/22 8:52 AM, Bjorn Helgaas wrote: > From: Bjorn Helgaas > > During suspend, we want to disable PTM on Root Ports because that allows > some chips, e.g., Intel mobile chips since Coffee Lake, to enter a > lower-power PM state. > > Previously we only disabled PTM for Root Ports, but PCIe r6.0, sec 2.2.8, > strongly recommends that functions support generation of Messages in non-D0 > states, so we must assume that Switch Upstream Ports or Endpoints may send > PTM Request Messages while in D1, D2, and D3hot. > > A PTM Message received by a Downstream Port, e.g., a Root Port, with PTM > disabled must be treated as an Unsupported Request (sec 6.21.3). > > With this topology: > > 0000:00:1d.0 Root Port to [bus 08-71] > 0000:08:00.0 Switch Upstream Port to [bus 09-71] > > Kai-Heng reported errors like this: > > pcieport 0000:00:1d.0: AER: Uncorrected (Non-Fatal) error received: 0000:00:1d.0 > pcieport 0000:00:1d.0: PCIe Bus Error: severity=Uncorrected (Non-Fatal), type=Transaction Layer, (Requester ID) > pcieport 0000:00:1d.0: device [8086:7ab0] error status/mask=00100000/00004000 > pcieport 0000:00:1d.0: [20] UnsupReq (First) > pcieport 0000:00:1d.0: AER: TLP Header: 34000000 08000052 00000000 00000000 > > Decoding this (from PCIe r6.0, sec 2.2.1.1, 2.2.8.10) shows that 00:1d.0 > logged an Unsupported Request error when it received a PTM Request with > Requester ID 08:00.0. > > To prevent this error, disable PTM when suspending Upstream Ports > (including those on Endpoints), not just Root Ports. > > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215453 > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=216210 > Based-on: https://lore.kernel.org/r/20220706123244.18056-1-kai.heng.feng@canonical.com > Based-on-patch-by: Kai-Heng Feng > Reported-by: Kai-Heng Feng > Tested-by: Kai-Heng Feng > Signed-off-by: Bjorn Helgaas > Cc: David E. Box > Cc: Sathyanarayanan Kuppuswamy > --- Looks good to me Reviewed-by: Kuppuswamy Sathyanarayanan > drivers/pci/pci.c | 30 ++++++++++++++---------------- > drivers/pci/pcie/ptm.c | 8 +++++++- > 2 files changed, 21 insertions(+), 17 deletions(-) > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index 95bc329e74c0..96487a9ce5bf 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -2707,14 +2707,19 @@ int pci_prepare_to_sleep(struct pci_dev *dev) > return -EIO; > > /* > - * There are systems (for example, Intel mobile chips since Coffee > - * Lake) where the power drawn while suspended can be significantly > - * reduced by disabling PTM on PCIe root ports as this allows the > - * port to enter a lower-power PM state and the SoC to reach a > - * lower-power idle state as a whole. > + * We want to disable PTM on Root Ports because that allows some > + * chips, e.g., Intel mobile chips since Coffee Lake, to enter a > + * lower-power PM state. > + * > + * PCIe r6.0, sec 2.2.8, strongly recommends that functions support > + * generation of messages in non-D0 states, so we assume Switch > + * Upstream Ports or Endpoints may send PTM Requests while in D1, > + * D2, and D3hot. A PTM message received by a Downstream Port > + * (including a Root Port) with PTM disabled must be treated as an > + * Unsupported Request (sec 6.21.3). To prevent this error, > + * disable PTM in *all* devices, not just Root Ports. > */ > - if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) > - pci_disable_ptm(dev); > + pci_disable_ptm(dev); > > pci_enable_wake(dev, target_state, wakeup); > > @@ -2764,15 +2769,8 @@ int pci_finish_runtime_suspend(struct pci_dev *dev) > if (target_state == PCI_POWER_ERROR) > return -EIO; > > - /* > - * There are systems (for example, Intel mobile chips since Coffee > - * Lake) where the power drawn while suspended can be significantly > - * reduced by disabling PTM on PCIe root ports as this allows the > - * port to enter a lower-power PM state and the SoC to reach a > - * lower-power idle state as a whole. > - */ > - if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) > - pci_disable_ptm(dev); > + /* See rationale above for disabling PTM */ > + pci_disable_ptm(dev); > > __pci_enable_wake(dev, target_state, pci_dev_run_wake(dev)); > > diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c > index 368a254e3124..ec338470d13f 100644 > --- a/drivers/pci/pcie/ptm.c > +++ b/drivers/pci/pcie/ptm.c > @@ -31,12 +31,18 @@ static void pci_ptm_info(struct pci_dev *dev) > > void pci_disable_ptm(struct pci_dev *dev) > { > - int ptm; > + int type, ptm; > u16 ctrl; > > if (!pci_is_pcie(dev)) > return; > > + type = pci_pcie_type(dev); > + if (!(type == PCI_EXP_TYPE_ROOT_PORT || > + type == PCI_EXP_TYPE_UPSTREAM || > + type == PCI_EXP_TYPE_ENDPOINT)) > + return; > + > ptm = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_PTM); > if (!ptm) > return; -- Sathyanarayanan Kuppuswamy Linux Kernel Developer