Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3004222pxu; Tue, 8 Dec 2020 00:29:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwy0jfgxzrJJrXIfMg7SW2NJ9lSSNPbNXnixSqmBxMFg8q+KmOZl67hhdNnzbVgRrUoGT6s X-Received: by 2002:a17:906:6693:: with SMTP id z19mr21784691ejo.376.1607416180888; Tue, 08 Dec 2020 00:29:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607416180; cv=none; d=google.com; s=arc-20160816; b=lOhGsXtYwrfKDgN+99VZNip0ziKFueZiAkAcNjrXilqTbmpRV+esGaRPCnyeEI/FlC tty6x5p7njhq2t9fC0vkXnEIJCps0DsPeOEarnEEjZkixyTmCu1wG0tZv0KNouFHqGps 3b4SMEubytbdOKDhnZAWLhyOm77J/hNcmFhRsM4kCc8nydb9la833Y6xaRqNRGrQxF5M kcvCjXy+OTPPrfuGN16OWzo6xTsE5mgNgDm3MzbbSIEWprSdc3KqaLX3yblesAhqBE68 nBGSb4hZenTODFPcMrDoE5FsFTnSk0q/O6h1o4826E8wZYwlQQrj8syMEl7P/+h5As2e CymA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=++nC1UYIXYcvShdPi+Ss6gA+PaLteELoZabk4sxfr4k=; b=n3M5xx4ueWN+xjkGLXtdiyEJP2r5tw+z8BuoMBT+GC93M8+xPeTY5lwcLrcRNKO21d +E4meHRRNqO+o1WHJD6tbPYizUzM8W+DXaCjD1S7gwqJJk3mco/XA85cdzCfC3QYyduB MjuaUdB09saU3k0U6QkHEWUG2DEuVOfqwaHUdYhWu3ESjEOkWY3gNqmosJmJiIkbhNDG +3Ty0tSp+mTIt4sEskK9yrtdj9KBEuovHJCxAupfAXLM3NSqjFgViwklYfyorNb1E7lY lTLR+dblLyzh2vyV9KMz/ighYRm33t7Q/8N8087IVqkIK9BAjrlwIn73x8BK4CifGf+L gokg== 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=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz19si9189227ejb.699.2020.12.08.00.29.18; Tue, 08 Dec 2020 00:29:40 -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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728169AbgLHI0h (ORCPT + 99 others); Tue, 8 Dec 2020 03:26:37 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:34652 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727849AbgLHI0g (ORCPT ); Tue, 8 Dec 2020 03:26:36 -0500 Received: from 36-229-231-79.dynamic-ip.hinet.net ([36.229.231.79] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kmYJb-0007bo-CD; Tue, 08 Dec 2020 08:25:44 +0000 From: Kai-Heng Feng To: bhelgaas@google.com Cc: hkallweit1@gmail.com, Kai-Heng Feng , "Saheed O. Bolarinwa" , Mika Westerberg , Chris Packham , Xiongfeng Wang , Yicong Yang , linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/2] PCI/ASPM: Store disabled ASPM states Date: Tue, 8 Dec 2020 16:25:33 +0800 Message-Id: <20201208082534.2460215-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we use sysfs to disable L1 ASPM, then enable one L1 ASPM substate again, all other substates will also be enabled too: link# grep . * clkpm:1 l0s_aspm:1 l1_1_aspm:1 l1_1_pcipm:1 l1_2_aspm:1 l1_2_pcipm:1 l1_aspm:1 link# echo 0 > l1_aspm link# grep . * clkpm:1 l0s_aspm:1 l1_1_aspm:0 l1_1_pcipm:0 l1_2_aspm:0 l1_2_pcipm:0 l1_aspm:0 link# echo 1 > l1_2_aspm link# grep . * clkpm:1 l0s_aspm:1 l1_1_aspm:1 l1_1_pcipm:1 l1_2_aspm:1 l1_2_pcipm:1 l1_aspm:1 This is because disabled ASPM states weren't saved, so enable any of the substate will also enable others. So store the disabled ASPM states for consistency. Signed-off-by: Kai-Heng Feng --- drivers/pci/pcie/aspm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index ac0557a305af..2ea9fddadfad 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -658,6 +658,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) /* Setup initial capable state. Will be updated later */ link->aspm_capable = link->aspm_support; + link->aspm_disable = link->aspm_capable & ~link->aspm_default; + /* Get and check endpoint acceptable latencies */ list_for_each_entry(child, &linkbus->devices, bus_list) { u32 reg32, encoding; @@ -1226,11 +1228,15 @@ static ssize_t aspm_attr_store_common(struct device *dev, mutex_lock(&aspm_lock); if (state_enable) { - link->aspm_disable &= ~state; /* need to enable L1 for substates */ if (state & ASPM_STATE_L1SS) - link->aspm_disable &= ~ASPM_STATE_L1; + state |= ASPM_STATE_L1; + + link->aspm_disable &= ~state; } else { + if (state == ASPM_STATE_L1) + state |= ASPM_STATE_L1SS; + link->aspm_disable |= state; } -- 2.29.2