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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 17 Dec 2014 13:02:24 -0500
From:	Murali Karicheri <m-karicheri2@...com>
To:	<gregkh@...uxfoundation.org>, <vinod.koul@...el.com>,
	<dmaengine@...r.kernel.org>, <bhelgaas@...gle.com>,
	<linux-pci@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<arnd@...db.de>, <linux-arm-kernel@...ts.infradead.org>
CC:	Murali Karicheri <m-karicheri2@...com>
Subject: [RFC PATCH 2/2] PCI: get device dma configuration from parent

This patch makes use of the helper function dma_get_parent_cfg() to
get dma configuration from the parent of the root bus bridge device.
One particular comfiguration that is required for Keystone PCI devices
to function correctly is the dma_pfn_offset that has to be correctly
set in the pci device's device structure in order for getting the
dma_mask right for the device.

Signed-off-by: Murali Karicheri <m-karicheri2@...com>
---
 drivers/pci/probe.c |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c8ca98c..8f4d55b 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1519,6 +1519,8 @@ static void pci_init_capabilities(struct pci_dev *dev)
 
 void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
 {
+	struct pci_bus *temp_bus = bus;
+	struct device *parent;
 	int ret;
 
 	pci_configure_device(dev);
@@ -1527,9 +1529,21 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
 	dev->dev.release = pci_release_dev;
 
 	set_dev_node(&dev->dev, pcibus_to_node(bus));
-	dev->dev.dma_mask = &dev->dma_mask;
-	dev->dev.dma_parms = &dev->dma_parms;
-	dev->dev.coherent_dma_mask = 0xffffffffull;
+	/*
+	 * look for host bridge and check if the dma parameters
+	 * can be copied from parent
+	 */
+	while (!pci_is_root_bus(temp_bus))
+		temp_bus = temp_bus->parent;
+
+	parent = temp_bus->bridge->parent;
+
+	/* override with parent dma configuration if available */
+	if (dma_get_parent_cfg(&dev->dev, parent) < 0) {
+		dev->dev.dma_mask = &dev->dma_mask;
+		dev->dev.dma_parms = &dev->dma_parms;
+		dev->dev.coherent_dma_mask = 0xffffffffull;
+	}
 
 	pci_set_dma_max_seg_size(dev, 65536);
 	pci_set_dma_seg_boundary(dev, 0xffffffff);
-- 
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