Skip to contentSkip to conversation

Microsoft Hyper-V drivers for Linux

PATCH In review Greg Kroah-Hartman 13 participants 84 messages Jul 17, 2009 – Jul 24, 2009 Page 2 of 2

Subsystems (2)
lore
Share & tools
lore
#29 lore raw

RE: [patch 27/54] Staging: hv: remove ULONG and LONG typedefs

In reply to Arnd Bergmann

Arnd,

Thanks for this and the other mails reviewing the code.

My TODO list keeps on getting bigger :). I will check into all of these and correct them.

Keep them coming!

Thanks!

Hank.

-----Original Message-----
From: Arnd Bergmann [mailto:[email protected]]
Sent: Monday, July 20, 2009 5:00 PM
To: [email protected]
Cc: Greg Kroah-Hartman; [email protected]; [email protected]; [email protected]; Greg KH; Sam Ramji; Haiyang Zhang; Hank Janssen; [email protected]
Subject: Re: [patch 27/54] Staging: hv: remove ULONG and LONG typedefs

Quoted 5 lines · Greg Kroah-Hartman

From: Greg Kroah-Hartman <[email protected]>

The ULONG and LONG typedefs are now removed from the Hyper-V driver code

This conversion is not equivalent:

drivers/staging/hv/include/osd.h typedef struct _DLIST_ENTRY { · line 105

Quoted 9 lines

//

drivers/staging/hv/include/osd.h +0 -8
-// unsigned types
-//
-typedef unsigned int         ULONG;
-
-//
-// signed types
-//
-typedef int                                  LONG;

- // redefine the world, because we can
- extern char *i;
- void abs(unsigned u);
- #define FALSE (2)

;-)

drivers/staging/hv/include/StorVscApi.h typedef struct _STORVSC_DRIVER_OBJECT { · line 123

Quoted 11 lines
drivers/staging/hv/include/StorVscApi.h +1 -1
@@ -117,7 +117,7 @@ typedef struct _STORVSC_DRIVER_OBJECT {
 } STORVSC_DRIVER_OBJECT;
 
 typedef struct _STORVSC_DEVICE_INFO {
-     ULONG   PortNumber;
+     unsigned long   PortNumber;
     unsigned char    PathId;
     unsigned char    TargetId;
 } STORVSC_DEVICE_INFO;

If this is an API (as the header file name suggests), you just changed it. Same for the other hunks in this patch.

        Arnd <><
author
#58 lore raw

Re: [patch 47/54] Staging: hv: make gVmbusConnection.ChannelLock a real spinlock

In reply to Arnd Bergmann
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · Greg Kroah-Hartman

I don't think we really want to be doing a irqsave for this code, but I left it alone to preserve the original codepath. It should be reviewed later.

Quoted 7 lines

This patch does not preserve the original code path if any of the callers has a different irq state from the others. When flags is shared, releasing the lock actually sets the irq state to whatever another thread was using when failing to acquire the lock while it was held.

The patch of course looks good, but the comment is misleading.

Good point, sorry for the misleading comment.

I'll let Hank work out the details as to if the irqsave mode is needed or not :)

thanks,

greg k-h

author
#30 lore raw

Re: [patch 27/54] Staging: hv: remove ULONG and LONG typedefs

In reply to Arnd Bergmann
Quoted 31 lines · Arnd Bergmann
Quoted 5 lines · Greg Kroah-Hartman

From: Greg Kroah-Hartman <[email protected]>

The ULONG and LONG typedefs are now removed from the Hyper-V driver code

This conversion is not equivalent:

drivers/staging/hv/include/osd.h typedef struct _DLIST_ENTRY { · line 105

Quoted 9 lines

//

drivers/staging/hv/include/osd.h +0 -8
-// unsigned types
-//
-typedef unsigned int		ULONG;
-
-//
-// signed types
-//
-typedef int					LONG;

- // redefine the world, because we can
- extern char *i;
- void abs(unsigned u);
- #define FALSE (2)

;-)

Quoted 5 lines
drivers/staging/hv/include/StorVscApi.h +0 -0
@@ -117,7 +117,7 @@ typedef struct _STORVSC_DRIVER_OBJECT {
 } STORVSC_DRIVER_OBJECT;
 
Quoted 9 lines

drivers/staging/hv/include/StorVscApi.h typedef struct _STORVSC_DRIVER_OBJECT { · line 123

Quoted 6 lines
drivers/staging/hv/include/StorVscApi.h +1 -1
 typedef struct _STORVSC_DEVICE_INFO {
-	ULONG	PortNumber;
+	unsigned long	PortNumber;
     unsigned char	PathId;
     unsigned char	TargetId;
 } STORVSC_DEVICE_INFO;

If this is an API (as the header file name suggests), you just changed it. Same for the other hunks in this patch.

Ah crap, you're right, that's all wrong, nice catch.

I'll go redo it to be "unsigned int", but for some reason, the code still seems to work properly :)

thanks,

greg k-h

author
#31 lore raw

Re: [patch 27/54] Staging: hv: remove ULONG and LONG typedefs

Quoted 42 lines · Greg KH
Quoted 31 lines · Arnd Bergmann
Quoted 5 lines · Greg Kroah-Hartman

From: Greg Kroah-Hartman <[email protected]>

The ULONG and LONG typedefs are now removed from the Hyper-V driver code

This conversion is not equivalent:

Review

Quoted 9 lines

//

(quoted diff) +0 -8
-// unsigned types
-//
-typedef unsigned int		ULONG;
-
-//
-// signed types
-//
-typedef int					LONG;

- // redefine the world, because we can
- extern char *i;
- void abs(unsigned u);
- #define FALSE (2)

;-)

Quoted 5 lines
drivers/staging/hv/include/StorVscApi.h +0 -0
@@ -117,7 +117,7 @@ typedef struct _STORVSC_DRIVER_OBJECT {
 } STORVSC_DRIVER_OBJECT;
 
Quoted 9 lines

drivers/staging/hv/include/StorVscApi.h typedef struct _STORVSC_DRIVER_OBJECT { · line 123

Quoted 6 lines
drivers/staging/hv/include/StorVscApi.h +1 -1
 typedef struct _STORVSC_DEVICE_INFO {
-	ULONG	PortNumber;
+	unsigned long	PortNumber;
     unsigned char	PathId;
     unsigned char	TargetId;
 } STORVSC_DEVICE_INFO;

If this is an API (as the header file name suggests), you just changed it. Same for the other hunks in this patch.

Quoted 4 lines

Ah crap, you're right, that's all wrong, nice catch.

I'll go redo it to be "unsigned int", but for some reason, the code still seems to work properly :)

Ok, here's the updated version. Thanks for the review.

Hank, a lot of these should probably be converted to "real" kernel types, like u32, or u64 if it's really needed. Especially if they are crossing the kernel/hypervisor boundry.

thanks,

greg k-h

-------------
From: Greg Kroah-Hartman <[email protected]>
Subject: Staging: hv: remove ULONG and LONG typedefs

From: Greg Kroah-Hartman <[email protected]>

The ULONG and LONG typedefs are now removed from the Hyper-V driver code.

Cc Hank Janssen <[email protected]>
Cc Haiyang Zhang <[email protected]>
---
 drivers/staging/hv/StorVsc.c            |    2 +-
 drivers/staging/hv/include/StorVscApi.h |    2 +-
 drivers/staging/hv/include/osd.h        |   10 ----------
 drivers/staging/hv/include/vstorage.h   |   12 ++++++------
 4 files changed, 8 insertions(+), 18 deletions(-)
drivers/staging/hv/StorVsc.c +1 -1
@@ -62,7 +62,7 @@ typedef struct _STORVSC_DEVICE{
 
 	//  Each unique Port/Path/Target represents 1 channel ie scsi controller. In reality, the pathid, targetid is always 0
 	// and the port is set by us
-	ULONG						PortNumber;
+	unsigned int						PortNumber;
     unsigned char						PathId;
     unsigned char						TargetId;
 
drivers/staging/hv/include/StorVscApi.h +1 -1
@@ -117,7 +117,7 @@ typedef struct _STORVSC_DRIVER_OBJECT {
 } STORVSC_DRIVER_OBJECT;
 
 typedef struct _STORVSC_DEVICE_INFO {
-	ULONG	PortNumber;
+	unsigned int	PortNumber;
     unsigned char	PathId;
     unsigned char	TargetId;
 } STORVSC_DEVICE_INFO;
drivers/staging/hv/include/osd.h +0 -10
@@ -95,16 +95,6 @@ typedef struct _DLIST_ENTRY {
 } DLIST_ENTRY;
 
 //
-// unsigned types
-//
-typedef unsigned int		ULONG;
-
-//
-// signed types
-//
-typedef int					LONG;
-
-//
 // Other types
 //
 typedef unsigned long		SIZE_T;
drivers/staging/hv/include/vstorage.h +6 -6
@@ -155,7 +155,7 @@ typedef struct
     unsigned char DataIn;
     unsigned char Reserved;
 
-    ULONG DataTransferLength;
+    unsigned int DataTransferLength;
 
     union
     {
@@ -185,11 +185,11 @@ typedef struct
     //
     // Note: port number is only really known on the client side
     //
-    ULONG  PortNumber;
+    unsigned int  PortNumber;
 
-    ULONG  Flags;
+    unsigned int  Flags;
 
-    ULONG  MaxTransferBytes;
+    unsigned int  MaxTransferBytes;
 
     //
     //  This id is unique for each channel and will correspond with
@@ -249,13 +249,13 @@ typedef struct _VSTOR_PACKET
     //  Flags - see below for values
     //
 
-    ULONG     Flags;
+    unsigned int     Flags;
 
     //
     // Status of the request returned from the server side.
     //
 
-    ULONG     Status;
+    unsigned int     Status;
 
     //
     // Data payload area
#32 lore raw

Re: [patch 27/54] Staging: hv: remove ULONG and LONG typedefs

In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann
Quoted 4 lines · Greg Kroah-Hartman

From: Greg Kroah-Hartman <[email protected]>

The ULONG and LONG typedefs are now removed from the Hyper-V driver code

This conversion is not equivalent:

[...]

Quoted 1 line

- // redefine the world, because we can

[...]

Quoted 1 line

- #define FALSE (2)

That has been done already by the SNMP folks - see
http://www.faqs.org/rfcs/rfc1903.html under "TruthValue". S,CNR and for off-topic ...

Quoted 1 line

;-)

;-) either ....

Bernd

Signature · 3 lines
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services
#80 lore raw
In reply to Greg Kroah-Hartman
Quoted 21 lines · Greg Kroah-Hartman

Hi all,

I'm happy to announce, that after many months of discussions, Microsoft has released their Hyper-V Linux drivers under the GPLv2. Following this message, will be the patches that add the drivers to the drivers/staging/ tree, and a whole bunch of cleanups.

It's taken a long road to get here, and I'd like to thank the following people who made this possible:
- Steve Hemminger for the initial prodding and extreme patience
- Hank Janssen for providing the code and working with me to get it into a workable and semi-mergable state. His involvement within Microsoft was also invaluable.
- Sam Ramji for his push within Microsoft to make this happen in a manner that works with the Linux community.
- Novell for sponsoring my work on the Linux Driver project, without which, this would not have even been possible.
And there are many others both within Novell and Microsoft, who I do not want to slight by not naming, but the list would be too long to go into.

Quoted 7 lines

These drivers are to enable Linux to work better when running as a guest on top of the Hyper-V system. There is still a lot of work to do in getting this into "proper" mergable state, and moving it out of the staging directory, but Hank and I will be undertaking this task. See the TODO file in the drivers/staging/hv/ directory if anyone wishes to help out with this task.

What is the long term strategy to keep the sources in sync? Is there one? Do you expect to get updates for these sources?

Signature · 1 line
	Balbir
#72 lore raw
In reply to Greg KH
Quoted 4 lines · Greg KH

Anyway, I agree, for a "proper" review, I will show the final, cleaned up version, like normal. But we aren't there just yet, that is why this code is going to live in the staging tree for a while. Give us some time to get it fixed up.

I would find it helpful to have them in a git tree (or a branch) that I can pull, so I can look at both the original code and the cleaned up state.

Any reason why the patches are not yet in your staging.git?

	Arnd <><
#73 lore raw
Quoted 9 lines · Arnd Bergmann
Quoted 4 lines · Greg KH

Anyway, I agree, for a "proper" review, I will show the final, cleaned up version, like normal.  But we aren't there just yet, that is why this code is going to live in the staging tree for a while.  Give us some time to get it fixed up.

I would find it helpful to have them in a git tree (or a branch) that I can pull, so I can look at both the original code and the cleaned up state.

You can find sources in linux-next tree in /drivers/staging/hv directory.
(git://git.kernel.org/pub/scm/linux/kernel/git/sfr/linux-next.git)

Quoted 9 lines

Any reason why the patches are not yet in your staging.git?

       Arnd <><
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Marek

#74 lore raw
In reply to Arnd Bergmann
Quoted 11 lines · Arnd Bergmann
Quoted 4 lines · Greg KH

Anyway, I agree, for a "proper" review, I will show the final, cleaned up version, like normal. But we aren't there just yet, that is why this code is going to live in the staging tree for a while. Give us some time to get it fixed up.

I would find it helpful to have them in a git tree (or a branch) that I can pull, so I can look at both the original code and the cleaned up state.

Any reason why the patches are not yet in your staging.git?

staging.git is for sending patches to Linus only. Look in the MAINTAINERS file for a location of my tree of patches for staging.

If you like git, I'd recommend just using the linux-next tree, as that always has the latest staging patches in it.

thanks,

greg k-h

#81 lore raw
In reply to Balbir Singh
Quoted 31 lines · Balbir Singh
Quoted 21 lines · Greg Kroah-Hartman

Hi all,

I'm happy to announce, that after many months of discussions, Microsoft has released their Hyper-V Linux drivers under the GPLv2. Following this message, will be the patches that add the drivers to the drivers/staging/ tree, and a whole bunch of cleanups.

It's taken a long road to get here, and I'd like to thank the following people who made this possible:
- Steve Hemminger for the initial prodding and extreme patience
- Hank Janssen for providing the code and working with me to get it into a workable and semi-mergable state. His involvement within Microsoft was also invaluable.
- Sam Ramji for his push within Microsoft to make this happen in a manner that works with the Linux community.
- Novell for sponsoring my work on the Linux Driver project, without which, this would not have even been possible.
And there are many others both within Novell and Microsoft, who I do not want to slight by not naming, but the list would be too long to go into.

Quoted 7 lines

These drivers are to enable Linux to work better when running as a guest on top of the Hyper-V system. There is still a lot of work to do in getting this into "proper" mergable state, and moving it out of the staging directory, but Hank and I will be undertaking this task. See the TODO file in the drivers/staging/hv/ directory if anyone wishes to help out with this task.

Quoted 2 lines

What is the long term strategy to keep the sources in sync? Is there one? Do you expect to get updates for these sources?

The in-kernel version will be the only source for the drivers in the long run. Eventually they will take the drivers off their web site when the distros pick them up in their new releases.

thanks,

greg k-h

#82 lore raw
In reply to Balbir Singh
Quoted 6 lines

What is the long term strategy to keep the sources in sync? Is there one? Do you expect to get updates for these sources?

Balbir

Balbir,

I think you are asking me if we plan to continue contributing?

It is my plan to use the kernel as my primary development area, and I will Continue to provide Greg with updates. First step is to clean up the code To make sure if fulfills all Kernel coding standards and requirements.

Then I will start contributing new functionality.

Thanks,

Hank.

#83 lore raw
Quoted 10 lines · Hank Janssen
Quoted 6 lines

What is the long term strategy to keep the sources in sync? Is there one? Do you expect to get updates for these sources?

Balbir

Balbir,

Quoted 8 lines

I think you are asking me if we plan to continue contributing?

It is my plan to use the kernel as my primary development area, and I will Continue to provide Greg with updates. First step is to clean up the code To make sure if fulfills all Kernel coding standards and requirements.

Then I will start contributing new functionality.

Good to know. Thanks for the clarification!

Signature · 1 line
	Balbir
#41 lore raw

Re: [patch 34/54] Staging: hv: remove STRUCT_PACKED and STRUCT_ALIGNED defines

In reply to Arnd Bergmann
Quoted 11 lines · Arnd Bergmann

drivers/staging/hv/RingBuffer.h typedef struct _RING_BUFFER { · line 47

Quoted 7 lines · Greg Kroah-Hartman
drivers/staging/hv/RingBuffer.h +1 -1
@@ -43,7 +43,7 @@ typedef struct _RING_BUFFER {
        // volatile u32 InterruptMask;
        // Ring data starts here + RingDataStartOffset !!! DO NOT place any fields below this !!!
     u8         Buffer[0];
-} STRUCT_PACKED RING_BUFFER;
+} __attribute__((packed)) RING_BUFFER;
 

The data structure is actually packed already, the attribute does not make it better and could be removed. We also have __packed as a shortcut for __attribute__((packed)).

Honestly, I don't know how useful __packed really is. In a shared kernel/userspace header, it is only defined for the kernel.

Jörn

Signature · 2 lines
Do not stop an army on its way home.
-- Sun Tzu
#42 lore raw

Re: [patch 34/54] Staging: hv: remove STRUCT_PACKED and STRUCT_ALIGNED defines

Quoted 13 lines · On Fri, 24 Jul 2009 23:32:19 +0200 Jörn Engel <[email protected]> wrote:
Quoted 11 lines · Arnd Bergmann

drivers/staging/hv/RingBuffer.h typedef struct _RING_BUFFER { · line 47

Quoted 7 lines · Greg Kroah-Hartman
drivers/staging/hv/RingBuffer.h +1 -1
@@ -43,7 +43,7 @@ typedef struct _RING_BUFFER {
        // volatile u32 InterruptMask;
        // Ring data starts here + RingDataStartOffset !!! DO NOT place any fields below this !!!
     u8         Buffer[0];
-} STRUCT_PACKED RING_BUFFER;
+} __attribute__((packed)) RING_BUFFER;
 

The data structure is actually packed already, the attribute does not make it better and could be removed. We also have __packed as a shortcut for __attribute__((packed)).

Quoted 3 lines

Honestly, I don't know how useful __packed really is. In a shared kernel/userspace header, it is only defined for the kernel.

As I remember, gcc generates worse code for packed structures on many architectures since it may have to do byte fetchs/recombining to avoid unaligned accesses.

#43 lore raw

Re: [patch 34/54] Staging: hv: remove STRUCT_PACKED and STRUCT_ALIGNED defines

Quoted 8 lines · Stephen Hemminger
Quoted 5 lines · On Fri, 24 Jul 2009 23:32:19 +0200 Jörn Engel <[email protected]> wrote:
Quoted 3 lines · Arnd Bergmann

The data structure is actually packed already, the attribute does not make it better and could be removed. We also have __packed as a shortcut for __attribute__((packed)).

Quoted 6 lines
Quoted 2 lines

Honestly, I don't know how useful __packed really is. In a shared kernel/userspace header, it is only defined for the kernel.

As I remember, gcc generates worse code for packed structures on many architectures since it may have to do byte fetchs/recombining to avoid unaligned accesses.

I was talking about "__packed" vs. "__attribute__((packed))". But yes, avoiding packed structures where possible is a good idea.

Jörn

Signature · 3 lines
"[One] doesn't need to know [...] how to cause a headache in order
to take an aspirin."
-- Scott Culp, Manager of the Microsoft Security Response Center, 2001