From patchwork Mon Mar 13 20:48:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9622097 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B3E8E60244 for ; Mon, 13 Mar 2017 20:49:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A112E284ED for ; Mon, 13 Mar 2017 20:49:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95FAE284F5; Mon, 13 Mar 2017 20:49:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49B9F284ED for ; Mon, 13 Mar 2017 20:49:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753957AbdCMUss (ORCPT ); Mon, 13 Mar 2017 16:48:48 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44512 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753920AbdCMUsX (ORCPT ); Mon, 13 Mar 2017 16:48:23 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 87EC760D37; Mon, 13 Mar 2017 20:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1489438101; bh=zpiiycfSlDTj+3o0MuJkJN6+nlmReLVMCdoosf80zsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d/7s1jU0g5JWNgiedeeMaX7m77HgmOgFRpDS5pHe08qtvqKx6nglO6zJuR+wftl4D 5wai4L7Y5n85eg++L56PNKGrqDn+0Z8NrUobLpeOs5kh/bewkhtqKTsXu7dCHTawad o8/TKcRjOHL1T3K8Um2WWiqBD+5pzPiV+eyk4AY8= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 66E8260D0B; Mon, 13 Mar 2017 20:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1489438100; bh=zpiiycfSlDTj+3o0MuJkJN6+nlmReLVMCdoosf80zsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ArsGQc8CAhqZ0XFWqWfWuE8KnCLSXJPHtP1SlpsYWgTyBiVSti0x/4GtqpKbZScrP bqwMIe/ij0M8OfJ+AHYVoqbgaTendOi/o4ahRK8cqCKggd6KJpyDGiQIO/DJtBhSNh qRf6+NyDcLhMCtIMPt7x9uY1lv1K8xBuk4B9S0Tk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 66E8260D0B Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-pci@vger.kernel.org, timur@codeaurora.org Cc: mayurkumar.patel@intel.com, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , Bjorn Helgaas , Shawn Lin , David Daney , Julia Lawall , linux-kernel@vger.kernel.org Subject: [PATCH V4 3/3] PCI/ASPM: move link_state cleanup to bridge remove Date: Mon, 13 Mar 2017 16:48:05 -0400 Message-Id: <1489438085-2055-4-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1489438085-2055-1-git-send-email-okaya@codeaurora.org> References: <1489438085-2055-1-git-send-email-okaya@codeaurora.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For endpoints, change pcie_aspm_exit_link_state() so it cleans up the device's own state and disables ASPM if necessary, but doesn't remove the parent's link_state. For bridges, change pcie_aspm_exit_link_state() so it frees the bridge's own link_state. Signed-off-by: Sinan Kaya --- drivers/pci/pcie/aspm.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index ed67710..6c2d7ea 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -419,8 +419,10 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, */ if (dwreg.support & upreg.support & PCIE_LINK_STATE_L0S) link->aspm_support |= ASPM_STATE_L0S; - if (dwreg.enabled & PCIE_LINK_STATE_L0S) + if (dwreg.enabled & PCIE_LINK_STATE_L0S) { link->aspm_enabled |= ASPM_STATE_L0S_UP; + link->aspm_default |= ASPM_STATE_L0S_UP; + } if (upreg.enabled & PCIE_LINK_STATE_L0S) link->aspm_enabled |= ASPM_STATE_L0S_DW; link->latency_up.l0s = calc_l0s_latency(upreg.latency_encoding_l0s); @@ -434,9 +436,6 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, link->latency_up.l1 = calc_l1_latency(upreg.latency_encoding_l1); link->latency_dw.l1 = calc_l1_latency(dwreg.latency_encoding_l1); - /* Save default state */ - link->aspm_default = link->aspm_enabled; - /* Setup initial capable state. Will be updated later */ link->aspm_capable = link->aspm_support; } @@ -579,6 +578,7 @@ int pci_aspm_init(struct pci_dev *pdev) { int ret; struct pcie_link_state *link; + struct aspm_register_info upreg; if (!aspm_support_enabled) return 0; @@ -601,6 +601,13 @@ int pci_aspm_init(struct pci_dev *pdev) ret = -ENOMEM; goto unlock; } + + pcie_get_aspm_reg(pdev, &upreg); + if (upreg.enabled & PCIE_LINK_STATE_L0S) + link->aspm_default |= ASPM_STATE_L0S_DW; + if (upreg.enabled & PCIE_LINK_STATE_L1) + link->aspm_default |= ASPM_STATE_L1; + } else { WARN_ON(!pdev->bus); if (!pdev->bus) { @@ -748,10 +755,12 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev) /* All functions are removed, so just disable ASPM for the link */ pcie_config_aspm_link(link, 0); - list_del(&link->sibling); - list_del(&link->link); - /* Clock PM is for endpoint device */ - free_link_state(link); + if (pdev->has_secondary_link) { + list_del(&link->sibling); + list_del(&link->link); + /* Clock PM is for endpoint device */ + free_link_state(link); + } /* Recheck latencies and configure upstream links */ if (parent_link) {