From patchwork Wed Mar 29 23:04:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9652713 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 EEA69602BE for ; Wed, 29 Mar 2017 23:05:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E10EA28540 for ; Wed, 29 Mar 2017 23:05:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5C6228560; Wed, 29 Mar 2017 23:05:11 +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 918E828540 for ; Wed, 29 Mar 2017 23:05:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933108AbdC2XE6 (ORCPT ); Wed, 29 Mar 2017 19:04:58 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:50802 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932945AbdC2XEz (ORCPT ); Wed, 29 Mar 2017 19:04:55 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 5093960E0C; Wed, 29 Mar 2017 23:04:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1490828689; bh=y3g2bDxthkoMc38Y6H5rsJ/llF3BpEkznhCU6Qo6OiY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IfPvV8pOdTfn6sxx6Cka3uQVUY1Gi7zUQCS9DnUNef7DGKuPR5pi67HqWxt2eUZk5 upgd3/N9bIt2Rc5ejMsd3CbDyfxqv3dpM48AsKAOzaJGbFACFjxh+StaY7kAgWjLQv ABXHJNyKF/s8vhibVxRohy011aLPmpcACD/WtSbQ= 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 82BEF607E2; Wed, 29 Mar 2017 23:04:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1490828688; bh=y3g2bDxthkoMc38Y6H5rsJ/llF3BpEkznhCU6Qo6OiY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nLF9A8+OjTNJqCrzAd9v/2s1x7vrhCVLIawZwE+wz1UsMbOgK8vQZHj68x1uqHTmP 5f2/AXWsci6eExOOI4u1b8h4vfEUUaurNdhxm/BX1OGY7aLn7Lw3/L0J3vcBSK0BL1 OO61PWdMDEo7xw3xQU/X6L5rBmHHcKw2fhQa2SFg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 82BEF607E2 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 , Rajat Jain , David Daney , Yinghai Lu , linux-kernel@vger.kernel.org Subject: [PATCH V6 5/5] PCI/ASPM: move link_state cleanup to bridge remove Date: Wed, 29 Mar 2017 19:04:27 -0400 Message-Id: <1490828667-30973-6-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490828667-30973-1-git-send-email-okaya@codeaurora.org> References: <1490828667-30973-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. Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=194895 Signed-off-by: Sinan Kaya --- drivers/pci/pcie/aspm.c | 20 +++++++++++++++----- drivers/pci/remove.c | 3 +-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index a38602a..37ca9b3 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -963,6 +963,21 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev) if (!parent || !parent->link_state) return; + if (pdev->has_secondary_link) { + link = pdev->link_state; + down_read(&pci_bus_sem); + mutex_lock(&aspm_lock); + + list_del(&link->sibling); + list_del(&link->link); + + /* Clock PM is for endpoint device */ + free_link_state(link); + mutex_unlock(&aspm_lock); + up_read(&pci_bus_sem); + return; + } + down_read(&pci_bus_sem); mutex_lock(&aspm_lock); /* @@ -978,11 +993,6 @@ 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); - /* Recheck latencies and configure upstream links */ if (parent_link) { pcie_update_aspm_capable(root); diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 73a03d3..7e14ebd 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -25,8 +25,7 @@ static void pci_stop_dev(struct pci_dev *dev) dev->is_added = 0; } - if (dev->bus->self) - pcie_aspm_exit_link_state(dev); + pcie_aspm_exit_link_state(dev); } static void pci_destroy_dev(struct pci_dev *dev)