Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1369990

[PATCH 6/6] hv: Track allocations of children of hv_vmbus in private resource tree

From "K. Y. Srinivasan" <kys@microsoft.com>
Newsgroups linux.kernel
Subject [PATCH 6/6] hv: Track allocations of children of hv_vmbus in private resource tree
Date 2016-04-02 18:40 +0200
Message-ID <rjwKD-6wn-29@gated-at.bofh.it> (permalink)
References <rjwKC-6wn-7@gated-at.bofh.it> <rjwKC-6wn-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Jake Oshins <jakeo@microsoft.com>

This patch changes vmbus_allocate_mmio() and vmbus_free_mmio() so
that when child paravirtual devices allocate memory-mapped I/O
space, they allocate it privately from a resource tree pointed
at by hyperv_mmio and also by the public resource tree
iomem_resource.  This allows the region to be marked as "busy"
in the private tree, but a "bridge window" in the public tree,
guaranteeing that no two bridge windows will overlap each other
but while also allowing the PCI device children of the bridge
windows to overlap that window.

One might conclude that this belongs in the pnp layer, rather
than in this driver.  Rafael Wysocki, the maintainter of the
pnp layer, has previously asked that we not modify the pnp layer
as it is considered deprecated.  This patch is thus essentially
a workaround.

Signed-off-by: Jake Oshins <jakeo@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/hv/vmbus_drv.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 1ce47d0..dfc6149 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1128,7 +1128,7 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj,
 			resource_size_t size, resource_size_t align,
 			bool fb_overlap_ok)
 {
-	struct resource *iter;
+	struct resource *iter, *shadow;
 	resource_size_t range_min, range_max, start, local_min, local_max;
 	const char *dev_n = dev_name(&device_obj->device);
 	u32 fb_end = screen_info.lfb_base + (screen_info.lfb_size << 1);
@@ -1170,12 +1170,22 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj,
 
 			start = (local_min + align - 1) & ~(align - 1);
 			for (; start + size - 1 <= local_max; start += align) {
+				shadow = __request_region(iter, start,
+							  size,
+							  NULL,
+							  IORESOURCE_BUSY);
+				if (!shadow)
+					continue;
+
 				*new = request_mem_region_exclusive(start, size,
 								    dev_n);
 				if (*new) {
+					shadow->name = (char *)*new;
 					retval = 0;
 					goto exit;
 				}
+
+				__release_region(iter, start, size);
 			}
 		}
 	}
@@ -1196,7 +1206,17 @@ EXPORT_SYMBOL_GPL(vmbus_allocate_mmio);
  */
 void vmbus_free_mmio(resource_size_t start, resource_size_t size)
 {
+	struct resource *iter;
+
+	down(&hyperv_mmio_lock);
+	for (iter = hyperv_mmio; iter; iter = iter->sibling) {
+		if ((iter->start >= start + size) || (iter->end <= start))
+			continue;
+
+		__release_region(iter, start, size);
+	}
 	release_mem_region(start, size);
+	up(&hyperv_mmio_lock);
 
 }
 EXPORT_SYMBOL_GPL(vmbus_free_mmio);
-- 
1.7.4.1

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio management.  "K. Y. Srinivasan" <kys@microsoft.com> - 2016-04-02 18:40 +0200
  [PATCH 1/6] Drivers: hv: kvp: fix IP Failover "K. Y. Srinivasan" <kys@microsoft.com> - 2016-04-02 18:40 +0200
    [PATCH 5/6] hv: Reverse order of resources in hyperv_mmio "K. Y. Srinivasan" <kys@microsoft.com> - 2016-04-02 18:40 +0200
    [PATCH 6/6] hv: Track allocations of children of hv_vmbus in private resource tree "K. Y. Srinivasan" <kys@microsoft.com> - 2016-04-02 18:40 +0200
    [PATCH 3/6] hv: Lock access to hyperv_mmio resource tree "K. Y. Srinivasan" <kys@microsoft.com> - 2016-04-02 18:40 +0200
  Re: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio management. Greg KH <gregkh@linuxfoundation.org> - 2016-04-03 00:30 +0200
    RE: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio management. KY Srinivasan <kys@microsoft.com> - 2016-04-03 01:50 +0200
      Re: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio management. Greg KH <gregkh@linuxfoundation.org> - 2016-04-03 03:50 +0200
        RE: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio management. KY Srinivasan <kys@microsoft.com> - 2016-04-03 07:20 +0200
          RE: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio management. KY Srinivasan <kys@microsoft.com> - 2016-04-04 16:40 +0200
  Re: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio management. Vitaly Kuznetsov <vkuznets@redhat.com> - 2016-04-04 13:10 +0200

csiph-web