Re: [PATCH V2 7/9] vhost: do not use RCU to synchronize MMU notifier with worker

2019-08-02 Thread Jason Gunthorpe
On Fri, Aug 02, 2019 at 10:27:21AM -0400, Michael S. Tsirkin wrote: > On Fri, Aug 02, 2019 at 09:46:13AM -0300, Jason Gunthorpe wrote: > > On Fri, Aug 02, 2019 at 05:40:07PM +0800, Jason Wang wrote: > > > > This must be a proper barrier, like a spinlock, mutex, or > > > > synchronize_rcu. > > > >

Re: [PATCH V2 7/9] vhost: do not use RCU to synchronize MMU notifier with worker

2019-08-02 Thread Michael S. Tsirkin
On Fri, Aug 02, 2019 at 09:46:13AM -0300, Jason Gunthorpe wrote: > On Fri, Aug 02, 2019 at 05:40:07PM +0800, Jason Wang wrote: > > > This must be a proper barrier, like a spinlock, mutex, or > > > synchronize_rcu. > > > > > > I start with synchronize_rcu() but both you and Michael raise some > >

Re: [PATCH V2 7/9] vhost: do not use RCU to synchronize MMU notifier with worker

2019-08-02 Thread Michael S. Tsirkin
On Fri, Aug 02, 2019 at 05:40:07PM +0800, Jason Wang wrote: > Btw, I come up another idea, that is to disable preemption when vhost thread > need to access the memory. Then register preempt notifier and if vhost > thread is preempted, we're sure no one will access the memory and can do the >

[PATCH v7 07/18] drm/virtio: add virtio_gpu_object_array & helpers

2019-08-02 Thread Gerd Hoffmann
Some helper functions to manage an array of gem objects. v6: - add ticket to struct virtio_gpu_object_array. - add virtio_gpu_array_{lock,unlock}_resv helpers. - add virtio_gpu_array_add_fence helper. v5: some small optimizations (Chia-I Wu). v4: make them virtio-private instead of generic

[PATCH v7 08/18] drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing

2019-08-02 Thread Gerd Hoffmann
Rework fencing workflow, starting with virtio_gpu_execbuffer_ioctl. Stop using ttm helpers, use the virtio_gpu_array_* helpers (which work on the reservation objects directly) instead. Also store the object array in struct virtio_gpu_vbuffer, so we explicitly keep a reference of all buffers used

[PATCH v7 16/18] drm/virtio: drop virtio_gpu_object_{ref,unref}

2019-08-02 Thread Gerd Hoffmann
No users left. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_drv.h | 15 --- 1 file changed, 15 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index d4d82679d83a..59f71dc94017 100644 ---

[PATCH v7 10/18] drm/virtio: rework virtio_gpu_transfer_from_host_ioctl fencing

2019-08-02 Thread Gerd Hoffmann
Switch to the virtio_gpu_array_* helper workflow. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_drv.h | 3 +- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 40 ++ drivers/gpu/drm/virtio/virtgpu_vq.c| 8 -- 3 files changed, 23 insertions(+), 28

[PATCH v7 03/18] drm/virtio: simplify cursor updates

2019-08-02 Thread Gerd Hoffmann
No need to do the reservation dance, we can just wait on the fence directly. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/virtio/virtgpu_plane.c | 13 +++-- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git

[PATCH v7 18/18] drm/virtio: add fence sanity check

2019-08-02 Thread Gerd Hoffmann
Make sure we don't leak half-initialized fences outside the driver. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_fence.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c index

[PATCH v7 14/18] drm/virtio: switch from ttm to gem shmem helpers

2019-08-02 Thread Gerd Hoffmann
virtio-gpu basically needs a sg_table for the bo, to tell the host where the backing pages for the object are. So the gem shmem helpers are a perfect fit. Some drm_gem_object_funcs need thin wrappers to update the host state, but otherwise the helpers handle everything just fine. Once the

[PATCH v7 05/18] drm/virtio: drop no_wait argument from virtio_gpu_object_reserve

2019-08-02 Thread Gerd Hoffmann
All callers pass no_wait = false. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/virtio/virtgpu_drv.h | 5 ++--- drivers/gpu/drm/virtio/virtgpu_gem.c | 4 ++-- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-)

[PATCH v7 15/18] drm/virtio: remove virtio_gpu_alloc_object

2019-08-02 Thread Gerd Hoffmann
Thin wrapper around virtio_gpu_object_create(), but calling that directly works equally well. Signed-off-by: Gerd Hoffmann Acked-by: Daniel Vetter --- drivers/gpu/drm/virtio/virtgpu_drv.h | 4 drivers/gpu/drm/virtio/virtgpu_gem.c | 23 ---

[PATCH v7 12/18] drm/virtio: rework virtio_gpu_cmd_context_{attach, detach}_resource

2019-08-02 Thread Gerd Hoffmann
Switch to the virtio_gpu_array_* helper workflow. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_drv.h | 4 ++-- drivers/gpu/drm/virtio/virtgpu_gem.c | 24 +++- drivers/gpu/drm/virtio/virtgpu_vq.c | 12 3 files changed, 21 insertions(+), 19

[PATCH v7 17/18] drm/virtio: drop virtio_gpu_object_{reserve, unreserve}

2019-08-02 Thread Gerd Hoffmann
No users left. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_drv.h | 21 - 1 file changed, 21 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index 59f71dc94017..fb35831ed351 100644 ---

[PATCH v7 04/18] drm/virtio: remove virtio_gpu_object_wait

2019-08-02 Thread Gerd Hoffmann
No users left. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/virtio/virtgpu_drv.h| 1 - drivers/gpu/drm/virtio/virtgpu_object.c | 13 - 2 files changed, 14 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h

[PATCH v7 06/18] drm/virtio: remove ttm calls from in virtio_gpu_object_{reserve, unreserve}

2019-08-02 Thread Gerd Hoffmann
Call reservation_object_* directly instead of using ttm_bo_{reserve,unreserve}. v4: check for EINTR only. v3: check for EINTR too. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/virtio/virtgpu_drv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff

[PATCH v7 02/18] drm/virtio: switch virtio_gpu_wait_ioctl() to gem helper.

2019-08-02 Thread Gerd Hoffmann
Use drm_gem_reservation_object_wait() in virtio_gpu_wait_ioctl(). This also makes the ioctl run lockless. v5: handle lookup failure. v2: use reservation_object_test_signaled_rcu for VIRTGPU_WAIT_NOWAIT. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel Vetter ---

[PATCH v7 11/18] drm/virtio: rework virtio_gpu_transfer_to_host_ioctl fencing

2019-08-02 Thread Gerd Hoffmann
Switch to the virtio_gpu_array_* helper workflow. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_drv.h | 4 +-- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 50 +++--- drivers/gpu/drm/virtio/virtgpu_plane.c | 21 ---

[PATCH v7 01/18] drm/virtio: pass gem reservation object to ttm init

2019-08-02 Thread Gerd Hoffmann
With this gem and ttm will use the same reservation object, so mixing and matching ttm / gem reservation helpers should work fine. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/virtio/virtgpu_object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff

[PATCH v7 09/18] drm/virtio: rework virtio_gpu_object_create fencing

2019-08-02 Thread Gerd Hoffmann
Rework fencing workflow. Stop using ttm helpers, use the virtio_gpu_array_* helpers instead. Due to using the gem reservation object it is initialized and ready for use before calling ttm_bo_init. So we can simply use the standard fencing workflow and drop the tricky logic which checks whenever

[PATCH v7 13/18] drm/virtio: drop virtio_gpu_object_list_validate/virtio_gpu_unref_list

2019-08-02 Thread Gerd Hoffmann
No users left. Signed-off-by: Gerd Hoffmann Acked-by: Daniel Vetter --- drivers/gpu/drm/virtio/virtgpu_drv.h | 3 -- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 39 -- 2 files changed, 42 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h

Re: [PATCH V2 7/9] vhost: do not use RCU to synchronize MMU notifier with worker

2019-08-02 Thread Jason Gunthorpe
On Fri, Aug 02, 2019 at 05:40:07PM +0800, Jason Wang wrote: > > This must be a proper barrier, like a spinlock, mutex, or > > synchronize_rcu. > > > I start with synchronize_rcu() but both you and Michael raise some > concern. I've also idly wondered if calling synchronize_rcu() under the

Re: [PATCH V2 7/9] vhost: do not use RCU to synchronize MMU notifier with worker

2019-08-02 Thread Jason Wang
On 2019/8/1 下午10:15, Jason Gunthorpe wrote: On Thu, Aug 01, 2019 at 01:02:18PM +0800, Jason Wang wrote: On 2019/8/1 上午3:30, Jason Gunthorpe wrote: On Wed, Jul 31, 2019 at 09:28:20PM +0800, Jason Wang wrote: On 2019/7/31 下午8:39, Jason Gunthorpe wrote: On Wed, Jul 31, 2019 at 04:46:53AM

Re: [PATCH] drm/virtio: kick vq outside of the vq lock

2019-08-02 Thread Gerd Hoffmann
> @@ -291,11 +291,9 @@ static int virtio_gpu_queue_ctrl_buffer_locked(struct > virtio_gpu_device *vgdev, > trace_virtio_gpu_cmd_queue(vq, > (struct virtio_gpu_ctrl_hdr *)vbuf->buf); > > - virtqueue_kick(vq); > + ret =

Re: [PATCH v2 00/11] VSOCK: add vsock_test test suite

2019-08-02 Thread Stefano Garzarella
On Thu, Aug 01, 2019 at 04:16:37PM +, Dexuan Cui wrote: > > From: Stefano Garzarella > > Sent: Thursday, August 1, 2019 8:26 AM > > > > The vsock_diag.ko module already has a test suite but the core AF_VSOCK > > functionality has no tests. This patch series adds several test cases that > >