aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/vmw_balloon.c
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@vmware.com>2015-08-06 18:18:01 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-04 07:59:11 -0400
commitd7568c130d0d0ff1fc5b364fc879b91f108a3d54 (patch)
treeaabd272e6a5085c0951ddfcf5d1fd59330ad97ae /drivers/misc/vmw_balloon.c
parent365bd7ef7ec8eb9c2e081cd970a5cdfa237dc243 (diff)
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 <acking@vmware.com> Signed-off-by: Xavier Deguillard <xdeguillard@vmware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/vmw_balloon.c')
-rw-r--r--drivers/misc/vmw_balloon.c53
1 files changed, 18 insertions, 35 deletions
diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index 01519ff443dd..28fe9e5a14ca 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -47,7 +47,7 @@
47 47
48MODULE_AUTHOR("VMware, Inc."); 48MODULE_AUTHOR("VMware, Inc.");
49MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver"); 49MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
50MODULE_VERSION("1.4.0.0-k"); 50MODULE_VERSION("1.4.1.0-k");
51MODULE_ALIAS("dmi:*:svnVMware*:*"); 51MODULE_ALIAS("dmi:*:svnVMware*:*");
52MODULE_ALIAS("vmware_vmmemctl"); 52MODULE_ALIAS("vmware_vmmemctl");
53MODULE_LICENSE("GPL"); 53MODULE_LICENSE("GPL");
@@ -564,12 +564,14 @@ static void vmballoon_pop(struct vmballoon *b)
564 } 564 }
565 } 565 }
566 566
567 if ((b->capabilities & VMW_BALLOON_BATCHED_CMDS) != 0) { 567 if (b->batch_page) {
568 if (b->batch_page) 568 vunmap(b->batch_page);
569 vunmap(b->batch_page); 569 b->batch_page = NULL;
570 }
570 571
571 if (b->page) 572 if (b->page) {
572 __free_page(b->page); 573 __free_page(b->page);
574 b->page = NULL;
573 } 575 }
574} 576}
575 577
@@ -1044,7 +1046,7 @@ static void vmballoon_work(struct work_struct *work)
1044 if (b->slow_allocation_cycles > 0) 1046 if (b->slow_allocation_cycles > 0)
1045 b->slow_allocation_cycles--; 1047 b->slow_allocation_cycles--;
1046 1048
1047 if (vmballoon_send_get_target(b, &target)) { 1049 if (!b->reset_required && vmballoon_send_get_target(b, &target)) {
1048 /* update target, adjust size */ 1050 /* update target, adjust size */
1049 b->target = target; 1051 b->target = target;
1050 1052
@@ -1076,8 +1078,10 @@ static int vmballoon_debug_show(struct seq_file *f, void *offset)
1076 /* format capabilities info */ 1078 /* format capabilities info */
1077 seq_printf(f, 1079 seq_printf(f,
1078 "balloon capabilities: %#4x\n" 1080 "balloon capabilities: %#4x\n"
1079 "used capabilities: %#4lx\n", 1081 "used capabilities: %#4lx\n"
1080 VMW_BALLOON_CAPABILITIES, b->capabilities); 1082 "is resetting: %c\n",
1083 VMW_BALLOON_CAPABILITIES, b->capabilities,
1084 b->reset_required ? 'y' : 'n');
1081 1085
1082 /* format size info */ 1086 /* format size info */
1083 seq_printf(f, 1087 seq_printf(f,
@@ -1196,35 +1200,14 @@ static int __init vmballoon_init(void)
1196 1200
1197 INIT_DELAYED_WORK(&balloon.dwork, vmballoon_work); 1201 INIT_DELAYED_WORK(&balloon.dwork, vmballoon_work);
1198 1202
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
1224 error = vmballoon_debugfs_init(&balloon); 1203 error = vmballoon_debugfs_init(&balloon);
1225 if (error) 1204 if (error)
1226 return error; 1205 return error;
1227 1206
1207 balloon.batch_page = NULL;
1208 balloon.page = NULL;
1209 balloon.reset_required = true;
1210
1228 queue_delayed_work(system_freezable_wq, &balloon.dwork, 0); 1211 queue_delayed_work(system_freezable_wq, &balloon.dwork, 0);
1229 1212
1230 return 0; 1213 return 0;
@@ -1242,7 +1225,7 @@ static void __exit vmballoon_exit(void)
1242 * Reset connection before deallocating memory to avoid potential for 1225 * Reset connection before deallocating memory to avoid potential for
1243 * additional spurious resets from guest touching deallocated pages. 1226 * additional spurious resets from guest touching deallocated pages.
1244 */ 1227 */
1245 vmballoon_send_start(&balloon, VMW_BALLOON_CAPABILITIES); 1228 vmballoon_send_start(&balloon, 0);
1246 vmballoon_pop(&balloon); 1229 vmballoon_pop(&balloon);
1247} 1230}
1248module_exit(vmballoon_exit); 1231module_exit(vmballoon_exit);