diff mbox series

[v8,2/6] arm64: hyperv: Add Hyper-V clocksource/clockevent support

Message ID 1613690194-102905-3-git-send-email-mikelley@microsoft.com (mailing list archive)
State New, archived
Headers show
Series Enable Linux guests on Hyper-V on ARM64 | expand

Commit Message

Michael Kelley (LINUX) Feb. 18, 2021, 11:16 p.m. UTC
Add architecture specific definitions and functions needed
by the architecture independent Hyper-V clocksource driver.
Update the Hyper-V clocksource driver to be initialized
on ARM64.

Signed-off-by: Michael Kelley <mikelley@microsoft.com>
---
 arch/arm64/include/asm/mshyperv.h  | 12 ++++++++++++
 drivers/clocksource/hyperv_timer.c | 14 ++++++++++++++
 2 files changed, 26 insertions(+)

Comments

kernel test robot Feb. 19, 2021, 2:35 a.m. UTC | #1
Hi Michael,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on tip/timers/core efi/next linus/master v5.11 next-20210218]
[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]

url:    https://github.com/0day-ci/linux/commits/Michael-Kelley/Enable-Linux-guests-on-Hyper-V-on-ARM64/20210219-072336
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: i386-randconfig-a003-20210218 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/a8eb25332c441e0965c0ecdfb1a86b507e3465e1
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Michael-Kelley/Enable-Linux-guests-on-Hyper-V-on-ARM64/20210219-072336
        git checkout a8eb25332c441e0965c0ecdfb1a86b507e3465e1
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/clocksource/hyperv_timer.c:478:44: warning: 'struct acpi_table_header' declared inside parameter list will not be visible outside of this definition or declaration
     478 | static int __init hyperv_timer_init(struct acpi_table_header *table)
         |                                            ^~~~~~~~~~~~~~~~~
   drivers/clocksource/hyperv_timer.c: In function 'hyperv_timer_init':
   drivers/clocksource/hyperv_timer.c:484:6: error: too many arguments to function 'hv_stimer_alloc'
     484 |  if (hv_stimer_alloc(true))
         |      ^~~~~~~~~~~~~~~
   drivers/clocksource/hyperv_timer.c:173:5: note: declared here
     173 | int hv_stimer_alloc(void)
         |     ^~~~~~~~~~~~~~~
   In file included from include/linux/clockchips.h:14,
                    from drivers/clocksource/hyperv_timer.c:16:
   drivers/clocksource/hyperv_timer.c: At top level:
   include/linux/clocksource.h:283:50: error: expected ')' before numeric constant
     283 |  ACPI_DECLARE_PROBE_ENTRY(timer, name, table_id, 0, NULL, 0, fn)
         |                                                  ^
   drivers/clocksource/hyperv_timer.c:489:1: note: in expansion of macro 'TIMER_ACPI_DECLARE'
     489 | TIMER_ACPI_DECLARE(hyperv, ACPI_SIG_GTDT, hyperv_timer_init);
         | ^~~~~~~~~~~~~~~~~~
   drivers/clocksource/hyperv_timer.c:478:19: warning: 'hyperv_timer_init' defined but not used [-Wunused-function]
     478 | static int __init hyperv_timer_init(struct acpi_table_header *table)
         |                   ^~~~~~~~~~~~~~~~~


vim +478 drivers/clocksource/hyperv_timer.c

   476	
   477	/* Initialize everything on ARM64 */
 > 478	static int __init hyperv_timer_init(struct acpi_table_header *table)

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Feb. 19, 2021, 4:40 a.m. UTC | #2
Hi Michael,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on tip/timers/core efi/next linus/master v5.11 next-20210218]
[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]

url:    https://github.com/0day-ci/linux/commits/Michael-Kelley/Enable-Linux-guests-on-Hyper-V-on-ARM64/20210219-072336
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: i386-randconfig-a003-20210218 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/a8eb25332c441e0965c0ecdfb1a86b507e3465e1
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Michael-Kelley/Enable-Linux-guests-on-Hyper-V-on-ARM64/20210219-072336
        git checkout a8eb25332c441e0965c0ecdfb1a86b507e3465e1
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/clocksource/hyperv_timer.c:478:44: warning: 'struct acpi_table_header' declared inside parameter list will not be visible outside of this definition or declaration
     478 | static int __init hyperv_timer_init(struct acpi_table_header *table)
         |                                            ^~~~~~~~~~~~~~~~~
   drivers/clocksource/hyperv_timer.c: In function 'hyperv_timer_init':
>> drivers/clocksource/hyperv_timer.c:484:6: error: too many arguments to function 'hv_stimer_alloc'
     484 |  if (hv_stimer_alloc(true))
         |      ^~~~~~~~~~~~~~~
   drivers/clocksource/hyperv_timer.c:173:5: note: declared here
     173 | int hv_stimer_alloc(void)
         |     ^~~~~~~~~~~~~~~
   In file included from include/linux/clockchips.h:14,
                    from drivers/clocksource/hyperv_timer.c:16:
   drivers/clocksource/hyperv_timer.c: At top level:
>> include/linux/clocksource.h:283:50: error: expected ')' before numeric constant
     283 |  ACPI_DECLARE_PROBE_ENTRY(timer, name, table_id, 0, NULL, 0, fn)
         |                                                  ^
   drivers/clocksource/hyperv_timer.c:489:1: note: in expansion of macro 'TIMER_ACPI_DECLARE'
     489 | TIMER_ACPI_DECLARE(hyperv, ACPI_SIG_GTDT, hyperv_timer_init);
         | ^~~~~~~~~~~~~~~~~~
   drivers/clocksource/hyperv_timer.c:478:19: warning: 'hyperv_timer_init' defined but not used [-Wunused-function]
     478 | static int __init hyperv_timer_init(struct acpi_table_header *table)
         |                   ^~~~~~~~~~~~~~~~~


vim +/hv_stimer_alloc +484 drivers/clocksource/hyperv_timer.c

   476	
   477	/* Initialize everything on ARM64 */
   478	static int __init hyperv_timer_init(struct acpi_table_header *table)
   479	{
   480		if (!hv_is_hyperv_initialized())
   481			return -EINVAL;
   482	
   483		hv_init_clocksource();
 > 484		if (hv_stimer_alloc(true))

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/mshyperv.h b/arch/arm64/include/asm/mshyperv.h
index 44ee012..d6ff2ee 100644
--- a/arch/arm64/include/asm/mshyperv.h
+++ b/arch/arm64/include/asm/mshyperv.h
@@ -21,6 +21,7 @@ 
 #include <linux/types.h>
 #include <linux/arm-smccc.h>
 #include <asm/hyperv-tlfs.h>
+#include <clocksource/arm_arch_timer.h>
 
 /*
  * Declare calls to get and set Hyper-V VP register values on ARM64, which
@@ -42,6 +43,17 @@  static inline u64 hv_get_register(unsigned int reg)
 	return hv_get_vpreg(reg);
 }
 
+/* Define the interrupt ID used by STIMER0 Direct Mode interrupts. This
+ * value can't come from ACPI tables because it is needed before the
+ * Linux ACPI subsystem is initialized.
+ */
+#define HYPERV_STIMER0_VECTOR	31
+
+static inline u64 hv_get_raw_timer(void)
+{
+	return arch_timer_read_counter();
+}
+
 /* SMCCC hypercall parameters */
 #define HV_SMCCC_FUNC_NUMBER	1
 #define HV_FUNC_ID	ARM_SMCCC_CALL_VAL(			\
diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
index c553b8c..f8bb5df 100644
--- a/drivers/clocksource/hyperv_timer.c
+++ b/drivers/clocksource/hyperv_timer.c
@@ -567,3 +567,17 @@  void __init hv_init_clocksource(void)
 	hv_setup_sched_clock(read_hv_sched_clock_msr);
 }
 EXPORT_SYMBOL_GPL(hv_init_clocksource);
+
+/* Initialize everything on ARM64 */
+static int __init hyperv_timer_init(struct acpi_table_header *table)
+{
+	if (!hv_is_hyperv_initialized())
+		return -EINVAL;
+
+	hv_init_clocksource();
+	if (hv_stimer_alloc(true))
+		return -EINVAL;
+
+	return 0;
+}
+TIMER_ACPI_DECLARE(hyperv, ACPI_SIG_GTDT, hyperv_timer_init);