[kvm-unit-tests PATCH 09/14] pci: provide pci_set_master()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



And set master by default for pci devices. So that DMA is allowed.

Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
---
 lib/pci.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/pci.c b/lib/pci.c
index ef0b02a..044e4db 100644
--- a/lib/pci.c
+++ b/lib/pci.c
@@ -7,6 +7,13 @@
 #include "pci.h"
 #include "asm/pci.h"
 
+static void pci_set_master(pci_dev *dev, int master)
+{
+	uint32_t val = pci_config_read(dev->pci_addr, PCI_COMMAND);
+	val |= PCI_COMMAND_MASTER;
+	pci_config_write(dev->pci_addr, PCI_COMMAND, val);
+}
+
 /*
  * Scan bus look for a specific device. Only bus 0 scanned for now.
  * After the scan, a pci_dev is returned with correct BAR information.
@@ -41,6 +48,8 @@ int pci_dev_init(pci_dev *dev, uint16_t vendor_id, uint16_t device_id)
 	}
 	dev->inited = true;
 
+	pci_set_master(dev, 1);
+
 	return 0;
 }
 
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux