|
|
0a122b |
From 1e726d2e4db2132cb5f0ee985745c87174e6f599 Mon Sep 17 00:00:00 2001
|
|
|
0a122b |
Message-Id: <1e726d2e4db2132cb5f0ee985745c87174e6f599.1387298827.git.minovotn@redhat.com>
|
|
|
0a122b |
In-Reply-To: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
|
|
|
0a122b |
References: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
|
|
|
0a122b |
From: "Michael S. Tsirkin" <mst@redhat.com>
|
|
|
0a122b |
Date: Tue, 17 Dec 2013 15:17:05 +0100
|
|
|
0a122b |
Subject: [PATCH 07/56] pci: add helper to retrieve the 64-bit range
|
|
|
0a122b |
|
|
|
0a122b |
RH-Author: Michael S. Tsirkin <mst@redhat.com>
|
|
|
0a122b |
Message-id: <1387293161-4085-8-git-send-email-mst@redhat.com>
|
|
|
0a122b |
Patchwork-id: 56312
|
|
|
0a122b |
O-Subject: [PATCH qemu-kvm RHEL7.0 v2 07/57] pci: add helper to retrieve the 64-bit range
|
|
|
0a122b |
Bugzilla: 1034876
|
|
|
0a122b |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
0a122b |
(cherry picked from commit 438640695723f33be6d0081ac1e690aa40975c39)
|
|
|
0a122b |
|
|
|
0a122b |
Conflicts:
|
|
|
0a122b |
include/hw/pci/pci.h
|
|
|
0a122b |
---
|
|
|
0a122b |
include/hw/pci/pci.h | 1 +
|
|
|
0a122b |
hw/pci/pci.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
0a122b |
2 files changed, 51 insertions(+)
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Michal Novotny <minovotn@redhat.com>
|
|
|
0a122b |
---
|
|
|
0a122b |
hw/pci/pci.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
0a122b |
include/hw/pci/pci.h | 1 +
|
|
|
0a122b |
2 files changed, 51 insertions(+)
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
|
|
|
0a122b |
index 26995d7..d550851 100644
|
|
|
0a122b |
--- a/hw/pci/pci.c
|
|
|
0a122b |
+++ b/hw/pci/pci.c
|
|
|
0a122b |
@@ -2244,6 +2244,56 @@ void pci_setup_iommu(PCIBus *bus, PCIDMAContextFunc fn, void *opaque)
|
|
|
0a122b |
bus->dma_context_opaque = opaque;
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
+static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ Range *range = opaque;
|
|
|
0a122b |
+ PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
|
|
|
0a122b |
+ uint16_t cmd = pci_get_word(dev->config + PCI_COMMAND);
|
|
|
0a122b |
+ int r;
|
|
|
0a122b |
+
|
|
|
0a122b |
+ if (!(cmd & PCI_COMMAND_MEMORY)) {
|
|
|
0a122b |
+ return;
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+
|
|
|
0a122b |
+ if (pc->is_bridge) {
|
|
|
0a122b |
+ pcibus_t base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
|
|
|
0a122b |
+ pcibus_t limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
|
|
|
0a122b |
+
|
|
|
0a122b |
+ base = MAX(base, 0x1ULL << 32);
|
|
|
0a122b |
+
|
|
|
0a122b |
+ if (limit >= base) {
|
|
|
0a122b |
+ Range pref_range;
|
|
|
0a122b |
+ pref_range.begin = base;
|
|
|
0a122b |
+ pref_range.end = limit + 1;
|
|
|
0a122b |
+ range_extend(range, &pref_range);
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+ for (r = 0; r < PCI_NUM_REGIONS; ++r) {
|
|
|
0a122b |
+ PCIIORegion *region = &dev->io_regions[r];
|
|
|
0a122b |
+ Range region_range;
|
|
|
0a122b |
+
|
|
|
0a122b |
+ if (!region->size ||
|
|
|
0a122b |
+ (region->type & PCI_BASE_ADDRESS_SPACE_IO) ||
|
|
|
0a122b |
+ !(region->type & PCI_BASE_ADDRESS_MEM_TYPE_64)) {
|
|
|
0a122b |
+ continue;
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+ region_range.begin = pci_get_quad(dev->config + pci_bar(dev, r));
|
|
|
0a122b |
+ region_range.end = region_range.begin + region->size;
|
|
|
0a122b |
+
|
|
|
0a122b |
+ region_range.begin = MAX(region_range.begin, 0x1ULL << 32);
|
|
|
0a122b |
+
|
|
|
0a122b |
+ if (region_range.end - 1 >= region_range.begin) {
|
|
|
0a122b |
+ range_extend(range, ®ion_range);
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
+void pci_bus_get_w64_range(PCIBus *bus, Range *range)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ range->begin = range->end = 0;
|
|
|
0a122b |
+ pci_for_each_device_under_bus(bus, pci_dev_get_w64, range);
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
static const TypeInfo pci_device_type_info = {
|
|
|
0a122b |
.name = TYPE_PCI_DEVICE,
|
|
|
0a122b |
.parent = TYPE_DEVICE,
|
|
|
0a122b |
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
|
|
|
0a122b |
index 8d075ab..e7760dd 100644
|
|
|
0a122b |
--- a/include/hw/pci/pci.h
|
|
|
0a122b |
+++ b/include/hw/pci/pci.h
|
|
|
0a122b |
@@ -395,6 +395,7 @@ int pci_find_domain(const PCIBus *bus);
|
|
|
0a122b |
PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
|
|
|
0a122b |
int pci_qdev_find_device(const char *id, PCIDevice **pdev);
|
|
|
0a122b |
PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr);
|
|
|
0a122b |
+void pci_bus_get_w64_range(PCIBus *bus, Range *range);
|
|
|
0a122b |
|
|
|
0a122b |
int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
|
|
|
0a122b |
unsigned *slotp);
|
|
|
0a122b |
--
|
|
|
0a122b |
1.7.11.7
|
|
|
0a122b |
|