sfrench/cifs-2.6.git
2 years agodt-bindings: display: simple: add some Logic Technologies and Multi-Inno panels
Oleksij Rempel [Wed, 14 Jul 2021 04:53:46 +0000 (06:53 +0200)]
dt-bindings: display: simple: add some Logic Technologies and Multi-Inno panels

Add Logictechno and Multi-Inno panels:
- Logic Technologies LTTD800x480 L2RT 7" 800x480 TFT Resistive Touch Module
- Logic Technologies LTTD800480070-L6WH-RT 7” 800x480 TFT Resistive Touch Module
- Multi-Inno Technology Co.,Ltd MI1010AIT-1CP 10.1" 1280x800 LVDS IPS Cap Touch Mod.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210714045349.10963-2-o.rempel@pengutronix.de
2 years agodrm/shmobile: Convert to Linux IRQ interfaces
Thomas Zimmermann [Tue, 20 Jul 2021 08:09:41 +0000 (10:09 +0200)]
drm/shmobile: Convert to Linux IRQ interfaces

Drop the DRM IRQ midlayer in favor of Linux IRQ interfaces. DRM's
IRQ helpers are mostly useful for UMS drivers. Modern KMS drivers
don't benefit from using it.

v3:
* return error if (ret < 0) (Geert)
* remove duplicate error message (Geert)
v2:
* handle errors in platform_get_irq() (Geert, Sergei)
* store IRQ number in struct shmob_drm_device (Laurent)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210720080941.23646-1-tzimmermann@suse.de
2 years agodrm/st7586: Use framebuffer dma-buf helpers
Thomas Zimmermann [Fri, 16 Jul 2021 14:08:01 +0000 (16:08 +0200)]
drm/st7586: Use framebuffer dma-buf helpers

Replace dma_buf_begin_cpu_access() with drm_gem_fb_begin_cpu_access();
same for _end_cpu_access(). Remove some boiler-plate code. No functional
changes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: David Lechner <david@lechnology.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716140801.1215-8-tzimmermann@suse.de
2 years agodrm/repaper: Use framebuffer dma-buf helpers
Thomas Zimmermann [Fri, 16 Jul 2021 14:08:00 +0000 (16:08 +0200)]
drm/repaper: Use framebuffer dma-buf helpers

Replace dma_buf_begin_cpu_access() with drm_gem_fb_begin_cpu_access();
same for _end_cpu_access(). Remove some boiler-plate code. No functional
changes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716140801.1215-7-tzimmermann@suse.de
2 years agodrm/gm12u320: Use framebuffer dma-buf helpers
Thomas Zimmermann [Fri, 16 Jul 2021 14:07:59 +0000 (16:07 +0200)]
drm/gm12u320: Use framebuffer dma-buf helpers

Replace dma_buf_begin_cpu_access() with drm_gem_fb_begin_cpu_access();
same for _end_cpu_access(). Remove some boiler-plate code. No functional
changes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716140801.1215-6-tzimmermann@suse.de
2 years agodrm/gud: Use framebuffer dma-buf helpers
Thomas Zimmermann [Fri, 16 Jul 2021 14:07:58 +0000 (16:07 +0200)]
drm/gud: Use framebuffer dma-buf helpers

Replace dma_buf_begin_cpu_access() with drm_gem_fb_begin_cpu_access();
same for _end_cpu_access(). Remove some boiler-plate code. No functional
changes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716140801.1215-5-tzimmermann@suse.de
2 years agodrm/mipi-dbi: Use framebuffer dma-buf helpers
Thomas Zimmermann [Fri, 16 Jul 2021 14:07:57 +0000 (16:07 +0200)]
drm/mipi-dbi: Use framebuffer dma-buf helpers

Replace dma_buf_begin_cpu_access() with drm_gem_fb_begin_cpu_access();
same for _end_cpu_access(). Remove some boiler-plate code. No functional
changes.

There's one left-over reference to the imported attachment that we
keep. GEM BOs with imported attachment are considered uncached and
enables special handling within the drm_fb_swab().

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716140801.1215-4-tzimmermann@suse.de
2 years agodrm/udl: Use framebuffer dma-buf helpers
Thomas Zimmermann [Fri, 16 Jul 2021 14:07:56 +0000 (16:07 +0200)]
drm/udl: Use framebuffer dma-buf helpers

Replace dma_buf_begin_cpu_access() with drm_gem_fb_begin_cpu_access();
same for _end_cpu_access(). Remove some boiler-plate code. No functional
changes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716140801.1215-3-tzimmermann@suse.de
2 years agodrm/gem: Provide drm_gem_fb_{begin,end}_cpu_access() helpers
Thomas Zimmermann [Fri, 16 Jul 2021 14:07:55 +0000 (16:07 +0200)]
drm/gem: Provide drm_gem_fb_{begin,end}_cpu_access() helpers

Implement helpers drm_gem_fb_begin_cpu_access() and _end_cpu_access(),
which call the rsp dma-buf functions for all GEM BOs of the given
framebuffer.

Calls to dma_buf_end_cpu_access() can return an error code on failure,
while drm_gem_fb_end_cpu_access() does not. The latter runs during DRM's
atomic commit or during cleanup. Both cases don't allow for errors, so
leave out the return value.

v2:
* fix typo in docs (Daniel)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716140801.1215-2-tzimmermann@suse.de
2 years agodrm/hisilicon/hibmc: Remove variable 'priv' from hibmc_unload()
Thomas Zimmermann [Wed, 21 Jul 2021 13:17:04 +0000 (15:17 +0200)]
drm/hisilicon/hibmc: Remove variable 'priv' from hibmc_unload()

The variable 'priv' got introduced in commit 39a364a19e03
("drm/hisilicon/hibmc: Convert to Linux IRQ interfaces") by accident.
It's unused; remove it. Fixes a compiler warning.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: 39a364a19e03 ("drm/hisilicon/hibmc: Convert to Linux IRQ interfaces")
Reviewed-by: Tian Tao <tiantao6@hisilicon.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reported-by: Dave Airlie <airlied@gmail.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Tian Tao <tiantao6@hisilicon.com>
Cc: Maxime Ripard <maxime@cerno.tech>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210721131704.10306-1-tzimmermann@suse.de
2 years agodrm/fourcc: Add modifier definitions for Arm Fixed Rate Compression
Normunds Rieksts [Thu, 1 Jul 2021 17:07:09 +0000 (18:07 +0100)]
drm/fourcc: Add modifier definitions for Arm Fixed Rate Compression

Arm Fixed Rate Compression (AFRC) is a proprietary fixed rate image
compression protocol and format.
It is designed to provide guaranteed bandwidth and memory footprint
reductions in graphics and media use-cases.

This patch aims to add modifier definitions for describing
AFRC.

Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210701170709.39922-1-normunds.rieksts@arm.com
2 years agoDocumentation: gpu: Mention the requirements for new properties
Maxime Ripard [Tue, 20 Jul 2021 14:35:44 +0000 (16:35 +0200)]
Documentation: gpu: Mention the requirements for new properties

New KMS properties come with a bunch of requirements to avoid each
driver from running their own, inconsistent, set of properties,
eventually leading to issues like property conflicts, inconsistencies
between drivers and semantics, etc.

Let's document what we expect.

Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210720143544.571760-1-maxime@cerno.tech
2 years agodrm/panfrost: devfreq: Don't display error for EPROBE_DEFER
Chris Morgan [Wed, 21 Jul 2021 21:48:30 +0000 (16:48 -0500)]
drm/panfrost: devfreq: Don't display error for EPROBE_DEFER

Set a condition for the message of "Couldn't set OPP regulators" to not
display if the error code is EPROBE_DEFER. Note that I used an if
statement to capture the condition instead of the dev_err_probe
function because I didn't want to change the DRM_DEV_ERROR usage.

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210721214830.25690-1-macroalpha82@gmail.com
2 years agodt-bindings: display: simple-bridge: Add corpro,gm7123 compatible
Maxime Ripard [Wed, 21 Jul 2021 14:03:41 +0000 (16:03 +0200)]
dt-bindings: display: simple-bridge: Add corpro,gm7123 compatible

The corpro,gm7123 was in use in a DT but was never properly documented,
let's add it.

Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210721140424.725744-12-maxime@cerno.tech
2 years agovideo: fbdev: neofb: add a check against divide error
Zheyu Ma [Wed, 21 Jul 2021 12:43:44 +0000 (12:43 +0000)]
video: fbdev: neofb: add a check against divide error

The userspace program could pass any values to the driver through
ioctl() interface. If the driver doesn't check the value of 'pixclock',
it may cause divide error because of the 'PICOS2KHZ' macro.

Fix this by checking whether 'pixclock' is zero first.

The following log reveals it:

[   53.093806] divide error: 0000 [#1] PREEMPT SMP KASAN PTI
[   53.093838] CPU: 3 PID: 11763 Comm: hang Not tainted 5.14.0-rc2-00478-g2734d6c1b1a0 #215
[   53.093859] RIP: 0010:neofb_check_var+0x80/0xe50
[   53.093951] Call Trace:
[   53.093956]  ? neofb_setcolreg+0x2b0/0x2b0
[   53.093968]  fb_set_var+0x2e4/0xeb0
[   53.093977]  ? fb_blank+0x1a0/0x1a0
[   53.093984]  ? lock_acquire+0x1ef/0x530
[   53.093996]  ? lock_release+0x810/0x810
[   53.094005]  ? lock_is_held_type+0x100/0x140
[   53.094016]  ? ___might_sleep+0x1ee/0x2d0
[   53.094028]  ? __mutex_lock+0x620/0x1190
[   53.094036]  ? do_fb_ioctl+0x313/0x700
[   53.094044]  ? mutex_lock_io_nested+0xfa0/0xfa0
[   53.094051]  ? __this_cpu_preempt_check+0x1d/0x30
[   53.094060]  ? _raw_spin_unlock_irqrestore+0x46/0x60
[   53.094069]  ? lockdep_hardirqs_on+0x59/0x100
[   53.094076]  ? _raw_spin_unlock_irqrestore+0x46/0x60
[   53.094085]  ? trace_hardirqs_on+0x6a/0x1c0
[   53.094096]  do_fb_ioctl+0x31e/0x700

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1626871424-27708-1-git-send-email-zheyuma97@gmail.com
2 years agovideo: fbdev: arcfb: remove redundant initialization of variable err
Colin Ian King [Wed, 21 Jul 2021 10:26:08 +0000 (11:26 +0100)]
video: fbdev: arcfb: remove redundant initialization of variable err

The variable err is being initialized with a value that is never
read, the assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210721102608.42694-1-colin.king@canonical.com
2 years agodrivers/firmware: consolidate EFI framebuffer setup for all arches
Javier Martinez Canillas [Fri, 25 Jun 2021 13:13:59 +0000 (15:13 +0200)]
drivers/firmware: consolidate EFI framebuffer setup for all arches

The register_gop_device() function registers an "efi-framebuffer" platform
device to match against the efifb driver, to have an early framebuffer for
EFI platforms.

But there is already support to do exactly the same by the Generic System
Framebuffers (sysfb) driver. This used to be only for X86 but it has been
moved to drivers/firmware and could be reused by other architectures.

Also, besides supporting registering an "efi-framebuffer", this driver can
register a "simple-framebuffer" allowing to use the siple{fb,drm} drivers
on non-X86 EFI platforms. For example, on aarch64 these drivers can only
be used with DT and doesn't have code to register a "simple-frambuffer"
platform device when booting with EFI.

For these reasons, let's remove the register_gop_device() duplicated code
and instead move the platform specific logic that's there to sysfb driver.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Acked-by: Borislav Petkov <bp@suse.de>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210625131359.1804394-1-javierm@redhat.com
2 years agodrivers/firmware: move x86 Generic System Framebuffers support
Javier Martinez Canillas [Fri, 25 Jun 2021 13:09:46 +0000 (15:09 +0200)]
drivers/firmware: move x86 Generic System Framebuffers support

The x86 architecture has generic support to register a system framebuffer
platform device. It either registers a "simple-framebuffer" if the config
option CONFIG_X86_SYSFB is enabled, or a legacy VGA/VBE/EFI FB device.

But the code is generic enough to be reused by other architectures and can
be moved out of the arch/x86 directory.

This will allow to also support the simple{fb,drm} drivers on non-x86 EFI
platforms, such as aarch64 where these drivers are only supported with DT.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Acked-by: Borislav Petkov <bp@suse.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210625130947.1803678-2-javierm@redhat.com
2 years agovgaarb: don't pass a cookie to vga_client_register
Christoph Hellwig [Fri, 16 Jul 2021 06:16:34 +0000 (08:16 +0200)]
vgaarb: don't pass a cookie to vga_client_register

The VGA arbitration is entirely based on pci_dev structures, so just pass
that back to the set_vga_decode callback.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716061634.2446357-8-hch@lst.de
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
2 years agovgaarb: remove the unused irq_set_state argument to vga_client_register
Christoph Hellwig [Fri, 16 Jul 2021 06:16:33 +0000 (08:16 +0200)]
vgaarb: remove the unused irq_set_state argument to vga_client_register

All callers pass NULL as the irq_set_state argument, so remove it and
the ->irq_set_state member in struct vga_device.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716061634.2446357-7-hch@lst.de
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
2 years agovgaarb: provide a vga_client_unregister wrapper
Christoph Hellwig [Fri, 16 Jul 2021 06:16:32 +0000 (08:16 +0200)]
vgaarb: provide a vga_client_unregister wrapper

Add a trivial wrapper for the unregister case that sets all fields to
NULL.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716061634.2446357-6-hch@lst.de
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
2 years agovgaarb: cleanup vgaarb.h
Christoph Hellwig [Fri, 16 Jul 2021 06:16:31 +0000 (08:16 +0200)]
vgaarb: cleanup vgaarb.h

Merge the different CONFIG_VGA_ARB ifdef blocks, remove superflous
externs, and regularize the stubs for !CONFIG_VGA_ARB.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716061634.2446357-5-hch@lst.de
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
2 years agovgaarb: move the kerneldoc for vga_set_legacy_decoding to vgaarb.c
Christoph Hellwig [Fri, 16 Jul 2021 06:16:30 +0000 (08:16 +0200)]
vgaarb: move the kerneldoc for vga_set_legacy_decoding to vgaarb.c

Kerneldoc comments should be at the implementation side, not in the
header just declaring the prototype.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716061634.2446357-4-hch@lst.de
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
2 years agovgaarb: remove vga_conflicts
Christoph Hellwig [Fri, 16 Jul 2021 06:16:29 +0000 (08:16 +0200)]
vgaarb: remove vga_conflicts

vga_conflicts only has a single caller and none of the arch overrides
mentioned in the comment.  Just remove it and the thus dead check in the
caller.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716061634.2446357-3-hch@lst.de
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
2 years agovgaarb: remove VGA_DEFAULT_DEVICE
Christoph Hellwig [Fri, 16 Jul 2021 06:16:28 +0000 (08:16 +0200)]
vgaarb: remove VGA_DEFAULT_DEVICE

The define is entirely unused.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716061634.2446357-2-hch@lst.de
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
2 years agodrm/v3d: Expose performance counters to userspace
Juan A. Suarez Romero [Tue, 8 Jun 2021 11:15:41 +0000 (13:15 +0200)]
drm/v3d: Expose performance counters to userspace

The V3D engine has several hardware performance counters that can of
interest for userspace performance analysis tools.

This exposes new ioctls to create and destroy performance monitor
objects, as well as to query the counter values.

Each created performance monitor object has an ID that can be attached
to CL/CSD submissions, so the driver enables the requested counters when
the job is submitted, and updates the performance monitor values when
the job is done.

It is up to the user to ensure all the jobs have been finished before
getting the performance monitor values. It is also up to the user to
properly synchronize BCL jobs when submitting jobs with different
performance monitors attached.

Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Cc: Emma Anholt <emma@anholt.net>
To: dri-devel@lists.freedesktop.org
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Acked-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Melissa Wen <melissa.srw@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210608111541.461991-1-jasuarez@igalia.com
2 years agodrm: protect drm_master pointers in drm_lease.c
Desmond Cheong Zhi Xi [Mon, 12 Jul 2021 04:35:08 +0000 (12:35 +0800)]
drm: protect drm_master pointers in drm_lease.c

drm_file->master pointers should be protected by
drm_device.master_mutex or drm_file.master_lookup_lock when being
dereferenced.

However, in drm_lease.c, there are multiple instances where
drm_file->master is accessed and dereferenced while neither lock is
held. This makes drm_lease.c vulnerable to use-after-free bugs.

We address this issue in 2 ways:

1. Add a new drm_file_get_master() function that calls drm_master_get
on drm_file->master while holding on to
drm_file.master_lookup_lock. Since drm_master_get increments the
reference count of master, this prevents master from being freed until
we unreference it with drm_master_put.

2. In each case where drm_file->master is directly accessed and
eventually dereferenced in drm_lease.c, we wrap the access in a call
to the new drm_file_get_master function, then unreference the master
pointer once we are done using it.

Reported-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210712043508.11584-6-desmondcheongzx@gmail.com
2 years agodrm: serialize drm_file.master with a new spinlock
Desmond Cheong Zhi Xi [Mon, 12 Jul 2021 04:35:07 +0000 (12:35 +0800)]
drm: serialize drm_file.master with a new spinlock

Currently, drm_file.master pointers should be protected by
drm_device.master_mutex when being dereferenced. This is because
drm_file.master is not invariant for the lifetime of drm_file. If
drm_file is not the creator of master, then drm_file.is_master is
false, and a call to drm_setmaster_ioctl will invoke
drm_new_set_master, which then allocates a new master for drm_file and
puts the old master.

Thus, without holding drm_device.master_mutex, the old value of
drm_file.master could be freed while it is being used by another
concurrent process.

However, it is not always possible to lock drm_device.master_mutex to
dereference drm_file.master. Through the fbdev emulation code, this
might occur in a deep nest of other locks. But drm_device.master_mutex
is also the outermost lock in the nesting hierarchy, so this leads to
potential deadlocks.

To address this, we introduce a new spin lock at the bottom of the
lock hierarchy that only serializes drm_file.master. With this change,
the value of drm_file.master changes only when both
drm_device.master_mutex and drm_file.master_lookup_lock are
held. Hence, any process holding either of those locks can ensure that
the value of drm_file.master will not change concurrently.

Since no lock depends on the new drm_file.master_lookup_lock, when
drm_file.master is dereferenced, but drm_device.master_mutex cannot be
held, we can safely protect the master pointer with
drm_file.master_lookup_lock.

Reported-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210712043508.11584-5-desmondcheongzx@gmail.com
2 years agodrm: add a locked version of drm_is_current_master
Desmond Cheong Zhi Xi [Mon, 12 Jul 2021 04:35:06 +0000 (12:35 +0800)]
drm: add a locked version of drm_is_current_master

While checking the master status of the DRM file in
drm_is_current_master(), the device's master mutex should be
held. Without the mutex, the pointer fpriv->master may be freed
concurrently by another process calling drm_setmaster_ioctl(). This
could lead to use-after-free errors when the pointer is subsequently
dereferenced in drm_lease_owner().

The callers of drm_is_current_master() from drm_auth.c hold the
device's master mutex, but external callers do not. Hence, we implement
drm_is_current_master_locked() to be used within drm_auth.c, and
modify drm_is_current_master() to grab the device's master mutex
before checking the master status.

Reported-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210712043508.11584-4-desmondcheongzx@gmail.com
2 years agodrm: avoid blocking in drm_clients_info's rcu section
Desmond Cheong Zhi Xi [Mon, 12 Jul 2021 04:35:05 +0000 (12:35 +0800)]
drm: avoid blocking in drm_clients_info's rcu section

Inside drm_clients_info, the rcu_read_lock is held to lock
pid_task()->comm. However, within this protected section, a call to
drm_is_current_master is made, which involves a mutex lock in a future
patch. However, this is illegal because the mutex lock might block
while in the RCU read-side critical section.

Since drm_is_current_master isn't protected by rcu_read_lock, we avoid
this by moving it out of the RCU critical section.

The following report came from intel-gfx ci's
igt@debugfs_test@read_all_entries testcase:

=============================
[ BUG: Invalid wait context ]
5.13.0-CI-Patchwork_20515+ #1 Tainted: G        W
-----------------------------
debugfs_test/1101 is trying to lock:
ffff888132d901a8 (&dev->master_mutex){+.+.}-{3:3}, at:
drm_is_current_master+0x1e/0x50
other info that might help us debug this:
context-{4:4}
3 locks held by debugfs_test/1101:
 #0: ffff88810fdffc90 (&p->lock){+.+.}-{3:3}, at:
 seq_read_iter+0x53/0x3b0
 #1: ffff888132d90240 (&dev->filelist_mutex){+.+.}-{3:3}, at:
 drm_clients_info+0x63/0x2a0
 #2: ffffffff82734220 (rcu_read_lock){....}-{1:2}, at:
 drm_clients_info+0x1b1/0x2a0
stack backtrace:
CPU: 8 PID: 1101 Comm: debugfs_test Tainted: G        W
5.13.0-CI-Patchwork_20515+ #1
Hardware name: Intel Corporation CometLake Client Platform/CometLake S
UDIMM (ERB/CRB), BIOS CMLSFWR1.R00.1263.D00.1906260926 06/26/2019
Call Trace:
 dump_stack+0x7f/0xad
 __lock_acquire.cold.78+0x2af/0x2ca
 lock_acquire+0xd3/0x300
 ? drm_is_current_master+0x1e/0x50
 ? __mutex_lock+0x76/0x970
 ? lockdep_hardirqs_on+0xbf/0x130
 __mutex_lock+0xab/0x970
 ? drm_is_current_master+0x1e/0x50
 ? drm_is_current_master+0x1e/0x50
 ? drm_is_current_master+0x1e/0x50
 drm_is_current_master+0x1e/0x50
 drm_clients_info+0x107/0x2a0
 seq_read_iter+0x178/0x3b0
 seq_read+0x104/0x150
 full_proxy_read+0x4e/0x80
 vfs_read+0xa5/0x1b0
 ksys_read+0x5a/0xd0
 do_syscall_64+0x39/0xb0
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210712043508.11584-3-desmondcheongzx@gmail.com
2 years agodrm: avoid circular locks in drm_mode_getconnector
Desmond Cheong Zhi Xi [Mon, 12 Jul 2021 04:35:04 +0000 (12:35 +0800)]
drm: avoid circular locks in drm_mode_getconnector

In preparation for a future patch to take a lock on
drm_device.master_mutex inside drm_is_current_master(), we first move
the call to drm_is_current_master() in drm_mode_getconnector out from the
section locked by &dev->mode_config.mutex. This avoids creating a
circular lock dependency.

Failing to avoid this lock dependency produces the following lockdep
splat:

======================================================
WARNING: possible circular locking dependency detected
5.13.0-rc7-CI-CI_DRM_10254+ #1 Not tainted
------------------------------------------------------
kms_frontbuffer/1087 is trying to acquire lock:
ffff88810dcd01a8 (&dev->master_mutex){+.+.}-{3:3}, at: drm_is_current_master+0x1b/0x40
but task is already holding lock:
ffff88810dcd0488 (&dev->mode_config.mutex){+.+.}-{3:3}, at: drm_mode_getconnector+0x1c6/0x4a0
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (&dev->mode_config.mutex){+.+.}-{3:3}:
       __mutex_lock+0xab/0x970
       drm_client_modeset_probe+0x22e/0xca0
       __drm_fb_helper_initial_config_and_unlock+0x42/0x540
       intel_fbdev_initial_config+0xf/0x20 [i915]
       async_run_entry_fn+0x28/0x130
       process_one_work+0x26d/0x5c0
       worker_thread+0x37/0x380
       kthread+0x144/0x170
       ret_from_fork+0x1f/0x30
-> #1 (&client->modeset_mutex){+.+.}-{3:3}:
       __mutex_lock+0xab/0x970
       drm_client_modeset_commit_locked+0x1c/0x180
       drm_client_modeset_commit+0x1c/0x40
       __drm_fb_helper_restore_fbdev_mode_unlocked+0x88/0xb0
       drm_fb_helper_set_par+0x34/0x40
       intel_fbdev_set_par+0x11/0x40 [i915]
       fbcon_init+0x270/0x4f0
       visual_init+0xc6/0x130
       do_bind_con_driver+0x1e5/0x2d0
       do_take_over_console+0x10e/0x180
       do_fbcon_takeover+0x53/0xb0
       register_framebuffer+0x22d/0x310
       __drm_fb_helper_initial_config_and_unlock+0x36c/0x540
       intel_fbdev_initial_config+0xf/0x20 [i915]
       async_run_entry_fn+0x28/0x130
       process_one_work+0x26d/0x5c0
       worker_thread+0x37/0x380
       kthread+0x144/0x170
       ret_from_fork+0x1f/0x30
-> #0 (&dev->master_mutex){+.+.}-{3:3}:
       __lock_acquire+0x151e/0x2590
       lock_acquire+0xd1/0x3d0
       __mutex_lock+0xab/0x970
       drm_is_current_master+0x1b/0x40
       drm_mode_getconnector+0x37e/0x4a0
       drm_ioctl_kernel+0xa8/0xf0
       drm_ioctl+0x1e8/0x390
       __x64_sys_ioctl+0x6a/0xa0
       do_syscall_64+0x39/0xb0
       entry_SYSCALL_64_after_hwframe+0x44/0xae
other info that might help us debug this:
Chain exists of: &dev->master_mutex --> &client->modeset_mutex --> &dev->mode_config.mutex
 Possible unsafe locking scenario:
       CPU0                    CPU1
       ----                    ----
  lock(&dev->mode_config.mutex);
                               lock(&client->modeset_mutex);
                               lock(&dev->mode_config.mutex);
  lock(&dev->master_mutex);
*** DEADLOCK ***
1 lock held by kms_frontbuffer/1087:
 #0: ffff88810dcd0488 (&dev->mode_config.mutex){+.+.}-{3:3}, at: drm_mode_getconnector+0x1c6/0x4a0
stack backtrace:
CPU: 7 PID: 1087 Comm: kms_frontbuffer Not tainted 5.13.0-rc7-CI-CI_DRM_10254+ #1
Hardware name: Intel Corporation Ice Lake Client Platform/IceLake U DDR4 SODIMM PD RVP TLC, BIOS ICLSFWR1.R00.3234.A01.1906141750 06/14/2019
Call Trace:
 dump_stack+0x7f/0xad
 check_noncircular+0x12e/0x150
 __lock_acquire+0x151e/0x2590
 lock_acquire+0xd1/0x3d0
 __mutex_lock+0xab/0x970
 drm_is_current_master+0x1b/0x40
 drm_mode_getconnector+0x37e/0x4a0
 drm_ioctl_kernel+0xa8/0xf0
 drm_ioctl+0x1e8/0x390
 __x64_sys_ioctl+0x6a/0xa0
 do_syscall_64+0x39/0xb0
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Reported-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210712043508.11584-2-desmondcheongzx@gmail.com
2 years agodrm/print: fixup spelling in a comment
Jim Cromie [Wed, 14 Jul 2021 17:51:34 +0000 (11:51 -0600)]
drm/print: fixup spelling in a comment

s/prink/printk/ - no functional changes

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210714175138.319514-2-jim.cromie@gmail.com
2 years agodma_buf: remove dmabuf sysfs teardown before release
Guangming Cao [Tue, 20 Jul 2021 10:31:58 +0000 (18:31 +0800)]
dma_buf: remove dmabuf sysfs teardown before release

Dmabuf sysfs stat is used for dmabuf info track.
But these file maybe still in use after buffer released,
should clear it before buffer release.

Signed-off-by: Guangming Cao <Guangming.Cao@mediatek.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210720103158.83439-1-guangming.cao@mediatek.com
Signed-off-by: Christian König <christian.koenig@amd.com>
2 years agodrm/bochs: Fix missing pci_disable_device() on error in bochs_pci_probe()
Yang Yingliang [Thu, 15 Jul 2021 13:28:45 +0000 (21:28 +0800)]
drm/bochs: Fix missing pci_disable_device() on error in bochs_pci_probe()

Replace pci_enable_device() with pcim_enable_device(),
pci_disable_device() will be called in release automatically.

v3:
  reformat commit message
  update for move to tiny/
v2:
  use pcim_enable_device()

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reported-by: Hulk Robot <hulkci@huawei.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210715132845.2415619-1-yangyingliang@huawei.com
2 years agodrm/ast: Disable fast reset after DRAM initial
KuoHsiang Chou [Fri, 9 Jul 2021 08:09:00 +0000 (16:09 +0800)]
drm/ast: Disable fast reset after DRAM initial

[Bug][AST2500]

V1:
When AST2500 acts as stand-alone VGA so that DRAM and DVO initialization
have to be achieved by VGA driver with P2A (PCI to AHB) enabling.
However, HW suggests disable Fast reset mode after DRAM initializaton,
because fast reset mode is mainly designed for ARM ICE debugger.
Once Fast reset is checked as enabling, WDT (Watch Dog Timer) should be
first enabled to avoid system deadlock before disable fast reset mode.

V2:
Use to_pci_dev() to get revision of PCI configuration.

V3:
If SCU00 is not unlocked, just enter its password again.
It is unnecessary to clear AHB lock condition and restore WDT default
setting again, before Fast-reset clearing.

V4:
repatch after "error : could not build fake ancestor" resolved.

V5:
Since CVE_2019_6260 item3, Most of AST2500 have disabled P2A(PCIe to AMBA).
However, for backward compatibility, some patches about P2A, such as items
of v5.2 and v5.3, are considered to be upstreamed with comments.
1. Add define macro to improve source readability.
ast_drv.h, ast_main.c, ast_post.c
2. Add comment about "Fast restet" is enabled for ARM-ICE debugger
ast_post.c
3. Add comment about Reset USB port to patch USB unknown device issue
ast_post.c

Signed-off-by: KuoHsiang Chou <kuohsiang_chou@aspeedtech.com>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210709080900.4056-1-kuohsiang_chou@aspeedtech.com
2 years agodrm/ast: Zero is missing in detect function
Ainux.Wang [Fri, 16 Jul 2021 01:56:15 +0000 (09:56 +0800)]
drm/ast: Zero is missing in detect function

The function ast_get_modes() will also return 0, when it try to get the
edid, but it also do not get the edid.

Signed-off-by: Ainux.Wang <ainux.wang@gmail.com>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716015615.9150-1-ainux.wang@gmail.com
2 years agodma-buf: Delete the DMA-BUF attachment sysfs statistics
Hridya Valsaraju [Tue, 13 Jul 2021 04:07:38 +0000 (21:07 -0700)]
dma-buf: Delete the DMA-BUF attachment sysfs statistics

The DMA-BUF attachment statistics form a subset of the DMA-BUF
sysfs statistics that recently merged to the drm-misc tree. They are not
UABI yet since they have not merged to the upstream Linux kernel.

Since there has been a reported a performance regression due to the
overhead of sysfs directory creation/teardown during
dma_buf_attach()/dma_buf_detach(), this patch deletes the DMA-BUF
attachment statistics from sysfs.

Fixes: bdb8d06dfefd ("dmabuf: Add the capability to expose DMA-BUF stats in sysfs")
Signed-off-by: Hridya Valsaraju <hridya@google.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210713040742.2680135-1-hridya@google.com
Signed-off-by: Christian König <christian.koenig@amd.com>
2 years agodrm/ingenic: Convert to Linux IRQ interfaces
Thomas Zimmermann [Thu, 15 Jul 2021 10:02:58 +0000 (12:02 +0200)]
drm/ingenic: Convert to Linux IRQ interfaces

Drop the DRM IRQ midlayer in favor of Linux IRQ interfaces. DRM's
IRQ helpers are mostly useful for UMS drivers. Modern KMS drivers
don't benefit from using it.

This patch also fixes a bug where the driver didn't release the
IRQ.

v2:
* automatically release IRQ via devm_request_irq() (Paul)
* mention the bugfix (Sam)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20210715100258.6638-1-tzimmermann@suse.de
2 years agofbmem: Convert from atomic_t to refcount_t on fb_info->count
Xiyu Yang [Mon, 19 Jul 2021 05:59:45 +0000 (13:59 +0800)]
fbmem: Convert from atomic_t to refcount_t on fb_info->count

refcount_t type and corresponding API can protect refcounters from
accidental underflow and overflow and further use-after-free situations.

Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1626674392-55857-1-git-send-email-xiyuyang19@fudan.edu.cn
2 years agovideo: fbdev: kyro: fix a DoS bug by restricting user input
Zheyu Ma [Wed, 14 Jul 2021 04:09:22 +0000 (04:09 +0000)]
video: fbdev: kyro: fix a DoS bug by restricting user input

The user can pass in any value to the driver through the 'ioctl'
interface. The driver dost not check, which may cause DoS bugs.

The following log reveals it:

divide error: 0000 [#1] PREEMPT SMP KASAN PTI
RIP: 0010:SetOverlayViewPort+0x133/0x5f0 drivers/video/fbdev/kyro/STG4000OverlayDevice.c:476
Call Trace:
 kyro_dev_overlay_viewport_set drivers/video/fbdev/kyro/fbdev.c:378 [inline]
 kyrofb_ioctl+0x2eb/0x330 drivers/video/fbdev/kyro/fbdev.c:603
 do_fb_ioctl+0x1f3/0x700 drivers/video/fbdev/core/fbmem.c:1171
 fb_ioctl+0xeb/0x130 drivers/video/fbdev/core/fbmem.c:1185
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl fs/ioctl.c:739 [inline]
 __x64_sys_ioctl+0x19b/0x220 fs/ioctl.c:739
 do_syscall_64+0x32/0x80 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1626235762-2590-1-git-send-email-zheyuma97@gmail.com
2 years agodrm/stm: dsi: compute the transition time from LP to HS and back
Antonio Borneo [Tue, 13 Jul 2021 14:49:41 +0000 (16:49 +0200)]
drm/stm: dsi: compute the transition time from LP to HS and back

The driver uses a conservative set of hardcoded values for the
maximum time delay of the transitions between LP and HS, either
for data and clock lanes.

By using the info in STM32MP157 datasheet, valid also for other ST
devices, compute the actual delay from the lane's bps.

Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com>
Reviewed-by: Philippe Cornu <philippe.cornu@foss.st.com>
Acked-by: Philippe Cornu <philippe.cornu@foss.st.com>
Signed-off-by: Philippe Cornu <philippe.cornu@foss.st.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210713144941.3599-1-antonio.borneo@foss.st.com
2 years agodrm/stm: ltdc: Silence -EPROBE_DEFER till bridge attached
Jagan Teki [Sun, 4 Jul 2021 13:59:14 +0000 (19:29 +0530)]
drm/stm: ltdc: Silence -EPROBE_DEFER till bridge attached

As dw-mipi-dsi supported all possible ways to find the DSI
devices. It can take multiple iterations for ltdc to find
all components attached to the DSI bridge.

The current ltdc driver failed to find the endpoint as
it returned -EINVAL for the first iteration itself. This leads
to following error:

[    3.099289] [drm:ltdc_load] *ERROR* init encoder endpoint 0

So, check the return value and cleanup the encoder only if it's
not -EPROBE_DEFER. This make all components in the attached DSI
bridge found properly.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Tested-by: Yannick Fertre <yannick.fertre@foss.st.com>
Acked-by: Philippe Cornu <philippe.cornu@foss.st.com>
Signed-off-by: Philippe Cornu <philippe.cornu@foss.st.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210704135914.268308-1-jagan@amarulasolutions.com
2 years agodrm/panel: ws2401: Add driver for WideChips WS2401
Linus Walleij [Wed, 14 Jul 2021 22:50:02 +0000 (00:50 +0200)]
drm/panel: ws2401: Add driver for WideChips WS2401

This adds a driver for panels based on the WideChips WS2401 display
controller. This display controller is used in the Samsung LMS380KF01
display found in the Samsung GT-I8160 (Codina) mobile phone and
possibly others.

As is common with Samsung displays manufacturer commands are necessary
to configure the display to a working state.

The display optionally supports internal backlight control, but can
also use an external backlight.

This driver re-uses the DBI infrastructure to communicate with the
display.

Cc: phone-devel@vger.kernel.org
Cc: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210714225002.1065107-2-linus.walleij@linaro.org
2 years agodrm/panel: Add DT bindings for Samsung LMS380KF01
Linus Walleij [Wed, 14 Jul 2021 22:50:01 +0000 (00:50 +0200)]
drm/panel: Add DT bindings for Samsung LMS380KF01

This adds device tree bindings for the Samsung Mobile Displays
LMS380KF01 RGB DPI display panel.

Cc: devicetree@vger.kernel.org
Cc: phone-devel@vger.kernel.org
Cc: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210714225002.1065107-1-linus.walleij@linaro.org
2 years agodrm/dp: For drm_panel_dp_aux_backlight(), init backlight as disabled
Douglas Anderson [Wed, 14 Jul 2021 17:17:46 +0000 (10:17 -0700)]
drm/dp: For drm_panel_dp_aux_backlight(), init backlight as disabled

Even after the DP AUX backlight on my board worked OK after applying
the patch ("drm/panel-simple: Power the panel when probing DP AUX
backlight") [1], I still noticed some strange timeouts being reported
by ti_sn_aux_transfer(). Digging, I realized the problem was this:
* Even though `enabled` in `struct dp_aux_backlight` was false, the
  base backlight structure (`base` in that structure) thought that the
  backlight was powered on.
* If userspace wrote to sysfs in this state then we'd try to enable
  the backlight.
* Unfortunatley, enabling the backlight didn't work because the panel
  itself wasn't powered.

We can only use the backlight if the panel is on and the panel is not
officially on when we probe (it's temporarily just on enough for us to
talk to it).

The important thing we want here is to get `BL_CORE_FBBLANK` set since
userspace can't mess with that. This will keep us disabled until
drm_panel enables us, which means that the panel is enabled
first. Ideally we'd just set this in our `props` before calling
devm_backlight_device_register() but the comments in the header file
are pretty explicit that we're not supposed to much with the `state`
ourselves. Because of this, there may be a small window where the
backlight device is registered and someone could try to tweak with the
backlight. This isn't likely to happen and even if it did, I don't
believe this causes any huge problem.

[1] https://lore.kernel.org/lkml/20210714093334.1.Idb41f87e5abae4aee0705db7458b0097fc50e7ab@changeid/

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210714101744.1.Ifc22696b27930749915e383f0108b7bcdc015a6e@changeid
2 years agodrm/panel-simple: Power the panel when probing DP AUX backlight
Douglas Anderson [Wed, 14 Jul 2021 16:33:50 +0000 (09:33 -0700)]
drm/panel-simple: Power the panel when probing DP AUX backlight

When I tried booting up a device that needed the DP AUX backlight, I
found an error in the logs:
  panel-simple-dp-aux: probe of aux-ti_sn65dsi86.aux.0 failed with error -110

The aux transfers were failing because the panel wasn't powered. Just
like when reading the EDID we need to power the panel when trying to
talk to it. Add the needed pm_runtime calls.

After I do this I can successfully probe the panel and adjust the
backlight on my board.

Fixes: bfd451403d70 ("drm/panel-simple: Support DP AUX backlight")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210714093334.1.Idb41f87e5abae4aee0705db7458b0097fc50e7ab@changeid
2 years agodrm/of: free the iterator object on failure
Steven Price [Wed, 14 Jul 2021 14:33:00 +0000 (15:33 +0100)]
drm/of: free the iterator object on failure

When bailing out due to the sanity check the iterator value needs to be
freed because the early return prevents for_each_child_of_node() from
doing the dereference itself.

Fixes: 6529007522de ("drm: of: Add drm_of_lvds_get_dual_link_pixel_order")
Signed-off-by: Steven Price <steven.price@arm.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210714143300.20632-1-steven.price@arm.com
2 years agodrm/omapdrm: Remove outdated comment
Thomas Zimmermann [Tue, 6 Jul 2021 07:31:25 +0000 (09:31 +0200)]
drm/omapdrm: Remove outdated comment

The comment refers to drm_irq_install() et al, which are not used by
omapdrm. The functions are part of the DRM IRQ midlayer and shouldn't
be used any longer. Remove the comment.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210706073125.7689-1-tzimmermann@suse.de
2 years agodrm/vbox: Convert to Linux IRQ interfaces
Thomas Zimmermann [Tue, 6 Jul 2021 07:50:11 +0000 (09:50 +0200)]
drm/vbox: Convert to Linux IRQ interfaces

Drop the DRM IRQ midlayer in favor of Linux IRQ interfaces. DRM's
IRQ helpers are mostly useful for UMS drivers. Modern KMS drivers
don't benefit from using it.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210706075011.9009-1-tzimmermann@suse.de
2 years agodrm/qxl: Convert to Linux IRQ interfaces
Thomas Zimmermann [Tue, 6 Jul 2021 07:47:35 +0000 (09:47 +0200)]
drm/qxl: Convert to Linux IRQ interfaces

Drop the DRM IRQ midlayer in favor of Linux IRQ interfaces. DRM's
IRQ helpers are mostly useful for UMS drivers. Modern KMS drivers
don't benefit from using it.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210706074735.8849-1-tzimmermann@suse.de
2 years agodrm/vc4: hdmi: Remove drm_encoder->crtc usage
Maxime Ripard [Wed, 7 Jul 2021 14:19:30 +0000 (16:19 +0200)]
drm/vc4: hdmi: Remove drm_encoder->crtc usage

The drm_encoder crtc pointer isn't really fit for an atomic driver,
let's rely on the connector state instead.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210707141930.1811128-1-maxime@cerno.tech
2 years agodrm/vc4: hdmi: Only call into DRM framework if registered
Maxime Ripard [Wed, 7 Jul 2021 09:51:12 +0000 (11:51 +0200)]
drm/vc4: hdmi: Only call into DRM framework if registered

Our hotplug handler will currently call the drm_kms_helper_hotplug_event
every time a hotplug interrupt is called.

However, since the device is registered after all the drivers have
finished their bind callback, we have a window between when we install
our interrupt handler and when drm_dev_register() is eventually called
where our handler can run and call drm_kms_helper_hotplug_event but the
device hasn't been registered yet, causing a null pointer dereference.

Fix this by making sure we only call drm_kms_helper_hotplug_event if our
device has been properly registered.

Fixes: f4790083c7c2 ("drm/vc4: hdmi: Rely on interrupts to handle hotplug")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210707095112.1469670-4-maxime@cerno.tech
2 years agodrm/vc4: hdmi: Drop devm interrupt handler for hotplug interrupts
Maxime Ripard [Wed, 7 Jul 2021 09:51:11 +0000 (11:51 +0200)]
drm/vc4: hdmi: Drop devm interrupt handler for hotplug interrupts

The hotplugs interrupt handlers are registered through the
devm_request_threaded_irq function. However, while free_irq is indeed
called properly when the device is unbound or bind fails, it's called
after unbind or bind is done.

In our particular case, it means that on failure it creates a window
where our interrupt handler can be called, but we're freeing every
resource (CEC adapter, DRM objects, etc.) it might need.

In order to address this, let's switch to the non-devm variant to
control better when the handler will be unregistered and allow us to
make it safe.

Fixes: f4790083c7c2 ("drm/vc4: hdmi: Rely on interrupts to handle hotplug")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210707095112.1469670-3-maxime@cerno.tech
2 years agodrm/panel: Add Innolux EJ030NA 3.0" 320x480 panel
Christophe Branchereau [Fri, 25 Jun 2021 12:10:45 +0000 (13:10 +0100)]
drm/panel: Add Innolux EJ030NA 3.0" 320x480 panel

Add support for the Innolux/Chimei EJ030NA 3.0"
320x480 TFT panel.

This panel can be found in the LDKs, RS97 V2.1 and RG300 (non IPS)
handheld gaming consoles.

While being 320x480, it is actually a horizontal 4:3
panel with non-square pixels in delta arrangement.

Signed-off-by: Christophe Branchereau <cbranchereau@gmail.com>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210625121045.81711-2-paul@crapouillou.net
2 years agodt-bindings: display/panel: Add Innolux EJ030NA
Paul Cercueil [Fri, 25 Jun 2021 12:10:44 +0000 (13:10 +0100)]
dt-bindings: display/panel: Add Innolux EJ030NA

Add binding for the Innolux EJ030NA panel, which is a 320x480 3.0" 4:3
24-bit TFT LCD panel with non-square pixels and a delta-RGB 8-bit
interface.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210625121045.81711-1-paul@crapouillou.net
2 years agodrm/shmem-helper: Align to page size in dumb_create
Daniel Vetter [Thu, 3 Jun 2021 16:41:12 +0000 (18:41 +0200)]
drm/shmem-helper: Align to page size in dumb_create

shmem helpers seem a bit sloppy here by automatically rounding up when
actually creating the buffer, which results in under-reporting of what
we actually have. Caught by igt/vgem_basic tests.

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210603164113.1433476-4-daniel.vetter@ffwll.ch
2 years agodrm/dp: Move panel DP AUX backlight support to drm_dp_helper
Douglas Anderson [Mon, 12 Jul 2021 15:00:44 +0000 (08:00 -0700)]
drm/dp: Move panel DP AUX backlight support to drm_dp_helper

We were getting a depmod error:
  depmod: ERROR: Cycle detected: drm_kms_helper -> drm -> drm_kms_helper

It looks like the rule is that drm_kms_helper can call into drm, but
drm can't call into drm_kms_helper. That means we've got to move the
DP AUX backlight support into drm_dp_helper.

NOTE: as part of this, I didn't try to do any renames of the main
registration function. Even though it's in the drm_dp_helper, it still
feels very parallel to drm_panel_of_backlight().

Fixes: 10f7b40e4f30 ("drm/panel: add basic DP AUX backlight support")
Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reported-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Rajeev Nandan <rajeevny@codeaurora.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210712075933.v2.1.I23eb4cc5a680341e7b3e791632a635566fa5806a@changeid
2 years agodrm/vkms: Use dma-buf mapping from shadow-plane state for composing
Thomas Zimmermann [Mon, 5 Jul 2021 07:46:33 +0000 (09:46 +0200)]
drm/vkms: Use dma-buf mapping from shadow-plane state for composing

Store the shadow-buffer mapping's address in struct vkms_composer and
use the value when composing the output. It's the same value as stored
in the GEM SHMEM BO, but frees the composer code from its dependency
on GEM SHMEM.

Using struct dma_buf_map is how framebuffer access is supposed to be.
The long-term plan is to perform all framebuffer access via struct
dma_buf_map and avoid the details of accessing I/O and system memory.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Melissa Wen <melissa.srw@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210705074633.9425-5-tzimmermann@suse.de
2 years agodrm/vkms: Let shadow-plane helpers prepare the plane's FB
Thomas Zimmermann [Mon, 5 Jul 2021 07:46:32 +0000 (09:46 +0200)]
drm/vkms: Let shadow-plane helpers prepare the plane's FB

Replace vkms' prepare_fb and cleanup_fb functions with the generic
code for shadow-buffered planes. No functional changes.

This change also fixes a problem where IGT kms_flip tests would
create a segmentation fault within vkms. The driver's prepare_fb
function did not report an error if a BO's vmap operation failed.
The kernel later tried to operate on the non-mapped memory areas.
The shared shadow-plane helpers handle errors correctly, so that
the driver now avoids the segmantation fault.

v2:
* include paragraph about IGT tests in commit message (Melissa)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Melissa Wen <melissa.srw@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210705074633.9425-4-tzimmermann@suse.de
2 years agodrm/vkms: Inherit plane state from struct drm_shadow_plane_state
Thomas Zimmermann [Mon, 5 Jul 2021 07:46:31 +0000 (09:46 +0200)]
drm/vkms: Inherit plane state from struct drm_shadow_plane_state

Subclass struct drm_shadow_plane_state for VKMS planes and update
all plane-state callbacks accordingly.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Melissa Wen <melissa.srw@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210705074633.9425-3-tzimmermann@suse.de
2 years agodrm/gem: Export implementation of shadow-plane helpers
Thomas Zimmermann [Mon, 5 Jul 2021 07:46:30 +0000 (09:46 +0200)]
drm/gem: Export implementation of shadow-plane helpers

Export the implementation of duplicate, destroy and reset helpers for
shadow-buffered plane state. Useful for drivers that subclass struct
drm_shadow_plane_state.

The exported functions are wrappers around plane-state implementation,
but using them is the correct thing to do for drivers.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Melissa Wen <melissa.srw@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210705074633.9425-2-tzimmermann@suse.de
2 years agoRevert "drm/vgem: Implement mmap as GEM object function"
Thomas Zimmermann [Tue, 13 Jul 2021 09:02:35 +0000 (11:02 +0200)]
Revert "drm/vgem: Implement mmap as GEM object function"

Commit 375cca1cfeb5 ("drm/vgem: Implement mmap as GEM object function")
broke several IGT tests in vgem_basic. [1] Attempts to fix the issue
have not worked out so far. [2][3] Revert the change for now.

Note that there is a patch that converts vgem to shmem helpers. [4]
Merging this change would be preferable to modifying vgem's mmap code.

v2:
* fix spelling error in commit message (Daniel)

[1] https://intel-gfx-ci.01.org/tree/drm-tip/igt@vgem_basic@unload.html
[2] https://lore.kernel.org/intel-gfx/20210709154256.12005-1-tzimmermann@suse.de/
[3] https://lore.kernel.org/intel-gfx/20210712123321.3658-1-tzimmermann@suse.de/
[4] https://patchwork.freedesktop.org/series/90671/

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: 375cca1cfeb5 ("drm/vgem: Implement mmap as GEM object function")
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Christian König <christian.koenig@amd.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Melissa Wen <melissa.srw@gmail.com>
Cc: Qinglang Miao <miaoqinglang@huawei.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210713090235.26372-1-tzimmermann@suse.de
2 years agodrm: bridge: Mark deprecated operations in drm_bridge_funcs
Sam Ravnborg [Sat, 10 Jul 2021 08:42:40 +0000 (10:42 +0200)]
drm: bridge: Mark deprecated operations in drm_bridge_funcs

drm_bridge_funcs includes several duplicated operations as atomic
variants have been added over time.
New bridge drivers shall use the atomic variants - mark the deprecated
operations to try to avoid usage in new bridge drivers.

v2:
  - Drop out-dated comment about state in mode_set (Laurent)
  - Added missing "the" in a description

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Acked-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210710084240.281063-1-sam@ravnborg.org
2 years agodrm/of: free the right object
Julia Lawall [Fri, 9 Jul 2021 20:07:17 +0000 (22:07 +0200)]
drm/of: free the right object

There is no need to free a NULL value.  Instead, free the object
that is leaking due to the iterator.

The semantic patch that finds this problem is as follows:

// <smpl>
@@
expression x,e;
identifier f;
@@
 x = f(...);
 if (x == NULL) {
... when any
    when != x = e
* of_node_put(x);
...
 }
// </smpl>

Fixes: 6529007522de ("drm: of: Add drm_of_lvds_get_dual_link_pixel_order")
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210709200717.3676376-1-Julia.Lawall@inria.fr
2 years agodrm/panfrost:fix the exception name always "UNKNOWN"
ChunyouTang [Thu, 8 Jul 2021 07:34:06 +0000 (15:34 +0800)]
drm/panfrost:fix the exception name always "UNKNOWN"

The exception_code in register is only 8 bits,So if
fault_status in panfrost_gpu_irq_handler() don't
(& 0xFF),it can't get correct exception reason.

and it's better to show all of the register value
to custom,so it's better fault_status don't (& 0xFF).

Signed-off-by: ChunyouTang <tangchunyou@icubecorp.cn>
Reviewed-by: Steven Price <steven.price@arm.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210708073407.2015-1-tangchunyou@163.com
2 years agodrm: bridge: nwl-dsi: Drop unused nwl_dsi_plat_clk_config
Jagan Teki [Sun, 4 Jul 2021 09:34:33 +0000 (15:04 +0530)]
drm: bridge: nwl-dsi: Drop unused nwl_dsi_plat_clk_config

nwl_dsi_plat_clk_config structure added in below commit but not
used anywhere in the driver.

commit <44cfc6233447c> ("drm/bridge: Add NWL MIPI DSI host controller
support")

Drop it.

Cc: Guido Günther <agx@sigxcpu.org>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Guido Günther <agx@sigxcpu.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210704093433.27717-1-jagan@amarulasolutions.com
2 years agodrm/panel: simple: Add support for EDT ETM0350G0DH6 panel
Stefan Riedmueller [Fri, 9 Jul 2021 20:03:49 +0000 (22:03 +0200)]
drm/panel: simple: Add support for EDT ETM0350G0DH6 panel

This patch adds support for the EDT ETM0350G0DH6 3.5" (320x240) lcd
panel to DRM simple panel driver.

Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Yunus Bas <y.bas@phytec.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210709200349.2665205-2-y.bas@phytec.de
2 years agodrm/panel: simple: Add support for EDT ETMV570G2DHU panel
Stefan Riedmueller [Fri, 9 Jul 2021 20:03:48 +0000 (22:03 +0200)]
drm/panel: simple: Add support for EDT ETMV570G2DHU panel

This patch adds support for the EDT ETMV570G2DHU 5.7" (640x480) lcd panel
to DRM simple panel driver.

Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Yunus Bas <y.bas@phytec.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210709200349.2665205-1-y.bas@phytec.de
2 years agodt-bindings: display: simple: Add EDT ETM0350G0DH6
Yunus Bas [Fri, 9 Jul 2021 20:09:13 +0000 (22:09 +0200)]
dt-bindings: display: simple: Add EDT ETM0350G0DH6

The Emerging Display Technology ETM0350G0DH6 is a 3.5" WVGA TFT panel
with capacitive multitouch. Add it to the list of compatibles.

Signed-off-by: Yunus Bas <y.bas@phytec.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210709200913.2666570-2-y.bas@phytec.de
2 years agodt-bindings: display: simple: Add EDT ETMV570G2DHU
Yunus Bas [Fri, 9 Jul 2021 20:09:12 +0000 (22:09 +0200)]
dt-bindings: display: simple: Add EDT ETMV570G2DHU

The Emerging Display Technology ETMV570G2DHU is a 5.7" VGA TFT panel.
Add it to the list of compatibles.

Signed-off-by: Yunus Bas <y.bas@phytec.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210709200913.2666570-1-y.bas@phytec.de
2 years agodrm/gma500: Add the missed drm_gem_object_put() in psb_user_framebuffer_create()
Jing Xiangfeng [Tue, 29 Jun 2021 11:59:56 +0000 (19:59 +0800)]
drm/gma500: Add the missed drm_gem_object_put() in psb_user_framebuffer_create()

psb_user_framebuffer_create() misses to call drm_gem_object_put() in an
error path. Add the missed function call to fix it.

Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210629115956.15160-1-jingxiangfeng@huawei.com
2 years agodrm/panel: Fix up DT bindings for Samsung lms397kf04
Linus Walleij [Thu, 1 Jul 2021 21:36:18 +0000 (23:36 +0200)]
drm/panel: Fix up DT bindings for Samsung lms397kf04

Improve the bindings and make them more usable:

- Pick in spi-cpha and spi-cpol from the SPI node parent,
  this will specify that we are "type 3" in the device tree
  rather than hardcoding it in the operating system.
- Drop the u32 ref from the SPI frequency: comes in from
  the SPI host bindings.
- Make spi-cpha, spi-cpol and port compulsory.
- Update the example with a real-world SPI controller,
  spi-gpio.

Cc: Noralf Trønnes <noralf@tronnes.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210701213618.3818821-1-linus.walleij@linaro.org
2 years agodrm/panel-simple: Add Samsung ATNA33XC20
Rajeev Nandan [Sat, 26 Jun 2021 16:51:08 +0000 (22:21 +0530)]
drm/panel-simple: Add Samsung ATNA33XC20

Add Samsung 13.3" FHD eDP AMOLED panel.

Signed-off-by: Rajeev Nandan <rajeevny@codeaurora.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1624726268-14869-7-git-send-email-rajeevny@codeaurora.org
2 years agodt-bindings: display: simple: Add Samsung ATNA33XC20
Rajeev Nandan [Sat, 26 Jun 2021 16:51:07 +0000 (22:21 +0530)]
dt-bindings: display: simple: Add Samsung ATNA33XC20

Add Samsung 13.3" FHD eDP AMOLED panel.

Signed-off-by: Rajeev Nandan <rajeevny@codeaurora.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1624726268-14869-6-git-send-email-rajeevny@codeaurora.org
2 years agodrm/panel-simple: Update validation warnings for eDP panel description
Rajeev Nandan [Sat, 26 Jun 2021 16:51:06 +0000 (22:21 +0530)]
drm/panel-simple: Update validation warnings for eDP panel description

Do not give a warning for the eDP panels if the "bus_format" is
not specified, since most eDP panels can support more than one
bus formats and this can be auto-detected.
Also, update the check to include bpc=10 for the eDP panel.

Signed-off-by: Rajeev Nandan <rajeevny@codeaurora.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1624726268-14869-5-git-send-email-rajeevny@codeaurora.org
2 years agodrm/panel-simple: Support for delays between GPIO & regulator
Rajeev Nandan [Sat, 26 Jun 2021 16:51:05 +0000 (22:21 +0530)]
drm/panel-simple: Support for delays between GPIO & regulator

Some panels datasheets may specify a delay between the enable GPIO and
the regulator. Support this in panel-simple.

Signed-off-by: Rajeev Nandan <rajeevny@codeaurora.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1624726268-14869-4-git-send-email-rajeevny@codeaurora.org
2 years agodrm/panel-simple: Support DP AUX backlight
Rajeev Nandan [Sat, 26 Jun 2021 16:51:04 +0000 (22:21 +0530)]
drm/panel-simple: Support DP AUX backlight

If there is no backlight specified in the device tree and the panel
has access to the DP AUX channel then create a DP AUX backlight if
supported by the panel.

Signed-off-by: Rajeev Nandan <rajeevny@codeaurora.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1624726268-14869-3-git-send-email-rajeevny@codeaurora.org
2 years agodrm/panel: add basic DP AUX backlight support
Rajeev Nandan [Sat, 26 Jun 2021 16:51:03 +0000 (22:21 +0530)]
drm/panel: add basic DP AUX backlight support

Some panels support backlight control over DP AUX channel using
VESA's standard backlight control interface.
Using new DRM eDP backlight helpers, add support to create and
register a backlight for those panels in drm_panel to simplify
the panel drivers.

The panel driver with access to "struct drm_dp_aux" can create and
register a backlight device using following code snippet in its
probe() function:

err = drm_panel_dp_aux_backlight(panel, aux);
if (err)
return err;

Then drm_panel will handle backlight_(enable|disable) calls
similar to the case when drm_panel_of_backlight() is used.

Currently, we are not supporting one feature where the source
device can combine the backlight brightness levels set through
DP AUX and the BL_PWM_DIM eDP connector pin. Since it's not
required for the basic backlight controls, it can be added later.

Signed-off-by: Rajeev Nandan <rajeevny@codeaurora.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Lyude Paul <lyude@redhat.com>
[dianders: added blank line for warning when applying]
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1624726268-14869-2-git-send-email-rajeevny@codeaurora.org
2 years agodrm/msm: always wait for the exclusive fence
Christian König [Fri, 2 Jul 2021 11:16:42 +0000 (13:16 +0200)]
drm/msm: always wait for the exclusive fence

Drivers also need to to sync to the exclusive fence when
a shared one is present.

Completely untested since the driver won't even compile on !ARM.

Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210702111642.17259-5-christian.koenig@amd.com
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2 years agodrm/gma500: Fix end of loop tests for list_for_each_entry
Harshvardhan Jha [Fri, 9 Jul 2021 07:39:59 +0000 (13:09 +0530)]
drm/gma500: Fix end of loop tests for list_for_each_entry

The list_for_each_entry() iterator, "connector" in this code, can never be
NULL.  If we exit the loop without finding the correct  connector then
"connector" points invalid memory that is an offset from the list head.
This will eventually lead to memory corruption and presumably a kernel
crash.

Fixes: 9bd81acdb648 ("gma500: Convert Oaktrail to work with new output handling")
Signed-off-by: Harshvardhan Jha <harshvardhan.jha@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210709073959.11443-1-harshvardhan.jha@oracle.com
2 years agodrm/vkms: Create a debugfs file to get vkms config data
Beatriz Martins de Carvalho [Thu, 8 Jul 2021 09:20:02 +0000 (10:20 +0100)]
drm/vkms: Create a debugfs file to get vkms config data

Creating a vkms_config debugfs file in vkms_drv.c to get/track vkms config
data, for the long-term plan of making vkms configurable and have multiple
different instances.

Reviewed-by: Melissa Wen <melissa.srw@gmail.com>
Signed-off-by: Beatriz Martins de Carvalho <martinsdecarvalhobeatriz@gmail.com>
Signed-off-by: Melissa Wen <melissa.srw@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210708092002.11847-1-martinsdecarvalhobeatriz@gmail.com
2 years agodrm/nouveau: always wait for the exclusive fence
Christian König [Sun, 6 Jun 2021 09:50:15 +0000 (11:50 +0200)]
drm/nouveau: always wait for the exclusive fence

Drivers also need to to sync to the exclusive fence when
a shared one is present.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210702111642.17259-4-christian.koenig@amd.com
2 years agodma-buf: fix dma_resv_test_signaled test_all handling v2
Christian König [Sun, 6 Jun 2021 09:46:33 +0000 (11:46 +0200)]
dma-buf: fix dma_resv_test_signaled test_all handling v2

As the name implies if testing all fences is requested we
should indeed test all fences and not skip the exclusive
one because we see shared ones.

v2: fix logic once more

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210702111642.17259-3-christian.koenig@amd.com
2 years agodrm/gud: Add async_flush module parameter
Noralf Trønnes [Sat, 3 Jul 2021 14:13:21 +0000 (16:13 +0200)]
drm/gud: Add async_flush module parameter

Provide a way for userspace to choose synchronous flushing/pageflips.
This helps save CPU and power.

It is also useful for test scripts since userspace can know when a flush
has happended and wait before doing the next visual test.

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Peter Stuge <peter@stuge.se>
Link: https://patchwork.freedesktop.org/patch/msgid/20210703141321.35494-2-noralf@tronnes.org
2 years agodrm/gud: Add Raspberry Pi Pico ID
Noralf Trønnes [Sat, 3 Jul 2021 14:13:20 +0000 (16:13 +0200)]
drm/gud: Add Raspberry Pi Pico ID

Add VID/PID for the Raspberry Pi Pico implementation.
Source: https://github.com/notro/gud-pico

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Peter Stuge <peter@stuge.se>
Link: https://patchwork.freedesktop.org/patch/msgid/20210703141321.35494-1-noralf@tronnes.org
2 years agodrm/gud: Use scatter-gather USB bulk transfer
Noralf Trønnes [Thu, 1 Jul 2021 17:07:48 +0000 (19:07 +0200)]
drm/gud: Use scatter-gather USB bulk transfer

There'a limit to how big a kmalloc buffer can be, and as memory gets
fragmented it becomes more difficult to get big buffers. The downside of
smaller buffers is that the driver has to split the transfer up which
hampers performance. Compression might also take a hit because of the
splitting.

Solve this by allocating the transfer buffer using vmalloc and create a
SG table to be passed on to the USB subsystem. vmalloc_32() is used to
avoid DMA bounce buffers on USB controllers that can only access 32-bit
addresses.

This also solves the problem that split transfers can give host side
tearing since flushing is decoupled from rendering.

usb_sg_wait() doesn't have timeout handling builtin, so it is wrapped in
a timer like 4 out of 6 users in the kernel have done.

v2:
- Use DIV_ROUND_UP (Linus)
- Add timeout note to the commit log (Linus)
- Expand note about upper buffer limit (Linus)
- Change var name s/timer/ctx/ in gud_usb_bulk_timeout()

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210701170748.58009-2-noralf@tronnes.org
2 years agodrm/gud: Free buffers on device removal
Noralf Trønnes [Thu, 1 Jul 2021 17:07:47 +0000 (19:07 +0200)]
drm/gud: Free buffers on device removal

Free transfer and compression buffers on device removal instead of at
DRM device removal time. This ensures that the usual 2x8MB buffers are
released when the device is unplugged and not kept around should
userspace keep the DRM device fd open.

At least Ubuntu 20.04 doesn't release the DRM device on unplug.

The damage_lock mutex is not destroyed because it is used outside the
drm_dev_enter/exit block in gud_pipe_update(). AFAICT it's possible for
an open fbdev descriptor to trigger a commit after the USB device is gone.

v2: Don't destroy damage_lock

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210701170748.58009-1-noralf@tronnes.org
2 years agodrm/hisilicon/hibmc: Convert to Linux IRQ interfaces
Thomas Zimmermann [Tue, 6 Jul 2021 07:54:25 +0000 (09:54 +0200)]
drm/hisilicon/hibmc: Convert to Linux IRQ interfaces

Drop the DRM IRQ midlayer in favor of Linux IRQ interfaces. DRM's
IRQ helpers are mostly useful for UMS drivers. Modern KMS drivers
don't benefit from using it.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Tian Tao <tiantao6@hisilicon.com>
Reviewed-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210706075425.9257-1-tzimmermann@suse.de
2 years agodrm/vmwgfx: Convert to Linux IRQ interfaces
Thomas Zimmermann [Tue, 6 Jul 2021 07:22:53 +0000 (09:22 +0200)]
drm/vmwgfx: Convert to Linux IRQ interfaces

Drop the DRM IRQ midlayer in favor of Linux IRQ interfaces. DRM's
IRQ helpers are mostly useful for UMS drivers. Modern KMS drivers
don't benefit from using it.

Vmwgfx already uses Linux IRQ functions. All that's left to replace
is the reference to struct drm_device.irq. Use irq value of struct
pci_dev instead.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Zack Rusin <zackr@vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210706072253.6844-1-tzimmermann@suse.de
2 years agodrm/arm/komeda: Don't include drm_irq.h
Thomas Zimmermann [Tue, 6 Jul 2021 07:27:12 +0000 (09:27 +0200)]
drm/arm/komeda: Don't include drm_irq.h

The header file is not required. Don't include it.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Liviu Dudau <liviu.dudau@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210706072712.7558-1-tzimmermann@suse.de
2 years agodrm/meson: Convert to Linux IRQ interfaces
Thomas Zimmermann [Tue, 6 Jul 2021 07:45:45 +0000 (09:45 +0200)]
drm/meson: Convert to Linux IRQ interfaces

Drop the DRM IRQ midlayer in favor of Linux IRQ interfaces. DRM's
IRQ helpers are mostly useful for UMS drivers. Modern KMS drivers
don't benefit from using it.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210706074545.8763-1-tzimmermann@suse.de
2 years agodrm/qxl: Remove empty qxl_gem_prime_mmap()
Thomas Zimmermann [Thu, 24 Jun 2021 09:05:00 +0000 (11:05 +0200)]
drm/qxl: Remove empty qxl_gem_prime_mmap()

The function qxl_gem_prime_mmap() returns an error. The two callers
of gem_prime_mmap are drm_fbdev_fb_mmap() and drm_gem_dmabuf_mmap(),
which both already handle NULL-callbacks with an error code. So clear
gem_prime_mmap in qxl and remove qxl_gem_prime_mmap().

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210624090500.8320-1-tzimmermann@suse.de
2 years agodrm/vkms: replace macro in vkms_release()
Beatriz Martins de Carvalho [Tue, 6 Jul 2021 15:45:10 +0000 (16:45 +0100)]
drm/vkms: replace macro in vkms_release()

Replace macro in vkms_release()

Signed-off-by: Beatriz Martins de Carvalho <martinsdecarvalhobeatriz@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210706154510.224695-1-martinsdecarvalhobeatriz@gmail.com
2 years agodrm: vc4: Fix pixel-wrap issue with DVP teardown
Tim Gover [Mon, 28 Jun 2021 13:05:33 +0000 (15:05 +0200)]
drm: vc4: Fix pixel-wrap issue with DVP teardown

Adjust the DVP enable/disable sequence to avoid a pixel getting stuck
in an internal, non resettable FIFO within PixelValve when changing
HDMI resolution.

The blank pixels features of the DVP can prevent signals back to
pixelvalve causing it to not clear the FIFO. Adjust the ordering
and timing of operations to ensure the clear signal makes it through to
pixelvalve.

Signed-off-by: Tim Gover <tim.gover@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210628130533.144617-1-maxime@cerno.tech
2 years agodrm/vc4: hdmi: Limit noise when deferring snd card registration
Nicolas Saenz Julienne [Tue, 29 Jun 2021 12:17:23 +0000 (14:17 +0200)]
drm/vc4: hdmi: Limit noise when deferring snd card registration

We don't want to print an error message each time
devm_snd_soc_register_card() returns -EPROBE_DEFER, the function will
most likely succeed some time in the future, once the missing resources
are available. So use dev_err_probe(), which will redirect the messages
to the debug log level in such case.

Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210629121723.11523-1-nsaenzju@redhat.com
2 years agodrm/vgem: Implement mmap as GEM object function
Thomas Zimmermann [Thu, 24 Jun 2021 09:52:38 +0000 (11:52 +0200)]
drm/vgem: Implement mmap as GEM object function

Moving the driver-specific mmap code into a GEM object function allows
for using DRM helpers for various mmap callbacks.

The respective vgem functions are being removed. The file_operations
structure vgem_driver_fops is now being created by the helper macro
DEFINE_DRM_GEM_FOPS().

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210624095238.8804-1-tzimmermann@suse.de
2 years agodrm/mgag200: Constify LUT for programming bpp
Thomas Zimmermann [Fri, 2 Jul 2021 07:56:42 +0000 (09:56 +0200)]
drm/mgag200: Constify LUT for programming bpp

Declare constant LUT for bpp programming as static const. Removes mutable
data from device structure.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210702075642.27834-5-tzimmermann@suse.de
2 years agodrm/mgag200: Extract device type and flags in mgag200_pci_probe()
Thomas Zimmermann [Fri, 2 Jul 2021 07:56:41 +0000 (09:56 +0200)]
drm/mgag200: Extract device type and flags in mgag200_pci_probe()

The type and flags values are stored in the PCI ID list. Extract them
in the probe function. Makes the device initialization more readable.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210702075642.27834-4-tzimmermann@suse.de
2 years agodrm/mgag200: Inline mgag200_device_init()
Thomas Zimmermann [Fri, 2 Jul 2021 07:56:40 +0000 (09:56 +0200)]
drm/mgag200: Inline mgag200_device_init()

Inline mgag200_device_init() into mgag200_device_create(), which is
the only caller. Also remove a duplicate error message for
mgag200_modeset_init(). The function will print an error if/where it
failed.

v2:
* include a note about the removed error message in
  changelog (Sam)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210702075642.27834-3-tzimmermann@suse.de
2 years agodrm/mgag200: Don't pass flags to drm_dev_register()
Thomas Zimmermann [Fri, 2 Jul 2021 07:56:39 +0000 (09:56 +0200)]
drm/mgag200: Don't pass flags to drm_dev_register()

The flags argument is only relevant for UMS drivers. Pass 0.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210702075642.27834-2-tzimmermann@suse.de