Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1587126 > unrolled thread

[PATCH] PCI,pciehp: Not write linkctrl register if val is changed

Started byYinghai Lu <yinghai@kernel.org>
First post2017-02-23 22:40 +0100
Last post2017-02-23 22:40 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] PCI,pciehp: Not write linkctrl register if val is changed Yinghai Lu <yinghai@kernel.org> - 2017-02-23 22:40 +0100

#1587126 — [PATCH] PCI,pciehp: Not write linkctrl register if val is changed

FromYinghai Lu <yinghai@kernel.org>
Date2017-02-23 22:40 +0100
Subject[PATCH] PCI,pciehp: Not write linkctrl register if val is changed
Message-ID<te9hf-6UP-9@gated-at.bofh.it>
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.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/hotplug/pciehp_hpc.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 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
@@ -336,17 +336,21 @@ int pciehp_check_link_status(struct cont
 static int __pciehp_link_set(struct controller *ctrl, bool enable)
 {
 	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;
 
-	pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, lnk_ctrl);
+	if (old_lnk_ctrl == lnk_ctrl)
+		return 0;
+
 	ctrl_dbg(ctrl, "%s: lnk_ctrl = %x\n", __func__, lnk_ctrl);
+	pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, lnk_ctrl);
 	return 0;
 }
 

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web