[PATCH] drm/virtio: use virtio_max_dma_size

2019-08-08 Thread Gerd Hoffmann
We must make sure our scatterlist segments are not too big, otherwise we might see swiotlb failures (happens with sev, also reproducable with swiotlb=force). Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_object.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-)

[PATCH V5 8/9] vhost: correctly set dirty pages in MMU notifiers callback

2019-08-08 Thread Jason Wang
We need make sure there's no reference on the map before trying to mark set dirty pages. Reported-by: Michael S. Tsirkin Fixes: 7f466032dc9e ("vhost: access vq metadata through kernel virtual address") Signed-off-by: Jason Wang --- drivers/vhost/vhost.c | 5 ++--- 1 file changed, 2

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

2019-08-08 Thread Jason Wang
We used to use RCU to synchronize MMU notifier with worker. This leads calling synchronize_rcu() in invalidate_range_start(). But on a busy system, there would be many factors that may slow down the synchronize_rcu() which makes it unsuitable to be called in MMU notifier. This path switch to use a

[PATCH V5 9/9] vhost: do not return -EAGAIN for non blocking invalidation too early

2019-08-08 Thread Jason Wang
Instead of returning -EAGAIN unconditionally, we'd better do that only we're sure the range is overlapped with the metadata area. Reported-by: Jason Gunthorpe Fixes: 7f466032dc9e ("vhost: access vq metadata through kernel virtual address") Signed-off-by: Jason Wang --- drivers/vhost/vhost.c |

[PATCH V5 5/9] vhost: mark dirty pages during map uninit

2019-08-08 Thread Jason Wang
We don't mark dirty pages if the map was teared down outside MMU notifier. This will lead untracked dirty pages. Fixing by marking dirty pages during map uninit. Reported-by: Michael S. Tsirkin Fixes: 7f466032dc9e ("vhost: access vq metadata through kernel virtual address") Signed-off-by: Jason

[PATCH V5 3/9] vhost: fix vhost map leak

2019-08-08 Thread Jason Wang
We don't free map during vhost_map_unprefetch(). This means it could be leaked. Fixing by free the map. Reported-by: Michael S. Tsirkin Fixes: 7f466032dc9e ("vhost: access vq metadata through kernel virtual address") Signed-off-by: Jason Wang --- drivers/vhost/vhost.c | 4 +--- 1 file changed,

[PATCH V5 0/9] Fixes for vhost metadata acceleration

2019-08-08 Thread Jason Wang
Hi all: This series try to fix several issues introduced by meta data accelreation series. Please review. Changes from V4: - switch to use spinlock synchronize MMU notifier with accessors Changes from V3: - remove the unnecessary patch Changes from V2: - use seqlck helper to synchronize MMU

[PATCH V5 6/9] vhost: don't do synchronize_rcu() in vhost_uninit_vq_maps()

2019-08-08 Thread Jason Wang
There's no need for RCU synchronization in vhost_uninit_vq_maps() since we've already serialized with readers (memory accessors). This also avoid the possible userspace DOS through ioctl() because of the possible high latency caused by synchronize_rcu(). Reported-by: Michael S. Tsirkin Fixes:

Re: [PATCH V4 0/9] Fixes for metadata accelreation

2019-08-08 Thread David Miller
From: Jason Wang Date: Wed, 7 Aug 2019 03:06:08 -0400 > This series try to fix several issues introduced by meta data > accelreation series. Please review. ... My impression is that patch #7 will be changed to use spinlocks so there will be a v5.

Re: [PATCH v4 07/17] drm/shmem: drop DEFINE_DRM_GEM_SHMEM_FOPS

2019-08-08 Thread Rob Herring
On Thu, Aug 8, 2019 at 7:44 AM Gerd Hoffmann wrote: > > DEFINE_DRM_GEM_SHMEM_FOPS is identical to DEFINE_DRM_GEM_FOPS now, > drop it. > > Signed-off-by: Gerd Hoffmann > --- > include/drm/drm_gem_shmem_helper.h | 26 - > drivers/gpu/drm/cirrus/cirrus.c | 2

[PATCH V5 1/9] vhost: don't set uaddr for invalid address

2019-08-08 Thread Jason Wang
We should not setup uaddr for the invalid address, otherwise we may try to pin or prefetch mapping of wrong pages. Fixes: 7f466032dc9e ("vhost: access vq metadata through kernel virtual address") Signed-off-by: Jason Wang --- drivers/vhost/vhost.c | 3 ++- 1 file changed, 2 insertions(+), 1

[PATCH V5 2/9] vhost: validate MMU notifier registration

2019-08-08 Thread Jason Wang
The return value of mmu_notifier_register() is not checked in vhost_vring_set_num_addr(). This will cause an out of sync between mm and MMU notifier thus a double free. To solve this, introduce a boolean flag to track whether MMU notifier is registered and only do unregistering when it was true.

[PATCH V5 4/9] vhost: reset invalidate_count in vhost_set_vring_num_addr()

2019-08-08 Thread Jason Wang
The vhost_set_vring_num_addr() could be called in the middle of invalidate_range_start() and invalidate_range_end(). If we don't reset invalidate_count after the un-registering of MMU notifier, the invalidate_cont will run out of sync (e.g never reach zero). This will in fact disable the fast

Re: [PATCH V4 0/9] Fixes for metadata accelreation

2019-08-08 Thread Jason Wang
On 2019/8/9 下午1:15, David Miller wrote: From: Jason Wang Date: Wed, 7 Aug 2019 03:06:08 -0400 This series try to fix several issues introduced by meta data accelreation series. Please review. ... My impression is that patch #7 will be changed to use spinlocks so there will be a v5.

Re: [PATCH v2 2/2] virtio_ring: packed ring: fix virtqueue_detach_unused_buf

2019-08-08 Thread Pankaj Gupta
> On Thu, Aug 08, 2019 at 08:28:46AM -0400, Pankaj Gupta wrote: > > > > > > > > This patch makes packed ring code compatible with split ring in > > > > function > > > > 'virtqueue_detach_unused_buf_*'. > > > > > > What does that mean? What does this "fix"? > > > > Patch 1 frees the buffers

[PATCH v4 16/17] drm/qxl: drop verify_access

2019-08-08 Thread Gerd Hoffmann
Not needed any more. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/qxl/qxl_ttm.c | 9 - 1 file changed, 9 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c index dbaed0e67c21..d1d8fe6e1e93 100644 --- a/drivers/gpu/drm/qxl/qxl_ttm.c +++

[PATCH v4 12/17] drm: drop DRM_VRAM_MM_FILE_OPERATIONS

2019-08-08 Thread Gerd Hoffmann
Not needed any more because we don't have vram specific functions any more. DEFINE_DRM_GEM_FOPS() can be used instead. Signed-off-by: Gerd Hoffmann --- include/drm/drm_vram_mm_helper.h| 17 - drivers/gpu/drm/ast/ast_drv.c | 5 +

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

2019-08-08 Thread Jason Wang
- Original Message - > > On 2019/8/7 下午10:02, Jason Wang wrote: > > > > On 2019/8/7 下午8:07, Jason Gunthorpe wrote: > >> On Wed, Aug 07, 2019 at 03:06:15AM -0400, Jason Wang wrote: > >>> We used to use RCU to synchronize MMU notifier with worker. This leads > >>> calling

[PATCH v3 5/8] drm/qxl: switch qxl to the new gem_ttm_bo_device_init()

2019-08-08 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/qxl/qxl_drv.h| 4 +--- drivers/gpu/drm/qxl/qxl_object.h | 5 - drivers/gpu/drm/qxl/qxl_drv.c| 1 - drivers/gpu/drm/qxl/qxl_dumb.c | 17 - drivers/gpu/drm/qxl/qxl_ioctl.c | 5 +++-- drivers/gpu/drm/qxl/qxl_ttm.c

[PATCH v3 8/8] gem/qxl: use drm_gem_ttm_bo_driver_verify_access()

2019-08-08 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/qxl/qxl_ttm.c | 10 +- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c index 3a24145dd516..bcf48b062a85 100644 --- a/drivers/gpu/drm/qxl/qxl_ttm.c +++

Re: [PATCH v2 1/2] virtio_console: free unused buffers with port delete

2019-08-08 Thread Greg KH
On Thu, Aug 08, 2019 at 05:06:05PM +0530, Pankaj Gupta wrote: > The commit a7a69ec0d8e4 ("virtio_console: free buffers after reset") > deferred detaching of unused buffer to virtio device unplug time. > > This causes unplug/replug of single port in virtio device with an > error "Error

Re: [PATCH v2 2/2] virtio_ring: packed ring: fix virtqueue_detach_unused_buf

2019-08-08 Thread Greg KH
On Thu, Aug 08, 2019 at 05:06:06PM +0530, Pankaj Gupta wrote: > This patch makes packed ring code compatible with split ring in function > 'virtqueue_detach_unused_buf_*'. What does that mean? What does this "fix"? thanks, greg k-h ___ Virtualization

Re: [PATCH v2 2/2] virtio_ring: packed ring: fix virtqueue_detach_unused_buf

2019-08-08 Thread Greg KH
On Thu, Aug 08, 2019 at 08:28:46AM -0400, Pankaj Gupta wrote: > > > > > This patch makes packed ring code compatible with split ring in function > > > 'virtqueue_detach_unused_buf_*'. > > > > What does that mean? What does this "fix"? > > Patch 1 frees the buffers When a port is unplugged

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

2019-08-08 Thread Jason Wang
On 2019/8/7 下午10:02, Jason Wang wrote: > > On 2019/8/7 下午8:07, Jason Gunthorpe wrote: >> On Wed, Aug 07, 2019 at 03:06:15AM -0400, Jason Wang wrote: >>> We used to use RCU to synchronize MMU notifier with worker. This leads >>> calling synchronize_rcu() in invalidate_range_start(). But on a busy

[PATCH v4 04/17] drm/qxl: switch qxl to the new gem_ttm_bo_device_init()

2019-08-08 Thread Gerd Hoffmann
This allows to drop qxl_mode_dumb_mmap() and qxl_bo_mmap_offset(), the default gem function works just fine. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/qxl/qxl_drv.h| 4 +--- drivers/gpu/drm/qxl/qxl_object.h | 5 - drivers/gpu/drm/qxl/qxl_drv.c| 1 -

[PATCH v4 07/17] drm/shmem: drop DEFINE_DRM_GEM_SHMEM_FOPS

2019-08-08 Thread Gerd Hoffmann
DEFINE_DRM_GEM_SHMEM_FOPS is identical to DEFINE_DRM_GEM_FOPS now, drop it. Signed-off-by: Gerd Hoffmann --- include/drm/drm_gem_shmem_helper.h | 26 - drivers/gpu/drm/cirrus/cirrus.c | 2 +- drivers/gpu/drm/panfrost/panfrost_drv.c | 2 +-

Re: [PATCH v2 1/2] virtio_console: free unused buffers with port delete

2019-08-08 Thread Pankaj Gupta
> > On Thu, Aug 08, 2019 at 05:06:05PM +0530, Pankaj Gupta wrote: > > The commit a7a69ec0d8e4 ("virtio_console: free buffers after reset") > > deferred detaching of unused buffer to virtio device unplug time. > > > > This causes unplug/replug of single port in virtio device with an > >

Re: [PATCH v2 2/2] virtio_ring: packed ring: fix virtqueue_detach_unused_buf

2019-08-08 Thread Pankaj Gupta
> > This patch makes packed ring code compatible with split ring in function > > 'virtqueue_detach_unused_buf_*'. > > What does that mean? What does this "fix"? Patch 1 frees the buffers When a port is unplugged from the virtio console device. It does this with the help of

[PATCH v4 14/17] drm/qxl: drop qxl_ttm_fault

2019-08-08 Thread Gerd Hoffmann
Not sure what this hook is supposed to do. vmf->vma->vm_private_data should never be NULL, so the extra check in qxl_ttm_fault should have no effect. Drop it. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/qxl/qxl_ttm.c | 27 +-- 1 file changed, 1 insertion(+), 26

[PATCH v4 17/17] drm/qxl: use DEFINE_DRM_GEM_FOPS()

2019-08-08 Thread Gerd Hoffmann
We have no qxl-specific fops any more. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/qxl/qxl_drv.c | 10 +- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c index 2fb1641c817e..4853082ba924 100644 ---

[PATCH v4 13/17] drm/qxl: use drm_gem_object_funcs

2019-08-08 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/qxl/qxl_drv.c| 8 drivers/gpu/drm/qxl/qxl_object.c | 12 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c index 12cf85a06bed..38467478c7b2

[PATCH v4 15/17] drm/qxl: switch qxl to drm_gem_object_funcs->mmap codepath

2019-08-08 Thread Gerd Hoffmann
... using the use drm_gem_ttm_mmap() helper function. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/qxl/qxl_drv.h| 1 - drivers/gpu/drm/qxl/qxl_drv.c| 2 +- drivers/gpu/drm/qxl/qxl_object.c | 1 + drivers/gpu/drm/qxl/qxl_ttm.c| 16 4 files changed, 2

[PATCH v2 1/2] virtio_console: free unused buffers with port delete

2019-08-08 Thread Pankaj Gupta
The commit a7a69ec0d8e4 ("virtio_console: free buffers after reset") deferred detaching of unused buffer to virtio device unplug time. This causes unplug/replug of single port in virtio device with an error "Error allocating inbufs\n". As we don't free the unused buffers attached with

[PATCH v2 2/2] virtio_ring: packed ring: fix virtqueue_detach_unused_buf

2019-08-08 Thread Pankaj Gupta
This patch makes packed ring code compatible with split ring in function 'virtqueue_detach_unused_buf_*'. Signed-off-by: Pankaj Gupta --- drivers/virtio/virtio_ring.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index

[PATCH v2 0/2] virtio_console: fix replug of virtio console port

2019-08-08 Thread Pankaj Gupta
This patch series fixes the issue with unplug/replug of a port in virtio console device, which fails with an error "Error allocating inbufs\n". Patch 2 makes virtio packed ring code compatible with virtio split ring. Tested the packed ring code with the qemu virtio 1.1 device code posted here

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

2019-08-08 Thread Jason Gunthorpe
On Thu, Aug 08, 2019 at 08:54:54PM +0800, Jason Wang wrote: > I don't have any objection to convert  to spinlock() but just want to > know if any case that the above smp_mb() + counter looks good to you? This email is horribly mangled, but I don't think mixing smb_mb() and smp_load_acquire()