Skip to contentSkip to conversation

x86/Hyper-V: Initialize Syn timer clock when it's

PATCH In review [email protected] 3 participants 5 messages Mar 30, 2020 – Apr 2, 2020 Hyper-V/Azure core and drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/Hyper-V: Initialize Syn timer clock when it's

From: Tianyu Lan <[email protected]>

Current code initializes clock event data structure for syn timer even when it's not available. Fix it.

---
- Fix the wrong title.

 drivers/hv/hv.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/hv/hv.c +9 -6
index 632d25674e7f..2e893768fc76 100644
@@ -212,13 +212,16 @@ int hv_synic_alloc(void)
 		tasklet_init(&hv_cpu->msg_dpc,
 			     vmbus_on_msg_dpc, (unsigned long) hv_cpu);
 
-		hv_cpu->clk_evt = kzalloc(sizeof(struct clock_event_device),
-					  GFP_KERNEL);
-		if (hv_cpu->clk_evt == NULL) {
-			pr_err("Unable to allocate clock event device\n");
-			goto err;
+		if (ms_hyperv.features & HV_MSR_SYNTIMER_AVAILABLE) {
+			hv_cpu->clk_evt =
+				kzalloc(sizeof(struct clock_event_device),
+						  GFP_KERNEL);
+			if (hv_cpu->clk_evt == NULL) {
+				pr_err("Unable to allocate clock event device\n");
+				goto err;
+			}
+			hv_init_clockevent_device(hv_cpu->clk_evt, cpu);
 		}
-		hv_init_clockevent_device(hv_cpu->clk_evt, cpu);
 
 		hv_cpu->synic_message_page =
 			(void *)get_zeroed_page(GFP_ATOMIC);
Signature · 1 line
2.14.5
#1 lore raw
Quoted 8 lines · [email protected] writes:

From: Tianyu Lan <[email protected]>

Current code initializes clock event data structure for syn timer even when it's not available. Fix it.

---
- Fix the wrong title.

The new one is ... weird too :-)

I think it was supposed to be something like "x86/Hyper-V: don't allocate clockevent device when synthetic timer is unavailable"

Quoted 2 lines
 
 drivers/hv/hv.c | 15 +++++++++------

Which tree is this patch for? Upstream clockevent allocation has moved to drivers/clocksource/hyperv_timer.c

Quoted 29 lines
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/hv/hv.c +9 -6
index 632d25674e7f..2e893768fc76 100644
@@ -212,13 +212,16 @@ int hv_synic_alloc(void)
 		tasklet_init(&hv_cpu->msg_dpc,
 			     vmbus_on_msg_dpc, (unsigned long) hv_cpu);
 
-		hv_cpu->clk_evt = kzalloc(sizeof(struct clock_event_device),
-					  GFP_KERNEL);
-		if (hv_cpu->clk_evt == NULL) {
-			pr_err("Unable to allocate clock event device\n");
-			goto err;
+		if (ms_hyperv.features & HV_MSR_SYNTIMER_AVAILABLE) {
+			hv_cpu->clk_evt =
+				kzalloc(sizeof(struct clock_event_device),
+						  GFP_KERNEL);
+			if (hv_cpu->clk_evt == NULL) {
+				pr_err("Unable to allocate clock event device\n");
+				goto err;
+			}
+			hv_init_clockevent_device(hv_cpu->clk_evt, cpu);
 		}
-		hv_init_clockevent_device(hv_cpu->clk_evt, cpu);
 
 		hv_cpu->synic_message_page =
 			(void *)get_zeroed_page(GFP_ATOMIC);
Signature · 1 line
Vitaly
author
#2 lore raw

Hi Vitaly:
Thanks for your review.

Quoted 7 lines · Vitaly Kuznetsov
Quoted 5 lines · [email protected] writes:

From: Tianyu Lan <[email protected]>

Current code initializes clock event data structure for syn timer even when it's not available. Fix it.

Quoted 8 lines
Quoted 3 lines

---
- Fix the wrong title.

The new one is ... weird too :-)

I think it was supposed to be something like "x86/Hyper-V: don't allocate clockevent device when synthetic timer is unavailable"

Good suggestion. Will update in the next version.

Quoted 37 lines
Quoted 3 lines
  
  drivers/hv/hv.c | 15 +++++++++------

Which tree is this patch for? Upstream clockevent allocation has moved to drivers/clocksource/hyperv_timer.c

Quoted 29 lines
  1 file changed, 9 insertions(+), 6 deletions(-)
drivers/hv/hv.c +9 -6
index 632d25674e7f..2e893768fc76 100644
@@ -212,13 +212,16 @@ int hv_synic_alloc(void)
  		tasklet_init(&hv_cpu->msg_dpc,
  			     vmbus_on_msg_dpc, (unsigned long) hv_cpu);
 
-		hv_cpu->clk_evt = kzalloc(sizeof(struct clock_event_device),
-					  GFP_KERNEL);
-		if (hv_cpu->clk_evt == NULL) {
-			pr_err("Unable to allocate clock event device\n");
-			goto err;
+		if (ms_hyperv.features & HV_MSR_SYNTIMER_AVAILABLE) {
+			hv_cpu->clk_evt =
+				kzalloc(sizeof(struct clock_event_device),
+						  GFP_KERNEL);
+			if (hv_cpu->clk_evt == NULL) {
+				pr_err("Unable to allocate clock event device\n");
+				goto err;
+			}
+			hv_init_clockevent_device(hv_cpu->clk_evt, cpu);
  		}
-		hv_init_clockevent_device(hv_cpu->clk_evt, cpu);
 
  		hv_cpu->synic_message_page =
  			(void *)get_zeroed_page(GFP_ATOMIC);
author
#4 lore raw

Hi Dan:
Sorry. Please ignore this patch and it's based on the old code.

Quoted 5 lines · Dan Carpenter

This doesn't apply to today's linux-next.

regards,
dan carpenter