Re: [PATCH] drm/panfrost: Fix dma_resv deadlock at drm object pin time

2024-04-22 Thread Dmitry Osipenko
drm_gem_pin+0x2c/0x80 [drm] > > Fix it by assuming the object's reservation had already been locked by the > time we reach panfrost_gem_pin. > > Cc: Thomas Zimmermann > Cc: Dmitry Osipenko > Cc: Boris Brezillon > Cc: Steven Price > Fixes: a78027847226 ("drm/

Re: [PATCH] drm/virtio: add driver_priv validation in virtio_gpu_create_context

2024-04-11 Thread Dmitry Osipenko
On 3/28/24 16:43, Maxim Korotkov wrote: > The pointer file->driver_priv was dereferenced without checking > against NULL, but in the "virtio_gpu_transfer_to_host_ioctl" function > it was checked against NULL after calling virtio_gpu_create_context > function. > > Found by Security Code and Linux

Re: [PATCH v19 17/30] drm/panfrost: Fix the error path in panfrost_mmu_map_fault_addr()

2024-04-04 Thread Dmitry Osipenko
On 1/5/24 21:46, Dmitry Osipenko wrote: > From: Boris Brezillon > > If some the pages or sgt allocation failed, we shouldn't release the > pages ref we got earlier, otherwise we will end up with unbalanced > get/put_pages() calls. We should instead leave everything in place &

Re: [PATCH 19/43] drm/virtio: Use fbdev-shmem

2024-03-28 Thread Dmitry Osipenko
rtio_gpu_probe(struct virtio_device *vdev) > if (ret) > goto err_deinit; > > - drm_fbdev_generic_setup(vdev->priv, 32); > + drm_fbdev_shmem_setup(vdev->priv, 32); > return 0; > > err_deinit: Tested-by: Dmitry Osipenko -- Best regards, Dmitry

Re: [PATCH 00/13] drm: Fix reservation locking for pin/unpin and console

2024-03-05 Thread Dmitry Osipenko
m_gem_{pin/unpin}() > drm/fbdev-generic: Fix locking with drm_client_buffer_vmap_local() > drm/client: Pin vmap'ed GEM buffers > drm/gem-vram: Do not pin buffer objects for vmap > drm/qxl: Do not pin buffer objects for vmap The patches look good. I gave them fbtest on virtio-gpu, no problems spotted. Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko # virtio-gpu -- Best regards, Dmitry

Re: [PATCH 00/13] drm: Fix reservation locking for pin/unpin and console

2024-03-01 Thread Dmitry Osipenko
On 2/28/24 11:19, Thomas Zimmermann wrote: > Hi > > Am 27.02.24 um 19:14 schrieb Dmitry Osipenko: >> Hello, >> >> Thank you for the patches! >> >> On 2/27/24 13:14, Thomas Zimmermann wrote: >>> Dma-buf locking semantics require the caller of pin and

Re: [PATCH 00/13] drm: Fix reservation locking for pin/unpin and console

2024-02-27 Thread Dmitry Osipenko
Hello, Thank you for the patches! On 2/27/24 13:14, Thomas Zimmermann wrote: > Dma-buf locking semantics require the caller of pin and unpin to hold > the buffer's reservation lock. Fix DRM to adhere to the specs. This > enables to fix the locking in DRM's console emulation. Similar changes >

Re: [PATCH v19 09/30] drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages()

2024-02-01 Thread Dmitry Osipenko
On 1/30/24 13:10, Boris Brezillon wrote: > On Tue, 30 Jan 2024 09:34:29 +0100 > Daniel Vetter wrote: > >> On Fri, Jan 26, 2024 at 07:43:29PM +0300, Dmitry Osipenko wrote: >>> On 1/26/24 13:18, Boris Brezillon wrote: >>>> On Thu, 25 Jan 2024 18:2

Re: [PATCH v2] drm/msm/gem: Fix double resv lock aquire

2024-01-31 Thread Dmitry Osipenko
On 1/31/24 04:15, Rob Clark wrote: > From: Rob Clark > > Since commit 56e5abba8c3e ("dma-buf: Add unlocked variant of vmapping > functions"), the resv lock is already held in the prime vmap path, so > don't try to grab it again. > > v2: This applies to vunmap path as well > > Fixes:

Re: [PATCH v19 09/30] drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages()

2024-01-30 Thread Dmitry Osipenko
On 1/30/24 11:34, Daniel Vetter wrote: > On Fri, Jan 26, 2024 at 07:43:29PM +0300, Dmitry Osipenko wrote: >> On 1/26/24 13:18, Boris Brezillon wrote: >>> On Thu, 25 Jan 2024 18:24:04 +0100 >>> Daniel Vetter wrote: >>> >>>> On Fri, Jan 05, 2024 at 09

Re: [PATCH v19 22/30] drm/shmem-helper: Add common memory shrinker

2024-01-30 Thread Dmitry Osipenko
On 1/30/24 11:39, Daniel Vetter wrote: > On Thu, Jan 25, 2024 at 10:07:03AM +0100, Boris Brezillon wrote: >> On Fri, 5 Jan 2024 21:46:16 +0300 >> Dmitry Osipenko wrote: >> >>> * >>> * This function Increases the use count and allocates the backing pa

Re: [PATCH v19 22/30] drm/shmem-helper: Add common memory shrinker

2024-01-29 Thread Dmitry Osipenko
On 1/29/24 12:01, Boris Brezillon wrote: > On Fri, 5 Jan 2024 21:46:16 +0300 > Dmitry Osipenko wrote: > >> +/** >> + * drm_gem_shmem_swapin_locked() - Moves shmem GEM back to memory and >> enables >> + * hardware access to the

Re: [PATCH RESEND] drm/virtio: set segment size for virtio_gpu device

2024-01-29 Thread Dmitry Osipenko
On 1/23/24 21:14, Sebastian Ott wrote: > drm/virtio: set segment size for virtio_gpu device > > Set the segment size of the virtio_gpu device to the value > used by the drm helpers when allocating sg lists to fix the > following complaint from DMA_API debug code: > DMA-API: virtio-pci

Re: [PATCH v19 22/30] drm/shmem-helper: Add common memory shrinker

2024-01-28 Thread Dmitry Osipenko
On 1/26/24 21:12, Boris Brezillon wrote: > On Fri, 26 Jan 2024 19:27:49 +0300 > Dmitry Osipenko wrote: > >> On 1/26/24 12:55, Boris Brezillon wrote: >>> On Fri, 26 Jan 2024 00:56:47 +0300 >>> Dmitry Osipenko wrote: >>> >>>> On 1/25/24 13:

Re: [PATCH v19 09/30] drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages()

2024-01-26 Thread Dmitry Osipenko
On 1/26/24 13:18, Boris Brezillon wrote: > On Thu, 25 Jan 2024 18:24:04 +0100 > Daniel Vetter wrote: > >> On Fri, Jan 05, 2024 at 09:46:03PM +0300, Dmitry Osipenko wrote: >>> Add lockless drm_gem_shmem_get_pages() helper that skips taking reservation >>> lo

Re: [PATCH v19 22/30] drm/shmem-helper: Add common memory shrinker

2024-01-26 Thread Dmitry Osipenko
On 1/26/24 12:55, Boris Brezillon wrote: > On Fri, 26 Jan 2024 00:56:47 +0300 > Dmitry Osipenko wrote: > >> On 1/25/24 13:19, Boris Brezillon wrote: >>> On Fri, 5 Jan 2024 21:46:16 +0300 >>> Dmitry Osipenko wrote: >>> >>>> +static bool

Re: [PATCH v19 22/30] drm/shmem-helper: Add common memory shrinker

2024-01-25 Thread Dmitry Osipenko
On 1/25/24 13:19, Boris Brezillon wrote: > On Fri, 5 Jan 2024 21:46:16 +0300 > Dmitry Osipenko wrote: > >> +static bool drm_gem_shmem_is_evictable(struct drm_gem_shmem_object *shmem) >> +{ >> +return (shmem->madv >= 0) && shmem->base.f

Re: [PATCH v19 09/30] drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages()

2024-01-25 Thread Dmitry Osipenko
On 1/25/24 20:24, Daniel Vetter wrote: > On Fri, Jan 05, 2024 at 09:46:03PM +0300, Dmitry Osipenko wrote: >> 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. Ma

Re: [PATCH v19 17/30] drm/panfrost: Fix the error path in panfrost_mmu_map_fault_addr()

2024-01-25 Thread Dmitry Osipenko
On 1/26/24 00:41, Dmitry Osipenko wrote: > On 1/5/24 21:46, Dmitry Osipenko wrote: >> for (i = page_offset; i < page_offset + NUM_FAULT_PAGES; i++) { >> +/* Can happen if the last fault only partially filled this >> + * section of the pa

Re: [PATCH v19 17/30] drm/panfrost: Fix the error path in panfrost_mmu_map_fault_addr()

2024-01-25 Thread Dmitry Osipenko
On 1/5/24 21:46, Dmitry Osipenko wrote: > for (i = page_offset; i < page_offset + NUM_FAULT_PAGES; i++) { > + /* Can happen if the last fault only partially filled this > + * section of the pages array before failing. In that case > + *

Re: [PATCH v19 30/30] drm/panfrost: Switch to generic memory shrinker

2024-01-25 Thread Dmitry Osipenko
On 1/25/24 12:49, Boris Brezillon wrote: > On Fri, 5 Jan 2024 21:46:24 +0300 > Dmitry Osipenko wrote: > >> --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c >> +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c >> @@ -328,6 +328,7 @@ int panfrost_mmu_map(struct panfro

[PATCH v19 30/30] drm/panfrost: Switch to generic memory shrinker

2024-01-05 Thread Dmitry Osipenko
Replace Panfrost's custom memory shrinker with a common drm-shmem memory shrinker. Co-developed-by: Boris Brezillon Signed-off-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c| 4 +- drivers/gpu/drm/panfrost/Makefile | 1

[PATCH v19 29/30] drm/virtio: Support shmem shrinking

2024-01-05 Thread Dmitry Osipenko
y if guest supports SWAP file or partition. Link: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15278 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

[PATCH v19 26/30] drm/shmem-helper: Turn warnings about imported GEM into errors

2024-01-05 Thread Dmitry Osipenko
Turn sanity warnings about DRM-SHMEM API misuse into a error conditions for cases where imported GEM is used when it shouldn't be used. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers

[PATCH v19 27/30] drm/virtio: Pin display framebuffer BO

2024-01-05 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 v19 28/30] drm/virtio: Attach shmem BOs dynamically

2024-01-05 Thread Dmitry Osipenko
-by: Gerd Hoffmann Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_drv.h| 7 +++ drivers/gpu/drm/virtio/virtgpu_gem.c| 26 + drivers/gpu/drm/virtio/virtgpu_ioctl.c | 32 +++ drivers/gpu/drm/virtio/virtgpu_object.c | 73 - drivers/gpu

[PATCH v19 25/30] drm/shmem-helper: Don't free refcounted GEM

2024-01-05 Thread Dmitry Osipenko
Don't free shmem object if it has pages that are in use at the time of the GEM's freeing if DRM driver doesn't manage GEM/pages lifetime properly. This prevents memory corruption due to the use-after-free bug in exchange to leaking GEM. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm

[PATCH v19 24/30] drm/shmem-helper: Optimize unlocked get_pages_sgt()

2024-01-05 Thread Dmitry Osipenko
SGT isn't refcounted. Once SGT pointer has been obtained, it remains the same for both locked and unlocked get_pages_sgt(). Return cached SGT directly without taking a potentially expensive lock. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 12 1 file

[PATCH v19 23/30] drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked()

2024-01-05 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. Reviewed-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 22 +- include

[PATCH v19 21/30] drm/shmem-helper: Change sgt allocation policy

2024-01-05 Thread Dmitry Osipenko
-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 55 ++ 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index c7357110ca76..ff5437ab2c95 100644

[PATCH v19 22/30] drm/shmem-helper: Add common memory shrinker

2024-01-05 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| 365

[PATCH v19 19/30] drm/virtio: Explicitly get and put drm-shmem pages

2024-01-05 Thread Dmitry Osipenko
ris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_object.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index c7e74cf13022..e58528c562ef 100644 --- a/drivers/gpu/

[PATCH v19 20/30] drm/v3d: Explicitly get and put drm-shmem pages

2024-01-05 Thread Dmitry Osipenko
; 0. Reviewed-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/v3d/v3d_bo.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/v3d/v3d_bo.c b/drivers/gpu/drm/v3d/v3d_bo.c index 1bdfac8beafd..ccf04ce93e8c 100644 --- a/drivers/gpu/

[PATCH v19 13/30] drm/shmem-helper: Make drm_gem_shmem_get_pages() public

2024-01-05 Thread Dmitry Osipenko
We're going to move away from having implicit get_pages() done by get_pages_sgt() to simplify refcnt handling. Drivers will manage get/put_pages() by themselves. Expose the drm_gem_shmem_get_pages() in a public drm-shmem API. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm

[PATCH v19 18/30] drm/panfrost: Explicitly get and put drm-shmem pages

2024-01-05 Thread Dmitry Osipenko
BO lifetime, and MADVISE(DONT_NEED) flagging remains after the GEM handle has been destroyed, we need to add an extra 'is_purgeable' check in panfrost_gem_purge(), to make sure we're not trying to purge a BO that already had its pages released. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/panfr

[PATCH v19 17/30] drm/panfrost: Fix the error path in panfrost_mmu_map_fault_addr()

2024-01-05 Thread Dmitry Osipenko
is destroyed, or let the fault handler try again next time it's called. Fixes: 187d2929206e ("drm/panfrost: Add support for GPU heap allocations") Cc: Signed-off-by: Boris Brezillon Co-developed-by: Dmitry Osipenko Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/panfrost/panf

[PATCH v19 15/30] drm/shmem-helper: Avoid lockdep warning when pages are released

2024-01-05 Thread Dmitry Osipenko
know that fs_reclaim isn't functioning for a freed object, and thus, can't deadlock. Release pages directly without taking reservation lock if GEM is freed and its refcount is zero. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 16 1 file changed

[PATCH v19 14/30] drm/shmem-helper: Add drm_gem_shmem_put_pages()

2024-01-05 Thread Dmitry Osipenko
We're going to move away from having implicit get_pages() done by get_pages_sgt() to ease simplify refcnt handling. Drivers will manage get/put_pages() by themselves. Add drm_gem_shmem_put_pages(). Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 20

[PATCH v19 16/30] drm/lima: Explicitly get and put drm-shmem pages

2024-01-05 Thread Dmitry Osipenko
; 0. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/lima/lima_gem.c | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c index 2a97aa85416b..9c3e34a7fbed 100644 --- a/drivers/gpu/drm/lima/lima_ge

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

2024-01-05 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 | 40 ++ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b

[PATCH v19 11/30] drm/shmem-helper: Use refcount_t for vmap_use_count

2024-01-05 Thread Dmitry Osipenko
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 b/drivers/gpu/drm/drm_gem_shmem_helper.c

[PATCH v19 09/30] drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages()

2024-01-05 Thread Dmitry Osipenko
Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index cacf0f8c42e2..1c032513abf1 100644 --- a/drivers

[PATCH v19 10/30] drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin

2024-01-05 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. Acked-by: Maxime Ripard Reviewed-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/

[PATCH v19 07/30] drm/shmem-helper: Add and use pages_pin_count

2024-01-05 Thread Dmitry Osipenko
be swapped out). The pages_pin_count > 1 will hard-pin pages in memory. Acked-by: Maxime Ripard Reviewed-by: Boris Brezillon Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 25 + include/drm/drm_gem_shmem_helpe

[PATCH v19 08/30] drm/shmem-helper: Use refcount_t for pages_use_count

2024-01-05 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. Acked-by: Maxime Ripard Reviewed-by: Boris Brezillon Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/

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

2024-01-05 Thread Dmitry Osipenko
Reviewed-by: Boris Brezillon 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

[PATCH v19 05/30] drm/shmem-helper: Refactor locked/unlocked functions

2024-01-05 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| 60

[PATCH v19 06/30] drm/shmem-helper: Remove obsoleted is_iomem test

2024-01-05 Thread Dmitry Osipenko
me Ripard Suggested-by: Thomas Zimmermann Reviewed-by: Boris Brezillon 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 043

[PATCH v19 04/30] drm/shmem-helper: Make all exported symbols GPL

2024-01-05 Thread Dmitry Osipenko
Make all drm-shmem exported symbols GPL to make them consistent with the rest of drm-shmem symbols. Acked-by: Maxime Ripard Reviewed-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 16 1 file changed, 8 insertions(+), 8

[PATCH v19 03/30] drm/gem: Document locking rule of vmap and evict callbacks

2024-01-05 Thread Dmitry Osipenko
The vmap/vunmap/evict GEM callbacks are always invoked with a held GEM's reservation lock. Document this locking rule for clarity. Signed-off-by: Dmitry Osipenko --- include/drm/drm_gem.h | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/drm/drm_gem.h b

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

2024-01-05 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. Acked-by: Maxime Ripard Reviewed-by: Boris Brezillon Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko

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

2024-01-05 Thread Dmitry Osipenko
d 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/ Boris Brezillon (1): drm/panfrost: Fix the error path in panfrost_mmu_map_fault_addr() Dmitry Osipenko (29): drm/gem: Change

Re: [PATCH 1/1] drm/virtio: Implement RESOURCE_GET_LAYOUT ioctl

2024-01-03 Thread Dmitry Osipenko
On 12/21/23 13:00, Julia Zhang wrote: > From: Daniel Stone > > Add a new ioctl to allow the guest VM to discover how the guest > actually allocated the underlying buffer, which allows buffers to > be used for GL<->Vulkan interop and through standard window systems. > It's also a step towards

Re: [PATCH v1 1/1] drm/virtio: Spelling fixes

2024-01-03 Thread Dmitry Osipenko
On 12/19/23 18:19, Andy Shevchenko wrote: > While making a spelling mistake myself for `git grep kvalloc` > I found that the only file has such a typo. Fix it and update > to the standard de facto of how we refer to the functions. > Also spell usr-out as user-out, it seems this driver uses its >

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

2023-12-15 Thread Dmitry Osipenko
On 11/19/23 06:46, Dmitry Osipenko wrote: > On 9/21/23 00:16, Dmitry Osipenko wrote: >> 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

Re: [PATCH v18 04/26] drm/shmem-helper: Refactor locked/unlocked functions

2023-12-14 Thread Dmitry Osipenko
On 12/14/23 21:16, Maxime Ripard wrote: > On Tue, Dec 05, 2023 at 02:43:16PM +0300, Dmitry Osipenko wrote: >> On 12/4/23 15:55, Maxime Ripard wrote: >>>> Okay, that means s/_locked/_nolock/ in drm_gem_shmem_helpers.{c,h}, I >>>> guess. >> >> DRM subs

Re: [PATCH v18 04/26] drm/shmem-helper: Refactor locked/unlocked functions

2023-12-05 Thread Dmitry Osipenko
On 12/4/23 15:55, Maxime Ripard wrote: >> Okay, that means s/_locked/_nolock/ in drm_gem_shmem_helpers.{c,h}, I >> guess. DRM subsys and majority of kernel uses common _locked postfix. We should retain the old naming scheme by using _locked() in DRM. It's not worthwhile changing the name to a

Re: [PATCH v18 04/26] drm/shmem-helper: Refactor locked/unlocked functions

2023-11-29 Thread Dmitry Osipenko
On 11/29/23 10:53, Boris Brezillon wrote: > On Wed, 29 Nov 2023 01:05:14 +0300 > Dmitry Osipenko wrote: > >> On 11/28/23 15:37, Boris Brezillon wrote: >>> On Tue, 28 Nov 2023 12:14:42 +0100 >>> Maxime Ripard wrote: >>> >>>> Hi, >

Re: [PATCH v18 04/26] drm/shmem-helper: Refactor locked/unlocked functions

2023-11-28 Thread Dmitry Osipenko
gt;>> >>>> On Mon, Oct 30, 2023 at 02:01:43AM +0300, Dmitry Osipenko wrote: >>>>> Add locked and remove unlocked postfixes from drm-shmem function names, >>>>> making names consistent with the drm/gem core code. >>>>>

Re: [PATCH v18 22/26] drm/shmem-helper: Don't free refcounted GEM

2023-11-23 Thread Dmitry Osipenko
On 11/23/23 12:08, Boris Brezillon wrote: > On Thu, 23 Nov 2023 01:30:24 +0300 > Dmitry Osipenko wrote: > >> On 11/13/23 12:54, Boris Brezillon wrote: >>> On Mon, 30 Oct 2023 02:02:01 +0300 >>> Dmitry Osipenko wrote: >>> >>>> Don't free

Re: [PATCH v18 15/26] drm/panfrost: Explicitly get and put drm-shmem pages

2023-11-23 Thread Dmitry Osipenko
On 11/23/23 12:05, Boris Brezillon wrote: > On Thu, 23 Nov 2023 01:04:56 +0300 > Dmitry Osipenko wrote: > >> On 11/10/23 13:53, Boris Brezillon wrote: >>> Hm, there was no drm_gem_shmem_get_pages_sgt() call here, why should we >>> add a drm_gem_shmem_get_pages()?

Re: [PATCH v18 24/26] drm/virtio: Attach shmem BOs dynamically

2023-11-22 Thread Dmitry Osipenko
On 11/23/23 01:37, Dmitry Osipenko wrote: > On 11/13/23 12:57, Boris Brezillon wrote: >> On Mon, 30 Oct 2023 02:02:03 +0300 >> Dmitry Osipenko wrote: >> >>> Prepare for addition of memory shrinker support by attaching shmem pages >>> to host dynamically on

Re: [PATCH v18 24/26] drm/virtio: Attach shmem BOs dynamically

2023-11-22 Thread Dmitry Osipenko
On 11/13/23 12:57, Boris Brezillon wrote: > On Mon, 30 Oct 2023 02:02:03 +0300 > Dmitry Osipenko wrote: > >> Prepare for addition of memory shrinker support by attaching shmem pages >> to host dynamically on first use. Previously the attachment vq command >> wasn't

Re: [PATCH v18 22/26] drm/shmem-helper: Don't free refcounted GEM

2023-11-22 Thread Dmitry Osipenko
On 11/13/23 12:54, Boris Brezillon wrote: > On Mon, 30 Oct 2023 02:02:01 +0300 > Dmitry Osipenko wrote: > >> Don't free refcounted shmem object to prevent use-after-free bug that >> is worse than a memory leak. >> >> Signed-off-by: Dmitry Osi

Re: [PATCH v18 15/26] drm/panfrost: Explicitly get and put drm-shmem pages

2023-11-22 Thread Dmitry Osipenko
On 11/10/23 13:53, Boris Brezillon wrote: > Hm, there was no drm_gem_shmem_get_pages_sgt() call here, why should we > add a drm_gem_shmem_get_pages()? What we should do instead is add a > drm_gem_shmem_get_pages() for each drm_gem_shmem_get_pages_sgt() we > have in the driver (in

Re: [PATCH v18 11/26] drm/shmem-helper: Prepare drm_gem_shmem_free() to shrinker addition

2023-11-20 Thread Dmitry Osipenko
On 11/20/23 14:19, Boris Brezillon wrote: ... - dma_resv_lock(shmem->base.resv, NULL); - drm_WARN_ON(obj->dev, refcount_read(>vmap_use_count)); if (shmem->sgt) { @@ -157,8 +171,6 @@ void drm_gem_shmem_free(struct drm_gem_shmem_object

Re: [PATCH v18 11/26] drm/shmem-helper: Prepare drm_gem_shmem_free() to shrinker addition

2023-11-20 Thread Dmitry Osipenko
On 11/10/23 13:16, Boris Brezillon wrote: > On Mon, 30 Oct 2023 02:01:50 +0300 > Dmitry Osipenko wrote: > >> Prepare drm_gem_shmem_free() to addition of memory shrinker support >> to drm-shmem by adding and using variant of put_pages() that doesn't >> touch re

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

2023-11-18 Thread Dmitry Osipenko
On 9/21/23 00:16, Dmitry Osipenko wrote: > 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-b

Re: [PATCH v1] drm/virtio: Fix return value for VIRTGPU_CONTEXT_PARAM_DEBUG_NAME

2023-11-14 Thread Dmitry Osipenko
On 11/12/23 01:42, Dmitry Osipenko wrote: > The strncpy_from_user() returns number of copied bytes and not zero on > success. The non-zero return value of ioctl is treated as error. Return > zero on success instead of the number of copied bytes. > > Fixes: 7add80126bce ("dr

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

2023-11-13 Thread Dmitry Osipenko
On 10/23/23 20:31, Kim, Dongwon wrote: ... >> Please write a guide how to test it. Are you using spice for the >> multi-display >> viewer? > > [DW] Yeah, let me come up with a simple test case. So we use virtio-gpu as > KMS device. It is used to share the guest frame with QEMU. > SPICE is one

Re: [PATCH 2/2] drm/virtio: Modify RESOURCE_GET_LAYOUT ioctl

2023-11-13 Thread Dmitry Osipenko
On 11/10/23 10:16, Julia Zhang wrote: > Modify RESOURCE_GET_LAYOUT ioctl to handle the use case that query > correct stride for guest linear resource before it is created. > > Signed-off-by: Julia Zhang > --- > drivers/gpu/drm/virtio/virtgpu_drv.h | 26 -- >

[PATCH v1] drm/virtio: Fix return value for VIRTGPU_CONTEXT_PARAM_DEBUG_NAME

2023-11-11 Thread Dmitry Osipenko
The strncpy_from_user() returns number of copied bytes and not zero on success. The non-zero return value of ioctl is treated as error. Return zero on success instead of the number of copied bytes. Fixes: 7add80126bce ("drm/uapi: add explicit virtgpu context debug name") Signed-off-

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

2023-11-11 Thread Dmitry Osipenko
On 10/18/23 21:17, Gurchetan Singh wrote: > + case VIRTGPU_CONTEXT_PARAM_DEBUG_NAME: > + if (vfpriv->explicit_debug_name) { > + ret = -EINVAL; > + goto out_unlock; > + } > + > +

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

2023-11-11 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 v18 25/26] drm/virtio: Support shmem shrinking

2023-11-05 Thread Dmitry Osipenko
On 11/4/23 01:55, Gurchetan Singh wrote: > On Sun, Oct 29, 2023 at 4:03 PM Dmitry Osipenko < > dmitry.osipe...@collabora.com> wrote: > >> Support generic drm-shmem memory shrinker and add new madvise IOCTL to >> the VirtIO-GPU driver. BO cache manager of Mesa driver

[PATCH v18 14/26] drm/lima: Explicitly get and put drm-shmem pages

2023-10-29 Thread Dmitry Osipenko
; 0. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/lima/lima_gem.c | 18 -- drivers/gpu/drm/lima/lima_gem.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c index 988e74f67465..d255f5775

[PATCH v18 25/26] drm/virtio: Support shmem shrinking

2023-10-29 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 v18 08/26] drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages()

2023-10-29 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 v18 19/26] drm/shmem-helper: Add common memory shrinker

2023-10-29 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| 386

[PATCH v18 13/26] drm/shmem-helper: Add drm_gem_shmem_put_pages()

2023-10-29 Thread Dmitry Osipenko
We're going to move away from having implicit get_pages() done by get_pages_sgt() to ease simplify refcnt handling. Drivers will manage get/put_pages() by themselves. Add drm_gem_shmem_put_pages(). Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 20

[PATCH v18 12/26] drm/shmem-helper: Make drm_gem_shmem_get_pages() public

2023-10-29 Thread Dmitry Osipenko
We're going to move away from having implicit get_pages() done by get_pages_sgt() to ease simplify refcnt handling. Drivers will manage get/put_pages() by themselves. Expose the drm_gem_shmem_get_pages() in a public drm-shmem API. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm

[PATCH v18 18/26] drm/shmem-helper: Change sgt allocation policy

2023-10-29 Thread Dmitry Osipenko
and should get new SGT if pages were unpinned. This new policy is required by the shrinker because it will move pages to/from SWAP unless pages are pinned, invalidating SGT pointer once pages are relocated. Previous patches prepared drivers to the new policy. Signed-off-by: Dmitry Osipenko

[PATCH v18 26/26] drm/panfrost: Switch to generic memory shrinker

2023-10-29 Thread Dmitry Osipenko
Replace Panfrost's custom memory shrinker with a common drm-shmem memory shrinker. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/panfrost/Makefile | 1 - drivers/gpu/drm/panfrost/panfrost_device.h| 4 - drivers/gpu/drm/panfrost/panfrost_drv.c | 27 ++-- drivers

[PATCH v18 06/26] drm/shmem-helper: Add and use pages_pin_count

2023-10-29 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 | 25 + include/drm/drm_gem_shmem_helper.h | 11 +++ 2 fi

[PATCH v18 22/26] drm/shmem-helper: Don't free refcounted GEM

2023-10-29 Thread Dmitry Osipenko
Don't free refcounted shmem object to prevent use-after-free bug that is worse than a memory leak. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b

[PATCH v18 24/26] drm/virtio: Attach shmem BOs dynamically

2023-10-29 Thread Dmitry Osipenko
-by: Gerd Hoffmann Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_drv.h| 7 +++ drivers/gpu/drm/virtio/virtgpu_gem.c| 26 + drivers/gpu/drm/virtio/virtgpu_ioctl.c | 32 +++ drivers/gpu/drm/virtio/virtgpu_object.c | 73 - drivers/gpu

[PATCH v18 11/26] drm/shmem-helper: Prepare drm_gem_shmem_free() to shrinker addition

2023-10-29 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 | 35 +- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b

[PATCH v18 05/26] drm/shmem-helper: Remove obsoleted is_iomem test

2023-10-29 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 v18 17/26] drm/v3d: Explicitly get and put drm-shmem pages

2023-10-29 Thread Dmitry Osipenko
; 0. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/v3d/v3d_bo.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/v3d/v3d_bo.c b/drivers/gpu/drm/v3d/v3d_bo.c index 42cd874f6810..0597c6b01b6c 100644 --- a/drivers/gpu/drm/v3d/v3d_bo.c +++ b/drivers/

[PATCH v18 20/26] drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked()

2023-10-29 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. Reviewed-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 22 +- include

[PATCH v18 07/26] drm/shmem-helper: Use refcount_t for pages_use_count

2023-10-29 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. Reviewed-by: Boris Brezillon Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c |

[PATCH v18 21/26] drm/shmem-helper: Optimize unlocked get_pages_sgt()

2023-10-29 Thread Dmitry Osipenko
SGT isn't refcounted. Once SGT pointer has been obtained, it remains the same for both locked and unlocked get_pages_sgt(). Return cached SGT directly without taking a potentially expensive lock. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 3 +++ 1 file changed

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

2023-10-29 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 v18 23/26] drm/virtio: Pin display framebuffer BO

2023-10-29 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 v18 16/26] drm/virtio: Explicitly get and put drm-shmem pages

2023-10-29 Thread Dmitry Osipenko
We're moving away from implicit get_pages() that is done by get_pages_sgt() to simplify the refcnt handling. Drivers will have to pin pages while they use sgt. VirtIO-GPU doesn't support shrinker, hence pages are pinned and sgt is valid as long as pages' use-count > 0. Signed-off-by: Dmi

[PATCH v18 10/26] drm/shmem-helper: Use refcount_t for vmap_use_count

2023-10-29 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 v18 15/26] drm/panfrost: Explicitly get and put drm-shmem pages

2023-10-29 Thread Dmitry Osipenko
' use-count > 0. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/panfrost/panfrost_gem.c | 17 + drivers/gpu/drm/panfrost/panfrost_mmu.c | 6 ++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/

[PATCH v18 03/26] drm/shmem-helper: Make all exported symbols GPL

2023-10-29 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 v18 04/26] drm/shmem-helper: Refactor locked/unlocked functions

2023-10-29 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 v18 01/26] drm/gem: Change locked/unlocked postfix of drm_gem_v/unmap() function names

2023-10-29 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

  1   2   3   4   5   6   7   8   9   10   >