linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] Drivers: hv: Change hv_free_hyperv_page() to take void * argument
@ 2023-06-23 22:09 Kameron Carr
  2023-06-23 22:19 ` Dexuan Cui
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kameron Carr @ 2023-06-23 22:09 UTC (permalink / raw)
  To: arnd, decui, haiyangz, kys, linux-arch, linux-hyperv,
	linux-kernel, wei.liu

Currently hv_free_hyperv_page() takes an unsigned long argument, which
is inconsistent with the void * return value from the corresponding
hv_alloc_hyperv_page() function and variants. This creates unnecessary
extra casting.

Change the hv_free_hyperv_page() argument type to void *.
Also remove redundant casts from invocations of
hv_alloc_hyperv_page() and variants.

Signed-off-by: Kameron Carr <kameroncarr@linux.microsoft.com>
---
V1 -> V2: Added Signed-off-by

 drivers/hv/connection.c        | 13 ++++++-------
 drivers/hv/hv_common.c         | 10 +++++-----
 include/asm-generic/mshyperv.h |  2 +-
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 5978e9d..ebf15f3 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -209,8 +209,7 @@ int vmbus_connect(void)
 	 * Setup the vmbus event connection for channel interrupt
 	 * abstraction stuff
 	 */
-	vmbus_connection.int_page =
-	(void *)hv_alloc_hyperv_zeroed_page();
+	vmbus_connection.int_page = hv_alloc_hyperv_zeroed_page();
 	if (vmbus_connection.int_page == NULL) {
 		ret = -ENOMEM;
 		goto cleanup;
@@ -225,8 +224,8 @@ int vmbus_connect(void)
 	 * Setup the monitor notification facility. The 1st page for
 	 * parent->child and the 2nd page for child->parent
 	 */
-	vmbus_connection.monitor_pages[0] = (void *)hv_alloc_hyperv_page();
-	vmbus_connection.monitor_pages[1] = (void *)hv_alloc_hyperv_page();
+	vmbus_connection.monitor_pages[0] = hv_alloc_hyperv_page();
+	vmbus_connection.monitor_pages[1] = hv_alloc_hyperv_page();
 	if ((vmbus_connection.monitor_pages[0] == NULL) ||
 	    (vmbus_connection.monitor_pages[1] == NULL)) {
 		ret = -ENOMEM;
@@ -333,15 +332,15 @@ void vmbus_disconnect(void)
 		destroy_workqueue(vmbus_connection.work_queue);
 
 	if (vmbus_connection.int_page) {
-		hv_free_hyperv_page((unsigned long)vmbus_connection.int_page);
+		hv_free_hyperv_page(vmbus_connection.int_page);
 		vmbus_connection.int_page = NULL;
 	}
 
 	set_memory_encrypted((unsigned long)vmbus_connection.monitor_pages[0], 1);
 	set_memory_encrypted((unsigned long)vmbus_connection.monitor_pages[1], 1);
 
-	hv_free_hyperv_page((unsigned long)vmbus_connection.monitor_pages[0]);
-	hv_free_hyperv_page((unsigned long)vmbus_connection.monitor_pages[1]);
+	hv_free_hyperv_page(vmbus_connection.monitor_pages[0]);
+	hv_free_hyperv_page(vmbus_connection.monitor_pages[1]);
 	vmbus_connection.monitor_pages[0] = NULL;
 	vmbus_connection.monitor_pages[1] = NULL;
 }
diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
index 542a1d5..6a2258f 100644
--- a/drivers/hv/hv_common.c
+++ b/drivers/hv/hv_common.c
@@ -115,12 +115,12 @@ void *hv_alloc_hyperv_zeroed_page(void)
 }
 EXPORT_SYMBOL_GPL(hv_alloc_hyperv_zeroed_page);
 
-void hv_free_hyperv_page(unsigned long addr)
+void hv_free_hyperv_page(void *addr)
 {
 	if (PAGE_SIZE == HV_HYP_PAGE_SIZE)
-		free_page(addr);
+		free_page((unsigned long)addr);
 	else
-		kfree((void *)addr);
+		kfree(addr);
 }
 EXPORT_SYMBOL_GPL(hv_free_hyperv_page);
 
@@ -253,7 +253,7 @@ static void hv_kmsg_dump_unregister(void)
 	atomic_notifier_chain_unregister(&panic_notifier_list,
 					 &hyperv_panic_report_block);
 
-	hv_free_hyperv_page((unsigned long)hv_panic_page);
+	hv_free_hyperv_page(hv_panic_page);
 	hv_panic_page = NULL;
 }
 
@@ -270,7 +270,7 @@ static void hv_kmsg_dump_register(void)
 	ret = kmsg_dump_register(&hv_kmsg_dumper);
 	if (ret) {
 		pr_err("Hyper-V: kmsg dump register error 0x%x\n", ret);
-		hv_free_hyperv_page((unsigned long)hv_panic_page);
+		hv_free_hyperv_page(hv_panic_page);
 		hv_panic_page = NULL;
 	}
 }
diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
index 402a8c1..a8f4b65 100644
--- a/include/asm-generic/mshyperv.h
+++ b/include/asm-generic/mshyperv.h
@@ -190,7 +190,7 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
 
 void *hv_alloc_hyperv_page(void);
 void *hv_alloc_hyperv_zeroed_page(void);
-void hv_free_hyperv_page(unsigned long addr);
+void hv_free_hyperv_page(void *addr);
 
 /**
  * hv_cpu_number_to_vp_number() - Map CPU to VP.
-- 
1.8.3.1


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

* RE: [PATCH v2] Drivers: hv: Change hv_free_hyperv_page() to take void * argument
  2023-06-23 22:09 [PATCH v2] Drivers: hv: Change hv_free_hyperv_page() to take void * argument Kameron Carr
@ 2023-06-23 22:19 ` Dexuan Cui
  2023-06-27 16:58 ` Nuno Das Neves
  2023-06-28 17:51 ` Wei Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Dexuan Cui @ 2023-06-23 22:19 UTC (permalink / raw)
  To: Kameron Carr, arnd, Haiyang Zhang, KY Srinivasan, linux-arch,
	linux-hyperv, linux-kernel, wei.liu

> From: Kameron Carr <kameroncarr@linux.microsoft.com>
> Sent: Friday, June 23, 2023 3:10 PM
>  ...
> Currently hv_free_hyperv_page() takes an unsigned long argument, which
> is inconsistent with the void * return value from the corresponding
> hv_alloc_hyperv_page() function and variants. This creates unnecessary
> extra casting.
> 
> Change the hv_free_hyperv_page() argument type to void *.
> Also remove redundant casts from invocations of
> hv_alloc_hyperv_page() and variants.
> 
> Signed-off-by: Kameron Carr <kameroncarr@linux.microsoft.com>
> ---
> V1 -> V2: Added Signed-off-by

Reviewed-by: Dexuan Cui <decui@microsoft.com>

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

* Re: [PATCH v2] Drivers: hv: Change hv_free_hyperv_page() to take void * argument
  2023-06-23 22:09 [PATCH v2] Drivers: hv: Change hv_free_hyperv_page() to take void * argument Kameron Carr
  2023-06-23 22:19 ` Dexuan Cui
@ 2023-06-27 16:58 ` Nuno Das Neves
  2023-06-28 17:51 ` Wei Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Nuno Das Neves @ 2023-06-27 16:58 UTC (permalink / raw)
  To: Kameron Carr, arnd, decui, haiyangz, kys, linux-arch,
	linux-hyperv, linux-kernel, wei.liu

Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>

On 6/23/2023 3:09 PM, Kameron Carr wrote:
> Currently hv_free_hyperv_page() takes an unsigned long argument, which
> is inconsistent with the void * return value from the corresponding
> hv_alloc_hyperv_page() function and variants. This creates unnecessary
> extra casting.
> 
> Change the hv_free_hyperv_page() argument type to void *.
> Also remove redundant casts from invocations of
> hv_alloc_hyperv_page() and variants.
> 
> Signed-off-by: Kameron Carr <kameroncarr@linux.microsoft.com>
> ---
> V1 -> V2: Added Signed-off-by
> 
>  drivers/hv/connection.c        | 13 ++++++-------
>  drivers/hv/hv_common.c         | 10 +++++-----
>  include/asm-generic/mshyperv.h |  2 +-
>  3 files changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
> index 5978e9d..ebf15f3 100644
> --- a/drivers/hv/connection.c
> +++ b/drivers/hv/connection.c
> @@ -209,8 +209,7 @@ int vmbus_connect(void)
>  	 * Setup the vmbus event connection for channel interrupt
>  	 * abstraction stuff
>  	 */
> -	vmbus_connection.int_page =
> -	(void *)hv_alloc_hyperv_zeroed_page();
> +	vmbus_connection.int_page = hv_alloc_hyperv_zeroed_page();
>  	if (vmbus_connection.int_page == NULL) {
>  		ret = -ENOMEM;
>  		goto cleanup;
> @@ -225,8 +224,8 @@ int vmbus_connect(void)
>  	 * Setup the monitor notification facility. The 1st page for
>  	 * parent->child and the 2nd page for child->parent
>  	 */
> -	vmbus_connection.monitor_pages[0] = (void *)hv_alloc_hyperv_page();
> -	vmbus_connection.monitor_pages[1] = (void *)hv_alloc_hyperv_page();
> +	vmbus_connection.monitor_pages[0] = hv_alloc_hyperv_page();
> +	vmbus_connection.monitor_pages[1] = hv_alloc_hyperv_page();
>  	if ((vmbus_connection.monitor_pages[0] == NULL) ||
>  	    (vmbus_connection.monitor_pages[1] == NULL)) {
>  		ret = -ENOMEM;
> @@ -333,15 +332,15 @@ void vmbus_disconnect(void)
>  		destroy_workqueue(vmbus_connection.work_queue);
>  
>  	if (vmbus_connection.int_page) {
> -		hv_free_hyperv_page((unsigned long)vmbus_connection.int_page);
> +		hv_free_hyperv_page(vmbus_connection.int_page);
>  		vmbus_connection.int_page = NULL;
>  	}
>  
>  	set_memory_encrypted((unsigned long)vmbus_connection.monitor_pages[0], 1);
>  	set_memory_encrypted((unsigned long)vmbus_connection.monitor_pages[1], 1);
>  
> -	hv_free_hyperv_page((unsigned long)vmbus_connection.monitor_pages[0]);
> -	hv_free_hyperv_page((unsigned long)vmbus_connection.monitor_pages[1]);
> +	hv_free_hyperv_page(vmbus_connection.monitor_pages[0]);
> +	hv_free_hyperv_page(vmbus_connection.monitor_pages[1]);
>  	vmbus_connection.monitor_pages[0] = NULL;
>  	vmbus_connection.monitor_pages[1] = NULL;
>  }
> diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
> index 542a1d5..6a2258f 100644
> --- a/drivers/hv/hv_common.c
> +++ b/drivers/hv/hv_common.c
> @@ -115,12 +115,12 @@ void *hv_alloc_hyperv_zeroed_page(void)
>  }
>  EXPORT_SYMBOL_GPL(hv_alloc_hyperv_zeroed_page);
>  
> -void hv_free_hyperv_page(unsigned long addr)
> +void hv_free_hyperv_page(void *addr)
>  {
>  	if (PAGE_SIZE == HV_HYP_PAGE_SIZE)
> -		free_page(addr);
> +		free_page((unsigned long)addr);
>  	else
> -		kfree((void *)addr);
> +		kfree(addr);
>  }
>  EXPORT_SYMBOL_GPL(hv_free_hyperv_page);
>  
> @@ -253,7 +253,7 @@ static void hv_kmsg_dump_unregister(void)
>  	atomic_notifier_chain_unregister(&panic_notifier_list,
>  					 &hyperv_panic_report_block);
>  
> -	hv_free_hyperv_page((unsigned long)hv_panic_page);
> +	hv_free_hyperv_page(hv_panic_page);
>  	hv_panic_page = NULL;
>  }
>  
> @@ -270,7 +270,7 @@ static void hv_kmsg_dump_register(void)
>  	ret = kmsg_dump_register(&hv_kmsg_dumper);
>  	if (ret) {
>  		pr_err("Hyper-V: kmsg dump register error 0x%x\n", ret);
> -		hv_free_hyperv_page((unsigned long)hv_panic_page);
> +		hv_free_hyperv_page(hv_panic_page);
>  		hv_panic_page = NULL;
>  	}
>  }
> diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
> index 402a8c1..a8f4b65 100644
> --- a/include/asm-generic/mshyperv.h
> +++ b/include/asm-generic/mshyperv.h
> @@ -190,7 +190,7 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
>  
>  void *hv_alloc_hyperv_page(void);
>  void *hv_alloc_hyperv_zeroed_page(void);
> -void hv_free_hyperv_page(unsigned long addr);
> +void hv_free_hyperv_page(void *addr);
>  
>  /**
>   * hv_cpu_number_to_vp_number() - Map CPU to VP.


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

* Re: [PATCH v2] Drivers: hv: Change hv_free_hyperv_page() to take void * argument
  2023-06-23 22:09 [PATCH v2] Drivers: hv: Change hv_free_hyperv_page() to take void * argument Kameron Carr
  2023-06-23 22:19 ` Dexuan Cui
  2023-06-27 16:58 ` Nuno Das Neves
@ 2023-06-28 17:51 ` Wei Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2023-06-28 17:51 UTC (permalink / raw)
  To: Kameron Carr
  Cc: arnd, decui, haiyangz, kys, linux-arch, linux-hyperv,
	linux-kernel, wei.liu

On Fri, Jun 23, 2023 at 03:09:49PM -0700, Kameron Carr wrote:
> Currently hv_free_hyperv_page() takes an unsigned long argument, which
> is inconsistent with the void * return value from the corresponding
> hv_alloc_hyperv_page() function and variants. This creates unnecessary
> extra casting.
> 
> Change the hv_free_hyperv_page() argument type to void *.
> Also remove redundant casts from invocations of
> hv_alloc_hyperv_page() and variants.
> 
> Signed-off-by: Kameron Carr <kameroncarr@linux.microsoft.com>

Applied to hyperv-fixes. Thanks!

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

end of thread, other threads:[~2023-06-28 17:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-23 22:09 [PATCH v2] Drivers: hv: Change hv_free_hyperv_page() to take void * argument Kameron Carr
2023-06-23 22:19 ` Dexuan Cui
2023-06-27 16:58 ` Nuno Das Neves
2023-06-28 17:51 ` Wei Liu

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).