linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] Drivers: hv: vmbus: Add parsing of VMbus interrupt in ACPI DSDT
@ 2020-08-13 23:51 Michael Kelley
  2020-08-14  9:44 ` Wei Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Kelley @ 2020-08-13 23:51 UTC (permalink / raw)
  To: linux-kernel, kys, sthemmin, wei.liu, linux-hyperv
  Cc: mikelley, tglx, peterz, mingo, bp, x86, hpa

On ARM64, Hyper-V now specifies the interrupt to be used by VMbus
in the ACPI DSDT.  This information is not used on x86 because the
interrupt vector must be hardcoded.  But update the generic
VMbus driver to do the parsing and pass the information to the
architecture specific code that sets up the Linux IRQ.  Update
consumers of the interrupt to get it from an architecture specific
function.

Signed-off-by: Michael Kelley <mikelley@microsoft.com>
---
 arch/x86/include/asm/mshyperv.h |  1 +
 arch/x86/kernel/cpu/mshyperv.c  |  3 ++-
 drivers/hv/hv.c                 |  2 +-
 drivers/hv/vmbus_drv.c          | 30 +++++++++++++++++++++++++++---
 include/asm-generic/mshyperv.h  |  4 +++-
 5 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 4f77b8f..ffc2899 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -54,6 +54,7 @@ typedef int (*hyperv_fill_flush_list_func)(
 #define hv_enable_vdso_clocksource() \
 	vclocks_set_used(VDSO_CLOCKMODE_HVCLOCK);
 #define hv_get_raw_timer() rdtsc_ordered()
+#define hv_get_vector() HYPERVISOR_CALLBACK_VECTOR
 
 /*
  * Reference to pv_ops must be inline so objtool
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 3112544..538aa87 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -55,9 +55,10 @@
 	set_irq_regs(old_regs);
 }
 
-void hv_setup_vmbus_irq(void (*handler)(void))
+int hv_setup_vmbus_irq(int irq, void (*handler)(void))
 {
 	vmbus_handler = handler;
+	return 0;
 }
 
 void hv_remove_vmbus_irq(void)
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index da69338..2bd44fd 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -180,7 +180,7 @@ void hv_synic_enable_regs(unsigned int cpu)
 	/* Setup the shared SINT. */
 	hv_get_synint_state(VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
 
-	shared_sint.vector = HYPERVISOR_CALLBACK_VECTOR;
+	shared_sint.vector = hv_get_vector();
 	shared_sint.masked = false;
 	shared_sint.auto_eoi = hv_recommend_using_aeoi();
 	hv_set_synint_state(VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 910b6e9..3f6a42a 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -48,6 +48,10 @@ struct vmbus_dynid {
 
 static void *hv_panic_page;
 
+/* Values parsed from ACPI DSDT */
+static int vmbus_irq;
+int vmbus_interrupt;
+
 /*
  * Boolean to control whether to report panic messages over Hyper-V.
  *
@@ -1347,7 +1351,7 @@ static void vmbus_isr(void)
 			tasklet_schedule(&hv_cpu->msg_dpc);
 	}
 
-	add_interrupt_randomness(HYPERVISOR_CALLBACK_VECTOR, 0);
+	add_interrupt_randomness(hv_get_vector(), 0);
 }
 
 /*
@@ -1430,7 +1434,9 @@ static int vmbus_bus_init(void)
 	if (ret)
 		return ret;
 
-	hv_setup_vmbus_irq(vmbus_isr);
+	ret = hv_setup_vmbus_irq(vmbus_irq, vmbus_isr);
+	if (ret)
+		goto err_setup;
 
 	ret = hv_synic_alloc();
 	if (ret)
@@ -1505,7 +1511,7 @@ static int vmbus_bus_init(void)
 	hv_synic_free();
 err_alloc:
 	hv_remove_vmbus_irq();
-
+err_setup:
 	bus_unregister(&hv_bus);
 	unregister_sysctl_table(hv_ctl_table_hdr);
 	hv_ctl_table_hdr = NULL;
@@ -2070,6 +2076,7 @@ static acpi_status vmbus_walk_resources(struct acpi_resource *res, void *ctx)
 	struct resource *new_res;
 	struct resource **old_res = &hyperv_mmio;
 	struct resource **prev_res = NULL;
+	struct resource r;
 
 	switch (res->type) {
 
@@ -2088,6 +2095,23 @@ static acpi_status vmbus_walk_resources(struct acpi_resource *res, void *ctx)
 		end = res->data.address64.address.maximum;
 		break;
 
+	/*
+	 * The IRQ information is needed only on ARM64, which Hyper-V
+	 * sets up in the extended format. IRQ information is present
+	 * on x86/x64 in the non-extended format but it is not used by
+	 * Linux. So don't bother checking for the non-extended format.
+	 */
+	case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
+		if (!acpi_dev_resource_interrupt(res, 0, &r)) {
+			pr_err("Unable to parse Hyper-V ACPI interrupt\n");
+			return AE_ERROR;
+		}
+		/* ARM64 INTID for VMbus */
+		vmbus_interrupt = res->data.extended_irq.interrupts[0];
+		/* Linux IRQ number */
+		vmbus_irq = r.start;
+		return AE_OK;
+
 	default:
 		/* Unused resource type */
 		return AE_OK;
diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
index c5edc5e..c577996 100644
--- a/include/asm-generic/mshyperv.h
+++ b/include/asm-generic/mshyperv.h
@@ -89,7 +89,7 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
 	}
 }
 
-void hv_setup_vmbus_irq(void (*handler)(void));
+int hv_setup_vmbus_irq(int irq, void (*handler)(void));
 void hv_remove_vmbus_irq(void);
 void hv_enable_vmbus_irq(void);
 void hv_disable_vmbus_irq(void);
@@ -99,6 +99,8 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
 void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs));
 void hv_remove_crash_handler(void);
 
+extern int vmbus_interrupt;
+
 #if IS_ENABLED(CONFIG_HYPERV)
 /*
  * Hypervisor's notion of virtual processor ID is different from
-- 
1.8.3.1


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

* Re: [PATCH 1/1] Drivers: hv: vmbus: Add parsing of VMbus interrupt in ACPI DSDT
  2020-08-13 23:51 [PATCH 1/1] Drivers: hv: vmbus: Add parsing of VMbus interrupt in ACPI DSDT Michael Kelley
@ 2020-08-14  9:44 ` Wei Liu
  2020-08-14 13:32   ` Michael Kelley
  0 siblings, 1 reply; 4+ messages in thread
From: Wei Liu @ 2020-08-14  9:44 UTC (permalink / raw)
  To: Michael Kelley
  Cc: linux-kernel, kys, sthemmin, wei.liu, linux-hyperv, tglx, peterz,
	mingo, bp, x86, hpa

On Thu, Aug 13, 2020 at 04:51:19PM -0700, Michael Kelley wrote:
> On ARM64, Hyper-V now specifies the interrupt to be used by VMbus
> in the ACPI DSDT.  This information is not used on x86 because the
> interrupt vector must be hardcoded.  But update the generic
> VMbus driver to do the parsing and pass the information to the
> architecture specific code that sets up the Linux IRQ.  Update
> consumers of the interrupt to get it from an architecture specific
> function.
> 
> Signed-off-by: Michael Kelley <mikelley@microsoft.com>
> ---
>  arch/x86/include/asm/mshyperv.h |  1 +
>  arch/x86/kernel/cpu/mshyperv.c  |  3 ++-
>  drivers/hv/hv.c                 |  2 +-
>  drivers/hv/vmbus_drv.c          | 30 +++++++++++++++++++++++++++---
>  include/asm-generic/mshyperv.h  |  4 +++-
>  5 files changed, 34 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
> index 4f77b8f..ffc2899 100644
> --- a/arch/x86/include/asm/mshyperv.h
> +++ b/arch/x86/include/asm/mshyperv.h
> @@ -54,6 +54,7 @@ typedef int (*hyperv_fill_flush_list_func)(
>  #define hv_enable_vdso_clocksource() \
>  	vclocks_set_used(VDSO_CLOCKMODE_HVCLOCK);
>  #define hv_get_raw_timer() rdtsc_ordered()
> +#define hv_get_vector() HYPERVISOR_CALLBACK_VECTOR
>  
>  /*
>   * Reference to pv_ops must be inline so objtool
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index 3112544..538aa87 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -55,9 +55,10 @@
>  	set_irq_regs(old_regs);
>  }
>  
> -void hv_setup_vmbus_irq(void (*handler)(void))
> +int hv_setup_vmbus_irq(int irq, void (*handler)(void))
>  {

irq is not used here. Did you perhaps forget to commit a chunk of code?

>  	vmbus_handler = handler;
> +	return 0;
>  }

Wei.

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

* RE: [PATCH 1/1] Drivers: hv: vmbus: Add parsing of VMbus interrupt in ACPI DSDT
  2020-08-14  9:44 ` Wei Liu
@ 2020-08-14 13:32   ` Michael Kelley
  2020-08-14 13:44     ` Wei Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Kelley @ 2020-08-14 13:32 UTC (permalink / raw)
  To: Wei Liu
  Cc: linux-kernel, KY Srinivasan, Stephen Hemminger, linux-hyperv,
	tglx, peterz, mingo, bp, x86, hpa

From: Wei Liu <wei.liu@kernel.org> Sent: Friday, August 14, 2020 2:44 AM
> 
> On Thu, Aug 13, 2020 at 04:51:19PM -0700, Michael Kelley wrote:
> > On ARM64, Hyper-V now specifies the interrupt to be used by VMbus
> > in the ACPI DSDT.  This information is not used on x86 because the
> > interrupt vector must be hardcoded.  But update the generic
> > VMbus driver to do the parsing and pass the information to the
> > architecture specific code that sets up the Linux IRQ.  Update
> > consumers of the interrupt to get it from an architecture specific
> > function.
> >
> > Signed-off-by: Michael Kelley <mikelley@microsoft.com>
> > ---
> >  arch/x86/include/asm/mshyperv.h |  1 +
> >  arch/x86/kernel/cpu/mshyperv.c  |  3 ++-
> >  drivers/hv/hv.c                 |  2 +-
> >  drivers/hv/vmbus_drv.c          | 30 +++++++++++++++++++++++++++---
> >  include/asm-generic/mshyperv.h  |  4 +++-
> >  5 files changed, 34 insertions(+), 6 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
> > index 4f77b8f..ffc2899 100644
> > --- a/arch/x86/include/asm/mshyperv.h
> > +++ b/arch/x86/include/asm/mshyperv.h
> > @@ -54,6 +54,7 @@ typedef int (*hyperv_fill_flush_list_func)(
> >  #define hv_enable_vdso_clocksource() \
> >  	vclocks_set_used(VDSO_CLOCKMODE_HVCLOCK);
> >  #define hv_get_raw_timer() rdtsc_ordered()
> > +#define hv_get_vector() HYPERVISOR_CALLBACK_VECTOR
> >
> >  /*
> >   * Reference to pv_ops must be inline so objtool
> > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> > index 3112544..538aa87 100644
> > --- a/arch/x86/kernel/cpu/mshyperv.c
> > +++ b/arch/x86/kernel/cpu/mshyperv.c
> > @@ -55,9 +55,10 @@
> >  	set_irq_regs(old_regs);
> >  }
> >
> > -void hv_setup_vmbus_irq(void (*handler)(void))
> > +int hv_setup_vmbus_irq(int irq, void (*handler)(void))
> >  {
> 
> irq is not used here. Did you perhaps forget to commit a chunk of code?

No, this is correct.  Per the commit message, the irq information
parsed from the DSDT is not used in the x86 code.  But it is used on the
ARM64 side.  I should add a comment to that effect here in the x86
code so there's no confusion.

Michael

> 
> >  	vmbus_handler = handler;
> > +	return 0;
> >  }
> 
> Wei.

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

* Re: [PATCH 1/1] Drivers: hv: vmbus: Add parsing of VMbus interrupt in ACPI DSDT
  2020-08-14 13:32   ` Michael Kelley
@ 2020-08-14 13:44     ` Wei Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2020-08-14 13:44 UTC (permalink / raw)
  To: Michael Kelley
  Cc: Wei Liu, linux-kernel, KY Srinivasan, Stephen Hemminger,
	linux-hyperv, tglx, peterz, mingo, bp, x86, hpa

On Fri, Aug 14, 2020 at 01:32:11PM +0000, Michael Kelley wrote:
> From: Wei Liu <wei.liu@kernel.org> Sent: Friday, August 14, 2020 2:44 AM
> > 
> > On Thu, Aug 13, 2020 at 04:51:19PM -0700, Michael Kelley wrote:
> > > On ARM64, Hyper-V now specifies the interrupt to be used by VMbus
> > > in the ACPI DSDT.  This information is not used on x86 because the
> > > interrupt vector must be hardcoded.  But update the generic
> > > VMbus driver to do the parsing and pass the information to the
> > > architecture specific code that sets up the Linux IRQ.  Update
> > > consumers of the interrupt to get it from an architecture specific
> > > function.
> > >
> > > Signed-off-by: Michael Kelley <mikelley@microsoft.com>
> > > ---
> > >  arch/x86/include/asm/mshyperv.h |  1 +
> > >  arch/x86/kernel/cpu/mshyperv.c  |  3 ++-
> > >  drivers/hv/hv.c                 |  2 +-
> > >  drivers/hv/vmbus_drv.c          | 30 +++++++++++++++++++++++++++---
> > >  include/asm-generic/mshyperv.h  |  4 +++-
> > >  5 files changed, 34 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
> > > index 4f77b8f..ffc2899 100644
> > > --- a/arch/x86/include/asm/mshyperv.h
> > > +++ b/arch/x86/include/asm/mshyperv.h
> > > @@ -54,6 +54,7 @@ typedef int (*hyperv_fill_flush_list_func)(
> > >  #define hv_enable_vdso_clocksource() \
> > >  	vclocks_set_used(VDSO_CLOCKMODE_HVCLOCK);
> > >  #define hv_get_raw_timer() rdtsc_ordered()
> > > +#define hv_get_vector() HYPERVISOR_CALLBACK_VECTOR
> > >
> > >  /*
> > >   * Reference to pv_ops must be inline so objtool
> > > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> > > index 3112544..538aa87 100644
> > > --- a/arch/x86/kernel/cpu/mshyperv.c
> > > +++ b/arch/x86/kernel/cpu/mshyperv.c
> > > @@ -55,9 +55,10 @@
> > >  	set_irq_regs(old_regs);
> > >  }
> > >
> > > -void hv_setup_vmbus_irq(void (*handler)(void))
> > > +int hv_setup_vmbus_irq(int irq, void (*handler)(void))
> > >  {
> > 
> > irq is not used here. Did you perhaps forget to commit a chunk of code?
> 
> No, this is correct.  Per the commit message, the irq information
> parsed from the DSDT is not used in the x86 code.  But it is used on the
> ARM64 side.  I should add a comment to that effect here in the x86
> code so there's no confusion.

I see. The function for Arm64 is not here yet.

If you want to send a new version, feel free. I can also queue this
version up. I don't think lacking a comment here is a blocking issue.

Wei.

> 
> Michael
> 
> > 
> > >  	vmbus_handler = handler;
> > > +	return 0;
> > >  }
> > 
> > Wei.

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

end of thread, other threads:[~2020-08-14 13:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13 23:51 [PATCH 1/1] Drivers: hv: vmbus: Add parsing of VMbus interrupt in ACPI DSDT Michael Kelley
2020-08-14  9:44 ` Wei Liu
2020-08-14 13:32   ` Michael Kelley
2020-08-14 13:44     ` 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).