Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp652612pxb; Thu, 19 Nov 2020 10:16:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzu16VPrRBJvXg06QBDtdT+GicJPhrV3/WtgcT4Jl2j3iJUs33/rzny/m2KH5YMfhEhmRm X-Received: by 2002:a17:906:1186:: with SMTP id n6mr32456776eja.89.1605809809767; Thu, 19 Nov 2020 10:16:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605809809; cv=none; d=google.com; s=arc-20160816; b=dP2dhz0Wnv5pZomPSl1f69ndWe96V1HWUUly+X1C0N10Ao2yGrSPPhMXYYwoUK6l6R aUTs+M/0FfuuaqzZdYVJnVOwKt1oTR7uw/m1EtYbc75WsrObFsKDjCkcD101pYp/cUwd AgdrWtEsAqSPrdjGfRHJIp9EytS/7i9JhVsLCU59QqRUu9iEf3D1NxK1GtyoDSm6VknY UbSaIMlfx5LnXuJViSGVxPHohjMyHiViokcT59lbUrNrSgNjCWqRFgG+UgQcf6kWIXX5 g/h94Bu3yTW7mA51aQ09+4ss8AcP7TCkwSGDGNUb2AXs4vCg3sIik/2kjAV4Sl1tZZVq ffnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=wRCdNCjOfunXbAIS7K4tkE2IMIlCbdlGRdRWxA2SgIU=; b=MwMBJERQ/7UrNfoMLkZhimTW7t6AFwgXd0eSO9rhuhNzLel1OE5bv4eAF32/jN11El P1m8wtFoPOzaEa/nV2sTd1Bk2Z283DDokk6/kYtnxlvQSJo+rR8k6KsdZlrR9+ZDT3D7 i4PClBgFhoILgvXn5PJwQ3ZNVyAYAia61LQintgDJrXpdVrUuPovlKY0KEWk7mXjyqMg BtLaOKj7EYk5Q8g2E+UEZzcIAtlTFzxmzSZ6Ldh+PC0xiUDt8og3zEzhSUyEpDuwIT4g kbHLG7RkVF1lmEa7aDtmXZvxTuFxs11ksyIO/Y6wknhqsdud/vWHnGRmOScUzYfHU1bn 0F+g== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u26si320323edb.100.2020.11.19.10.16.24; Thu, 19 Nov 2020 10:16:49 -0800 (PST) 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728837AbgKSSNe (ORCPT + 99 others); Thu, 19 Nov 2020 13:13:34 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:46791 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727117AbgKSSNd (ORCPT ); Thu, 19 Nov 2020 13:13:33 -0500 Received: by mail-ot1-f67.google.com with SMTP id g19so6160281otp.13; Thu, 19 Nov 2020 10:13:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wRCdNCjOfunXbAIS7K4tkE2IMIlCbdlGRdRWxA2SgIU=; b=Xdugvpfoqt0PLHESs/y2YlIeC5xc9WTVX8Ix87eHFkX5flqTS3glWxTVAxwYkrKyCM 0lu59pBq+qMCNib71wpJJX53ugMleqFVIgjvK3CRMubJaftm70eObqMqrZH8ohm+cL9v 3TRq7PEP/DTKBd8PBSD6PxLCBKsofGm+yiZkkcXfztRF/9X7ddcbgHnjUMy8gLKSrmvX nHD8DIH+xbSjA3L6hT6/eQbDguyZVjclVF9J+UidFHzEO7stDlaLd6xtQifaqG+IRnyM YFTC0ex1bFq0KzVwUcE0SWEyrrKVqPfMoff2CCYUgSP48FOIfcuHUlLoDvJmh2tYVlUy ldlg== X-Gm-Message-State: AOAM530VkLevXwHWbLg4P+MYLhyi+duIP44bzAMalS1tXJj79NQ5Tall 2TPtMsY2we90W+wppoLcEP0FKeJPOZx4oT3iLi4= X-Received: by 2002:a9d:171a:: with SMTP id i26mr11558331ota.260.1605809612651; Thu, 19 Nov 2020 10:13:32 -0800 (PST) MIME-Version: 1.0 References: <20201119001822.31617-1-david.e.box@linux.intel.com> <20201119001822.31617-2-david.e.box@linux.intel.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 19 Nov 2020 19:13:21 +0100 Message-ID: Subject: Re: [PATCH 2/2] PCI: Disable Precision Time Measurement during suspend To: David Box Cc: "Rafael J. Wysocki" , Bjorn Helgaas , Len Brown , Linux PCI , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 19, 2020 at 6:45 PM David E. Box wrote: > > On Thu, 2020-11-19 at 13:01 +0100, Rafael J. Wysocki wrote: > > On Thu, Nov 19, 2020 at 1:17 AM David E. Box > > wrote: > > > On Intel client platforms that support suspend-to-idle, like Ice > > > Lake, > > > root ports that have Precision Time Management (PTM) enabled can > > > prevent > > > the port from being fully power gated, causing higher power > > > consumption > > > while suspended. To prevent this, after saving the PTM control > > > register, > > > disable the feature. The feature will be returned to its previous > > > state > > > during restore. > > > > > > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=209361 > > > Reported-by: Len Brown > > > Suggested-by: Rafael J. Wysocki > > > Signed-off-by: David E. Box > > > --- > > > drivers/pci/pci.c | 14 +++++++++++++- > > > 1 file changed, 13 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > > > index 6fd4ae910a88..a2b40497d443 100644 > > > --- a/drivers/pci/pci.c > > > +++ b/drivers/pci/pci.c > > > @@ -21,6 +21,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -1543,7 +1544,7 @@ static void pci_save_ptm_state(struct pci_dev > > > *dev) > > > { > > > int ptm; > > > struct pci_cap_saved_state *save_state; > > > - u16 *cap; > > > + u16 *cap, ctrl; > > > > > > if (!pci_is_pcie(dev)) > > > return; > > > @@ -1560,6 +1561,17 @@ static void pci_save_ptm_state(struct > > > pci_dev *dev) > > > > > > cap = (u16 *)&save_state->cap.data[0]; > > > pci_read_config_word(dev, ptm + PCI_PTM_CTRL, cap); > > > + > > > + /* > > > + * On Intel systems that support suspend-to-idle, > > > additional > > > + * power savings can be gained by disabling PTM on root > > > ports, > > > + * as this allows the port to enter a deeper pm state. > > > > I would say "There are systems (for example, ...) 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". > > Okay. > > > > > > + */ > > > + if (pm_suspend_target_state == PM_SUSPEND_TO_IDLE && > > > > AFAICS the target sleep state doesn't matter here, so I'd skip the > > check above, but otherwise it LGTM. > > The target sleep state doesn't matter so much but that it's suspending > does. pci_save_state() is called during probe for the root ports (and > many other pci devices - I'm curious as to why). I tend to forget about this, sorry. > So without this check the capability gets disabled on boot. > So instead of calling this from here, why don't we invoke the code below from pci_prepare_to_sleep() and pci_finish_runtime_suspend(), before enabling wakeup (and it needs to be re-done on failures, eg. by restoring the cap from the saved copy)? > > > + pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) { > > > + ctrl = *cap & ~(PCI_PTM_CTRL_ENABLE | > > > PCI_PTM_CTRL_ROOT); > > > + pci_write_config_word(dev, ptm + PCI_PTM_CTRL, > > > ctrl); > > > + } > > > } > > > > > > static void pci_restore_ptm_state(struct pci_dev *dev) > > > --