Skip to content

Commit be000f9

Browse files
jakeatmicrosoftgregkh
authored andcommitted
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 <[email protected]> Signed-off-by: K. Y. Srinivasan <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 23a0683 commit be000f9

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

drivers/hv/vmbus_drv.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj,
11281128
resource_size_t size, resource_size_t align,
11291129
bool fb_overlap_ok)
11301130
{
1131-
struct resource *iter;
1131+
struct resource *iter, *shadow;
11321132
resource_size_t range_min, range_max, start, local_min, local_max;
11331133
const char *dev_n = dev_name(&device_obj->device);
11341134
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,
11701170

11711171
start = (local_min + align - 1) & ~(align - 1);
11721172
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+
11731180
*new = request_mem_region_exclusive(start, size,
11741181
dev_n);
11751182
if (*new) {
1183+
shadow->name = (char *)*new;
11761184
retval = 0;
11771185
goto exit;
11781186
}
1187+
1188+
__release_region(iter, start, size);
11791189
}
11801190
}
11811191
}
@@ -1196,7 +1206,17 @@ EXPORT_SYMBOL_GPL(vmbus_allocate_mmio);
11961206
*/
11971207
void vmbus_free_mmio(resource_size_t start, resource_size_t size)
11981208
{
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+
}
11991218
release_mem_region(start, size);
1219+
up(&hyperv_mmio_lock);
12001220

12011221
}
12021222
EXPORT_SYMBOL_GPL(vmbus_free_mmio);

0 commit comments

Comments
 (0)