From patchwork Thu Feb 23 21:37:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 731768 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vTnf55p07z9s0Z for ; Fri, 24 Feb 2017 08:38:05 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751222AbdBWViE (ORCPT ); Thu, 23 Feb 2017 16:38:04 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:27783 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751207AbdBWViD (ORCPT ); Thu, 23 Feb 2017 16:38:03 -0500 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v1NLbutp021993 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Feb 2017 21:37:57 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v1NLbua6015691 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 23 Feb 2017 21:37:56 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v1NLbuBj010442; Thu, 23 Feb 2017 21:37:56 GMT Received: from localhost.localdomain (/10.159.149.188) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 23 Feb 2017 13:37:56 -0800 From: Yinghai Lu To: Bjorn Helgaas Cc: Ashok Raj , james puthukattukaran , Yinghai Lu , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH -v2] PCI, pciehp: Not write linkctrl register if val is not changed Date: Thu, 23 Feb 2017 13:37:47 -0800 Message-Id: <20170223213747.12154-1-yinghai@kernel.org> X-Mailer: git-send-email 2.8.3 X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Most system have port link enabled by default, and should not have confusing printout. Also move printout before actully write, so could make debug print in order. -v2: inline __pciehp_link_set into pciehp_link_enable Signed-off-by: Yinghai Lu --- drivers/pci/hotplug/pciehp_hpc.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) Index: linux-2.6/drivers/pci/hotplug/pciehp_hpc.c =================================================================== --- linux-2.6.orig/drivers/pci/hotplug/pciehp_hpc.c +++ linux-2.6/drivers/pci/hotplug/pciehp_hpc.c @@ -333,28 +333,23 @@ int pciehp_check_link_status(struct cont return 0; } -static int __pciehp_link_set(struct controller *ctrl, bool enable) +static int pciehp_link_enable(struct controller *ctrl) { struct pci_dev *pdev = ctrl_dev(ctrl); - u16 lnk_ctrl; + u16 lnk_ctrl, old_lnk_ctrl; pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &lnk_ctrl); + old_lnk_ctrl = lnk_ctrl; - if (enable) - lnk_ctrl &= ~PCI_EXP_LNKCTL_LD; - else - lnk_ctrl |= PCI_EXP_LNKCTL_LD; + lnk_ctrl &= ~PCI_EXP_LNKCTL_LD; + if (old_lnk_ctrl == lnk_ctrl) + return 0; - pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, lnk_ctrl); ctrl_dbg(ctrl, "%s: lnk_ctrl = %x\n", __func__, lnk_ctrl); + pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, lnk_ctrl); return 0; } -static int pciehp_link_enable(struct controller *ctrl) -{ - return __pciehp_link_set(ctrl, true); -} - int pciehp_get_raw_indicator_status(struct hotplug_slot *hotplug_slot, u8 *status) {