From patchwork Sat Oct 5 12:04:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 1172178 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iF6Uaxgb"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46llt506cxz9sPv for ; Sat, 5 Oct 2019 22:09:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727788AbfJEMJn (ORCPT ); Sat, 5 Oct 2019 08:09:43 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46684 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727715AbfJEMJn (ORCPT ); Sat, 5 Oct 2019 08:09:43 -0400 Received: by mail-wr1-f66.google.com with SMTP id o18so10050346wrv.13 for ; Sat, 05 Oct 2019 05:09:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=wBJD05NJvs43JSkNpE6CAGqMMhHik5oVKM6ZCLNUQNM=; b=iF6Uaxgby2MFy1x+4nsUpOiq42iVPRFlRA4pp/GuLjxNCBqVtSq1bNsnigtlfuq4tX acUrBJZ5XWxOYZMD0OZsAAYwRTXlaTsbue6iM+wgNmzwrLyov7Os5GjdFh+bvdatPDw4 5ALCYk3gvU5oylBMw/QOfU5r4AGbuuAuv2oLoMOUi8W8pMLnXRBnNFq8LhNj540DJRoz KC5nCjWhkaGWLy1LoQyH2r3YxUtTJNkdlm/txdhACIgEW8oTi8uY/GsZ0XANOX3gswLM EYQjBcsCrsywNGtYRW+xKi+32v5awZJpUxADQr9d271ISXHdN8NPJae0HdzOQ2Y97h79 cF9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=wBJD05NJvs43JSkNpE6CAGqMMhHik5oVKM6ZCLNUQNM=; b=LGCG2rYI9A0ctuClGReuFEbaenqrsQ4zRvfdAxITtQYUI6qgFAt3a9xu0Y0gC4Vv33 l0yZPXZ+8YKTzj/UsxakXj5qBzoh4uRKh8Ql8I5jqoGHBqCT++AQSQfefh8Jfm8w3OdE ksJjTt0PxDaJzfFwXOVHjclVolyfhagI1cRa9qF5oEW+SN7busPi115vnpu3A1Z9/s3S ZMBO3FQkhfAXQzpeK83DzuBfSY9+pXSFcevE5kmjhFCbxl0d6avYLl5fHaZzrFYISfbC 08r3KHZ6aT7NZ9AE7HqZ9lDG7vFWxwJsZp2RympuxOr/AeTau6VKDPuBls3dKc10ZAUW nPaw== X-Gm-Message-State: APjAAAX5Y12GO7atsCcG3EnX6xmZKpOKHBPo1iTgfEODiZbTDVFOTg1b SRLgQ+SyPfIc5PwyaSdb7OMx2M2F X-Google-Smtp-Source: APXvYqy2vCbH+YGg/lnQejX+FQ3/ObunCtgr0TQ2EsZafLGLywgmzgkewT9cZ4Ep+qHe9V8IRKIC+A== X-Received: by 2002:a5d:694c:: with SMTP id r12mr14725679wrw.44.1570277381180; Sat, 05 Oct 2019 05:09:41 -0700 (PDT) Received: from ?IPv6:2003:ea:8f26:6400:78ef:16af:4ef6:6109? (p200300EA8F26640078EF16AF4EF66109.dip0.t-ipconnect.de. [2003:ea:8f26:6400:78ef:16af:4ef6:6109]) by smtp.googlemail.com with ESMTPSA id j1sm21050541wrg.24.2019.10.05.05.09.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Oct 2019 05:09:40 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH v7 1/5] PCI/ASPM: Add L1 sub-state support to pci_disable_link_state To: Frederick Lawler , Bjorn Helgaas , Greg KH , Rajat Jain Cc: "linux-pci@vger.kernel.org" References: Message-ID: Date: Sat, 5 Oct 2019 14:04:36 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Add support for disabling states L1.1 and L1.2 to pci_disable_link_state(). Allow separate control of ASPM and PCI PM L1 sub-states. Signed-off-by: Heiner Kallweit --- v2: - allow separate control of ASPM and PCI PM L1 sub-states --- drivers/pci/pcie/aspm.c | 11 ++++++++++- include/linux/pci.h | 10 +++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 652ef23bb..ed463339e 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1094,7 +1094,16 @@ static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem) if (state & PCIE_LINK_STATE_L0S) link->aspm_disable |= ASPM_STATE_L0S; if (state & PCIE_LINK_STATE_L1) - link->aspm_disable |= ASPM_STATE_L1; + /* sub-states require L1 */ + link->aspm_disable |= ASPM_STATE_L1 | ASPM_STATE_L1SS; + if (state & PCIE_LINK_STATE_L1_1) + link->aspm_disable |= ASPM_STATE_L1_1; + if (state & PCIE_LINK_STATE_L1_2) + link->aspm_disable |= ASPM_STATE_L1_2; + if (state & PCIE_LINK_STATE_L1_1_PCIPM) + link->aspm_disable |= ASPM_STATE_L1_1_PCIPM; + if (state & PCIE_LINK_STATE_L1_2_PCIPM) + link->aspm_disable |= ASPM_STATE_L1_2_PCIPM; pcie_config_aspm_link(link, policy_to_aspm_state(link)); if (state & PCIE_LINK_STATE_CLKPM) { diff --git a/include/linux/pci.h b/include/linux/pci.h index f9088c89a..9dc5bee14 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1544,9 +1544,13 @@ extern bool pcie_ports_native; #define pcie_ports_native false #endif -#define PCIE_LINK_STATE_L0S 1 -#define PCIE_LINK_STATE_L1 2 -#define PCIE_LINK_STATE_CLKPM 4 +#define PCIE_LINK_STATE_L0S BIT(0) +#define PCIE_LINK_STATE_L1 BIT(1) +#define PCIE_LINK_STATE_CLKPM BIT(2) +#define PCIE_LINK_STATE_L1_1 BIT(3) +#define PCIE_LINK_STATE_L1_2 BIT(4) +#define PCIE_LINK_STATE_L1_1_PCIPM BIT(5) +#define PCIE_LINK_STATE_L1_2_PCIPM BIT(6) #ifdef CONFIG_PCIEASPM int pci_disable_link_state(struct pci_dev *pdev, int state); From patchwork Sat Oct 5 12:03:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 1172177 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gGcGlLjx"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46llt449h0z9sCJ for ; Sat, 5 Oct 2019 22:09:48 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727787AbfJEMJm (ORCPT ); Sat, 5 Oct 2019 08:09:42 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43666 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727612AbfJEMJm (ORCPT ); Sat, 5 Oct 2019 08:09:42 -0400 Received: by mail-wr1-f66.google.com with SMTP id j18so9290511wrq.10 for ; Sat, 05 Oct 2019 05:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=XLEDj7lJ59wa9ec0V3EX//kc9AMcwJTkEP5jkJV1YK4=; b=gGcGlLjxYIdwpqznDgsRp1NM52xTzsyUGSXC4h2AQAyJHDHugIOC6XyrMftIDwK+Ed VLLrBWiwb6bjLq1DDIS+9Q4PC7f6E5wVWljCxQV6w42wsyg9uH1AyrNzThCbhigqTK+/ xZPpkCZ6UEz2dAWbRj8aAsVw1Wk8Xs4OdZppPaI9k9AIm3lmIz8VQ0owFF+c1zB9twfI eXq//5/BQnOS1+lILTq+3ilBgv2xe36NvfVlq0XBzGojMuJG6xWHo+Yg1pC6Vdq73j/f BMsVBAhkXBIgXm5veWdNDLp6zbBK7p1bum6floxj4+vKn/a3WPLazwUVHnVoX6NlIBou KLuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=XLEDj7lJ59wa9ec0V3EX//kc9AMcwJTkEP5jkJV1YK4=; b=n4jyaap0zu78yLXskj/1EDE9LfgVXspu1NfoadunfRDMym+V6tUcw731M31TpsQmBH K+V/6JhamwsG/Pk1VedKalZ8jg3VqLlZysnecAdOC27V9DVwGeXRJEX2D8dZbEsF9oC0 LHcGlneAqXf+vyEIvqeHmW7FpgmU0U5XhIYQPwbzTeFoItholWQLByetaM8GRz1aE5PV a4mwUox8xRzeH55H2Aua2NQaKgAbuOZzhpABo/8yvRMCrkizQmg2+F1b7Rv4NKOQhY6T 0EEQHqvO3752g2luaRyKOya9Uk3YiBr75U0Fooo6frrNWgHZQfAAP93xJxJX7/2Kxj6c 3ILg== X-Gm-Message-State: APjAAAXIAltkBY1kJ7k6fmkwf7QjU62wsAPusQcB2GwCXaKiqmCH0xo3 tnBRIzmGsJ/M45ftCO3+IuI3PU7/ X-Google-Smtp-Source: APXvYqzAcAqUNzXT7jBuVjwrtPxoRGYlrjcGEnd3Un88e+q+6vrvQBcXGysbHQrWF/HajP+jXEJOeg== X-Received: by 2002:adf:e5cb:: with SMTP id a11mr15028175wrn.200.1570277379855; Sat, 05 Oct 2019 05:09:39 -0700 (PDT) Received: from ?IPv6:2003:ea:8f26:6400:78ef:16af:4ef6:6109? (p200300EA8F26640078EF16AF4EF66109.dip0.t-ipconnect.de. [2003:ea:8f26:6400:78ef:16af:4ef6:6109]) by smtp.googlemail.com with ESMTPSA id y186sm19132158wmb.41.2019.10.05.05.09.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Oct 2019 05:09:39 -0700 (PDT) Subject: [PATCH v7 2/5] PCI/ASPM: Allow to re-enable Clock PM From: Heiner Kallweit To: Frederick Lawler , Bjorn Helgaas , Greg KH , Rajat Jain Cc: "linux-pci@vger.kernel.org" References: Message-ID: <4e8a66db-7d53-4a66-c26c-f0037ffaa705@gmail.com> Date: Sat, 5 Oct 2019 14:03:57 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org So far Clock PM can't be re-enabled once it has been disabled with a call to pci_disable_link_state(). Reason is that clkpm_capable is reset. Change this by adding a clkpm_disable field similar to aspm_disable. Signed-off-by: Heiner Kallweit --- drivers/pci/pcie/aspm.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index ed463339e..574f822bf 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -64,6 +64,7 @@ struct pcie_link_state { u32 clkpm_capable:1; /* Clock PM capable? */ u32 clkpm_enabled:1; /* Current Clock PM state */ u32 clkpm_default:1; /* Default Clock PM state by BIOS */ + u32 clkpm_disable:1; /* Clock PM disabled */ /* Exit latencies */ struct aspm_latency latency_up; /* Upstream direction exit latency */ @@ -161,8 +162,11 @@ static void pcie_set_clkpm_nocheck(struct pcie_link_state *link, int enable) static void pcie_set_clkpm(struct pcie_link_state *link, int enable) { - /* Don't enable Clock PM if the link is not Clock PM capable */ - if (!link->clkpm_capable) + /* + * Don't enable Clock PM if the link is not Clock PM capable + * or Clock PM is disabled + */ + if (!link->clkpm_capable || link->clkpm_disable) enable = 0; /* Need nothing if the specified equals to current state */ if (link->clkpm_enabled == enable) @@ -192,7 +196,8 @@ static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist) } link->clkpm_enabled = enabled; link->clkpm_default = enabled; - link->clkpm_capable = (blacklist) ? 0 : capable; + link->clkpm_capable = capable; + link->clkpm_disable = blacklist ? 1 : 0; } static bool pcie_retrain_link(struct pcie_link_state *link) @@ -1106,10 +1111,9 @@ static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem) link->aspm_disable |= ASPM_STATE_L1_2_PCIPM; pcie_config_aspm_link(link, policy_to_aspm_state(link)); - if (state & PCIE_LINK_STATE_CLKPM) { - link->clkpm_capable = 0; - pcie_set_clkpm(link, 0); - } + if (state & PCIE_LINK_STATE_CLKPM) + link->clkpm_disable = 1; + pcie_set_clkpm(link, policy_to_clkpm_state(link)); mutex_unlock(&aspm_lock); if (sem) up_read(&pci_bus_sem); From patchwork Sat Oct 5 12:07:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 1172179 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="X3SyAQSS"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46llt54yFKz9sPw for ; Sat, 5 Oct 2019 22:09:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727715AbfJEMJo (ORCPT ); Sat, 5 Oct 2019 08:09:44 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46028 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727612AbfJEMJo (ORCPT ); Sat, 5 Oct 2019 08:09:44 -0400 Received: by mail-wr1-f65.google.com with SMTP id r5so10044269wrm.12 for ; Sat, 05 Oct 2019 05:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=BKkF5+b2V8NBAHrbTEiaIHhBc1cU2f8cEaSBQmS03Ds=; b=X3SyAQSSak2hP05fmj8yhwHvcCzDj4wv7V7CgDXvSmeH+V3TmIlHcvCHAV34F4UBmU Uoew9WjdRNaYJ7323e+wuqZWiLzvpQTZCGiK53AL4gLq4cIJ9aaLwPMalO9rf6trbWrm 7qmwk19Y3aq88+SDT7afm7CS9OFTruUTYuef8vRaKDr9GaM/gc3iFHpWepZhqAf/WWq2 xL6aKRGO1HyVTAdclfEAttdm1Qy/tEDTcEr4sy2iFhRuay/+hF3rovt195fxdfZN+Pdf 01kgZcztvZOwGG55CiAN4WUEy7dzXp7aWl/e8eNbL2XwEP53Yk1USZg/w+1r4PLHqJq3 asAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BKkF5+b2V8NBAHrbTEiaIHhBc1cU2f8cEaSBQmS03Ds=; b=FdKd3UZG0PjvnuLYPBSJbCFze/eElRLD6VDBhrncIJwvPZ5l/eybQF0JKT6com3YUE bVKtdRkiMpSXTkk72KB7Lnb8WmanUyJ8eMleH1qbtPGRnImBdjg22TC/b32kyGvwMQSA J9rgx5+QpH2+HXIpWNXseh/hO6aXFHy7T5NpC2Rr0BmK6cFYe0/7qREAq5WIGZtJ2A26 NV8HFlpJpnA7L9u2MTJ7yjI4dZ9upbciHXts2IbOgbkwxdHb0ADb2d7PhUMRP49ZDvx8 NGnxWw2Q7Li1PhUhOOaQNTTFz1PY4dMmV3un6VeyWkOQmpLhG/ZcYg9QkGx1wWzIFvHC CdZQ== X-Gm-Message-State: APjAAAWn5ey2pC5BN/WQ8S+MRRgTTuYUkIdZjbQ5IqOx6dagONGYdYOC YUFMqbiwDaMqaANTBX1XIsDRytnk X-Google-Smtp-Source: APXvYqwpNohVLrP1gfYcWSymByu6xHSZNfeJG5KzHzZJb3UjFOXG06QWv4fh9NPyubBQtUoYboyhAw== X-Received: by 2002:a05:6000:11d0:: with SMTP id i16mr5916749wrx.217.1570277382305; Sat, 05 Oct 2019 05:09:42 -0700 (PDT) Received: from ?IPv6:2003:ea:8f26:6400:78ef:16af:4ef6:6109? (p200300EA8F26640078EF16AF4EF66109.dip0.t-ipconnect.de. [2003:ea:8f26:6400:78ef:16af:4ef6:6109]) by smtp.googlemail.com with ESMTPSA id 13sm7050727wmj.29.2019.10.05.05.09.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Oct 2019 05:09:41 -0700 (PDT) Subject: [PATCH v7 3/5] PCI/ASPM: Add and use helper pcie_aspm_get_link From: Heiner Kallweit To: Frederick Lawler , Bjorn Helgaas , Greg KH , Rajat Jain Cc: "linux-pci@vger.kernel.org" References: Message-ID: <19d33770-29de-a9af-4d85-f2b30269d383@gmail.com> Date: Sat, 5 Oct 2019 14:07:18 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Factor out getting the link associated with a pci_dev and use this helper where appropriate. In addition this helper will be used in a subsequent patch of this series. Signed-off-by: Heiner Kallweit --- v7: - add as separate patch --- drivers/pci/pcie/aspm.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 574f822bf..91cfea673 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1066,19 +1066,28 @@ void pcie_aspm_powersave_config_link(struct pci_dev *pdev) up_read(&pci_bus_sem); } +static struct pcie_link_state *pcie_aspm_get_link(struct pci_dev *pdev) +{ + struct pci_dev *upstream; + + if (pcie_downstream_port(pdev)) + upstream = pdev; + else + upstream = pci_upstream_bridge(pdev); + + return upstream ? upstream->link_state : NULL; +} + static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem) { - struct pci_dev *parent = pdev->bus->self; struct pcie_link_state *link; if (!pci_is_pcie(pdev)) return 0; - if (pcie_downstream_port(pdev)) - parent = pdev; - if (!parent || !parent->link_state) + link = pcie_aspm_get_link(pdev); + if (!link) return -EINVAL; - /* * A driver requested that ASPM be disabled on this device, but * if we don't have permission to manage ASPM (e.g., on ACPI @@ -1095,7 +1104,6 @@ static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem) if (sem) down_read(&pci_bus_sem); mutex_lock(&aspm_lock); - link = parent->link_state; if (state & PCIE_LINK_STATE_L0S) link->aspm_disable |= ASPM_STATE_L0S; if (state & PCIE_LINK_STATE_L1) @@ -1188,14 +1196,14 @@ module_param_call(policy, pcie_aspm_set_policy, pcie_aspm_get_policy, */ bool pcie_aspm_enabled(struct pci_dev *pdev) { - struct pci_dev *bridge = pci_upstream_bridge(pdev); + struct pcie_link_state *link = pcie_aspm_get_link(pdev); bool ret; - if (!bridge) + if (!link) return false; mutex_lock(&aspm_lock); - ret = bridge->link_state ? !!bridge->link_state->aspm_enabled : false; + ret = link->aspm_enabled; mutex_unlock(&aspm_lock); return ret; From patchwork Sat Oct 5 12:07:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 1172181 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="sWjv8jWl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46llt662MMz9sPv for ; Sat, 5 Oct 2019 22:09:50 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727612AbfJEMJs (ORCPT ); Sat, 5 Oct 2019 08:09:48 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:35517 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727797AbfJEMJs (ORCPT ); Sat, 5 Oct 2019 08:09:48 -0400 Received: by mail-wm1-f65.google.com with SMTP id y21so8218915wmi.0 for ; Sat, 05 Oct 2019 05:09:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=cJg5BNYgx36rU3i+O8MnkLFHoaynWTce8xtnYdjo5Dk=; b=sWjv8jWlJXcyR9SkxTVKGvOZXKi7ZchFEkZH+OmgZK+P+TugmMnSoU0NNGIB1Ybg3P 4QModicycbsazkxwllkMfjm0d73OaCvnV7f8/TGXzRvOYsFFOtJoxEhhi/FyJnV0urXC ifPnHKg+kNqELiqETRQVdfDI6A2MsIJrhM0x3jE8CgW35uP9NJP4ROlh49dLM0DUncgA jzqQR+iVdrqyHrcxLLubp60EYZF1X5IqW+ULSyG8Zl/MTAHur8VNvwJqRXg7fTIzJgfT EQbD7DqIVlzkogMfaOQNOFvqqXXaDGIWojdNkEz4rtZlSU+qJ5DyZXqTGI1YPTH1OFAY 2bZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cJg5BNYgx36rU3i+O8MnkLFHoaynWTce8xtnYdjo5Dk=; b=L4SpNhDbznIGMHD16R/lszkiwU64lO1jbLE/WmY+qUG9vuUTYF2tzSLwSMNO8pg2NF 2qo9TL56ZCtK9IY9rtSOd1HZVzw29hG0UdbXGq82r3kdT0F5gpFWkh4MCxiUAd3Q1F6W 8myenATVBtk+gfGyKLgvTUJZfHjlsA7eiWmaHSsFXlBchqQ9l9Xalg07UqkXLw1B8ZzJ DQ+/VAkbsc1FTmocxwJzlBmBHJtGnqaAaiecpK6H4SqbUu8AkuSy9jNeNBVFxGyDAd/+ ZVomRmi7poB74hkk5DgXtjmQgYUU4FRtRbPUuoJusLgOq+uz0m/DTTG0DHSHH0SpYLl/ ey0g== X-Gm-Message-State: APjAAAXdK0BuQbSOHaqX1bcB5B1Pqev/xej/PybR8Bv5Le/wL5lbL+fp IzJqGV0BZFJXM1xfNpjOcz1tDidY X-Google-Smtp-Source: APXvYqzBa16ldBGCi1IOAb/Yb50DdrlMk7gGEjzAhFudraIbdY8eM0HnVe7yRonugyexAyzKGqK4xQ== X-Received: by 2002:a1c:a404:: with SMTP id n4mr13954906wme.41.1570277383403; Sat, 05 Oct 2019 05:09:43 -0700 (PDT) Received: from ?IPv6:2003:ea:8f26:6400:78ef:16af:4ef6:6109? (p200300EA8F26640078EF16AF4EF66109.dip0.t-ipconnect.de. [2003:ea:8f26:6400:78ef:16af:4ef6:6109]) by smtp.googlemail.com with ESMTPSA id w9sm16017319wrt.62.2019.10.05.05.09.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Oct 2019 05:09:42 -0700 (PDT) Subject: [PATCH v7 4/5] PCI/ASPM: Add sysfs attributes for controlling ASPM link states From: Heiner Kallweit To: Frederick Lawler , Bjorn Helgaas , Greg KH , Rajat Jain Cc: "linux-pci@vger.kernel.org" References: Message-ID: Date: Sat, 5 Oct 2019 14:07:56 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Background of this extension is a problem with the r8169 network driver. Several combinations of board chipsets and network chip versions have problems if ASPM is enabled, therefore we have to disable ASPM per default. However especially on notebooks ASPM can provide significant power-saving, therefore we want to give users the option to enable ASPM. With the new sysfs attributes users can control which ASPM link-states are enabled/disabled. Signed-off-by: Heiner Kallweit --- v2: - use a dedicated sysfs attribute per link state - allow separate control of ASPM and PCI PM L1 sub-states v3: - statically allocate the attribute group - replace snprintf with printf - base on top of "PCI: Make pcie_downstream_port() available outside of access.c" v4: - add call to sysfs_update_group because is_visible callback returns false always at file creation time - simplify code a little v5: - rebased to latest pci/next v6: - fix style of added documentation and extend it - don't use term "parent" and rename function to pcie_aspm_get_link - rename pcie_check_valid_aspm_endpoint to pcie_is_aspm_dev - enable the sysfs files also selected other port types - avoid usage of !! v7: - change group name from aspm to link_pm - control visibility of attributes individually --- Documentation/ABI/testing/sysfs-bus-pci | 14 ++ drivers/pci/pci-sysfs.c | 3 + drivers/pci/pci.h | 4 + drivers/pci/pcie/aspm.c | 174 ++++++++++++++++++++++++ 4 files changed, 195 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci index 8bfee557e..c86c8ab00 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci +++ b/Documentation/ABI/testing/sysfs-bus-pci @@ -347,3 +347,17 @@ Description: If the device has any Peer-to-Peer memory registered, this file contains a '1' if the memory has been published for use outside the driver that owns the device. + +What: /sys/bus/pci/devices/.../link_pm/clkpm + /sys/bus/pci/devices/.../link_pm/l0s_aspm + /sys/bus/pci/devices/.../link_pm/l1_aspm + /sys/bus/pci/devices/.../link_pm/l1_1_aspm + /sys/bus/pci/devices/.../link_pm/l1_2_aspm + /sys/bus/pci/devices/.../link_pm/l1_1_pcipm + /sys/bus/pci/devices/.../link_pm/l1_2_pcipm +Date: October 2019 +Contact: Heiner Kallweit +Description: If ASPM is supported for an endpoint, then these files + can be used to disable or enable the individual + power management states. Write y/1/on to enable, + n/0/off to disable. diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 793412954..0e76c02e0 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1587,6 +1587,9 @@ static const struct attribute_group *pci_dev_attr_groups[] = { &pcie_dev_attr_group, #ifdef CONFIG_PCIEAER &aer_stats_attr_group, +#endif +#ifdef CONFIG_PCIEASPM + &aspm_ctrl_attr_group, #endif NULL, }; diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 3f6947ee3..b2cd21e8c 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -667,4 +667,8 @@ static inline int pci_acpi_program_hp_params(struct pci_dev *dev) } #endif +#ifdef CONFIG_PCIEASPM +extern const struct attribute_group aspm_ctrl_attr_group; +#endif + #endif /* DRIVERS_PCI_H */ diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 91cfea673..05ea02abf 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -899,6 +899,14 @@ static struct pcie_link_state *alloc_pcie_link_state(struct pci_dev *pdev) return link; } +static void pcie_aspm_update_sysfs_visibility(struct pci_dev *pdev) +{ + struct pci_dev *child; + + list_for_each_entry(child, &pdev->subordinate->devices, bus_list) + sysfs_update_group(&child->dev.kobj, &aspm_ctrl_attr_group); +} + /* * pcie_aspm_init_link_state: Initiate PCI express link state. * It is called after the pcie and its children devices are scanned. @@ -960,6 +968,9 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev) pcie_set_clkpm(link, policy_to_clkpm_state(link)); } + /* Update visibility of ASPM sysfs attributes */ + pcie_aspm_update_sysfs_visibility(pdev); + unlock: mutex_unlock(&aspm_lock); out: @@ -1315,6 +1326,169 @@ void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev) } #endif +static ssize_t aspm_attr_show_common(struct device *dev, + struct device_attribute *attr, + char *buf, u8 state) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct pcie_link_state *link; + bool enabled; + + link = pcie_aspm_get_link(pdev); + + mutex_lock(&aspm_lock); + enabled = link->aspm_enabled & state; + mutex_unlock(&aspm_lock); + + return sprintf(buf, "%d\n", enabled ? 1 : 0); +} + +static ssize_t aspm_attr_store_common(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len, u8 state) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct pcie_link_state *link; + bool state_enable; + + link = pcie_aspm_get_link(pdev); + + if (strtobool(buf, &state_enable) < 0) + return -EINVAL; + + down_read(&pci_bus_sem); + mutex_lock(&aspm_lock); + + if (state_enable) { + link->aspm_disable &= ~state; + /* need to enable L1 for sub-states */ + if (state & ASPM_STATE_L1SS) + link->aspm_disable &= ~ASPM_STATE_L1; + } else { + link->aspm_disable |= state; + } + + pcie_config_aspm_link(link, policy_to_aspm_state(link)); + + mutex_unlock(&aspm_lock); + up_read(&pci_bus_sem); + + return len; +} + +#define ASPM_ATTR(_f, _s) \ +static ssize_t _f##_show(struct device *dev, \ + struct device_attribute *attr, char *buf) \ +{ return aspm_attr_show_common(dev, attr, buf, ASPM_STATE_##_s); } \ + \ +static ssize_t _f##_store(struct device *dev, \ + struct device_attribute *attr, \ + const char *buf, size_t len) \ +{ return aspm_attr_store_common(dev, attr, buf, len, ASPM_STATE_##_s); } + +ASPM_ATTR(l0s_aspm, L0S) +ASPM_ATTR(l1_aspm, L1) +ASPM_ATTR(l1_1_aspm, L1_1) +ASPM_ATTR(l1_2_aspm, L1_2) +ASPM_ATTR(l1_1_pcipm, L1_1_PCIPM) +ASPM_ATTR(l1_2_pcipm, L1_2_PCIPM) + +static ssize_t clkpm_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct pcie_link_state *link; + int val; + + link = pcie_aspm_get_link(pdev); + + mutex_lock(&aspm_lock); + val = link->clkpm_enabled; + mutex_unlock(&aspm_lock); + + return sprintf(buf, "%d\n", val); +} + +static ssize_t clkpm_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct pcie_link_state *link; + bool state_enable; + + link = pcie_aspm_get_link(pdev); + + if (strtobool(buf, &state_enable) < 0) + return -EINVAL; + + down_read(&pci_bus_sem); + mutex_lock(&aspm_lock); + + link->clkpm_disable = !state_enable; + pcie_set_clkpm(link, policy_to_clkpm_state(link)); + + mutex_unlock(&aspm_lock); + up_read(&pci_bus_sem); + + return len; +} + +static DEVICE_ATTR_RW(clkpm); +static DEVICE_ATTR_RW(l0s_aspm); +static DEVICE_ATTR_RW(l1_aspm); +static DEVICE_ATTR_RW(l1_1_aspm); +static DEVICE_ATTR_RW(l1_2_aspm); +static DEVICE_ATTR_RW(l1_1_pcipm); +static DEVICE_ATTR_RW(l1_2_pcipm); + +static struct attribute *aspm_ctrl_attrs[] = { + &dev_attr_clkpm.attr, + &dev_attr_l0s_aspm.attr, + &dev_attr_l1_aspm.attr, + &dev_attr_l1_1_aspm.attr, + &dev_attr_l1_2_aspm.attr, + &dev_attr_l1_1_pcipm.attr, + &dev_attr_l1_2_pcipm.attr, + NULL +}; + +static umode_t aspm_ctrl_attrs_are_visible(struct kobject *kobj, + struct attribute *a, int n) +{ + struct device *dev = kobj_to_dev(kobj); + struct pci_dev *pdev = to_pci_dev(dev); + struct pcie_link_state *link = NULL; + static const u8 aspm_state_map[] = { + ASPM_STATE_L0S, + ASPM_STATE_L1, + ASPM_STATE_L1_1, + ASPM_STATE_L1_2, + ASPM_STATE_L1_1_PCIPM, + ASPM_STATE_L1_2_PCIPM, + }; + + if (aspm_disabled) + return 0; + + if (pci_is_pcie(pdev)) + link = pcie_aspm_get_link(pdev); + + if (!link) + return 0; + + if (n) + return link->aspm_capable & aspm_state_map[n - 1] ? a->mode : 0; + else + return link->clkpm_capable ? a->mode : 0; +} + +const struct attribute_group aspm_ctrl_attr_group = { + .name = "link_pm", + .attrs = aspm_ctrl_attrs, + .is_visible = aspm_ctrl_attrs_are_visible, +}; + static int __init pcie_aspm_disable(char *str) { if (!strcmp(str, "off")) { From patchwork Sat Oct 5 12:08:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 1172180 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WX1ams1f"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46llt61jQPz9sCJ for ; Sat, 5 Oct 2019 22:09:50 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727801AbfJEMJr (ORCPT ); Sat, 5 Oct 2019 08:09:47 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:50358 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727612AbfJEMJr (ORCPT ); Sat, 5 Oct 2019 08:09:47 -0400 Received: by mail-wm1-f65.google.com with SMTP id 5so8224958wmg.0 for ; Sat, 05 Oct 2019 05:09:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=fPOwJXP7eu2TBWO+OVyu9GToqz4RTMNIKoPIeY2boJ8=; b=WX1ams1farKQxkx27ruJ0SG7V21a328YgNx3d0y9B+EhR2WNCfOHxmIYiwGs+czRKv wqfRoKXxfntrPFhsMt/lY2pjGbL2PGvVGdItaLPpEx+omwBM8RqWz8/MbHxFTXdyX+vc ANVYVvI8UbtsG5JPZc5/cDZqSJ0X7LrkLzMjjd31x0F4AiTfT54Zsezr/xvqAPWPWE8R Yo8wJXAMPVE+W/Oxcs6ADxckihNe+oFoiVzw6SscTxRSuBMhUUolRHwtxdeCXHT9CHsg lo+5wWY6YuTDU9PJalsMLNReoYhICCAhQ5O0ZfRw+2K3Z2CO0ztA3dxfC9CWIc0miwhe SW2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=fPOwJXP7eu2TBWO+OVyu9GToqz4RTMNIKoPIeY2boJ8=; b=KbX2RhQ2MKIPFQ98qexHE8aclR/lYbqxk46nTKnG40jSVlNzydQ3Fufaz/LzHC6DJn 9FB5UNtoyQhbAtwIX8JeSQnzKt8RTBNBPGPbKn0gMWH+VusJkTbpHReAxGWP9syDfWrz M3qNdXj2SMPgaMf/9JFptI6h6EdDkftti7ubd8JqYJakWzrAwIIgRgUb0I11RLRo40Tz E30DxXsYKqMtZHQ1GfgEO2HCbbd7VLShGRfDjx/XFWKLc22E+zw3Qja8kfbAAVj8S6q9 pa59NOazFKmeaNljU8NJ2QBliyRGsDpZB0VWf50+21PdXrOITqnjlxm3JdYd1GJFU5Ad XX+w== X-Gm-Message-State: APjAAAWthbvIDjvtN54yHxKUISZzndPg+xDIhv5lMcrm0TrcApEd8EP1 zBo/L1HsdbCgn3homXFdE7J6zCWX X-Google-Smtp-Source: APXvYqzWDf0RZ7HYnWgRb/uBPs8Z+gu4ufbCtSEZg8rlOR5axnVcGM6gxFda8rAVNVhAIM0Vp+AshA== X-Received: by 2002:a05:600c:141:: with SMTP id w1mr14086691wmm.75.1570277384470; Sat, 05 Oct 2019 05:09:44 -0700 (PDT) Received: from ?IPv6:2003:ea:8f26:6400:78ef:16af:4ef6:6109? (p200300EA8F26640078EF16AF4EF66109.dip0.t-ipconnect.de. [2003:ea:8f26:6400:78ef:16af:4ef6:6109]) by smtp.googlemail.com with ESMTPSA id n8sm12898684wma.7.2019.10.05.05.09.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Oct 2019 05:09:44 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH v7 5/5] PCI/ASPM: Remove Kconfig option PCIEASPM_DEBUG and related code To: Frederick Lawler , Bjorn Helgaas , Greg KH , Rajat Jain Cc: "linux-pci@vger.kernel.org" References: Message-ID: Date: Sat, 5 Oct 2019 14:08:52 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Now that we have sysfs attributes for enabling/disabling the individual ASPM link states, this debug code isn't needed any longer. Removing this debug code has been discussed for quite some time, see e.g. [0]. [0] https://lore.kernel.org/lkml/20180727202619.GD173328@bhelgaas-glaptop.roam.corp.google.com/ Signed-off-by: Heiner Kallweit --- v6: - add discussion link to commit message --- drivers/pci/pci-sysfs.c | 3 -- drivers/pci/pci.h | 8 --- drivers/pci/pcie/Kconfig | 7 --- drivers/pci/pcie/aspm.c | 105 --------------------------------------- 4 files changed, 123 deletions(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 0e76c02e0..92bf1b1ce 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1330,7 +1330,6 @@ static int pci_create_capabilities_sysfs(struct pci_dev *dev) int retval; pcie_vpd_create_sysfs_dev_files(dev); - pcie_aspm_create_sysfs_dev_files(dev); if (dev->reset_fn) { retval = device_create_file(&dev->dev, &dev_attr_reset); @@ -1340,7 +1339,6 @@ static int pci_create_capabilities_sysfs(struct pci_dev *dev) return 0; error: - pcie_aspm_remove_sysfs_dev_files(dev); pcie_vpd_remove_sysfs_dev_files(dev); return retval; } @@ -1416,7 +1414,6 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev) static void pci_remove_capabilities_sysfs(struct pci_dev *dev) { pcie_vpd_remove_sysfs_dev_files(dev); - pcie_aspm_remove_sysfs_dev_files(dev); if (dev->reset_fn) { device_remove_file(&dev->dev, &dev_attr_reset); dev->reset_fn = 0; diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index b2cd21e8c..ae231e3cd 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -541,14 +541,6 @@ static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev) { } static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev) { } #endif -#ifdef CONFIG_PCIEASPM_DEBUG -void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev); -void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev); -#else -static inline void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev) { } -static inline void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev) { } -#endif - #ifdef CONFIG_PCIE_ECRC void pcie_set_ecrc_checking(struct pci_dev *dev); void pcie_ecrc_get_policy(char *str); diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig index 362eb8cfa..a2e862d4e 100644 --- a/drivers/pci/pcie/Kconfig +++ b/drivers/pci/pcie/Kconfig @@ -79,13 +79,6 @@ config PCIEASPM When in doubt, say Y. -config PCIEASPM_DEBUG - bool "Debug PCI Express ASPM" - depends on PCIEASPM - help - This enables PCI Express ASPM debug support. It will add per-device - interface to control ASPM. - choice prompt "Default ASPM policy" default PCIEASPM_DEFAULT diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 05ea02abf..896299a6b 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1221,111 +1221,6 @@ bool pcie_aspm_enabled(struct pci_dev *pdev) } EXPORT_SYMBOL_GPL(pcie_aspm_enabled); -#ifdef CONFIG_PCIEASPM_DEBUG -static ssize_t link_state_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct pci_dev *pci_device = to_pci_dev(dev); - struct pcie_link_state *link_state = pci_device->link_state; - - return sprintf(buf, "%d\n", link_state->aspm_enabled); -} - -static ssize_t link_state_store(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t n) -{ - struct pci_dev *pdev = to_pci_dev(dev); - struct pcie_link_state *link, *root = pdev->link_state->root; - u32 state; - - if (aspm_disabled) - return -EPERM; - - if (kstrtouint(buf, 10, &state)) - return -EINVAL; - if ((state & ~ASPM_STATE_ALL) != 0) - return -EINVAL; - - down_read(&pci_bus_sem); - mutex_lock(&aspm_lock); - list_for_each_entry(link, &link_list, sibling) { - if (link->root != root) - continue; - pcie_config_aspm_link(link, state); - } - mutex_unlock(&aspm_lock); - up_read(&pci_bus_sem); - return n; -} - -static ssize_t clk_ctl_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct pci_dev *pci_device = to_pci_dev(dev); - struct pcie_link_state *link_state = pci_device->link_state; - - return sprintf(buf, "%d\n", link_state->clkpm_enabled); -} - -static ssize_t clk_ctl_store(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t n) -{ - struct pci_dev *pdev = to_pci_dev(dev); - bool state; - - if (strtobool(buf, &state)) - return -EINVAL; - - down_read(&pci_bus_sem); - mutex_lock(&aspm_lock); - pcie_set_clkpm_nocheck(pdev->link_state, state); - mutex_unlock(&aspm_lock); - up_read(&pci_bus_sem); - - return n; -} - -static DEVICE_ATTR_RW(link_state); -static DEVICE_ATTR_RW(clk_ctl); - -static char power_group[] = "power"; -void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev) -{ - struct pcie_link_state *link_state = pdev->link_state; - - if (!link_state) - return; - - if (link_state->aspm_support) - sysfs_add_file_to_group(&pdev->dev.kobj, - &dev_attr_link_state.attr, power_group); - if (link_state->clkpm_capable) - sysfs_add_file_to_group(&pdev->dev.kobj, - &dev_attr_clk_ctl.attr, power_group); -} - -void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev) -{ - struct pcie_link_state *link_state = pdev->link_state; - - if (!link_state) - return; - - if (link_state->aspm_support) - sysfs_remove_file_from_group(&pdev->dev.kobj, - &dev_attr_link_state.attr, power_group); - if (link_state->clkpm_capable) - sysfs_remove_file_from_group(&pdev->dev.kobj, - &dev_attr_clk_ctl.attr, power_group); -} -#endif - static ssize_t aspm_attr_show_common(struct device *dev, struct device_attribute *attr, char *buf, u8 state)