All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
@ 2011-06-29 19:06 K. Y. Srinivasan
  2011-06-29 19:06   ` Greg KH
  0 siblings, 1 reply; 15+ messages in thread
From: K. Y. Srinivasan @ 2011-06-29 19:06 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

The Hyper-V timesource driver is best integrated with Hyper-V detection code
since: (a) Linux guests running on Hyper-V need this timesource and (b)
by integrating with Hyper-V detection, we could minimize the code in the 
timesource driver. Greg, you had  helped me initially in getting the Hyper-V
detection code into the kernel (mshyperv.c). I am hoping you can take
this patch. 

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 arch/x86/kernel/cpu/mshyperv.c     |   24 ++++++++
 drivers/staging/hv/Makefile        |    2 +-
 drivers/staging/hv/hv_timesource.c |  102 ------------------------------------
 3 files changed, 25 insertions(+), 103 deletions(-)
 delete mode 100644 drivers/staging/hv/hv_timesource.c

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index d944bf6..c97f88d 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -11,6 +11,8 @@
  */
 
 #include <linux/types.h>
+#include <linux/time.h>
+#include <linux/clocksource.h>
 #include <linux/module.h>
 #include <asm/processor.h>
 #include <asm/hypervisor.h>
@@ -36,6 +38,25 @@ static bool __init ms_hyperv_platform(void)
 		!memcmp("Microsoft Hv", hyp_signature, 12);
 }
 
+static cycle_t read_hv_clock(struct clocksource *arg)
+{
+	cycle_t current_tick;
+	/*
+	 * Read the partition counter to get the current tick count. This count
+	 * is set to 0 when the partition is created and is incremented in
+	 * 100 nanosecond units.
+	 */
+	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
+	return current_tick;
+}
+
+static struct clocksource hyperv_cs = {
+	.name           = "hyperv_clocksource",
+	.rating         = 400, /* use this when running on Hyperv*/
+	.read           = read_hv_clock,
+	.mask           = CLOCKSOURCE_MASK(64),
+};
+
 static void __init ms_hyperv_init_platform(void)
 {
 	/*
@@ -46,6 +67,9 @@ static void __init ms_hyperv_init_platform(void)
 
 	printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
 	       ms_hyperv.features, ms_hyperv.hints);
+
+
+	clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index bd176b1..3e0d7e6 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -1,4 +1,4 @@
-obj-$(CONFIG_HYPERV)		+= hv_vmbus.o hv_timesource.o
+obj-$(CONFIG_HYPERV)		+= hv_vmbus.o
 obj-$(CONFIG_HYPERV_STORAGE)	+= hv_storvsc.o
 obj-$(CONFIG_HYPERV_NET)	+= hv_netvsc.o
 obj-$(CONFIG_HYPERV_UTILS)	+= hv_utils.o
diff --git a/drivers/staging/hv/hv_timesource.c b/drivers/staging/hv/hv_timesource.c
deleted file mode 100644
index 0efb049..0000000
--- a/drivers/staging/hv/hv_timesource.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * A clocksource for Linux running on HyperV.
- *
- *
- * Copyright (C) 2010, Novell, Inc.
- * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/version.h>
-#include <linux/clocksource.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/dmi.h>
-#include <asm/hyperv.h>
-#include <asm/mshyperv.h>
-#include <asm/hypervisor.h>
-
-#define HV_CLOCK_SHIFT	22
-
-static cycle_t read_hv_clock(struct clocksource *arg)
-{
-	cycle_t current_tick;
-	/*
-	 * Read the partition counter to get the current tick count. This count
-	 * is set to 0 when the partition is created and is incremented in
-	 * 100 nanosecond units.
-	 */
-	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
-	return current_tick;
-}
-
-static struct clocksource hyperv_cs = {
-	.name           = "hyperv_clocksource",
-	.rating         = 400, /* use this when running on Hyperv*/
-	.read           = read_hv_clock,
-	.mask           = CLOCKSOURCE_MASK(64),
-	/*
-	 * The time ref counter in HyperV is in 100ns units.
-	 * The definition of mult is:
-	 * mult/2^shift = ns/cyc = 100
-	 * mult = (100 << shift)
-	 */
-	.mult           = (100 << HV_CLOCK_SHIFT),
-	.shift          = HV_CLOCK_SHIFT,
-};
-
-static const struct dmi_system_id __initconst
-hv_timesource_dmi_table[] __maybe_unused  = {
-	{
-		.ident = "Hyper-V",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-		},
-	},
-	{ },
-};
-MODULE_DEVICE_TABLE(dmi, hv_timesource_dmi_table);
-
-static const struct pci_device_id __initconst
-hv_timesource_pci_table[] __maybe_unused = {
-	{ PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, hv_timesource_pci_table);
-
-
-static int __init init_hv_clocksource(void)
-{
-	if ((x86_hyper != &x86_hyper_ms_hyperv) ||
-		!(ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE))
-		return -ENODEV;
-
-	if (!dmi_check_system(hv_timesource_dmi_table))
-		return -ENODEV;
-
-	pr_info("Registering HyperV clock source\n");
-	return clocksource_register(&hyperv_cs);
-}
-
-module_init(init_hv_clocksource);
-MODULE_DESCRIPTION("HyperV based clocksource");
-MODULE_AUTHOR("K. Y. Srinivasan <ksrinivasan@novell.com>");
-MODULE_LICENSE("GPL");
-- 
1.7.4.1


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

* Re: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
  2011-06-29 19:06 [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code K. Y. Srinivasan
@ 2011-06-29 19:06   ` Greg KH
  0 siblings, 0 replies; 15+ messages in thread
From: Greg KH @ 2011-06-29 19:06 UTC (permalink / raw)
  To: K. Y. Srinivasan; +Cc: linux-kernel, devel, virtualization, Haiyang Zhang

On Wed, Jun 29, 2011 at 12:06:04PM -0700, K. Y. Srinivasan wrote:
> The Hyper-V timesource driver is best integrated with Hyper-V detection code
> since: (a) Linux guests running on Hyper-V need this timesource and (b)
> by integrating with Hyper-V detection, we could minimize the code in the 
> timesource driver. Greg, you had  helped me initially in getting the Hyper-V
> detection code into the kernel (mshyperv.c). I am hoping you can take
> this patch. 

Nope, it needs to go through the x86 maintainers, please resend it to
them.  The scripts/get_maintainer.pl file should have told you this,
right?

thanks,

greg k-h

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

* Re: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
@ 2011-06-29 19:06   ` Greg KH
  0 siblings, 0 replies; 15+ messages in thread
From: Greg KH @ 2011-06-29 19:06 UTC (permalink / raw)
  To: K. Y. Srinivasan; +Cc: devel, Haiyang Zhang, linux-kernel, virtualization

On Wed, Jun 29, 2011 at 12:06:04PM -0700, K. Y. Srinivasan wrote:
> The Hyper-V timesource driver is best integrated with Hyper-V detection code
> since: (a) Linux guests running on Hyper-V need this timesource and (b)
> by integrating with Hyper-V detection, we could minimize the code in the 
> timesource driver. Greg, you had  helped me initially in getting the Hyper-V
> detection code into the kernel (mshyperv.c). I am hoping you can take
> this patch. 

Nope, it needs to go through the x86 maintainers, please resend it to
them.  The scripts/get_maintainer.pl file should have told you this,
right?

thanks,

greg k-h

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

* RE: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
  2011-06-29 19:06   ` Greg KH
  (?)
@ 2011-06-30  0:42   ` KY Srinivasan
  -1 siblings, 0 replies; 15+ messages in thread
From: KY Srinivasan @ 2011-06-30  0:42 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, devel, virtualization, Haiyang Zhang



> -----Original Message-----
> From: Greg KH [mailto:gregkh@suse.de]
> Sent: Wednesday, June 29, 2011 3:07 PM
> To: KY Srinivasan
> Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-
> V detection code
> 
> On Wed, Jun 29, 2011 at 12:06:04PM -0700, K. Y. Srinivasan wrote:
> > The Hyper-V timesource driver is best integrated with Hyper-V detection code
> > since: (a) Linux guests running on Hyper-V need this timesource and (b)
> > by integrating with Hyper-V detection, we could minimize the code in the
> > timesource driver. Greg, you had  helped me initially in getting the Hyper-V
> > detection code into the kernel (mshyperv.c). I am hoping you can take
> > this patch.
> 
> Nope, it needs to go through the x86 maintainers, please resend it to
> them.  The scripts/get_maintainer.pl file should have told you this,
> right?

Thanks Greg. I have done what you have recommended.

Regards,

K. Y


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

* Re: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
  2011-09-07 22:25 K. Y. Srinivasan
@ 2011-09-09 20:32   ` Greg KH
  0 siblings, 0 replies; 15+ messages in thread
From: Greg KH @ 2011-09-09 20:32 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang

On Wed, Sep 07, 2011 at 03:25:10PM -0700, K. Y. Srinivasan wrote:
> The Hyper-V timesource driver is best integrated with Hyper-V detection code
> since: (a) Linux guests running on Hyper-V need this timesource and (b)
> by integrating with Hyper-V detection, we could significantly  minimize the
> code in the timesource driver.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>

Acked-by: Greg Kroah-Hartman <gregkh@suse.de>


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

* Re: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
@ 2011-09-09 20:32   ` Greg KH
  0 siblings, 0 replies; 15+ messages in thread
From: Greg KH @ 2011-09-09 20:32 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization

On Wed, Sep 07, 2011 at 03:25:10PM -0700, K. Y. Srinivasan wrote:
> The Hyper-V timesource driver is best integrated with Hyper-V detection code
> since: (a) Linux guests running on Hyper-V need this timesource and (b)
> by integrating with Hyper-V detection, we could significantly  minimize the
> code in the timesource driver.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>

Acked-by: Greg Kroah-Hartman <gregkh@suse.de>

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

* [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
@ 2011-09-07 22:25 K. Y. Srinivasan
  2011-09-09 20:32   ` Greg KH
  0 siblings, 1 reply; 15+ messages in thread
From: K. Y. Srinivasan @ 2011-09-07 22:25 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

The Hyper-V timesource driver is best integrated with Hyper-V detection code
since: (a) Linux guests running on Hyper-V need this timesource and (b)
by integrating with Hyper-V detection, we could significantly  minimize the
code in the timesource driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 arch/x86/kernel/cpu/mshyperv.c     |   24 +++++++++
 drivers/staging/hv/Makefile        |    2 +-
 drivers/staging/hv/hv_timesource.c |  101 ------------------------------------
 3 files changed, 25 insertions(+), 102 deletions(-)
 delete mode 100644 drivers/staging/hv/hv_timesource.c

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index d944bf6..c97f88d 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -11,6 +11,8 @@
  */
 
 #include <linux/types.h>
+#include <linux/time.h>
+#include <linux/clocksource.h>
 #include <linux/module.h>
 #include <asm/processor.h>
 #include <asm/hypervisor.h>
@@ -36,6 +38,25 @@ static bool __init ms_hyperv_platform(void)
 		!memcmp("Microsoft Hv", hyp_signature, 12);
 }
 
+static cycle_t read_hv_clock(struct clocksource *arg)
+{
+	cycle_t current_tick;
+	/*
+	 * Read the partition counter to get the current tick count. This count
+	 * is set to 0 when the partition is created and is incremented in
+	 * 100 nanosecond units.
+	 */
+	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
+	return current_tick;
+}
+
+static struct clocksource hyperv_cs = {
+	.name           = "hyperv_clocksource",
+	.rating         = 400, /* use this when running on Hyperv*/
+	.read           = read_hv_clock,
+	.mask           = CLOCKSOURCE_MASK(64),
+};
+
 static void __init ms_hyperv_init_platform(void)
 {
 	/*
@@ -46,6 +67,9 @@ static void __init ms_hyperv_init_platform(void)
 
 	printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
 	       ms_hyperv.features, ms_hyperv.hints);
+
+
+	clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index bd176b1..3e0d7e6 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -1,4 +1,4 @@
-obj-$(CONFIG_HYPERV)		+= hv_vmbus.o hv_timesource.o
+obj-$(CONFIG_HYPERV)		+= hv_vmbus.o
 obj-$(CONFIG_HYPERV_STORAGE)	+= hv_storvsc.o
 obj-$(CONFIG_HYPERV_NET)	+= hv_netvsc.o
 obj-$(CONFIG_HYPERV_UTILS)	+= hv_utils.o
diff --git a/drivers/staging/hv/hv_timesource.c b/drivers/staging/hv/hv_timesource.c
deleted file mode 100644
index 2b0f9aa..0000000
--- a/drivers/staging/hv/hv_timesource.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * A clocksource for Linux running on HyperV.
- *
- *
- * Copyright (C) 2010, Novell, Inc.
- * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/clocksource.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/dmi.h>
-#include <asm/hyperv.h>
-#include <asm/mshyperv.h>
-#include <asm/hypervisor.h>
-
-#define HV_CLOCK_SHIFT	22
-
-static cycle_t read_hv_clock(struct clocksource *arg)
-{
-	cycle_t current_tick;
-	/*
-	 * Read the partition counter to get the current tick count. This count
-	 * is set to 0 when the partition is created and is incremented in
-	 * 100 nanosecond units.
-	 */
-	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
-	return current_tick;
-}
-
-static struct clocksource hyperv_cs = {
-	.name           = "hyperv_clocksource",
-	.rating         = 400, /* use this when running on Hyperv*/
-	.read           = read_hv_clock,
-	.mask           = CLOCKSOURCE_MASK(64),
-	/*
-	 * The time ref counter in HyperV is in 100ns units.
-	 * The definition of mult is:
-	 * mult/2^shift = ns/cyc = 100
-	 * mult = (100 << shift)
-	 */
-	.mult           = (100 << HV_CLOCK_SHIFT),
-	.shift          = HV_CLOCK_SHIFT,
-};
-
-static const struct dmi_system_id __initconst
-hv_timesource_dmi_table[] __maybe_unused  = {
-	{
-		.ident = "Hyper-V",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-		},
-	},
-	{ },
-};
-MODULE_DEVICE_TABLE(dmi, hv_timesource_dmi_table);
-
-static const struct pci_device_id __initconst
-hv_timesource_pci_table[] __maybe_unused = {
-	{ PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, hv_timesource_pci_table);
-
-
-static int __init init_hv_clocksource(void)
-{
-	if ((x86_hyper != &x86_hyper_ms_hyperv) ||
-		!(ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE))
-		return -ENODEV;
-
-	if (!dmi_check_system(hv_timesource_dmi_table))
-		return -ENODEV;
-
-	pr_info("Registering HyperV clock source\n");
-	return clocksource_register(&hyperv_cs);
-}
-
-module_init(init_hv_clocksource);
-MODULE_DESCRIPTION("HyperV based clocksource");
-MODULE_AUTHOR("K. Y. Srinivasan <ksrinivasan@novell.com>");
-MODULE_LICENSE("GPL");
-- 
1.7.4.1


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

* RE: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
  2011-09-02  8:13 ` Thomas Gleixner
@ 2011-09-02 13:30     ` KY Srinivasan
  0 siblings, 0 replies; 15+ messages in thread
From: KY Srinivasan @ 2011-09-02 13:30 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: gregkh, linux-kernel, devel, virtualization, andi, akpm, x86,
	Haiyang Zhang



> -----Original Message-----
> From: Thomas Gleixner [mailto:tglx@linutronix.de]
> Sent: Friday, September 02, 2011 4:14 AM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; andi@firstfloor.org;
> akpm@linux-foundation.org; x86@kernel.org; Haiyang Zhang
> Subject: Re: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-
> V detection code
> 
> On Tue, 2 Aug 2011, K. Y. Srinivasan wrote:
> 
> > The Hyper-V timesource driver is best integrated with Hyper-V detection code
> > since: (a) Linux guests running on Hyper-V need this timesource and (b)
> > by integrating with Hyper-V detection, we could significantly  minimize the
> > code in the timesource driver.
> >
> > Andrew, could you take this patch for the -mm tree. I have sent this patch
> > out multiple times and I have not recived any response or comments.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> 
> Acked-by: Thomas Gleixner <tglx@linutronix.de>

Thanks Thomas. As you are one of the maintainers, would you be
taking this patch?

Regards,

K. Y 

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

* RE: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
@ 2011-09-02 13:30     ` KY Srinivasan
  0 siblings, 0 replies; 15+ messages in thread
From: KY Srinivasan @ 2011-09-02 13:30 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: x86, Haiyang Zhang, gregkh, linux-kernel, virtualization, andi,
	devel, akpm



> -----Original Message-----
> From: Thomas Gleixner [mailto:tglx@linutronix.de]
> Sent: Friday, September 02, 2011 4:14 AM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; andi@firstfloor.org;
> akpm@linux-foundation.org; x86@kernel.org; Haiyang Zhang
> Subject: Re: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-
> V detection code
> 
> On Tue, 2 Aug 2011, K. Y. Srinivasan wrote:
> 
> > The Hyper-V timesource driver is best integrated with Hyper-V detection code
> > since: (a) Linux guests running on Hyper-V need this timesource and (b)
> > by integrating with Hyper-V detection, we could significantly  minimize the
> > code in the timesource driver.
> >
> > Andrew, could you take this patch for the -mm tree. I have sent this patch
> > out multiple times and I have not recived any response or comments.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> 
> Acked-by: Thomas Gleixner <tglx@linutronix.de>

Thanks Thomas. As you are one of the maintainers, would you be
taking this patch?

Regards,

K. Y 

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

* Re: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
  2011-08-02 16:03 K. Y. Srinivasan
@ 2011-09-02  8:13 ` Thomas Gleixner
  2011-09-02 13:30     ` KY Srinivasan
  0 siblings, 1 reply; 15+ messages in thread
From: Thomas Gleixner @ 2011-09-02  8:13 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, andi, akpm, x86,
	Haiyang Zhang

On Tue, 2 Aug 2011, K. Y. Srinivasan wrote:

> The Hyper-V timesource driver is best integrated with Hyper-V detection code
> since: (a) Linux guests running on Hyper-V need this timesource and (b)
> by integrating with Hyper-V detection, we could significantly  minimize the
> code in the timesource driver.
> 
> Andrew, could you take this patch for the -mm tree. I have sent this patch
> out multiple times and I have not recived any response or comments.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>

Acked-by: Thomas Gleixner <tglx@linutronix.de>

> ---
>  arch/x86/kernel/cpu/mshyperv.c     |   24 ++++++++
>  drivers/staging/hv/Makefile        |    2 +-
>  drivers/staging/hv/hv_timesource.c |  102 ------------------------------------
>  3 files changed, 25 insertions(+), 103 deletions(-)
>  delete mode 100644 drivers/staging/hv/hv_timesource.c
> 
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index d944bf6..c97f88d 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -11,6 +11,8 @@
>   */
>  
>  #include <linux/types.h>
> +#include <linux/time.h>
> +#include <linux/clocksource.h>
>  #include <linux/module.h>
>  #include <asm/processor.h>
>  #include <asm/hypervisor.h>
> @@ -36,6 +38,25 @@ static bool __init ms_hyperv_platform(void)
>  		!memcmp("Microsoft Hv", hyp_signature, 12);
>  }
>  
> +static cycle_t read_hv_clock(struct clocksource *arg)
> +{
> +	cycle_t current_tick;
> +	/*
> +	 * Read the partition counter to get the current tick count. This count
> +	 * is set to 0 when the partition is created and is incremented in
> +	 * 100 nanosecond units.
> +	 */
> +	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> +	return current_tick;
> +}
> +
> +static struct clocksource hyperv_cs = {
> +	.name           = "hyperv_clocksource",
> +	.rating         = 400, /* use this when running on Hyperv*/
> +	.read           = read_hv_clock,
> +	.mask           = CLOCKSOURCE_MASK(64),
> +};
> +
>  static void __init ms_hyperv_init_platform(void)
>  {
>  	/*
> @@ -46,6 +67,9 @@ static void __init ms_hyperv_init_platform(void)
>  
>  	printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
>  	       ms_hyperv.features, ms_hyperv.hints);
> +
> +
> +	clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
>  }
>  
>  const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
> diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
> index bd176b1..3e0d7e6 100644
> --- a/drivers/staging/hv/Makefile
> +++ b/drivers/staging/hv/Makefile
> @@ -1,4 +1,4 @@
> -obj-$(CONFIG_HYPERV)		+= hv_vmbus.o hv_timesource.o
> +obj-$(CONFIG_HYPERV)		+= hv_vmbus.o
>  obj-$(CONFIG_HYPERV_STORAGE)	+= hv_storvsc.o
>  obj-$(CONFIG_HYPERV_NET)	+= hv_netvsc.o
>  obj-$(CONFIG_HYPERV_UTILS)	+= hv_utils.o
> diff --git a/drivers/staging/hv/hv_timesource.c b/drivers/staging/hv/hv_timesource.c
> deleted file mode 100644
> index 0efb049..0000000
> --- a/drivers/staging/hv/hv_timesource.c
> +++ /dev/null
> @@ -1,102 +0,0 @@
> -/*
> - * A clocksource for Linux running on HyperV.
> - *
> - *
> - * Copyright (C) 2010, Novell, Inc.
> - * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
> - * NON INFRINGEMENT.  See the GNU General Public License for more
> - * details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
> - *
> - */
> -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> -
> -#include <linux/version.h>
> -#include <linux/clocksource.h>
> -#include <linux/init.h>
> -#include <linux/module.h>
> -#include <linux/pci.h>
> -#include <linux/dmi.h>
> -#include <asm/hyperv.h>
> -#include <asm/mshyperv.h>
> -#include <asm/hypervisor.h>
> -
> -#define HV_CLOCK_SHIFT	22
> -
> -static cycle_t read_hv_clock(struct clocksource *arg)
> -{
> -	cycle_t current_tick;
> -	/*
> -	 * Read the partition counter to get the current tick count. This count
> -	 * is set to 0 when the partition is created and is incremented in
> -	 * 100 nanosecond units.
> -	 */
> -	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> -	return current_tick;
> -}
> -
> -static struct clocksource hyperv_cs = {
> -	.name           = "hyperv_clocksource",
> -	.rating         = 400, /* use this when running on Hyperv*/
> -	.read           = read_hv_clock,
> -	.mask           = CLOCKSOURCE_MASK(64),
> -	/*
> -	 * The time ref counter in HyperV is in 100ns units.
> -	 * The definition of mult is:
> -	 * mult/2^shift = ns/cyc = 100
> -	 * mult = (100 << shift)
> -	 */
> -	.mult           = (100 << HV_CLOCK_SHIFT),
> -	.shift          = HV_CLOCK_SHIFT,
> -};
> -
> -static const struct dmi_system_id __initconst
> -hv_timesource_dmi_table[] __maybe_unused  = {
> -	{
> -		.ident = "Hyper-V",
> -		.matches = {
> -			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
> -			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
> -			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
> -		},
> -	},
> -	{ },
> -};
> -MODULE_DEVICE_TABLE(dmi, hv_timesource_dmi_table);
> -
> -static const struct pci_device_id __initconst
> -hv_timesource_pci_table[] __maybe_unused = {
> -	{ PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
> -	{ 0 }
> -};
> -MODULE_DEVICE_TABLE(pci, hv_timesource_pci_table);
> -
> -
> -static int __init init_hv_clocksource(void)
> -{
> -	if ((x86_hyper != &x86_hyper_ms_hyperv) ||
> -		!(ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE))
> -		return -ENODEV;
> -
> -	if (!dmi_check_system(hv_timesource_dmi_table))
> -		return -ENODEV;
> -
> -	pr_info("Registering HyperV clock source\n");
> -	return clocksource_register(&hyperv_cs);
> -}
> -
> -module_init(init_hv_clocksource);
> -MODULE_DESCRIPTION("HyperV based clocksource");
> -MODULE_AUTHOR("K. Y. Srinivasan <ksrinivasan@novell.com>");
> -MODULE_LICENSE("GPL");
> -- 
> 1.7.4.1
> 
> 

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

* [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
@ 2011-08-02 16:03 K. Y. Srinivasan
  2011-09-02  8:13 ` Thomas Gleixner
  0 siblings, 1 reply; 15+ messages in thread
From: K. Y. Srinivasan @ 2011-08-02 16:03 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, andi, akpm, tglx, x86
  Cc: K. Y. Srinivasan, Haiyang Zhang

The Hyper-V timesource driver is best integrated with Hyper-V detection code
since: (a) Linux guests running on Hyper-V need this timesource and (b)
by integrating with Hyper-V detection, we could significantly  minimize the
code in the timesource driver.

Andrew, could you take this patch for the -mm tree. I have sent this patch
out multiple times and I have not recived any response or comments.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 arch/x86/kernel/cpu/mshyperv.c     |   24 ++++++++
 drivers/staging/hv/Makefile        |    2 +-
 drivers/staging/hv/hv_timesource.c |  102 ------------------------------------
 3 files changed, 25 insertions(+), 103 deletions(-)
 delete mode 100644 drivers/staging/hv/hv_timesource.c

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index d944bf6..c97f88d 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -11,6 +11,8 @@
  */
 
 #include <linux/types.h>
+#include <linux/time.h>
+#include <linux/clocksource.h>
 #include <linux/module.h>
 #include <asm/processor.h>
 #include <asm/hypervisor.h>
@@ -36,6 +38,25 @@ static bool __init ms_hyperv_platform(void)
 		!memcmp("Microsoft Hv", hyp_signature, 12);
 }
 
+static cycle_t read_hv_clock(struct clocksource *arg)
+{
+	cycle_t current_tick;
+	/*
+	 * Read the partition counter to get the current tick count. This count
+	 * is set to 0 when the partition is created and is incremented in
+	 * 100 nanosecond units.
+	 */
+	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
+	return current_tick;
+}
+
+static struct clocksource hyperv_cs = {
+	.name           = "hyperv_clocksource",
+	.rating         = 400, /* use this when running on Hyperv*/
+	.read           = read_hv_clock,
+	.mask           = CLOCKSOURCE_MASK(64),
+};
+
 static void __init ms_hyperv_init_platform(void)
 {
 	/*
@@ -46,6 +67,9 @@ static void __init ms_hyperv_init_platform(void)
 
 	printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
 	       ms_hyperv.features, ms_hyperv.hints);
+
+
+	clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index bd176b1..3e0d7e6 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -1,4 +1,4 @@
-obj-$(CONFIG_HYPERV)		+= hv_vmbus.o hv_timesource.o
+obj-$(CONFIG_HYPERV)		+= hv_vmbus.o
 obj-$(CONFIG_HYPERV_STORAGE)	+= hv_storvsc.o
 obj-$(CONFIG_HYPERV_NET)	+= hv_netvsc.o
 obj-$(CONFIG_HYPERV_UTILS)	+= hv_utils.o
diff --git a/drivers/staging/hv/hv_timesource.c b/drivers/staging/hv/hv_timesource.c
deleted file mode 100644
index 0efb049..0000000
--- a/drivers/staging/hv/hv_timesource.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * A clocksource for Linux running on HyperV.
- *
- *
- * Copyright (C) 2010, Novell, Inc.
- * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/version.h>
-#include <linux/clocksource.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/dmi.h>
-#include <asm/hyperv.h>
-#include <asm/mshyperv.h>
-#include <asm/hypervisor.h>
-
-#define HV_CLOCK_SHIFT	22
-
-static cycle_t read_hv_clock(struct clocksource *arg)
-{
-	cycle_t current_tick;
-	/*
-	 * Read the partition counter to get the current tick count. This count
-	 * is set to 0 when the partition is created and is incremented in
-	 * 100 nanosecond units.
-	 */
-	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
-	return current_tick;
-}
-
-static struct clocksource hyperv_cs = {
-	.name           = "hyperv_clocksource",
-	.rating         = 400, /* use this when running on Hyperv*/
-	.read           = read_hv_clock,
-	.mask           = CLOCKSOURCE_MASK(64),
-	/*
-	 * The time ref counter in HyperV is in 100ns units.
-	 * The definition of mult is:
-	 * mult/2^shift = ns/cyc = 100
-	 * mult = (100 << shift)
-	 */
-	.mult           = (100 << HV_CLOCK_SHIFT),
-	.shift          = HV_CLOCK_SHIFT,
-};
-
-static const struct dmi_system_id __initconst
-hv_timesource_dmi_table[] __maybe_unused  = {
-	{
-		.ident = "Hyper-V",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-		},
-	},
-	{ },
-};
-MODULE_DEVICE_TABLE(dmi, hv_timesource_dmi_table);
-
-static const struct pci_device_id __initconst
-hv_timesource_pci_table[] __maybe_unused = {
-	{ PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, hv_timesource_pci_table);
-
-
-static int __init init_hv_clocksource(void)
-{
-	if ((x86_hyper != &x86_hyper_ms_hyperv) ||
-		!(ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE))
-		return -ENODEV;
-
-	if (!dmi_check_system(hv_timesource_dmi_table))
-		return -ENODEV;
-
-	pr_info("Registering HyperV clock source\n");
-	return clocksource_register(&hyperv_cs);
-}
-
-module_init(init_hv_clocksource);
-MODULE_DESCRIPTION("HyperV based clocksource");
-MODULE_AUTHOR("K. Y. Srinivasan <ksrinivasan@novell.com>");
-MODULE_LICENSE("GPL");
-- 
1.7.4.1


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

* RE: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
  2011-07-16  1:01 K. Y. Srinivasan
  2011-07-18 14:53 ` KY Srinivasan
@ 2011-07-18 14:53 ` KY Srinivasan
  1 sibling, 0 replies; 15+ messages in thread
From: KY Srinivasan @ 2011-07-18 14:53 UTC (permalink / raw)
  To: KY Srinivasan, gregkh, linux-kernel, devel, virtualization, tglx
  Cc: Haiyang Zhang



> -----Original Message-----
> From: K. Y. Srinivasan [mailto:kys@microsoft.com]
> Sent: Friday, July 15, 2011 9:01 PM
> To: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; tglx@linutronix.de
> Cc: KY Srinivasan; Haiyang Zhang
> Subject: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V
> detection code
> 
> The Hyper-V timesource driver is best integrated with Hyper-V detection code
> since: (a) Linux guests running on Hyper-V need this timesource and (b)
> by integrating with Hyper-V detection, we could significantly  minimize the
> code in the timesource driver.

Thomas,

A number of weeks ago you had reviewed the time Hyper-V time source driver code
and recommended that I merge it with Hyper-V detection code. That is exactly what I 
have done here. Is this what you had in mind; your feedback would be greatly appreciated.
I had sent this patch a couple of weeks ago and got no response. As an X86 maintainer,
would you be willing to take this patch.


Regards,

K. Y

> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  arch/x86/kernel/cpu/mshyperv.c     |   24 ++++++++
>  drivers/staging/hv/Makefile        |    2 +-
>  drivers/staging/hv/hv_timesource.c |  102 ------------------------------------
>  3 files changed, 25 insertions(+), 103 deletions(-)
>  delete mode 100644 drivers/staging/hv/hv_timesource.c
> 
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index d944bf6..c97f88d 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -11,6 +11,8 @@
>   */
> 
>  #include <linux/types.h>
> +#include <linux/time.h>
> +#include <linux/clocksource.h>
>  #include <linux/module.h>
>  #include <asm/processor.h>
>  #include <asm/hypervisor.h>
> @@ -36,6 +38,25 @@ static bool __init ms_hyperv_platform(void)
>  		!memcmp("Microsoft Hv", hyp_signature, 12);
>  }
> 
> +static cycle_t read_hv_clock(struct clocksource *arg)
> +{
> +	cycle_t current_tick;
> +	/*
> +	 * Read the partition counter to get the current tick count. This count
> +	 * is set to 0 when the partition is created and is incremented in
> +	 * 100 nanosecond units.
> +	 */
> +	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> +	return current_tick;
> +}
> +
> +static struct clocksource hyperv_cs = {
> +	.name           = "hyperv_clocksource",
> +	.rating         = 400, /* use this when running on Hyperv*/
> +	.read           = read_hv_clock,
> +	.mask           = CLOCKSOURCE_MASK(64),
> +};
> +
>  static void __init ms_hyperv_init_platform(void)
>  {
>  	/*
> @@ -46,6 +67,9 @@ static void __init ms_hyperv_init_platform(void)
> 
>  	printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
>  	       ms_hyperv.features, ms_hyperv.hints);
> +
> +
> +	clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
>  }
> 
>  const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
> diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
> index bd176b1..3e0d7e6 100644
> --- a/drivers/staging/hv/Makefile
> +++ b/drivers/staging/hv/Makefile
> @@ -1,4 +1,4 @@
> -obj-$(CONFIG_HYPERV)		+= hv_vmbus.o hv_timesource.o
> +obj-$(CONFIG_HYPERV)		+= hv_vmbus.o
>  obj-$(CONFIG_HYPERV_STORAGE)	+= hv_storvsc.o
>  obj-$(CONFIG_HYPERV_NET)	+= hv_netvsc.o
>  obj-$(CONFIG_HYPERV_UTILS)	+= hv_utils.o
> diff --git a/drivers/staging/hv/hv_timesource.c
> b/drivers/staging/hv/hv_timesource.c
> deleted file mode 100644
> index 0efb049..0000000
> --- a/drivers/staging/hv/hv_timesource.c
> +++ /dev/null
> @@ -1,102 +0,0 @@
> -/*
> - * A clocksource for Linux running on HyperV.
> - *
> - *
> - * Copyright (C) 2010, Novell, Inc.
> - * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
> - * NON INFRINGEMENT.  See the GNU General Public License for more
> - * details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
> - *
> - */
> -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> -
> -#include <linux/version.h>
> -#include <linux/clocksource.h>
> -#include <linux/init.h>
> -#include <linux/module.h>
> -#include <linux/pci.h>
> -#include <linux/dmi.h>
> -#include <asm/hyperv.h>
> -#include <asm/mshyperv.h>
> -#include <asm/hypervisor.h>
> -
> -#define HV_CLOCK_SHIFT	22
> -
> -static cycle_t read_hv_clock(struct clocksource *arg)
> -{
> -	cycle_t current_tick;
> -	/*
> -	 * Read the partition counter to get the current tick count. This count
> -	 * is set to 0 when the partition is created and is incremented in
> -	 * 100 nanosecond units.
> -	 */
> -	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> -	return current_tick;
> -}
> -
> -static struct clocksource hyperv_cs = {
> -	.name           = "hyperv_clocksource",
> -	.rating         = 400, /* use this when running on Hyperv*/
> -	.read           = read_hv_clock,
> -	.mask           = CLOCKSOURCE_MASK(64),
> -	/*
> -	 * The time ref counter in HyperV is in 100ns units.
> -	 * The definition of mult is:
> -	 * mult/2^shift = ns/cyc = 100
> -	 * mult = (100 << shift)
> -	 */
> -	.mult           = (100 << HV_CLOCK_SHIFT),
> -	.shift          = HV_CLOCK_SHIFT,
> -};
> -
> -static const struct dmi_system_id __initconst
> -hv_timesource_dmi_table[] __maybe_unused  = {
> -	{
> -		.ident = "Hyper-V",
> -		.matches = {
> -			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft
> Corporation"),
> -			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
> -			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
> -		},
> -	},
> -	{ },
> -};
> -MODULE_DEVICE_TABLE(dmi, hv_timesource_dmi_table);
> -
> -static const struct pci_device_id __initconst
> -hv_timesource_pci_table[] __maybe_unused = {
> -	{ PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
> -	{ 0 }
> -};
> -MODULE_DEVICE_TABLE(pci, hv_timesource_pci_table);
> -
> -
> -static int __init init_hv_clocksource(void)
> -{
> -	if ((x86_hyper != &x86_hyper_ms_hyperv) ||
> -		!(ms_hyperv.features &
> HV_X64_MSR_TIME_REF_COUNT_AVAILABLE))
> -		return -ENODEV;
> -
> -	if (!dmi_check_system(hv_timesource_dmi_table))
> -		return -ENODEV;
> -
> -	pr_info("Registering HyperV clock source\n");
> -	return clocksource_register(&hyperv_cs);
> -}
> -
> -module_init(init_hv_clocksource);
> -MODULE_DESCRIPTION("HyperV based clocksource");
> -MODULE_AUTHOR("K. Y. Srinivasan <ksrinivasan@novell.com>");
> -MODULE_LICENSE("GPL");
> --
> 1.7.4.1
> 


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

* RE: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
  2011-07-16  1:01 K. Y. Srinivasan
@ 2011-07-18 14:53 ` KY Srinivasan
  2011-07-18 14:53 ` KY Srinivasan
  1 sibling, 0 replies; 15+ messages in thread
From: KY Srinivasan @ 2011-07-18 14:53 UTC (permalink / raw)
  To: KY Srinivasan, gregkh, linux-kernel, devel@linuxdriverproject.org
  Cc: Haiyang Zhang



> -----Original Message-----
> From: K. Y. Srinivasan [mailto:kys@microsoft.com]
> Sent: Friday, July 15, 2011 9:01 PM
> To: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; tglx@linutronix.de
> Cc: KY Srinivasan; Haiyang Zhang
> Subject: [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V
> detection code
> 
> The Hyper-V timesource driver is best integrated with Hyper-V detection code
> since: (a) Linux guests running on Hyper-V need this timesource and (b)
> by integrating with Hyper-V detection, we could significantly  minimize the
> code in the timesource driver.

Thomas,

A number of weeks ago you had reviewed the time Hyper-V time source driver code
and recommended that I merge it with Hyper-V detection code. That is exactly what I 
have done here. Is this what you had in mind; your feedback would be greatly appreciated.
I had sent this patch a couple of weeks ago and got no response. As an X86 maintainer,
would you be willing to take this patch.


Regards,

K. Y

> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  arch/x86/kernel/cpu/mshyperv.c     |   24 ++++++++
>  drivers/staging/hv/Makefile        |    2 +-
>  drivers/staging/hv/hv_timesource.c |  102 ------------------------------------
>  3 files changed, 25 insertions(+), 103 deletions(-)
>  delete mode 100644 drivers/staging/hv/hv_timesource.c
> 
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index d944bf6..c97f88d 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -11,6 +11,8 @@
>   */
> 
>  #include <linux/types.h>
> +#include <linux/time.h>
> +#include <linux/clocksource.h>
>  #include <linux/module.h>
>  #include <asm/processor.h>
>  #include <asm/hypervisor.h>
> @@ -36,6 +38,25 @@ static bool __init ms_hyperv_platform(void)
>  		!memcmp("Microsoft Hv", hyp_signature, 12);
>  }
> 
> +static cycle_t read_hv_clock(struct clocksource *arg)
> +{
> +	cycle_t current_tick;
> +	/*
> +	 * Read the partition counter to get the current tick count. This count
> +	 * is set to 0 when the partition is created and is incremented in
> +	 * 100 nanosecond units.
> +	 */
> +	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> +	return current_tick;
> +}
> +
> +static struct clocksource hyperv_cs = {
> +	.name           = "hyperv_clocksource",
> +	.rating         = 400, /* use this when running on Hyperv*/
> +	.read           = read_hv_clock,
> +	.mask           = CLOCKSOURCE_MASK(64),
> +};
> +
>  static void __init ms_hyperv_init_platform(void)
>  {
>  	/*
> @@ -46,6 +67,9 @@ static void __init ms_hyperv_init_platform(void)
> 
>  	printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
>  	       ms_hyperv.features, ms_hyperv.hints);
> +
> +
> +	clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
>  }
> 
>  const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
> diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
> index bd176b1..3e0d7e6 100644
> --- a/drivers/staging/hv/Makefile
> +++ b/drivers/staging/hv/Makefile
> @@ -1,4 +1,4 @@
> -obj-$(CONFIG_HYPERV)		+= hv_vmbus.o hv_timesource.o
> +obj-$(CONFIG_HYPERV)		+= hv_vmbus.o
>  obj-$(CONFIG_HYPERV_STORAGE)	+= hv_storvsc.o
>  obj-$(CONFIG_HYPERV_NET)	+= hv_netvsc.o
>  obj-$(CONFIG_HYPERV_UTILS)	+= hv_utils.o
> diff --git a/drivers/staging/hv/hv_timesource.c
> b/drivers/staging/hv/hv_timesource.c
> deleted file mode 100644
> index 0efb049..0000000
> --- a/drivers/staging/hv/hv_timesource.c
> +++ /dev/null
> @@ -1,102 +0,0 @@
> -/*
> - * A clocksource for Linux running on HyperV.
> - *
> - *
> - * Copyright (C) 2010, Novell, Inc.
> - * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
> - * NON INFRINGEMENT.  See the GNU General Public License for more
> - * details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
> - *
> - */
> -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> -
> -#include <linux/version.h>
> -#include <linux/clocksource.h>
> -#include <linux/init.h>
> -#include <linux/module.h>
> -#include <linux/pci.h>
> -#include <linux/dmi.h>
> -#include <asm/hyperv.h>
> -#include <asm/mshyperv.h>
> -#include <asm/hypervisor.h>
> -
> -#define HV_CLOCK_SHIFT	22
> -
> -static cycle_t read_hv_clock(struct clocksource *arg)
> -{
> -	cycle_t current_tick;
> -	/*
> -	 * Read the partition counter to get the current tick count. This count
> -	 * is set to 0 when the partition is created and is incremented in
> -	 * 100 nanosecond units.
> -	 */
> -	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> -	return current_tick;
> -}
> -
> -static struct clocksource hyperv_cs = {
> -	.name           = "hyperv_clocksource",
> -	.rating         = 400, /* use this when running on Hyperv*/
> -	.read           = read_hv_clock,
> -	.mask           = CLOCKSOURCE_MASK(64),
> -	/*
> -	 * The time ref counter in HyperV is in 100ns units.
> -	 * The definition of mult is:
> -	 * mult/2^shift = ns/cyc = 100
> -	 * mult = (100 << shift)
> -	 */
> -	.mult           = (100 << HV_CLOCK_SHIFT),
> -	.shift          = HV_CLOCK_SHIFT,
> -};
> -
> -static const struct dmi_system_id __initconst
> -hv_timesource_dmi_table[] __maybe_unused  = {
> -	{
> -		.ident = "Hyper-V",
> -		.matches = {
> -			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft
> Corporation"),
> -			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
> -			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
> -		},
> -	},
> -	{ },
> -};
> -MODULE_DEVICE_TABLE(dmi, hv_timesource_dmi_table);
> -
> -static const struct pci_device_id __initconst
> -hv_timesource_pci_table[] __maybe_unused = {
> -	{ PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
> -	{ 0 }
> -};
> -MODULE_DEVICE_TABLE(pci, hv_timesource_pci_table);
> -
> -
> -static int __init init_hv_clocksource(void)
> -{
> -	if ((x86_hyper != &x86_hyper_ms_hyperv) ||
> -		!(ms_hyperv.features &
> HV_X64_MSR_TIME_REF_COUNT_AVAILABLE))
> -		return -ENODEV;
> -
> -	if (!dmi_check_system(hv_timesource_dmi_table))
> -		return -ENODEV;
> -
> -	pr_info("Registering HyperV clock source\n");
> -	return clocksource_register(&hyperv_cs);
> -}
> -
> -module_init(init_hv_clocksource);
> -MODULE_DESCRIPTION("HyperV based clocksource");
> -MODULE_AUTHOR("K. Y. Srinivasan <ksrinivasan@novell.com>");
> -MODULE_LICENSE("GPL");
> --
> 1.7.4.1
> 

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

* [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
@ 2011-07-16  1:01 K. Y. Srinivasan
  2011-07-18 14:53 ` KY Srinivasan
  2011-07-18 14:53 ` KY Srinivasan
  0 siblings, 2 replies; 15+ messages in thread
From: K. Y. Srinivasan @ 2011-07-16  1:01 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, tglx
  Cc: K. Y. Srinivasan, Haiyang Zhang

The Hyper-V timesource driver is best integrated with Hyper-V detection code
since: (a) Linux guests running on Hyper-V need this timesource and (b)
by integrating with Hyper-V detection, we could significantly  minimize the
code in the timesource driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 arch/x86/kernel/cpu/mshyperv.c     |   24 ++++++++
 drivers/staging/hv/Makefile        |    2 +-
 drivers/staging/hv/hv_timesource.c |  102 ------------------------------------
 3 files changed, 25 insertions(+), 103 deletions(-)
 delete mode 100644 drivers/staging/hv/hv_timesource.c

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index d944bf6..c97f88d 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -11,6 +11,8 @@
  */
 
 #include <linux/types.h>
+#include <linux/time.h>
+#include <linux/clocksource.h>
 #include <linux/module.h>
 #include <asm/processor.h>
 #include <asm/hypervisor.h>
@@ -36,6 +38,25 @@ static bool __init ms_hyperv_platform(void)
 		!memcmp("Microsoft Hv", hyp_signature, 12);
 }
 
+static cycle_t read_hv_clock(struct clocksource *arg)
+{
+	cycle_t current_tick;
+	/*
+	 * Read the partition counter to get the current tick count. This count
+	 * is set to 0 when the partition is created and is incremented in
+	 * 100 nanosecond units.
+	 */
+	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
+	return current_tick;
+}
+
+static struct clocksource hyperv_cs = {
+	.name           = "hyperv_clocksource",
+	.rating         = 400, /* use this when running on Hyperv*/
+	.read           = read_hv_clock,
+	.mask           = CLOCKSOURCE_MASK(64),
+};
+
 static void __init ms_hyperv_init_platform(void)
 {
 	/*
@@ -46,6 +67,9 @@ static void __init ms_hyperv_init_platform(void)
 
 	printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
 	       ms_hyperv.features, ms_hyperv.hints);
+
+
+	clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index bd176b1..3e0d7e6 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -1,4 +1,4 @@
-obj-$(CONFIG_HYPERV)		+= hv_vmbus.o hv_timesource.o
+obj-$(CONFIG_HYPERV)		+= hv_vmbus.o
 obj-$(CONFIG_HYPERV_STORAGE)	+= hv_storvsc.o
 obj-$(CONFIG_HYPERV_NET)	+= hv_netvsc.o
 obj-$(CONFIG_HYPERV_UTILS)	+= hv_utils.o
diff --git a/drivers/staging/hv/hv_timesource.c b/drivers/staging/hv/hv_timesource.c
deleted file mode 100644
index 0efb049..0000000
--- a/drivers/staging/hv/hv_timesource.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * A clocksource for Linux running on HyperV.
- *
- *
- * Copyright (C) 2010, Novell, Inc.
- * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/version.h>
-#include <linux/clocksource.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/dmi.h>
-#include <asm/hyperv.h>
-#include <asm/mshyperv.h>
-#include <asm/hypervisor.h>
-
-#define HV_CLOCK_SHIFT	22
-
-static cycle_t read_hv_clock(struct clocksource *arg)
-{
-	cycle_t current_tick;
-	/*
-	 * Read the partition counter to get the current tick count. This count
-	 * is set to 0 when the partition is created and is incremented in
-	 * 100 nanosecond units.
-	 */
-	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
-	return current_tick;
-}
-
-static struct clocksource hyperv_cs = {
-	.name           = "hyperv_clocksource",
-	.rating         = 400, /* use this when running on Hyperv*/
-	.read           = read_hv_clock,
-	.mask           = CLOCKSOURCE_MASK(64),
-	/*
-	 * The time ref counter in HyperV is in 100ns units.
-	 * The definition of mult is:
-	 * mult/2^shift = ns/cyc = 100
-	 * mult = (100 << shift)
-	 */
-	.mult           = (100 << HV_CLOCK_SHIFT),
-	.shift          = HV_CLOCK_SHIFT,
-};
-
-static const struct dmi_system_id __initconst
-hv_timesource_dmi_table[] __maybe_unused  = {
-	{
-		.ident = "Hyper-V",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-		},
-	},
-	{ },
-};
-MODULE_DEVICE_TABLE(dmi, hv_timesource_dmi_table);
-
-static const struct pci_device_id __initconst
-hv_timesource_pci_table[] __maybe_unused = {
-	{ PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, hv_timesource_pci_table);
-
-
-static int __init init_hv_clocksource(void)
-{
-	if ((x86_hyper != &x86_hyper_ms_hyperv) ||
-		!(ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE))
-		return -ENODEV;
-
-	if (!dmi_check_system(hv_timesource_dmi_table))
-		return -ENODEV;
-
-	pr_info("Registering HyperV clock source\n");
-	return clocksource_register(&hyperv_cs);
-}
-
-module_init(init_hv_clocksource);
-MODULE_DESCRIPTION("HyperV based clocksource");
-MODULE_AUTHOR("K. Y. Srinivasan <ksrinivasan@novell.com>");
-MODULE_LICENSE("GPL");
-- 
1.7.4.1


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

* [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code
@ 2011-06-30  0:58 K. Y. Srinivasan
  0 siblings, 0 replies; 15+ messages in thread
From: K. Y. Srinivasan @ 2011-06-30  0:58 UTC (permalink / raw)
  To: gregkh, linux-kernel, tglx, mingo, hpa, x86
  Cc: K. Y. Srinivasan, Haiyang Zhang

The Hyper-V timesource driver is best integrated with Hyper-V detection code
since: (a) Linux guests running on Hyper-V need this timesource and (b)
by integrating with Hyper-V detection, we could significantly  minimize the
code in the timesource driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 arch/x86/kernel/cpu/mshyperv.c     |   24 ++++++++
 drivers/staging/hv/Makefile        |    2 +-
 drivers/staging/hv/hv_timesource.c |  102 ------------------------------------
 3 files changed, 25 insertions(+), 103 deletions(-)
 delete mode 100644 drivers/staging/hv/hv_timesource.c

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index d944bf6..c97f88d 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -11,6 +11,8 @@
  */
 
 #include <linux/types.h>
+#include <linux/time.h>
+#include <linux/clocksource.h>
 #include <linux/module.h>
 #include <asm/processor.h>
 #include <asm/hypervisor.h>
@@ -36,6 +38,25 @@ static bool __init ms_hyperv_platform(void)
 		!memcmp("Microsoft Hv", hyp_signature, 12);
 }
 
+static cycle_t read_hv_clock(struct clocksource *arg)
+{
+	cycle_t current_tick;
+	/*
+	 * Read the partition counter to get the current tick count. This count
+	 * is set to 0 when the partition is created and is incremented in
+	 * 100 nanosecond units.
+	 */
+	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
+	return current_tick;
+}
+
+static struct clocksource hyperv_cs = {
+	.name           = "hyperv_clocksource",
+	.rating         = 400, /* use this when running on Hyperv*/
+	.read           = read_hv_clock,
+	.mask           = CLOCKSOURCE_MASK(64),
+};
+
 static void __init ms_hyperv_init_platform(void)
 {
 	/*
@@ -46,6 +67,9 @@ static void __init ms_hyperv_init_platform(void)
 
 	printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
 	       ms_hyperv.features, ms_hyperv.hints);
+
+
+	clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index bd176b1..3e0d7e6 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -1,4 +1,4 @@
-obj-$(CONFIG_HYPERV)		+= hv_vmbus.o hv_timesource.o
+obj-$(CONFIG_HYPERV)		+= hv_vmbus.o
 obj-$(CONFIG_HYPERV_STORAGE)	+= hv_storvsc.o
 obj-$(CONFIG_HYPERV_NET)	+= hv_netvsc.o
 obj-$(CONFIG_HYPERV_UTILS)	+= hv_utils.o
diff --git a/drivers/staging/hv/hv_timesource.c b/drivers/staging/hv/hv_timesource.c
deleted file mode 100644
index 0efb049..0000000
--- a/drivers/staging/hv/hv_timesource.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * A clocksource for Linux running on HyperV.
- *
- *
- * Copyright (C) 2010, Novell, Inc.
- * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/version.h>
-#include <linux/clocksource.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/dmi.h>
-#include <asm/hyperv.h>
-#include <asm/mshyperv.h>
-#include <asm/hypervisor.h>
-
-#define HV_CLOCK_SHIFT	22
-
-static cycle_t read_hv_clock(struct clocksource *arg)
-{
-	cycle_t current_tick;
-	/*
-	 * Read the partition counter to get the current tick count. This count
-	 * is set to 0 when the partition is created and is incremented in
-	 * 100 nanosecond units.
-	 */
-	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
-	return current_tick;
-}
-
-static struct clocksource hyperv_cs = {
-	.name           = "hyperv_clocksource",
-	.rating         = 400, /* use this when running on Hyperv*/
-	.read           = read_hv_clock,
-	.mask           = CLOCKSOURCE_MASK(64),
-	/*
-	 * The time ref counter in HyperV is in 100ns units.
-	 * The definition of mult is:
-	 * mult/2^shift = ns/cyc = 100
-	 * mult = (100 << shift)
-	 */
-	.mult           = (100 << HV_CLOCK_SHIFT),
-	.shift          = HV_CLOCK_SHIFT,
-};
-
-static const struct dmi_system_id __initconst
-hv_timesource_dmi_table[] __maybe_unused  = {
-	{
-		.ident = "Hyper-V",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-		},
-	},
-	{ },
-};
-MODULE_DEVICE_TABLE(dmi, hv_timesource_dmi_table);
-
-static const struct pci_device_id __initconst
-hv_timesource_pci_table[] __maybe_unused = {
-	{ PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, hv_timesource_pci_table);
-
-
-static int __init init_hv_clocksource(void)
-{
-	if ((x86_hyper != &x86_hyper_ms_hyperv) ||
-		!(ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE))
-		return -ENODEV;
-
-	if (!dmi_check_system(hv_timesource_dmi_table))
-		return -ENODEV;
-
-	pr_info("Registering HyperV clock source\n");
-	return clocksource_register(&hyperv_cs);
-}
-
-module_init(init_hv_clocksource);
-MODULE_DESCRIPTION("HyperV based clocksource");
-MODULE_AUTHOR("K. Y. Srinivasan <ksrinivasan@novell.com>");
-MODULE_LICENSE("GPL");
-- 
1.7.4.1


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

end of thread, other threads:[~2011-09-09 20:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-29 19:06 [PATCH 1/1] Staging: hv: Integrate the time source driver with Hyper-V detection code K. Y. Srinivasan
2011-06-29 19:06 ` Greg KH
2011-06-29 19:06   ` Greg KH
2011-06-30  0:42   ` KY Srinivasan
2011-06-30  0:58 K. Y. Srinivasan
2011-07-16  1:01 K. Y. Srinivasan
2011-07-18 14:53 ` KY Srinivasan
2011-07-18 14:53 ` KY Srinivasan
2011-08-02 16:03 K. Y. Srinivasan
2011-09-02  8:13 ` Thomas Gleixner
2011-09-02 13:30   ` KY Srinivasan
2011-09-02 13:30     ` KY Srinivasan
2011-09-07 22:25 K. Y. Srinivasan
2011-09-09 20:32 ` Greg KH
2011-09-09 20:32   ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.