summaryrefslogtreecommitdiffstats
path: root/drivers/hv
diff options
context:
space:
mode:
authorJake Oshins <jakeo@microsoft.com>2016-04-05 13:22:54 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-04-30 17:01:37 -0400
commitbe000f93e5d71f5d43dd722f8eb110b069f9d8a2 (patch)
tree5b87f10b2c25800aa44ce6cd0234fa8e382b5994 /drivers/hv
parent23a0683186b7ca0083bfc76b410497f39a9d0351 (diff)
drivers:hv: Track allocations of children of hv_vmbus in private resource tree
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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hv')
-rw-r--r--drivers/hv/vmbus_drv.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 1ce47d03e800..dfc6149ccc93 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,
1128 resource_size_t size, resource_size_t align, 1128 resource_size_t size, resource_size_t align,
1129 bool fb_overlap_ok) 1129 bool fb_overlap_ok)
1130{ 1130{
1131 struct resource *iter; 1131 struct resource *iter, *shadow;
1132 resource_size_t range_min, range_max, start, local_min, local_max; 1132 resource_size_t range_min, range_max, start, local_min, local_max;
1133 const char *dev_n = dev_name(&device_obj->device); 1133 const char *dev_n = dev_name(&device_obj->device);
1134 u32 fb_end = screen_info.lfb_base + (screen_info.lfb_size << 1); 1134 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,
1170 1170
1171 start = (local_min + align - 1) & ~(align - 1); 1171 start = (local_min + align - 1) & ~(align - 1);
1172 for (; start + size - 1 <= local_max; start += align) { 1172 for (; start + size - 1 <= local_max; start += align) {
1173 shadow = __request_region(iter, start,
1174 size,
1175 NULL,
1176 IORESOURCE_BUSY);
1177 if (!shadow)
1178 continue;
1179
1173 *new = request_mem_region_exclusive(start, size, 1180 *new = request_mem_region_exclusive(start, size,
1174 dev_n); 1181 dev_n);
1175 if (*new) { 1182 if (*new) {
1183 shadow->name = (char *)*new;
1176 retval = 0; 1184 retval = 0;
1177 goto exit; 1185 goto exit;
1178 } 1186 }
1187
1188 __release_region(iter, start, size);
1179 } 1189 }
1180 } 1190 }
1181 } 1191 }
@@ -1196,7 +1206,17 @@ EXPORT_SYMBOL_GPL(vmbus_allocate_mmio);
1196 */ 1206 */
1197void vmbus_free_mmio(resource_size_t start, resource_size_t size) 1207void vmbus_free_mmio(resource_size_t start, resource_size_t size)
1198{ 1208{
1209 struct resource *iter;
1210
1211 down(&hyperv_mmio_lock);
1212 for (iter = hyperv_mmio; iter; iter = iter->sibling) {
1213 if ((iter->start >= start + size) || (iter->end <= start))
1214 continue;
1215
1216 __release_region(iter, start, size);
1217 }
1199 release_mem_region(start, size); 1218 release_mem_region(start, size);
1219 up(&hyperv_mmio_lock);
1200 1220
1201} 1221}
1202EXPORT_SYMBOL_GPL(vmbus_free_mmio); 1222EXPORT_SYMBOL_GPL(vmbus_free_mmio);