Skip to content

Commit d7568c1

Browse files
Philip P. Moltmanngregkh
authored andcommitted
VMware balloon: Treat init like reset
Unify the behavior of the first start of the balloon and a reset. Also on unload, declare that the balloon driver does not have any capabilities anymore. Acked-by: Andy King <[email protected]> Signed-off-by: Xavier Deguillard <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 365bd7e commit d7568c1

File tree

1 file changed

+18
-35
lines changed

1 file changed

+18
-35
lines changed

drivers/misc/vmw_balloon.c

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
MODULE_AUTHOR("VMware, Inc.");
4949
MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
50-
MODULE_VERSION("1.4.0.0-k");
50+
MODULE_VERSION("1.4.1.0-k");
5151
MODULE_ALIAS("dmi:*:svnVMware*:*");
5252
MODULE_ALIAS("vmware_vmmemctl");
5353
MODULE_LICENSE("GPL");
@@ -564,12 +564,14 @@ static void vmballoon_pop(struct vmballoon *b)
564564
}
565565
}
566566

567-
if ((b->capabilities & VMW_BALLOON_BATCHED_CMDS) != 0) {
568-
if (b->batch_page)
569-
vunmap(b->batch_page);
567+
if (b->batch_page) {
568+
vunmap(b->batch_page);
569+
b->batch_page = NULL;
570+
}
570571

571-
if (b->page)
572-
__free_page(b->page);
572+
if (b->page) {
573+
__free_page(b->page);
574+
b->page = NULL;
573575
}
574576
}
575577

@@ -1044,7 +1046,7 @@ static void vmballoon_work(struct work_struct *work)
10441046
if (b->slow_allocation_cycles > 0)
10451047
b->slow_allocation_cycles--;
10461048

1047-
if (vmballoon_send_get_target(b, &target)) {
1049+
if (!b->reset_required && vmballoon_send_get_target(b, &target)) {
10481050
/* update target, adjust size */
10491051
b->target = target;
10501052

@@ -1076,8 +1078,10 @@ static int vmballoon_debug_show(struct seq_file *f, void *offset)
10761078
/* format capabilities info */
10771079
seq_printf(f,
10781080
"balloon capabilities: %#4x\n"
1079-
"used capabilities: %#4lx\n",
1080-
VMW_BALLOON_CAPABILITIES, b->capabilities);
1081+
"used capabilities: %#4lx\n"
1082+
"is resetting: %c\n",
1083+
VMW_BALLOON_CAPABILITIES, b->capabilities,
1084+
b->reset_required ? 'y' : 'n');
10811085

10821086
/* format size info */
10831087
seq_printf(f,
@@ -1196,35 +1200,14 @@ static int __init vmballoon_init(void)
11961200

11971201
INIT_DELAYED_WORK(&balloon.dwork, vmballoon_work);
11981202

1199-
/*
1200-
* Start balloon.
1201-
*/
1202-
if (!vmballoon_send_start(&balloon, VMW_BALLOON_CAPABILITIES)) {
1203-
pr_err("failed to send start command to the host\n");
1204-
return -EIO;
1205-
}
1206-
1207-
if ((balloon.capabilities & VMW_BALLOON_BATCHED_CMDS) != 0) {
1208-
balloon.ops = &vmballoon_batched_ops;
1209-
balloon.batch_max_pages = VMW_BALLOON_BATCH_MAX_PAGES;
1210-
if (!vmballoon_init_batching(&balloon)) {
1211-
pr_err("failed to init batching\n");
1212-
return -EIO;
1213-
}
1214-
} else if ((balloon.capabilities & VMW_BALLOON_BASIC_CMDS) != 0) {
1215-
balloon.ops = &vmballoon_basic_ops;
1216-
balloon.batch_max_pages = 1;
1217-
}
1218-
1219-
if (!vmballoon_send_guest_id(&balloon)) {
1220-
pr_err("failed to send guest ID to the host\n");
1221-
return -EIO;
1222-
}
1223-
12241203
error = vmballoon_debugfs_init(&balloon);
12251204
if (error)
12261205
return error;
12271206

1207+
balloon.batch_page = NULL;
1208+
balloon.page = NULL;
1209+
balloon.reset_required = true;
1210+
12281211
queue_delayed_work(system_freezable_wq, &balloon.dwork, 0);
12291212

12301213
return 0;
@@ -1242,7 +1225,7 @@ static void __exit vmballoon_exit(void)
12421225
* Reset connection before deallocating memory to avoid potential for
12431226
* additional spurious resets from guest touching deallocated pages.
12441227
*/
1245-
vmballoon_send_start(&balloon, VMW_BALLOON_CAPABILITIES);
1228+
vmballoon_send_start(&balloon, 0);
12461229
vmballoon_pop(&balloon);
12471230
}
12481231
module_exit(vmballoon_exit);

0 commit comments

Comments
 (0)