[PATCH kvm-unit-tests 10/17] pci: provide pci_set_master()

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

 



We need to call this whenever we want to do DMA with a device.

Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
---
 lib/pci.c | 7 +++++++
 lib/pci.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/lib/pci.c b/lib/pci.c
index 95a6581..1495f61 100644
--- a/lib/pci.c
+++ b/lib/pci.c
@@ -7,6 +7,13 @@
 #include "pci.h"
 #include "asm/pci.h"
 
+void pci_set_master(struct pci_dev *dev, int master)
+{
+	uint32_t val = pci_config_readw(dev->pci_bdf, PCI_COMMAND);
+	val |= PCI_COMMAND_MASTER;
+	pci_config_writew(dev->pci_bdf, PCI_COMMAND, val);
+}
+
 bool pci_dev_exists(pcidevaddr_t dev)
 {
 	return (pci_config_readw(dev, PCI_VENDOR_ID) != 0xffff &&
diff --git a/lib/pci.h b/lib/pci.h
index e48045c..46657f4 100644
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -25,6 +25,7 @@ struct pci_dev {
 
 void pci_dev_init(struct pci_dev *dev, pcidevaddr_t bdf);
 void pci_scan_bars(struct pci_dev *dev);
+void pci_set_master(struct pci_dev *dev, int master);
 
 extern bool pci_probe(void);
 extern void pci_print(void);
-- 
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