[PATCH v18 02/26] drm/gem: Add _locked postfix to functions that have unlocked counterpart

2023-10-29 Thread Dmitry Osipenko
Add _locked postfix to drm_gem functions that have unlocked counterpart functions to make GEM functions naming more consistent and intuitive in regards to the locking requirements. Reviewed-by: Boris Brezillon Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm

[PATCH v18 00/26] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers

2023-10-29 Thread Dmitry Osipenko
quot;map->is_iomem" from drm-shmem, as was suggested by Thomas Zimmermann. - Added acks and r-b's that were given to v10. v10:- Was partially applied to misc-fixes/next. https://lore.kernel.org/dri-devel/6c16f303-81df-7ebe-85e9-51bb40a8b...@collabora.com/T/ Dmitry Osi

Re: [RFC PATCH v2 1/1] drm/virtio: new fence for every plane update

2023-10-23 Thread Dmitry Osipenko
; old and new planes are pointing to the same framebuffer. > > v2: removed virtio_gpu_plane_duplicate_state as the existing helper, > drm_atomic_helper_plane_destroy_state does the same. > > Cc: Dmitry Osipenko > Cc: Gerd Hoffmann > Cc: Vivek Kasireddy >

Re: [PATCH v3 2/2] drm/uapi: add explicit virtgpu context debug name

2023-10-22 Thread Dmitry Osipenko
terminator) **should** be <= 64 bytes. Otherwise, > the debug_name will be truncated to 64 bytes. > > Link to open-source userspace: > https://android-review.googlesource.com/c/platform/hardware/google/gfxstream/+/2787176 > > Signed-off-by: Gurchetan Singh > Revie

Re: [PATCH v3] drm/virtio: add new virtio gpu capset definitions

2023-10-18 Thread Dmitry Osipenko
On 10/19/23 02:25, Gurchetan Singh wrote: > On Tue, Oct 10, 2023 at 9:41 PM Huang Rui wrote: > >> On Tue, Oct 10, 2023 at 11:52:14PM +0800, Dmitry Osipenko wrote: >>> On 10/10/23 18:40, Dmitry Osipenko wrote: >>>> On 10/10/23 16:57, Huang Rui wrote: >>

Re: [PATCH v3 2/2] drm/uapi: add explicit virtgpu context debug name

2023-10-18 Thread Dmitry Osipenko
terminator) **should** be <= 64 bytes. Otherwise, > the debug_name will be truncated to 64 bytes. > > Link to open-source userspace: > https://android-review.googlesource.com/c/platform/hardware/google/gfxstream/+/2787176 > > Signed-off-by: Gurchetan Singh > Revie

Re: [PATCH v2 2/2] drm/uapi: add explicit virtgpu context debug name

2023-10-18 Thread Dmitry Osipenko
On 10/18/23 20:04, Gurchetan Singh wrote: > + > + ret = strncpy_from_user(vfpriv->debug_name, > + u64_to_user_ptr(value), > + DEBUG_NAME_MAX_LEN); > + > + if (ret < 0) {

Re: [PATCH 1/3] drm/virtio: use uint64_t more in virtio_gpu_context_init_ioctl

2023-10-16 Thread Dmitry Osipenko
valid_ring_mask, param, value; > size_t len; > struct drm_virtgpu_context_set_param *ctx_set_params = NULL; > struct virtio_gpu_device *vgdev = dev->dev_private; Reviewed-by: Dmitry Osipenko -- Best regards, Dmitry

Re: [PATCH 2/3] drm/uapi: add explicit virtgpu context debug name

2023-10-16 Thread Dmitry Osipenko
On 10/16/23 21:41, Gurchetan Singh wrote: > There are two problems with the current method of determining the > virtio-gpu debug name. > > 1) TASK_COMM_LEN is defined to be 16 bytes only, and this is a >Linux kernel idiom (see PR_SET_NAME + PR_GET_NAME). Though, >Android/FreeBSD get

Re: [PATCH 3/3] drm/virtio: implement debug name via CONTEXT_INIT

2023-10-16 Thread Dmitry Osipenko
On 10/16/23 21:42, Gurchetan Singh wrote: > This allows setting the debug name during CONTEXT_INIT. > > Signed-off-by: Gurchetan Singh > --- > drivers/gpu/drm/virtio/virtgpu_drv.h | 4 +++ > drivers/gpu/drm/virtio/virtgpu_ioctl.c | 38 ++ > 2 files changed, 36

Re: [PATCH v3] drm/virtio: add new virtio gpu capset definitions

2023-10-10 Thread Dmitry Osipenko
On 10/10/23 18:40, Dmitry Osipenko wrote: > On 10/10/23 16:57, Huang Rui wrote: >> These definitions are used fro qemu, and qemu imports this marco in the >> headers to enable gfxstream, venus, cross domain, and drm (native >> context) for virtio gpu. So it should add them ev

Re: [PATCH v3] drm/virtio: add new virtio gpu capset definitions

2023-10-10 Thread Dmitry Osipenko
-off-by: Huang Rui > Reviewed-by: Akihiko Odaki > --- > > Changes V1 -> V2: > - Add all capsets including gfxstream and venus in kernel header (Dmitry > Osipenko) > > Changes V2 -> V3: > - Add missed capsets including cross domain and drm (native context) > (

Re: [PATCH v2] drm/virtio: add definitions for gfxstream and venus capset

2023-10-10 Thread Dmitry Osipenko
es V1 -> V2: > - Add all capsets including gfxstream and venus in kernel header (Dmitry > Osipenko) > > v1: https://lore.kernel.org/lkml/20230915105918.3763061-1-ray.hu...@amd.com/ > > include/uapi/linux/virtio_gpu.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-10-08 Thread Dmitry Osipenko
On 10/3/23 12:00, Boris Brezillon wrote: >> I'd prefer to keep refcounting as is, don't see how to implement your >> suggestion. > Can you be more specific? I don't really see what the problem is with > decrementing pages_use_count when you free the sgt (eviction), and > re-incrementing it when

[RFC PATCH v1 1/1] drm/virtio: Support fence-passing feature

2023-10-07 Thread Dmitry Osipenko
/-/merge_requests/1138 Link: https://gitlab.freedesktop.org/digetx/qemu/-/commits/native-context-iris Link: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679609 Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_drv.c| 1 + drivers/gpu/drm/virtio/virtgpu_drv.h| 11

[RFC PATCH v1 0/1] Support passing VirtIO-GPU fences to host for waiting

2023-10-07 Thread Dmitry Osipenko
xts, where it proved to be useful by increasing FPS up to 3x times. [1] https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1138 [2] https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679609 [3] https://gitlab.freedesktop.org/digetx/qemu/-/commits/native-context-iris Dmitry O

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-10-05 Thread Dmitry Osipenko
On 10/3/23 14:09, Boris Brezillon wrote: > Unmap tends to refer to a VM related operation (removing a mapping in > the CPU or GPU VM), so it's confusing too IMHO. What we do here is > return pages to the shmem file logic, so they can be reclaimed. > > Given the drm_gem function doing that is

Re: [RFC PATCH 3/3] drm/virtio: drm_gem_plane_helper_prepare_fb for obj synchronization

2023-10-04 Thread Dmitry Osipenko
On 9/6/23 00:08, Kim, Dongwon wrote: > > I don't believe the guest will start rendering on the same FB while host is > consuming it because the virtio-gpu driver on the guest won't release > the FB for the next > frame before it gets the virtio resp for the resource flush command and > the host

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-10-02 Thread Dmitry Osipenko
On 9/26/23 10:35, Boris Brezillon wrote: + __drm_gem_shmem_release_pages(shmem); >>> Make sure you drop the implicit pages_use_count ref the sgt had, this >>> way you can still tie the necessity to drop the pages to sgt != NULL in >>> drm_gem_shmem_free(). >> This will require further

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-10-02 Thread Dmitry Osipenko
On 9/26/23 10:35, Boris Brezillon wrote: >> On 9/15/23 11:46, Boris Brezillon wrote: >>> The naming becomes quite confusing, with drm_gem_shmem_unpin_locked() >>> and drm_gem_shmem_unpin_pages_locked(). By the look of it, it seems to >>> do exactly the opposite of drm_gem_shmem_swapin_locked(),

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-09-25 Thread Dmitry Osipenko
On 9/15/23 11:46, Boris Brezillon wrote: >> -static int drm_gem_shmem_get_pages_locked(struct drm_gem_shmem_object >> *shmem) >> +static int >> +drm_gem_shmem_acquire_pages(struct drm_gem_shmem_object *shmem, bool init) >> { >> struct drm_gem_object *obj = >base; >> struct page

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-09-25 Thread Dmitry Osipenko
On 9/15/23 11:46, Boris Brezillon wrote: > The naming becomes quite confusing, with drm_gem_shmem_unpin_locked() > and drm_gem_shmem_unpin_pages_locked(). By the look of it, it seems to > do exactly the opposite of drm_gem_shmem_swapin_locked(), except for > the missing ->evicted = true, which we

Re: [PATCH] drm/virtio: add definition for venus capset

2023-09-20 Thread Dmitry Osipenko
On 9/15/23 13:59, Huang Rui wrote: > This definition is used fro qemu, and qemu imports this marco in the > headers to enable venus for virtio gpu. So it should add it even kernel > doesn't use this. > > Signed-off-by: Huang Rui > --- > > Hi all, > > We would like to add a new definition for

Re: [PATCH] drm/virtio: clean out_fence on complete_submit

2023-09-20 Thread Dmitry Osipenko
On 9/12/23 09:08, José Pekkarinen wrote: > The removed line prevents the following cleanup function > to execute a dma_fence_put on the out_fence to free its > memory, producing the following output in kmemleak: > > unreferenced object 0x888126d8ee00 (size 128): > comm "kwin_wayland", pid

[PATCH v17 17/18] drm/virtio: Support memory shrinking

2023-09-14 Thread Dmitry Osipenko
y if guest supports SWAP file or partition. Acked-by: Gerd Hoffmann Signed-off-by: Daniel Almeida Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_drv.h| 13 +- drivers/gpu/drm/virtio/virtgpu_gem.c| 35 ++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 25 +

[PATCH v17 16/18] drm/virtio: Attach shmem BOs dynamically

2023-09-14 Thread Dmitry Osipenko
attachment explicitly dynamic will allow to simplify and reuse more code when shrinker will be added. The virtio_gpu_object_shmem_init() now works under held reservation lock, which will be important to have for shrinker. Acked-by: Gerd Hoffmann Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio

[PATCH v17 15/18] drm/virtio: Pin display framebuffer BO

2023-09-14 Thread Dmitry Osipenko
-by: Gerd Hoffmann Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ drivers/gpu/drm/virtio/virtgpu_gem.c | 19 +++ drivers/gpu/drm/virtio/virtgpu_plane.c | 17 +++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers

[PATCH v17 18/18] drm/panfrost: Switch to generic memory shrinker

2023-09-14 Thread Dmitry Osipenko
Replace Panfrost's custom memory shrinker with a common drm-shmem memory shrinker. Tested-by: Steven Price # Firefly-RK3288 Reviewed-by: Steven Price Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/panfrost/Makefile | 1 - drivers/gpu/drm/panfrost/panfrost_device.h| 4

[PATCH v17 14/18] drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked()

2023-09-14 Thread Dmitry Osipenko
Export drm_gem_shmem_get_pages_sgt_locked() that will be used by virtio-gpu shrinker during GEM swap-in operation done under the held reservation lock. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 3 ++- include/drm/drm_gem_shmem_helper.h | 1 + 2 files

[PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-09-14 Thread Dmitry Osipenko
. Initialize drm-shmem internals using drmm_gem_shmem_init(drm_device), which will register drm-shmem shrinker 3. Implement madvise IOCTL that will use drm_gem_shmem_madvise() Signed-off-by: Daniel Almeida Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c| 390

[PATCH v17 11/18] drm/shmem-helper: Improve drm_gem_shmem_vmap_locked() error handling

2023-09-14 Thread Dmitry Osipenko
Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 13 +++-- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index e1fcb5154209..8a8eab4d0332 100644 --- a/drivers/gpu/drm

[PATCH v17 10/18] drm/shmem-helper: Use refcount_t for vmap_use_count

2023-09-14 Thread Dmitry Osipenko
Use refcount_t helper for vmap_use_count to make refcounting consistent with pages_use_count and pages_pin_count that use refcount_t. This also makes vmapping to benefit from the refcount_t's overflow checks. Reviewed-by: Boris Brezillon Suggested-by: Boris Brezillon Signed-off-by: Dmitry

[PATCH v17 09/18] drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin

2023-09-14 Thread Dmitry Osipenko
ned), while the new pages_pin_count will do the hard-pinning. Switch the vmap/vunmap() to use pin/unpin() functions in a preparation of addition of the memory shrinker support to drm-shmem. Reviewed-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c |

[PATCH v17 12/18] drm/shmem-helper: Prepare drm_gem_shmem_free() to shrinker addition

2023-09-14 Thread Dmitry Osipenko
that can't happen during the time when GEM is freed and lockdep doesn't know about that. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 55 +- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b

[PATCH v17 07/18] drm/shmem-helper: Use refcount_t for pages_use_count

2023-09-14 Thread Dmitry Osipenko
Use atomic refcount_t helper for pages_use_count to optimize pin/unpin functions by skipping reservation locking while GEM's pin refcount > 1. Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 33 +++-- drivers/

[PATCH v17 08/18] drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages()

2023-09-14 Thread Dmitry Osipenko
Add lockless drm_gem_shmem_get_pages() helper that skips taking reservation lock if pages_use_count is non-zero, leveraging from atomicity of the refcount_t. Make drm_gem_shmem_mmap() to utilize the new helper. Reviewed-by: Boris Brezillon Suggested-by: Boris Brezillon Signed-off-by: Dmitry

[PATCH v17 06/18] drm/shmem-helper: Add and use pages_pin_count

2023-09-14 Thread Dmitry Osipenko
be swapped out). The pages_pin_count > 1 will hard-pin pages in memory. Reviewed-by: Boris Brezillon Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 24 include/drm/drm_gem_shmem_helper.h | 10 ++ 2 fi

[PATCH v17 03/18] drm/shmem-helper: Make all exported symbols GPL

2023-09-14 Thread Dmitry Osipenko
Make all drm-shmem exported symbols GPL to make them consistent with the rest of drm-shmem symbols. Reviewed-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git

[PATCH v17 04/18] drm/shmem-helper: Refactor locked/unlocked functions

2023-09-14 Thread Dmitry Osipenko
Add locked and remove unlocked postfixes from drm-shmem function names, making names consistent with the drm/gem core code. Reviewed-by: Boris Brezillon Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c| 64

[PATCH v17 05/18] drm/shmem-helper: Remove obsoleted is_iomem test

2023-09-14 Thread Dmitry Osipenko
y: Thomas Zimmermann Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 154585ddae08..2cc0601865f6 100644 --- a/driver

[PATCH v17 01/18] drm/gem: Change locked/unlocked postfix of drm_gem_v/unmap() function names

2023-09-14 Thread Dmitry Osipenko
Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_client.c | 6 +++--- drivers/gpu/drm/drm_gem.c| 20 ++-- drivers/gpu/drm/drm_gem_framebuffer_helper.c | 6 +++--- drivers/gpu/drm/drm_internal.h

[PATCH v17 02/18] drm/gem: Add _locked postfix to functions that have unlocked counterpart

2023-09-14 Thread Dmitry Osipenko
Add _locked postfix to drm_gem functions that have unlocked counterpart functions to make GEM functions naming more consistent and intuitive in regards to the locking requirements. Reviewed-by: Boris Brezillon Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm

[PATCH v17 00/18] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers

2023-09-14 Thread Dmitry Osipenko
ext. https://lore.kernel.org/dri-devel/6c16f303-81df-7ebe-85e9-51bb40a8b...@collabora.com/T/ Dmitry Osipenko (18): drm/gem: Change locked/unlocked postfix of drm_gem_v/unmap() function names drm/gem: Add _locked postfix to functions that have unlocked counterpart drm/shmem-h

Re: [PATCH v16 15/20] drm/shmem-helper: Add memory shrinker

2023-09-14 Thread Dmitry Osipenko
On 9/14/23 16:27, Boris Brezillon wrote: ... > If you added this pages_use_count > 0 check to deal with the > 'free-partially-imported-GEM' case, I keep thinking this is not > the right fix. You should just assume that obj->import_attach == NULL > means not-a-prime-buffer, and then make sure >

Re: [PATCH v16 15/20] drm/shmem-helper: Add memory shrinker

2023-09-14 Thread Dmitry Osipenko
On 9/14/23 14:58, Boris Brezillon wrote: > On Thu, 14 Sep 2023 14:36:23 +0300 > Dmitry Osipenko wrote: > >> On 9/14/23 11:27, Boris Brezillon wrote: >>> On Thu, 14 Sep 2023 10:50:32 +0300 >>> Dmitry Osipenko wrote: >>> >>>> On 9/14/23 10:

Re: [PATCH v16 15/20] drm/shmem-helper: Add memory shrinker

2023-09-14 Thread Dmitry Osipenko
On 9/14/23 11:27, Boris Brezillon wrote: > On Thu, 14 Sep 2023 10:50:32 +0300 > Dmitry Osipenko wrote: > >> On 9/14/23 10:36, Boris Brezillon wrote: >>> On Thu, 14 Sep 2023 07:02:52 +0300 >>> Dmitry Osipenko wrote: >>> >>>> On 9/13/23 10:

Re: [PATCH v16 15/20] drm/shmem-helper: Add memory shrinker

2023-09-14 Thread Dmitry Osipenko
On 9/14/23 10:36, Boris Brezillon wrote: > On Thu, 14 Sep 2023 07:02:52 +0300 > Dmitry Osipenko wrote: > >> On 9/13/23 10:48, Boris Brezillon wrote: >>> On Wed, 13 Sep 2023 03:56:14 +0300 >>> Dmitry Osipenko wrote: >>> &

Re: [PATCH v16 15/20] drm/shmem-helper: Add memory shrinker

2023-09-13 Thread Dmitry Osipenko
On 9/13/23 10:48, Boris Brezillon wrote: > On Wed, 13 Sep 2023 03:56:14 +0300 > Dmitry Osipenko wrote: > >> On 9/5/23 11:03, Boris Brezillon wrote: >>>>* But >>>> + * acquiring the obj lock in >>>> drm_gem_shmem_

Re: [PATCH v16 15/20] drm/shmem-helper: Add memory shrinker

2023-09-12 Thread Dmitry Osipenko
On 9/5/23 11:03, Boris Brezillon wrote: >>* But >> + * acquiring the obj lock in >> drm_gem_shmem_release_pages_locked() can >> + * cause a locking order inversion between >> reservation_ww_class_mutex >> + * and fs_reclaim. >> + *

Re: [PATCH v16 09/20] drm/shmem-helper: Remove obsoleted is_iomem test

2023-09-12 Thread Dmitry Osipenko
On 9/5/23 09:46, Boris Brezillon wrote: > On Sun, 3 Sep 2023 20:07:25 +0300 > Dmitry Osipenko wrote: > >> Everything that uses the mapped buffer should be agnostic to is_iomem. >> The only reason for the is_iomem test is that we're setting shmem->vaddr >> t

Re: [PATCH v16 15/20] drm/shmem-helper: Add memory shrinker

2023-09-11 Thread Dmitry Osipenko
On 9/7/23 13:03, Dan Carpenter wrote: > 2c607edf57db6a Dmitry Osipenko 2023-09-03 @724if (page_offset >= > num_pages || (!shmem->pages &&

Re: [PATCH v16 02/20] drm/shmem-helper: Use flag for tracking page count bumped by get_pages_sgt()

2023-09-11 Thread Dmitry Osipenko
On 9/5/23 10:40, Boris Brezillon wrote: > On Sun, 3 Sep 2023 20:07:18 +0300 > Dmitry Osipenko wrote: > >> Use separate flag for tracking page count bumped by shmem->sgt to avoid >> imbalanced page counter during of drm_gem_shmem_free() time. It's fragile >> to assu

Re: [PATCH v16 06/20] drm/virtio: Replace drm_gem_shmem_free() with drm_gem_object_put()

2023-09-11 Thread Dmitry Osipenko
On 9/5/23 10:20, Boris Brezillon wrote: > On Sun, 3 Sep 2023 20:07:22 +0300 > Dmitry Osipenko wrote: > >> Prepare virtio_gpu_object_create() to addition of memory shrinker support >> by replacing open-coded drm_gem_shmem_free() with drm_gem_object_put() that >> d

[PATCH v16 16/20] drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked()

2023-09-03 Thread Dmitry Osipenko
Export drm_gem_shmem_get_pages_sgt_locked() that will be used by virtio-gpu shrinker during GEM swap-in operation done under the held reservation lock. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 3 ++- include/drm/drm_gem_shmem_helper.h | 1 + 2 files

[PATCH v16 17/20] drm/virtio: Pin display framebuffer BO

2023-09-03 Thread Dmitry Osipenko
-by: Gerd Hoffmann Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ drivers/gpu/drm/virtio/virtgpu_gem.c | 19 +++ drivers/gpu/drm/virtio/virtgpu_plane.c | 17 +++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers

[PATCH v16 13/20] drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin

2023-09-03 Thread Dmitry Osipenko
ned), while the new pages_pin_count will do the hard-pinning. Switch the vmap/vunmap() to use pin/unpin() functions in a preparation of addition of the memory shrinker support to drm-shmem. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 19 --- include/

[PATCH v16 19/20] drm/virtio: Support memory shrinking

2023-09-03 Thread Dmitry Osipenko
y if guest supports SWAP file or partition. Acked-by: Gerd Hoffmann Signed-off-by: Daniel Almeida Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_drv.h| 13 +- drivers/gpu/drm/virtio/virtgpu_gem.c| 35 ++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 25 +

[PATCH v16 15/20] drm/shmem-helper: Add memory shrinker

2023-09-03 Thread Dmitry Osipenko
. Initialize drm-shmem internals using drmm_gem_shmem_init(drm_device), which will register drm-shmem shrinker 3. Implement madvise IOCTL that will use drm_gem_shmem_madvise() Signed-off-by: Daniel Almeida Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c| 442

[PATCH v16 20/20] drm/panfrost: Switch to generic memory shrinker

2023-09-03 Thread Dmitry Osipenko
Replace Panfrost's custom memory shrinker with a common drm-shmem memory shrinker. Tested-by: Steven Price # Firefly-RK3288 Reviewed-by: Steven Price Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/panfrost/Makefile | 1 - drivers/gpu/drm/panfrost/panfrost_device.h| 4

[PATCH v16 12/20] drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages()

2023-09-03 Thread Dmitry Osipenko
Add lockless drm_gem_shmem_get_pages() helper that skips taking reservation lock if pages_use_count is non-zero, leveraging from atomicity of the refcount_t. Make drm_gem_shmem_mmap() to utilize the new helper. Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm

[PATCH v16 18/20] drm/virtio: Attach shmem BOs dynamically

2023-09-03 Thread Dmitry Osipenko
attachment explicitly dynamic will allow to simplify and reuse more code when shrinker will be added. The virtio_gpu_object_shmem_init() now works under held reservation lock, which will be important to have for shrinker. Acked-by: Gerd Hoffmann Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio

[PATCH v16 09/20] drm/shmem-helper: Remove obsoleted is_iomem test

2023-09-03 Thread Dmitry Osipenko
y: Thomas Zimmermann Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 2b50d1a7f718..25e99468ced2 100644 --- a/driver

[PATCH v16 14/20] drm/shmem-helper: Use refcount_t for vmap_use_count

2023-09-03 Thread Dmitry Osipenko
low checks. Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 28 +++--- include/drm/drm_gem_shmem_helper.h | 2 +- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c

[PATCH v16 00/20] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers

2023-09-03 Thread Dmitry Osipenko
- Added new patch to remove the "map->is_iomem" from drm-shmem, as was suggested by Thomas Zimmermann. - Added acks and r-b's that were given to v10. v10:- Was partially applied to misc-fixes/next. https://lore.kernel.org/dri-devel/6c16f303-81df-7ebe-85e9-51bb

[PATCH v16 08/20] drm/shmem-helper: Refactor locked/unlocked functions

2023-09-03 Thread Dmitry Osipenko
Add locked and remove unlocked postfixes from drm-shmem function names, making names consistent with the drm/gem core code. Reviewed-by: Boris Brezillon Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c| 64

[PATCH v16 05/20] drm/v3d: Replace open-coded drm_gem_shmem_free() with drm_gem_object_put()

2023-09-03 Thread Dmitry Osipenko
code paths. Replace open-coded drm_gem_shmem_free() with drm_gem_object_put() that drops kref to zero before freeing GEM. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/v3d/v3d_bo.c | 22 -- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm

[PATCH v16 10/20] drm/shmem-helper: Add and use pages_pin_count

2023-09-03 Thread Dmitry Osipenko
be swapped out). The pages_pin_count > 1 will hard-pin pages in memory. Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 24 include/drm/drm_gem_shmem_helper.h | 10 ++ 2 files changed, 26 insertions(+)

[PATCH v16 11/20] drm/shmem-helper: Use refcount_t for pages_use_count

2023-09-03 Thread Dmitry Osipenko
Use atomic refcount_t helper for pages_use_count to optimize pin/unpin functions by skipping reservation locking while GEM's pin refcount > 1. Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 35 +++-- drivers/

[PATCH v16 07/20] drm/shmem-helper: Make all exported symbols GPL

2023-09-03 Thread Dmitry Osipenko
Make all drm-shmem exported symbols GPL to make them consistent with the rest of drm-shmem symbols. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm

[PATCH v16 06/20] drm/virtio: Replace drm_gem_shmem_free() with drm_gem_object_put()

2023-09-03 Thread Dmitry Osipenko
in order to prevent spurious lockdep warning about resv lock ordering vs fs_reclaim code paths. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm

[PATCH v16 04/20] drm/gem: Add _locked postfix to functions that have unlocked counterpart

2023-09-03 Thread Dmitry Osipenko
Add _locked postfix to drm_gem functions that have unlocked counterpart functions to make GEM functions naming more consistent and intuitive in regards to the locking requirements. Reviewed-by: Boris Brezillon Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm

[PATCH v16 02/20] drm/shmem-helper: Use flag for tracking page count bumped by get_pages_sgt()

2023-09-03 Thread Dmitry Osipenko
emoves the ambiguity. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 11 ++- drivers/gpu/drm/lima/lima_gem.c| 1 + include/drm/drm_gem_shmem_helper.h | 7 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/g

[PATCH v16 01/20] drm/shmem-helper: Fix UAF in error path when freeing SGT of imported GEM

2023-09-03 Thread Dmitry Osipenko
t;) Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 13 - include/drm/drm_gem_shmem_helper.h | 7 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_help

[PATCH v16 03/20] drm/gem: Change locked/unlocked postfix of drm_gem_v/unmap() function names

2023-09-03 Thread Dmitry Osipenko
Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_client.c | 6 +++--- drivers/gpu/drm/drm_gem.c| 20 ++-- drivers/gpu/drm/drm_gem_framebuffer_helper.c | 6 +++--- drivers/gpu/drm/drm_internal.h

Re: [PATCH v15 16/23] drm/shmem-helper: Use kref for vmap_use_count

2023-09-02 Thread Dmitry Osipenko
On 8/28/23 13:00, Boris Brezillon wrote: > On Sun, 27 Aug 2023 20:54:42 +0300 > Dmitry Osipenko wrote: > >> Use kref helper for vmap_use_count to make refcounting consistent with >> pages_use_count and pages_pin_count that use kref. This will allow to >> optimize unl

Re: [PATCH v15 17/23] drm/shmem-helper: Add and use drm_gem_shmem_resv_assert_held() helper

2023-09-02 Thread Dmitry Osipenko
On 8/29/23 10:29, Boris Brezillon wrote: > On Tue, 29 Aug 2023 05:34:23 +0300 > Dmitry Osipenko wrote: > >> On 8/28/23 13:12, Boris Brezillon wrote: >>> On Sun, 27 Aug 2023 20:54:43 +0300 >>> Dmitry Osipenko wrote: >>> >>>> In a pre

Re: [PATCH v15 02/23] drm/shmem-helper: Use flag for tracking page count bumped by get_pages_sgt()

2023-09-02 Thread Dmitry Osipenko
On 8/28/23 13:55, Boris Brezillon wrote: > On Sun, 27 Aug 2023 20:54:28 +0300 > Dmitry Osipenko wrote: > >> Use separate flag for tracking page count bumped by shmem->sgt to avoid >> imbalanced page counter during of drm_gem_shmem_free() time. It's fragile >>

Re: [PATCH v15 01/23] drm/shmem-helper: Fix UAF in error path when freeing SGT of imported GEM

2023-09-02 Thread Dmitry Osipenko
On 8/28/23 14:16, Boris Brezillon wrote: > On Sun, 27 Aug 2023 20:54:27 +0300 > Dmitry Osipenko wrote: > >> Freeing drm-shmem GEM right after creating it using >> drm_gem_shmem_prime_import_sg_table() frees SGT of the imported dma-buf >> and then dma-buf

Re: [PATCH -next] drm/virtio: Remove unused function declarations

2023-09-02 Thread Dmitry Osipenko
On 8/11/23 13:18, Yue Haibing wrote: > Commit dc5698e80cf7 ("Add virtio gpu driver.") declared but never > implemented virtio_gpu_attach_status_page()/virtio_gpu_detach_status_page() > Also commit 62fb7a5e1096 ("virtio-gpu: add 3d/virgl support") > declared but never implemented

Re: [PATCH v2] MAINTAINERS: Add Boris Brezillon as Panfrost driver maintainer

2023-09-02 Thread Dmitry Osipenko
On 8/22/23 08:25, Dmitry Osipenko wrote: > Add Boris Brezillon as Panfrost driver maintainer. Boris is a new lead > developer of the Panfrost Mesa driver and main developer behind the > upcoming Panthor kernel driver that will serve next-gen Mali GPUs. > > Remove Tomeu and A

Re: [RFC PATCH 3/3] drm/virtio: drm_gem_plane_helper_prepare_fb for obj synchronization

2023-08-31 Thread Dmitry Osipenko
On 8/24/23 20:58, Kim, Dongwon wrote: ... >> You can do fence-wait in the guest userspace/Mesa after blitting/drawing >> to the udmabuf. > > There is already synchronization between QEMU and virtio-gpu driver on > the guest. Upon resource flush, virtio-gpu waits for the response for > the message

Re: [PATCH v15 00/23] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers

2023-08-28 Thread Dmitry Osipenko
On 8/28/23 18:24, Helen Mae Koike Fornazier wrote: > On Monday, August 28, 2023 11:37 -03, "Helen Mae Koike Fornazier" > wrote: > >> On Sunday, August 27, 2023 14:54 -03, Dmitry Osipenko >> wrote: >> >>> This series: >>> >>> 1.

Re: [PATCH v15 17/23] drm/shmem-helper: Add and use drm_gem_shmem_resv_assert_held() helper

2023-08-28 Thread Dmitry Osipenko
On 8/28/23 13:12, Boris Brezillon wrote: > On Sun, 27 Aug 2023 20:54:43 +0300 > Dmitry Osipenko wrote: > >> In a preparation of adding drm-shmem memory shrinker, move all reservation >> locking lockdep checks to use new drm_gem_shmem_resv_assert_held() that >> wi

Re: [PATCH v15 12/23] drm/shmem-helper: Add and use pages_pin_count

2023-08-28 Thread Dmitry Osipenko
On 8/28/23 14:46, Boris Brezillon wrote: > On Sun, 27 Aug 2023 20:54:38 +0300 > Dmitry Osipenko wrote: > >> Add separate pages_pin_count for tracking of whether drm-shmem pages are >> moveable or not. With the addition of memory shrinker support to drm-shmem, &

Re: [PATCH v15 10/23] locking/refcount, kref: Add kref_put_ww_mutex()

2023-08-28 Thread Dmitry Osipenko
On 8/28/23 12:26, Boris Brezillon wrote: > On Sun, 27 Aug 2023 20:54:36 +0300 > Dmitry Osipenko wrote: > >> Introduce kref_put_ww_mutex() helper that will handle the wait-wound >> mutex auto-locking on kref_put(). This helper is wanted by DRM drivers >> that exte

[PATCH v15 22/23] drm/virtio: Support memory shrinking

2023-08-27 Thread Dmitry Osipenko
y if guest supports SWAP file or partition. Acked-by: Gerd Hoffmann Signed-off-by: Daniel Almeida Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_drv.h| 13 +- drivers/gpu/drm/virtio/virtgpu_gem.c| 35 ++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 25 +

[PATCH v15 16/23] drm/shmem-helper: Use kref for vmap_use_count

2023-08-27 Thread Dmitry Osipenko
Use kref helper for vmap_use_count to make refcounting consistent with pages_use_count and pages_pin_count that use kref. This will allow to optimize unlocked vmappings by skipping reservation locking if refcnt > 1. Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/

[PATCH v15 23/23] drm/panfrost: Switch to generic memory shrinker

2023-08-27 Thread Dmitry Osipenko
Replace Panfrost's custom memory shrinker with a common drm-shmem memory shrinker. Tested-by: Steven Price # Firefly-RK3288 Reviewed-by: Steven Price Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/panfrost/Makefile | 1 - drivers/gpu/drm/panfrost/panfrost_device.h| 4

[PATCH v15 19/23] drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked()

2023-08-27 Thread Dmitry Osipenko
Export drm_gem_shmem_get_pages_sgt_locked() that will be used by virtio-gpu shrinker during GEM swap-in operation done under the held reservation lock. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 3 ++- include/drm/drm_gem_shmem_helper.h | 1 + 2 files

[PATCH v15 20/23] drm/virtio: Pin display framebuffer BO

2023-08-27 Thread Dmitry Osipenko
-by: Gerd Hoffmann Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ drivers/gpu/drm/virtio/virtgpu_gem.c | 19 +++ drivers/gpu/drm/virtio/virtgpu_plane.c | 17 +++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers

[PATCH v15 21/23] drm/virtio: Attach shmem BOs dynamically

2023-08-27 Thread Dmitry Osipenko
attachment explicitly dynamic will allow to simplify and reuse more code when shrinker will be added. The virtio_gpu_object_shmem_init() now works under held reservation lock, which will be important to have for shrinker. Acked-by: Gerd Hoffmann Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio

[PATCH v15 12/23] drm/shmem-helper: Add and use pages_pin_count

2023-08-27 Thread Dmitry Osipenko
be swapped out). The pages_pin_count > 1 will hard-pin pages in memory. Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 22 +- include/drm/drm_gem_shmem_helper.h | 10 ++ 2 files changed, 27 insertions(+)

[PATCH v15 07/23] drm/shmem-helper: Make all exported symbols GPL

2023-08-27 Thread Dmitry Osipenko
Make all drm-shmem exported symbols GPL to make them consistent with the rest of drm-shmem symbols. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm

[PATCH v15 15/23] drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin

2023-08-27 Thread Dmitry Osipenko
ned), while the new pages_pin_count will do the hard-pinning. Switch the vmap/vunmap() to use pin/unpin() functions in a preparation of addition of the memory shrinker support to drm-shmem. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 13 ++--- include/

[PATCH v15 13/23] drm/shmem-helper: Use kref for pages_use_count

2023-08-27 Thread Dmitry Osipenko
Use atomic kref helper for pages_use_count to optimize pin/unpin functions by skipping reservation locking while GEM's pin refcount > 1. Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 48 ++--- drivers/gpu/drm/l

[PATCH v15 18/23] drm/shmem-helper: Add memory shrinker

2023-08-27 Thread Dmitry Osipenko
. Initialize drm-shmem internals using drmm_gem_shmem_init(drm_device), which will register drm-shmem shrinker 3. Implement madvise IOCTL that will use drm_gem_shmem_madvise() Signed-off-by: Daniel Almeida Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c| 415

[PATCH v15 10/23] locking/refcount, kref: Add kref_put_ww_mutex()

2023-08-27 Thread Dmitry Osipenko
Introduce kref_put_ww_mutex() helper that will handle the wait-wound mutex auto-locking on kref_put(). This helper is wanted by DRM drivers that extensively use dma-reservation locking which in turns uses ww-mutex. Signed-off-by: Dmitry Osipenko --- include/linux/kref.h | 12

[PATCH v15 11/23] dma-resv: Add kref_put_dma_resv()

2023-08-27 Thread Dmitry Osipenko
Add simple kref_put_dma_resv() helper that wraps around kref_put_ww_mutex() for drivers that needs to lock dma-resv on kref_put(). It's not possible to easily add this helper to kref.h because of the headers inclusion dependency, hence add it to dma-resv.h. Signed-off-by: Dmitry Osipenko

[PATCH v15 09/23] drm/shmem-helper: Remove obsoleted is_iomem test

2023-08-27 Thread Dmitry Osipenko
y: Thomas Zimmermann Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index f053dc511508..d545d3d227d7 100644 --- a/driver

[PATCH v15 08/23] drm/shmem-helper: Refactor locked/unlocked functions

2023-08-27 Thread Dmitry Osipenko
Add locked and remove unlocked postfixes from drm-shmem function names, making names consistent with the drm/gem core code. Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c| 64 +-- drivers/gpu/drm/lima/lima_gem.c

<    1   2   3   4   5   6   7   8   9   10   >