From patchwork Fri Feb 24 06:54:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 731942 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 3vV21H18ngz9s7t for ; Fri, 24 Feb 2017 17:55:31 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751319AbdBXGzJ (ORCPT ); Fri, 24 Feb 2017 01:55:09 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:31874 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751115AbdBXGzH (ORCPT ); Fri, 24 Feb 2017 01:55:07 -0500 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v1O6t22g023244 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Feb 2017 06:55:02 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v1O6t1Ot014414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Feb 2017 06:55:02 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v1O6t107007099; Fri, 24 Feb 2017 06:55:01 GMT Received: from localhost.localdomain (/10.159.174.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 23 Feb 2017 22:55:01 -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] PCI,pciehp: Skip not changed command write Date: Thu, 23 Feb 2017 22:54:49 -0800 Message-Id: <20170224065449.14997-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 Notice two systems with different cpu hve different print out when power on slots: First one: pciehp 0000:60:03.2:pcie004: pciehp_green_led_on: SLOTCTRL a8 write cmd 100 pciehp 0000:60:03.2:pcie004: pciehp_set_attention_status: SLOTCTRL a8 write cmd c0 pciehp 0000:60:03.2:pcie004: pending interrupts 0x0010 from Slot Status Second one: pciehp 0000:73:00.0:pcie004: pciehp_green_led_on: SLOTCTRL a8 write cmd 100 pciehp 0000:73:00.0:pcie004: pciehp_set_attention_status: SLOTCTRL a8 write cmd c0 pciehp 0000:73:00.0:pcie004: pending interrupts 0x0010 from Slot Status pciehp 0000:73:00.0:pcie004: pending interrupts 0x0010 from Slot Status Actually attention is not changed on both. First one will not generate CC if write not change cmd. Second one will generate CC even if write not change cmd. To avoid those difference interrupts, check if we are trying to write same cmd, if so skip writing. Signed-off-by: Yinghai Lu --- drivers/pci/hotplug/pciehp_hpc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 @@ -186,7 +186,7 @@ static void pcie_do_write_cmd(struct con u16 mask, bool wait) { struct pci_dev *pdev = ctrl_dev(ctrl); - u16 slot_ctrl; + u16 slot_ctrl, old_slot_ctrl; mutex_lock(&ctrl->ctrl_lock); @@ -201,8 +201,14 @@ static void pcie_do_write_cmd(struct con goto out; } + old_slot_ctrl = slot_ctrl; slot_ctrl &= ~mask; slot_ctrl |= (cmd & mask); + if (slot_ctrl == old_slot_ctrl) { + ctrl_dbg(ctrl, "%s: mask/cmd %x/%x no change\n", __func__, + mask, cmd & mask); + goto out; + } ctrl->cmd_busy = 1; smp_mb(); pcie_capability_write_word(pdev, PCI_EXP_SLTCTL, slot_ctrl);