Re: [PATCH 3/4] drm/virtio: track whether or not a context has been initiated

2020-02-12 Thread Chia-I Wu
On Wed, Feb 12, 2020 at 5:54 PM Gurchetan Singh wrote: > > On Wed, Feb 12, 2020 at 10:50 AM Chia-I Wu wrote: > > > > On Tue, Feb 11, 2020 at 3:56 PM Gurchetan Singh > > wrote: > > > > > > We only want create a new virglrenderer context after the first

Re: [PATCH v3 0/4] drm/virtio: rework batching

2020-02-13 Thread Chia-I Wu
Series is Reviewed-by: Chia-I Wu After the series, virtio_gpu_cmd_* may or may not call virtio_gpu_notify. It is error-prone and should be fixed, such that virtio_gpu_cmd_* never notifies, or such that different naming conventions are used for functions that notify and for those don't.

Re: [PATCH v3 3/4] drm/virtio: batch resource creation

2020-02-13 Thread Chia-I Wu
On Thu, Feb 13, 2020 at 5:22 AM Gerd Hoffmann wrote: > > Move virtio_gpu_notify() to higher-level functions for > virtio_gpu_cmd_create_resource(), virtio_gpu_cmd_resource_create_3d() > and virtio_gpu_cmd_resource_attach_backing(). > > virtio_gpu_object_create() will batch commands and notify only

[RFC PATCH 2/3] RFC: KVM: add KVM_MEM_DMA

2020-02-13 Thread Chia-I Wu
When the flag is set, it means the the userspace wants to do DMA with the memory and the guest will use an appropriate memory type to access the memory. The kernel should be prepared to honor the guest's memory type. Signed-off-by: Chia-I Wu Cc: Gurchetan Singh Cc: Gerd Hof

[RFC PATCH 0/3] KVM: x86: honor guest memory type

2020-02-13 Thread Chia-I Wu
Hi, Host GPU drivers like to give userspace WC mapping. When the userspace makes the mapping available to a guest, it also tells the guest to create a WC mapping. However, even when the guest kernel picks the correct memory type, it gets ignored because of VMX_EPT_IPAT_BIT on Intel. This series

[RFC PATCH 3/3] RFC: KVM: x86: support KVM_CAP_DMA_MEM

2020-02-13 Thread Chia-I Wu
When a memslot has KVM_MEM_DMA set, we want VMX_EPT_IPAT_BIT cleared for the memslot. Before that is possible, simply call kvm_arch_register_noncoherent_dma for the memslot. SVM does not have the ignore-pat bit. Guest PAT is always honored. Signed-off-by: Chia-I Wu Cc: Gurchetan Singh Cc

[RFC PATCH 1/3] KVM: vmx: rewrite the comment in vmx_get_mt_mask

2020-02-13 Thread Chia-I Wu
Better reflect the structure of the code and metion why we could not always honor the guest. Signed-off-by: Chia-I Wu Cc: Gurchetan Singh Cc: Gerd Hoffmann --- arch/x86/kvm/vmx/vmx.c | 27 +-- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm

Re: [RFC PATCH 0/3] KVM: x86: honor guest memory type

2020-02-13 Thread Chia-I Wu
On Thu, Feb 13, 2020 at 1:41 PM Paolo Bonzini wrote: > > On 13/02/20 22:30, Chia-I Wu wrote: > > Hi, > > > > Host GPU drivers like to give userspace WC mapping. When the userspace > > makes > > the mapping available to a guest, it also tells the guest to cre

Re: [PATCH 3/5] drm/virtio: track whether or not a context has been initiated

2020-02-14 Thread Chia-I Wu
On Thu, Feb 13, 2020 at 3:18 PM Gurchetan Singh wrote: > > Use an atomic variable to track whether a context has been > initiated. > > v2: Fix possible race (@olv) > > Signed-off-by: Gurchetan Singh > --- > drivers/gpu/drm/virtio/virtgpu_drv.h | 1 + > drivers/gpu/drm/virtio/virtgpu_ioctl.c |

Re: [PATCH v4 0/6] drm/virtio: rework batching

2020-02-14 Thread Chia-I Wu
Series is Reviewed-by: Chia-I Wu Thanks! On Fri, Feb 14, 2020 at 4:55 AM Gerd Hoffmann wrote: > > v4: > - add patches #2 + #6. > v3: > - split into multiple patches. > > Gerd Hoffmann (6): > drm/virtio: rework notification for better batching > drm/virtio: no

Re: [RFC PATCH 0/3] KVM: x86: honor guest memory type

2020-02-14 Thread Chia-I Wu
On Fri, Feb 14, 2020 at 2:26 AM Paolo Bonzini wrote: > > On 13/02/20 23:18, Chia-I Wu wrote: > > > > The bug you mentioned was probably this one > > > > https://bugzilla.kernel.org/show_bug.cgi?id=104091 > > Yes, indeed. > > > From what I can tell, t

Re: [RFC PATCH 0/3] KVM: x86: honor guest memory type

2020-02-14 Thread Chia-I Wu
On Fri, Feb 14, 2020 at 11:52 AM Sean Christopherson wrote: > > On Fri, Feb 14, 2020 at 11:26:06AM +0100, Paolo Bonzini wrote: > > On 13/02/20 23:18, Chia-I Wu wrote: > > > > > > The bug you mentioned was probably this one > > > > > > ht

Re: [PATCH 3/5] drm/virtio: track whether or not a context has been initiated

2020-02-14 Thread Chia-I Wu
On Fri, Feb 14, 2020 at 6:29 PM Gurchetan Singh wrote: > > On Fri, Feb 14, 2020 at 11:27 AM Chia-I Wu wrote: > > > > On Thu, Feb 13, 2020 at 3:18 PM Gurchetan Singh > > wrote: > > > > > > Use an atomic variable to track whether a context has been >

Re: [PATCH 3/5 v5] drm/virtio: track whether or not a context has been initiated

2020-02-19 Thread Chia-I Wu
Patch 1-4 are Reviewed-by: Chia-I Wu I think we can drop patch 5 for now. On Wed, Feb 19, 2020 at 9:56 AM Gurchetan Singh wrote: > > Use an atomic variable to track whether a context has been > initiated. > > v5: Fix possible race and sleep via mutex (@olv) > > Signed-of

Re: [RFC PATCH 0/3] KVM: x86: honor guest memory type

2020-02-19 Thread Chia-I Wu
On Wed, Feb 19, 2020 at 2:00 AM Tian, Kevin wrote: > > > From: Chia-I Wu > > Sent: Saturday, February 15, 2020 5:15 AM > > > > On Fri, Feb 14, 2020 at 2:26 AM Paolo Bonzini wrote: > > > > > > On 13/02/20 23:18, Chia-I Wu wrote: > > >

Re: [RFC PATCH 0/3] KVM: x86: honor guest memory type

2020-02-19 Thread Chia-I Wu
On Wed, Feb 19, 2020 at 1:52 AM Tian, Kevin wrote: > > > From: Paolo Bonzini > > Sent: Wednesday, February 19, 2020 12:29 AM > > > > On 14/02/20 23:03, Sean Christopherson wrote: > > >> On Fri, Feb 14, 2020 at 1:47 PM Chia-I Wu wrote: > > >>>

Re: [PATCH] drm/virtio: fix virtio-gpu resource id creation race

2020-02-20 Thread Chia-I Wu
On Thu, Feb 20, 2020 at 5:30 AM Emil Velikov wrote: > > Hi John, > > On Thu, 20 Feb 2020 at 08:45, John Bates wrote: > > > > The previous code was not thread safe and caused > > undefined behavior from spurious duplicate resource IDs. > > In this patch, an atomic_t is used instead. We no longer >

Re: [Bug] virtio-gpu broken with qemu/kvm on arm64 on kernel 5.5+

2020-02-20 Thread Chia-I Wu
most part just removing the ttm code. > > v4: fix drm_gem_object_funcs name. > > Signed-off-by: Gerd Hoffmann > Acked-by: Daniel Vetter > Reviewed-by: Chia-I Wu > Link: > http://patchwork.freedesktop.org/patch/msgid/20190829103301.3539-15-kra...@redhat.com > *

Re: [RFC PATCH 0/3] KVM: x86: honor guest memory type

2020-02-20 Thread Chia-I Wu
On Wed, Feb 19, 2020 at 6:38 PM Tian, Kevin wrote: > > > From: Tian, Kevin > > Sent: Thursday, February 20, 2020 10:05 AM > > > > > From: Chia-I Wu > > > Sent: Thursday, February 20, 2020 3:37 AM > > > > > > On Wed, Feb 19, 2020 at

Re: [RFC PATCH 0/3] KVM: x86: honor guest memory type

2020-02-20 Thread Chia-I Wu
On Wed, Feb 19, 2020 at 6:13 PM Tian, Kevin wrote: > > > Curious... How is such slot exposed to the guest? A reserved memory > > > region? Is it static or might be dynamically added? > > The plan is for virtio-gpu device to reserve a huge memory region in > > the guest. Memslots may be added dyna

Re: [RFC PATCH 0/3] KVM: x86: honor guest memory type

2020-02-20 Thread Chia-I Wu
On Thu, Feb 20, 2020 at 4:23 PM Tian, Kevin wrote: > > From: Chia-I Wu > > Sent: Friday, February 21, 2020 6:24 AM > > > > On Wed, Feb 19, 2020 at 6:38 PM Tian, Kevin > wrote: > > > > > > > From: Tian, Kevin > > > > Sent: Thursday,

Re: [RFC PATCH 0/3] KVM: x86: honor guest memory type

2020-02-20 Thread Chia-I Wu
(resend because gmail did not format to plain text...) On Thu, Feb 20, 2020 at 8:45 PM Chia-I Wu wrote: > > > > On Thu, Feb 20, 2020 at 4:23 PM Tian, Kevin wrote: >> >> > From: Chia-I Wu >> > Sent: Friday, February 21, 2020 6:24 AM >> > >> &

Re: [RFC PATCH 0/3] KVM: x86: honor guest memory type

2020-02-21 Thread Chia-I Wu
On Fri, Feb 21, 2020 at 7:59 AM Sean Christopherson wrote: > > On Thu, Feb 20, 2020 at 09:39:05PM -0800, Tian, Kevin wrote: > > > From: Chia-I Wu > > > Sent: Friday, February 21, 2020 12:51 PM > > > If you think it is the best for KVM to inspect hva to determin

Re: [PATCH v2] drm/virtio: fix resource id creation race

2020-02-21 Thread Chia-I Wu
; Fixes: 16065fcdd19d ("drm/virtio: do NOT reuse resource ids") > Signed-off-by: John Bates Reviewed-by: Chia-I Wu > --- > drivers/gpu/drm/virtio/virtgpu_object.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/vi

Re: [Bug] virtio-gpu broken with qemu/kvm on arm64 on kernel 5.5+

2020-02-21 Thread Chia-I Wu
On Fri, Feb 21, 2020 at 2:06 AM Guillaume Gardet wrote: > > Hi, > > > -Original Message- > > From: Chia-I Wu > > Sent: 20 February 2020 19:41 > > To: Guillaume Gardet > > Cc: dri-devel@lists.freedesktop.org; Gerd Hoffmann ; > > Daniel Vette

Re: [PATCH 4/4 v6] drm/virtio: enqueue virtio_gpu_create_context after the first 3D ioctl

2020-02-21 Thread Chia-I Wu
rkaround or something? > > Reviewed-by: Chia-I Wu > Reviewed-by: Emil Velikov > Signed-off-by: Gurchetan Singh > --- > drivers/gpu/drm/virtio/virtgpu_drv.h | 2 -- > drivers/gpu/drm/virtio/virtgpu_ioctl.c | 32 +++--- > drivers/gpu/drm/virtio/vir

Re: [PATCH 4/4 v6] drm/virtio: enqueue virtio_gpu_create_context after the first 3D ioctl

2020-02-24 Thread Chia-I Wu
On Mon, Feb 24, 2020 at 5:24 AM Emil Velikov wrote: > > On Mon, 24 Feb 2020 at 11:06, Gerd Hoffmann wrote: > > > > On Fri, Feb 21, 2020 at 04:54:02PM -0800, Gurchetan Singh wrote: > > > On Fri, Feb 21, 2020 at 3:06 PM Chia-I Wu wrote: > > > > > >

Re: [PATCH v5 1/3] drm/shmem: add support for per object caching flags.

2020-02-26 Thread Chia-I Wu
On Wed, Feb 26, 2020 at 10:25 AM Thomas Hellström (VMware) wrote: > > Hi, Gerd, > > While looking at this patchset I came across some stuff that seems > strange but that was merged in a previous patchset. > > (please refer to > https://lists.freedesktop.org/archives/dri-devel/2018-September/190001

Re: [PATCH 2/2] [RFC] drm/virtgpu: modify uapi with stride/layer_stride fix

2020-02-28 Thread Chia-I Wu
On Wed, Oct 2, 2019 at 5:18 PM Gurchetan Singh wrote: > > On Wed, Oct 2, 2019 at 1:49 AM Gerd Hoffmann wrote: > > > > On Tue, Oct 01, 2019 at 06:49:35PM -0700, Gurchetan Singh wrote: > > > This doesn't really break userspace, since it always passes down > > > 0 for stride/layer_stride currently.

Re: [RFC PATCH 0/8] *** Per context fencing ***

2020-03-11 Thread Chia-I Wu
On Wed, Mar 11, 2020 at 3:36 AM Gerd Hoffmann wrote: > > Hi, > > > I should've been more clear -- this is an internal cleanup/preparation and > > the per-context changes are invisible to host userspace. > > Ok, it wasn't clear that you don't flip the switch yet. In general the > commit messages

Re: [RFC PATCH 0/8] *** Per context fencing ***

2020-03-11 Thread Chia-I Wu
On Wed, Mar 11, 2020 at 4:36 PM Gurchetan Singh wrote: > > > > On Wed, Mar 11, 2020 at 3:36 AM Gerd Hoffmann wrote: >> >> Hi, >> >> > I should've been more clear -- this is an internal cleanup/preparation and >> > the per-context changes are invisible to host userspace. >> >> Ok, it wasn't clea

Re: [RFC PATCH 0/8] *** Per context fencing ***

2020-03-13 Thread Chia-I Wu
On Thu, Mar 12, 2020 at 4:08 PM Gurchetan Singh wrote: > > > > On Thu, Mar 12, 2020 at 2:29 AM Gerd Hoffmann wrote: >> >> On Wed, Mar 11, 2020 at 04:36:16PM -0700, Gurchetan Singh wrote: >> > On Wed, Mar 11, 2020 at 3:36 AM Gerd Hoffmann wrote: >> > >> > > Hi, >> > > >> > > > I should've been

Re: [RFC PATCH 0/8] *** Per context fencing ***

2020-03-17 Thread Chia-I Wu
On Mon, Mar 16, 2020 at 3:44 PM Gerd Hoffmann wrote: > > Hi, > > > >> At virtio level it is pretty simple: The host completes the SUBMIT_3D > > >> virtio command when it finished rendering, period. > > >> > > >> > > >> On the guest side we don't need the fence_id. The completion callback > > >

Re: [PATCH] drm/virtio: add missing virtio_gpu_array_lock_resv call

2020-01-10 Thread Chia-I Wu
; > Thanks a lot! With this patch applied, my VM doesn't throw lockdep > warnings anymore. If you want, you can add: > > Tested-by: Jann Horn > > > Reported-by: Jann Horn > > Signed-off-by: Gerd Hoffmann Reviewed-by: Chia-I Wu > > --- > > driver

[PATCH 00/11] drm/virtio: fixes and cleanups for vbuf queuing

2020-02-05 Thread Chia-I Wu
This series consists of fixes and cleanups for virtio_gpu_queue_fenced_ctrl_buffer, except for the last patch. The fixes are for corner cases that were overlooked. The cleanups make the last patch easier, but they should be good in themselves as well. The last patch changes the disable_notify me

[PATCH 01/11] drm/virtio: fix a wait_event condition

2020-02-05 Thread Chia-I Wu
outcnt may be greater than 1 since commit e1218b8c0cc1 (drm/virtio: Use vmalloc for command buffer allocations.). Signed-off-by: Chia-I Wu Cc: David Riley --- drivers/gpu/drm/virtio/virtgpu_vq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio

[PATCH 05/11] drm/virtio: unlock object array on errors

2020-02-05 Thread Chia-I Wu
We don't propagate erros to the callers. We have to unlock object arrays on errors. Signed-off-by: Chia-I Wu --- drivers/gpu/drm/virtio/virtgpu_vq.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/v

[PATCH 02/11] drm/virtio: remove incorrect ENOSPC check

2020-02-05 Thread Chia-I Wu
incorrect and unnecessary error path. This also adds a WARN_ON(ret) until we properly handle errors. Signed-off-by: Chia-I Wu Cc: David Riley --- drivers/gpu/drm/virtio/virtgpu_vq.c | 19 ++- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/virtio

[PATCH 04/11] drm/virtio: no need to pass virtio_gpu_ctrl_hdr

2020-02-05 Thread Chia-I Wu
We can get it from vbuf. Signed-off-by: Chia-I Wu --- drivers/gpu/drm/virtio/virtgpu_vq.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 312fd8a039a1e..5815c7d50dc20

[PATCH 08/11] drm/virtio: move the check for vqs_ready earlier

2020-02-05 Thread Chia-I Wu
When vqs_ready is false, vq should be considered invalid and we should not check vq->num_free. After this change, a fenced command queued before the vqs are ready will have fence id 0 and will be considered done. Signed-off-by: Chia-I Wu --- drivers/gpu/drm/virtio/virtgpu_vq.c |

[PATCH 06/11] drm/virtio: set up virtqueue sgs before locking

2020-02-05 Thread Chia-I Wu
sgs setup does not need to be in the critical section. Signed-off-by: Chia-I Wu --- drivers/gpu/drm/virtio/virtgpu_vq.c | 66 +++-- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c

[PATCH 09/11] drm/virtio: avoid an infinite loop

2020-02-05 Thread Chia-I Wu
Make sure elemcnt does not exceed the maximum element count in virtio_gpu_queue_ctrl_sgs. We should improve our error handling or impose a size limit on execbuffer, which are TODOs. Signed-off-by: Chia-I Wu Cc: David Riley --- drivers/gpu/drm/virtio/virtgpu_drv.h | 1 + drivers/gpu/drm

[PATCH 07/11] drm/virtio: move locking into virtio_gpu_queue_ctrl_sgs

2020-02-05 Thread Chia-I Wu
Signed-off-by: Chia-I Wu --- drivers/gpu/drm/virtio/virtgpu_vq.c | 70 ++--- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 6ccb2a54dfb3c..299470aac281a 100644 --- a/drivers

[PATCH 10/11] drm/virtio: move virtqueue_notify into virtio_gpu_queue_ctrl_sgs

2020-02-05 Thread Chia-I Wu
It becomes clear that virtio_gpu_queue_fenced_ctrl_buffer should be responsible for setting up sgs and virtio_gpu_queue_ctrl_sgs should be responsible for queuing sgs. Signed-off-by: Chia-I Wu --- drivers/gpu/drm/virtio/virtgpu_vq.c | 22 ++ 1 file changed, 10 insertions

[PATCH 11/11] drm/virtio: rework virtio_gpu_enable_notify

2020-02-05 Thread Chia-I Wu
Call virtqueue_kick_prepare once in virtio_gpu_enable_notify, not whenever a command is added. This should be more efficient since the intention is to batch commands. Signed-off-by: Chia-I Wu --- drivers/gpu/drm/virtio/virtgpu_drv.h | 1 - drivers/gpu/drm/virtio/virtgpu_vq.c | 28

[PATCH 03/11] drm/virtio: add virtio_gpu_vbuf_ctrl_hdr

2020-02-05 Thread Chia-I Wu
It is a helper to return the virtio_gpu_ctrl_hdr in a vbuf. Signed-off-by: Chia-I Wu --- drivers/gpu/drm/virtio/virtgpu_vq.c | 20 +++- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index

Re: [PATCH 2/4] drm/virtio: resource teardown tweaks

2020-02-05 Thread Chia-I Wu
On Wed, Feb 5, 2020 at 3:00 AM Gerd Hoffmann wrote: > > Add new virtio_gpu_cleanup_object() helper function for object cleanup. > Wire up callback function for resource unref, do cleanup from callback > when we know the host stopped using the resource. > > Signed-off-by: Gerd Hoffmann > --- > dr

Re: [PATCH 4/4] drm/virtio: move virtio_gpu_mem_entry initialization to new function

2020-02-05 Thread Chia-I Wu
On Wed, Feb 5, 2020 at 3:00 AM Gerd Hoffmann wrote: > > Introduce new virtio_gpu_object_shmem_init() helper function which will > create the virtio_gpu_mem_entry array, containing the backing storage > information for the host. For the most path this just moves code from > virtio_gpu_object_attac

Re: [PATCH] drm/virtio: ratelimit error logging

2020-02-05 Thread Chia-I Wu
On Wed, Feb 5, 2020 at 2:26 AM Gerd Hoffmann wrote: > > Avoid flooding the log in case we screw up badly. > > Signed-off-by: Gerd Hoffmann Reviewed-by: Chia-I Wu > --- > drivers/gpu/drm/virtio/virtgpu_vq.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) >

Re: [PATCH 09/11] drm/virtio: avoid an infinite loop

2020-02-06 Thread Chia-I Wu
On Thu, Feb 6, 2020 at 1:49 AM Gerd Hoffmann wrote: > > On Wed, Feb 05, 2020 at 10:19:53AM -0800, Chia-I Wu wrote: > > Make sure elemcnt does not exceed the maximum element count in > > virtio_gpu_queue_ctrl_sgs. We should improve our error handling or > > impose a

Re: [PATCH] drm/virtio: fix ring free check

2020-02-06 Thread Chia-I Wu
} > > - if (vq->num_free < elemcnt) { > + indirect = virtio_has_feature(vgdev->vdev, > VIRTIO_RING_F_INDIRECT_DESC); > + vqcnt = indirect ? 1 : elemcnt; Is the feature dynamic and require the lock held? If not, the result can be cached and the fixup can happen before grabbin

Re: [PATCH 2/4] drm/virtio: resource teardown tweaks

2020-02-06 Thread Chia-I Wu
On Wed, Feb 5, 2020 at 10:43 PM Gerd Hoffmann wrote: > > > > - > > > - drm_gem_shmem_free_object(obj); > > > + if (bo->created) { > > > + virtio_gpu_cmd_unref_resource(vgdev, bo); > > > + /* completion handler calls virtio_gpu_cleanup_object() */ > > nitpick

Re: [PATCH 4/4] drm/virtio: move virtio_gpu_mem_entry initialization to new function

2020-02-06 Thread Chia-I Wu
On Thu, Feb 6, 2020 at 12:55 AM Gerd Hoffmann wrote: > > Hi, > > > > virtio_gpu_cmd_resource_attach_backing(vgdev, obj->hw_res_handle, > > > - ents, nents, > > > + obj->ents, obj->nents, > > >

Re: [PATCH] drm/virtio: Fix warning in virtio_gpu_queue_fenced_ctrl_buffer.

2019-09-12 Thread Chia-I Wu
On Thu, Sep 12, 2019 at 9:00 AM David Riley wrote: > > Fix warning introduced with commit e1218b8c0cc1 > ("drm/virtio: Use vmalloc for command buffer allocations.") > from drm-misc-next. > > Signed-off-by: David Riley Reviewed-by: Chia-I Wu > --- > drive

Re: [PATCH] drm/virtio: enable prime mmap support

2019-09-12 Thread Chia-I Wu
On Thu, Sep 12, 2019 at 4:46 AM Gerd Hoffmann wrote: > > Signed-off-by: Gerd Hoffmann Reviewed-by: Chia-I Wu > --- > drivers/gpu/drm/virtio/virtgpu_drv.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c > b/drivers/gpu/

Re: [PATCH 4/4] udmabuf: implement begin_cpu_access/end_cpu_access hooks

2019-12-09 Thread Chia-I Wu
On Mon, Dec 2, 2019 at 5:36 PM Gurchetan Singh wrote: > > With the misc device, we should end up using the result of > get_arch_dma_ops(..) or dma-direct ops. > > This can allow us to have WC mappings in the guest after > synchronization. > > Signed-off-by: Gurchetan Singh > --- > drivers/dma-bu

Re: [PATCH v2] drm/virtio: make resource id workaround runtime switchable.

2019-08-26 Thread Chia-I Wu
On Thu, Aug 22, 2019 at 3:26 AM Gerd Hoffmann wrote: > > Also update the comment with a reference to the virglrenderer fix. > > Signed-off-by: Gerd Hoffmann Reviewed-by: Chia-I Wu > --- > drivers/gpu/drm/virtio/virtgpu_object.c | 44 ++--- > 1 file c

Re: [PATCH v2] drm/virtio: add plane check

2019-08-26 Thread Chia-I Wu
On Thu, Aug 22, 2019 at 2:47 AM Gerd Hoffmann wrote: > > Use drm_atomic_helper_check_plane_state() > to sanity check the plane state. > > Signed-off-by: Gerd Hoffmann > --- > drivers/gpu/drm/virtio/virtgpu_plane.c | 17 - > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff

Re: [PATCH v2] drm/virtio: add plane check

2019-08-27 Thread Chia-I Wu
On Mon, Aug 26, 2019 at 10:21 PM Gerd Hoffmann wrote: > > On Mon, Aug 26, 2019 at 03:34:56PM -0700, Chia-I Wu wrote: > > On Thu, Aug 22, 2019 at 2:47 AM Gerd Hoffmann wrote: > > > > > > Use drm_atomic_helper_check_plane_state() > > > to sanity check the

Re: [PATCH 2/2] drm/virtio: notify virtqueues without holding spinlock

2019-08-27 Thread Chia-I Wu
k. This avoids triggering a vmexit while holding the lock and > thereby fixes a rather bad spinlock contention. > > Suggested-by: Chia-I Wu > Signed-off-by: Gerd Hoffmann Series is Reviewed-by: Chia-I Wu > --- > drivers/gpu/drm/virtio/virtgpu_vq.c | 25 +++--

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

2019-08-28 Thread Chia-I Wu
On Fri, Aug 23, 2019 at 2:55 AM Gerd Hoffmann wrote: > > 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 Hoffma

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

2019-08-28 Thread Chia-I Wu
per. > v5: some small optimizations (Chia-I Wu). > v4: make them virtio-private instead of generic helpers. > > Signed-off-by: Gerd Hoffmann > --- > drivers/gpu/drm/virtio/virtgpu_drv.h | 17 + > drivers/gpu/drm/virtio/virtgpu_gem.c | 93 > 2 file

Re: [PATCH v8 00/18] drm/virtio: switch from ttm to gem shmem helpers.

2019-08-28 Thread Chia-I Wu
On Fri, Aug 23, 2019 at 2:55 AM Gerd Hoffmann wrote: > > ttm increasingly gets into the way while hacking on virtio-gpu memory > management. It also overkill for what virtio-gpu needs. Lets get rid > of it. > > v8: > - rebase to latest drm-misc-next, adapt to changes. Other than two (minor) com

Re: [PATCH v9 00/18] drm/virtio: switch from ttm to gem shmem helpers.

2019-08-29 Thread Chia-I Wu
The series is Reviewed-by: Chia-I Wu However I ran into a deadlock with one GPU-heavy app. When I exits Unigine Valley benchmark with ctrl-c, the entire driver locks up probably 8 out of 10 times on my machine. When that happens, virtio_gpu_dequeue_ctrl_func does not return and is blocked

Re: [PATCH] drm/virtio: Use vmalloc for command buffer allocations.

2019-08-30 Thread Chia-I Wu
On Thu, Aug 29, 2019 at 2:24 PM David Riley wrote: > > Userspace requested command buffer allocations could be too large > to make as a contiguous allocation. Use vmalloc if necessary to > satisfy those allocations. > > Signed-off-by: David Riley > --- > drivers/gpu/drm/virtio/virtgpu_ioctl.c |

Re: [PATCH] drm/virtio: Use vmalloc for command buffer allocations.

2019-08-30 Thread Chia-I Wu
On Fri, Aug 30, 2019 at 4:16 AM Gerd Hoffmann wrote: > > Hi, > > > > > - kfree(vbuf->data_buf); > > > > + kvfree(vbuf->data_buf); > > > > > > if (is_vmalloc_addr(vbuf->data_buf)) ... > > > > > > needed here I gues? > > > > > > > kvfree() handles vmalloc/kmalloc/kvmalloc internally by doi

Re: [PATCH] drm/virtio: add worker for object release

2019-09-03 Thread Chia-I Wu
worker is also the one which will free up slots in the command > queue. > > Reported-by: Chia-I Wu > Signed-off-by: Gerd Hoffmann Tested-by: Chia-I Wu Reviewed-by: Chia-I Wu > --- > drivers/gpu/drm/virtio/virtgpu_drv.h | 8 > drive

Re: [PATCH] drm/virtio: fix command submission with objects but without fence.

2019-09-04 Thread Chia-I Wu
On Wed, Sep 4, 2019 at 12:48 AM Gerd Hoffmann wrote: > > Only call virtio_gpu_array_add_fence if we actually have a fence. > > Fixes: da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing") > Signed-off-by: Gerd Hoffmann > --- > drivers/gpu/drm/virtio/virtgpu_vq.c | 9 + >

Re: [PATCH] drm/virtio: fix command submission with objects but without fence.

2019-09-05 Thread Chia-I Wu
On Wed, Sep 4, 2019 at 10:23 PM Gerd Hoffmann wrote: > > On Wed, Sep 04, 2019 at 04:10:30PM -0700, Chia-I Wu wrote: > > On Wed, Sep 4, 2019 at 12:48 AM Gerd Hoffmann wrote: > > > > > > Only call virtio_gpu_array_add_fence if we actually have a fence. > > >

Re: [PATCH 0/7] dma-buf: Add an API for exporting sync files (v11)

2021-06-10 Thread Chia-I Wu
On Tue, May 25, 2021 at 2:18 PM Jason Ekstrand wrote: > Modern userspace APIs like Vulkan are built on an explicit > synchronization model. This doesn't always play nicely with the > implicit synchronization used in the kernel and assumed by X11 and > Wayland. The client -> compositor half of th

[PATCH] drm/amdkfd: fix a potential double free in pqm_create_queue

2023-03-07 Thread Chia-I Wu
Set *q to NULL on errors, otherwise pqm_create_queue would free it again. Signed-off-by: Chia-I Wu --- drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers

Re: [PATCH v2 0/3] drm/msm/gpu: Devfreq fixes+tuning

2023-01-13 Thread Chia-I Wu
Series is Reviewed-by: Chia-I Wu On Tue, Jan 10, 2023 at 3:14 PM Rob Clark wrote: > > From: Rob Clark > > Rob Clark (3): > drm/msm/gpu: Add devfreq tuning debugfs > drm/msm/gpu: Bypass PM QoS constraint for idle clamp > drm/msm/gpu: Add default devfreq thresholds

Re: [Freedreno] [PATCH 0/3] drm/msm/a6xx: devcore dump fixes

2022-10-13 Thread Chia-I Wu
On Thu, Oct 13, 2022 at 3:55 PM Rob Clark wrote: > > From: Rob Clark > > First patch fixes a recently introduced memory corruption, the remaining > two are cleanups. Series is Reviewed-by: Chia-I Wu > Rob Clark (3): > drm/msm/a6xx: Fix kvzalloc vs state_kcalloc usage &

Re: [PATCH] drm/msm: Enable clamp_to_idle for 7c3

2022-11-15 Thread Chia-I Wu
adreno/a6xx_gpu.c | 14 +++--- > > 1 file changed, 7 insertions(+), 7 deletions(-) > > Reviewed-by: Douglas Anderson Reviewed-by: Chia-I Wu

Re: [PATCH v3 2/2] drm/msm: Hangcheck progress detection

2022-11-09 Thread Chia-I Wu
u; > int id; > @@ -64,6 +69,25 @@ struct msm_ringbuffer { > uint64_t memptrs_iova; > struct msm_fence_context *fctx; > > + /** > +* hangcheck_progress_retries: > +* > +* The number of extra hangcheck duration cycles that we have given > +

Re: [PATCH] drm/virtio: Fix GEM handle creation UAF

2022-12-16 Thread Chia-I Wu
r that reason, dropping > the handle's reference must be done *after* we are done dereferencing > the object. > > Signed-off-by: Rob Clark Reviewed-by: Chia-I Wu

Re: [PATCH] drm/panfrost: Fix GEM handle creation UAF

2022-12-16 Thread Chia-I Wu
On Fri, Dec 16, 2022 at 3:34 PM Rob Clark wrote: > > From: Rob Clark > > Relying on an unreturned handle to hold a reference to an object we > dereference is not safe. Userspace can guess the handle and race us > by closing the handle from another thread. The _create_with_handle() > that return

Re: [PATCH] drm/panfrost: Fix GEM handle creation UAF

2022-12-16 Thread Chia-I Wu
On Fri, Dec 16, 2022 at 4:20 PM Rob Clark wrote: > > On Fri, Dec 16, 2022 at 3:59 PM Chia-I Wu wrote: > > > > On Fri, Dec 16, 2022 at 3:34 PM Rob Clark wrote: > > > > > > From: Rob Clark > > > > > > Relying on an unreturned handle to hol

[PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED

2023-04-25 Thread Chia-I Wu
Signed-off-by: Chia-I Wu Cc: sta...@vger.kernel.org --- drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c index e9b45089a28a6..863b2a34b2d64

Re: [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED

2023-04-25 Thread Chia-I Wu
--- > > From: amd-gfx On Behalf Of Chia- > > I Wu > > Sent: Wednesday, April 26, 2023 8:48 AM > > To: dri-devel@lists.freedesktop.org > > Cc: Pan, Xinhui ; linux-ker...@vger.kernel.org; > > sta...@vger.kernel.org; amd-...@lists.freedesktop.org; Daniel

[PATCH v2] drm/amdgpu: add a missing lock for AMDGPU_SCHED

2023-04-25 Thread Chia-I Wu
mgr->ctx_handles should be protected by mgr->lock. v2: improve commit message Signed-off-by: Chia-I Wu Cc: sta...@vger.kernel.org --- drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sche

Re: [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED

2023-04-25 Thread Chia-I Wu
On Tue, Apr 25, 2023 at 9:58 PM Greg KH wrote: > > On Tue, Apr 25, 2023 at 05:48:27PM -0700, Chia-I Wu wrote: > > Signed-off-by: Chia-I Wu > > Cc: sta...@vger.kernel.org > > I know I can not take patches without any changelog text at all, maybe > the DRM developers a

[PATCH v3] drm/amdgpu: add a missing lock for AMDGPU_SCHED

2023-04-26 Thread Chia-I Wu
mgr->ctx_handles should be protected by mgr->lock. v2: improve commit message v3: add a Fixes tag Signed-off-by: Chia-I Wu Reviewed-by: Christian König Fixes: 52c6a62c64fac ("drm/amdgpu: add interface for editing a foreign process's priority v3") --- drivers/gpu/drm/amd/

Re: [PATCH v2] drm/amdgpu: add a missing lock for AMDGPU_SCHED

2023-04-26 Thread Chia-I Wu
On Wed, Apr 26, 2023 at 4:05 AM Christian König wrote: > > Am 26.04.23 um 08:17 schrieb Chia-I Wu: > > mgr->ctx_handles should be protected by mgr->lock. > > > > v2: improve commit message > > > > Signed-off-by: Chia-I Wu > > Cc: sta...@

[PATCH] drm/amdkfd: fix potential kgd_mem UAFs

2023-03-08 Thread Chia-I Wu
kgd_mem should be accessed with p->mutex locked, or it could have been freed by kfd_ioctl_free_memory_of_gpu. Signed-off-by: Chia-I Wu --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amd

[PATCH 1/2] amdgpu: validate drm_amdgpu_gem_va addrs for all ops

2023-05-09 Thread Chia-I Wu
Extend the address and size validations to AMDGPU_VA_OP_UNMAP and AMDGPU_VA_OP_CLEAR by moving the validations to amdgpu_gem_va_ioctl. Internal users of amdgpu_vm_bo_map are no longer validated but they should be fine. Userspace (radeonsi and radv) seems fine as well. --- drivers/gpu/drm/amd/amd

[PATCH 2/2] amdgpu: validate drm_amdgpu_gem_va against overflows

2023-05-09 Thread Chia-I Wu
The existing validations are incorrect and insufficient. This is motivated by OOB access in amdgpu_vm_update_range when offset_in_bo+map_size overflows. Fixes: 9f7eb5367d00 ("drm/amdgpu: actually use the VM map parameters") --- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 +-- drivers/gpu/drm

Re: [PATCH 1/2] amdgpu: validate drm_amdgpu_gem_va addrs for all ops

2023-05-17 Thread Chia-I Wu
On Tue, May 9, 2023 at 11:33 AM Chia-I Wu wrote: > > Extend the address and size validations to AMDGPU_VA_OP_UNMAP and > AMDGPU_VA_OP_CLEAR by moving the validations to amdgpu_gem_va_ioctl. > > Internal users of amdgpu_vm_bo_map are no longer validated but they > should be f

Re: [PATCH 1/2] amdgpu: validate drm_amdgpu_gem_va addrs for all ops

2023-05-21 Thread Chia-I Wu
On Thu, May 18, 2023 at 1:12 PM Alex Deucher wrote: > > On Wed, May 17, 2023 at 5:27 PM Chia-I Wu wrote: > > > > On Tue, May 9, 2023 at 11:33 AM Chia-I Wu wrote: > > > > > > Extend the address and size validations to AMDGPU_VA_OP_UNMAP and > > > AM

Re: [PATCH 1/2] amdgpu: validate drm_amdgpu_gem_va addrs for all ops

2023-05-23 Thread Chia-I Wu
On Mon, May 22, 2023 at 12:12 PM Christian König wrote: > > Am 21.05.23 um 20:49 schrieb Chia-I Wu: > > On Thu, May 18, 2023 at 1:12 PM Alex Deucher wrote: > >> On Wed, May 17, 2023 at 5:27 PM Chia-I Wu wrote: > >>> On Tue, May 9, 2023 at 11:33 AM Chia-I Wu wro

[PATCH v2] amdgpu: validate drm_amdgpu_gem_va addrs

2023-05-23 Thread Chia-I Wu
offset_in_bo+map_size overflows. Userspace (radeonsi and radv) seems fine as well. v2: keep the validations in amdgpu_vm_bo_map Fixes: 9f7eb5367d00 ("drm/amdgpu: actually use the VM map parameters") Signed-off-by: Chia-I Wu --- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 15 +++ d

[PATCH] drm/amdgpu: fix xclk freq on CHIP_STONEY

2023-06-01 Thread Chia-I Wu
According to Alex, most APUs from that time seem to have the same issue (vbios says 48Mhz, actual is 100Mhz). I only have a CHIP_STONEY so I limit the fixup to CHIP_STONEY --- drivers/gpu/drm/amd/amdgpu/vi.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/g

[PATCH v3] amdgpu: validate offset_in_bo of drm_amdgpu_gem_va

2023-06-01 Thread Chia-I Wu
y use the VM map parameters") Signed-off-by: Chia-I Wu --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 22f9a65ca0fc7..76d

Re: [PATCH] drm/amdgpu: fix xclk freq on CHIP_STONEY

2023-06-02 Thread Chia-I Wu
On Fri, Jun 2, 2023 at 11:50 AM Alex Deucher wrote: > > Nevermind, missing your Signed-off-by. Please add and I'll apply. Sorry that I keep forgetting... This patch is Signed-off-by: Chia-I Wu I can send v2 if necessary. > > Alex >

pages pinned for BO lifetime and security

2020-07-21 Thread Chia-I Wu
Hi list, virtio-gpu is moving in the direction where BO pages are pinned for the lifetime for simplicity. I am wondering if that is considered a security issue in general, especially after running into the description of the new DMABUF_MOVE_NOTIFY config option. Most drivers do not have a shrink

Re: pages pinned for BO lifetime and security

2020-07-22 Thread Chia-I Wu
t; > >> > > >> Currently, the user seems to amdgpu for P2P dma-buf and it seems to > > >> plumb ttm (*move_notify) callback to dma-buf. We're not sure if it's a > > >> security issue occurring across DRM drivers, or one more specific to the &g

Re: [PATCH 3/3] drm/virtio: delete notify in virtio_gpu_object_create

2020-03-24 Thread Chia-I Wu
On Wed, Mar 25, 2020 at 12:44 AM Gurchetan Singh wrote: > > - For dumb buffers, virtio_gpu_gem_create can notify. > - For 3D buffers, virtio_gpu_gem_object_open can notify. Hmm, I feel this is a bit complex. virtio_gpu_gem_object_open may not notify, and the caller needs to know about it. Can we

Re: [PATCH] drm/virtio: delete notify in virtio_gpu_object_create

2020-03-25 Thread Chia-I Wu
On Wed, Mar 25, 2020 at 8:41 AM Gurchetan Singh wrote: > > For 3D buffers, virtio_gpu_gem_object_open notifies. > We can have the same behavior for dumb buffer. We just > need to make sure the first open notifies the host for > dumb buffers. virtio_gpu_notify is cheap and does not kick unless the

Re: [PATCH] drm/virtio: delete notify in virtio_gpu_object_create

2020-03-25 Thread Chia-I Wu
On Thu, Mar 26, 2020 at 7:10 AM Gurchetan Singh wrote: > > For 3D buffers, virtio_gpu_gem_object_open notifies. > We can have the same behavior for dumb buffer. > > v2: virtio_gpu_gem_object_open always notifies > v3: avoid boolean variable Series is Reviewed-by: Chia-I Wu

Re: [PATCH v2 22/23] drm/virtio: implement blob resources: resource create blob ioctl

2020-09-03 Thread Chia-I Wu
On Wed, Sep 2, 2020 at 2:09 PM Gurchetan Singh wrote: > > From: Gerd Hoffmann > > Implement resource create blob as specified. > > Signed-off-by: Gerd Hoffmann > Co-developed-by: Gurchetan Singh > Signed-off-by: Gurchetan Singh > Acked-by: Tomeu Vizoso > --- > drivers/gpu/drm/virtio/virtgpu_

<    1   2   3   >