[PATCH 5/5] drm: vmgfx_surface.c: copy user-array safely

2023-08-30 Thread Philipp Stanner
Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner --- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 4 ++-- 1 file

[PATCH 3/5] kernel: watch_queue: copy user-array safely

2023-08-30 Thread Philipp Stanner
Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner --- kernel/watch_queue.c | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH 4/5] drm_lease.c: copy user-array safely

2023-08-30 Thread Philipp Stanner
Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner --- drivers/gpu/drm/drm_lease.c | 4 ++-- 1 file changed, 2

[PATCH 0/5] Introduce new wrappers to copy user-arrays

2023-08-30 Thread Philipp Stanner
merged. P. Philipp Stanner (5): string.h: add array-wrappers for (v)memdup_user() kernel: kexec: copy user-array safely kernel: watch_queue: copy user-array safely drm_lease.c: copy user-array safely drm: vmgfx_surface.c: copy user-array safely drivers/gpu/drm/drm_lease.c

[PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-30 Thread Philipp Stanner
() and vmemdup_user() to provide a standardized and safe way for duplicating user arrays. This is both for new code as well as replacing usage of (v)memdup_user() in existing code that uses, e.g., n * size to calculate array sizes. Suggested-by: David Airlie Signed-off-by: Philipp Stanner --- include/linux

[PATCH 2/5] kernel: kexec: copy user-array safely

2023-08-30 Thread Philipp Stanner
Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner --- kernel/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH v2 0/5] Introduce new wrappers to copy user-arrays

2023-09-08 Thread Philipp Stanner
@ x86_64 does also boot fine. If there is more I can do to verify the early boot stages are fine, please let me know! P. Philipp Stanner (5): string.h: add array-wrappers for (v)memdup_user() kernel: kexec: copy user-array safely kernel: watch_queue: copy user-array safely drm_lease.c: copy

[PATCH v2 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-09-08 Thread Philipp Stanner
() and vmemdup_user() to provide a standardized and safe way for duplicating user arrays. This is both for new code as well as replacing usage of (v)memdup_user() in existing code that uses, e.g., n * size to calculate array sizes. Suggested-by: David Airlie Signed-off-by: Philipp Stanner --- include/linux

[PATCH v2 2/5] kernel: kexec: copy user-array safely

2023-09-08 Thread Philipp Stanner
Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner --- kernel/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH v2 3/5] kernel: watch_queue: copy user-array safely

2023-09-08 Thread Philipp Stanner
Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner --- kernel/watch_queue.c | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH v2 4/5] drm_lease.c: copy user-array safely

2023-09-08 Thread Philipp Stanner
Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner --- drivers/gpu/drm/drm_lease.c | 4 ++-- 1 file changed, 2

[PATCH v2 5/5] drm: vmgfx_surface.c: copy user-array safely

2023-09-08 Thread Philipp Stanner
Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner --- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 4 ++-- 1 file

Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-31 Thread Philipp Stanner
o wrote: > > > > > On Wed, Aug 30, 2023 at 4:46 PM Philipp Stanner > > > > > > > > Alphabetical. > > > > > > compiler.h > > > err.h > > > overflow.h > > > ...the rest that is a bit unordered... > > >

Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-31 Thread Philipp Stanner
On Wed, 2023-08-30 at 17:11 +0300, Andy Shevchenko wrote: > On Wed, Aug 30, 2023 at 4:46 PM Philipp Stanner > wrote: > > > > Currently, user array duplications are sometimes done without an > > overflow check. Sometimes the checks are done manually; sometimes > > th

[PATCH] drivers/video/fbdev: use new array-copying-wrapper

2023-11-02 Thread Philipp Stanner
viafbdev.c utilizes memdup_user() to copy an array from userspace. There is a new wrapper, specifically designed for copying arrays. Use this one instead. Suggested-by: Dave Airlie Signed-off-by: Philipp Stanner --- drivers/video/fbdev/via/viafbdev.c | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH v2] drm/ast: use managed devres functions

2023-11-03 Thread Philipp Stanner
-by: Thomas Zimmermann Signed-off-by: Philipp Stanner --- Changes in v2: - Remove unnecessary return code checks for pcim_iomap_regions() (Jocelyn) Thx Jocelyn for the kind review --- drivers/gpu/drm/ast/ast_main.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git

[PATCH] drm/ast: use managed devres functions

2023-10-30 Thread Philipp Stanner
-by: Thomas Zimmermann Signed-off-by: Philipp Stanner --- ¡Hola! I picked up the memory-region-request-task from the DRM-TODO-List [1] and began with this driver. Please have a first look. I wasn't entirely sure about -ENOMEM... for example, as far as my understanding goes, it should not be able to fail

Re: [PATCH v2 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-09-18 Thread Philipp Stanner
On Sat, 2023-09-16 at 17:32 +0300, Dan Carpenter wrote: > On Fri, Sep 08, 2023 at 09:59:40PM +0200, Philipp Stanner wrote: > > +static inline void *memdup_array_user(const void __user *src, > > size_t n, size_t size) > > +{ > > +   size_t nbytes; >

[PATCH v3 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-09-20 Thread Philipp Stanner
() and vmemdup_user() to provide a standardized and safe way for duplicating user arrays. This is both for new code as well as replacing usage of (v)memdup_user() in existing code that uses, e.g., n * size to calculate array sizes. Suggested-by: David Airlie Signed-off-by: Philipp Stanner Reviewed-by: Andy

[PATCH v3 0/5] Introduce new wrappers to copy user-arrays

2023-09-20 Thread Philipp Stanner
' docstrings - Return -EOVERFLOW instead of -EINVAL from wrapper functions P. Philipp Stanner (5): string.h: add array-wrappers for (v)memdup_user() kernel: kexec: copy user-array safely kernel: watch_queue: copy user-array safely drm_lease.c: copy user-array safely drm: vmgfx_surface.c: copy

[PATCH v3 2/5] kernel: kexec: copy user-array safely

2023-09-20 Thread Philipp Stanner
Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner Acked-by: Baoquan He Reviewed-by: Kees Cook Reviewed-by: Zack

[PATCH v3 5/5] drm: vmgfx_surface.c: copy user-array safely

2023-09-20 Thread Philipp Stanner
Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner Reviewed-by: Kees Cook Reviewed-by: Zack Rusin --- drivers/gpu

[PATCH v3 3/5] kernel: watch_queue: copy user-array safely

2023-09-20 Thread Philipp Stanner
Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner Reviewed-by: Kees Cook Reviewed-by: Zack Rusin --- kernel

[PATCH v3 4/5] drm_lease.c: copy user-array safely

2023-09-20 Thread Philipp Stanner
Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner Reviewed-by: Kees Cook Reviewed-by: Zack Rusin --- drivers/gpu

Re: [PATCH v2] drm/ast: use managed devres functions

2023-11-10 Thread Philipp Stanner
On Fri, 2023-11-03 at 19:25 +0100, Philipp Stanner wrote: > Currently, tha ast-driver just maps the PCI-dev's regions with > pcim_iomap(). It does not actually reserve the regions exclusively > with, e.g., pci_request_regions(). > > Replace the calls to pcim_io

Why does kgd2kfd_interrupt() have to schedule work on a specific CPU?

2023-06-27 Thread Philipp Stanner
Hello folks, I'm currently trying to learn more about DRM and discovered the following code sequence: drivers/gpu/drm/amd/amdkfd/kfd_device.c, Line 824 on 6.4-rc7 static inline void kfd_queue_work(struct workqueue_struct *wq, struct work_struct *work) {

[PATCH v4 0/2] drm/imx/dcss: implement region request and devres

2024-01-24 Thread Philipp Stanner
you might want to have a closer look. P. [1] https://lore.kernel.org/lkml/45ad1d0f-a10f-483e-848a-76a30252edbe@paulmck-laptop/ Philipp Stanner (2): drm/imx/dcss: request memory region drm/imx/dcss: have all init functions use devres drivers/gpu/drm/imx/dcss/dcss-blkctl.c | 13

[PATCH v4 1/2] drm/imx/dcss: request memory region

2024-01-24 Thread Philipp Stanner
The driver's memory regions are currently just ioremap()ed, but not reserved through a request. That's not a bug, but having the request is a little more robust. Implement the region-request through the corresponding managed devres-function. Signed-off-by: Philipp Stanner Reviewed-by: Laurentiu

[PATCH v4 2/2] drm/imx/dcss: have all init functions use devres

2024-01-24 Thread Philipp Stanner
-by: Philipp Stanner --- drivers/gpu/drm/imx/dcss/dcss-blkctl.c | 13 ++--- drivers/gpu/drm/imx/dcss/dcss-ctxld.c | 14 +++--- drivers/gpu/drm/imx/dcss/dcss-dev.c| 12 ++-- drivers/gpu/drm/imx/dcss/dcss-dev.h| 1 - drivers/gpu/drm/imx/dcss/dcss-dpr.c| 21

[PATCH v3 01/10] PCI: Add new set of devres functions

2024-02-06 Thread Philipp Stanner
ly and bypass the legacy iomap table mechanism. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 473 ++- include/linux/pci.h | 11 + 2 files changed, 479 insertions(+), 5 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c ind

[PATCH v3 02/10] PCI: Deprecate iomap-table functions

2024-02-06 Thread Philipp Stanner
as much of the iomap-table-mechanism as possible. Add comments describing the path towards a cleaned-up API. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 374 +-- drivers/pci/pci.c| 20 +++ drivers/pci/pci.h| 5 + include/linux/pci.h

[PATCH v3 03/10] PCI: Warn users about complicated devres nature

2024-02-06 Thread Philipp Stanner
. This is not the case. Add comments to the relevant functions' docstrings that warn users about this behavior. Signed-off-by: Philipp Stanner --- drivers/pci/iomap.c | 18 ++ drivers/pci/pci.c | 60 - 2 files changed, 77 insertions(+), 1

[PATCH v3 05/10] PCI: Move dev-enabled status bit to struct pci_dev

2024-02-06 Thread Philipp Stanner
to struct pci_dev. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 11 --- drivers/pci/pci.c| 17 ++--- drivers/pci/pci.h| 1 - include/linux/pci.h | 1 + 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c

[PATCH v3 06/10] PCI: Move pinned status bit to struct pci_dev

2024-02-06 Thread Philipp Stanner
. This will later permit simplifying pcim_enable_device(). Move the 'pinned' boolean bit to struct pci_dev. Restructure bits in struct pci_dev so the pm / pme fields are next to each other. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 14 -- drivers/pci/pci.h| 1

[PATCH v3 04/10] PCI: Make devres region requests consistent

2024-02-06 Thread Philipp Stanner
the pci_request / release functions call their pcim_ counterparts. Remove the now surplus region_mask from struct pci_devres. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 49 ++- drivers/pci/pci.c| 50

[PATCH v3 07/10] PCI: Give pcim_set_mwi() its own devres callback

2024-02-06 Thread Philipp Stanner
Managing pci_set_mwi() with devres can easily be done with its own callback, without the necessity to store any state about it in a device-related struct. Remove the MWI state from struct pci_devres. Give pcim_set_mwi() a separate devres-callback. Signed-off-by: Philipp Stanner --- drivers/pci

[PATCH v3 08/10] PCI: Give pci(m)_intx its own devres callback

2024-02-06 Thread Philipp Stanner
pcim_intx() in the managed case. Remove the struct pci_devres from pci.h. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 76 ++-- drivers/pci/pci.c| 24 +++--- drivers/pci/pci.h| 21 +++- 3 files changed, 77 insertions(+), 44

[PATCH v3 09/10] PCI: Remove legacy pcim_release()

2024-02-06 Thread Philipp Stanner
the now surplus function get_pci_dr(). Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 49 +++- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c index 8a643f15140a..3e567773c556 100644

[PATCH v3 10/10] drm/vboxvideo: fix mapping leaks

2024-02-06 Thread Philipp Stanner
, functions become managed that way. The function pci_iomap_range() is never managed. Replace pci_iomap_range() with the actually managed function pcim_iomap_range(). CC: # v5.10+ Fixes: 8558de401b5f ("drm/vboxvideo: use managed pci functions") Signed-off-by: Philipp Stanner --- drive

[PATCH v3 00/10] Make PCI's devres API more consistent

2024-02-06 Thread Philipp Stanner
tem. Kasan and kmemleak didn't find any problems. I believe this series cleans the API up as much as possible without having to port all existing drivers to the new API. Especially, I think that this implementation is easy to extend if the need for new managed functions arises :) Greetings, P.

[PATCH] drm/tilcdc: request and mapp iomem with devres

2023-12-22 Thread Philipp Stanner
Signed-off-by: Philipp Stanner --- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 19 --- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c index 8ebd7134ee21..2ad3f44a6e2d 100644 --- a/drivers/gpu/drm

[PATCH 2/2] drm/dcss: request memory region

2024-01-05 Thread Philipp Stanner
The driver's memory regions are currently just ioremap()ed, but not reserved through a request. That's not a bug, but having the request is a little more robust. Implement the region-request through the corresponding managed devres-function. Signed-off-by: Philipp Stanner --- drivers/gpu/drm

[PATCH 1/2] platform_device: add devres function region-reqs

2024-01-05 Thread Philipp Stanner
Some drivers want to use (request) a region exclusively but nevertheless create several mappings within that region. Currently, there is no managed devres function to request a region without mapping it. Add the function devm_platform_get_resource() Signed-off-by: Philipp Stanner --- drivers

[PATCH 0/2] platform_device: add new devres function

2024-01-05 Thread Philipp Stanner
. Philipp Stanner (2): platform_device: add devres function region-reqs drm/dcss: request memory region drivers/base/platform.c | 37 + drivers/gpu/drm/imx/dcss/dcss-dev.c | 8 +++ include/linux/platform_device.h | 2 ++ 3 files changed, 43 insertions

[PATCH] drm/imx/dcss: have all init functions use devres

2024-01-05 Thread Philipp Stanner
-by: Philipp Stanner --- This is a separate patch because it can be applied independently from my other patch-series that applies the region-request for this driver. --- drivers/gpu/drm/imx/dcss/dcss-blkctl.c | 14 +++--- drivers/gpu/drm/imx/dcss/dcss-ctxld.c | 15 --- drivers/gpu/drm

[PATCH v3 0/2] drm/imx/dcss: implement region request and devres

2024-01-11 Thread Philipp Stanner
want to have a closer look. P. Philipp Stanner (2): drm/imx/dcss: request memory region drm/imx/dcss: have all init functions use devres drivers/gpu/drm/imx/dcss/dcss-blkctl.c | 14 +++--- drivers/gpu/drm/imx/dcss/dcss-ctxld.c | 15 --- drivers/gpu/drm/imx/dcss/dcss-dev.c

[PATCH v3 1/2] drm/imx/dcss: request memory region

2024-01-11 Thread Philipp Stanner
The driver's memory regions are currently just ioremap()ed, but not reserved through a request. That's not a bug, but having the request is a little more robust. Implement the region-request through the corresponding managed devres-function. Signed-off-by: Philipp Stanner --- drivers/gpu/drm

[PATCH v3 2/2] drm/imx/dcss: have all init functions use devres

2024-01-11 Thread Philipp Stanner
-by: Philipp Stanner --- drivers/gpu/drm/imx/dcss/dcss-blkctl.c | 14 +++--- drivers/gpu/drm/imx/dcss/dcss-ctxld.c | 15 --- drivers/gpu/drm/imx/dcss/dcss-dev.c| 12 ++-- drivers/gpu/drm/imx/dcss/dcss-dev.h| 1 - drivers/gpu/drm/imx/dcss/dcss-dpr.c| 25

Re: [PATCH 01/10] pci: add new set of devres functions

2024-01-17 Thread Philipp Stanner
On Tue, 2024-01-16 at 23:15 +0200, andy.shevche...@gmail.com wrote: > Mon, Jan 15, 2024 at 03:46:12PM +0100, Philipp Stanner kirjoitti: > > PCI's devres API is not extensible to ranged mappings and has > > bug-provoking features. Improve that by providing better > > altern

Re: [PATCH 02/10] pci: deprecate iomap-table functions

2024-01-17 Thread Philipp Stanner
On Tue, 2024-01-16 at 23:27 +0200, andy.shevche...@gmail.com wrote: > Mon, Jan 15, 2024 at 03:46:13PM +0100, Philipp Stanner kirjoitti: > > The old plural devres functions tie PCI's devres implementation to > > the > > iomap-table mechanism which unfortunat

[PATCH 01/10] pci: add new set of devres functions

2024-01-15 Thread Philipp Stanner
d) region-request functions being sometimes managed and sometimes not is bug-provoking. Implement a set of singular pcim_ functions that use devres directly and bypass the legacy iomap table mechanism. Add devres.c to driver-api documentation. Signed-off-by: Philipp Stanner --- Docume

[PATCH 00/10] Make PCI's devres API more consistent

2024-01-15 Thread Philipp Stanner
ions arises :) Greetings, P. [1] https://lore.kernel.org/lkml/20240111085540.7740-1-pstan...@redhat.com/ Philipp Stanner (10): pci: add new set of devres functions pci: deprecate iomap-table functions pci: warn users about complicated devres nature pci: devres: make devres region requests c

[PATCH 03/10] pci: warn users about complicated devres nature

2024-01-15 Thread Philipp Stanner
. This is not the case. Add comments to the relevant functions' docstrings that warn users about this behavior. Signed-off-by: Philipp Stanner --- drivers/pci/iomap.c | 18 ++ drivers/pci/pci.c | 60 - 2 files changed, 77 insertions(+), 1 deletion

[PATCH 02/10] pci: deprecate iomap-table functions

2024-01-15 Thread Philipp Stanner
. Remove as much of the iomap-table-mechanism as possible. Add comments describing the path towards a cleaned-up API. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 369 +-- drivers/pci/pci.c| 20 +++ drivers/pci/pci.h| 5 + include

[PATCH 04/10] pci: devres: make devres region requests consistent

2024-01-15 Thread Philipp Stanner
the pci_request / release functions call their pcim_ counterparts. Remove the now surplus region_mask from the devres struct. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 49 ++- drivers/pci/pci.c| 50

[PATCH 08/10] pci: devres: give pci(m)_intx its own callback

2024-01-15 Thread Philipp Stanner
the region-request-functions, pci_intx() has to call into its managed counterpart for backwards compatibility. Implement pcim_intx() with its own device resource. Make pci_intx() call pcim_intx() in the managed case. Remove the legacy devres struct from pci.h. Signed-off-by: Philipp Stanner --- d

[PATCH 09/10] pci: devres: remove legacy pcim_release()

2024-01-15 Thread Philipp Stanner
the now surplus get_dr() function. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 38 -- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c index 7c4edcaeb8fe..87bc62be21eb 100644 --- a/drivers

[PATCH 07/10] pci: devres: give mwi its own callback

2024-01-15 Thread Philipp Stanner
managing mwi with devres can easily be done with its own callback, without the necessity to store any state about it in a device-related struct. Remove the mwi state from the devres-struct. Make the devres-mwi functions set a separate devres-callback. Signed-off-by: Philipp Stanner --- drivers

[PATCH 05/10] pci: move enabled status bit to pci_dev struct

2024-01-15 Thread Philipp Stanner
to struct pci_dev. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 11 --- drivers/pci/pci.c| 17 ++--- drivers/pci/pci.h| 1 - include/linux/pci.h | 1 + 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c

[PATCH 06/10] pci: move pinned status bit to pci_dev struct

2024-01-15 Thread Philipp Stanner
struct. This will later permit simplifying pcim_enable_device(). Move the 'pinned' boolean bit to struct pci_dev. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 14 -- drivers/pci/pci.h| 1 - include/linux/pci.h | 1 + 3 files changed, 5 insertions(+), 11 deletions

[PATCH 10/10] drm/vboxvideo: fix mapping leaks

2024-01-15 Thread Philipp Stanner
pci_iomap_range() is never managed. Replace pci_iomap_range() with the actually managed function pcim_iomap_range(). Additionally, add a call to pcim_request_region() to ensure exclusive access to BAR 0. CC: # v5.10+ Fixes: 8558de401b5f ("drm/vboxvideo: use managed pci functions") Signed-off-b

Re: [PATCH 01/10] pci: add new set of devres functions

2024-01-17 Thread Philipp Stanner
On Tue, 2024-01-16 at 12:44 -0600, Bjorn Helgaas wrote: > On Mon, Jan 15, 2024 at 03:46:12PM +0100, Philipp Stanner wrote: > > PCI's devres API is not extensible to ranged mappings and has > > bug-provoking features. Improve that by providing better > > alternatives. > &g

Re: [PATCH 06/10] pci: move pinned status bit to pci_dev struct

2024-01-17 Thread Philipp Stanner
On Tue, 2024-01-16 at 23:34 +0200, andy.shevche...@gmail.com wrote: > Mon, Jan 15, 2024 at 03:46:17PM +0100, Philipp Stanner kirjoitti: > > The bit describing whether the PCI device is currently pinned is > > stored > > in the PCI devres struct. To clean up and simplify t

Re: [PATCH 00/10] Make PCI's devres API more consistent

2024-01-17 Thread Philipp Stanner
On Tue, 2024-01-16 at 23:17 +0200, andy.shevche...@gmail.com wrote: > Mon, Jan 15, 2024 at 03:46:11PM +0100, Philipp Stanner kirjoitti: > > ¡Hola! > > i? Vim user? :-) The Dark Side of the Force is the path to many abilities, that some consider to be... unnatural https://www

Re: [PATCH 00/10] Make PCI's devres API more consistent

2024-01-18 Thread Philipp Stanner
On Wed, 2024-01-17 at 10:59 +0100, Philipp Stanner wrote: > On Tue, 2024-01-16 at 23:17 +0200, andy.shevche...@gmail.com wrote: > > Mon, Jan 15, 2024 at 03:46:11PM +0100, Philipp Stanner kirjoitti: [...] > > > > > > > PCI's devres API suffers seve

Re: [PATCH 09/10] pci: devres: remove legacy pcim_release()

2024-01-17 Thread Philipp Stanner
On Tue, 2024-01-16 at 23:40 +0200, andy.shevche...@gmail.com wrote: > Mon, Jan 15, 2024 at 03:46:20PM +0100, Philipp Stanner kirjoitti: > > Thanks to preceding cleanup steps, pcim_release() is now not needed > > anymore and can be replaced by pcim_disable_device(), which i

Re: [PATCH 1/2] platform_device: add devres function region-reqs

2024-01-08 Thread Philipp Stanner
Hi On Fri, 2024-01-05 at 20:11 +0100, Uwe Kleine-König wrote: > On Fri, Jan 05, 2024 at 06:22:18PM +0100, Philipp Stanner wrote: > > Some drivers want to use (request) a region exclusively but > > nevertheless > > create several mappings within that region. > > > &g

Re: [PATCH v2 1/2] platform_device: add devres function region-reqs

2024-01-09 Thread Philipp Stanner
Yo! On Mon, 2024-01-08 at 12:46 +0100, Uwe Kleine-König wrote: > On Mon, Jan 08, 2024 at 10:45:31AM +0100, Philipp Stanner wrote: > > On Mon, 2024-01-08 at 10:37 +0100, Uwe Kleine-König wrote: > > > Other than that I indifferent if this is a good idea. There are > > > s

[PATCH v2 1/2] drm/dcss: request memory region

2024-01-09 Thread Philipp Stanner
The driver's memory regions are currently just ioremap()ed, but not reserved through a request. That's not a bug, but having the request is a little more robust. Implement the region-request through the corresponding managed devres-function. Signed-off-by: Philipp Stanner --- drivers/gpu/drm

[PATCH v2 2/2] drm/imx/dcss: have all init functions use devres

2024-01-09 Thread Philipp Stanner
-by: Philipp Stanner --- drivers/gpu/drm/imx/dcss/dcss-blkctl.c | 14 +++--- drivers/gpu/drm/imx/dcss/dcss-ctxld.c | 15 --- drivers/gpu/drm/imx/dcss/dcss-dev.c| 11 ++- drivers/gpu/drm/imx/dcss/dcss-dpr.c| 25 ++--- drivers/gpu/drm/imx/dcss/dcss-drv.c

[PATCH v2 0/2] drm/imx/dcss: implement region request and devres

2024-01-09 Thread Philipp Stanner
. Philipp Stanner (2): drm/dcss: request memory region drm/imx/dcss: have all init functions use devres drivers/gpu/drm/imx/dcss/dcss-blkctl.c | 14 +++--- drivers/gpu/drm/imx/dcss/dcss-ctxld.c | 15 --- drivers/gpu/drm/imx/dcss/dcss-dev.c| 18 +- drivers

Re: [PATCH v2 1/2] platform_device: add devres function region-reqs

2024-01-08 Thread Philipp Stanner
On Mon, 2024-01-08 at 10:37 +0100, Uwe Kleine-König wrote: > Hello Philipp, > > the Subject is incomprehensible (to me). Maybe make it: > > platform_device: Add devm function to simplify mem and io > requests > > ? > > On Mon, Jan 08, 2024 at 10:20:42A

[PATCH v2 1/2] platform_device: add devres function region-reqs

2024-01-08 Thread Philipp Stanner
Some drivers want to use (request) a region exclusively but nevertheless create several mappings within that region. Currently, there is no managed devres function to request a region without mapping it. Add the function devm_platform_get_resource(). Signed-off-by: Philipp Stanner --- drivers

[PATCH v2 2/2] drm/dcss: request memory region

2024-01-08 Thread Philipp Stanner
The driver's memory regions are currently just ioremap()ed, but not reserved through a request. That's not a bug, but having the request is a little more robust. Implement the region-request through the corresponding managed devres-function. Signed-off-by: Philipp Stanner --- drivers/gpu/drm

[PATCH v2 0/2] platform_device: add new devres function

2024-01-08 Thread Philipp Stanner
this successfully but unfortunately don't have the hardware to test it for dcss. So you might want to have a closer look. Greetings, P. Philipp Stanner (2): platform_device: add devres function region-reqs drm/dcss: request memory region drivers/base/platform.c | 38

Re: [RFC PATCH 0/6] Supporting GMEM (generalized memory management) for external memory devices

2023-12-01 Thread Philipp Stanner
On Fri, 2023-12-01 at 02:37 +, zhuweixi wrote: > From your argument on KVM I can see that the biggest miscommunication > between us is that you believed that GMEM wanted to share the whole > address space. No, it is not the case. GMEM is only providing > coordination via certain mmap() calls.

Re: [PATCH v2 10/10] drm/vboxvideo: fix mapping leaks

2024-01-29 Thread Philipp Stanner
Hi, On Mon, 2024-01-29 at 12:15 +0100, Hans de Goede wrote: > Hi Philipp, > > On 1/23/24 10:43, Philipp Stanner wrote: > > When the PCI devres API was introduced to this driver, it was > > wrongly > > assumed that initializing the device with pcim_

[PATCH v2 02/10] PCI: deprecate iomap-table functions

2024-01-23 Thread Philipp Stanner
as much of the iomap-table-mechanism as possible. Add comments describing the path towards a cleaned-up API. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 374 +-- drivers/pci/pci.c| 20 +++ drivers/pci/pci.h| 5 + include/linux/pci.h

[PATCH v2 03/10] PCI: warn users about complicated devres nature

2024-01-23 Thread Philipp Stanner
. This is not the case. Add comments to the relevant functions' docstrings that warn users about this behavior. Signed-off-by: Philipp Stanner --- drivers/pci/iomap.c | 18 ++ drivers/pci/pci.c | 60 - 2 files changed, 77 insertions(+), 1

[PATCH v2 04/10] PCI: make devres region requests consistent

2024-01-23 Thread Philipp Stanner
the pci_request / release functions call their pcim_ counterparts. Remove the now surplus region_mask from struct pci_devres. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 49 ++- drivers/pci/pci.c| 50

[PATCH v2 09/10] PCI: remove legacy pcim_release()

2024-01-23 Thread Philipp Stanner
the now surplus function get_pci_dr(). Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 49 +++- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c index 4314d0863282..f368181c6c92 100644

[PATCH v2 05/10] PCI: move dev-enabled status bit to struct pci_dev

2024-01-23 Thread Philipp Stanner
to struct pci_dev. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 11 --- drivers/pci/pci.c| 17 ++--- drivers/pci/pci.h| 1 - include/linux/pci.h | 1 + 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c

[PATCH v2 00/10] Make PCI's devres API more consistent

2024-01-23 Thread Philipp Stanner
series cleans the API up as much as possible without having to port all existing drivers to the new API. Especially, I think that this implementation is easy to extend if the need for new managed functions arises :) Greetings, P. Philipp Stanner (10): PCI: add new set of devres functions

[PATCH v2 01/10] PCI: add new set of devres functions

2024-01-23 Thread Philipp Stanner
ly and bypass the legacy iomap table mechanism. Add devres.c to driver-api documentation. Signed-off-by: Philipp Stanner --- Documentation/driver-api/pci/pci.rst | 3 + drivers/pci/devres.c | 473 ++- include/linux/pci.h | 11 + 3

[PATCH v2 08/10] PCI: give pci(m)_intx its own devres callback

2024-01-23 Thread Philipp Stanner
pcim_intx() in the managed case. Remove the struct pci_devres from pci.h. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 76 ++-- drivers/pci/pci.c| 24 +++--- drivers/pci/pci.h| 21 +++- 3 files changed, 77 insertions(+), 44

[PATCH v2 10/10] drm/vboxvideo: fix mapping leaks

2024-01-23 Thread Philipp Stanner
t;drm/vboxvideo: use managed pci functions") Signed-off-by: Philipp Stanner --- drivers/gpu/drm/vboxvideo/vbox_main.c | 24 +--- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_ma

[PATCH v2 06/10] PCI: move pinned status bit to struct pci_dev

2024-01-23 Thread Philipp Stanner
. This will later permit simplifying pcim_enable_device(). Move the 'pinned' boolean bit to struct pci_dev. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 14 -- drivers/pci/pci.h| 1 - include/linux/pci.h | 5 +++-- 3 files changed, 7 insertions(+), 13 deletions(-) diff

[PATCH v2 07/10] PCI: give pcim_set_mwi() its own devres callback

2024-01-23 Thread Philipp Stanner
Managing pci_set_mwi() with devres can easily be done with its own callback, without the necessity to store any state about it in a device-related struct. Remove the MWI state from struct pci_devres. Give pcim_set_mwi() a separate devres-callback. Signed-off-by: Philipp Stanner --- drivers/pci

Re: [PATCH v2 00/10] Make PCI's devres API more consistent

2024-01-23 Thread Philipp Stanner
Forgot to add a few changes to the changelog: On Tue, 2024-01-23 at 10:42 +0100, Philipp Stanner wrote: > Changes in v2: >   - Make commit head lines congruent with PCI's style (Bjorn) >   - Add missing error checks for devm_add_action(). (Andy) >   - Repair the "Returns:

Re: [PATCH v3 00/10] Make PCI's devres API more consistent

2024-03-01 Thread Philipp Stanner
On Thu, 2024-02-29 at 14:57 -0600, Bjorn Helgaas wrote: > On Thu, Feb 29, 2024 at 09:31:20AM +0100, Philipp Stanner wrote: > > @Bjorn: > > Hey Bjorn, are we good with this series? Any more wishes or > > suggestions? > > Sorry, haven't had a chance to go through it yet

[PATCH v4 00/10] Make PCI's devres API more consistent

2024-03-01 Thread Philipp Stanner
Especially, I think that this implementation is easy to extend if the need for new managed functions arises :) Greetings, P. Philipp Stanner (10): PCI: Add new set of devres functions PCI: Deprecate iomap-table functions PCI: Warn users about complicated devres nature PCI: Make devres r

[PATCH v4 01/10] PCI: Add new set of devres functions

2024-03-01 Thread Philipp Stanner
ly and bypass the legacy iomap table mechanism. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 473 ++- include/linux/pci.h | 11 + 2 files changed, 479 insertions(+), 5 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c ind

[PATCH v4 09/10] PCI: Remove legacy pcim_release()

2024-03-01 Thread Philipp Stanner
the now surplus function get_pci_dr(). Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 49 +++- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c index 8a643f15140a..3e567773c556 100644

[PATCH v4 10/10] drm/vboxvideo: fix mapping leaks

2024-03-01 Thread Philipp Stanner
, functions become managed that way. The function pci_iomap_range() is never managed. Replace pci_iomap_range() with the actually managed function pcim_iomap_range(). CC: # v5.10+ Fixes: 8558de401b5f ("drm/vboxvideo: use managed pci functions") Signed-off-by: Philipp Stanner --- drive

[PATCH v4 08/10] PCI: Give pci(m)_intx its own devres callback

2024-03-01 Thread Philipp Stanner
pcim_intx() in the managed case. Remove the struct pci_devres from pci.h. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 74 +++- drivers/pci/pci.c| 24 +++--- drivers/pci/pci.h| 17 +- 3 files changed, 74 insertions(+), 41

[PATCH v4 02/10] PCI: Deprecate iomap-table functions

2024-03-01 Thread Philipp Stanner
as much of the iomap-table-mechanism as possible. Add comments describing the path towards a cleaned-up API. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 374 +-- drivers/pci/pci.c| 20 +++ drivers/pci/pci.h| 5 + include/linux/pci.h

[PATCH v4 03/10] PCI: Warn users about complicated devres nature

2024-03-01 Thread Philipp Stanner
. This is not the case. Add comments to the relevant functions' docstrings that warn users about this behavior. Signed-off-by: Philipp Stanner --- drivers/pci/iomap.c | 18 ++ drivers/pci/pci.c | 60 - 2 files changed, 77 insertions(+), 1

[PATCH v4 04/10] PCI: Make devres region requests consistent

2024-03-01 Thread Philipp Stanner
the pci_request / release functions call their pcim_ counterparts. Remove the now surplus region_mask from struct pci_devres. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 49 ++- drivers/pci/pci.c| 50

[PATCH v4 06/10] PCI: Move pinned status bit to struct pci_dev

2024-03-01 Thread Philipp Stanner
. This will later permit simplifying pcim_enable_device(). Move the 'pinned' boolean bit to struct pci_dev. Restructure bits in struct pci_dev so the pm / pme fields are next to each other. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 14 -- drivers/pci/pci.h| 1

[PATCH v4 05/10] PCI: Move dev-enabled status bit to struct pci_dev

2024-03-01 Thread Philipp Stanner
to struct pci_dev. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 11 --- drivers/pci/pci.c| 17 ++--- drivers/pci/pci.h| 1 - include/linux/pci.h | 1 + 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c

  1   2   >