* Re: [PATCH 1/4] x86: remove cast from void*
From: H. Peter Anvin @ 2010-09-14 18:20 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: xen-devel, Jeremy Fitzhardinge, matt mooney, x86, kernel-janitors,
Chris Wright, virtualization, Ingo Molnar, Tejun Heo,
Thomas Gleixner, Ian Campbell
In-Reply-To: <4C8FB5C3.3050806@goop.org>
On 09/14/2010 10:49 AM, Jeremy Fitzhardinge wrote:
> On 09/13/2010 10:18 PM, matt mooney wrote:
>> Unnecessary cast from void* in assignment.
>
> Not very keen on this. The cast may not be strictly required, but it
> does document what's going on there.
>
But unnecessary casts are problematic in that if the type changes, they
can hide a real bug in the future.
-hpa
^ permalink raw reply
* Re: [PATCH 1/4] x86: remove cast from void*
From: Jeremy Fitzhardinge @ 2010-09-14 18:46 UTC (permalink / raw)
To: H. Peter Anvin
Cc: xen-devel, Jeremy Fitzhardinge, matt mooney, x86, kernel-janitors,
Chris Wright, virtualization, Ingo Molnar, Tejun Heo,
Thomas Gleixner, Ian Campbell
In-Reply-To: <4C8FBD01.40900@zytor.com>
On 09/14/2010 11:20 AM, H. Peter Anvin wrote:
> On 09/14/2010 10:49 AM, Jeremy Fitzhardinge wrote:
>> On 09/13/2010 10:18 PM, matt mooney wrote:
>>> Unnecessary cast from void* in assignment.
>> Not very keen on this. The cast may not be strictly required, but it
>> does document what's going on there.
>>
> But unnecessary casts are problematic in that if the type changes, they
> can hide a real bug in the future.
If page->private changes in a way which invalidates this kind of usage,
I would hope it would also change name to something more descriptive of
its new role. If it changes type but is broadly compatible with this
usage (say, void * -> unsigned long), then the cast won't matter, or
will become a requirement.
I'm more concerned about "user_ptr" changing type, in which case the
cast will highlight the problem.
In general, the casts from these kinds of generic/polymorphic fields let
you easily eyeball how they're being used, without having to work out
what the type of the other side is.
J
^ permalink raw reply
* Re: [PATCH 1/1] staging: hv: Convert vmbus driver interface function pointer table to constant
From: Greg KH @ 2010-09-14 23:26 UTC (permalink / raw)
To: Haiyang Zhang
Cc: Greg KH, 'devel@driverdev.osuosl.org',
'virtualization@lists.osdl.org',
'linux-kernel@vger.kernel.org'
In-Reply-To: <1FB5E1D5CA062146B38059374562DF72854C94CE@TK5EX14MBXC130.redmond.corp.microsoft.com>
On Thu, Sep 09, 2010 at 02:53:03PM +0000, Haiyang Zhang wrote:
> > From: Greg KH [mailto:gregkh@suse.de]
> > Sent: Wednesday, September 08, 2010 6:44 PM
> > > Convert vmbus driver interface function pointer table to constant
> > > The vmbus interface functions are assigned to a constant - vmbus_ops.
> >
> > You also remove a function pointer in this patch, why? Please break up
> > the patch into logical parts, one patch, one thing.
> >
> > This looks like it should be 2 patches, right?
>
> Because the vmbus interface function pointer table is converted to a
> constant variable -- vmbus_ops, the function GetChannelInterface(),
> VmbusGetChannelInterface() and pointer GetChannelInterface are no longer
> in use. The deprecated function's work is done by the initialization of
> the newly added constant variable vmbus_ops.
>
> I created the new constant variable vmbus_ops and removed the deprecated
> function pointer GetChannelInterface in one patch.
Great, next time say that in the patch please :)
I'll go edit the wording and apply this...
thanks,
greg k-h
^ permalink raw reply
* PATCH: virtio_console: Fix poll blocking even though there is data to read
From: Hans de Goede @ 2010-09-15 13:04 UTC (permalink / raw)
To: virtualization; +Cc: amit.shah, spice-devel, kvm
[-- Attachment #1: Type: text/plain, Size: 937 bytes --]
Hi All,
I found this while working on a Linux agent for spice, the symptom I was
seeing was select blocking on the spice vdagent virtio serial port even
though there were messages queued up there.
I found this while working on a Linux agent for spice, the symptom I was
seeing was select blocking on the spice vdagent virtio serial port even
though there were messages queued up there.
virtio_console's port_fops_poll checks port->inbuf != NULL to determine if
read won't block. However if an application reads enough bytes from inbuf
through port_fops_read, to empty the current port->inbuf, port->inbuf
will be NULL even though there may be buffers left in the virtqueue.
This causes poll() to block even though there is data to be read, this patch
fixes this by using the alredy defined will_read_block utility function
instead of the port->inbuf != NULL check.
Signed-off-By: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
[-- Attachment #2: linux-2.6.35.4-virtio_console-fix-poll.patch --]
[-- Type: text/plain, Size: 1380 bytes --]
Subject: virtio_console: Fix poll blocking even though there is data to read
From: Hans de Goede <hdegoede@redhat.com>
I found this while working on a Linux agent for spice, the symptom I was
seeing was select blocking on the spice vdagent virtio serial port even
though there were messages queued up there.
virtio_console's port_fops_poll checks port->inbuf != NULL to determine if
read won't block. However if an application reads enough bytes from inbuf
through port_fops_read, to empty the current port->inbuf, port->inbuf
will be NULL even though there may be buffers left in the virtqueue.
This causes poll() to block even though there is data to be read, this patch
fixes this by using the alredy defined will_read_block utility function
instead of the port->inbuf != NULL check.
Signed-off-By: Hans de Goede <hdegoede@redhat.com>
diff -up linux-2.6.35.x86_64/drivers/char/virtio_console.c~ linux-2.6.35.x86_64/drivers/char/virtio_console.c
--- linux-2.6.35.x86_64/drivers/char/virtio_console.c~ 2010-08-02 00:11:14.000000000 +0200
+++ linux-2.6.35.x86_64/drivers/char/virtio_console.c 2010-09-15 13:39:29.043505000 +0200
@@ -642,7 +642,7 @@ static unsigned int port_fops_poll(struc
poll_wait(filp, &port->waitqueue, wait);
ret = 0;
- if (port->inbuf)
+ if (!will_read_block(port))
ret |= POLLIN | POLLRDNORM;
if (!will_write_block(port))
ret |= POLLOUT;
[-- Attachment #3: Type: text/plain, Size: 184 bytes --]
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* Re: PATCH: virtio_console: Fix poll blocking even though there is data to read
From: Amit Shah @ 2010-09-15 13:25 UTC (permalink / raw)
To: Hans de Goede; +Cc: spice-devel, kvm, virtualization
In-Reply-To: <4C90C475.4010809@redhat.com>
On (Wed) Sep 15 2010 [15:04:53], Hans de Goede wrote:
> Hi All,
>
> I found this while working on a Linux agent for spice, the symptom I was
> seeing was select blocking on the spice vdagent virtio serial port even
> though there were messages queued up there.
>
> I found this while working on a Linux agent for spice, the symptom I was
> seeing was select blocking on the spice vdagent virtio serial port even
> though there were messages queued up there.
>
> virtio_console's port_fops_poll checks port->inbuf != NULL to determine if
> read won't block. However if an application reads enough bytes from inbuf
> through port_fops_read, to empty the current port->inbuf, port->inbuf
> will be NULL even though there may be buffers left in the virtqueue.
>
> This causes poll() to block even though there is data to be read, this patch
> fixes this by using the alredy defined will_read_block utility function
> instead of the port->inbuf != NULL check.
>
> Signed-off-By: Hans de Goede <hdegoede@redhat.com>
>
> Regards,
>
> Hans
> diff -up linux-2.6.35.x86_64/drivers/char/virtio_console.c~ linux-2.6.35.x86_64/drivers/char/virtio_console.c
> --- linux-2.6.35.x86_64/drivers/char/virtio_console.c~ 2010-08-02 00:11:14.000000000 +0200
> +++ linux-2.6.35.x86_64/drivers/char/virtio_console.c 2010-09-15 13:39:29.043505000 +0200
> @@ -642,7 +642,7 @@ static unsigned int port_fops_poll(struc
> poll_wait(filp, &port->waitqueue, wait);
>
> ret = 0;
> - if (port->inbuf)
> + if (!will_read_block(port))
Looks correct, but this should be
if (port_has_data(port))
instead.
will_read_block() also tests if the host is connected, which is not what
we want for POLLIN to be set.
Amit
^ permalink raw reply
* Re: PATCH: virtio_console: Fix poll blocking even though there is data to read
From: Hans de Goede @ 2010-09-15 13:37 UTC (permalink / raw)
To: Amit Shah; +Cc: spice-devel, kvm, virtualization
In-Reply-To: <20100915132536.GA12320@amit-laptop.redhat.com>
Hi,
On 09/15/2010 03:25 PM, Amit Shah wrote:
> On (Wed) Sep 15 2010 [15:04:53], Hans de Goede wrote:
>> Hi All,
>>
>> I found this while working on a Linux agent for spice, the symptom I was
>> seeing was select blocking on the spice vdagent virtio serial port even
>> though there were messages queued up there.
>>
>> I found this while working on a Linux agent for spice, the symptom I was
>> seeing was select blocking on the spice vdagent virtio serial port even
>> though there were messages queued up there.
>>
>> virtio_console's port_fops_poll checks port->inbuf != NULL to determine if
>> read won't block. However if an application reads enough bytes from inbuf
>> through port_fops_read, to empty the current port->inbuf, port->inbuf
>> will be NULL even though there may be buffers left in the virtqueue.
>>
>> This causes poll() to block even though there is data to be read, this patch
>> fixes this by using the alredy defined will_read_block utility function
>> instead of the port->inbuf != NULL check.
>>
>> Signed-off-By: Hans de Goede<hdegoede@redhat.com>
>>
>> Regards,
>>
>> Hans
>
>> diff -up linux-2.6.35.x86_64/drivers/char/virtio_console.c~ linux-2.6.35.x86_64/drivers/char/virtio_console.c
>> --- linux-2.6.35.x86_64/drivers/char/virtio_console.c~ 2010-08-02 00:11:14.000000000 +0200
>> +++ linux-2.6.35.x86_64/drivers/char/virtio_console.c 2010-09-15 13:39:29.043505000 +0200
>> @@ -642,7 +642,7 @@ static unsigned int port_fops_poll(struc
>> poll_wait(filp,&port->waitqueue, wait);
>>
>> ret = 0;
>> - if (port->inbuf)
>> + if (!will_read_block(port))
>
> Looks correct, but this should be
>
> if (port_has_data(port))
>
> instead.
That certainly works for me (as in will still fix the bug I'm hitting), but
quoting from "man 2 select":
Three independent sets of file descriptors are watched. Those listed
in readfds will be watched to see if characters become available for
reading (more precisely, to see if a read will not block; in particu‐
lar, a file descriptor is also ready on end-of-file)
Notice the "a file descriptor is also ready on end-of-file", and
port_fops_read treats the host not being connected as eof (it returns 0
in that case). So from an API pov I'm not sure what is correct.
Regards,
Hans
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* Re: PATCH: virtio_console: Fix poll blocking even though there is data to read
From: Amit Shah @ 2010-09-15 13:46 UTC (permalink / raw)
To: Hans de Goede; +Cc: spice-devel, kvm, virtualization
In-Reply-To: <4C90CC11.70202@redhat.com>
On (Wed) Sep 15 2010 [15:37:21], Hans de Goede wrote:
> >>--- linux-2.6.35.x86_64/drivers/char/virtio_console.c~ 2010-08-02 00:11:14.000000000 +0200
> >>+++ linux-2.6.35.x86_64/drivers/char/virtio_console.c 2010-09-15 13:39:29.043505000 +0200
> >>@@ -642,7 +642,7 @@ static unsigned int port_fops_poll(struc
> >> poll_wait(filp,&port->waitqueue, wait);
> >>
> >> ret = 0;
> >>- if (port->inbuf)
> >>+ if (!will_read_block(port))
> >
> >Looks correct, but this should be
> >
> > if (port_has_data(port))
> >
> >instead.
>
> That certainly works for me (as in will still fix the bug I'm hitting), but
> quoting from "man 2 select":
>
> Three independent sets of file descriptors are watched. Those listed
> in readfds will be watched to see if characters become available for
> reading (more precisely, to see if a read will not block; in particu‐
> lar, a file descriptor is also ready on end-of-file)
>
> Notice the "a file descriptor is also ready on end-of-file", and
> port_fops_read treats the host not being connected as eof (it returns 0
> in that case). So from an API pov I'm not sure what is correct.
poll(2) says:
POLLIN There is data to read.
That makes it simple.
Also, we also set POLLHUP in case the host is disconnected, so if host
is not connected while there's data to read, we'll get POLLIN|POLLHUP in
revents, and further reads will be blocked.
I'm willing to go with the poll manpage and use port_has_data().
Amit
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* Re: PATCH: virtio_console: Fix poll blocking even though there is data to read
From: Hans de Goede @ 2010-09-15 14:02 UTC (permalink / raw)
To: Amit Shah; +Cc: spice-devel, kvm, virtualization
In-Reply-To: <20100915134624.GB12320@amit-laptop.redhat.com>
Hi,
On 09/15/2010 03:46 PM, Amit Shah wrote:
> On (Wed) Sep 15 2010 [15:37:21], Hans de Goede wrote:
>>>> --- linux-2.6.35.x86_64/drivers/char/virtio_console.c~ 2010-08-02 00:11:14.000000000 +0200
>>>> +++ linux-2.6.35.x86_64/drivers/char/virtio_console.c 2010-09-15 13:39:29.043505000 +0200
>>>> @@ -642,7 +642,7 @@ static unsigned int port_fops_poll(struc
>>>> poll_wait(filp,&port->waitqueue, wait);
>>>>
>>>> ret = 0;
>>>> - if (port->inbuf)
>>>> + if (!will_read_block(port))
>>>
>>> Looks correct, but this should be
>>>
>>> if (port_has_data(port))
>>>
>>> instead.
>>
>> That certainly works for me (as in will still fix the bug I'm hitting), but
>> quoting from "man 2 select":
>>
>> Three independent sets of file descriptors are watched. Those listed
>> in readfds will be watched to see if characters become available for
>> reading (more precisely, to see if a read will not block; in particu‐
>> lar, a file descriptor is also ready on end-of-file)
>>
>> Notice the "a file descriptor is also ready on end-of-file", and
>> port_fops_read treats the host not being connected as eof (it returns 0
>> in that case). So from an API pov I'm not sure what is correct.
>
> poll(2) says:
>
> POLLIN There is data to read.
>
> That makes it simple.
>
> Also, we also set POLLHUP in case the host is disconnected, so if host
> is not connected while there's data to read, we'll get POLLIN|POLLHUP in
> revents, and further reads will be blocked.
>
Ah, I completely missed the POLLHUP getting set thingie. I guess that will
get used by the kernel to also not block if any fds have it said in select's
readfds argument.
One new patch coming up!
Regards,
Hans
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* PATCH: virtio_console: Fix poll blocking even though there is data to read (version 2)
From: Hans de Goede @ 2010-09-15 15:18 UTC (permalink / raw)
To: virtualization; +Cc: amit.shah, spice-devel, kvm
[-- Attachment #1: Type: text/plain, Size: 912 bytes --]
Hi All,
I found this while working on a Linux agent for spice, the symptom I was
seeing was select blocking on the spice vdagent virtio serial port even
though there were messages queued up there.
I found this while working on a Linux agent for spice, the symptom I was
seeing was select blocking on the spice vdagent virtio serial port even
though there were messages queued up there.
virtio_console's port_fops_poll checks port->inbuf != NULL to determine if
read won't block. However if an application reads enough bytes from inbuf
through port_fops_read, to empty the current port->inbuf, port->inbuf
will be NULL even though there may be buffers left in the virtqueue.
This causes poll() to block even though there is data ready to be read, this
patch fixes this by using port_has_data(port) instead of the
port->inbuf != NULL check.
Signed-off-By: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
[-- Attachment #2: linux-2.6.35.4-virtio_console-fix-poll.patch --]
[-- Type: text/plain, Size: 1363 bytes --]
Subject: virtio_console: Fix poll blocking even though there is data to read (version 2)
From: Hans de Goede <hdegoede@redhat.com>
I found this while working on a Linux agent for spice, the symptom I was
seeing was select blocking on the spice vdagent virtio serial port even
though there were messages queued up there.
virtio_console's port_fops_poll checks port->inbuf != NULL to determine if
read won't block. However if an application reads enough bytes from inbuf
through port_fops_read, to empty the current port->inbuf, port->inbuf
will be NULL even though there may be buffers left in the virtqueue.
This causes poll() to block even though there is data ready to be read, this
patch fixes this by using port_has_data(port) instead of the
port->inbuf != NULL check.
Signed-off-By: Hans de Goede <hdegoede@redhat.com>
diff -up linux-2.6.35.x86_64/drivers/char/virtio_console.c~ linux-2.6.35.x86_64/drivers/char/virtio_console.c
--- linux-2.6.35.x86_64/drivers/char/virtio_console.c~ 2010-08-02 00:11:14.000000000 +0200
+++ linux-2.6.35.x86_64/drivers/char/virtio_console.c 2010-09-15 13:39:29.043505000 +0200
@@ -642,7 +642,7 @@ static unsigned int port_fops_poll(struc
poll_wait(filp, &port->waitqueue, wait);
ret = 0;
- if (port->inbuf)
+ if (port_has_data(port))
ret |= POLLIN | POLLRDNORM;
if (!will_write_block(port))
ret |= POLLOUT;
[-- Attachment #3: Type: text/plain, Size: 184 bytes --]
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* Re: PATCH: virtio_console: Fix poll blocking even though there is data to read (version 2)
From: Amit Shah @ 2010-09-16 5:16 UTC (permalink / raw)
To: Hans de Goede; +Cc: spice-devel, kvm, virtualization
In-Reply-To: <4C90E3BF.4000408@redhat.com>
On (Wed) Sep 15 2010 [17:18:23], Hans de Goede wrote:
> diff -up linux-2.6.35.x86_64/drivers/char/virtio_console.c~ linux-2.6.35.x86_64/drivers/char/virtio_console.c
> --- linux-2.6.35.x86_64/drivers/char/virtio_console.c~ 2010-08-02 00:11:14.000000000 +0200
> +++ linux-2.6.35.x86_64/drivers/char/virtio_console.c 2010-09-15 13:39:29.043505000 +0200
> @@ -642,7 +642,7 @@ static unsigned int port_fops_poll(struc
> poll_wait(filp, &port->waitqueue, wait);
>
> ret = 0;
> - if (port->inbuf)
> + if (port_has_data(port))
> ret |= POLLIN | POLLRDNORM;
> if (!will_write_block(port))
> ret |= POLLOUT;
Thanks, this works.
I'll send a git-formatted patch to Rusty.
Amit
^ permalink raw reply
* Re: PATCH: virtio_console: Fix poll blocking even though there is data to read
From: Rusty Russell @ 2010-09-16 6:02 UTC (permalink / raw)
To: Amit Shah
Cc: Hans de Goede, Michael Kerrisk, spice-devel, kvm, virtualization
In-Reply-To: <20100915134624.GB12320@amit-laptop.redhat.com>
On Wed, 15 Sep 2010 11:16:24 pm Amit Shah wrote:
> On (Wed) Sep 15 2010 [15:37:21], Hans de Goede wrote:
> > >>--- linux-2.6.35.x86_64/drivers/char/virtio_console.c~ 2010-08-02 00:11:14.000000000 +0200
> > >>+++ linux-2.6.35.x86_64/drivers/char/virtio_console.c 2010-09-15 13:39:29.043505000 +0200
> > >>@@ -642,7 +642,7 @@ static unsigned int port_fops_poll(struc
> > >> poll_wait(filp,&port->waitqueue, wait);
> > >>
> > >> ret = 0;
> > >>- if (port->inbuf)
> > >>+ if (!will_read_block(port))
> > >
> > >Looks correct, but this should be
> > >
> > > if (port_has_data(port))
> > >
> > >instead.
> >
> > That certainly works for me (as in will still fix the bug I'm hitting), but
> > quoting from "man 2 select":
> >
> > Three independent sets of file descriptors are watched. Those listed
> > in readfds will be watched to see if characters become available for
> > reading (more precisely, to see if a read will not block; in particu‐
> > lar, a file descriptor is also ready on end-of-file)
> >
> > Notice the "a file descriptor is also ready on end-of-file", and
> > port_fops_read treats the host not being connected as eof (it returns 0
> > in that case). So from an API pov I'm not sure what is correct.
>
> poll(2) says:
>
> POLLIN There is data to read.
>
> That makes it simple.
That's a documentation bug. On a pipe, POLLIN is set when the other end
closes. read() then returns 0 immediately.
poll() sets POLLIN when read() won't block, and people count on it.
Let's do that, please.
Rusty.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* Re: [PATCH] vhost-net: fix range checking in mrg bufs case
From: Jason Wang @ 2010-09-16 6:12 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: kvm, virtualization, netdev, linux-kernel
In-Reply-To: <20100914131552.GA1937@redhat.com>
Tested-by: Jason Wang <jasowang@redhat.com>
----- "Michael S. Tsirkin" <mst@redhat.com> wrote:
> In mergeable buffer case, we use headcount, log_num
> and seg as indexes in same-size arrays, and
> we know that headcount <= seg and
> log_num equals either 0 or seg.
>
> Therefore, the right thing to do is range-check seg,
> not headcount as we do now: these will be different
> if guest chains s/g descriptors (this does not
> happen now, but we can not trust the guest).
>
> Long term, we should add BUG_ON checks to verify
> two other indexes are what we think they should be.
>
> Reported-by: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Dave, I'll queue this on my tree, no need to bother.
>
> drivers/vhost/net.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> index 6400cd5..f095de6 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -245,7 +245,7 @@ static int get_rx_bufs(struct vhost_virtqueue
> *vq,
> int r, nlogs = 0;
>
> while (datalen > 0) {
> - if (unlikely(headcount >= VHOST_NET_MAX_SG)) {
> + if (unlikely(seg >= VHOST_NET_MAX_SG)) {
> r = -ENOBUFS;
> goto err;
> }
> --
> 1.7.3.rc1.5.ge5969
> _______________________________________________
> Virtualization mailing list
> Virtualization@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* Re: PATCH: virtio_console: Fix poll blocking even though there is data to read
From: Amit Shah @ 2010-09-16 6:22 UTC (permalink / raw)
To: Rusty Russell
Cc: Hans de Goede, Michael Kerrisk, spice-devel, kvm, virtualization
In-Reply-To: <201009161532.55462.rusty@rustcorp.com.au>
On (Thu) Sep 16 2010 [15:32:54], Rusty Russell wrote:
> On Wed, 15 Sep 2010 11:16:24 pm Amit Shah wrote:
> > On (Wed) Sep 15 2010 [15:37:21], Hans de Goede wrote:
> > > >>--- linux-2.6.35.x86_64/drivers/char/virtio_console.c~ 2010-08-02 00:11:14.000000000 +0200
> > > >>+++ linux-2.6.35.x86_64/drivers/char/virtio_console.c 2010-09-15 13:39:29.043505000 +0200
> > > >>@@ -642,7 +642,7 @@ static unsigned int port_fops_poll(struc
> > > >> poll_wait(filp,&port->waitqueue, wait);
> > > >>
> > > >> ret = 0;
> > > >>- if (port->inbuf)
> > > >>+ if (!will_read_block(port))
> > > >
> > > >Looks correct, but this should be
> > > >
> > > > if (port_has_data(port))
> > > >
> > > >instead.
> > >
> > > That certainly works for me (as in will still fix the bug I'm hitting), but
> > > quoting from "man 2 select":
> > >
> > > Three independent sets of file descriptors are watched. Those listed
> > > in readfds will be watched to see if characters become available for
> > > reading (more precisely, to see if a read will not block; in particu‐
> > > lar, a file descriptor is also ready on end-of-file)
> > >
> > > Notice the "a file descriptor is also ready on end-of-file", and
> > > port_fops_read treats the host not being connected as eof (it returns 0
> > > in that case). So from an API pov I'm not sure what is correct.
> >
> > poll(2) says:
> >
> > POLLIN There is data to read.
> >
> > That makes it simple.
>
> That's a documentation bug. On a pipe, POLLIN is set when the other end
> closes. read() then returns 0 immediately.
Currently we don't set POLLIN when host goes down. I'll do a second
patch for that.
> poll() sets POLLIN when read() won't block, and people count on it.
Yes, that's the behaviour with Hans's new patch as well -- that's not
changing.
The will_read_block() function (and the comment on top of it) are
causing this confusion:
/* The condition that must be true for polling to end */
static bool will_read_block(struct port *port)
{
if (!port->guest_connected) {
/* Port got hot-unplugged. Let's exit. */
return false;
}
return !port_has_data(port) && port->host_connected;
}
This function is only called to unblock a blocking read() call. So the
comment there has to be changed to read 'waiting' to end instead of
'polling' to end.
read() does return 0 immediately when the other end is not connected
(and there's no data to read).
In effect, we need:
- Hans's patch
- a patch to set POLLIN when host goes down (in addition to POLLHUP and
SIGIO)
- a patch to change the comment for will_read_block.
Thanks,
Amit
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* Re: PATCH: virtio_console: Fix poll blocking even though there is data to read
From: Amit Shah @ 2010-09-16 7:16 UTC (permalink / raw)
To: Rusty Russell
Cc: Hans de Goede, Michael Kerrisk, spice-devel, kvm, virtualization
In-Reply-To: <20100916062201.GC2429@amit-laptop.redhat.com>
On (Thu) Sep 16 2010 [11:52:01], Amit Shah wrote:
> On (Thu) Sep 16 2010 [15:32:54], Rusty Russell wrote:
> > On Wed, 15 Sep 2010 11:16:24 pm Amit Shah wrote:
> > > On (Wed) Sep 15 2010 [15:37:21], Hans de Goede wrote:
> > > > >>--- linux-2.6.35.x86_64/drivers/char/virtio_console.c~ 2010-08-02 00:11:14.000000000 +0200
> > > > >>+++ linux-2.6.35.x86_64/drivers/char/virtio_console.c 2010-09-15 13:39:29.043505000 +0200
> > > > >>@@ -642,7 +642,7 @@ static unsigned int port_fops_poll(struc
> > > > >> poll_wait(filp,&port->waitqueue, wait);
> > > > >>
> > > > >> ret = 0;
> > > > >>- if (port->inbuf)
> > > > >>+ if (!will_read_block(port))
> > > > >
> > > > >Looks correct, but this should be
> > > > >
> > > > > if (port_has_data(port))
> > > > >
> > > > >instead.
> > > >
> > > > That certainly works for me (as in will still fix the bug I'm hitting), but
> > > > quoting from "man 2 select":
> > > >
> > > > Three independent sets of file descriptors are watched. Those listed
> > > > in readfds will be watched to see if characters become available for
> > > > reading (more precisely, to see if a read will not block; in particu‐
> > > > lar, a file descriptor is also ready on end-of-file)
> > > >
> > > > Notice the "a file descriptor is also ready on end-of-file", and
> > > > port_fops_read treats the host not being connected as eof (it returns 0
> > > > in that case). So from an API pov I'm not sure what is correct.
> > >
> > > poll(2) says:
> > >
> > > POLLIN There is data to read.
> > >
> > > That makes it simple.
> >
> > That's a documentation bug. On a pipe, POLLIN is set when the other end
> > closes. read() then returns 0 immediately.
>
> Currently we don't set POLLIN when host goes down. I'll do a second
> patch for that.
>
> > poll() sets POLLIN when read() won't block, and people count on it.
>
> Yes, that's the behaviour with Hans's new patch as well -- that's not
> changing.
>
> The will_read_block() function (and the comment on top of it) are
> causing this confusion:
>
>
> /* The condition that must be true for polling to end */
> static bool will_read_block(struct port *port)
> {
> if (!port->guest_connected) {
> /* Port got hot-unplugged. Let's exit. */
> return false;
> }
> return !port_has_data(port) && port->host_connected;
> }
>
> This function is only called to unblock a blocking read() call. So the
> comment there has to be changed to read 'waiting' to end instead of
> 'polling' to end.
>
> read() does return 0 immediately when the other end is not connected
> (and there's no data to read).
>
> In effect, we need:
> - Hans's patch
> - a patch to set POLLIN when host goes down (in addition to POLLHUP and
> SIGIO)
> - a patch to change the comment for will_read_block.
Uh, sorry for blabbering.
will_read_block() was written to be used in poll(), and the comment says
as much. I should've used it right from the start. Hans's first patch
was correct, I'll pick that up and that addresses all the "issues" that
are present.
Sorry again!
Amit
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* [PATCH 1/2] virtio: console: Fix poll blocking even though there is data to read
From: Amit Shah @ 2010-09-16 9:13 UTC (permalink / raw)
To: Rusty Russell; +Cc: Amit Shah, Hans de Goede, Virtualization List
From: Hans de Goede <hdegoede@redhat.com>
I found this while working on a Linux agent for spice, the symptom I was
seeing was select blocking on the spice vdagent virtio serial port even
though there were messages queued up there.
virtio_console's port_fops_poll checks port->inbuf != NULL to determine
if read won't block. However if an application reads enough bytes from
inbuf through port_fops_read, to empty the current port->inbuf,
port->inbuf will be NULL even though there may be buffers left in the
virtqueue.
This causes poll() to block even though there is data to be read,
this patch fixes this by using will_read_block(port) instead of the
port->inbuf != NULL check.
Signed-off-By: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
drivers/char/virtio_console.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index be67d6b..2dbcd41 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -710,7 +710,7 @@ static unsigned int port_fops_poll(struct file *filp, poll_table *wait)
return POLLHUP;
}
ret = 0;
- if (port->inbuf)
+ if (!will_read_block(port))
ret |= POLLIN | POLLRDNORM;
if (!will_write_block(port))
ret |= POLLOUT;
--
1.7.2.3
^ permalink raw reply related
* [PATCH 2/2] virtio: console: Disable lseek(2) for port file operations
From: Amit Shah @ 2010-09-16 9:13 UTC (permalink / raw)
To: Rusty Russell; +Cc: Amit Shah, Arnd Bergmann, Virtualization List
In-Reply-To: <6c7c2590a114d65ec52689be7cda7ada5ee876d5.1284628364.git.amit.shah@redhat.com>
The ports are char devices; do not have seeking capabilities. Calling
nonseekable_open() from the fops_open() call and setting the llseek fops
pointer to no_llseek ensures an lseek() call from userspace returns
-ESPIPE.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
CC: Arnd Bergmann <arnd@arndb.de>
---
drivers/char/virtio_console.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 2dbcd41..28718a9 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -798,6 +798,8 @@ static int port_fops_open(struct inode *inode, struct file *filp)
reclaim_consumed_buffers(port);
spin_unlock_irq(&port->outvq_lock);
+ nonseekable_open(inode, filp);
+
/* Notify host of port being opened */
send_control_msg(filp->private_data, VIRTIO_CONSOLE_PORT_OPEN, 1);
@@ -829,6 +831,7 @@ static const struct file_operations port_fops = {
.poll = port_fops_poll,
.release = port_fops_release,
.fasync = port_fops_fasync,
+ .llseek = no_llseek,
};
/*
--
1.7.2.3
^ permalink raw reply related
* Re: [PATCH 1/2] virtio: console: Fix poll blocking even though there is data to read
From: Rusty Russell @ 2010-09-20 2:49 UTC (permalink / raw)
To: Amit Shah; +Cc: Hans de Goede, Virtualization List
In-Reply-To: <6c7c2590a114d65ec52689be7cda7ada5ee876d5.1284628364.git.amit.shah@redhat.com>
On Thu, 16 Sep 2010 06:43:08 pm Amit Shah wrote:
> From: Hans de Goede <hdegoede@redhat.com>
>
> I found this while working on a Linux agent for spice, the symptom I was
> seeing was select blocking on the spice vdagent virtio serial port even
> though there were messages queued up there.
>
> virtio_console's port_fops_poll checks port->inbuf != NULL to determine
> if read won't block. However if an application reads enough bytes from
> inbuf through port_fops_read, to empty the current port->inbuf,
> port->inbuf will be NULL even though there may be buffers left in the
> virtqueue.
>
> This causes poll() to block even though there is data to be read,
> this patch fixes this by using will_read_block(port) instead of the
> port->inbuf != NULL check.
>
> Signed-off-By: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
Thanks. I assume this one should go into stable too?
Cheers,
Rusty.
^ permalink raw reply
* Re: [PATCH 1/2] virtio: console: Fix poll blocking even though there is data to read
From: Amit Shah @ 2010-09-20 5:08 UTC (permalink / raw)
To: Rusty Russell; +Cc: Hans de Goede, Virtualization List
In-Reply-To: <201009201219.34378.rusty@rustcorp.com.au>
On (Mon) Sep 20 2010 [12:19:33], Rusty Russell wrote:
> On Thu, 16 Sep 2010 06:43:08 pm Amit Shah wrote:
> > From: Hans de Goede <hdegoede@redhat.com>
> >
> > I found this while working on a Linux agent for spice, the symptom I was
> > seeing was select blocking on the spice vdagent virtio serial port even
> > though there were messages queued up there.
> >
> > virtio_console's port_fops_poll checks port->inbuf != NULL to determine
> > if read won't block. However if an application reads enough bytes from
> > inbuf through port_fops_read, to empty the current port->inbuf,
> > port->inbuf will be NULL even though there may be buffers left in the
> > virtqueue.
> >
> > This causes poll() to block even though there is data to be read,
> > this patch fixes this by using will_read_block(port) instead of the
> > port->inbuf != NULL check.
> >
> > Signed-off-By: Hans de Goede <hdegoede@redhat.com>
> > Signed-off-by: Amit Shah <amit.shah@redhat.com>
>
> Thanks. I assume this one should go into stable too?
Yes, thanks.
Amit
^ permalink raw reply
* [GIT PULL net-2.6] vhost-net: fix range checking
From: Michael S. Tsirkin @ 2010-09-20 17:42 UTC (permalink / raw)
To: David Miller; +Cc: kvm, virtualization, netdev, linux-kernel
David,
The following tree includes a bugfix for vhost-net.
It is on top of net-2.6. Please merge it for 2.6.36.
Thanks!
The following changes since commit 053d8f6622701f849fda2ca2c9ae596c13599ba9:
Merge branch 'vhost-net' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost (2010-09-09 21:59:51 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost-net
Michael S. Tsirkin (1):
vhost-net: fix range checking in mrg bufs case
drivers/vhost/net.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
^ permalink raw reply
* Re: [GIT PULL net-2.6] vhost-net: fix range checking
From: David Miller @ 2010-09-20 18:15 UTC (permalink / raw)
To: mst; +Cc: kvm, virtualization, netdev, linux-kernel
In-Reply-To: <20100920174222.GA30510@redhat.com>
From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Mon, 20 Sep 2010 19:42:22 +0200
> git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost-net
Pulled, thanks!
^ permalink raw reply
* [PATCH 1/2] staging: hv: Remove camel cases of vmbus packet buffer structures
From: Haiyang Zhang @ 2010-09-20 21:07 UTC (permalink / raw)
To: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
"'virtualization@lists.osdl.org'" <virtualiz>
From: Haiyang Zhang <haiyangz@microsoft.com>
Remove camel cases of vmbus packet buffer structures
Remove camel cases of:
struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER
struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc.c | 2 +-
drivers/staging/hv/channel.c | 48 +++++++++++++++++++++---------------------
drivers/staging/hv/channel.h | 36 +++++++++++++++---------------
drivers/staging/hv/storvsc.c | 2 +-
drivers/staging/hv/vmbus.c | 6 ++--
5 files changed, 47 insertions(+), 47 deletions(-)
diff --git a/drivers/staging/hv/blkvsc.c b/drivers/staging/hv/blkvsc.c
index 929238a..d5b0abd 100644
--- a/drivers/staging/hv/blkvsc.c
+++ b/drivers/staging/hv/blkvsc.c
@@ -81,7 +81,7 @@ int BlkVscInitialize(struct hv_driver *Driver)
* Divide the ring buffer data size (which is 1 page less than the ring
* buffer size since that page is reserved for the ring buffer indices)
* by the max request size (which is
- * VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + struct vstor_packet + u64)
+ * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
*/
storDriver->MaxOutstandingRequestsPerChannel =
((storDriver->RingBufferSize - PAGE_SIZE) /
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index fece30c..37b7b4c 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -765,7 +765,7 @@ int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel,
{
int ret;
int i;
- struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER desc;
+ struct vmbus_channel_packet_page_buffer desc;
u32 descSize;
u32 packetLen;
u32 packetLenAligned;
@@ -778,10 +778,10 @@ int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel,
DumpVmbusChannel(Channel);
/*
- * Adjust the size down since VMBUS_CHANNEL_PACKET_PAGE_BUFFER is the
+ * Adjust the size down since vmbus_channel_packet_page_buffer is the
* largest size we support
*/
- descSize = sizeof(struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER) -
+ descSize = sizeof(struct vmbus_channel_packet_page_buffer) -
((MAX_PAGE_BUFFER_COUNT - PageCount) *
sizeof(struct hv_page_buffer));
packetLen = descSize + BufferLen;
@@ -790,17 +790,17 @@ int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel,
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
- desc.Type = VmbusPacketTypeDataUsingGpaDirect;
- desc.Flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
- desc.DataOffset8 = descSize >> 3; /* in 8-bytes grandularity */
- desc.Length8 = (u16)(packetLenAligned >> 3);
- desc.TransactionId = RequestId;
- desc.RangeCount = PageCount;
+ desc.type = VmbusPacketTypeDataUsingGpaDirect;
+ desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
+ desc.dataoffset8 = descSize >> 3; /* in 8-bytes grandularity */
+ desc.length8 = (u16)(packetLenAligned >> 3);
+ desc.transactionid = RequestId;
+ desc.rangecount = PageCount;
for (i = 0; i < PageCount; i++) {
- desc.Range[i].Length = PageBuffers[i].Length;
- desc.Range[i].Offset = PageBuffers[i].Offset;
- desc.Range[i].Pfn = PageBuffers[i].Pfn;
+ desc.range[i].Length = PageBuffers[i].Length;
+ desc.range[i].Offset = PageBuffers[i].Offset;
+ desc.range[i].Pfn = PageBuffers[i].Pfn;
}
sg_init_table(bufferList, 3);
@@ -826,7 +826,7 @@ int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel,
void *Buffer, u32 BufferLen, u64 RequestId)
{
int ret;
- struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER desc;
+ struct vmbus_channel_packet_multipage_buffer desc;
u32 descSize;
u32 packetLen;
u32 packetLenAligned;
@@ -844,10 +844,10 @@ int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel,
return -EINVAL;
/*
- * Adjust the size down since VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER is
+ * Adjust the size down since vmbus_channel_packet_multipage_buffer is
* the largest size we support
*/
- descSize = sizeof(struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER) -
+ descSize = sizeof(struct vmbus_channel_packet_multipage_buffer) -
((MAX_MULTIPAGE_BUFFER_COUNT - PfnCount) *
sizeof(u64));
packetLen = descSize + BufferLen;
@@ -856,17 +856,17 @@ int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel,
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
- desc.Type = VmbusPacketTypeDataUsingGpaDirect;
- desc.Flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
- desc.DataOffset8 = descSize >> 3; /* in 8-bytes grandularity */
- desc.Length8 = (u16)(packetLenAligned >> 3);
- desc.TransactionId = RequestId;
- desc.RangeCount = 1;
+ desc.type = VmbusPacketTypeDataUsingGpaDirect;
+ desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
+ desc.dataoffset8 = descSize >> 3; /* in 8-bytes grandularity */
+ desc.length8 = (u16)(packetLenAligned >> 3);
+ desc.transactionid = RequestId;
+ desc.rangecount = 1;
- desc.Range.Length = MultiPageBuffer->Length;
- desc.Range.Offset = MultiPageBuffer->Offset;
+ desc.range.Length = MultiPageBuffer->Length;
+ desc.range.Offset = MultiPageBuffer->Offset;
- memcpy(desc.Range.PfnArray, MultiPageBuffer->PfnArray,
+ memcpy(desc.range.PfnArray, MultiPageBuffer->PfnArray,
PfnCount * sizeof(u64));
sg_init_table(bufferList, 3);
diff --git a/drivers/staging/hv/channel.h b/drivers/staging/hv/channel.h
index acb2c55..85c5079 100644
--- a/drivers/staging/hv/channel.h
+++ b/drivers/staging/hv/channel.h
@@ -28,27 +28,27 @@
#include "channel_mgmt.h"
/* The format must be the same as struct vmdata_gpa_direct */
-struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER {
- u16 Type;
- u16 DataOffset8;
- u16 Length8;
- u16 Flags;
- u64 TransactionId;
- u32 Reserved;
- u32 RangeCount;
- struct hv_page_buffer Range[MAX_PAGE_BUFFER_COUNT];
+struct vmbus_channel_packet_page_buffer {
+ u16 type;
+ u16 dataoffset8;
+ u16 length8;
+ u16 flags;
+ u64 transactionid;
+ u32 reserved;
+ u32 rangecount;
+ struct hv_page_buffer range[MAX_PAGE_BUFFER_COUNT];
} __attribute__((packed));
/* The format must be the same as struct vmdata_gpa_direct */
-struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER {
- u16 Type;
- u16 DataOffset8;
- u16 Length8;
- u16 Flags;
- u64 TransactionId;
- u32 Reserved;
- u32 RangeCount; /* Always 1 in this case */
- struct hv_multipage_buffer Range;
+struct vmbus_channel_packet_multipage_buffer {
+ u16 type;
+ u16 dataoffset8;
+ u16 length8;
+ u16 flags;
+ u64 transactionid;
+ u32 reserved;
+ u32 rangecount; /* Always 1 in this case */
+ struct hv_multipage_buffer range;
} __attribute__((packed));
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 6bd2ff1..6821a8f 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -799,7 +799,7 @@ int StorVscInitialize(struct hv_driver *Driver)
* Divide the ring buffer data size (which is 1 page less
* than the ring buffer size since that page is reserved for
* the ring buffer indices) by the max request size (which is
- * VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + struct vstor_packet + u64)
+ * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
*/
storDriver->MaxOutstandingRequestsPerChannel =
((storDriver->RingBufferSize - PAGE_SIZE) /
diff --git a/drivers/staging/hv/vmbus.c b/drivers/staging/hv/vmbus.c
index db2afa3..ea2698c 100644
--- a/drivers/staging/hv/vmbus.c
+++ b/drivers/staging/hv/vmbus.c
@@ -255,10 +255,10 @@ int VmbusInitialize(struct hv_driver *drv)
VMBUS_REVISION_NUMBER);
DPRINT_INFO(VMBUS, "+++++++ Vmbus using SINT %d +++++++",
VMBUS_MESSAGE_SINT);
- DPRINT_DBG(VMBUS, "sizeof(VMBUS_CHANNEL_PACKET_PAGE_BUFFER)=%zd, "
+ DPRINT_DBG(VMBUS, "sizeof(vmbus_channel_packet_page_buffer)=%zd, "
"sizeof(VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER)=%zd",
- sizeof(struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER),
- sizeof(struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER));
+ sizeof(struct vmbus_channel_packet_page_buffer),
+ sizeof(struct vmbus_channel_packet_multipage_buffer));
drv->name = gDriverName;
memcpy(&drv->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid));
--
1.6.3.2
^ permalink raw reply related
* [PATCH 2/2] staging: hv: Remove camel cases from vmbus channel functions
From: Haiyang Zhang @ 2010-09-20 21:13 UTC (permalink / raw)
To: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
"'virtualization@lists.osdl.org'" <virtualiz>
From: Haiyang Zhang <haiyangz@microsoft.com>
Remove camel cases from vmbus channel functions
Converted the function names, local variables to lower cases.
More patches will be submitted soon to remove the remaining camel cases.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/channel.c | 793 +++++++++++++++-----------------
drivers/staging/hv/channel.h | 94 ++--
drivers/staging/hv/channel_interface.c | 20 +-
drivers/staging/hv/channel_mgmt.c | 8 +-
drivers/staging/hv/connection.c | 4 +-
drivers/staging/hv/hv_utils.c | 12 +-
6 files changed, 441 insertions(+), 490 deletions(-)
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 37b7b4c..af0e86a 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -27,50 +27,20 @@
#include "vmbus_private.h"
/* Internal routines */
-static int VmbusChannelCreateGpadlHeader(
- void *Kbuffer, /* must be phys and virt contiguous */
- u32 Size, /* page-size multiple */
- struct vmbus_channel_msginfo **msgInfo,
- u32 *MessageCount);
-static void DumpVmbusChannel(struct vmbus_channel *channel);
-static void VmbusChannelSetEvent(struct vmbus_channel *channel);
+static int vmbuschannel_creategpadlheader(
+ void *kbuffer, /* must be phys and virt contiguous */
+ u32 size, /* page-size multiple */
+ struct vmbus_channel_msginfo **msginfo,
+ u32 *messagecount);
+static void dumpvmbuschannel(struct vmbus_channel *channel);
+static void vmbuschannel_setevent(struct vmbus_channel *channel);
-#if 0
-static void DumpMonitorPage(struct hv_monitor_page *MonitorPage)
-{
- int i = 0;
- int j = 0;
-
- DPRINT_DBG(VMBUS, "monitorPage - %p, trigger state - %d",
- MonitorPage, MonitorPage->TriggerState);
-
- for (i = 0; i < 4; i++)
- DPRINT_DBG(VMBUS, "trigger group (%d) - %llx", i,
- MonitorPage->TriggerGroup[i].AsUINT64);
-
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 32; j++) {
- DPRINT_DBG(VMBUS, "latency (%d)(%d) - %llx", i, j,
- MonitorPage->Latency[i][j]);
- }
- }
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 32; j++) {
- DPRINT_DBG(VMBUS, "param-conn id (%d)(%d) - %d", i, j,
- MonitorPage->Parameter[i][j].ConnectionId.Asu32);
- DPRINT_DBG(VMBUS, "param-flag (%d)(%d) - %d", i, j,
- MonitorPage->Parameter[i][j].FlagNumber);
- }
- }
-}
-#endif
-
/*
* VmbusChannelSetEvent - Trigger an event notification on the specified
* channel.
*/
-static void VmbusChannelSetEvent(struct vmbus_channel *Channel)
+static void vmbuschannel_setevent(struct vmbus_channel *Channel)
{
struct hv_monitor_page *monitorPage;
@@ -92,82 +62,60 @@ static void VmbusChannelSetEvent(struct vmbus_channel *Channel)
}
}
-#if 0
-static void VmbusChannelClearEvent(struct vmbus_channel *channel)
-{
- struct hv_monitor_page *monitorPage;
-
- if (Channel->OfferMsg.MonitorAllocated) {
- /* Each u32 represents 32 channels */
- clear_bit(Channel->OfferMsg.ChildRelId & 31,
- (unsigned long *)gVmbusConnection.SendInterruptPage +
- (Channel->OfferMsg.ChildRelId >> 5));
-
- monitorPage =
- (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
- monitorPage++; /* Get the child to parent monitor page */
-
- clear_bit(Channel->MonitorBit,
- (unsigned long *)&monitorPage->TriggerGroup
- [Channel->MonitorGroup].Pending);
- }
-}
-
-#endif
/*
- * VmbusChannelGetDebugInfo -Retrieve various channel debug info
+ * vmbuschannel_getdebuginfo -Retrieve various channel debug info
*/
-void VmbusChannelGetDebugInfo(struct vmbus_channel *Channel,
- struct vmbus_channel_debug_info *DebugInfo)
+void vmbuschannel_getdebuginfo(struct vmbus_channel *channel,
+ struct vmbus_channel_debug_info *debuginfo)
{
struct hv_monitor_page *monitorPage;
- u8 monitorGroup = (u8)Channel->OfferMsg.MonitorId / 32;
- u8 monitorOffset = (u8)Channel->OfferMsg.MonitorId % 32;
+ u8 monitorGroup = (u8)channel->OfferMsg.MonitorId / 32;
+ u8 monitorOffset = (u8)channel->OfferMsg.MonitorId % 32;
/* u32 monitorBit = 1 << monitorOffset; */
- DebugInfo->RelId = Channel->OfferMsg.ChildRelId;
- DebugInfo->State = Channel->State;
- memcpy(&DebugInfo->InterfaceType,
- &Channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid));
- memcpy(&DebugInfo->InterfaceInstance,
- &Channel->OfferMsg.Offer.InterfaceInstance,
+ debuginfo->RelId = channel->OfferMsg.ChildRelId;
+ debuginfo->State = channel->State;
+ memcpy(&debuginfo->InterfaceType,
+ &channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid));
+ memcpy(&debuginfo->InterfaceInstance,
+ &channel->OfferMsg.Offer.InterfaceInstance,
sizeof(struct hv_guid));
monitorPage = (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
- DebugInfo->MonitorId = Channel->OfferMsg.MonitorId;
+ debuginfo->MonitorId = channel->OfferMsg.MonitorId;
- DebugInfo->ServerMonitorPending =
+ debuginfo->ServerMonitorPending =
monitorPage->TriggerGroup[monitorGroup].Pending;
- DebugInfo->ServerMonitorLatency =
+ debuginfo->ServerMonitorLatency =
monitorPage->Latency[monitorGroup][monitorOffset];
- DebugInfo->ServerMonitorConnectionId =
+ debuginfo->ServerMonitorConnectionId =
monitorPage->Parameter[monitorGroup]
[monitorOffset].ConnectionId.u.Id;
monitorPage++;
- DebugInfo->ClientMonitorPending =
+ debuginfo->ClientMonitorPending =
monitorPage->TriggerGroup[monitorGroup].Pending;
- DebugInfo->ClientMonitorLatency =
+ debuginfo->ClientMonitorLatency =
monitorPage->Latency[monitorGroup][monitorOffset];
- DebugInfo->ClientMonitorConnectionId =
+ debuginfo->ClientMonitorConnectionId =
monitorPage->Parameter[monitorGroup]
[monitorOffset].ConnectionId.u.Id;
- RingBufferGetDebugInfo(&Channel->Inbound, &DebugInfo->Inbound);
- RingBufferGetDebugInfo(&Channel->Outbound, &DebugInfo->Outbound);
+ RingBufferGetDebugInfo(&channel->Inbound, &debuginfo->Inbound);
+ RingBufferGetDebugInfo(&channel->Outbound, &debuginfo->Outbound);
}
/*
- * VmbusChannelOpen - Open the specified channel.
+ * vmbuschannel_open - Open the specified channel.
*/
-int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
- u32 RecvRingBufferSize, void *UserData, u32 UserDataLen,
- void (*OnChannelCallback)(void *context), void *Context)
+int vmbuschannel_open(struct vmbus_channel *newchannel, u32 sendringbuffersize,
+ u32 recvringbuffersize, void *userdata, u32 userdatalen,
+ void (*onchannelcallback)(void *context), void *context)
{
- struct vmbus_channel_open_channel *openMsg;
- struct vmbus_channel_msginfo *openInfo = NULL;
+ struct vmbus_channel_open_channel *openmsg;
+ struct vmbus_channel_msginfo *openinfo = NULL;
void *in, *out;
unsigned long flags;
int ret, err = 0;
@@ -176,30 +124,30 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
/* ASSERT(!(SendRingBufferSize & (PAGE_SIZE - 1))); */
/* ASSERT(!(RecvRingBufferSize & (PAGE_SIZE - 1))); */
- NewChannel->OnChannelCallback = OnChannelCallback;
- NewChannel->ChannelCallbackContext = Context;
+ newchannel->OnChannelCallback = onchannelcallback;
+ newchannel->ChannelCallbackContext = context;
/* Allocate the ring buffer */
- out = osd_PageAlloc((SendRingBufferSize + RecvRingBufferSize)
+ out = osd_PageAlloc((sendringbuffersize + recvringbuffersize)
>> PAGE_SHIFT);
if (!out)
return -ENOMEM;
/* ASSERT(((unsigned long)out & (PAGE_SIZE-1)) == 0); */
- in = (void *)((unsigned long)out + SendRingBufferSize);
+ in = (void *)((unsigned long)out + sendringbuffersize);
- NewChannel->RingBufferPages = out;
- NewChannel->RingBufferPageCount = (SendRingBufferSize +
- RecvRingBufferSize) >> PAGE_SHIFT;
+ newchannel->RingBufferPages = out;
+ newchannel->RingBufferPageCount = (sendringbuffersize +
+ recvringbuffersize) >> PAGE_SHIFT;
- ret = RingBufferInit(&NewChannel->Outbound, out, SendRingBufferSize);
+ ret = RingBufferInit(&newchannel->Outbound, out, sendringbuffersize);
if (ret != 0) {
err = ret;
goto errorout;
}
- ret = RingBufferInit(&NewChannel->Inbound, in, RecvRingBufferSize);
+ ret = RingBufferInit(&newchannel->Inbound, in, recvringbuffersize);
if (ret != 0) {
err = ret;
goto errorout;
@@ -208,15 +156,15 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
/* Establish the gpadl for the ring buffer */
DPRINT_DBG(VMBUS, "Establishing ring buffer's gpadl for channel %p...",
- NewChannel);
+ newchannel);
- NewChannel->RingBufferGpadlHandle = 0;
+ newchannel->RingBufferGpadlHandle = 0;
- ret = VmbusChannelEstablishGpadl(NewChannel,
- NewChannel->Outbound.RingBuffer,
- SendRingBufferSize +
- RecvRingBufferSize,
- &NewChannel->RingBufferGpadlHandle);
+ ret = vmbuschannel_establishgpadl(newchannel,
+ newchannel->Outbound.RingBuffer,
+ sendringbuffersize +
+ recvringbuffersize,
+ &newchannel->RingBufferGpadlHandle);
if (ret != 0) {
err = ret;
@@ -225,54 +173,54 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
DPRINT_DBG(VMBUS, "channel %p <relid %d gpadl 0x%x send ring %p "
"size %d recv ring %p size %d, downstreamoffset %d>",
- NewChannel, NewChannel->OfferMsg.ChildRelId,
- NewChannel->RingBufferGpadlHandle,
- NewChannel->Outbound.RingBuffer,
- NewChannel->Outbound.RingSize,
- NewChannel->Inbound.RingBuffer,
- NewChannel->Inbound.RingSize,
- SendRingBufferSize);
+ newchannel, newchannel->OfferMsg.ChildRelId,
+ newchannel->RingBufferGpadlHandle,
+ newchannel->Outbound.RingBuffer,
+ newchannel->Outbound.RingSize,
+ newchannel->Inbound.RingBuffer,
+ newchannel->Inbound.RingSize,
+ sendringbuffersize);
/* Create and init the channel open message */
- openInfo = kmalloc(sizeof(*openInfo) +
+ openinfo = kmalloc(sizeof(*openinfo) +
sizeof(struct vmbus_channel_open_channel),
GFP_KERNEL);
- if (!openInfo) {
+ if (!openinfo) {
err = -ENOMEM;
goto errorout;
}
- openInfo->WaitEvent = osd_WaitEventCreate();
- if (!openInfo->WaitEvent) {
+ openinfo->WaitEvent = osd_WaitEventCreate();
+ if (!openinfo->WaitEvent) {
err = -ENOMEM;
goto errorout;
}
- openMsg = (struct vmbus_channel_open_channel *)openInfo->Msg;
- openMsg->Header.MessageType = ChannelMessageOpenChannel;
- openMsg->OpenId = NewChannel->OfferMsg.ChildRelId; /* FIXME */
- openMsg->ChildRelId = NewChannel->OfferMsg.ChildRelId;
- openMsg->RingBufferGpadlHandle = NewChannel->RingBufferGpadlHandle;
- openMsg->DownstreamRingBufferPageOffset = SendRingBufferSize >>
+ openmsg = (struct vmbus_channel_open_channel *)openinfo->Msg;
+ openmsg->Header.MessageType = ChannelMessageOpenChannel;
+ openmsg->OpenId = newchannel->OfferMsg.ChildRelId; /* FIXME */
+ openmsg->ChildRelId = newchannel->OfferMsg.ChildRelId;
+ openmsg->RingBufferGpadlHandle = newchannel->RingBufferGpadlHandle;
+ openmsg->DownstreamRingBufferPageOffset = sendringbuffersize >>
PAGE_SHIFT;
- openMsg->ServerContextAreaGpadlHandle = 0; /* TODO */
+ openmsg->ServerContextAreaGpadlHandle = 0; /* TODO */
- if (UserDataLen > MAX_USER_DEFINED_BYTES) {
+ if (userdatalen > MAX_USER_DEFINED_BYTES) {
err = -EINVAL;
goto errorout;
}
- if (UserDataLen)
- memcpy(openMsg->UserData, UserData, UserDataLen);
+ if (userdatalen)
+ memcpy(openmsg->UserData, userdata, userdatalen);
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_add_tail(&openInfo->MsgListEntry,
+ list_add_tail(&openinfo->MsgListEntry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "Sending channel open msg...");
- ret = VmbusPostMessage(openMsg,
+ ret = VmbusPostMessage(openmsg,
sizeof(struct vmbus_channel_open_channel));
if (ret != 0) {
DPRINT_ERR(VMBUS, "unable to open channel - %d", ret);
@@ -280,29 +228,29 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
}
/* FIXME: Need to time-out here */
- osd_WaitEventWait(openInfo->WaitEvent);
+ osd_WaitEventWait(openinfo->WaitEvent);
- if (openInfo->Response.OpenResult.Status == 0)
- DPRINT_INFO(VMBUS, "channel <%p> open success!!", NewChannel);
+ if (openinfo->Response.OpenResult.Status == 0)
+ DPRINT_INFO(VMBUS, "channel <%p> open success!!", newchannel);
else
DPRINT_INFO(VMBUS, "channel <%p> open failed - %d!!",
- NewChannel, openInfo->Response.OpenResult.Status);
+ newchannel, openinfo->Response.OpenResult.Status);
Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_del(&openInfo->MsgListEntry);
+ list_del(&openinfo->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
- kfree(openInfo->WaitEvent);
- kfree(openInfo);
+ kfree(openinfo->WaitEvent);
+ kfree(openinfo);
return 0;
errorout:
- RingBufferCleanup(&NewChannel->Outbound);
- RingBufferCleanup(&NewChannel->Inbound);
- osd_PageFree(out, (SendRingBufferSize + RecvRingBufferSize)
+ RingBufferCleanup(&newchannel->Outbound);
+ RingBufferCleanup(&newchannel->Inbound);
+ osd_PageFree(out, (sendringbuffersize + recvringbuffersize)
>> PAGE_SHIFT);
- kfree(openInfo);
+ kfree(openinfo);
return err;
}
@@ -328,108 +276,109 @@ static void DumpGpadlBody(struct vmbus_channel_gpadl_body *Gpadl, u32 Len)
* DumpGpadlHeader - Dump the gpadl header message to the console for
* debugging purposes.
*/
-static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *Gpadl)
+static void dumpgpadlheader(struct vmbus_channel_gpadl_header *gpadl)
{
int i, j;
- int pageCount;
+ int pagecount;
DPRINT_DBG(VMBUS,
"gpadl header - relid %d, range count %d, range buflen %d",
- Gpadl->ChildRelId, Gpadl->RangeCount, Gpadl->RangeBufLen);
- for (i = 0; i < Gpadl->RangeCount; i++) {
- pageCount = Gpadl->Range[i].ByteCount >> PAGE_SHIFT;
- pageCount = (pageCount > 26) ? 26 : pageCount;
+ gpadl->ChildRelId, gpadl->RangeCount, gpadl->RangeBufLen);
+ for (i = 0; i < gpadl->RangeCount; i++) {
+ pagecount = gpadl->Range[i].ByteCount >> PAGE_SHIFT;
+ pagecount = (pagecount > 26) ? 26 : pagecount;
DPRINT_DBG(VMBUS, "gpadl range %d - len %d offset %d "
- "page count %d", i, Gpadl->Range[i].ByteCount,
- Gpadl->Range[i].ByteOffset, pageCount);
+ "page count %d", i, gpadl->Range[i].ByteCount,
+ gpadl->Range[i].ByteOffset, pagecount);
- for (j = 0; j < pageCount; j++)
+ for (j = 0; j < pagecount; j++)
DPRINT_DBG(VMBUS, "%d) pfn %llu", j,
- Gpadl->Range[i].PfnArray[j]);
+ gpadl->Range[i].PfnArray[j]);
}
}
/*
* VmbusChannelCreateGpadlHeader - Creates a gpadl for the specified buffer
*/
-static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
- struct vmbus_channel_msginfo **MsgInfo,
- u32 *MessageCount)
+static int vmbuschannel_creategpadlheader(void *kbuffer, u32 size,
+ struct vmbus_channel_msginfo **msginfo,
+ u32 *messagecount)
{
int i;
- int pageCount;
+ int pagecount;
unsigned long long pfn;
- struct vmbus_channel_gpadl_header *gpaHeader;
- struct vmbus_channel_gpadl_body *gpadlBody;
- struct vmbus_channel_msginfo *msgHeader;
- struct vmbus_channel_msginfo *msgBody = NULL;
- u32 msgSize;
+ struct vmbus_channel_gpadl_header *gpalheader;
+ struct vmbus_channel_gpadl_body *gpadlbody;
+ struct vmbus_channel_msginfo *msgheader;
+ struct vmbus_channel_msginfo *msgbody = NULL;
+ u32 msgsize;
- int pfnSum, pfnCount, pfnLeft, pfnCurr, pfnSize;
+ int pfnsum, pfncount, pfnleft, pfncurr, pfnsize;
/* ASSERT((kbuffer & (PAGE_SIZE-1)) == 0); */
/* ASSERT((Size & (PAGE_SIZE-1)) == 0); */
- pageCount = Size >> PAGE_SHIFT;
- pfn = virt_to_phys(Kbuffer) >> PAGE_SHIFT;
+ pagecount = size >> PAGE_SHIFT;
+ pfn = virt_to_phys(kbuffer) >> PAGE_SHIFT;
/* do we need a gpadl body msg */
- pfnSize = MAX_SIZE_CHANNEL_MESSAGE -
+ pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
sizeof(struct vmbus_channel_gpadl_header) -
sizeof(struct gpa_range);
- pfnCount = pfnSize / sizeof(u64);
+ pfncount = pfnsize / sizeof(u64);
- if (pageCount > pfnCount) {
+ if (pagecount > pfncount) {
/* we need a gpadl body */
/* fill in the header */
- msgSize = sizeof(struct vmbus_channel_msginfo) +
+ msgsize = sizeof(struct vmbus_channel_msginfo) +
sizeof(struct vmbus_channel_gpadl_header) +
- sizeof(struct gpa_range) + pfnCount * sizeof(u64);
- msgHeader = kzalloc(msgSize, GFP_KERNEL);
- if (!msgHeader)
+ sizeof(struct gpa_range) + pfncount * sizeof(u64);
+ msgheader = kzalloc(msgsize, GFP_KERNEL);
+ if (!msgheader)
goto nomem;
- INIT_LIST_HEAD(&msgHeader->SubMsgList);
- msgHeader->MessageSize = msgSize;
+ INIT_LIST_HEAD(&msgheader->SubMsgList);
+ msgheader->MessageSize = msgsize;
- gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg;
- gpaHeader->RangeCount = 1;
- gpaHeader->RangeBufLen = sizeof(struct gpa_range) +
- pageCount * sizeof(u64);
- gpaHeader->Range[0].ByteOffset = 0;
- gpaHeader->Range[0].ByteCount = Size;
- for (i = 0; i < pfnCount; i++)
- gpaHeader->Range[0].PfnArray[i] = pfn+i;
- *MsgInfo = msgHeader;
- *MessageCount = 1;
+ gpalheader =
+ (struct vmbus_channel_gpadl_header *)msgheader->Msg;
+ gpalheader->RangeCount = 1;
+ gpalheader->RangeBufLen = sizeof(struct gpa_range) +
+ pagecount * sizeof(u64);
+ gpalheader->Range[0].ByteOffset = 0;
+ gpalheader->Range[0].ByteCount = size;
+ for (i = 0; i < pfncount; i++)
+ gpalheader->Range[0].PfnArray[i] = pfn+i;
+ *msginfo = msgheader;
+ *messagecount = 1;
- pfnSum = pfnCount;
- pfnLeft = pageCount - pfnCount;
+ pfnsum = pfncount;
+ pfnleft = pagecount - pfncount;
/* how many pfns can we fit */
- pfnSize = MAX_SIZE_CHANNEL_MESSAGE -
+ pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
sizeof(struct vmbus_channel_gpadl_body);
- pfnCount = pfnSize / sizeof(u64);
+ pfncount = pfnsize / sizeof(u64);
/* fill in the body */
- while (pfnLeft) {
- if (pfnLeft > pfnCount)
- pfnCurr = pfnCount;
+ while (pfnleft) {
+ if (pfnleft > pfncount)
+ pfncurr = pfncount;
else
- pfnCurr = pfnLeft;
+ pfncurr = pfnleft;
- msgSize = sizeof(struct vmbus_channel_msginfo) +
+ msgsize = sizeof(struct vmbus_channel_msginfo) +
sizeof(struct vmbus_channel_gpadl_body) +
- pfnCurr * sizeof(u64);
- msgBody = kzalloc(msgSize, GFP_KERNEL);
+ pfncurr * sizeof(u64);
+ msgbody = kzalloc(msgsize, GFP_KERNEL);
/* FIXME: we probably need to more if this fails */
- if (!msgBody)
+ if (!msgbody)
goto nomem;
- msgBody->MessageSize = msgSize;
- (*MessageCount)++;
- gpadlBody =
- (struct vmbus_channel_gpadl_body *)msgBody->Msg;
+ msgbody->MessageSize = msgsize;
+ (*messagecount)++;
+ gpadlbody =
+ (struct vmbus_channel_gpadl_body *)msgbody->Msg;
/*
* FIXME:
@@ -437,155 +386,157 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
* be 64-bit
*/
/* gpadlBody->Gpadl = kbuffer; */
- for (i = 0; i < pfnCurr; i++)
- gpadlBody->Pfn[i] = pfn + pfnSum + i;
+ for (i = 0; i < pfncurr; i++)
+ gpadlbody->Pfn[i] = pfn + pfnsum + i;
/* add to msg header */
- list_add_tail(&msgBody->MsgListEntry,
- &msgHeader->SubMsgList);
- pfnSum += pfnCurr;
- pfnLeft -= pfnCurr;
+ list_add_tail(&msgbody->MsgListEntry,
+ &msgheader->SubMsgList);
+ pfnsum += pfncurr;
+ pfnleft -= pfncurr;
}
} else {
/* everything fits in a header */
- msgSize = sizeof(struct vmbus_channel_msginfo) +
+ msgsize = sizeof(struct vmbus_channel_msginfo) +
sizeof(struct vmbus_channel_gpadl_header) +
- sizeof(struct gpa_range) + pageCount * sizeof(u64);
- msgHeader = kzalloc(msgSize, GFP_KERNEL);
- if (msgHeader == NULL)
+ sizeof(struct gpa_range) + pagecount * sizeof(u64);
+ msgheader = kzalloc(msgsize, GFP_KERNEL);
+ if (msgheader == NULL)
goto nomem;
- msgHeader->MessageSize = msgSize;
-
- gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg;
- gpaHeader->RangeCount = 1;
- gpaHeader->RangeBufLen = sizeof(struct gpa_range) +
- pageCount * sizeof(u64);
- gpaHeader->Range[0].ByteOffset = 0;
- gpaHeader->Range[0].ByteCount = Size;
- for (i = 0; i < pageCount; i++)
- gpaHeader->Range[0].PfnArray[i] = pfn+i;
-
- *MsgInfo = msgHeader;
- *MessageCount = 1;
+ msgheader->MessageSize = msgsize;
+
+ gpalheader =
+ (struct vmbus_channel_gpadl_header *)msgheader->Msg;
+ gpalheader->RangeCount = 1;
+ gpalheader->RangeBufLen = sizeof(struct gpa_range) +
+ pagecount * sizeof(u64);
+ gpalheader->Range[0].ByteOffset = 0;
+ gpalheader->Range[0].ByteCount = size;
+ for (i = 0; i < pagecount; i++)
+ gpalheader->Range[0].PfnArray[i] = pfn+i;
+
+ *msginfo = msgheader;
+ *messagecount = 1;
}
return 0;
nomem:
- kfree(msgHeader);
- kfree(msgBody);
+ kfree(msgheader);
+ kfree(msgbody);
return -ENOMEM;
}
/*
- * VmbusChannelEstablishGpadl - Estabish a GPADL for the specified buffer
+ * vmbuschannel_establishgpadl - Estabish a GPADL for the specified buffer
*
- * @Channel: a channel
- * @Kbuffer: from kmalloc
- * @Size: page-size multiple
- * @GpadlHandle: some funky thing
+ * @channel: a channel
+ * @kbuffer: from kmalloc
+ * @size: page-size multiple
+ * @gpadlhandle: some funky thing
*/
-int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer,
- u32 Size, u32 *GpadlHandle)
+int vmbuschannel_establishgpadl(struct vmbus_channel *channel, void *kbuffer,
+ u32 size, u32 *gpadlhandle)
{
- struct vmbus_channel_gpadl_header *gpadlMsg;
- struct vmbus_channel_gpadl_body *gpadlBody;
+ struct vmbus_channel_gpadl_header *gpadlmsg;
+ struct vmbus_channel_gpadl_body *gpadlbody;
/* struct vmbus_channel_gpadl_created *gpadlCreated; */
- struct vmbus_channel_msginfo *msgInfo = NULL;
- struct vmbus_channel_msginfo *subMsgInfo;
- u32 msgCount;
+ struct vmbus_channel_msginfo *msginfo = NULL;
+ struct vmbus_channel_msginfo *submsginfo;
+ u32 msgcount;
struct list_head *curr;
- u32 nextGpadlHandle;
+ u32 nextgpadlhandle;
unsigned long flags;
int ret = 0;
- nextGpadlHandle = atomic_read(&gVmbusConnection.NextGpadlHandle);
+ nextgpadlhandle = atomic_read(&gVmbusConnection.NextGpadlHandle);
atomic_inc(&gVmbusConnection.NextGpadlHandle);
- ret = VmbusChannelCreateGpadlHeader(Kbuffer, Size, &msgInfo, &msgCount);
+ ret = vmbuschannel_creategpadlheader(kbuffer, size,
+ &msginfo, &msgcount);
if (ret)
return ret;
- msgInfo->WaitEvent = osd_WaitEventCreate();
- if (!msgInfo->WaitEvent) {
+ msginfo->WaitEvent = osd_WaitEventCreate();
+ if (!msginfo->WaitEvent) {
ret = -ENOMEM;
goto Cleanup;
}
- gpadlMsg = (struct vmbus_channel_gpadl_header *)msgInfo->Msg;
- gpadlMsg->Header.MessageType = ChannelMessageGpadlHeader;
- gpadlMsg->ChildRelId = Channel->OfferMsg.ChildRelId;
- gpadlMsg->Gpadl = nextGpadlHandle;
+ gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->Msg;
+ gpadlmsg->Header.MessageType = ChannelMessageGpadlHeader;
+ gpadlmsg->ChildRelId = channel->OfferMsg.ChildRelId;
+ gpadlmsg->Gpadl = nextgpadlhandle;
- DumpGpadlHeader(gpadlMsg);
+ dumpgpadlheader(gpadlmsg);
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_add_tail(&msgInfo->MsgListEntry,
+ list_add_tail(&msginfo->MsgListEntry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "buffer %p, size %d msg cnt %d",
- Kbuffer, Size, msgCount);
+ kbuffer, size, msgcount);
DPRINT_DBG(VMBUS, "Sending GPADL Header - len %zd",
- msgInfo->MessageSize - sizeof(*msgInfo));
+ msginfo->MessageSize - sizeof(*msginfo));
- ret = VmbusPostMessage(gpadlMsg, msgInfo->MessageSize -
- sizeof(*msgInfo));
+ ret = VmbusPostMessage(gpadlmsg, msginfo->MessageSize -
+ sizeof(*msginfo));
if (ret != 0) {
DPRINT_ERR(VMBUS, "Unable to open channel - %d", ret);
goto Cleanup;
}
- if (msgCount > 1) {
- list_for_each(curr, &msgInfo->SubMsgList) {
+ if (msgcount > 1) {
+ list_for_each(curr, &msginfo->SubMsgList) {
/* FIXME: should this use list_entry() instead ? */
- subMsgInfo = (struct vmbus_channel_msginfo *)curr;
- gpadlBody =
- (struct vmbus_channel_gpadl_body *)subMsgInfo->Msg;
+ submsginfo = (struct vmbus_channel_msginfo *)curr;
+ gpadlbody =
+ (struct vmbus_channel_gpadl_body *)submsginfo->Msg;
- gpadlBody->Header.MessageType = ChannelMessageGpadlBody;
- gpadlBody->Gpadl = nextGpadlHandle;
+ gpadlbody->Header.MessageType = ChannelMessageGpadlBody;
+ gpadlbody->Gpadl = nextgpadlhandle;
DPRINT_DBG(VMBUS, "Sending GPADL Body - len %zd",
- subMsgInfo->MessageSize -
- sizeof(*subMsgInfo));
-
- DumpGpadlBody(gpadlBody, subMsgInfo->MessageSize -
- sizeof(*subMsgInfo));
- ret = VmbusPostMessage(gpadlBody,
- subMsgInfo->MessageSize -
- sizeof(*subMsgInfo));
+ submsginfo->MessageSize -
+ sizeof(*submsginfo));
+
+ DumpGpadlBody(gpadlbody, submsginfo->MessageSize -
+ sizeof(*submsginfo));
+ ret = VmbusPostMessage(gpadlbody,
+ submsginfo->MessageSize -
+ sizeof(*submsginfo));
if (ret != 0)
goto Cleanup;
}
}
- osd_WaitEventWait(msgInfo->WaitEvent);
+ osd_WaitEventWait(msginfo->WaitEvent);
/* At this point, we received the gpadl created msg */
DPRINT_DBG(VMBUS, "Received GPADL created "
"(relid %d, status %d handle %x)",
- Channel->OfferMsg.ChildRelId,
- msgInfo->Response.GpadlCreated.CreationStatus,
- gpadlMsg->Gpadl);
+ channel->OfferMsg.ChildRelId,
+ msginfo->Response.GpadlCreated.CreationStatus,
+ gpadlmsg->Gpadl);
- *GpadlHandle = gpadlMsg->Gpadl;
+ *gpadlhandle = gpadlmsg->Gpadl;
Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_del(&msgInfo->MsgListEntry);
+ list_del(&msginfo->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
- kfree(msgInfo->WaitEvent);
- kfree(msgInfo);
+ kfree(msginfo->WaitEvent);
+ kfree(msginfo);
return ret;
}
/*
- * VmbusChannelTeardownGpadl -Teardown the specified GPADL handle
+ * vmbuschannel_teardowngpadl -Teardown the specified GPADL handle
*/
-int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
+int vmbuschannel_teardowngpadl(struct vmbus_channel *channel, u32 gpadlhandle)
{
struct vmbus_channel_gpadl_teardown *msg;
struct vmbus_channel_msginfo *info;
@@ -608,8 +559,8 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
msg = (struct vmbus_channel_gpadl_teardown *)info->Msg;
msg->Header.MessageType = ChannelMessageGpadlTeardown;
- msg->ChildRelId = Channel->OfferMsg.ChildRelId;
- msg->Gpadl = GpadlHandle;
+ msg->ChildRelId = channel->OfferMsg.ChildRelId;
+ msg->Gpadl = gpadlhandle;
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
list_add_tail(&info->MsgListEntry,
@@ -636,9 +587,9 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
}
/*
- * VmbusChannelClose - Close the specified channel
+ * vmbuschannel_close - Close the specified channel
*/
-void VmbusChannelClose(struct vmbus_channel *Channel)
+void vmbuschannel_close(struct vmbus_channel *channel)
{
struct vmbus_channel_close_channel *msg;
struct vmbus_channel_msginfo *info;
@@ -646,8 +597,8 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
int ret;
/* Stop callback and cancel the timer asap */
- Channel->OnChannelCallback = NULL;
- del_timer_sync(&Channel->poll_timer);
+ channel->OnChannelCallback = NULL;
+ del_timer_sync(&channel->poll_timer);
/* Send a closing message */
info = kmalloc(sizeof(*info) +
@@ -661,7 +612,7 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
msg = (struct vmbus_channel_close_channel *)info->Msg;
msg->Header.MessageType = ChannelMessageCloseChannel;
- msg->ChildRelId = Channel->OfferMsg.ChildRelId;
+ msg->ChildRelId = channel->OfferMsg.ChildRelId;
ret = VmbusPostMessage(msg, sizeof(struct vmbus_channel_close_channel));
if (ret != 0) {
@@ -670,17 +621,17 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
}
/* Tear down the gpadl for the channel's ring buffer */
- if (Channel->RingBufferGpadlHandle)
- VmbusChannelTeardownGpadl(Channel,
- Channel->RingBufferGpadlHandle);
+ if (channel->RingBufferGpadlHandle)
+ vmbuschannel_teardowngpadl(channel,
+ channel->RingBufferGpadlHandle);
/* TODO: Send a msg to release the childRelId */
/* Cleanup the ring buffers for this channel */
- RingBufferCleanup(&Channel->Outbound);
- RingBufferCleanup(&Channel->Inbound);
+ RingBufferCleanup(&channel->Outbound);
+ RingBufferCleanup(&channel->Inbound);
- osd_PageFree(Channel->RingBufferPages, Channel->RingBufferPageCount);
+ osd_PageFree(channel->RingBufferPages, channel->RingBufferPageCount);
kfree(info);
@@ -690,21 +641,21 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
* caller will free the channel
*/
- if (Channel->State == CHANNEL_OPEN_STATE) {
+ if (channel->State == CHANNEL_OPEN_STATE) {
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
- list_del(&Channel->ListEntry);
+ list_del(&channel->ListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
- FreeVmbusChannel(Channel);
+ FreeVmbusChannel(channel);
}
}
/**
- * VmbusChannelSendPacket() - Send the specified buffer on the given channel
- * @Channel: Pointer to vmbus_channel structure.
- * @Buffer: Pointer to the buffer you want to receive the data into.
- * @BufferLen: Maximum size of what the the buffer will hold
- * @RequestId: Identifier of the request
+ * vmbuschannel_sendpacket() - Send the specified buffer on the given channel
+ * @channel: Pointer to vmbus_channel structure.
+ * @buffer: Pointer to the buffer you want to receive the data into.
+ * @bufferlen: Maximum size of what the the buffer will hold
+ * @requestid: Identifier of the request
* @vmbus_packet_type: Type of packet that is being send e.g. negotiate, time
* packet etc.
*
@@ -713,192 +664,192 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
*
* Mainly used by Hyper-V drivers.
*/
-int VmbusChannelSendPacket(struct vmbus_channel *Channel, const void *Buffer,
- u32 BufferLen, u64 RequestId,
- enum vmbus_packet_type Type, u32 Flags)
+int vmbuschannel_sendpacket(struct vmbus_channel *channel, const void *buffer,
+ u32 bufferlen, u64 requestid,
+ enum vmbus_packet_type type, u32 flags)
{
struct vmpacket_descriptor desc;
- u32 packetLen = sizeof(struct vmpacket_descriptor) + BufferLen;
+ u32 packetLen = sizeof(struct vmpacket_descriptor) + bufferlen;
u32 packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
struct scatterlist bufferList[3];
u64 alignedData = 0;
int ret;
DPRINT_DBG(VMBUS, "channel %p buffer %p len %d",
- Channel, Buffer, BufferLen);
+ channel, buffer, bufferlen);
- DumpVmbusChannel(Channel);
+ dumpvmbuschannel(channel);
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
- desc.Type = Type; /* VmbusPacketTypeDataInBand; */
- desc.Flags = Flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
+ desc.Type = type; /* VmbusPacketTypeDataInBand; */
+ desc.Flags = flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
/* in 8-bytes granularity */
desc.DataOffset8 = sizeof(struct vmpacket_descriptor) >> 3;
desc.Length8 = (u16)(packetLenAligned >> 3);
- desc.TransactionId = RequestId;
+ desc.TransactionId = requestid;
sg_init_table(bufferList, 3);
sg_set_buf(&bufferList[0], &desc, sizeof(struct vmpacket_descriptor));
- sg_set_buf(&bufferList[1], Buffer, BufferLen);
+ sg_set_buf(&bufferList[1], buffer, bufferlen);
sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
- ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+ ret = RingBufferWrite(&channel->Outbound, bufferList, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
- VmbusChannelSetEvent(Channel);
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ vmbuschannel_setevent(channel);
return ret;
}
-EXPORT_SYMBOL(VmbusChannelSendPacket);
+EXPORT_SYMBOL(vmbuschannel_sendpacket);
/*
- * VmbusChannelSendPacketPageBuffer - Send a range of single-page buffer
+ * vmbuschannel_sendpacketpagebuffer - Send a range of single-page buffer
* packets using a GPADL Direct packet type.
*/
-int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel,
- struct hv_page_buffer PageBuffers[],
- u32 PageCount, void *Buffer, u32 BufferLen,
- u64 RequestId)
+int vmbuschannel_sendpacketpagebuffer(struct vmbus_channel *channel,
+ struct hv_page_buffer pagebuffers[],
+ u32 pagecount, void *buffer, u32 bufferlen,
+ u64 requestid)
{
int ret;
int i;
struct vmbus_channel_packet_page_buffer desc;
- u32 descSize;
- u32 packetLen;
- u32 packetLenAligned;
- struct scatterlist bufferList[3];
- u64 alignedData = 0;
+ u32 descsize;
+ u32 packetlen;
+ u32 packetlenaligned;
+ struct scatterlist bufferlist[3];
+ u64 aligneddata = 0;
- if (PageCount > MAX_PAGE_BUFFER_COUNT)
+ if (pagecount > MAX_PAGE_BUFFER_COUNT)
return -EINVAL;
- DumpVmbusChannel(Channel);
+ dumpvmbuschannel(channel);
/*
* Adjust the size down since vmbus_channel_packet_page_buffer is the
* largest size we support
*/
- descSize = sizeof(struct vmbus_channel_packet_page_buffer) -
- ((MAX_PAGE_BUFFER_COUNT - PageCount) *
+ descsize = sizeof(struct vmbus_channel_packet_page_buffer) -
+ ((MAX_PAGE_BUFFER_COUNT - pagecount) *
sizeof(struct hv_page_buffer));
- packetLen = descSize + BufferLen;
- packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
+ packetlen = descsize + bufferlen;
+ packetlenaligned = ALIGN_UP(packetlen, sizeof(u64));
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
desc.type = VmbusPacketTypeDataUsingGpaDirect;
desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
- desc.dataoffset8 = descSize >> 3; /* in 8-bytes grandularity */
- desc.length8 = (u16)(packetLenAligned >> 3);
- desc.transactionid = RequestId;
- desc.rangecount = PageCount;
-
- for (i = 0; i < PageCount; i++) {
- desc.range[i].Length = PageBuffers[i].Length;
- desc.range[i].Offset = PageBuffers[i].Offset;
- desc.range[i].Pfn = PageBuffers[i].Pfn;
+ desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
+ desc.length8 = (u16)(packetlenaligned >> 3);
+ desc.transactionid = requestid;
+ desc.rangecount = pagecount;
+
+ for (i = 0; i < pagecount; i++) {
+ desc.range[i].Length = pagebuffers[i].Length;
+ desc.range[i].Offset = pagebuffers[i].Offset;
+ desc.range[i].Pfn = pagebuffers[i].Pfn;
}
- sg_init_table(bufferList, 3);
- sg_set_buf(&bufferList[0], &desc, descSize);
- sg_set_buf(&bufferList[1], Buffer, BufferLen);
- sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
+ sg_init_table(bufferlist, 3);
+ sg_set_buf(&bufferlist[0], &desc, descsize);
+ sg_set_buf(&bufferlist[1], buffer, bufferlen);
+ sg_set_buf(&bufferlist[2], &aligneddata, packetlenaligned - packetlen);
- ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+ ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
- VmbusChannelSetEvent(Channel);
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ vmbuschannel_setevent(channel);
return ret;
}
/*
- * VmbusChannelSendPacketMultiPageBuffer - Send a multi-page buffer packet
+ * vmbuschannel_sendpacketmultipagebuffer - Send a multi-page buffer packet
* using a GPADL Direct packet type.
*/
-int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel,
- struct hv_multipage_buffer *MultiPageBuffer,
- void *Buffer, u32 BufferLen, u64 RequestId)
+int vmbuschannel_sendpacketmultipagebuffer(struct vmbus_channel *channel,
+ struct hv_multipage_buffer *multipagebuffer,
+ void *buffer, u32 bufferlen, u64 requestid)
{
int ret;
struct vmbus_channel_packet_multipage_buffer desc;
- u32 descSize;
- u32 packetLen;
- u32 packetLenAligned;
- struct scatterlist bufferList[3];
- u64 alignedData = 0;
- u32 PfnCount = NUM_PAGES_SPANNED(MultiPageBuffer->Offset,
- MultiPageBuffer->Length);
+ u32 descsize;
+ u32 packetlen;
+ u32 packetlenaligned;
+ struct scatterlist bufferlist[3];
+ u64 aligneddata = 0;
+ u32 pfncount = NUM_PAGES_SPANNED(multipagebuffer->Offset,
+ multipagebuffer->Length);
- DumpVmbusChannel(Channel);
+ dumpvmbuschannel(channel);
DPRINT_DBG(VMBUS, "data buffer - offset %u len %u pfn count %u",
- MultiPageBuffer->Offset, MultiPageBuffer->Length, PfnCount);
+ multipagebuffer->Offset, multipagebuffer->Length, pfncount);
- if ((PfnCount < 0) || (PfnCount > MAX_MULTIPAGE_BUFFER_COUNT))
+ if ((pfncount < 0) || (pfncount > MAX_MULTIPAGE_BUFFER_COUNT))
return -EINVAL;
/*
* Adjust the size down since vmbus_channel_packet_multipage_buffer is
* the largest size we support
*/
- descSize = sizeof(struct vmbus_channel_packet_multipage_buffer) -
- ((MAX_MULTIPAGE_BUFFER_COUNT - PfnCount) *
+ descsize = sizeof(struct vmbus_channel_packet_multipage_buffer) -
+ ((MAX_MULTIPAGE_BUFFER_COUNT - pfncount) *
sizeof(u64));
- packetLen = descSize + BufferLen;
- packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
+ packetlen = descsize + bufferlen;
+ packetlenaligned = ALIGN_UP(packetlen, sizeof(u64));
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
desc.type = VmbusPacketTypeDataUsingGpaDirect;
desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
- desc.dataoffset8 = descSize >> 3; /* in 8-bytes grandularity */
- desc.length8 = (u16)(packetLenAligned >> 3);
- desc.transactionid = RequestId;
+ desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
+ desc.length8 = (u16)(packetlenaligned >> 3);
+ desc.transactionid = requestid;
desc.rangecount = 1;
- desc.range.Length = MultiPageBuffer->Length;
- desc.range.Offset = MultiPageBuffer->Offset;
+ desc.range.Length = multipagebuffer->Length;
+ desc.range.Offset = multipagebuffer->Offset;
- memcpy(desc.range.PfnArray, MultiPageBuffer->PfnArray,
- PfnCount * sizeof(u64));
+ memcpy(desc.range.PfnArray, multipagebuffer->PfnArray,
+ pfncount * sizeof(u64));
- sg_init_table(bufferList, 3);
- sg_set_buf(&bufferList[0], &desc, descSize);
- sg_set_buf(&bufferList[1], Buffer, BufferLen);
- sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
+ sg_init_table(bufferlist, 3);
+ sg_set_buf(&bufferlist[0], &desc, descsize);
+ sg_set_buf(&bufferlist[1], buffer, bufferlen);
+ sg_set_buf(&bufferlist[2], &aligneddata, packetlenaligned - packetlen);
- ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+ ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
- VmbusChannelSetEvent(Channel);
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ vmbuschannel_setevent(channel);
return ret;
}
/**
- * VmbusChannelRecvPacket() - Retrieve the user packet on the specified channel
- * @Channel: Pointer to vmbus_channel structure.
- * @Buffer: Pointer to the buffer you want to receive the data into.
- * @BufferLen: Maximum size of what the the buffer will hold
- * @BufferActualLen: The actual size of the data after it was received
- * @RequestId: Identifier of the request
+ * vmbuschannel_recvpacket() - Retrieve the user packet on the specified channel
+ * @channel: Pointer to vmbus_channel structure.
+ * @buffer: Pointer to the buffer you want to receive the data into.
+ * @bufferlen: Maximum size of what the the buffer will hold
+ * @bufferactuallen: The actual size of the data after it was received
+ * @requestid: Identifier of the request
*
* Receives directly from the hyper-v vmbus and puts the data it received
* into Buffer. This will receive the data unparsed from hyper-v.
*
* Mainly used by Hyper-V drivers.
*/
-int VmbusChannelRecvPacket(struct vmbus_channel *Channel, void *Buffer,
- u32 BufferLen, u32 *BufferActualLen, u64 *RequestId)
+int vmbuschannel_recvpacket(struct vmbus_channel *channel, void *buffer,
+ u32 bufferlen, u32 *bufferactuallen, u64 *requestid)
{
struct vmpacket_descriptor desc;
u32 packetLen;
@@ -906,15 +857,15 @@ int VmbusChannelRecvPacket(struct vmbus_channel *Channel, void *Buffer,
int ret;
unsigned long flags;
- *BufferActualLen = 0;
- *RequestId = 0;
+ *bufferactuallen = 0;
+ *requestid = 0;
- spin_lock_irqsave(&Channel->inbound_lock, flags);
+ spin_lock_irqsave(&channel->inbound_lock, flags);
- ret = RingBufferPeek(&Channel->Inbound, &desc,
+ ret = RingBufferPeek(&channel->Inbound, &desc,
sizeof(struct vmpacket_descriptor));
if (ret != 0) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
/* DPRINT_DBG(VMBUS, "nothing to read!!"); */
return 0;
@@ -928,53 +879,53 @@ int VmbusChannelRecvPacket(struct vmbus_channel *Channel, void *Buffer,
DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
"flag %d tid %llx pktlen %d datalen %d> ",
- Channel, Channel->OfferMsg.ChildRelId, desc.Type,
+ channel, channel->OfferMsg.ChildRelId, desc.Type,
desc.Flags, desc.TransactionId, packetLen, userLen);
- *BufferActualLen = userLen;
+ *bufferactuallen = userLen;
- if (userLen > BufferLen) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ if (userLen > bufferlen) {
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
DPRINT_ERR(VMBUS, "buffer too small - got %d needs %d",
- BufferLen, userLen);
+ bufferlen, userLen);
return -1;
}
- *RequestId = desc.TransactionId;
+ *requestid = desc.TransactionId;
/* Copy over the packet to the user buffer */
- ret = RingBufferRead(&Channel->Inbound, Buffer, userLen,
+ ret = RingBufferRead(&channel->Inbound, buffer, userLen,
(desc.DataOffset8 << 3));
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
return 0;
}
-EXPORT_SYMBOL(VmbusChannelRecvPacket);
+EXPORT_SYMBOL(vmbuschannel_recvpacket);
/*
- * VmbusChannelRecvPacketRaw - Retrieve the raw packet on the specified channel
+ * vmbuschannel_recvpacketraw - Retrieve the raw packet on the specified channel
*/
-int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer,
- u32 BufferLen, u32 *BufferActualLen,
- u64 *RequestId)
+int vmbuschannel_recvpacketraw(struct vmbus_channel *channel, void *buffer,
+ u32 bufferlen, u32 *bufferactuallen,
+ u64 *requestid)
{
struct vmpacket_descriptor desc;
- u32 packetLen;
- u32 userLen;
+ u32 packetlen;
+ u32 userlen;
int ret;
unsigned long flags;
- *BufferActualLen = 0;
- *RequestId = 0;
+ *bufferactuallen = 0;
+ *requestid = 0;
- spin_lock_irqsave(&Channel->inbound_lock, flags);
+ spin_lock_irqsave(&channel->inbound_lock, flags);
- ret = RingBufferPeek(&Channel->Inbound, &desc,
+ ret = RingBufferPeek(&channel->Inbound, &desc,
sizeof(struct vmpacket_descriptor));
if (ret != 0) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
/* DPRINT_DBG(VMBUS, "nothing to read!!"); */
return 0;
@@ -982,50 +933,50 @@ int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer,
/* VmbusChannelClearEvent(Channel); */
- packetLen = desc.Length8 << 3;
- userLen = packetLen - (desc.DataOffset8 << 3);
+ packetlen = desc.Length8 << 3;
+ userlen = packetlen - (desc.DataOffset8 << 3);
DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
"flag %d tid %llx pktlen %d datalen %d> ",
- Channel, Channel->OfferMsg.ChildRelId, desc.Type,
- desc.Flags, desc.TransactionId, packetLen, userLen);
+ channel, channel->OfferMsg.ChildRelId, desc.Type,
+ desc.Flags, desc.TransactionId, packetlen, userlen);
- *BufferActualLen = packetLen;
+ *bufferactuallen = packetlen;
- if (packetLen > BufferLen) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ if (packetlen > bufferlen) {
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
DPRINT_ERR(VMBUS, "buffer too small - needed %d bytes but "
- "got space for only %d bytes", packetLen, BufferLen);
+ "got space for only %d bytes", packetlen, bufferlen);
return -2;
}
- *RequestId = desc.TransactionId;
+ *requestid = desc.TransactionId;
/* Copy over the entire packet to the user buffer */
- ret = RingBufferRead(&Channel->Inbound, Buffer, packetLen, 0);
+ ret = RingBufferRead(&channel->Inbound, buffer, packetlen, 0);
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
return 0;
}
/*
- * VmbusChannelOnChannelEvent - Channel event callback
+ * vmbuschannel_onchannelevent - Channel event callback
*/
-void VmbusChannelOnChannelEvent(struct vmbus_channel *Channel)
+void vmbuschannel_onchannelevent(struct vmbus_channel *channel)
{
- DumpVmbusChannel(Channel);
+ dumpvmbuschannel(channel);
/* ASSERT(Channel->OnChannelCallback); */
- Channel->OnChannelCallback(Channel->ChannelCallbackContext);
+ channel->OnChannelCallback(channel->ChannelCallbackContext);
- mod_timer(&Channel->poll_timer, jiffies + usecs_to_jiffies(100));
+ mod_timer(&channel->poll_timer, jiffies + usecs_to_jiffies(100));
}
/*
- * VmbusChannelOnTimer - Timer event callback
+ * vmbuschannel_ontimer - Timer event callback
*/
-void VmbusChannelOnTimer(unsigned long data)
+void vmbuschannel_ontimer(unsigned long data)
{
struct vmbus_channel *channel = (struct vmbus_channel *)data;
@@ -1036,7 +987,7 @@ void VmbusChannelOnTimer(unsigned long data)
/*
* DumpVmbusChannel - Dump vmbus channel info to the console
*/
-static void DumpVmbusChannel(struct vmbus_channel *Channel)
+static void dumpvmbuschannel(struct vmbus_channel *Channel)
{
DPRINT_DBG(VMBUS, "Channel (%d)", Channel->OfferMsg.ChildRelId);
DumpRingInfo(&Channel->Outbound, "Outbound ");
diff --git a/drivers/staging/hv/channel.h b/drivers/staging/hv/channel.h
index 85c5079..50ee36a 100644
--- a/drivers/staging/hv/channel.h
+++ b/drivers/staging/hv/channel.h
@@ -52,61 +52,61 @@ struct vmbus_channel_packet_multipage_buffer {
} __attribute__((packed));
-extern int VmbusChannelOpen(struct vmbus_channel *channel,
- u32 SendRingBufferSize,
- u32 RecvRingBufferSize,
- void *UserData,
- u32 UserDataLen,
- void(*OnChannelCallback)(void *context),
- void *Context);
-
-extern void VmbusChannelClose(struct vmbus_channel *channel);
-
-extern int VmbusChannelSendPacket(struct vmbus_channel *channel,
- const void *Buffer,
- u32 BufferLen,
- u64 RequestId,
- enum vmbus_packet_type Type,
- u32 Flags);
-
-extern int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *channel,
- struct hv_page_buffer PageBuffers[],
- u32 PageCount,
- void *Buffer,
- u32 BufferLen,
- u64 RequestId);
-
-extern int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *channel,
+extern int vmbuschannel_open(struct vmbus_channel *channel,
+ u32 sendringbuffersize,
+ u32 recvringbuffersize,
+ void *userdata,
+ u32 userdatalen,
+ void(*onchannelcallback)(void *context),
+ void *context);
+
+extern void vmbuschannel_close(struct vmbus_channel *channel);
+
+extern int vmbuschannel_sendpacket(struct vmbus_channel *channel,
+ const void *buffer,
+ u32 bufferlen,
+ u64 requestid,
+ enum vmbus_packet_type type,
+ u32 flags);
+
+extern int vmbuschannel_sendpacketpagebuffer(struct vmbus_channel *channel,
+ struct hv_page_buffer pagebuffers[],
+ u32 pagecount,
+ void *buffer,
+ u32 bufferlen,
+ u64 requestid);
+
+extern int vmbuschannel_sendpacketmultipagebuffer(struct vmbus_channel *channel,
struct hv_multipage_buffer *mpb,
- void *Buffer,
- u32 BufferLen,
- u64 RequestId);
+ void *buffer,
+ u32 bufferlen,
+ u64 requestid);
-extern int VmbusChannelEstablishGpadl(struct vmbus_channel *channel,
- void *Kbuffer,
- u32 Size,
- u32 *GpadlHandle);
+extern int vmbuschannel_establishgpadl(struct vmbus_channel *channel,
+ void *kbuffer,
+ u32 size,
+ u32 *gpadlhandle);
-extern int VmbusChannelTeardownGpadl(struct vmbus_channel *channel,
- u32 GpadlHandle);
+extern int vmbuschannel_teardowngpadl(struct vmbus_channel *channel,
+ u32 gpadlhandle);
-extern int VmbusChannelRecvPacket(struct vmbus_channel *channel,
- void *Buffer,
- u32 BufferLen,
- u32 *BufferActualLen,
- u64 *RequestId);
+extern int vmbuschannel_recvpacket(struct vmbus_channel *channel,
+ void *buffer,
+ u32 bufferlen,
+ u32 *bufferactuallen,
+ u64 *requestid);
-extern int VmbusChannelRecvPacketRaw(struct vmbus_channel *channel,
- void *Buffer,
- u32 BufferLen,
- u32 *BufferActualLen,
- u64 *RequestId);
+extern int vmbuschannel_recvpacketraw(struct vmbus_channel *channel,
+ void *buffer,
+ u32 bufferlen,
+ u32 *bufferactuallen,
+ u64 *requestid);
-extern void VmbusChannelOnChannelEvent(struct vmbus_channel *channel);
+extern void vmbuschannel_onchannelevent(struct vmbus_channel *channel);
-extern void VmbusChannelGetDebugInfo(struct vmbus_channel *channel,
+extern void vmbuschannel_getdebuginfo(struct vmbus_channel *channel,
struct vmbus_channel_debug_info *debug);
-extern void VmbusChannelOnTimer(unsigned long data);
+extern void vmbuschannel_ontimer(unsigned long data);
#endif /* _CHANNEL_H_ */
diff --git a/drivers/staging/hv/channel_interface.c b/drivers/staging/hv/channel_interface.c
index 3f6a1cb..68c374b 100644
--- a/drivers/staging/hv/channel_interface.c
+++ b/drivers/staging/hv/channel_interface.c
@@ -31,21 +31,21 @@ static int IVmbusChannelOpen(struct hv_device *device, u32 SendBufferSize,
void (*ChannelCallback)(void *context),
void *Context)
{
- return VmbusChannelOpen(device->context, SendBufferSize,
+ return vmbuschannel_open(device->context, SendBufferSize,
RecvRingBufferSize, UserData, UserDataLen,
ChannelCallback, Context);
}
static void IVmbusChannelClose(struct hv_device *device)
{
- VmbusChannelClose(device->context);
+ vmbuschannel_close(device->context);
}
static int IVmbusChannelSendPacket(struct hv_device *device, const void *Buffer,
u32 BufferLen, u64 RequestId, u32 Type,
u32 Flags)
{
- return VmbusChannelSendPacket(device->context, Buffer, BufferLen,
+ return vmbuschannel_sendpacket(device->context, Buffer, BufferLen,
RequestId, Type, Flags);
}
@@ -54,7 +54,7 @@ static int IVmbusChannelSendPacketPageBuffer(struct hv_device *device,
u32 PageCount, void *Buffer,
u32 BufferLen, u64 RequestId)
{
- return VmbusChannelSendPacketPageBuffer(device->context, PageBuffers,
+ return vmbuschannel_sendpacketpagebuffer(device->context, PageBuffers,
PageCount, Buffer, BufferLen,
RequestId);
}
@@ -63,7 +63,7 @@ static int IVmbusChannelSendPacketMultiPageBuffer(struct hv_device *device,
struct hv_multipage_buffer *MultiPageBuffer,
void *Buffer, u32 BufferLen, u64 RequestId)
{
- return VmbusChannelSendPacketMultiPageBuffer(device->context,
+ return vmbuschannel_sendpacketmultipagebuffer(device->context,
MultiPageBuffer, Buffer,
BufferLen, RequestId);
}
@@ -72,7 +72,7 @@ static int IVmbusChannelRecvPacket(struct hv_device *device, void *Buffer,
u32 BufferLen, u32 *BufferActualLen,
u64 *RequestId)
{
- return VmbusChannelRecvPacket(device->context, Buffer, BufferLen,
+ return vmbuschannel_recvpacket(device->context, Buffer, BufferLen,
BufferActualLen, RequestId);
}
@@ -80,20 +80,20 @@ static int IVmbusChannelRecvPacketRaw(struct hv_device *device, void *Buffer,
u32 BufferLen, u32 *BufferActualLen,
u64 *RequestId)
{
- return VmbusChannelRecvPacketRaw(device->context, Buffer, BufferLen,
+ return vmbuschannel_recvpacketraw(device->context, Buffer, BufferLen,
BufferActualLen, RequestId);
}
static int IVmbusChannelEstablishGpadl(struct hv_device *device, void *Buffer,
u32 BufferLen, u32 *GpadlHandle)
{
- return VmbusChannelEstablishGpadl(device->context, Buffer, BufferLen,
+ return vmbuschannel_establishgpadl(device->context, Buffer, BufferLen,
GpadlHandle);
}
static int IVmbusChannelTeardownGpadl(struct hv_device *device, u32 GpadlHandle)
{
- return VmbusChannelTeardownGpadl(device->context, GpadlHandle);
+ return vmbuschannel_teardowngpadl(device->context, GpadlHandle);
}
@@ -105,7 +105,7 @@ void GetChannelInfo(struct hv_device *device, struct hv_device_info *info)
if (!device->context)
return;
- VmbusChannelGetDebugInfo(device->context, &debugInfo);
+ vmbuschannel_getdebuginfo(device->context, &debugInfo);
info->ChannelId = debugInfo.RelId;
info->ChannelState = debugInfo.State;
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index 6ccf505..55bc2a4 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -172,7 +172,7 @@ void chn_cb_negotiate(void *context)
buflen = PAGE_SIZE;
buf = kmalloc(buflen, GFP_ATOMIC);
- VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid);
+ vmbuschannel_recvpacket(channel, buf, buflen, &recvlen, &requestid);
if (recvlen > 0) {
icmsghdrp = (struct icmsg_hdr *)&buf[
@@ -183,7 +183,7 @@ void chn_cb_negotiate(void *context)
icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
| ICMSGHDRFLAG_RESPONSE;
- VmbusChannelSendPacket(channel, buf,
+ vmbuschannel_sendpacket(channel, buf,
recvlen, requestid,
VmbusPacketTypeDataInBand, 0);
}
@@ -249,7 +249,7 @@ struct vmbus_channel *AllocVmbusChannel(void)
init_timer(&channel->poll_timer);
channel->poll_timer.data = (unsigned long)channel;
- channel->poll_timer.function = VmbusChannelOnTimer;
+ channel->poll_timer.function = vmbuschannel_ontimer;
channel->ControlWQ = create_workqueue("hv_vmbus_ctl");
if (!channel->ControlWQ) {
@@ -392,7 +392,7 @@ static void VmbusChannelProcessOffer(void *context)
if (memcmp(&newChannel->OfferMsg.Offer.InterfaceType,
&hv_cb_utils[cnt].data,
sizeof(struct hv_guid)) == 0 &&
- VmbusChannelOpen(newChannel, 2 * PAGE_SIZE,
+ vmbuschannel_open(newChannel, 2 * PAGE_SIZE,
2 * PAGE_SIZE, NULL, 0,
hv_cb_utils[cnt].callback,
newChannel) == 0) {
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index 1f4d668..508572f 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -254,10 +254,10 @@ static void VmbusProcessChannelEvent(void *context)
channel = GetChannelFromRelId(relId);
if (channel) {
- VmbusChannelOnChannelEvent(channel);
+ vmbuschannel_onchannelevent(channel);
/*
* WorkQueueQueueWorkItem(channel->dataWorkQueue,
- * VmbusChannelOnChannelEvent,
+ * vmbuschannel_onchannelevent,
* (void*)channel);
*/
} else {
diff --git a/drivers/staging/hv/hv_utils.c b/drivers/staging/hv/hv_utils.c
index 6eb79fe..2416f50 100644
--- a/drivers/staging/hv/hv_utils.c
+++ b/drivers/staging/hv/hv_utils.c
@@ -55,7 +55,7 @@ static void shutdown_onchannelcallback(void *context)
buflen = PAGE_SIZE;
buf = kmalloc(buflen, GFP_ATOMIC);
- VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid);
+ vmbuschannel_recvpacket(channel, buf, buflen, &recvlen, &requestid);
if (recvlen > 0) {
DPRINT_DBG(VMBUS, "shutdown packet: len=%d, requestid=%lld",
@@ -93,7 +93,7 @@ static void shutdown_onchannelcallback(void *context)
icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
| ICMSGHDRFLAG_RESPONSE;
- VmbusChannelSendPacket(channel, buf,
+ vmbuschannel_sendpacket(channel, buf,
recvlen, requestid,
VmbusPacketTypeDataInBand, 0);
}
@@ -159,7 +159,7 @@ static void timesync_onchannelcallback(void *context)
buflen = PAGE_SIZE;
buf = kmalloc(buflen, GFP_ATOMIC);
- VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid);
+ vmbuschannel_recvpacket(channel, buf, buflen, &recvlen, &requestid);
if (recvlen > 0) {
DPRINT_DBG(VMBUS, "timesync packet: recvlen=%d, requestid=%lld",
@@ -180,7 +180,7 @@ static void timesync_onchannelcallback(void *context)
icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
| ICMSGHDRFLAG_RESPONSE;
- VmbusChannelSendPacket(channel, buf,
+ vmbuschannel_sendpacket(channel, buf,
recvlen, requestid,
VmbusPacketTypeDataInBand, 0);
}
@@ -205,7 +205,7 @@ static void heartbeat_onchannelcallback(void *context)
buflen = PAGE_SIZE;
buf = kmalloc(buflen, GFP_ATOMIC);
- VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid);
+ vmbuschannel_recvpacket(channel, buf, buflen, &recvlen, &requestid);
if (recvlen > 0) {
DPRINT_DBG(VMBUS, "heartbeat packet: len=%d, requestid=%lld",
@@ -233,7 +233,7 @@ static void heartbeat_onchannelcallback(void *context)
icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
| ICMSGHDRFLAG_RESPONSE;
- VmbusChannelSendPacket(channel, buf,
+ vmbuschannel_sendpacket(channel, buf,
recvlen, requestid,
VmbusPacketTypeDataInBand, 0);
}
--
1.6.3.2
^ permalink raw reply related
* Re: [PATCH 2/2] staging: hv: Remove camel cases from vmbus channel functions
From: Greg KH @ 2010-09-20 23:29 UTC (permalink / raw)
To: Haiyang Zhang
Cc: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
'virtualization@lists.osdl.org', 'gregkh@suse.de',
Hank Janssen
In-Reply-To: <1FB5E1D5CA062146B38059374562DF7289E499E4@TK5EX14MBXC121.redmond.corp.microsoft.com>
On Mon, Sep 20, 2010 at 09:13:39PM +0000, Haiyang Zhang wrote:
> From: Haiyang Zhang <haiyangz@microsoft.com>
>
> Remove camel cases from vmbus channel functions
> Converted the function names, local variables to lower cases.
Nice try, but you can do better :)
> /* Internal routines */
> -static int VmbusChannelCreateGpadlHeader(
> - void *Kbuffer, /* must be phys and virt contiguous */
> - u32 Size, /* page-size multiple */
> - struct vmbus_channel_msginfo **msgInfo,
> - u32 *MessageCount);
> -static void DumpVmbusChannel(struct vmbus_channel *channel);
> -static void VmbusChannelSetEvent(struct vmbus_channel *channel);
> +static int vmbuschannel_creategpadlheader(
> + void *kbuffer, /* must be phys and virt contiguous */
> + u32 size, /* page-size multiple */
> + struct vmbus_channel_msginfo **msginfo,
> + u32 *messagecount);
> +static void dumpvmbuschannel(struct vmbus_channel *channel);
> +static void vmbuschannel_setevent(struct vmbus_channel *channel);
Internal functions are that, internal, why the verbosity for them? Why
not try the following:
create_gpad_header()
dump_channel()
set_event()
Looks almost readable, right?
> -#if 0
> -static void DumpMonitorPage(struct hv_monitor_page *MonitorPage)
> -{
> - int i = 0;
> - int j = 0;
> -
> - DPRINT_DBG(VMBUS, "monitorPage - %p, trigger state - %d",
> - MonitorPage, MonitorPage->TriggerState);
> -
> - for (i = 0; i < 4; i++)
> - DPRINT_DBG(VMBUS, "trigger group (%d) - %llx", i,
> - MonitorPage->TriggerGroup[i].AsUINT64);
> -
> - for (i = 0; i < 4; i++) {
> - for (j = 0; j < 32; j++) {
> - DPRINT_DBG(VMBUS, "latency (%d)(%d) - %llx", i, j,
> - MonitorPage->Latency[i][j]);
> - }
> - }
> - for (i = 0; i < 4; i++) {
> - for (j = 0; j < 32; j++) {
> - DPRINT_DBG(VMBUS, "param-conn id (%d)(%d) - %d", i, j,
> - MonitorPage->Parameter[i][j].ConnectionId.Asu32);
> - DPRINT_DBG(VMBUS, "param-flag (%d)(%d) - %d", i, j,
> - MonitorPage->Parameter[i][j].FlagNumber);
> - }
> - }
> -}
> -#endif
Nice fix, but, it has nothing to do with the camelcase changes in this
file.
Please, again, one-patch-per-logical-change. I'm getting tired of
repeating this...
> /*
> * VmbusChannelSetEvent - Trigger an event notification on the specified
> * channel.
> */
> -static void VmbusChannelSetEvent(struct vmbus_channel *Channel)
> +static void vmbuschannel_setevent(struct vmbus_channel *Channel)
You forgot to change the function comment name as well.
> -#if 0
> -static void VmbusChannelClearEvent(struct vmbus_channel *channel)
> -{
> - struct hv_monitor_page *monitorPage;
> -
> - if (Channel->OfferMsg.MonitorAllocated) {
> - /* Each u32 represents 32 channels */
> - clear_bit(Channel->OfferMsg.ChildRelId & 31,
> - (unsigned long *)gVmbusConnection.SendInterruptPage +
> - (Channel->OfferMsg.ChildRelId >> 5));
> -
> - monitorPage =
> - (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
> - monitorPage++; /* Get the child to parent monitor page */
> -
> - clear_bit(Channel->MonitorBit,
> - (unsigned long *)&monitorPage->TriggerGroup
> - [Channel->MonitorGroup].Pending);
> - }
> -}
> -
> -#endif
Again a different thing than the case changing.
> /*
> - * VmbusChannelGetDebugInfo -Retrieve various channel debug info
> + * vmbuschannel_getdebuginfo -Retrieve various channel debug info
> */
> -void VmbusChannelGetDebugInfo(struct vmbus_channel *Channel,
> - struct vmbus_channel_debug_info *DebugInfo)
> +void vmbuschannel_getdebuginfo(struct vmbus_channel *channel,
> + struct vmbus_channel_debug_info *debuginfo)
Do you really need the vmbuschannel prefix here?
How about hyperv_get_debuginfo()?
Or vmbus_get_debuginfo()?
Although you might get vmbus confused with the vme bus, right? Care to
find a consistant prefix for all hyperv bus functions and stick to it?
Oh, and what's wrong with "debug_info" instead of "debuginfo"? You
alredy have it split up in the structure name, consistancy is good.
> {
> struct hv_monitor_page *monitorPage;
> - u8 monitorGroup = (u8)Channel->OfferMsg.MonitorId / 32;
> - u8 monitorOffset = (u8)Channel->OfferMsg.MonitorId % 32;
> + u8 monitorGroup = (u8)channel->OfferMsg.MonitorId / 32;
> + u8 monitorOffset = (u8)channel->OfferMsg.MonitorId % 32;
> /* u32 monitorBit = 1 << monitorOffset; */
Function name changes are one thing.
Variable names are another thing.
Again, one patch per thing please.
It's easier to read and verify that everything is sane.
Please try this one again.
thanks,
greg k-h
^ permalink raw reply
* [PULL] virtio console fixes and lguest comment fix
From: Rusty Russell @ 2010-09-21 1:26 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Amit Shah, Eviatar Khen, linux-kernel, Virtualization List
The following changes since commit 2422084a94fcd5038406261b331672a13c92c050:
Linus Torvalds (1):
Merge branch 'for-linus' of git://git.kernel.org/.../mattst88/alpha-2.6
are available in the git repository at:
ssh://master.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus.git master
Amit Shah (1):
virtio: console: Prevent userspace from submitting NULL buffers
Hans de Goede (1):
virtio: console: Fix poll blocking even though there is data to read
Rusty Russell (1):
lguest: update comments to reflect LHCALL_LOAD_GDT_ENTRY.
arch/x86/lguest/boot.c | 13 ++++++++-----
drivers/char/virtio_console.c | 6 +++++-
2 files changed, 13 insertions(+), 6 deletions(-)
^ permalink raw reply
* RE: [PATCH 2/2] staging: hv: Remove camel cases from vmbus channel functions
From: Haiyang Zhang @ 2010-09-21 15:10 UTC (permalink / raw)
To: Greg KH
Cc: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
'virtualization@lists.osdl.org', 'gregkh@suse.de',
Hank Janssen
In-Reply-To: <20100920232921.GA31204@kroah.com>
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Monday, September 20, 2010 7:29 PM
> Function name changes are one thing.
>
> Variable names are another thing.
>
> Again, one patch per thing please.
>
> It's easier to read and verify that everything is sane.
>
> Please try this one again.
I will separate the variable names and function names into two patches,
And, incorporate your suggestions like - naming the functions as vmbus_*
instead of vmbus_channel_*, updating the comments, and etc..
Thanks,
- Haiyang
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox