[RFC PATCH v4 07/11] fbdev: Make sysfb to unregister its own registered devices

2022-04-29 Thread Javier Martinez Canillas
r the simple framebuffer devices, so an unregistration has to be forced by fbmem if sysfb_try_unregister() does not succeed at unregister the device. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Vetter --- Changes in v4: - Drop call to sysfb_disable() in

[RFC PATCH v4 10/11] Revert "fbdev: Prevent probing generic drivers if a FB is already registered"

2022-04-29 Thread Javier Martinez Canillas
and we can remove this somewhat hackish check here (e.g. this won't catch drm drivers if fbdev emulation isn't enabled). Cc: Thomas Zimmermann Cc: Zack Rusin Cc: Javier Martinez Canillas Cc: Zack Rusin Cc: Hans de Goede Cc: Ilya Trukhanov Signed-off-by: Daniel Vetter Signed-off-

[RFC PATCH v4 11/11] fbdev: Make registered_fb[] private to fbmem.c

2022-04-29 Thread Javier Martinez Canillas
: linux-stag...@lists.linux.dev Signed-off-by: Daniel Vetter Signed-off-by: Daniel Vetter Reviewed-by: Javier Martinez Canillas Cc: Daniel Vetter Cc: Helge Deller Cc: Matthew Wilcox Cc: Sam Ravnborg Cc: Tetsuo Handa Cc: Zhen Lei Cc: Alex Deucher Cc: Xiyu Yang Cc: linux-fb...@vger.kernel.org

Re: [RFC PATCH v4 02/11] drm/fb-helper: Set FBINFO_MISC_FIRMWARE flag for DRIVER_FIRMWARE fb

2022-04-29 Thread Javier Martinez Canillas
Hello Thomas, On 4/29/22 11:14, Thomas Zimmermann wrote: > Hi > > Am 29.04.22 um 10:42 schrieb Javier Martinez Canillas: >> The DRIVER_FIRMWARE flag denotes that a DRM driver uses a framebuffer >> that was initialized and provided by the system firmware for scanout. >&g

Re: [RFC PATCH v4 02/11] drm/fb-helper: Set FBINFO_MISC_FIRMWARE flag for DRIVER_FIRMWARE fb

2022-04-29 Thread Javier Martinez Canillas
eries ? Then the patches would only be 1) renaming preferred_bpp (that would be unused at this point) to flags and 2) make simpledrm to set FBDEV_FIRMWARE flag or something like that. Another option is to add a third flags param to drm_fbdev_generic_setup() and make all drivers to set 0 besides si

[PATCH 0/3] drm: Allow simpledrm to setup its emulated FB as firmware provided

2022-05-02 Thread Javier Martinez Canillas
[0]: https://lore.kernel.org/lkml/20220429084253.1085911-1-javi...@redhat.com/ Javier Martinez Canillas (3): drm: Remove superfluous arg when calling to drm_fbdev_generic_setup() drm/fb-helper: Rename preferred_bpp drm_fbdev_generic_setup() parameter drm: Allow simpledrm to setup its em

[PATCH 1/3] drm: Remove superfluous arg when calling to drm_fbdev_generic_setup()

2022-05-02 Thread Javier Martinez Canillas
: Javier Martinez Canillas --- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 2 +- drivers/gpu/drm/tiny/cirrus.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv

[PATCH 2/3] drm/fb-helper: Rename preferred_bpp drm_fbdev_generic_setup() parameter

2022-05-02 Thread Javier Martinez Canillas
ann Signed-off-by: Javier Martinez Canillas --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 6 -- drivers/gpu/drm/arm/hdlcd_drv.c | 2 +- drivers/gpu/drm/arm/malidp_drv.c| 2 +- drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 2 +- drivers/gpu/drm/

[PATCH 3/3] drm: Allow simpledrm to setup its emulated FB as firmware provided

2022-05-02 Thread Javier Martinez Canillas
. Drivers can use this to indicate the FB helper initialization that the FB registered is provided by the firmware, so it can be configured as such. Suggested-by: Thomas Zimmermann Signed-off-by: Javier Martinez Canillas --- drivers/gpu/drm/drm_fb_helper.c | 9 + drivers/gpu/drm/tiny

Re: [PATCH 0/3] drm: Allow simpledrm to setup its emulated FB as firmware provided

2022-05-02 Thread Javier Martinez Canillas
Hello Thomas, On 5/2/22 12:35, Thomas Zimmermann wrote: > Hi Javier > > Am 02.05.22 um 10:48 schrieb Javier Martinez Canillas: >> Hello, >> >> This series contain patches suggested by Thomas Zimmermannas a feedback for Ups, I missed a space here. I meant to writ

[PATCH 0/2] fbdev: Fix a NULL pointer dereference in fb_release()

2022-05-02 Thread Javier Martinez Canillas
tches in a rpi4 with both simplefb and vc4 drivers built-in and did not find any regression. [0]: https://github.com/raspberrypi/linux/issues/5011 Best regards, Javier Javier Martinez Canillas (2): fbdev: Check in file_fb_info() if the fb_info was already been freed fbdev: Make fb_re

[PATCH 1/2] fbdev: Check in file_fb_info() if the fb_info was already been freed

2022-05-02 Thread Javier Martinez Canillas
-by: Javier Martinez Canillas --- drivers/video/fbdev/core/fbmem.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 84427470367b..20d8929df79f 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b

[PATCH 2/2] fbdev: Make fb_release() return -ENODEV if fbdev was unregistered

2022-05-02 Thread Javier Martinez Canillas
. This can happen for example if the fbdev driver was one that is using a framebuffer provided by the system firmware. In that case, the fbdev core could unregister the framebuffer device if a real video driver is probed. Reported-by: Maxime Ripard Signed-off-by: Javier Martinez Canillas

Re: [PATCH 2/3] drm/fb-helper: Rename preferred_bpp drm_fbdev_generic_setup() parameter

2022-05-02 Thread Javier Martinez Canillas
rename DRM_FB_SET_OPTION() to DRM_FB_OPTION() as it's > computing the value of the option bitfield, it doesn't actually set it. > Apart from that, > Right. I'll rename it. > Reviewed-by: Laurent Pinchart > Thanks! -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH 1/2] fbdev: Check in file_fb_info() if the fb_info was already been freed

2022-05-02 Thread Javier Martinez Canillas
Hello Thomas, On 5/2/22 15:26, Thomas Zimmermann wrote: > Hi > > Am 02.05.22 um 15:09 schrieb Javier Martinez Canillas: >> If real driver probes, the fbdev core kicks out all drivers that are using >> a framebuffer that were provided by the system firmware. But it cou

Re: [PATCH 2/2] fbdev: Make fb_release() return -ENODEV if fbdev was unregistered

2022-05-02 Thread Javier Martinez Canillas
Hello Thomas, On 5/2/22 15:20, Thomas Zimmermann wrote: > > > Am 02.05.22 um 15:09 schrieb Javier Martinez Canillas: >> A reference to the framebuffer device struct fb_info is stored in the file >> private data, but this reference could no longer be valid and must not be

[PATCH v2] fbdev: Make fb_release() return -ENODEV if fbdev was unregistered

2022-05-02 Thread Javier Martinez Canillas
d removal") Reported-by: Maxime Ripard Reported-by: Junxiao Chang Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann --- Changes in v2: - Drop patch 1/2 since patch 2/2 should be enough to fix the issue. - Add missing Fixes and Reported-by tags (Thomas Zimmermann).

[PATCH v2 2/3] drm/fb-helper: Rename preferred_bpp drm_fbdev_generic_setup() parameter

2022-05-02 Thread Javier Martinez Canillas
ded. Suggested-by: Thomas Zimmermann Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Laurent Pinchart --- Changes in v2: - Rename DRM_FB_SET_OPTION() to DRM_FB_SET() and make more clear in the kernel-doc what this macro does (Laurent Pinchart). - Fix some kernel-

[PATCH v2 0/3] drm: Allow simpledrm to setup its emulated FB as firmware provided

2022-05-02 Thread Javier Martinez Canillas
c issues I didn't notice in v1. - Add Reviewed-by tags from Thomas and Laurent. Javier Martinez Canillas (3): drm: Remove superfluous arg when calling to drm_fbdev_generic_setup() drm/fb-helper: Rename preferred_bpp drm_fbdev_generic_setup() parameter drm: Allow simpledrm to setup i

[PATCH v2 3/3] drm: Allow simpledrm to setup its emulated FB as firmware provided

2022-05-02 Thread Javier Martinez Canillas
. Drivers can use this to indicate the FB helper initialization that the FB registered is provided by the firmware, so it can be configured as such. Suggested-by: Thomas Zimmermann Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann --- (no changes since v1) drivers/gpu/drm

[PATCH v2 1/3] drm: Remove superfluous arg when calling to drm_fbdev_generic_setup()

2022-05-02 Thread Javier Martinez Canillas
: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann --- (no changes since v1) drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 2 +- drivers/gpu/drm/tiny/cirrus.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_d

Re: [PATCH v2 1/3] drm: Remove superfluous arg when calling to drm_fbdev_generic_setup()

2022-05-02 Thread Javier Martinez Canillas
Hello Laurent, On 5/2/22 18:06, Laurent Pinchart wrote: > Hi Javier, > > Thank you for the patch. > > On Mon, May 02, 2022 at 05:38:58PM +0200, Javier Martinez Canillas wrote: >> The drm_fbdev_generic_setup() function already sets the preferred bits per >>

Re: [PATCH v2 2/3] drm/fb-helper: Rename preferred_bpp drm_fbdev_generic_setup() parameter

2022-05-02 Thread Javier Martinez Canillas
On 5/2/22 18:07, Laurent Pinchart wrote: > Hi Javier, > > Thank you for the patch. > > On Mon, May 02, 2022 at 05:38:59PM +0200, Javier Martinez Canillas wrote: >> By default the bits per pixel for the emulated framebuffer device is set >> to dev->mode_config.pre

Re: [PATCH v2 3/3] drm: Allow simpledrm to setup its emulated FB as firmware provided

2022-05-02 Thread Javier Martinez Canillas
Hello Laurent, On 5/2/22 18:17, Laurent Pinchart wrote: > Hi Javier, > > Thank you for the patch. > > On Mon, May 02, 2022 at 05:39:00PM +0200, Javier Martinez Canillas wrote: >> Indicate to fbdev subsystem that the registered framebuffer is provided by >> the syst

Re: [PATCH v2 1/3] drm: Remove superfluous arg when calling to drm_fbdev_generic_setup()

2022-05-02 Thread Javier Martinez Canillas
On 5/2/22 18:55, Javier Martinez Canillas wrote: [snip] > >> drop the depth option to drm_fbdev_generic_setup() ? There's a FIXME >> comment in drm_fbdev_generic_setup() that could be related. >> > > A FIXME makes sense, I'll add that to when posting a v3.

Re: [PATCH v2 1/3] drm: Remove superfluous arg when calling to drm_fbdev_generic_setup()

2022-05-02 Thread Javier Martinez Canillas
On 5/2/22 20:36, Laurent Pinchart wrote: > On Mon, May 02, 2022 at 07:15:16PM +0200, Javier Martinez Canillas wrote: >> On 5/2/22 18:55, Javier Martinez Canillas wrote: >> >> [snip] >> >>>> drop the depth option to drm_fbdev_generic_setup() ? There's a F

Re: [PATCH v2 3/3] drm: Allow simpledrm to setup its emulated FB as firmware provided

2022-05-02 Thread Javier Martinez Canillas
odified. > Right. I'll also do the same for the preferred_bpp variable in patch 2/3 if I choose to keep them in v3. Thanks again for your feedback and comments! -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

[PATCH v3 0/3] drm: Allow simpledrm to setup its emulated FB as firmware provided

2022-05-03 Thread Javier Martinez Canillas
PTION() and make more clear in the kernel-doc what this macro does (Laurent Pinchart). - Fix some kernel-doc issues I didn't notice in v1. - Add Reviewed-by tags from Thomas and Laurent. Javier Martinez Canillas (3): drm: Remove superfluous arg when calling to drm_fbdev_generic_setup()

[PATCH v3 1/3] drm: Remove superfluous arg when calling to drm_fbdev_generic_setup()

2022-05-03 Thread Javier Martinez Canillas
: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Laurent Pinchart --- (no changes since v1) drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 2 +- drivers/gpu/drm/tiny/cirrus.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers

[PATCH v3 2/3] drm/fb-helper: Rename preferred_bpp drm_fbdev_generic_setup() parameter

2022-05-03 Thread Javier Martinez Canillas
ded. Suggested-by: Thomas Zimmermann Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Laurent Pinchart --- Changes in v3: - Drop the preferred_bpp local variable (Laurent Pinchart). - Add a const qualifier to options parameter (Laurent Pinchart). Changes in

[PATCH v3 3/3] drm: Allow simpledrm to setup its emulated FB as firmware provided

2022-05-03 Thread Javier Martinez Canillas
. Drivers can use this to indicate the FB helper initialization that the FB registered is provided by the firmware, so it can be configured as such. Suggested-by: Thomas Zimmermann Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Laurent Pinchart --- Changes

Re: [PATCH 1/4] drm/format-helper: Implement drm_fb_swab() with per-line helpers

2022-05-03 Thread Javier Martinez Canillas
forth. If is just that the naming haven't been used consistently, maybe this rework (or a follow-up) could be an opportunity to add consistency in that regard. -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH 2/4] drm/format-helper: Remove optional byte-swap from line convertion

2022-05-03 Thread Javier Martinez Canillas
I'm not asking to do it as a part of this series but something that we may do as a follow-up though, just mentioning. I'll post a patch to add that task to Documentation/gpu/todo.rst, so it is tracked somewhere. -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH 3/4] drm/format-helper: Unify the parameters of all per-line conversion helpers

2022-05-03 Thread Javier Martinez Canillas
On 4/27/22 16:14, Thomas Zimmermann wrote: > Give each per-line conversion helper pointers of type void and the > number of pixels in the line. Remove the unused swab parameters. > > Signed-off-by: Thomas Zimmermann > --- Reviewed-by: Javier Martinez Canillas -- Best r

Re: [PATCH 4/4] drm/format-helper: Share implementation among conversion helpers

2022-05-03 Thread Javier Martinez Canillas
the generic implementation. > > Signed-off-by: Thomas Zimmermann > --- Reviewed-by: Javier Martinez Canillas -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH v2] fbdev: Make fb_release() return -ENODEV if fbdev was unregistered

2022-05-03 Thread Javier Martinez Canillas
On 5/2/22 15:50, Javier Martinez Canillas wrote: > A reference to the framebuffer device struct fb_info is stored in the file > private data, but this reference could no longer be valid and must not be > accessed directly. Instead, the file_fb_info() accessor function must be > used s

[PATCH] fbdev: Use helper to get fb_info in all file operations

2022-05-03 Thread Javier Martinez Canillas
nxiao Chang Signed-off-by: Javier Martinez Canillas --- drivers/video/fbdev/core/fb_defio.c | 5 - drivers/video/fbdev/core/fbmem.c| 24 +++- include/linux/fb.h | 1 + 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/video/

[PATCH v2] fbdev: Use helper to get fb_info in all file operations

2022-05-03 Thread Javier Martinez Canillas
nxiao Chang Signed-off-by: Javier Martinez Canillas --- Changes in v2: - Fix copy & paste error passing file->private_data instead of file to fb_file_fb_info() function (Sam Ravnborg). drivers/video/fbdev/core/fb_defio.c | 5 - drivers/video/fbdev/core/fbm

Re: [PATCH] fbdev: Use helper to get fb_info in all file operations

2022-05-03 Thread Javier Martinez Canillas
fo *info = fb_file_fb_info(file->private_data); > This looks wrong. I assume you wanted to write: >> +struct fb_info *info = fb_file_fb_info(file); Right I did. Thanks for pointing out. -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

[PATCH] drm/todo: Add entry for using kunit in the subsystem

2022-05-04 Thread Javier Martinez Canillas
The Kernel Unit Testing (KUnit) framework provides a common framework for unit tests within the Linux kernel. Having a test suite would allow to identify regressions earlier. Signed-off-by: Javier Martinez Canillas --- Documentation/gpu/todo.rst | 14 ++ 1 file changed, 14

Re: [PATCH v2] fbdev: Use helper to get fb_info in all file operations

2022-05-04 Thread Javier Martinez Canillas
Hello Thomas, On 5/4/22 10:15, Thomas Zimmermann wrote: > Hi > > Am 03.05.22 um 22:19 schrieb Javier Martinez Canillas: >> A reference to the framebuffer device struct fb_info is stored in the file >> private data, but this reference could no longer be valid and must not be

Re: [PATCH] drm/todo: Add entry for using kunit in the subsystem

2022-05-04 Thread Javier Martinez Canillas
Hello Maxime, Thanks for your feedback. On 5/4/22 10:10, Maxime Ripard wrote: > Hi, > > On Wed, May 04, 2022 at 10:02:12AM +0200, Javier Martinez Canillas wrote: >> The Kernel Unit Testing (KUnit) framework provides a common framework for >> unit tests within the Linux

Re: [PATCH v2] fbdev: Use helper to get fb_info in all file operations

2022-05-04 Thread Javier Martinez Canillas
Hello Daniel, On 5/4/22 11:02, Daniel Vetter wrote: > On Tue, May 03, 2022 at 10:19:34PM +0200, Javier Martinez Canillas wrote: >> A reference to the framebuffer device struct fb_info is stored in the file >> private data, but this reference could no longer be valid and must not

Re: [PATCH 2/2] fbdev: Make fb_release() return -ENODEV if fbdev was unregistered

2022-05-04 Thread Javier Martinez Canillas
Hello Daniel, On 5/4/22 11:47, Daniel Vetter wrote: > On Mon, May 02, 2022 at 03:09:44PM +0200, Javier Martinez Canillas wrote: >> A reference to the framebuffer device struct fb_info is stored in the file >> private data, but this reference could no longer be valid and must not

[PATCH] Revert "fbdev: Make fb_release() return -ENODEV if fbdev was unregistered"

2022-05-04 Thread Javier Martinez Canillas
papering over the issue, and also would leak any resources that might be reference counted in fb_open. Instead, the fbdev drivers that are releasing the fb_info too soon should be fixed to prevent this situation to happen. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas

Re: [PATCH v3 3/3] drm: Allow simpledrm to setup its emulated FB as firmware provided

2022-05-04 Thread Javier Martinez Canillas
On 5/4/22 12:58, Daniel Vetter wrote: > On Tue, May 03, 2022 at 09:15:40AM +0200, Javier Martinez Canillas wrote: >> Indicate to fbdev subsystem that the registered framebuffer is provided by >> the system firmware, so that it can handle accordingly. For example, would >> unre

Re: [PATCH v2] fbdev: Use helper to get fb_info in all file operations

2022-05-04 Thread Javier Martinez Canillas
until > we fixed hot-unplugging for fbdev. Not doing anything is probably not > the right thing. > Actually, this issue shouldn't happen if the fbdev drivers are not buggy and do the proper cleanup at .fb_release() time rather than at .remove(). I'll post patches for simplefb

[PATCH v2] Revert "fbdev: Make fb_release() return -ENODEV if fbdev was unregistered"

2022-05-04 Thread Javier Martinez Canillas
ssion. But the proper solution is to fix the drivers to not release the fb_info too soon. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Vetter --- Changes in v2: - Add more info in the commit message about why it's crashing and how the reverted

Re: [PATCH 1/2] Revert "drm/amdgpu: disable runpm if we are the primary adapter"

2022-05-04 Thread Javier Martinez Canillas
ays attached (v3)"). > I would write this line instead as: in commit f95af4a9236695 ("drm/amdgpu: don't runtime suspend if there are displays attached (v3)"). > Signed-off-by: Alex Deucher > --- The patch looks good to me. Reviewed-by: Javier Martinez Canill

Re: [PATCH 2/2] Revert "fbdev: fbmem: add a helper to determine if an aperture is used by a fw fb"

2022-05-04 Thread Javier Martinez Canillas
und is no longer necessary. Since amdgpu was the only > user of this interface, we can remove it. > > Signed-off-by: Alex Deucher > --- Reviewed-by: Javier Martinez Canillas -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH 1/2] Revert "drm/amdgpu: disable runpm if we are the primary adapter"

2022-05-04 Thread Javier Martinez Canillas
On 5/4/22 18:50, Alex Deucher wrote: > On Wed, May 4, 2022 at 12:46 PM Javier Martinez Canillas > wrote: >> >> Hello Alex, >> >> On 5/4/22 15:48, Alex Deucher wrote: >>> This reverts commit b95dc06af3e683d6b7ddbbae178b2b2a21ee8b2b. >>> >>>

[PATCH 0/3] fbdev: Fix use-after-free caused by wrong fb_info cleanup in drivers

2022-05-04 Thread Javier Martinez Canillas
Vetter (1): fbdev: Prevent possible use-after-free in fb_release() Javier Martinez Canillas (2): fbdev/simplefb: Cleanup fb_info in .fb_destroy rather than .remove fbdev/efifb: Cleanup fb_info in .fb_destroy rather than .remove drivers/video/fbdev/core/fbsysfs.c | 4 drivers/video/fbd

[PATCH 1/3] fbdev: Prevent possible use-after-free in fb_release()

2022-05-04 Thread Javier Martinez Canillas
exist, leading to a use-after-free error. To prevent this, check the fb_info reference counter when attempting to kfree the data structure in framebuffer_release(). That will leak it but at least will prevent the mentioned error. Signed-off-by: Daniel Vetter Signed-off-by: Javier Martinez Can

[PATCH 2/3] fbdev/simplefb: Cleanup fb_info in .fb_destroy rather than .remove

2022-05-04 Thread Javier Martinez Canillas
unregistered but later a user-space process tries to close the fbdev fd. The correct thing to do is to only unregister the framebuffer in the driver's .remove callback, but do any cleanup in the fb_ops.fb_destroy. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas --- drivers/

[PATCH 3/3] fbdev/efifb: Cleanup fb_info in .fb_destroy rather than .remove

2022-05-04 Thread Javier Martinez Canillas
unregistered but later a user-space process tries to close the fbdev fd. The correct thing to do is to only unregister the framebuffer in the driver's .remove callback, but do any cleanup in the fb_ops.fb_destroy. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas --- drivers/

Re: [PATCH 2/3] fbdev/simplefb: Cleanup fb_info in .fb_destroy rather than .remove

2022-05-05 Thread Javier Martinez Canillas
ndler and that decrement the fb_info refcount, so if reaches zero it will call to the fb fops .destroy() handler and release the I/O memory. In other words, in most cases (i.e: only fbcon bound to the fbdev) the driver's removal/ device unbind and the memory release will be at the same time. -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH 2/3] fbdev/simplefb: Cleanup fb_info in .fb_destroy rather than .remove

2022-05-05 Thread Javier Martinez Canillas
hat we shouldn't try to fix all possible corner cases and just try to get rid of fbdev as soon as possible. -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH 0/3] fbdev: Fix use-after-free caused by wrong fb_info cleanup in drivers

2022-05-05 Thread Javier Martinez Canillas
e the resources at the correct place. > > From a quick look, vesafb seems to be affected as well. > Right, I wrongly assumed that we only cared about efifb and simplefb but forgot that vesafb is used when setting a VESA mode with vga=foo. I'll add it in a v2. > Best regards > Thom

Re: [PATCH] drm/todo: Add entry for using kunit in the subsystem

2022-05-05 Thread Javier Martinez Canillas
On 5/4/22 10:02, Javier Martinez Canillas wrote: > The Kernel Unit Testing (KUnit) framework provides a common framework for > unit tests within the Linux kernel. Having a test suite would allow to > identify regressions earlier. > > Signed-off-by: Javier Martinez Canillas >

[PATCH v2 0/4] fbdev: Fix use-after-free caused by wrong fb_info cleanup in drivers

2022-05-05 Thread Javier Martinez Canillas
nges in v2: - Also do the change for vesafb (Thomas Zimmermann). Daniel Vetter (1): fbdev: Prevent possible use-after-free in fb_release() Javier Martinez Canillas (3): fbdev: simplefb: Cleanup fb_info in .fb_destroy rather than .remove fbdev: efifb: Cleanup fb_info in .fb_destroy rather th

[PATCH v2 1/4] fbdev: Prevent possible use-after-free in fb_release()

2022-05-05 Thread Javier Martinez Canillas
exist, leading to a use-after-free error. To prevent this, check the fb_info reference counter when attempting to kfree the data structure in framebuffer_release(). That will leak it but at least will prevent the mentioned error. Signed-off-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Rev

[PATCH v2 2/4] fbdev: simplefb: Cleanup fb_info in .fb_destroy rather than .remove

2022-05-05 Thread Javier Martinez Canillas
unregistered but later a user-space process tries to close the fbdev fd. The correct thing to do is to only unregister the framebuffer in the driver's .remove callback, but do any cleanup in the fb_ops.fb_destroy. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: T

[PATCH v2 3/4] fbdev: efifb: Cleanup fb_info in .fb_destroy rather than .remove

2022-05-05 Thread Javier Martinez Canillas
unregistered but later a user-space process tries to close the fbdev fd. The correct thing to do is to only unregister the framebuffer in the driver's .remove callback, but do any cleanup in the fb_ops.fb_destroy. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: T

[PATCH v2 4/4] fbdev: vesafb: Cleanup fb_info in .fb_destroy rather than .remove

2022-05-05 Thread Javier Martinez Canillas
unregistered but later a user-space process tries to close the fbdev fd. The correct thing to do is to only unregister the framebuffer in the driver's .remove callback, but do any cleanup in the fb_ops.fb_destroy. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas --- Changes

[PATCH] fbdev: vesafb: Allow to be built if COMPILE_TEST is enabled

2022-05-05 Thread Javier Martinez Canillas
: Javier Martinez Canillas --- drivers/video/fbdev/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index f2a6b81e45c4..bd849013f16f 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -616,7

Re: [PATCH v3 3/3] drm: Allow simpledrm to setup its emulated FB as firmware provided

2022-05-05 Thread Javier Martinez Canillas
that point we shouldn't need > special flags anymore. I'm OK with this take and happy to just drop this patch-set then. My worry was just that someone could complain that we broke their uncommon setup [0]. [0]: https://xkcd.com/1172/. -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH 2/3] fbdev/simplefb: Cleanup fb_info in .fb_destroy rather than .remove

2022-05-05 Thread Javier Martinez Canillas
Hello Daniel, On 5/5/22 14:52, Daniel Vetter wrote: > On Wed, May 04, 2022 at 11:57:22PM +0200, Javier Martinez Canillas wrote: >> The driver is calling framebuffer_release() in its .remove callback, but >> this will cause the struct fb_info to be freed too early. Since it cou

Re: [PATCH v2 4/4] fbdev: vesafb: Cleanup fb_info in .fb_destroy rather than .remove

2022-05-05 Thread Javier Martinez Canillas
s them. But I will only move the framebuffer_release() that is the problematic bit. Someone if care enough could fix the rest of the driver. > Also same comments as on v1 about adding more details about what/how this > fixes, with that: Reviewed-by: Daniel Vetter > Yes, I'll do that too. Thanks again for your comments and feedback. -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

[PATCH] MAINTAINERS: Add simpledrm driver co-maintainer

2022-05-05 Thread Javier Martinez Canillas
Thomas asked me to serve as co-maintainer for the simpledrm driver. Signed-off-by: Javier Martinez Canillas --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 1a04950c1a8f..bfe43560f9d5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6389,6

[PATCH v3 0/4] fbdev: Fix use-after-free caused by wrong fb_info cleanup in drivers

2022-05-05 Thread Javier Martinez Canillas
vesafb (Thomas Zimmermann). Daniel Vetter (1): fbdev: Prevent possible use-after-free in fb_release() Javier Martinez Canillas (3): fbdev: simplefb: Cleanup fb_info in .fb_destroy rather than .remove fbdev: efifb: Cleanup fb_info in .fb_destroy rather than .remove fbdev: vesafb: Cle

[PATCH v3 1/4] fbdev: Prevent possible use-after-free in fb_release()

2022-05-05 Thread Javier Martinez Canillas
exist, leading to a use-after-free error. To prevent this, check the fb_info reference counter when attempting to kfree the data structure in framebuffer_release(). That will leak it but at least will prevent the mentioned error. Signed-off-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Rev

[PATCH v3 2/4] fbdev: simplefb: Cleanup fb_info in .fb_destroy rather than .remove

2022-05-05 Thread Javier Martinez Canillas
aacbaef ("fbdev: Hot-unplug firmware fb devices on forced removal") Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Daniel Vetter --- (no changes since v1) drivers/video/fbdev/simplefb.c | 8 +++- 1 file changed, 7

[PATCH v3 3/4] fbdev: efifb: Cleanup fb_info in .fb_destroy rather than .remove

2022-05-05 Thread Javier Martinez Canillas
aacbaef ("fbdev: Hot-unplug firmware fb devices on forced removal") Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Daniel Vetter --- (no changes since v1) drivers/video/fbdev/efifb.c | 9 - 1 file changed, 8

[PATCH v3 4/4] fbdev: vesafb: Cleanup fb_info in .fb_destroy rather than .remove

2022-05-05 Thread Javier Martinez Canillas
aacbaef ("fbdev: Hot-unplug firmware fb devices on forced removal") Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Daniel Vetter --- Changes in v3: - Only move framebuffer_release() and don't do any other change (

[PATCH v4] drm/msm: Make .remove and .shutdown HW shutdown consistent

2022-08-16 Thread Javier Martinez Canillas
5fe46e ("drm/msm: add shutdown support for display platform_driver") Signed-off-by: Javier Martinez Canillas Reviewed-by: Abhinav Kumar --- Changes in v4: - Remove the kernel log timestamps and just keep the stacktrace (Abhinav Kumar). - Add Abhinav Kumar Reviewed-by tag. Changes in v3:

Re: [PATCH v2] Revert "fbdev: Make fb_release() return -ENODEV if fbdev was unregistered"

2022-05-06 Thread Javier Martinez Canillas
On 5/4/22 13:59, Javier Martinez Canillas wrote: > This reverts commit aafa025c76dcc7d1a8c8f0bdefcbe4eb480b2f6a. That commit > attempted to fix a NULL pointer dereference, caused by the struct fb_info > associated with a framebuffer device to not longer be valid when the file > de

Re: [PATCH v3 0/4] fbdev: Fix use-after-free caused by wrong fb_info cleanup in drivers

2022-05-06 Thread Javier Martinez Canillas
On 5/5/22 23:59, Javier Martinez Canillas wrote: > Hello, > > This series contains patches suggested by Daniel Vetter to fix a > use-after-free > error in the fb_release() function, due a fb_info associated with a fbdev > being > freed too early while a user-space proces

Re: [PATCH v3 3/4] fbdev: efifb: Cleanup fb_info in .fb_destroy rather than .remove

2022-05-06 Thread Javier Martinez Canillas
Hello Andrzej, On 5/6/22 15:07, Andrzej Hajda wrote: > On 06.05.2022 00:05, Javier Martinez Canillas wrote: [snip] >> + >> +framebuffer_release(info); >> + >> if (request_mem_succeeded) >> release_mem_regio

[PATCH] fbdev: efifb: Fix a use-after-free due early fb_info cleanup

2022-05-06 Thread Javier Martinez Canillas
since the fb_info was still used after the free. This should fix for good by freeing the fb_info at the end of the handler. Fixes: d258d00fb9c7 ("fbdev: efifb: Cleanup fb_info in .fb_destroy rather than .remove") Reported-by: Ville Syrjälä Reported-by: Andrzej Hajda Signed-off-by: Javi

Re: [PATCH] fbdev: efifb: Fix a use-after-free due early fb_info cleanup

2022-05-07 Thread Javier Martinez Canillas
Hello Lucas, On 5/7/22 18:20, Lucas De Marchi wrote: > On Fri, May 06, 2022 at 03:22:25PM +0200, Javier Martinez Canillas wrote: >> Commit d258d00fb9c7 ("fbdev: efifb: Cleanup fb_info in .fb_destroy rather >> than .remove") attempted to fix a use-after-free error due driv

Re: [PATCH] drm/vmwgfx: Fix passing partly uninitialized drm_mode_fb_cmd2 struct

2022-05-09 Thread Javier Martinez Canillas
k: https://bugzilla.redhat.com/show_bug.cgi?id=2072556 > Signed-off-by: Hans de Goede > --- Zack fixed this already: https://cgit.freedesktop.org/drm/drm-misc/commit/?id=5405d25b9e8e6 -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH] drm/vmwgfx: Fix passing partly uninitialized drm_mode_fb_cmd2 struct

2022-05-09 Thread Javier Martinez Canillas
fixed this already: >> >> https://cgit.freedesktop.org/drm/drm-misc/commit/?id=5405d25b9e8e6 > > I see, but it seems that this was never pushed to drm-misc-fixes, > so this is still broken in 5.18-rc# > Indeed. Agreed that should be cherry-picked in -fixes as well. -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

[PATCH] drm/todo: Add entry for converting kselftests to kunit

2022-05-09 Thread Javier Martinez Canillas
Many of the kselftests in DRM can be converted to kunit tests instead, since that framework is more suitable for unit testing. Suggested-by: Maxime Ripard Signed-off-by: Javier Martinez Canillas --- Documentation/gpu/todo.rst | 11 +++ 1 file changed, 11 insertions(+) diff --git a

Re: [PATCH v2] Revert "fbdev: Make fb_release() return -ENODEV if fbdev was unregistered"

2022-05-09 Thread Javier Martinez Canillas
v hot-unplug regression will get merged in mainline soon and since all have a Fixes tag, they should get picked for stable as well. -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH v3 1/4] fbdev: Prevent possible use-after-free in fb_release()

2022-05-09 Thread Javier Martinez Canillas
Hello Andrzej, On 5/9/22 16:56, Andrzej Hajda wrote: > On 06.05.2022 00:04, Javier Martinez Canillas wrote: >> From: Daniel Vetter >> >> Most fbdev drivers have issues with the fb_info lifetime, because call to >> framebuffer_release() from their driver's .remov

Re: [PATCH v3 1/4] fbdev: Prevent possible use-after-free in fb_release()

2022-05-09 Thread Javier Martinez Canillas
fb expert so happy to move fb_dealloc_cmap() as well if that is the correct thing to do. [0]: https://www.spinics.net/lists/dri-devel/msg346257.html [1]: https://www.spinics.net/lists/dri-devel/msg346261.html -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH v3 1/4] fbdev: Prevent possible use-after-free in fb_release()

2022-05-09 Thread Javier Martinez Canillas
Hello Thomas, On 5/9/22 20:32, Thomas Zimmermann wrote: > Hi > > Am 09.05.22 um 18:33 schrieb Javier Martinez Canillas: >> On 5/9/22 17:51, Andrzej Hajda wrote: >> >> [snip] >> >>>>>> + >>>>> Regarding drm: >>>

Re: [PATCH v3 1/4] fbdev: Prevent possible use-after-free in fb_release()

2022-05-09 Thread Javier Martinez Canillas
nfo) { + if (info->cmap.len) + fb_dealloc_cmap(&info->cmap); + drm_fbdev_release(info->par); + framebuffer_release(info); } static int drm_fbdev_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH v3 1/4] fbdev: Prevent possible use-after-free in fb_release()

2022-05-09 Thread Javier Martinez Canillas
_destroy() anyways. We should probably remove that call in all drivers and make this helper function static and just private to drm_fb_helper functions. Or am I missing something here ? [0]: >From 5170cafcf2936da8f1c53231e3baa7d7a2b16c61 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canilla

Re: [PATCH v3 1/4] fbdev: Prevent possible use-after-free in fb_release()

2022-05-10 Thread Javier Martinez Canillas
On 5/10/22 09:19, Andrzej Hajda wrote: > > > On 10.05.2022 00:42, Javier Martinez Canillas wrote: >> On 5/10/22 00:22, Andrzej Hajda wrote: >> >> [snip] >> >>>>static void drm_fbdev_fb_destroy(struct fb_info *in

Re: [PATCH v3 1/4] fbdev: Prevent possible use-after-free in fb_release()

2022-05-10 Thread Javier Martinez Canillas
Hello Thomas, On 5/10/22 10:04, Thomas Zimmermann wrote: > Hi > > Am 10.05.22 um 00:42 schrieb Javier Martinez Canillas: >> On 5/10/22 00:22, Andrzej Hajda wrote: >> >> [snip] >> >>>>static void drm_fbdev_fb_destroy(struct fb_info *in

Re: [PATCH v3 1/4] fbdev: Prevent possible use-after-free in fb_release()

2022-05-10 Thread Javier Martinez Canillas
it. 3) Set .fb_destroy to drm_fbdev_fb_destroy() if isn't set by drivers when they call drm_fb_helper_initial_config() or drm_fb_helper_fill_info(). I'm leaning towards option (3). Then the fb_info release will be automatic whether drivers are using the generic setup or a custom one.

Re: [PATCH v3 1/4] fbdev: Prevent possible use-after-free in fb_release()

2022-05-10 Thread Javier Martinez Canillas
ttern. > Right. We can't really abstract this away from drivers that are not using the generic fbdev helpers. So then they will have to provide their own .fb_destroy() callback and do the cleanup. -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH] MAINTAINERS: Add simpledrm driver co-maintainer

2022-05-11 Thread Javier Martinez Canillas
On 5/5/22 19:26, Javier Martinez Canillas wrote: > Thomas asked me to serve as co-maintainer for the simpledrm driver. > > Signed-off-by: Javier Martinez Canillas > --- Pushed this to drm-misc (drm-misc-next). -- Best regards, Javier Martinez Canillas Linux Engineering Red Hat

Re: [PATCH] drm/todo: Add entry for converting kselftests to kunit

2022-05-11 Thread Javier Martinez Canillas
On 5/9/22 15:08, Javier Martinez Canillas wrote: > Many of the kselftests in DRM can be converted to kunit tests instead, > since that framework is more suitable for unit testing. > > Suggested-by: Maxime Ripard > Signed-off-by: Javier Martinez Canillas > --- Pushed this to

[PATCH v5 0/7] Fix some races between sysfb device registration and drivers probe

2022-05-11 Thread Javier Martinez Canillas
- Add Daniel Reviewed-by tags to the patches. Daniel Vetter (2): Revert "fbdev: Prevent probing generic drivers if a FB is already registered" fbdev: Make registered_fb[] private to fbmem.c Javier Martinez Canillas (5): firmware: sysfb: Make sysfb_create_simplefb() return a pdev

[PATCH v5 1/7] firmware: sysfb: Make sysfb_create_simplefb() return a pdev pointer

2022-05-11 Thread Javier Martinez Canillas
This function just returned 0 on success or an errno code on error, but it could be useful for sysfb_init() callers to have a pointer to the device. Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Vetter Reviewed-by: Thomas Zimmermann --- (no changes since v3) Changes in v3

[PATCH v5 2/7] firmware: sysfb: Add helpers to unregister a pdev and disable registration

2022-05-11 Thread Javier Martinez Canillas
These can be used by subsystems to unregister a platform device registered by sysfb and also to disable future platform device registration in sysfb. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Vetter --- (no changes since v4) Changes in v4: - Make

[PATCH v5 3/7] fbdev: Restart conflicting fb removal loop when unregistering devices

2022-05-11 Thread Javier Martinez Canillas
restart. Since the framebuffer devices will already be removed, the loop would just finish when no more conflicting framebuffers are found. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Vetter --- (no changes since v1) drivers/video/fbdev/core/fbmem.c

[PATCH v5 4/7] fbdev: Make sysfb to unregister its own registered devices

2022-05-11 Thread Javier Martinez Canillas
r the simple framebuffer devices, so an unregistration has to be forced by fbmem if sysfb_try_unregister() does not succeed at unregister the device. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Vetter --- (no changes since v4) Changes in v4: - Drop ca

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