[PATCH kvm-unit-tests v2 11/17] pci: provide pci_enable_defaults()

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

 



Provide a function to do most of the common PCI init work.

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

diff --git a/lib/pci.c b/lib/pci.c
index fd17ea5..971f02e 100644
--- a/lib/pci.c
+++ b/lib/pci.c
@@ -249,3 +249,11 @@ void pci_scan_bars(struct pci_dev *dev)
 		dev->bar[i] = pci_bar_get_addr(dev, i);
 	}
 }
+
+int pci_enable_defaults(struct pci_dev *dev)
+{
+	pci_scan_bars(dev);
+	/* Enable device DMA operations */
+	pci_cmd_set_clr(dev, PCI_COMMAND_MASTER, 0);
+	return 0;
+}
diff --git a/lib/pci.h b/lib/pci.h
index de15086..63f8a0a 100644
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -26,6 +26,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_cmd_set_clr(struct pci_dev *dev, uint16_t set, uint16_t clr);
+int pci_enable_defaults(struct pci_dev *dev);
 
 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