linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5] Drivers: hv: Cosmetic changes for hv.c and balloon.c
@ 2024-05-29 16:04 Aditya Nagesh
  2024-05-29 16:29 ` Michael Kelley
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Aditya Nagesh @ 2024-05-29 16:04 UTC (permalink / raw)
  To: adityanagesh, kys, haiyangz, wei.liu, decui, linux-hyperv,
	linux-kernel
  Cc: Aditya Nagesh

Fix issues reported by checkpatch.pl script in hv.c and
balloon.c
 - Remove unnecessary parentheses
 - Remove extra newlines
 - Remove extra spaces
 - Add spaces between comparison operators
 - Remove comparison with NULL in if statements

No functional changes intended

Signed-off-by: Aditya Nagesh <adityanagesh@linux.microsoft.com>
Reviewed-by: Saurabh Sengar <ssengar@linux.microsoft.com>
---
[V5]
Rebase to hyperv-fixes

[V4]
Fix Alignment issue and revert a line since 100 characters are allowed in a line

[V3]
Fix alignment issues in multiline function parameters.

[V2]
Change Subject from "Drivers: hv: Fix Issues reported by checkpatch.pl script"
 to "Drivers: hv: Cosmetic changes for hv.c and balloon.c"
 drivers/hv/hv.c         |  37 +++++++-------
 drivers/hv/hv_balloon.c | 105 ++++++++++++++--------------------------
 2 files changed, 53 insertions(+), 89 deletions(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index a8ad728354cb..e0d676c74f14 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -45,8 +45,8 @@ int hv_init(void)
  * This involves a hypercall.
  */
 int hv_post_message(union hv_connection_id connection_id,
-		  enum hv_message_type message_type,
-		  void *payload, size_t payload_size)
+			enum hv_message_type message_type,
+			void *payload, size_t payload_size)
 {
 	struct hv_input_post_message *aligned_msg;
 	unsigned long flags;
@@ -86,7 +86,7 @@ int hv_post_message(union hv_connection_id connection_id,
 			status = HV_STATUS_INVALID_PARAMETER;
 	} else {
 		status = hv_do_hypercall(HVCALL_POST_MESSAGE,
-				aligned_msg, NULL);
+					 aligned_msg, NULL);
 	}
 
 	local_irq_restore(flags);
@@ -111,7 +111,7 @@ int hv_synic_alloc(void)
 
 	hv_context.hv_numa_map = kcalloc(nr_node_ids, sizeof(struct cpumask),
 					 GFP_KERNEL);
-	if (hv_context.hv_numa_map == NULL) {
+	if (!hv_context.hv_numa_map) {
 		pr_err("Unable to allocate NUMA map\n");
 		goto err;
 	}
@@ -120,11 +120,11 @@ int hv_synic_alloc(void)
 		hv_cpu = per_cpu_ptr(hv_context.cpu_context, cpu);
 
 		tasklet_init(&hv_cpu->msg_dpc,
-			     vmbus_on_msg_dpc, (unsigned long) hv_cpu);
+			     vmbus_on_msg_dpc, (unsigned long)hv_cpu);
 
 		if (ms_hyperv.paravisor_present && hv_isolation_type_tdx()) {
 			hv_cpu->post_msg_page = (void *)get_zeroed_page(GFP_ATOMIC);
-			if (hv_cpu->post_msg_page == NULL) {
+			if (!hv_cpu->post_msg_page) {
 				pr_err("Unable to allocate post msg page\n");
 				goto err;
 			}
@@ -147,14 +147,14 @@ int hv_synic_alloc(void)
 		if (!ms_hyperv.paravisor_present && !hv_root_partition) {
 			hv_cpu->synic_message_page =
 				(void *)get_zeroed_page(GFP_ATOMIC);
-			if (hv_cpu->synic_message_page == NULL) {
+			if (!hv_cpu->synic_message_page) {
 				pr_err("Unable to allocate SYNIC message page\n");
 				goto err;
 			}
 
 			hv_cpu->synic_event_page =
 				(void *)get_zeroed_page(GFP_ATOMIC);
-			if (hv_cpu->synic_event_page == NULL) {
+			if (!hv_cpu->synic_event_page) {
 				pr_err("Unable to allocate SYNIC event page\n");
 
 				free_page((unsigned long)hv_cpu->synic_message_page);
@@ -203,14 +203,13 @@ int hv_synic_alloc(void)
 	return ret;
 }
 
-
 void hv_synic_free(void)
 {
 	int cpu, ret;
 
 	for_each_present_cpu(cpu) {
-		struct hv_per_cpu_context *hv_cpu
-			= per_cpu_ptr(hv_context.cpu_context, cpu);
+		struct hv_per_cpu_context *hv_cpu =
+			per_cpu_ptr(hv_context.cpu_context, cpu);
 
 		/* It's better to leak the page if the encryption fails. */
 		if (ms_hyperv.paravisor_present && hv_isolation_type_tdx()) {
@@ -262,8 +261,8 @@ void hv_synic_free(void)
  */
 void hv_synic_enable_regs(unsigned int cpu)
 {
-	struct hv_per_cpu_context *hv_cpu
-		= per_cpu_ptr(hv_context.cpu_context, cpu);
+	struct hv_per_cpu_context *hv_cpu =
+		per_cpu_ptr(hv_context.cpu_context, cpu);
 	union hv_synic_simp simp;
 	union hv_synic_siefp siefp;
 	union hv_synic_sint shared_sint;
@@ -277,8 +276,8 @@ void hv_synic_enable_regs(unsigned int cpu)
 		/* Mask out vTOM bit. ioremap_cache() maps decrypted */
 		u64 base = (simp.base_simp_gpa << HV_HYP_PAGE_SHIFT) &
 				~ms_hyperv.shared_gpa_boundary;
-		hv_cpu->synic_message_page
-			= (void *)ioremap_cache(base, HV_HYP_PAGE_SIZE);
+		hv_cpu->synic_message_page =
+			(void *)ioremap_cache(base, HV_HYP_PAGE_SIZE);
 		if (!hv_cpu->synic_message_page)
 			pr_err("Fail to map synic message page.\n");
 	} else {
@@ -296,8 +295,8 @@ void hv_synic_enable_regs(unsigned int cpu)
 		/* Mask out vTOM bit. ioremap_cache() maps decrypted */
 		u64 base = (siefp.base_siefp_gpa << HV_HYP_PAGE_SHIFT) &
 				~ms_hyperv.shared_gpa_boundary;
-		hv_cpu->synic_event_page
-			= (void *)ioremap_cache(base, HV_HYP_PAGE_SIZE);
+		hv_cpu->synic_event_page =
+			(void *)ioremap_cache(base, HV_HYP_PAGE_SIZE);
 		if (!hv_cpu->synic_event_page)
 			pr_err("Fail to map synic event page.\n");
 	} else {
@@ -348,8 +347,8 @@ int hv_synic_init(unsigned int cpu)
  */
 void hv_synic_disable_regs(unsigned int cpu)
 {
-	struct hv_per_cpu_context *hv_cpu
-		= per_cpu_ptr(hv_context.cpu_context, cpu);
+	struct hv_per_cpu_context *hv_cpu =
+		per_cpu_ptr(hv_context.cpu_context, cpu);
 	union hv_synic_sint shared_sint;
 	union hv_synic_simp simp;
 	union hv_synic_siefp siefp;
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 4370ad31b5b3..8f94240e5910 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -42,8 +42,6 @@
  * Begin protocol definitions.
  */
 
-
-
 /*
  * Protocol versions. The low word is the minor version, the high word the major
  * version.
@@ -72,8 +70,6 @@ enum {
 	DYNMEM_PROTOCOL_VERSION_CURRENT = DYNMEM_PROTOCOL_VERSION_WIN10
 };
 
-
-
 /*
  * Message Types
  */
@@ -102,7 +98,6 @@ enum dm_message_type {
 	DM_VERSION_1_MAX		= 12
 };
 
-
 /*
  * Structures defining the dynamic memory management
  * protocol.
@@ -116,7 +111,6 @@ union dm_version {
 	__u32 version;
 } __packed;
 
-
 union dm_caps {
 	struct {
 		__u64 balloon:1;
@@ -149,8 +143,6 @@ union dm_mem_page_range {
 	__u64  page_range;
 } __packed;
 
-
-
 /*
  * The header for all dynamic memory messages:
  *
@@ -175,7 +167,6 @@ struct dm_message {
 	__u8 data[]; /* enclosed message */
 } __packed;
 
-
 /*
  * Specific message types supporting the dynamic memory protocol.
  */
@@ -272,7 +263,6 @@ struct dm_status {
 	__u32 io_diff;
 } __packed;
 
-
 /*
  * Message to ask the guest to allocate memory - balloon up message.
  * This message is sent from the host to the guest. The guest may not be
@@ -287,14 +277,13 @@ struct dm_balloon {
 	__u32 reservedz;
 } __packed;
 
-
 /*
  * Balloon response message; this message is sent from the guest
  * to the host in response to the balloon message.
  *
  * reservedz: Reserved; must be set to zero.
  * more_pages: If FALSE, this is the last message of the transaction.
- * if TRUE there will atleast one more message from the guest.
+ * if TRUE there will be at least one more message from the guest.
  *
  * range_count: The number of ranges in the range array.
  *
@@ -315,7 +304,7 @@ struct dm_balloon_response {
  * to the guest to give guest more memory.
  *
  * more_pages: If FALSE, this is the last message of the transaction.
- * if TRUE there will atleast one more message from the guest.
+ * if TRUE there will be at least one more message from the guest.
  *
  * reservedz: Reserved; must be set to zero.
  *
@@ -343,7 +332,6 @@ struct dm_unballoon_response {
 	struct dm_header hdr;
 } __packed;
 
-
 /*
  * Hot add request message. Message sent from the host to the guest.
  *
@@ -391,7 +379,6 @@ enum dm_info_type {
 	MAX_INFO_TYPE
 };
 
-
 /*
  * Header for the information message.
  */
@@ -481,10 +468,10 @@ static unsigned long last_post_time;
 
 static int hv_hypercall_multi_failure;
 
-module_param(hot_add, bool, (S_IRUGO | S_IWUSR));
+module_param(hot_add, bool, 0644);
 MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
 
-module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
+module_param(pressure_report_delay, uint, 0644);
 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
 static atomic_t trans_id = ATOMIC_INIT(0);
 
@@ -503,7 +490,6 @@ enum hv_dm_state {
 	DM_INIT_ERROR
 };
 
-
 static __u8 recv_buffer[HV_HYP_PAGE_SIZE];
 static __u8 balloon_up_send_buffer[HV_HYP_PAGE_SIZE];
 
@@ -599,12 +585,12 @@ static inline bool has_pfn_is_backed(struct hv_hotadd_state *has,
 	struct hv_hotadd_gap *gap;
 
 	/* The page is not backed. */
-	if ((pfn < has->covered_start_pfn) || (pfn >= has->covered_end_pfn))
+	if (pfn < has->covered_start_pfn || pfn >= has->covered_end_pfn)
 		return false;
 
 	/* Check for gaps. */
 	list_for_each_entry(gap, &has->gap_list, list) {
-		if ((pfn >= gap->start_pfn) && (pfn < gap->end_pfn))
+		if (pfn >= gap->start_pfn && pfn < gap->end_pfn)
 			return false;
 	}
 
@@ -784,8 +770,8 @@ static void hv_online_page(struct page *pg, unsigned int order)
 	guard(spinlock_irqsave)(&dm_device.ha_lock);
 	list_for_each_entry(has, &dm_device.ha_region_list, list) {
 		/* The page belongs to a different HAS. */
-		if ((pfn < has->start_pfn) ||
-				(pfn + (1UL << order) > has->end_pfn))
+		if (pfn < has->start_pfn ||
+		    (pfn + (1UL << order) > has->end_pfn))
 			continue;
 
 		hv_bring_pgs_online(has, pfn, 1UL << order);
@@ -846,7 +832,7 @@ static int pfn_covered(unsigned long start_pfn, unsigned long pfn_cnt)
 }
 
 static unsigned long handle_pg_range(unsigned long pg_start,
-					unsigned long pg_count)
+				     unsigned long pg_count)
 {
 	unsigned long start_pfn = pg_start;
 	unsigned long pfn_cnt = pg_count;
@@ -857,7 +843,7 @@ static unsigned long handle_pg_range(unsigned long pg_start,
 	unsigned long res = 0, flags;
 
 	pr_debug("Hot adding %lu pages starting at pfn 0x%lx.\n", pg_count,
-		pg_start);
+		 pg_start);
 
 	spin_lock_irqsave(&dm_device.ha_lock, flags);
 	list_for_each_entry(has, &dm_device.ha_region_list, list) {
@@ -893,10 +879,9 @@ static unsigned long handle_pg_range(unsigned long pg_start,
 			if (start_pfn > has->start_pfn &&
 			    online_section_nr(pfn_to_section_nr(start_pfn)))
 				hv_bring_pgs_online(has, start_pfn, pgs_ol);
-
 		}
 
-		if ((has->ha_end_pfn < has->end_pfn) && (pfn_cnt > 0)) {
+		if (has->ha_end_pfn < has->end_pfn && pfn_cnt > 0) {
 			/*
 			 * We have some residual hot add range
 			 * that needs to be hot added; hot add
@@ -999,21 +984,14 @@ static void hot_add_req(struct work_struct *dummy)
 	rg_start = dm->ha_wrk.ha_region_range.finfo.start_page;
 	rg_sz = dm->ha_wrk.ha_region_range.finfo.page_cnt;
 
-	if ((rg_start == 0) && (!dm->host_specified_ha_region)) {
+	if (rg_start == 0 && !dm->host_specified_ha_region) {
 		/*
-		 * The host has not specified the hot-add region.
 		 * Based on the hot-add page range being specified,
-		 * compute a hot-add region that can cover the pages
-		 * that need to be hot-added while ensuring the alignment
-		 * and size requirements of Linux as it relates to hot-add.
-		 */
-		rg_start = ALIGN_DOWN(pg_start, ha_pages_in_chunk);
-		rg_sz = ALIGN(pfn_cnt, ha_pages_in_chunk);
 	}
 
 	if (do_hot_add)
 		resp.page_count = process_hot_add(pg_start, pfn_cnt,
-						rg_start, rg_sz);
+						  rg_start, rg_sz);
 
 	dm->num_pages_added += resp.page_count;
 #endif
@@ -1191,11 +1169,10 @@ static void post_status(struct hv_dynmem_device *dm)
 				sizeof(struct dm_status),
 				(unsigned long)NULL,
 				VM_PKT_DATA_INBAND, 0);
-
 }
 
 static void free_balloon_pages(struct hv_dynmem_device *dm,
-			 union dm_mem_page_range *range_array)
+			       union dm_mem_page_range *range_array)
 {
 	int num_pages = range_array->finfo.page_cnt;
 	__u64 start_frame = range_array->finfo.start_page;
@@ -1211,8 +1188,6 @@ static void free_balloon_pages(struct hv_dynmem_device *dm,
 	}
 }
 
-
-
 static unsigned int alloc_balloon_pages(struct hv_dynmem_device *dm,
 					unsigned int num_pages,
 					struct dm_balloon_response *bl_resp,
@@ -1258,7 +1233,6 @@ static unsigned int alloc_balloon_pages(struct hv_dynmem_device *dm,
 			page_to_pfn(pg);
 		bl_resp->range_array[i].finfo.page_cnt = alloc_unit;
 		bl_resp->hdr.size += sizeof(union dm_mem_page_range);
-
 	}
 
 	return i * alloc_unit;
@@ -1312,7 +1286,7 @@ static void balloon_up(struct work_struct *dummy)
 
 		if (num_ballooned == 0 || num_ballooned == num_pages) {
 			pr_debug("Ballooned %u out of %u requested pages.\n",
-				num_pages, dm_device.balloon_wrk.num_pages);
+				 num_pages, dm_device.balloon_wrk.num_pages);
 
 			bl_resp->more_pages = 0;
 			done = true;
@@ -1346,16 +1320,15 @@ static void balloon_up(struct work_struct *dummy)
 
 			for (i = 0; i < bl_resp->range_count; i++)
 				free_balloon_pages(&dm_device,
-						 &bl_resp->range_array[i]);
+						   &bl_resp->range_array[i]);
 
 			done = true;
 		}
 	}
-
 }
 
 static void balloon_down(struct hv_dynmem_device *dm,
-			struct dm_unballoon_request *req)
+			 struct dm_unballoon_request *req)
 {
 	union dm_mem_page_range *range_array = req->range_array;
 	int range_count = req->range_count;
@@ -1369,7 +1342,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
 	}
 
 	pr_debug("Freed %u ballooned pages.\n",
-		prev_pages_ballooned - dm->num_pages_ballooned);
+		 prev_pages_ballooned - dm->num_pages_ballooned);
 
 	if (req->more_pages == 1)
 		return;
@@ -1394,8 +1367,7 @@ static int dm_thread_func(void *dm_dev)
 	struct hv_dynmem_device *dm = dm_dev;
 
 	while (!kthread_should_stop()) {
-		wait_for_completion_interruptible_timeout(
-						&dm_device.config_event, 1*HZ);
+		wait_for_completion_interruptible_timeout(&dm_device.config_event, 1 * HZ);
 		/*
 		 * The host expects us to post information on the memory
 		 * pressure every second.
@@ -1419,9 +1391,8 @@ static int dm_thread_func(void *dm_dev)
 	return 0;
 }
 
-
 static void version_resp(struct hv_dynmem_device *dm,
-			struct dm_version_response *vresp)
+			 struct dm_version_response *vresp)
 {
 	struct dm_version_request version_req;
 	int ret;
@@ -1482,7 +1453,7 @@ static void version_resp(struct hv_dynmem_device *dm,
 }
 
 static void cap_resp(struct hv_dynmem_device *dm,
-			struct dm_capabilities_resp_msg *cap_resp)
+		     struct dm_capabilities_resp_msg *cap_resp)
 {
 	if (!cap_resp->is_accepted) {
 		pr_err("Capabilities not accepted by host\n");
@@ -1515,7 +1486,7 @@ static void balloon_onchannelcallback(void *context)
 		switch (dm_hdr->type) {
 		case DM_VERSION_RESPONSE:
 			version_resp(dm,
-				 (struct dm_version_response *)dm_msg);
+				     (struct dm_version_response *)dm_msg);
 			break;
 
 		case DM_CAPABILITIES_RESPONSE:
@@ -1545,7 +1516,7 @@ static void balloon_onchannelcallback(void *context)
 
 			dm->state = DM_BALLOON_DOWN;
 			balloon_down(dm,
-				 (struct dm_unballoon_request *)recv_buffer);
+				     (struct dm_unballoon_request *)recv_buffer);
 			break;
 
 		case DM_MEM_HOT_ADD_REQUEST:
@@ -1583,17 +1554,15 @@ static void balloon_onchannelcallback(void *context)
 
 		default:
 			pr_warn_ratelimited("Unhandled message: type: %d\n", dm_hdr->type);
-
 		}
 	}
-
 }
 
 #define HV_LARGE_REPORTING_ORDER	9
 #define HV_LARGE_REPORTING_LEN (HV_HYP_PAGE_SIZE << \
 		HV_LARGE_REPORTING_ORDER)
 static int hv_free_page_report(struct page_reporting_dev_info *pr_dev_info,
-		    struct scatterlist *sgl, unsigned int nents)
+			       struct scatterlist *sgl, unsigned int nents)
 {
 	unsigned long flags;
 	struct hv_memory_hint *hint;
@@ -1628,7 +1597,7 @@ static int hv_free_page_report(struct page_reporting_dev_info *pr_dev_info,
 		 */
 
 		/* page reporting for pages 2MB or higher */
-		if (order >= HV_LARGE_REPORTING_ORDER ) {
+		if (order >= HV_LARGE_REPORTING_ORDER) {
 			range->page.largepage = 1;
 			range->page_size = HV_GPA_PAGE_RANGE_PAGE_SIZE_2MB;
 			range->base_large_pfn = page_to_hvpfn(
@@ -1642,23 +1611,21 @@ static int hv_free_page_report(struct page_reporting_dev_info *pr_dev_info,
 			range->page.additional_pages =
 				(sg->length / HV_HYP_PAGE_SIZE) - 1;
 		}
-
 	}
 
 	status = hv_do_rep_hypercall(HV_EXT_CALL_MEMORY_HEAT_HINT, nents, 0,
 				     hint, NULL);
 	local_irq_restore(flags);
 	if (!hv_result_success(status)) {
-
 		pr_err("Cold memory discard hypercall failed with status %llx\n",
-				status);
+		       status);
 		if (hv_hypercall_multi_failure > 0)
 			hv_hypercall_multi_failure++;
 
 		if (hv_result(status) == HV_STATUS_INVALID_PARAMETER) {
 			pr_err("Underlying Hyper-V does not support order less than 9. Hypercall failed\n");
 			pr_err("Defaulting to page_reporting_order %d\n",
-					pageblock_order);
+			       pageblock_order);
 			page_reporting_order = pageblock_order;
 			hv_hypercall_multi_failure++;
 			return -EINVAL;
@@ -1692,7 +1659,7 @@ static void enable_page_reporting(void)
 		pr_err("Failed to enable cold memory discard: %d\n", ret);
 	} else {
 		pr_info("Cold memory discard hint enabled with order %d\n",
-				page_reporting_order);
+			page_reporting_order);
 	}
 }
 
@@ -1775,7 +1742,7 @@ static int balloon_connect_vsp(struct hv_device *dev)
 	if (ret)
 		goto out;
 
-	t = wait_for_completion_timeout(&dm_device.host_event, 5*HZ);
+	t = wait_for_completion_timeout(&dm_device.host_event, 5 * HZ);
 	if (t == 0) {
 		ret = -ETIMEDOUT;
 		goto out;
@@ -1833,7 +1800,7 @@ static int balloon_connect_vsp(struct hv_device *dev)
 	if (ret)
 		goto out;
 
-	t = wait_for_completion_timeout(&dm_device.host_event, 5*HZ);
+	t = wait_for_completion_timeout(&dm_device.host_event, 5 * HZ);
 	if (t == 0) {
 		ret = -ETIMEDOUT;
 		goto out;
@@ -1874,8 +1841,8 @@ static int hv_balloon_debug_show(struct seq_file *f, void *offset)
 	char *sname;
 
 	seq_printf(f, "%-22s: %u.%u\n", "host_version",
-				DYNMEM_MAJOR_VERSION(dm->version),
-				DYNMEM_MINOR_VERSION(dm->version));
+			DYNMEM_MAJOR_VERSION(dm->version),
+			DYNMEM_MINOR_VERSION(dm->version));
 
 	seq_printf(f, "%-22s:", "capabilities");
 	if (ballooning_enabled())
@@ -1924,10 +1891,10 @@ static int hv_balloon_debug_show(struct seq_file *f, void *offset)
 	seq_printf(f, "%-22s: %u\n", "pages_ballooned", dm->num_pages_ballooned);
 
 	seq_printf(f, "%-22s: %lu\n", "total_pages_committed",
-				get_pages_committed(dm));
+		   get_pages_committed(dm));
 
 	seq_printf(f, "%-22s: %llu\n", "max_dynamic_page_count",
-				dm->max_dynamic_page_count);
+		   dm->max_dynamic_page_count);
 
 	return 0;
 }
@@ -1937,7 +1904,7 @@ DEFINE_SHOW_ATTRIBUTE(hv_balloon_debug);
 static void  hv_balloon_debugfs_init(struct hv_dynmem_device *b)
 {
 	debugfs_create_file("hv-balloon", 0444, NULL, b,
-			&hv_balloon_debug_fops);
+			    &hv_balloon_debug_fops);
 }
 
 static void  hv_balloon_debugfs_exit(struct hv_dynmem_device *b)
@@ -2095,7 +2062,6 @@ static int balloon_suspend(struct hv_device *hv_dev)
 	tasklet_enable(&hv_dev->channel->callback_event);
 
 	return 0;
-
 }
 
 static int balloon_resume(struct hv_device *dev)
@@ -2154,7 +2120,6 @@ static  struct hv_driver balloon_drv = {
 
 static int __init init_balloon_drv(void)
 {
-
 	return vmbus_driver_register(&balloon_drv);
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH v5] Drivers: hv: Cosmetic changes for hv.c and balloon.c
  2024-05-29 16:04 [PATCH v5] Drivers: hv: Cosmetic changes for hv.c and balloon.c Aditya Nagesh
@ 2024-05-29 16:29 ` Michael Kelley
  2024-05-30  2:45   ` Wei Liu
  2024-05-30  1:06 ` kernel test robot
  2024-05-30  8:12 ` kernel test robot
  2 siblings, 1 reply; 5+ messages in thread
From: Michael Kelley @ 2024-05-29 16:29 UTC (permalink / raw)
  To: Aditya Nagesh, adityanagesh@microsoft.com, kys@microsoft.com,
	haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org

From: Aditya Nagesh <adityanagesh@linux.microsoft.com> Sent: Wednesday, May 29, 2024 9:05 AM
> 
> Fix issues reported by checkpatch.pl script in hv.c and
> balloon.c
>  - Remove unnecessary parentheses
>  - Remove extra newlines
>  - Remove extra spaces
>  - Add spaces between comparison operators
>  - Remove comparison with NULL in if statements
> 
> No functional changes intended
> 
> Signed-off-by: Aditya Nagesh <adityanagesh@linux.microsoft.com>
> Reviewed-by: Saurabh Sengar <ssengar@linux.microsoft.com>
> ---
> [V5]
> Rebase to hyperv-fixes
> 
> [V4]
> Fix Alignment issue and revert a line since 100 characters are allowed in a line
> 
> [V3]
> Fix alignment issues in multiline function parameters.
> 
> [V2]
> Change Subject from "Drivers: hv: Fix Issues reported by checkpatch.pl script"
>  to "Drivers: hv: Cosmetic changes for hv.c and balloon.c"
>  drivers/hv/hv.c         |  37 +++++++-------
>  drivers/hv/hv_balloon.c | 105 ++++++++++++++--------------------------
>  2 files changed, 53 insertions(+), 89 deletions(-)
> 

[snip]

> @@ -999,21 +984,14 @@ static void hot_add_req(struct work_struct *dummy)
>  	rg_start = dm->ha_wrk.ha_region_range.finfo.start_page;
>  	rg_sz = dm->ha_wrk.ha_region_range.finfo.page_cnt;
> 
> -	if ((rg_start == 0) && (!dm->host_specified_ha_region)) {
> +	if (rg_start == 0 && !dm->host_specified_ha_region) {
>  		/*
> -		 * The host has not specified the hot-add region.
>  		 * Based on the hot-add page range being specified,
> -		 * compute a hot-add region that can cover the pages
> -		 * that need to be hot-added while ensuring the alignment
> -		 * and size requirements of Linux as it relates to hot-add.
> -		 */
> -		rg_start = ALIGN_DOWN(pg_start, ha_pages_in_chunk);
> -		rg_sz = ALIGN(pfn_cnt, ha_pages_in_chunk);

Hmmm.  The above is not a cosmetic change.  Looks like this
delta was erroneously introduced in the v5 version.  It wasn't
there in v4.

Everything else LGTM.

Michael

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v5] Drivers: hv: Cosmetic changes for hv.c and balloon.c
  2024-05-29 16:04 [PATCH v5] Drivers: hv: Cosmetic changes for hv.c and balloon.c Aditya Nagesh
  2024-05-29 16:29 ` Michael Kelley
@ 2024-05-30  1:06 ` kernel test robot
  2024-05-30  8:12 ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2024-05-30  1:06 UTC (permalink / raw)
  To: Aditya Nagesh, adityanagesh, kys, haiyangz, wei.liu, decui,
	linux-hyperv, linux-kernel
  Cc: llvm, oe-kbuild-all, Aditya Nagesh

Hi Aditya,

kernel test robot noticed the following build errors:

[auto build test ERROR on next-20240529]
[cannot apply to linus/master v6.10-rc1 v6.9 v6.9-rc7 v6.10-rc1]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Aditya-Nagesh/Drivers-hv-Cosmetic-changes-for-hv-c-and-balloon-c/20240530-000928
base:   next-20240529
patch link:    https://lore.kernel.org/r/1716998695-32135-1-git-send-email-adityanagesh%40linux.microsoft.com
patch subject: [PATCH v5] Drivers: hv: Cosmetic changes for hv.c and balloon.c
config: i386-buildonly-randconfig-004-20240530 (https://download.01.org/0day-ci/archive/20240530/202405300835.7RLpoY4A-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240530/202405300835.7RLpoY4A-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405300835.7RLpoY4A-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/hv/hv_balloon.c:980:2: error: unterminated conditional directive
     980 | #ifdef CONFIG_MEMORY_HOTPLUG
         |  ^
>> drivers/hv/hv_balloon.c:2129:23: error: expected '}'
    2129 | MODULE_LICENSE("GPL");
         |                       ^
   drivers/hv/hv_balloon.c:968:1: note: to match this '{'
     968 | {
         | ^
   2 errors generated.


vim +980 drivers/hv/hv_balloon.c

1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   966  
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   967  static void hot_add_req(struct work_struct *dummy)
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   968  {
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   969  	struct dm_hot_add_response resp;
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   970  #ifdef CONFIG_MEMORY_HOTPLUG
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   971  	unsigned long pg_start, pfn_cnt;
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   972  	unsigned long rg_start, rg_sz;
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   973  #endif
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   974  	struct hv_dynmem_device *dm = &dm_device;
9aa8b50b2b3d3a K. Y. Srinivasan 2012-11-14   975  
9aa8b50b2b3d3a K. Y. Srinivasan 2012-11-14   976  	memset(&resp, 0, sizeof(struct dm_hot_add_response));
9aa8b50b2b3d3a K. Y. Srinivasan 2012-11-14   977  	resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
9aa8b50b2b3d3a K. Y. Srinivasan 2012-11-14   978  	resp.hdr.size = sizeof(struct dm_hot_add_response);
9aa8b50b2b3d3a K. Y. Srinivasan 2012-11-14   979  
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15  @980  #ifdef CONFIG_MEMORY_HOTPLUG
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   981  	pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   982  	pfn_cnt = dm->ha_wrk.ha_page_range.finfo.page_cnt;
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   983  
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   984  	rg_start = dm->ha_wrk.ha_region_range.finfo.start_page;
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   985  	rg_sz = dm->ha_wrk.ha_region_range.finfo.page_cnt;
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   986  
1aa0ebde593dfb Aditya Nagesh    2024-05-29   987  	if (rg_start == 0 && !dm->host_specified_ha_region) {
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   988  		/*
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   989  		 * Based on the hot-add page range being specified,
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   990  	}
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   991  
7f4f2302a11173 K. Y. Srinivasan 2013-03-18   992  	if (do_hot_add)
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   993  		resp.page_count = process_hot_add(pg_start, pfn_cnt,
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   994  						  rg_start, rg_sz);
549fd280b145e2 Vitaly Kuznetsov 2015-02-28   995  
549fd280b145e2 Vitaly Kuznetsov 2015-02-28   996  	dm->num_pages_added += resp.page_count;
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15   997  #endif
7f4f2302a11173 K. Y. Srinivasan 2013-03-18   998  	/*
7f4f2302a11173 K. Y. Srinivasan 2013-03-18   999  	 * The result field of the response structure has the
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1000  	 * following semantics:
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1001  	 *
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1002  	 * 1. If all or some pages hot-added: Guest should return success.
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1003  	 *
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1004  	 * 2. If no pages could be hot-added:
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1005  	 *
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1006  	 * If the guest returns success, then the host
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1007  	 * will not attempt any further hot-add operations. This
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1008  	 * signifies a permanent failure.
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1009  	 *
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1010  	 * If the guest returns failure, then this failure will be
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1011  	 * treated as a transient failure and the host may retry the
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1012  	 * hot-add operation after some delay.
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1013  	 */
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15  1014  	if (resp.page_count > 0)
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15  1015  		resp.result = 1;
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1016  	else if (!do_hot_add)
7f4f2302a11173 K. Y. Srinivasan 2013-03-18  1017  		resp.result = 1;
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15  1018  	else
9aa8b50b2b3d3a K. Y. Srinivasan 2012-11-14  1019  		resp.result = 0;
9aa8b50b2b3d3a K. Y. Srinivasan 2012-11-14  1020  
25bd2b2f1f0534 Dexuan Cui       2019-11-19  1021  	if (!do_hot_add || resp.page_count == 0) {
25bd2b2f1f0534 Dexuan Cui       2019-11-19  1022  		if (!allow_hibernation)
223e1e4d2c16fe Vitaly Kuznetsov 2018-03-04  1023  			pr_err("Memory hot add failed\n");
25bd2b2f1f0534 Dexuan Cui       2019-11-19  1024  		else
25bd2b2f1f0534 Dexuan Cui       2019-11-19  1025  			pr_info("Ignore hot-add request!\n");
25bd2b2f1f0534 Dexuan Cui       2019-11-19  1026  	}
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15  1027  
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15  1028  	dm->state = DM_INITIALIZED;
20138d6cb838aa K. Y. Srinivasan 2013-07-17  1029  	resp.hdr.trans_id = atomic_inc_return(&trans_id);
1cac8cd4d146b6 K. Y. Srinivasan 2013-03-15  1030  	vmbus_sendpacket(dm->dev->channel, &resp,
9aa8b50b2b3d3a K. Y. Srinivasan 2012-11-14  1031  			sizeof(struct dm_hot_add_response),
9aa8b50b2b3d3a K. Y. Srinivasan 2012-11-14  1032  			(unsigned long)NULL,
9aa8b50b2b3d3a K. Y. Srinivasan 2012-11-14  1033  			VM_PKT_DATA_INBAND, 0);
9aa8b50b2b3d3a K. Y. Srinivasan 2012-11-14  1034  }
9aa8b50b2b3d3a K. Y. Srinivasan 2012-11-14  1035  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v5] Drivers: hv: Cosmetic changes for hv.c and balloon.c
  2024-05-29 16:29 ` Michael Kelley
@ 2024-05-30  2:45   ` Wei Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2024-05-30  2:45 UTC (permalink / raw)
  To: Michael Kelley
  Cc: Aditya Nagesh, adityanagesh@microsoft.com, kys@microsoft.com,
	haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org

On Wed, May 29, 2024 at 04:29:17PM +0000, Michael Kelley wrote:
> From: Aditya Nagesh <adityanagesh@linux.microsoft.com> Sent: Wednesday, May 29, 2024 9:05 AM
> > 
> > Fix issues reported by checkpatch.pl script in hv.c and
> > balloon.c
> >  - Remove unnecessary parentheses
> >  - Remove extra newlines
> >  - Remove extra spaces
> >  - Add spaces between comparison operators
> >  - Remove comparison with NULL in if statements
> > 
> > No functional changes intended
> > 
> > Signed-off-by: Aditya Nagesh <adityanagesh@linux.microsoft.com>
> > Reviewed-by: Saurabh Sengar <ssengar@linux.microsoft.com>
> > ---
> > [V5]
> > Rebase to hyperv-fixes
> > 
> > [V4]
> > Fix Alignment issue and revert a line since 100 characters are allowed in a line
> > 
> > [V3]
> > Fix alignment issues in multiline function parameters.
> > 
> > [V2]
> > Change Subject from "Drivers: hv: Fix Issues reported by checkpatch.pl script"
> >  to "Drivers: hv: Cosmetic changes for hv.c and balloon.c"
> >  drivers/hv/hv.c         |  37 +++++++-------
> >  drivers/hv/hv_balloon.c | 105 ++++++++++++++--------------------------
> >  2 files changed, 53 insertions(+), 89 deletions(-)
> > 
> 
> [snip]
> 
> > @@ -999,21 +984,14 @@ static void hot_add_req(struct work_struct *dummy)
> >  	rg_start = dm->ha_wrk.ha_region_range.finfo.start_page;
> >  	rg_sz = dm->ha_wrk.ha_region_range.finfo.page_cnt;
> > 
> > -	if ((rg_start == 0) && (!dm->host_specified_ha_region)) {
> > +	if (rg_start == 0 && !dm->host_specified_ha_region) {
> >  		/*
> > -		 * The host has not specified the hot-add region.
> >  		 * Based on the hot-add page range being specified,
> > -		 * compute a hot-add region that can cover the pages
> > -		 * that need to be hot-added while ensuring the alignment
> > -		 * and size requirements of Linux as it relates to hot-add.
> > -		 */
> > -		rg_start = ALIGN_DOWN(pg_start, ha_pages_in_chunk);
> > -		rg_sz = ALIGN(pfn_cnt, ha_pages_in_chunk);
> 
> Hmmm.  The above is not a cosmetic change.  Looks like this
> delta was erroneously introduced in the v5 version.  It wasn't
> there in v4.

This also breaks the build, since now the comment is not terminated.

Please fix this and resubmit.

In general, you should always build test your code before submission.

Thanks,
Wei.

> 
> Everything else LGTM.
> 
> Michael

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v5] Drivers: hv: Cosmetic changes for hv.c and balloon.c
  2024-05-29 16:04 [PATCH v5] Drivers: hv: Cosmetic changes for hv.c and balloon.c Aditya Nagesh
  2024-05-29 16:29 ` Michael Kelley
  2024-05-30  1:06 ` kernel test robot
@ 2024-05-30  8:12 ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2024-05-30  8:12 UTC (permalink / raw)
  To: Aditya Nagesh, adityanagesh, kys, haiyangz, wei.liu, decui,
	linux-hyperv, linux-kernel
  Cc: oe-kbuild-all, Aditya Nagesh

Hi Aditya,

kernel test robot noticed the following build errors:

[auto build test ERROR on next-20240529]
[cannot apply to linus/master v6.10-rc1 v6.9 v6.9-rc7 v6.10-rc1]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Aditya-Nagesh/Drivers-hv-Cosmetic-changes-for-hv-c-and-balloon-c/20240530-000928
base:   next-20240529
patch link:    https://lore.kernel.org/r/1716998695-32135-1-git-send-email-adityanagesh%40linux.microsoft.com
patch subject: [PATCH v5] Drivers: hv: Cosmetic changes for hv.c and balloon.c
config: arm64-randconfig-002-20240530 (https://download.01.org/0day-ci/archive/20240530/202405301550.DKuS2OzK-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240530/202405301550.DKuS2OzK-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405301550.DKuS2OzK-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   drivers/hv/hv_balloon.c: In function 'hot_add_req':
>> drivers/hv/hv_balloon.c:998:9: warning: "/*" within comment [-Wcomment]
     998 |         /*
         |          
>> drivers/hv/hv_balloon.c:980: error: unterminated #ifdef
     980 | #ifdef CONFIG_MEMORY_HOTPLUG
         | 
>> drivers/hv/hv_balloon.c:978:39: error: expected declaration or statement at end of input
     978 |         resp.hdr.size = sizeof(struct dm_hot_add_response);
         |                                       ^~~~~~~~~~~~~~~~~~~
>> drivers/hv/hv_balloon.c:974:34: warning: unused variable 'dm' [-Wunused-variable]
     974 |         struct hv_dynmem_device *dm = &dm_device;
         |                                  ^~
   drivers/hv/hv_balloon.c: At top level:
>> drivers/hv/hv_balloon.c:575:13: warning: 'post_status' declared 'static' but never defined [-Wunused-function]
     575 | static void post_status(struct hv_dynmem_device *dm);
         |             ^~~~~~~~~~~
>> drivers/hv/hv_balloon.c:577:13: warning: 'enable_page_reporting' declared 'static' but never defined [-Wunused-function]
     577 | static void enable_page_reporting(void);
         |             ^~~~~~~~~~~~~~~~~~~~~
>> drivers/hv/hv_balloon.c:579:13: warning: 'disable_page_reporting' declared 'static' but never defined [-Wunused-function]
     579 | static void disable_page_reporting(void);
         |             ^~~~~~~~~~~~~~~~~~~~~~
>> drivers/hv/hv_balloon.c:967:13: warning: 'hot_add_req' defined but not used [-Wunused-function]
     967 | static void hot_add_req(struct work_struct *dummy)
         |             ^~~~~~~~~~~
>> drivers/hv/hv_balloon.c:496:22: warning: 'ha_pages_in_chunk' defined but not used [-Wunused-variable]
     496 | static unsigned long ha_pages_in_chunk;
         |                      ^~~~~~~~~~~~~~~~~
>> drivers/hv/hv_balloon.c:494:13: warning: 'balloon_up_send_buffer' defined but not used [-Wunused-variable]
     494 | static __u8 balloon_up_send_buffer[HV_HYP_PAGE_SIZE];
         |             ^~~~~~~~~~~~~~~~~~~~~~
>> drivers/hv/hv_balloon.c:493:13: warning: 'recv_buffer' defined but not used [-Wunused-variable]
     493 | static __u8 recv_buffer[HV_HYP_PAGE_SIZE];
         |             ^~~~~~~~~~~
>> drivers/hv/hv_balloon.c:478:12: warning: 'dm_ring_size' defined but not used [-Wunused-variable]
     478 | static int dm_ring_size = VMBUS_RING_SIZE(16 * 1024);
         |            ^~~~~~~~~~~~
>> drivers/hv/hv_balloon.c:476:17: warning: 'trans_id' defined but not used [-Wunused-variable]
     476 | static atomic_t trans_id = ATOMIC_INIT(0);
         |                 ^~~~~~~~
>> drivers/hv/hv_balloon.c:469:12: warning: 'hv_hypercall_multi_failure' defined but not used [-Wunused-variable]
     469 | static int hv_hypercall_multi_failure;
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/hv/hv_balloon.c:467:22: warning: 'last_post_time' defined but not used [-Wunused-variable]
     467 | static unsigned long last_post_time;
         |                      ^~~~~~~~~~~~~~
>> drivers/hv/hv_balloon.c:455:13: warning: 'do_hot_add' defined but not used [-Wunused-variable]
     455 | static bool do_hot_add;
         |             ^~~~~~~~~~
>> drivers/hv/hv_balloon.c:453:13: warning: 'allow_hibernation' defined but not used [-Wunused-variable]
     453 | static bool allow_hibernation;
         |             ^~~~~~~~~~~~~~~~~


vim +980 drivers/hv/hv_balloon.c

1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   966  
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15  @967  static void hot_add_req(struct work_struct *dummy)
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   968  {
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   969  	struct dm_hot_add_response resp;
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   970  #ifdef CONFIG_MEMORY_HOTPLUG
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   971  	unsigned long pg_start, pfn_cnt;
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   972  	unsigned long rg_start, rg_sz;
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   973  #endif
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15  @974  	struct hv_dynmem_device *dm = &dm_device;
9aa8b50b2b3d3a7 K. Y. Srinivasan 2012-11-14   975  
9aa8b50b2b3d3a7 K. Y. Srinivasan 2012-11-14   976  	memset(&resp, 0, sizeof(struct dm_hot_add_response));
9aa8b50b2b3d3a7 K. Y. Srinivasan 2012-11-14   977  	resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
9aa8b50b2b3d3a7 K. Y. Srinivasan 2012-11-14  @978  	resp.hdr.size = sizeof(struct dm_hot_add_response);
9aa8b50b2b3d3a7 K. Y. Srinivasan 2012-11-14   979  
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15  @980  #ifdef CONFIG_MEMORY_HOTPLUG
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   981  	pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   982  	pfn_cnt = dm->ha_wrk.ha_page_range.finfo.page_cnt;
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   983  
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   984  	rg_start = dm->ha_wrk.ha_region_range.finfo.start_page;
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   985  	rg_sz = dm->ha_wrk.ha_region_range.finfo.page_cnt;
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   986  
1aa0ebde593dfb1 Aditya Nagesh    2024-05-29   987  	if (rg_start == 0 && !dm->host_specified_ha_region) {
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   988  		/*
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   989  		 * Based on the hot-add page range being specified,
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   990  	}
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   991  
7f4f2302a11173d K. Y. Srinivasan 2013-03-18   992  	if (do_hot_add)
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   993  		resp.page_count = process_hot_add(pg_start, pfn_cnt,
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   994  						  rg_start, rg_sz);
549fd280b145e21 Vitaly Kuznetsov 2015-02-28   995  
549fd280b145e21 Vitaly Kuznetsov 2015-02-28   996  	dm->num_pages_added += resp.page_count;
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15   997  #endif
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  @998  	/*
7f4f2302a11173d K. Y. Srinivasan 2013-03-18   999  	 * The result field of the response structure has the
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1000  	 * following semantics:
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1001  	 *
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1002  	 * 1. If all or some pages hot-added: Guest should return success.
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1003  	 *
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1004  	 * 2. If no pages could be hot-added:
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1005  	 *
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1006  	 * If the guest returns success, then the host
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1007  	 * will not attempt any further hot-add operations. This
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1008  	 * signifies a permanent failure.
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1009  	 *
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1010  	 * If the guest returns failure, then this failure will be
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1011  	 * treated as a transient failure and the host may retry the
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1012  	 * hot-add operation after some delay.
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1013  	 */
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15  1014  	if (resp.page_count > 0)
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15  1015  		resp.result = 1;
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1016  	else if (!do_hot_add)
7f4f2302a11173d K. Y. Srinivasan 2013-03-18  1017  		resp.result = 1;
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15  1018  	else
9aa8b50b2b3d3a7 K. Y. Srinivasan 2012-11-14  1019  		resp.result = 0;
9aa8b50b2b3d3a7 K. Y. Srinivasan 2012-11-14  1020  
25bd2b2f1f05347 Dexuan Cui       2019-11-19  1021  	if (!do_hot_add || resp.page_count == 0) {
25bd2b2f1f05347 Dexuan Cui       2019-11-19  1022  		if (!allow_hibernation)
223e1e4d2c16fed Vitaly Kuznetsov 2018-03-04  1023  			pr_err("Memory hot add failed\n");
25bd2b2f1f05347 Dexuan Cui       2019-11-19  1024  		else
25bd2b2f1f05347 Dexuan Cui       2019-11-19  1025  			pr_info("Ignore hot-add request!\n");
25bd2b2f1f05347 Dexuan Cui       2019-11-19  1026  	}
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15  1027  
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15  1028  	dm->state = DM_INITIALIZED;
20138d6cb838aa0 K. Y. Srinivasan 2013-07-17  1029  	resp.hdr.trans_id = atomic_inc_return(&trans_id);
1cac8cd4d146b60 K. Y. Srinivasan 2013-03-15  1030  	vmbus_sendpacket(dm->dev->channel, &resp,
9aa8b50b2b3d3a7 K. Y. Srinivasan 2012-11-14  1031  			sizeof(struct dm_hot_add_response),
9aa8b50b2b3d3a7 K. Y. Srinivasan 2012-11-14  1032  			(unsigned long)NULL,
9aa8b50b2b3d3a7 K. Y. Srinivasan 2012-11-14  1033  			VM_PKT_DATA_INBAND, 0);
9aa8b50b2b3d3a7 K. Y. Srinivasan 2012-11-14  1034  }
9aa8b50b2b3d3a7 K. Y. Srinivasan 2012-11-14  1035  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-30  8:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29 16:04 [PATCH v5] Drivers: hv: Cosmetic changes for hv.c and balloon.c Aditya Nagesh
2024-05-29 16:29 ` Michael Kelley
2024-05-30  2:45   ` Wei Liu
2024-05-30  1:06 ` kernel test robot
2024-05-30  8:12 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).