Re: [PATCH] virtio_blk: fix race at module removal

2014-10-23 Thread Ming Lei
On Fri, Oct 24, 2014 at 12:12 AM, Michael S. Tsirkin wrote: > If a device appears while module is being removed, > driver will get a callback after we've given up > on the major number. > > In theory this means this major number can get reused > by something else, resulting in a conflict. Yes, th

[PATCH RFC] virtio_blk: WCE is assumed on under VIRTIO 1.0

2014-10-23 Thread Michael S. Tsirkin
Signed-off-by: Michael S. Tsirkin --- drivers/block/virtio_blk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index adfba9f..1f8b111 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -478,7

Re: [PATCH RFC 00/11] qemu: towards virtio-1 host support

2014-10-23 Thread Michael S. Tsirkin
On Tue, Oct 07, 2014 at 04:39:56PM +0200, Cornelia Huck wrote: > This patchset aims to get us some way to implement virtio-1 compliant > and transitional devices in qemu. Branch available at > > git://github.com/cohuck/qemu virtio-1 > > I've mainly focused on: > - endianness handling > - extended

[PATCH RFC 3/4] virtio_net: stricter short buffer length checks

2014-10-23 Thread Michael S. Tsirkin
Our buffer length check is not strict enough for mergeable buffers: buffer can still be shorter that header + address by 2 bytes. Fix that up. Signed-off-by: Michael S. Tsirkin --- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio_ne

[PATCH RFC 4/4] virtio_net: bigger header when VERSION_1 is set

2014-10-23 Thread Michael S. Tsirkin
With VERSION_1 virtio_net uses same header size whether mergeable buffers are enabled or not. Signed-off-by: Michael S. Tsirkin --- drivers/net/virtio_net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 9c6d50f..a2

[PATCH RFC 1/4] virtio_net: pass vi around

2014-10-23 Thread Michael S. Tsirkin
Too many places poke at [rs]q->vq->vdev->priv just to get the the vi structure. Let's just pass the pointer around: seems cleaner, and might even be faster. Signed-off-by: Michael S. Tsirkin --- drivers/net/virtio_net.c | 36 +++- 1 file changed, 19 insertions(+)

[PATCH RFC 2/4] virtio_net: get rid of virtio_net_hdr/skb_vnet_hdr

2014-10-23 Thread Michael S. Tsirkin
virtio 1.0 doesn't use virtio_net_hdr anymore, and in fact, it's not really useful since virtio_net_hdr_mrg_rxbuf includes that as the first field anyway. Let's drop it, precalculate header len and store within vi instead. This way we can also remove struct skb_vnet_hdr. Signed-off-by: Michael S

[PATCH RFC] tun: fix sparse warnings for virtio headers

2014-10-23 Thread Michael S. Tsirkin
Note: stub out endian-ness conversion for now. We'll add a flag to control it for BE guests later. Signed-off-by: Michael S. Tsirkin --- This will be needed once __virtio16 typedefs come in. drivers/net/tun.c | 34 +- 1 file changed, 17 insertions(+), 17 deletio

[PATCH] fixup! virtio: add legacy feature table support

2014-10-23 Thread Michael S. Tsirkin
the following is needed on top of v4 virtio 1.0 support that I sent. Will squash it in for v5. Signed-off-by: Michael S. Tsirkin --- drivers/virtio/virtio.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 85a164e..e9018b4 100644

[PATCH RFC v4 11/17] virtio: add legacy feature table support

2014-10-23 Thread Michael S. Tsirkin
virtio blk has some legacy feature bits that modern drivers must not negotiate, but are needed for old legacy hosts (e.g. that dn't support virtio scsi). Allow a separate legacy feature table for such cases. Signed-off-by: Michael S. Tsirkin --- include/linux/virtio.h | 4 drivers/virtio/

[PATCH RFC v4 13/17] virtio_blk: v1.0 support

2014-10-23 Thread Michael S. Tsirkin
Based on patch by Cornelia Huck. Note: for consistency, and to avoid sparse errors, convert all fields, even those no longer in use for virtio v1.0. Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck Signed-off-by: Michael S. Tsirkin --- include/

[PATCH RFC v4 12/17] virtio_net: v1.0 support

2014-10-23 Thread Michael S. Tsirkin
Based on patches by Rusty Russell, Cornelia Huck. Signed-off-by: Rusty Russell Signed-off-by: Cornelia Huck Signed-off-by: Michael S. Tsirkin --- include/uapi/linux/virtio_net.h | 15 --- drivers/net/virtio_net.c| 34 +- 2 files changed, 29 i

[PATCH RFC v4 04/17] virtio: add support for 64 bit features.

2014-10-23 Thread Michael S. Tsirkin
From: Rusty Russell Change the u32 to a u64, and make sure to use 1ULL everywhere! Cc: Brian Swetland Cc: Christian Borntraeger [Thomas Huth: fix up virtio-ccw get_features] Signed-off-by: Rusty Russell Signed-off-by: Cornelia Huck Acked-by: Pawel Moll Acked-by: Ohad Ben-Cohen Signed-off-

[PATCH RFC v4 08/17] virtio: allow transports to get avail/used addresses

2014-10-23 Thread Michael S. Tsirkin
From: Cornelia Huck For virtio-1, we can theoretically have a more complex virtqueue layout with avail and used buffers not on a contiguous memory area with the descriptor table. For now, it's fine for a transport driver to stay with the old layout: It needs, however, a way to access the location

[PATCH RFC v4 03/17] virtio: use u32, not bitmap for struct virtio_device's features

2014-10-23 Thread Michael S. Tsirkin
From: Rusty Russell It seemed like a good idea, but it's actually a pain when we get more than 32 feature bits. Just change it to a u32 for now. Cc: Brian Swetland Cc: Christian Borntraeger Signed-off-by: Rusty Russell Signed-off-by: Cornelia Huck Acked-by: Pawel Moll Acked-by: Ohad Ben-Co

[PATCH RFC v4 09/17] virtio: set FEATURES_OK

2014-10-23 Thread Michael S. Tsirkin
set FEATURES_OK as per virtio 1.0 spec Signed-off-by: Michael S. Tsirkin --- include/uapi/linux/virtio_config.h | 2 ++ drivers/virtio/virtio.c| 29 ++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/include/uapi/linux/virtio_config.h b/in

[PATCH RFC v4 10/17] virtio: simplify feature bit handling

2014-10-23 Thread Michael S. Tsirkin
Now that we use u64 for bits, we can simply & them together. Signed-off-by: Michael S. Tsirkin --- drivers/virtio/virtio.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index a3df817..0f44cff 100644 --- a/drivers/

[PATCH RFC v4 07/17] virtio_config: endian conversion for v1.0

2014-10-23 Thread Michael S. Tsirkin
We (ab)use virtio conversion functions for device-specific config space accesses. Reviewed-by: David Hildenbrand Signed-off-by: Rusty Russell Signed-off-by: Cornelia Huck Signed-off-by: Michael S. Tsirkin --- include/linux/virtio_config.h | 9 ++--- 1 file changed, 6 insertions(+), 3 dele

[PATCH RFC v4 06/17] virtio: make endian-ness depend on virtio 1.0

2014-10-23 Thread Michael S. Tsirkin
virtio 1.0 is LE, virtio without 1.0 is native endian. Signed-off-by: Michael S. Tsirkin --- include/linux/virtio_config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index 4bc2ebe..952b6d7 100644 --- a/inc

[PATCH RFC v4 05/17] virtio: add virtio 1.0 feature bit

2014-10-23 Thread Michael S. Tsirkin
Based on original patches by Rusty Russell, Thomas Huth and Cornelia Huck. Note: at this time, we do not negotiate this feature bit in core, drivers have to declare VERSION_1 support explicitly. After all drivers are converted, we will be able to move VERSION_1 to core and drop it from all driver

[PATCH RFC v4 01/17] virtio: memory access APIs

2014-10-23 Thread Michael S. Tsirkin
virtio 1.0 makes all memory structures LE, so we need APIs to conditionally do a byteswap on BE architectures. To make it easier to check code statically, add virtio specific types for multi-byte integers in memory. Add low level wrappers that do a byteswap conditionally, these will be useful e.g

[PATCH RFC v4 02/17] virtio_ring: switch to new memory access APIs

2014-10-23 Thread Michael S. Tsirkin
Use virtioXX_to_cpu and friends for access to all multibyte structures in memory. Note: this is intentionally mechanical. A follow-up patch will split long lines etc. Signed-off-by: Michael S. Tsirkin --- drivers/virtio/virtio_ring.c | 89 ++-- 1 file cha

[PATCH] virtio_blk: fix race at module removal

2014-10-23 Thread Michael S. Tsirkin
If a device appears while module is being removed, driver will get a callback after we've given up on the major number. In theory this means this major number can get reused by something else, resulting in a conflict. To fix, cleanup in reverse order of initialization. Signed-off-by: Michael S.

Re: [PATCH RFC v3 09/16] virtio: set FEATURES_OK

2014-10-23 Thread Michael S. Tsirkin
On Thu, Oct 23, 2014 at 03:30:06PM +0200, Cornelia Huck wrote: > On Thu, 23 Oct 2014 15:51:39 +0300 > "Michael S. Tsirkin" wrote: > > > On Thu, Oct 23, 2014 at 02:28:08PM +0200, Cornelia Huck wrote: > > > On Wed, 22 Oct 2014 21:44:44 +0300 > > > "Michael S. Tsirkin" wrote: > > > > > > > set FEA

Re: [PATCH RFC v3 09/16] virtio: set FEATURES_OK

2014-10-23 Thread Cornelia Huck
On Thu, 23 Oct 2014 15:51:39 +0300 "Michael S. Tsirkin" wrote: > On Thu, Oct 23, 2014 at 02:28:08PM +0200, Cornelia Huck wrote: > > On Wed, 22 Oct 2014 21:44:44 +0300 > > "Michael S. Tsirkin" wrote: > > > > > set FEATURES_OK as per virtio 1.0 spec > > > > > > Signed-off-by: Michael S. Tsirkin

[PATCH] virtio_blk: make serial attribute static

2014-10-23 Thread Michael S. Tsirkin
It's never declared so no need to make it extern. Signed-off-by: Michael S. Tsirkin --- drivers/block/virtio_blk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 93e23a7..a68f4c6 100644 --- a/drivers/block/virti

Re: [PATCH RFC v3 09/16] virtio: set FEATURES_OK

2014-10-23 Thread Michael S. Tsirkin
On Thu, Oct 23, 2014 at 02:28:08PM +0200, Cornelia Huck wrote: > On Wed, 22 Oct 2014 21:44:44 +0300 > "Michael S. Tsirkin" wrote: > > > set FEATURES_OK as per virtio 1.0 spec > > > > Signed-off-by: Michael S. Tsirkin > > --- > > include/uapi/linux/virtio_config.h | 2 ++ > > drivers/virtio/vi

Re: [PATCH RFC v3 09/16] virtio: set FEATURES_OK

2014-10-23 Thread Cornelia Huck
On Wed, 22 Oct 2014 21:44:44 +0300 "Michael S. Tsirkin" wrote: > set FEATURES_OK as per virtio 1.0 spec > > Signed-off-by: Michael S. Tsirkin > --- > include/uapi/linux/virtio_config.h | 2 ++ > drivers/virtio/virtio.c| 29 ++--- > 2 files changed, 24 inser

Re: [PATCH RFC v3 06/16] virtio: make endian-ness depend on virtio 1.0

2014-10-23 Thread Cornelia Huck
On Wed, 22 Oct 2014 21:44:34 +0300 "Michael S. Tsirkin" wrote: > virtio 1.0 is LE, virtio without 1.0 is native endian. > > Signed-off-by: Michael S. Tsirkin > --- > include/linux/virtio_config.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > Looks sane. _

Re: [PATCH RFC v3 05/16] virtio: add virtio 1.0 feature bit

2014-10-23 Thread Cornelia Huck
On Wed, 22 Oct 2014 21:44:31 +0300 "Michael S. Tsirkin" wrote: > Based on original patches by Rusty Russell, Thomas Huth > and Cornelia Huck. > > Signed-off-by: Michael S. Tsirkin > --- > include/uapi/linux/virtio_config.h | 7 +-- > drivers/virtio/virtio_ring.c | 2 ++ > 2 files cha

Re: [PATCH RFC 00/11] qemu: towards virtio-1 host support

2014-10-23 Thread Michael S. Tsirkin
On Thu, Oct 23, 2014 at 08:44:09AM +0200, Jan Kiszka wrote: > On 2014-10-22 22:34, Benjamin Herrenschmidt wrote: > > On Wed, 2014-10-22 at 16:17 +0200, Jan Kiszka wrote: > >> I thought about this again, and I'm not sure anymore if we can use > >> ACPI > >> to "black-list" the incompatible virtio de

Re: [PATCH RFC v3 01/16] virtio: memory access APIs

2014-10-23 Thread Michael S. Tsirkin
On Thu, Oct 23, 2014 at 09:54:05AM +0200, Cornelia Huck wrote: > On Wed, 22 Oct 2014 21:44:08 +0300 > "Michael S. Tsirkin" wrote: > > > virtio 1.0 makes all memory structures LE, so > > we need APIs to conditionally do a byteswap on BE > > architectures. > > > > To make it easier to check code s

Re: [PATCH RFC v3 01/16] virtio: memory access APIs

2014-10-23 Thread Cornelia Huck
On Wed, 22 Oct 2014 21:44:08 +0300 "Michael S. Tsirkin" wrote: > virtio 1.0 makes all memory structures LE, so > we need APIs to conditionally do a byteswap on BE > architectures. > > To make it easier to check code statically, > add virtio specific types for multi-byte integers > in memory. >

Re: [PATCH RFC 00/11] qemu: towards virtio-1 host support

2014-10-23 Thread Michael S. Tsirkin
On Thu, Oct 23, 2014 at 07:34:16AM +1100, Benjamin Herrenschmidt wrote: > On Wed, 2014-10-22 at 16:17 +0200, Jan Kiszka wrote: > > I thought about this again, and I'm not sure anymore if we can use > > ACPI > > to "black-list" the incompatible virtio devices. Reason: hotplug. To > > my > > understa