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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1339142492-13625-2-git-send-email-xudong.hao@intel.com>
Date:	Fri,  8 Jun 2012 16:01:29 +0800
From:	Xudong Hao <xudong.hao@...el.com>
To:	bhelgaas@...gle.com
Cc:	linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
	kvm@...r.kernel.org, avi@...hat.com, alex.williamson@...hat.com,
	ddutile@...hat.com, myron.stowe@...hat.com,
	xiantao.zhang@...el.com, xudong.hao@...el.com
Subject: [PATCH 1/4] Add pci_obff_supported() function.

Add pci_obff_supported() function and use it by obff relative function.

Signed-off-by: Xudong Hao <xudong.hao@...el.com>
---
 drivers/pci/pci.c |   30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 447e834..a70093b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -39,6 +39,7 @@ EXPORT_SYMBOL(pci_pci_problems);
 
 unsigned int pci_pm_d3_delay;
 
+static bool pci_obff_supported(struct pci_dev *dev);
 static void pci_pme_list_scan(struct work_struct *work);
 
 static LIST_HEAD(pci_pme_list);
@@ -2071,6 +2072,27 @@ void pci_disable_ido(struct pci_dev *dev, unsigned long type)
 EXPORT_SYMBOL(pci_disable_ido);
 
 /**
+ * pci_obff_supported - check whether a device supports OBFF 
+ * @dev: PCI device
+ *
+ * RETURNS:
+ * True if @dev supports optimized buffer flush/fill, false otherwise.
+ */
+static bool pci_obff_supported(struct pci_dev *dev)
+{
+	int pos;
+	u32 cap;
+
+	pos = pci_pcie_cap(dev);
+	if (!pos)
+		return false;
+
+	pci_read_config_dword(dev, pos + PCI_EXP_DEVCAP2, &cap);
+
+	return cap & PCI_EXP_OBFF_MASK;
+}
+
+/**
  * pci_enable_obff - enable optimized buffer flush/fill
  * @dev: PCI device
  * @type: type of signaling to use
@@ -2096,17 +2118,13 @@ int pci_enable_obff(struct pci_dev *dev, enum pci_obff_signal_type type)
 	u16 ctrl;
 	int ret;
 
-	if (!pci_is_pcie(dev))
+	if (!pci_obff_supported(dev))
 		return -ENOTSUPP;
 
 	pos = pci_pcie_cap(dev);
 	if (!pos)
 		return -ENOTSUPP;
 
-	pci_read_config_dword(dev, pos + PCI_EXP_DEVCAP2, &cap);
-	if (!(cap & PCI_EXP_OBFF_MASK))
-		return -ENOTSUPP; /* no OBFF support at all */
-
 	/* Make sure the topology supports OBFF as well */
 	if (dev->bus) {
 		ret = pci_enable_obff(dev->bus->self, type);
@@ -2149,7 +2167,7 @@ void pci_disable_obff(struct pci_dev *dev)
 	int pos;
 	u16 ctrl;
 
-	if (!pci_is_pcie(dev))
+	if (!pci_obff_supported(dev))
 		return;
 
 	pos = pci_pcie_cap(dev);
-- 
1.5.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