lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1377209958-26362-1-git-send-email-zoltan.kiss@citrix.com>
Date:	Thu, 22 Aug 2013 23:19:18 +0100
From:	Zoltan Kiss <zoltan.kiss@...rix.com>
To:	Bjorn Helgaas <bhelgaas@...gle.com>, <linux-pci@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>
CC:	Zoltan Kiss <zoltan.kiss@...rix.com>
Subject: [PATCH] pci: avoid unnecessary writing of the command register during probe

While I tracked an another bug, I noticed that the PCI command register is
quite often updated here unnecessarily.

Signed-off-by: Zoltan Kiss <zoltan.kiss@...rix.com>
---
 drivers/pci/probe.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 46ada5c..54f6bec 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -178,8 +178,12 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
 	/* No printks while decoding is disabled! */
 	if (!dev->mmio_always_on) {
 		pci_read_config_word(dev, PCI_COMMAND, &orig_cmd);
-		pci_write_config_word(dev, PCI_COMMAND,
-			orig_cmd & ~(PCI_COMMAND_MEMORY | PCI_COMMAND_IO));
+		if (orig_cmd & (PCI_COMMAND_MEMORY | PCI_COMMAND_IO)) {
+			pci_write_config_word(dev,
+				PCI_COMMAND,
+				orig_cmd &
+				~(PCI_COMMAND_MEMORY | PCI_COMMAND_IO));
+		}
 	}
 
 	res->name = pci_name(dev);
@@ -293,7 +297,8 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
 fail:
 	res->flags = 0;
 out:
-	if (!dev->mmio_always_on)
+	if (!dev->mmio_always_on &&
+		(orig_cmd & (PCI_COMMAND_MEMORY | PCI_COMMAND_IO)))
 		pci_write_config_word(dev, PCI_COMMAND, orig_cmd);
 
 	if (bar_too_big)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ