[PATCH] virtio-console: avoid DMA from stack

2017-02-01 Thread Omar Sandoval
From: Omar Sandoval put_chars() stuffs the buffer it gets into an sg, but that buffer may be on the stack. This breaks with CONFIG_VMAP_STACK=y (for me, it manifested as printks getting turned into NUL bytes). Signed-off-by: Omar Sandoval --- Patch based on v4.10-rc6. drivers/char/virtio_cons

[PATCH] virtio: Try to untangle DMA coherency

2017-02-01 Thread Robin Murphy
By forcing on DMA API usage for ARM systems, we have inadvertently kicked open a hornets' nest in terms of cache-coherency. Namely that unless the virtio device is explicitly described as capable of coherent DMA by firmware, the DMA APIs on ARM and other DT-based platforms will assume it is non-coh

Re: [PATCH] virtio-console: avoid DMA from stack

2017-02-01 Thread Amit Shah
On (Wed) 01 Feb 2017 [00:02:27], Omar Sandoval wrote: > From: Omar Sandoval > > put_chars() stuffs the buffer it gets into an sg, but that buffer may be > on the stack. This breaks with CONFIG_VMAP_STACK=y (for me, it > manifested as printks getting turned into NUL bytes). Seems reasonable. I w

Re: [PATCH] vhost: fix initialization for vq->is_le

2017-02-01 Thread Halil Pasic
On 01/31/2017 07:28 PM, Michael S. Tsirkin wrote: > On Tue, Jan 31, 2017 at 04:56:13PM +0100, Halil Pasic wrote: >> >> >> On 01/30/2017 08:06 PM, Greg Kurz wrote: Currently, under certain circumstances vhost_init_is_le does just a part of the initialization job, and depends on vhost_res

Re: [PATCH] virtio: Try to untangle DMA coherency

2017-02-01 Thread Will Deacon
On Wed, Feb 01, 2017 at 12:25:57PM +, Robin Murphy wrote: > By forcing on DMA API usage for ARM systems, we have inadvertently > kicked open a hornets' nest in terms of cache-coherency. Namely that > unless the virtio device is explicitly described as capable of coherent > DMA by firmware, the

[PATCH 00/14] hyperv: vmbus related patches

2017-02-01 Thread Stephen Hemminger
This is a rebase/resend of earlier patches. I skipped the pure cosmetic patches for now. Mostly this is consolidation earlier changes, removing dead code etc. The important part is the change for allowing a vmbus channel to get callback directly in interrupt mode; this is necessary for NAPI suppo

[PATCH 02/14] vmbus: drop no longer used kick_q argument

2017-02-01 Thread Stephen Hemminger
The flag to cause notification of host is unused after commit a01a291a282f7c2e ("Drivers: hv: vmbus: Base host signaling strictly on the ring state"). Therefore remove it from the ring buffer internal API. Signed-off-by: Stephen Hemminger --- drivers/hv/channel.c | 13 - drivers

[PATCH 03/14] vmbus: remove no longer used signal_policy

2017-02-01 Thread Stephen Hemminger
The explicit signal policy is no longer used. A different mechanism will be added later when xmit_more is supported. Signed-off-by: Stephen Hemminger --- include/linux/hyperv.h | 18 -- 1 file changed, 18 deletions(-) diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h

[PATCH 01/14] vmbus: use kernel bitops for traversing interrupt mask

2017-02-01 Thread Stephen Hemminger
Use standard kernel operations for find first set bit to traverse the channel bit array. This has added benefit of speeding up lookup on 64 bit and because it uses find first set instruction. Signed-off-by: Stephen Hemminger --- drivers/hv/channel.c | 8 ++- drivers/hv/connection.c |

[PATCH 04/14] vmbus: remove unused kickq argument to sendpacket

2017-02-01 Thread Stephen Hemminger
Since sendpacket no longer uses kickq argument remove it. Remove it no longer used xmit_more in sendpacket in netvsc as well. Signed-off-by: Stephen Hemminger --- drivers/hv/channel.c| 19 +-- drivers/net/hyperv/netvsc.c | 21 +++-- include/linux/hyperv.h

[PATCH 05/14] netvsc: remove no longer needed receive staging buffers

2017-02-01 Thread Stephen Hemminger
Since commit aed8c164ca5199 ("Drivers: hv: ring_buffer: count on wrap around mappings") it is no longer necessary to handle ring wrapping by having a special receive buffer. Signed-off-by: Stephen Hemminger --- drivers/net/hyperv/hyperv_net.h | 5 --- drivers/net/hyperv/netvsc.c | 83 ++

[PATCH 06/14] vmbus: remove per channel state

2017-02-01 Thread Stephen Hemminger
The netvsc no longer needs per channel state hook to track receive buffer. Signed-off-by: Stephen Hemminger --- include/linux/hyperv.h | 14 -- 1 file changed, 14 deletions(-) diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 8c6a1505b876..39d493ce550d 100644 --- a/

[PATCH 08/14] vmbus: put related per-cpu variable together

2017-02-01 Thread Stephen Hemminger
The hv_context structure had several arrays which were per-cpu and was allocating small structures (tasklet_struct). Instead use a single per-cpu array. Signed-off-by: Stephen Hemminger --- drivers/hv/channel_mgmt.c | 35 - drivers/hv/connection.c | 20 --- drivers/hv/hv.c

[PATCH 07/14] vmbus: callback is in softirq not workqueue

2017-02-01 Thread Stephen Hemminger
The callback is done via tasklet not workqueue. Signed-off-by: Stephen Hemminger --- include/linux/hyperv.h | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 39d493ce550d..b30808f740f9 100644 --- a/include/linux/hyperv.h

[PATCH 09/14] vmbus: change to per channel tasklet

2017-02-01 Thread Stephen Hemminger
Make the event handling tasklet per channel rather than per-cpu. This allows for better fairness when getting lots of data on the same cpu. Signed-off-by: Stephen Hemminger --- drivers/hv/channel.c | 2 +- drivers/hv/channel_mgmt.c | 16 +- drivers/hv/connection.c | 78 ++

[PATCH 11/14] vmbus: remove conditional locking of vmbus_write

2017-02-01 Thread Stephen Hemminger
All current usage of vmbus write uses the acquire_lock flag, therefore having it be optional is unnecessary. This also fixes a sparse warning since sparse doesn't like when a function has conditional locking. Signed-off-by: Stephen Hemminger --- drivers/hv/channel.c | 13 - driv

[PATCH 10/14] vmbus: add direct isr callback mode

2017-02-01 Thread Stephen Hemminger
Change the simple boolean batched_reading into a tri-value. For future NAPI support in netvsc driver, the callback needs to occur directly in interrupt handler. Batched mode is also changed to disable host interrupts immediately in interrupt routine (to avoid unnecessary host signals), and the tas

[PATCH 13/14] vmbus: constify parameters where possible

2017-02-01 Thread Stephen Hemminger
Functions that just query state of ring buffer can have parameters marked const. Signed-off-by: Stephen Hemminger --- drivers/hv/hyperv_vmbus.h | 6 +++--- drivers/hv/ring_buffer.c | 22 ++ include/linux/hyperv.h| 12 ++-- 3 files changed, 19 insertions(+), 21 d

[PATCH 14/14] vmbus: replace modulus operation with subtraction

2017-02-01 Thread Stephen Hemminger
Takes less clock cycles to check for ring wrap and subtract than to do a modulus instruction. Signed-off-by: Stephen Hemminger --- drivers/hv/ring_buffer.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index ee3e4

[PATCH 12/14] vmbus: expose hv_begin/end_read

2017-02-01 Thread Stephen Hemminger
In order to implement NAPI in netvsc, the driver needs access to control host interrupt mask. Signed-off-by: Stephen Hemminger --- drivers/hv/hyperv_vmbus.h | 4 drivers/hv/ring_buffer.c | 20 include/linux/hyperv.h| 30 ++ 3 files chan

Re: [PATCH] vhost: fix initialization for vq->is_le

2017-02-01 Thread Greg Kurz
On Tue, 31 Jan 2017 16:56:13 +0100 Halil Pasic wrote: > On 01/30/2017 08:06 PM, Greg Kurz wrote: > >> Currently, under certain circumstances vhost_init_is_le does just a part > >> of the initialization job, and depends on vhost_reset_is_le being called > >> too. For this reason vhost_vq_init_acce

Re: [PATCH] virtio: Try to untangle DMA coherency

2017-02-01 Thread Michael S. Tsirkin
On Wed, Feb 01, 2017 at 12:25:57PM +, Robin Murphy wrote: > By forcing on DMA API usage for ARM systems, we have inadvertently > kicked open a hornets' nest in terms of cache-coherency. Namely that > unless the virtio device is explicitly described as capable of coherent > DMA by firmware, the

Re: [PATCH] virtio: Try to untangle DMA coherency

2017-02-01 Thread Will Deacon
On Wed, Feb 01, 2017 at 08:09:21PM +0200, Michael S. Tsirkin wrote: > On Wed, Feb 01, 2017 at 12:25:57PM +, Robin Murphy wrote: > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > > index 7e38ed79c3fc..961af25b385c 100644 > > --- a/drivers/virtio/virtio_ring.c > > +++

Re: [PATCH] virtio: Try to untangle DMA coherency

2017-02-01 Thread Michael S. Tsirkin
On Wed, Feb 01, 2017 at 06:27:09PM +, Will Deacon wrote: > On Wed, Feb 01, 2017 at 08:09:21PM +0200, Michael S. Tsirkin wrote: > > On Wed, Feb 01, 2017 at 12:25:57PM +, Robin Murphy wrote: > > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > > > index 7e38ed79c3f