linux-block.git
2 months agodrm/format-helper: Optimize 32-to-24-bpp conversion
Thomas Zimmermann [Fri, 28 Mar 2025 14:15:02 +0000 (15:15 +0100)]
drm/format-helper: Optimize 32-to-24-bpp conversion

For ease of implementation, existing line-conversion functions
for 24-bit formats write each byte individually. Optimize the
performance by writing 4 pixels in 3 32-bit stores.

v2:
- simplify address calculation (Jani)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://lore.kernel.org/r/20250328141709.217283-7-tzimmermann@suse.de
2 months agodrm/format-helper: Add generic conversion to 8-bit formats
Thomas Zimmermann [Fri, 28 Mar 2025 14:15:01 +0000 (15:15 +0100)]
drm/format-helper: Add generic conversion to 8-bit formats

Add drm_fb_xfrm_line_32to8() to implement conversion from 32-bit
pixels to 8-bit pixels. The pixel-conversion is specified by the
given callback parameter. Mark the helper as always_inline to avoid
overhead from function calls.

Then implement all existing line-conversion functions with the new
generic call and the respective pixel-conversion helper.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://lore.kernel.org/r/20250328141709.217283-6-tzimmermann@suse.de
2 months agodrm/format-helper: Add generic conversion to 16-bit formats
Thomas Zimmermann [Fri, 28 Mar 2025 14:15:00 +0000 (15:15 +0100)]
drm/format-helper: Add generic conversion to 16-bit formats

Add drm_fb_xfrm_line_32to16() to implement conversion from 32-bit
pixels to 16-bit pixels. The pixel-conversion is specified by the
given callback parameter. Mark the helper as always_inline to avoid
overhead from function calls.

Then implement all existing line-conversion functions with the new
generic call and the respective pixel-conversion helper. There's one
pixel-conversion helper that swaps output bytes. It is for gud and
requires refactoring, so don't move it into the header file.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://lore.kernel.org/r/20250328141709.217283-5-tzimmermann@suse.de
2 months agodrm/format-helper: Add generic conversion to 24-bit formats
Thomas Zimmermann [Fri, 28 Mar 2025 14:14:59 +0000 (15:14 +0100)]
drm/format-helper: Add generic conversion to 24-bit formats

Add drm_fb_xfrm_line_32to24() to implement conversion from 32-bit
pixels to 24-bit pixels. The pixel-conversion is specified by the
given callback parameter. Mark the helper as always_inline to avoid
overhead from function calls.

Then implement all existing line-conversion functions with the new
generic call and the respective pixel-conversion helper.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://lore.kernel.org/r/20250328141709.217283-4-tzimmermann@suse.de
2 months agodrm/format-helper: Add generic conversion to 32-bit formats
Thomas Zimmermann [Fri, 28 Mar 2025 14:14:58 +0000 (15:14 +0100)]
drm/format-helper: Add generic conversion to 32-bit formats

Add drm_fb_xfrm_line_32to32() to implement conversion from 32-bit
pixels to 32-bit pixels. The pixel-conversion is specified by the
given callback parameter. Mark the helper as always_inline to avoid
overhead from function calls.

Then implement all existing line-conversion functions with the new
generic call and the respective pixel-conversion helper.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://lore.kernel.org/r/20250328141709.217283-3-tzimmermann@suse.de
2 months agodrm/format-helper: Move helpers for pixel conversion to header file
Thomas Zimmermann [Fri, 28 Mar 2025 14:14:57 +0000 (15:14 +0100)]
drm/format-helper: Move helpers for pixel conversion to header file

The DRM draw helpers contain format-conversion helpers that operate
on individual pixels. Move them into an internal header file and adopt
them as individual API. Update the draw code accordingly. The pixel
helpers will also be useful for other format conversion helpers.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://lore.kernel.org/r/20250328141709.217283-2-tzimmermann@suse.de
2 months agodrm/cirrus-qemu: Remove custom plane state
Thomas Zimmermann [Fri, 28 Mar 2025 09:17:08 +0000 (10:17 +0100)]
drm/cirrus-qemu: Remove custom plane state

Remove struct cirrus_primary_plane_state and its helpers, which
are all unused. Use struct drm_shadow_plane_state instead.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Link: https://lore.kernel.org/r/20250328091821.195061-5-tzimmermann@suse.de
2 months agodrm/cirrus-qemu: Use framebuffer format as-is, drop adjustments
Thomas Zimmermann [Fri, 28 Mar 2025 09:17:07 +0000 (10:17 +0100)]
drm/cirrus-qemu: Use framebuffer format as-is, drop adjustments

Remove internal adjustments to framebuffer format from cirrus-qemu
driver. The driver did this to support higher resolutions by reducing
the per-pixel memory consumption. DRM has a policy of exporting formats
as they are implemented in hardware. So avoid internal adjustments if
possible.

Also remove the call to drm_fb_blit() from cirrus-qemu. The helper
is useful if source and destination format are not known beforehand.
This is not the case for cirrus-qemu.

This change effectively reduces the maximum available resolution to
800x600 at 32 bpp. A maximum scanline pitch of 4095 byte prevents
1024 pixels per scanline at 32 bpp. Higher resolutions are possible
at lower bit depths, but are currently not supported by userspace.

When cirrus-qemu currently reduced the internal bit depth to support
higher resolutions, it trades resolution for bit depth and CPU time.
Converting from 32-bit colors has a significant runtime overhead, as
outlined at [1]. Avoiding color-format adjustments also avoids this
tradeoff.

v2:
- expand commit message (Gerd)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Link: https://lore.kernel.org/dri-devel/20250325110407.81107-1-tzimmermann@suse.de/
Link: https://lore.kernel.org/r/20250328091821.195061-4-tzimmermann@suse.de
2 months agodrm/cirrus-qemu: Stricter mode validation
Thomas Zimmermann [Fri, 28 Mar 2025 09:17:06 +0000 (10:17 +0100)]
drm/cirrus-qemu: Stricter mode validation

Implement strict checking of a display mode's minimum scanline
pitch in cirrus_mode_config_mode_valid(). Sort out all modes that
possibly overflow the maximum pitch.

The current validation only tests against a display mode's minimum
requirements for video memory. Only atomic_check later tests against
the pitch limit before programming the framebuffer.

The problem is that user-space compositors do not handle this
gracefully. If atomic_check fails to validate the scanline pitch
and returns an error, the compositor, namely Weston, does nothing
and the display remains stale.

Ruling out display modes that possibly overflow the pitch avoids
this problem. With only 4 MiB of video memory available, this
effectively limits horizontal resolution to 800 pixels. But with
cirrus-qemu being low-end and obsolete, this is probably not an
issue in practice. Better alternatives are available in qemu.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Link: https://lore.kernel.org/r/20250328091821.195061-3-tzimmermann@suse.de
2 months agodrm/cirrus-qemu: Fix pitch programming
Thomas Zimmermann [Fri, 28 Mar 2025 09:17:05 +0000 (10:17 +0100)]
drm/cirrus-qemu: Fix pitch programming

Do not set CR1B[6] when programming the pitch. The bit effects VGA
text mode and is not interpreted by qemu. [1] It has no affect on
the scanline pitch.

The scanline bit that is set into CR1B[6] belongs into CR13[7], which
the driver sets up correctly.

This bug goes back to the driver's initial commit.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Link: https://gitlab.com/qemu-project/qemu/-/blob/stable-9.2/hw/display/cirrus_vga.c?ref_type=heads#L1112
Fixes: f9aa76a85248 ("drm/kms: driver for virtual cirrus under qemu")
Cc: Adam Jackson <ajax@redhat.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: <stable@vger.kernel.org> # v3.5+
Link: https://lore.kernel.org/r/20250328091821.195061-2-tzimmermann@suse.de
2 months agodrm/panfrost: Force AARCH64_4K page table format on MediaTek MT8192
Ariel D'Alessandro [Mon, 24 Mar 2025 18:58:01 +0000 (15:58 -0300)]
drm/panfrost: Force AARCH64_4K page table format on MediaTek MT8192

MediaTek MT8192 SoC has an ARM Mali-G57 MC5 GPU (Valhall-JM). Now that
Panfrost supports AARCH64_4K page table format, let's enable it on this
SoC.

Running glmark2-es2-drm [0] benchmark, reported the same performance
score on both modes Mali LPAE (LEGACY) vs. AARCH64_4K, before and after
this commit. Tested on a Mediatek (MT8395) Genio 1200 EVK board.

[0] https://github.com/glmark2/glmark2

Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Link: https://lore.kernel.org/r/20250324185801.168664-7-ariel.dalessandro@collabora.com
2 months agodrm/panfrost: Force AARCH64_4K page table format on MediaTek MT8188
Ariel D'Alessandro [Mon, 24 Mar 2025 18:58:00 +0000 (15:58 -0300)]
drm/panfrost: Force AARCH64_4K page table format on MediaTek MT8188

MediaTek MT8188 SoC has an ARM Mali-G57 MC3 GPU (Valhall-JM), which
constantly faults with the current panfrost support.

For instance, running `glmark2-es2-drm` benchmark test:
```
[   79.617461] panfrost 13000000.gpu: js fault, js=1, status=JOB_BUS_FAULT, head=0xaadc380, tail=0xaadc380
[   80.119811] panfrost 13000000.gpu: gpu sched timeout, js=0, config=0x7300, status=0x58, head=0xaaca180, tail=0xaaca180, sched_job=000000002fd03ccc
[   80.129083] panfrost 13000000.gpu: Unhandled Page fault in AS0 at VA 0x0000000000000000
[   80.129083] Reason: TODO
[   80.129083] raw fault status: 0x1C2
[   80.129083] decoded fault status: SLAVE FAULT
[   80.129083] exception type 0xC2: TRANSLATION_FAULT_2
[   80.129083] access type 0x1: EXECUTE
[   80.129083] source id 0x0
```

Note that current panfrost mode (Mali LPAE - LEGACY) only allows to
specify write-cache or implementation-defined as the caching policy,
probably not matching the right configuration. As depicted in the source
code:

drivers/iommu/io-pgtable-arm.c:
```
* MEMATTR: Mali has no actual notion of a non-cacheable type, so the
* best we can do is mimic the out-of-tree driver and hope that the
* "implementation-defined caching policy" is good enough...
```

Now that Panfrost supports AARCH64_4K page table format, let's enable it
on Mediatek MT8188 and configure the cache/shareability policies
properly.

Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Link: https://lore.kernel.org/r/20250324185801.168664-6-ariel.dalessandro@collabora.com
2 months agodrm/panfrost: Add support for AARCH64_4K page table format
Ariel D'Alessandro [Mon, 24 Mar 2025 18:57:59 +0000 (15:57 -0300)]
drm/panfrost: Add support for AARCH64_4K page table format

Currently, Panfrost only supports MMU configuration in "LEGACY" (as
Bifrost calls it) mode, a (modified) version of LPAE "Large Physical
Address Extension", which in Linux we've called "mali_lpae".

This commit adds support for conditionally enabling AARCH64_4K page
table format. To achieve that, a "GPU optional quirks" field was added
to `struct panfrost_features` with the related flag.

Note that, in order to enable AARCH64_4K mode, the GPU variant must have
the HW_FEATURE_AARCH64_MMU feature flag present.

Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Link: https://lore.kernel.org/r/20250324185801.168664-5-ariel.dalessandro@collabora.com
2 months agodrm/panfrost: Set HW_FEATURE_AARCH64_MMU feature flag on Bifrost models
Ariel D'Alessandro [Mon, 24 Mar 2025 18:57:58 +0000 (15:57 -0300)]
drm/panfrost: Set HW_FEATURE_AARCH64_MMU feature flag on Bifrost models

Set this feature flag on all Mali Bifrost platforms as the MMU supports
AARCH64 4K page table format.

Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Link: https://lore.kernel.org/r/20250324185801.168664-4-ariel.dalessandro@collabora.com
2 months agodrm/panfrost: Use GPU_MMU_FEATURES_VA_BITS/PA_BITS macros
Ariel D'Alessandro [Mon, 24 Mar 2025 18:57:57 +0000 (15:57 -0300)]
drm/panfrost: Use GPU_MMU_FEATURES_VA_BITS/PA_BITS macros

As done in panthor, define and use these GPU_MMU_FEATURES_* macros,
which makes code easier to read and reuse.

Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Link: https://lore.kernel.org/r/20250324185801.168664-3-ariel.dalessandro@collabora.com
2 months agodrm/panfrost: Set IOMMU_CACHE flag
Ariel D'Alessandro [Mon, 24 Mar 2025 18:57:56 +0000 (15:57 -0300)]
drm/panfrost: Set IOMMU_CACHE flag

Panfrost does not support uncached mappings, so flag them properly. Also
flag the pages that are mapped as response to a page fault as cached.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Reviewed-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Link: https://lore.kernel.org/r/20250324185801.168664-2-ariel.dalessandro@collabora.com
2 months agodrm/bridge: sii902x: Set bridge type
Alexander Stein [Wed, 26 Mar 2025 10:11:23 +0000 (11:11 +0100)]
drm/bridge: sii902x: Set bridge type

This is a RGB to HDMI bridge, so set the bridge type accordingly.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250326101124.4031874-1-alexander.stein@ew.tq-group.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/panel: himax-hx8394: transition to mipi_dsi wrapped functions
Tejas Vipin [Tue, 25 Mar 2025 09:47:07 +0000 (15:17 +0530)]
drm/panel: himax-hx8394: transition to mipi_dsi wrapped functions

Changes the himax-hx8394 panel to use multi style functions for
improved error handling.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Tejas Vipin <tejasvipin76@gmail.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20250325094707.961349-1-tejasvipin76@gmail.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/panel/sharp-ls043t1le01: Use _multi variants
Anusha Srivatsa [Thu, 27 Mar 2025 03:29:19 +0000 (23:29 -0400)]
drm/panel/sharp-ls043t1le01: Use _multi variants

Move away from using deprecated API and use _multi variants
if available. Use mipi_dsi_msleep() and mipi_dsi_usleep_range()
instead of msleep() and usleep_range() respectively.

Used Coccinelle to find the _multi variant APIs,replacing
mpi_dsi_msleep() where necessary and for returning
dsi_ctx.accum_err in these functions. mipi_dsi_dcs_write()
does not have a corresponding _multi() variant. Replacing it with
mipi_dsi_dcs_write_seq_multi() instead. This change is manual.

The Coccinelle script is the same as the one in commit c8ba07caaecc
("drm/panel/synaptics-r63353: Use _multi variants")

v2: Use mipi_dsi_write_buffer_multi() in place of
mipi_dsi_dcs_write(). (Dmitry)

v3: add commit details where the same coccinelle script is
used and remove the actual script from commit log.
Use mipi_dsi_dcs_write_seq_multi() for mipi_dsi_dcs_write() (Doug)

Cc: Maxime Ripard <mripard@kernel.org>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Tejas Vipin <tejasvipin76@gmail.com>
Cc: Doug Anderson <dianders@chromium.org>
Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20250326-b4-panel-ls043t1le01-v3-1-96c554c0ea2b@redhat.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/bridge: cdns-dsi: Move DSI mode check to _atomic_check()
Aradhya Bhatia [Sat, 29 Mar 2025 11:39:20 +0000 (17:09 +0530)]
drm/bridge: cdns-dsi: Move DSI mode check to _atomic_check()

At present, the DSI mode configuration check happens during the
_atomic_enable() phase, which is not really the best place for this.
Moreover, if the mode is not valid, the driver gives a warning and
continues the hardware configuration.

Move the DSI mode configuration check to _atomic_check() instead, which
can properly report back any invalid mode, before the _enable phase even
begins.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Aradhya Bhatia <a-bhatia1@ti.com>
Signed-off-by: Aradhya Bhatia <aradhya.bhatia@linux.dev>
Link: https://lore.kernel.org/r/20250329113925.68204-10-aradhya.bhatia@linux.dev
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/bridge: cdns-dsi: Add input format negotiation
Aradhya Bhatia [Sat, 29 Mar 2025 11:39:19 +0000 (17:09 +0530)]
drm/bridge: cdns-dsi: Add input format negotiation

Add support for the input format negotiation hook, that uses the helper
drm_mipi_dsi_get_input_bus_fmt() for dsi hosts, to figure out the
required input format.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Aradhya Bhatia <a-bhatia1@ti.com>
Signed-off-by: Aradhya Bhatia <aradhya.bhatia@linux.dev>
Link: https://lore.kernel.org/r/20250329113925.68204-9-aradhya.bhatia@linux.dev
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/mipi-dsi: Add helper to find input format
Aradhya Bhatia [Sat, 29 Mar 2025 11:39:18 +0000 (17:09 +0530)]
drm/mipi-dsi: Add helper to find input format

Add a helper API that can be used by the DSI hosts to find the required
input bus format for the given output dsi pixel format.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Aradhya Bhatia <a-bhatia1@ti.com>
Signed-off-by: Aradhya Bhatia <aradhya.bhatia@linux.dev>
Link: https://lore.kernel.org/r/20250329113925.68204-8-aradhya.bhatia@linux.dev
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/bridge: cdns-dsi: Move to devm_drm_of_get_bridge()
Aradhya Bhatia [Sat, 29 Mar 2025 11:39:17 +0000 (17:09 +0530)]
drm/bridge: cdns-dsi: Move to devm_drm_of_get_bridge()

Instead of manually finding the next bridge/panel, and maintaining the
panel-bridge (in-case the next entity is a panel), switch to using the
automatically managing devm_drm_of_get_bridge() API.

Drop the drm_panel support completely from the driver while at it.

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Aradhya Bhatia <a-bhatia1@ti.com>
Signed-off-by: Aradhya Bhatia <aradhya.bhatia@linux.dev>
Link: https://lore.kernel.org/r/20250329113925.68204-7-aradhya.bhatia@linux.dev
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/bridge: cdns-dsi: Wait for Clk and Data Lanes to be ready
Aradhya Bhatia [Sat, 29 Mar 2025 11:39:16 +0000 (17:09 +0530)]
drm/bridge: cdns-dsi: Wait for Clk and Data Lanes to be ready

Once the DSI Link and DSI Phy are initialized, the code needs to wait
for Clk and Data Lanes to be ready, before continuing configuration.
This is in accordance with the DSI Start-up procedure, found in the
Technical Reference Manual of Texas Instrument's J721E SoC[0] which
houses this DSI TX controller.

If the previous bridge (or crtc/encoder) are configured pre-maturely,
the input signal FIFO gets corrupt. This introduces a color-shift on the
display.

Allow the driver to wait for the clk and data lanes to get ready during
DSI enable.

[0]: See section 12.6.5.7.3 "Start-up Procedure" in J721E SoC TRM
Link: http://www.ti.com/lit/pdf/spruil1
Fixes: e19233955d9e ("drm/bridge: Add Cadence DSI driver")
Cc: stable@vger.kernel.org
Tested-by: Dominik Haller <d.haller@phytec.de>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Aradhya Bhatia <a-bhatia1@ti.com>
Signed-off-by: Aradhya Bhatia <aradhya.bhatia@linux.dev>
Link: https://lore.kernel.org/r/20250329113925.68204-6-aradhya.bhatia@linux.dev
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/bridge: cdns-dsi: Check return value when getting default PHY config
Aradhya Bhatia [Sat, 29 Mar 2025 11:39:15 +0000 (17:09 +0530)]
drm/bridge: cdns-dsi: Check return value when getting default PHY config

Check for the return value of the phy_mipi_dphy_get_default_config()
call, and in case of an error, return back the same.

Fixes: fced5a364dee ("drm/bridge: cdns: Convert to phy framework")
Cc: stable@vger.kernel.org
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Aradhya Bhatia <a-bhatia1@ti.com>
Signed-off-by: Aradhya Bhatia <aradhya.bhatia@linux.dev>
Link: https://lore.kernel.org/r/20250329113925.68204-5-aradhya.bhatia@linux.dev
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/bridge: cdns-dsi: Fix the clock variable for mode_valid()
Aradhya Bhatia [Sat, 29 Mar 2025 11:39:14 +0000 (17:09 +0530)]
drm/bridge: cdns-dsi: Fix the clock variable for mode_valid()

The crtc_* mode parameters do not get generated (duplicated in this
case) from the regular parameters before the mode validation phase
begins.

The rest of the code conditionally uses the crtc_* parameters only
during the bridge enable phase, but sticks to the regular parameters
for mode validation. In this singular instance, however, the driver
tries to use the crtc_clock parameter even during the mode validation,
causing the validation to fail.

Allow the D-Phy config checks to use mode->clock instead of
mode->crtc_clock during mode_valid checks, like everywhere else in the
driver.

Fixes: fced5a364dee ("drm/bridge: cdns: Convert to phy framework")
Cc: stable@vger.kernel.org
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Aradhya Bhatia <a-bhatia1@ti.com>
Signed-off-by: Aradhya Bhatia <aradhya.bhatia@linux.dev>
Link: https://lore.kernel.org/r/20250329113925.68204-4-aradhya.bhatia@linux.dev
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/bridge: cdns-dsi: Fix phy de-init and flag it so
Aradhya Bhatia [Sat, 29 Mar 2025 11:39:13 +0000 (17:09 +0530)]
drm/bridge: cdns-dsi: Fix phy de-init and flag it so

The driver code doesn't have a Phy de-initialization path as yet, and so
it does not clear the phy_initialized flag while suspending. This is a
problem because after resume the driver looks at this flag to determine
if a Phy re-initialization is required or not. It is in fact required
because the hardware is resuming from a suspend, but the driver does not
carry out any re-initialization causing the D-Phy to not work at all.

Call the counterparts of phy_init() and phy_power_on(), that are
phy_exit() and phy_power_off(), from _bridge_post_disable(), and clear
the flags so that the Phy can be initialized again when required.

Fixes: fced5a364dee ("drm/bridge: cdns: Convert to phy framework")
Cc: stable@vger.kernel.org
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Aradhya Bhatia <a-bhatia1@ti.com>
Signed-off-by: Aradhya Bhatia <aradhya.bhatia@linux.dev>
Link: https://lore.kernel.org/r/20250329113925.68204-3-aradhya.bhatia@linux.dev
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/bridge: cdns-dsi: Fix connecting to next bridge
Aradhya Bhatia [Sat, 29 Mar 2025 11:39:12 +0000 (17:09 +0530)]
drm/bridge: cdns-dsi: Fix connecting to next bridge

Fix the OF node pointer passed to the of_drm_find_bridge() call to find
the next bridge in the display chain.

The code to find the next panel (and create its panel-bridge) works
fine, but to find the next (non-panel) bridge does not.

To find the next bridge in the pipeline, we need to pass "np" - the OF
node pointer of the next entity in the devicetree chain. Passing
"of_node" to of_drm_find_bridge (which is what the code does currently)
will fetch the bridge for the cdns-dsi which is not what's required.

Fix that.

Fixes: e19233955d9e ("drm/bridge: Add Cadence DSI driver")
Cc: stable@vger.kernel.org
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Aradhya Bhatia <a-bhatia1@ti.com>
Signed-off-by: Aradhya Bhatia <aradhya.bhatia@linux.dev>
Link: https://lore.kernel.org/r/20250329113925.68204-2-aradhya.bhatia@linux.dev
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/nouveau: fix hibernate on disabled GPU
Christoph Rudorff [Tue, 25 Mar 2025 12:44:36 +0000 (13:44 +0100)]
drm/nouveau: fix hibernate on disabled GPU

Hibernate bricks the machine if a discrete GPU was disabled via

echo IGD > /sys/kernel/debug/vgaswitcheroo/switch

The freeze and thaw handler lacks checking the GPU power state,
as suspend and resume do.

This patch add the checks and fix this issue.

Signed-off-by: Christoph Rudorff <chris@rudorff.com>
Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://lore.kernel.org/r/20250325-nouveau-fix-hibernate-v2-1-2bd5c13fb953@rudorff.com
2 months agoaccel/amdxdna: Add BO import and export
Lizhi Hou [Tue, 25 Mar 2025 20:01:05 +0000 (13:01 -0700)]
accel/amdxdna: Add BO import and export

Add amdxdna_gem_prime_export() and amdxdna_gem_prime_import() for BO
import and export. Register mmu notifier for imported BO as well. When
MMU_NOTIFIER_UNMAP event is received, queue work to remove the notifier.

The same BO could be mapped multiple times if it is exported and imported
by an application. Use a link list to track VMAs the BO been mapped.

v2: Rebased and call get_dma_buf() before dma_buf_attach()
v3: Removed import_attach usage

Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Link: https://lore.kernel.org/r/20250325200105.2744079-1-lizhi.hou@amd.com
2 months agodrm/nouveau/outp: Avoid -Wflex-array-member-not-at-end warning
Gustavo A. R. Silva [Fri, 28 Mar 2025 15:52:18 +0000 (09:52 -0600)]
drm/nouveau/outp: Avoid -Wflex-array-member-not-at-end warning

-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.

Use the `DEFINE_RAW_FLEX()` helper for an on-stack definition of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

So, with these changes, fix the following warning:

drivers/gpu/drm/nouveau/nvif/outp.c:199:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/Z-bFsmWjr5yZy6c6@kspp
2 months agodrm/nouveau/conn: Avoid -Wflex-array-member-not-at-end warning
Gustavo A. R. Silva [Fri, 28 Mar 2025 14:56:25 +0000 (08:56 -0600)]
drm/nouveau/conn: Avoid -Wflex-array-member-not-at-end warning

-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.

Use the `DEFINE_RAW_FLEX()` helper for an on-stack definition of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

So, with these changes, fix the following warning:

drivers/gpu/drm/nouveau/nvif/conn.c:34:38: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/Z-a4meHAy-t58bcE@kspp
2 months agodrm/virtio: Add capset definitions to UAPI
Aaron Ruby [Thu, 27 Mar 2025 15:25:49 +0000 (15:25 +0000)]
drm/virtio: Add capset definitions to UAPI

Since the context-type additions to the virtio-gpu spec, these have been
defined locally in guest user-space, and virtio-gpu backend library code.

Now, these capsets have been stabilized, and should be defined in a
common space, in both the virtio_gpu header, and alongside the virtgpu_drm
interface that they apply to.

Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Aaron Ruby <aruby@qnx.com>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
[dmitry.osipenko@collabora.com: edit commit title]
Link: https://patchwork.freedesktop.org/patch/msgid/YT3PR01MB5857E808EDF6949F2DF517FDAFA12@YT3PR01MB5857.CANPRD01.PROD.OUTLOOK.COM
2 months agodrm/bridge: anx7625: Remove redundant 'flush_workqueue()' calls
Chen Ni [Wed, 12 Mar 2025 09:01:32 +0000 (17:01 +0800)]
drm/bridge: anx7625: Remove redundant 'flush_workqueue()' calls

'destroy_workqueue()' already drains the queue before destroying it, so
there is no need to flush it explicitly.

Remove the redundant 'flush_workqueue()' calls.

This was generated with coccinelle:

@@
expression E;
@@
- flush_workqueue(E);
  destroy_workqueue(E);

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Reviewed-by: Robert Foss <rfoss@kernel.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20250312090132.1624445-1-nichen@iscas.ac.cn
2 months agodt-bindings: display: panel: samsung,atna40yk20: document ATNA40YK20
Christopher Obbard [Tue, 25 Mar 2025 19:21:26 +0000 (19:21 +0000)]
dt-bindings: display: panel: samsung,atna40yk20: document ATNA40YK20

The Samsung ATNA40YK20 panel is a 14" AMOLED eDP panel. It is
similar to the ATNA33XC20 except that it is larger and has a
different resolution.

Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20250325-wip-obbardc-qcom-t14s-oled-panel-v2-1-e9bc7c9d30cc@linaro.org
2 months agodrm/panic: add missing Markdown code span
Miguel Ojeda [Mon, 24 Mar 2025 21:03:49 +0000 (22:03 +0100)]
drm/panic: add missing Markdown code span

Add missing Markdown code span.

This was found using the Clippy `doc_markdown` lint, which we may want
to enable.

Fixes: cb5164ac43d0 ("drm/panic: Add a QR code panic screen")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://lore.kernel.org/r/20250324210359.1199574-3-ojeda@kernel.org
2 months agodrm/panic: add missing space
Miguel Ojeda [Mon, 24 Mar 2025 21:03:48 +0000 (22:03 +0100)]
drm/panic: add missing space

Add missing space in sentence.

This was found using the Clippy `doc_markdown` lint, which we may want
to enable.

Fixes: cb5164ac43d0 ("drm/panic: Add a QR code panic screen")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://lore.kernel.org/r/20250324210359.1199574-2-ojeda@kernel.org
2 months agodrm: Remove redundant statement in drm_crtc_helper_set_mode()
Huacai Chen [Mon, 11 Nov 2024 13:21:49 +0000 (21:21 +0800)]
drm: Remove redundant statement in drm_crtc_helper_set_mode()

Commit dbbfaf5f2641a ("drm: Remove bridge support from legacy helpers")
removes the drm_bridge_mode_fixup() call in drm_crtc_helper_set_mode(),
which makes the subsequent "encoder_funcs = encoder->helper_private" be
redundant, so remove it.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Link: https://lore.kernel.org/r/20241111132149.1113736-1-chenhuacai@loongson.cn
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
2 months agoaccel/amdxdna: s/drm_gem_v[un]map_unlocked/drm_gem_v[un]map/
Boris Brezillon [Thu, 27 Mar 2025 10:43:00 +0000 (11:43 +0100)]
accel/amdxdna: s/drm_gem_v[un]map_unlocked/drm_gem_v[un]map/

Commit 8f5c4871a014 ("drm/gem: Change locked/unlocked postfix of
drm_gem_v/unmap() function names") dropped the _unlocked suffix,
but accel drivers were left behind.

Fixes: 8f5c4871a014 ("drm/gem: Change locked/unlocked postfix of drm_gem_v/unmap() function names")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Min Ma <min.ma@amd.com>
Cc: Lizhi Hou <lizhi.hou@amd.com>
Cc: Oded Gabbay <ogabbay@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Tested-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250327104300.1982058-3-boris.brezillon@collabora.com
2 months agoaccel/ivpu: s/drm_gem_shmem_v[un]map/drm_gem_shmem_v[un]map_locked/
Boris Brezillon [Thu, 27 Mar 2025 10:42:59 +0000 (11:42 +0100)]
accel/ivpu: s/drm_gem_shmem_v[un]map/drm_gem_shmem_v[un]map_locked/

Commit 954907f7147d ("drm/shmem-helper: Refactor locked/unlocked
functions") suffixed drm_gem_shmem_v[un]map with _locked to reflect
the fact these functions must be called with the GEM resv lock held,
but accel drivers were left behind.

Fixes: 954907f7147d ("drm/shmem-helper: Refactor locked/unlocked functions")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Cc: Maciej Falkowski <maciej.falkowski@linux.intel.com>
Cc: Oded Gabbay <ogabbay@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Tested-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250327104300.1982058-2-boris.brezillon@collabora.com
2 months agoaccel/ivpu: pages_use_count is now a refcount_t
Boris Brezillon [Thu, 27 Mar 2025 10:42:58 +0000 (11:42 +0100)]
accel/ivpu: pages_use_count is now a refcount_t

Commit 051b6646d36d ("drm/shmem-helper: Use refcount_t for
pages_use_count") changed the type of
drm_gem_shmem_object::pages_use_count but accel drivers were left
behind.

Fixes: 051b6646d36d ("drm/shmem-helper: Use refcount_t for pages_use_count")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Cc: Maciej Falkowski <maciej.falkowski@linux.intel.com>
Cc: Oded Gabbay <ogabbay@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Tested-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250327104300.1982058-1-boris.brezillon@collabora.com
2 months agodrm/shmem-helper: Use refcount_t for vmap_use_count
Dmitry Osipenko [Sat, 22 Mar 2025 21:26:08 +0000 (00:26 +0300)]
drm/shmem-helper: Use refcount_t for vmap_use_count

Use refcount_t helper for vmap_use_count to make refcounting consistent
with pages_use_count and pages_pin_count that use refcount_t. This also
makes vmapping to benefit from the refcount_t's overflow checks.

Acked-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.d>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250322212608.40511-11-dmitry.osipenko@collabora.com
2 months agodrm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin
Dmitry Osipenko [Sat, 22 Mar 2025 21:26:07 +0000 (00:26 +0300)]
drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin

The vmapped pages shall be pinned in memory and previously get/put_pages()
were implicitly hard-pinning/unpinning the pages. This will no longer be
the case with addition of memory shrinker because pages_use_count > 0 won't
determine anymore whether pages are hard-pinned (they will be soft-pinned),
while the new pages_pin_count will do the hard-pinning. Switch the
vmap/vunmap() to use pin/unpin() functions in a preparation of addition
of the memory shrinker support to drm-shmem.

Acked-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.d>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250322212608.40511-10-dmitry.osipenko@collabora.com
2 months agodrm/shmem-helper: Use refcount_t for pages_use_count
Dmitry Osipenko [Sat, 22 Mar 2025 21:26:06 +0000 (00:26 +0300)]
drm/shmem-helper: Use refcount_t for pages_use_count

Use atomic refcount_t helper for pages_use_count to optimize pin/unpin
functions by skipping reservation locking while GEM's pin refcount > 1.

Acked-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.d>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250322212608.40511-9-dmitry.osipenko@collabora.com
2 months agodrm/shmem-helper: Add and use pages_pin_count
Dmitry Osipenko [Sat, 22 Mar 2025 21:26:05 +0000 (00:26 +0300)]
drm/shmem-helper: Add and use pages_pin_count

Add separate pages_pin_count for tracking of whether drm-shmem pages are
moveable or not. With the addition of memory shrinker support to drm-shmem,
the pages_use_count will no longer determine whether pages are hard-pinned
in memory, but whether pages exist and are soft-pinned (and could be swapped
out). The pages_pin_count > 1 will hard-pin pages in memory.

Acked-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.d>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250322212608.40511-8-dmitry.osipenko@collabora.com
2 months agodrm/shmem-helper: Remove obsoleted is_iomem test
Dmitry Osipenko [Sat, 22 Mar 2025 21:26:04 +0000 (00:26 +0300)]
drm/shmem-helper: Remove obsoleted is_iomem test

Everything that uses the mapped buffer should be agnostic to is_iomem.
The only reason for the is_iomem test is that we're setting shmem->vaddr
to the returned map->vaddr. Now that the shmem->vaddr code is gone, remove
the obsoleted is_iomem test to clean up the code.

Acked-by: Maxime Ripard <mripard@kernel.org>
Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.d>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250322212608.40511-7-dmitry.osipenko@collabora.com
2 months agodrm/shmem-helper: Refactor locked/unlocked functions
Dmitry Osipenko [Sat, 22 Mar 2025 21:26:03 +0000 (00:26 +0300)]
drm/shmem-helper: Refactor locked/unlocked functions

Add locked and remove unlocked postfixes from drm-shmem function names,
making names consistent with the drm/gem core code.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.d>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250322212608.40511-6-dmitry.osipenko@collabora.com
2 months agodrm/shmem-helper: Make all exported symbols GPL
Dmitry Osipenko [Sat, 22 Mar 2025 21:26:02 +0000 (00:26 +0300)]
drm/shmem-helper: Make all exported symbols GPL

Make all drm-shmem exported symbols GPL to make them consistent with
the rest of drm-shmem symbols.

Acked-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.d>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250322212608.40511-5-dmitry.osipenko@collabora.com
2 months agodrm/gem: Document locking rule of vmap and evict callbacks
Dmitry Osipenko [Sat, 22 Mar 2025 21:26:01 +0000 (00:26 +0300)]
drm/gem: Document locking rule of vmap and evict callbacks

The vmap/vunmap/evict GEM callbacks are always invoked with a held GEM's
reservation lock. Document this locking rule for clarity.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.d>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250322212608.40511-4-dmitry.osipenko@collabora.com
2 months agodrm/gem: Add _locked postfix to functions that have unlocked counterpart
Dmitry Osipenko [Sat, 22 Mar 2025 21:26:00 +0000 (00:26 +0300)]
drm/gem: Add _locked postfix to functions that have unlocked counterpart

Add _locked postfix to drm_gem functions that have unlocked counterpart
functions to make GEM functions naming more consistent and intuitive in
regards to the locking requirements.

Acked-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.d>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250322212608.40511-3-dmitry.osipenko@collabora.com
2 months agodrm/gem: Change locked/unlocked postfix of drm_gem_v/unmap() function names
Dmitry Osipenko [Sat, 22 Mar 2025 21:25:59 +0000 (00:25 +0300)]
drm/gem: Change locked/unlocked postfix of drm_gem_v/unmap() function names

Make drm/gem API function names consistent by having locked function
use the _locked postfix in the name, while the unlocked variants don't
use the _unlocked postfix. Rename drm_gem_v/unmap() function names to
make them consistent with the rest of the API functions.

Acked-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.d>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250322212608.40511-2-dmitry.osipenko@collabora.com
2 months agodrm/vc4: hdmi: Add jack detection to HDMI audio driver
David Turner [Mon, 17 Mar 2025 17:12:24 +0000 (17:12 +0000)]
drm/vc4: hdmi: Add jack detection to HDMI audio driver

Add ALSA jack detection to the vc4-hdmi audio driver so userspace knows
when to add/remove HDMI audio devices.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: David Turner <david.turner@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250317-vc4_hotplug-v4-3-2af625629186@raspberrypi.com
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 months agodrm/vc4: hdmi: Call HDMI hotplug helper on disconnect
Stefan Wahren [Mon, 17 Mar 2025 17:12:23 +0000 (17:12 +0000)]
drm/vc4: hdmi: Call HDMI hotplug helper on disconnect

drm_atomic_helper_connector_hdmi_hotplug() must be called
regardless of the connection status, otherwise the HDMI audio
disconnect event won't be notified.

Fixes: 2ea9ec5d2c20 ("drm/vc4: hdmi: use drm_atomic_helper_connector_hdmi_hotplug()")
Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: David Turner <david.turner@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250317-vc4_hotplug-v4-2-2af625629186@raspberrypi.com
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 months agodrm/display: Update comment on hdmi hotplug helper
David Turner [Mon, 17 Mar 2025 17:12:22 +0000 (17:12 +0000)]
drm/display: Update comment on hdmi hotplug helper

Update the comment on drm_atomic_helper_connector_hdmi_hotplug() to
clarify that it must be called for all status updates.

Signed-off-by: David Turner <david.turner@raspberrypi.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250317-vc4_hotplug-v4-1-2af625629186@raspberrypi.com
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 months agodrm/display: dp-tunnel: use new DCPD access helpers
Dmitry Baryshkov [Mon, 24 Mar 2025 11:51:24 +0000 (13:51 +0200)]
drm/display: dp-tunnel: use new DCPD access helpers

Switch drm_dp_tunnel.c to use new set of DPCD read / write helpers.

Reviewed-by: Lyude Paul <lyude@redhat.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20250324-drm-rework-dpcd-access-v4-6-e80ff89593df@oss.qualcomm.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/display: dp-mst-topology: use new DCPD access helpers
Dmitry Baryshkov [Mon, 24 Mar 2025 11:51:23 +0000 (13:51 +0200)]
drm/display: dp-mst-topology: use new DCPD access helpers

Switch drm_dp_mst_topology.c to use new set of DPCD read / write helpers.

Reviewed-by: Lyude Paul <lyude@redhat.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20250324-drm-rework-dpcd-access-v4-5-e80ff89593df@oss.qualcomm.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/display: dp-cec: use new DCPD access helpers
Dmitry Baryshkov [Mon, 24 Mar 2025 11:51:22 +0000 (13:51 +0200)]
drm/display: dp-cec: use new DCPD access helpers

Switch drm_dp_cec.c to use new set of DPCD read / write helpers.

Reviewed-by: Lyude Paul <lyude@redhat.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20250324-drm-rework-dpcd-access-v4-4-e80ff89593df@oss.qualcomm.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/display: dp: use new DCPD access helpers
Dmitry Baryshkov [Mon, 24 Mar 2025 11:51:21 +0000 (13:51 +0200)]
drm/display: dp: use new DCPD access helpers

Switch drm_dp_helper.c to use new set of DPCD read / write helpers.

Reviewed-by: Lyude Paul <lyude@redhat.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20250324-drm-rework-dpcd-access-v4-3-e80ff89593df@oss.qualcomm.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/display: dp: change drm_dp_dpcd_read_link_status() return value
Dmitry Baryshkov [Mon, 24 Mar 2025 11:51:20 +0000 (13:51 +0200)]
drm/display: dp: change drm_dp_dpcd_read_link_status() return value

drm_dp_dpcd_read_link_status() follows the "return error code or number
of bytes read" protocol, with the code returning less bytes than
requested in case of some errors. However most of the drivers
interpreted that as "return error code in case of any error". Switch
drm_dp_dpcd_read_link_status() to drm_dp_dpcd_read_data() and make it
follow that protocol too.

Acked-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20250324-drm-rework-dpcd-access-v4-2-e80ff89593df@oss.qualcomm.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/display: dp: implement new access helpers
Dmitry Baryshkov [Mon, 24 Mar 2025 11:51:19 +0000 (13:51 +0200)]
drm/display: dp: implement new access helpers

Existing DPCD access functions return an error code or the number of
bytes being read / write in case of partial access. However a lot of
drivers either (incorrectly) ignore partial access or mishandle error
codes. In other cases this results in a boilerplate code which compares
returned value with the size.

Implement new set of DPCD access helpers, which ignore partial access,
always return 0 or an error code.

Suggested-by: Jani Nikula <jani.nikula@linux.intel.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20250324-drm-rework-dpcd-access-v4-1-e80ff89593df@oss.qualcomm.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2 months agodrm/ci: arm64.config: mediatek: enable PHY drivers
Vignesh Raman [Fri, 14 Mar 2025 08:58:52 +0000 (14:28 +0530)]
drm/ci: arm64.config: mediatek: enable PHY drivers

The mediatek display driver fails to probe on mt8173-elm-hana and
mt8183-kukui-jacuzzi-juniper-sku16 in v6.14-rc4 due to missing PHY
configurations.

Enable the following PHY drivers for MediaTek platforms:
- CONFIG_PHY_MTK_HDMI=y for HDMI display
- CONFIG_PHY_MTK_MIPI_DSI=y for DSI display

Signed-off-by: Vignesh Raman <vignesh.raman@collabora.com>
Acked-by: Helen Koike <helen.fornazier@gmail.com>
Link: https://lore.kernel.org/r/20250314085858.39328-4-vignesh.raman@collabora.com
2 months agodrm/ci: uprev IGT
Vignesh Raman [Fri, 14 Mar 2025 08:58:51 +0000 (14:28 +0530)]
drm/ci: uprev IGT

Uprev IGT to the latest version and update expectation files.

Signed-off-by: Vignesh Raman <vignesh.raman@collabora.com>
Acked-by: Helen Koike <helen.fornazier@gmail.com>
Link: https://lore.kernel.org/r/20250314085858.39328-3-vignesh.raman@collabora.com
2 months agodrm/ci: uprev mesa
Vignesh Raman [Fri, 14 Mar 2025 08:58:50 +0000 (14:28 +0530)]
drm/ci: uprev mesa

LAVA was recently patched [1] with a fix on how parameters are parsed in
`lava-test-case`, so we don't need to repeat quotes to send the
arguments properly to it. Uprev mesa to fix this issue.

[1] https://gitlab.com/lava/lava/-/commit/18c9cf79

Signed-off-by: Vignesh Raman <vignesh.raman@collabora.com>
Acked-by: Helen Koike <helen.fornazier@gmail.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Link: https://lore.kernel.org/r/20250314085858.39328-2-vignesh.raman@collabora.com
2 months agodrm/panel/synaptics-r63353: Use _multi variants
Anusha Srivatsa [Tue, 18 Mar 2025 14:37:07 +0000 (10:37 -0400)]
drm/panel/synaptics-r63353: Use _multi variants

Move away from using deprecated API and use _multi
variants if available. Use mipi_dsi_msleep()
and mipi_dsi_usleep_range() instead of msleep()
and usleep_range() respectively.

Used Coccinelle to find the _multi variant APIs,
replacing mpi_dsi_msleep() where necessary and for returning
dsi_ctx.accum_err in these functions. Manually handled the
reset step before returning from r63353_panel_activate()

v2: Do not skip the reset in case of error during
panel activate (Dmitry)
- Convert all usleep_range()

v3: mipi_dsi_usleep_range() is to be used only when in
between _multi commands(Doug)
- Check for error once in the end while using _multi
variants (Doug)

v4: Change return type of r63353_panel_deactivate() to void (Doug)

@rule_1@
identifier dsi_var;
identifier r;
identifier func;
type t;
position p;
expression dsi_device;
expression list es;
@@
t func(...) {
...
struct mipi_dsi_device *dsi_var = dsi_device;
+struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi_var };
<+...
(
-r = mipi_dsi_dcs_nop(dsi_var)@p;
+mipi_dsi_dcs_nop_multi(&dsi_ctx);
|
-r = mipi_dsi_dcs_exit_sleep_mode(dsi_var)@p;
+mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
|
-r = mipi_dsi_dcs_enter_sleep_mode(dsi_var)@p;
+mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
|
-r = mipi_dsi_dcs_write_buffer(dsi_var,es)@p;
+mipi_dsi_dcs_write_buffer_multi(&dsi_ctx,es);
|
-r = mipi_dsi_dcs_set_display_off(dsi_var,es)@p;
+mipi_dsi_dcs_set_display_off_multi(&dsi_ctx,es);
|
-r = mipi_dsi_compression_mode_ext(dsi_var,es)@p;
+mipi_dsi_compression_mode_ext_multi(&dsi_ctx,es);
|
-r = mipi_dsi_compression_mode(dsi_var,es)@p;
+mipi_dsi_compression_mode_multi(&dsi_ctx,es);
|
-r = mipi_dsi_picture_parameter_set(dsi_var,es)@p;
+mipi_dsi_picture_parameter_set_multi(&dsi_ctx,es);
|
-r = mipi_dsi_dcs_set_display_on(dsi_var,es)@p;
+mipi_dsi_dcs_set_display_on_multi(&dsi_ctx,es);
|
-r = mipi_dsi_dcs_set_tear_on(dsi_var)@p;
+mipi_dsi_dcs_set_tear_on_multi(&dsi_ctx);
|
-r = mipi_dsi_turn_on_peripheral(dsi_var)@p;
+mipi_dsi_turn_on_peripheral_multi(&dsi_ctx);
|
-r = mipi_dsi_dcs_soft_reset(dsi_var)@p;
+mipi_dsi_dcs_soft_reset_multi(&dsi_ctx);
|
-r = mipi_dsi_dcs_set_display_brightness(dsi_var,es)@p;
+mipi_dsi_dcs_set_display_brightness_multi(&dsi_ctx,es);
|
-r = mipi_dsi_dcs_set_pixel_format(dsi_var,es)@p;
+mipi_dsi_dcs_set_pixel_format_multi(&dsi_ctx,es);
|
-r = mipi_dsi_dcs_set_column_address(dsi_var,es)@p;
+mipi_dsi_dcs_set_column_address_multi(&dsi_ctx,es);
|
-r = mipi_dsi_dcs_set_page_address(dsi_var,es)@p;
+mipi_dsi_dcs_set_page_address_multi(&dsi_ctx,es);
|
-r = mipi_dsi_dcs_set_tear_scanline(dsi_var,es)@p;
+mipi_dsi_dcs_set_tear_scanline_multi(&dsi_ctx,es);
)
-if(r < 0) {
-...
-}
...+>
}

@rule_2@
identifier dsi_var;
identifier r;
identifier func;
type t;
position p;
expression dsi_device;
expression list es;
@@
t func(...) {
...
struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi_var };
<+...
(
-r = msleep(es)@p;
+r = mipi_dsi_msleep(&dsi_ctx,es);
|
-msleep(es)@p;
+mipi_dsi_msleep(&dsi_ctx,es);
|
-r = usleep_range(es)@p;
+r = mipi_dsi_usleep_range(&dsi_ctx,es);
|
-usleep_range(es)@p;
+mipi_dsi_usleep_range(&dsi_ctx,es);
)
...+>
}

@rule_3@
identifier dsi_var;
identifier func;
type t;
position p;
expression list es;
@@
t func(...) {
...
struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi_var };
...
-return 0;
+return dsi_ctx.accum_err;
}

Cc: Maxime Ripard <mripard@kernel.org>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Tejas Vipin <tejasvipin76@gmail.com>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250318-synaptic-expt-v1-1-fa3831a7d883@redhat.com
2 months agodrm/panel: novatek-nt36523: transition to mipi_dsi wrapped functions
Tejas Vipin [Sat, 15 Mar 2025 18:25:22 +0000 (23:55 +0530)]
drm/panel: novatek-nt36523: transition to mipi_dsi wrapped functions

Changes the novatek-nt36523 panel to use multi style functions for
improved error handling.

Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Tejas Vipin <tejasvipin76@gmail.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250315182522.628187-1-tejasvipin76@gmail.com
2 months agodrm/panel: samsung-s6d7aa0: transition to mipi_dsi wrapped functions
Tejas Vipin [Wed, 19 Mar 2025 18:31:06 +0000 (00:01 +0530)]
drm/panel: samsung-s6d7aa0: transition to mipi_dsi wrapped functions

Changes the samsung-s6d7aa0 panel to use multi style functions for
improved error handling.

Signed-off-by: Tejas Vipin <tejasvipin76@gmail.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
[dianders: fixed whitespace errors]
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250319183106.12613-1-tejasvipin76@gmail.com
2 months agodrm/bridge: ti-sn65dsi86: Check bridge connection failure
Wolfram Sang [Tue, 18 Mar 2025 15:52:56 +0000 (16:52 +0100)]
drm/bridge: ti-sn65dsi86: Check bridge connection failure

Read out and check the ID registers, so we can bail out if I2C
communication does not work or if the device is unknown. Tested on a
Renesas GrayHawk board (R-Car V4M) by using a wrong I2C address and by
not enabling RuntimePM for the device.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250318155549.19625-2-wsa+renesas@sang-engineering.com
2 months agodrm/bridge: ti-sn65dsi86: make use of debugfs_init callback
Wolfram Sang [Sat, 15 Mar 2025 20:15:11 +0000 (21:15 +0100)]
drm/bridge: ti-sn65dsi86: make use of debugfs_init callback

Do not create a custom directory in debugfs-root, but use the
debugfs_init callback to create a custom directory at the given place
for the bridge. The new directory layout looks like this on a Renesas
GrayHawk-Single with a R-Car V4M SoC:

/sys/kernel/debug/dri/feb00000.display/DP-1/1-002c

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250315201651.7339-2-wsa+renesas@sang-engineering.com
2 months agodrm/sched: Add a basic test for checking credit limit
Tvrtko Ursulin [Mon, 24 Mar 2025 09:26:33 +0000 (09:26 +0000)]
drm/sched: Add a basic test for checking credit limit

Add a basic test for checking whether scheduler respects the configured
credit limit.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Philipp Stanner <phasta@kernel.org>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250324092633.49746-7-tvrtko.ursulin@igalia.com
2 months agodrm/sched: Add a basic test for modifying entities scheduler list
Tvrtko Ursulin [Mon, 24 Mar 2025 09:26:32 +0000 (09:26 +0000)]
drm/sched: Add a basic test for modifying entities scheduler list

Add a basic test for exercising modifying the entities scheduler list at
runtime.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Philipp Stanner <phasta@kernel.org>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250324092633.49746-6-tvrtko.ursulin@igalia.com
2 months agodrm/sched: Add basic priority tests
Tvrtko Ursulin [Mon, 24 Mar 2025 09:26:31 +0000 (09:26 +0000)]
drm/sched: Add basic priority tests

Add some basic tests for exercising entity priority handling.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Philipp Stanner <phasta@kernel.org>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250324092633.49746-5-tvrtko.ursulin@igalia.com
2 months agodrm/sched: Add a simple timeout test
Tvrtko Ursulin [Mon, 24 Mar 2025 09:26:30 +0000 (09:26 +0000)]
drm/sched: Add a simple timeout test

Add a very simple timeout test which submits a single job and verifies
that the timeout handling will run if the backend failed to complete the
job in time.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Philipp Stanner <phasta@kernel.org>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250324092633.49746-4-tvrtko.ursulin@igalia.com
2 months agodrm/sched: Add scheduler unit testing infrastructure and some basic tests
Tvrtko Ursulin [Mon, 24 Mar 2025 09:26:29 +0000 (09:26 +0000)]
drm/sched: Add scheduler unit testing infrastructure and some basic tests

Implement a mock scheduler backend and add some basic test to exercise the
core scheduler code paths.

Mock backend (kind of like a very simple mock GPU) can either process jobs
by tests manually advancing the "timeline" job at a time, or alternatively
jobs can be configured with a time duration in which case they get
completed asynchronously from the unit test code.

Core scheduler classes are subclassed to support this mock implementation.

The tests added are just a few simple submission patterns.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Suggested-by: Philipp Stanner <phasta@kernel.org>
Cc: Christian König <christian.koenig@amd.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Philipp Stanner <phasta@kernel.org>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250324092633.49746-3-tvrtko.ursulin@igalia.com
2 months agodrm: Move some options to separate new Kconfig
Tvrtko Ursulin [Mon, 24 Mar 2025 09:26:28 +0000 (09:26 +0000)]
drm: Move some options to separate new Kconfig

Move some options out into a new debug specific kconfig file in order to
make things a bit cleaner.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Philipp Stanner <phasta@kernel.org>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250324092633.49746-2-tvrtko.ursulin@igalia.com
2 months agodrm/probe-helper: Do not fail from drmm_kms_helper_poll_init()
Thomas Zimmermann [Mon, 3 Mar 2025 14:52:58 +0000 (15:52 +0100)]
drm/probe-helper: Do not fail from drmm_kms_helper_poll_init()

Failing to set up connector polling is not significant enough to
fail device probing. Print a warning and return nothing from the
init helper.

This only affects the managed init function. The unmanaged init
already never fails with an error.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250303145604.62962-4-tzimmermann@suse.de
2 months agodrm/udl: Switch poll helpers to managed cleanup
Thomas Zimmermann [Mon, 3 Mar 2025 14:52:57 +0000 (15:52 +0100)]
drm/udl: Switch poll helpers to managed cleanup

Call drmm_kms_helper_poll_init() to set up managed cleanup for
connector polling.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250303145604.62962-3-tzimmermann@suse.de
2 months agodrm/udl: Unregister device before cleaning up on disconnect
Thomas Zimmermann [Mon, 3 Mar 2025 14:52:56 +0000 (15:52 +0100)]
drm/udl: Unregister device before cleaning up on disconnect

Disconnecting a DisplayLink device results in the following kernel
error messages

[   93.041748] [drm:udl_urb_completion [udl]] *ERROR* udl_urb_completion - nonzero write bulk status received: -115
[   93.055299] [drm:udl_submit_urb [udl]] *ERROR* usb_submit_urb error fffffffe
[   93.065363] [drm:udl_urb_completion [udl]] *ERROR* udl_urb_completion - nonzero write bulk status received: -115
[   93.078207] [drm:udl_submit_urb [udl]] *ERROR* usb_submit_urb error fffffffe

coming from KMS poll helpers. Shutting down poll helpers runs them
one final time when the USB device is already gone.

Run drm_dev_unplug() first in udl's USB disconnect handler. Udl's
polling code already handles disconnects gracefully if the device has
been marked as unplugged.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: b1a981bd5576 ("drm/udl: drop drm_driver.release hook")
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v5.8+
Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250303145604.62962-2-tzimmermann@suse.de
2 months agodrm/bridge: fsl-ldb: make warning message more informative
Luca Ceresoli [Thu, 6 Mar 2025 17:28:41 +0000 (18:28 +0100)]
drm/bridge: fsl-ldb: make warning message more informative

This warning notifies a clock was set to an inaccurate value. Modify the
string to also show the clock name.

While doing that also rewrap the entire function call.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Acked-by: Liu Ying <victor.liu@nxp.com>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250306-drm-two-ldb-improvements-v1-2-f139d768b92c@bootlin.com
2 months agodrm/bridge: imx8qxp-ldb: cleanup return value
Luca Ceresoli [Thu, 6 Mar 2025 17:28:40 +0000 (18:28 +0100)]
drm/bridge: imx8qxp-ldb: cleanup return value

'ret' can only be 0 at this point, being preceded by a 'if (ret) return
ret;'. So return 0 for clarity.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Liu Ying <victor.liu@nxp.com>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250306-drm-two-ldb-improvements-v1-1-f139d768b92c@bootlin.com
2 months agodrm/v3d: Use V3D_SMS registers for power on/off and reset on V3D 7.x
Maíra Canal [Tue, 18 Mar 2025 01:01:13 +0000 (22:01 -0300)]
drm/v3d: Use V3D_SMS registers for power on/off and reset on V3D 7.x

In addition to the standard reset controller, V3D 7.x requires configuring
the V3D_SMS registers for proper power on/off and reset. Add the new
registers to `v3d_regs.h` and ensure they are properly configured during
device probing, removal, and reset.

This change fixes GPU reset issues on the Raspberry Pi 5 (BCM2712).
Without exposing these registers, a GPU reset causes the GPU to hang,
stopping any further job execution and freezing the desktop GUI. The same
issue occurs when unloading and loading the v3d driver.

Link: https://github.com/raspberrypi/linux/issues/6660
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250317-v3d-gpu-reset-fixes-v6-5-f3ee7717ed17@igalia.com
2 months agodt-bindings: gpu: v3d: Add V3D driver maintainer as DT maintainer
Maíra Canal [Tue, 18 Mar 2025 01:01:12 +0000 (22:01 -0300)]
dt-bindings: gpu: v3d: Add V3D driver maintainer as DT maintainer

As established in commit 89d04995f76c ("MAINTAINERS: Drop Emma Anholt
from all M lines."), Emma is no longer active in the Linux kernel and
dropped the V3D maintainership. Therefore, remove Emma as one of the DT
maintainers and add the current V3D driver maintainer.

Acked-by: Emma Anholt <emma@anholt.net>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250317-v3d-gpu-reset-fixes-v6-4-f3ee7717ed17@igalia.com
2 months agodt-bindings: gpu: v3d: Add SMS register to BCM2712 compatible
Maíra Canal [Tue, 18 Mar 2025 01:01:11 +0000 (22:01 -0300)]
dt-bindings: gpu: v3d: Add SMS register to BCM2712 compatible

V3D 7.1 exposes a new register block, called V3D_SMS. As BCM2712 has a
V3D 7.1 core, add a new register item to its compatible. Similar to the
GCA, which is specific for V3D 3.3, SMS should only be added for V3D 7.1
variants (such as brcm,2712-v3d).

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250317-v3d-gpu-reset-fixes-v6-3-f3ee7717ed17@igalia.com
2 months agodt-bindings: gpu: v3d: Add per-compatible register restrictions
Maíra Canal [Tue, 18 Mar 2025 01:01:10 +0000 (22:01 -0300)]
dt-bindings: gpu: v3d: Add per-compatible register restrictions

In order to enforce per-SoC register rules, add per-compatible
restrictions. For example, V3D 3.3 (used in brcm,7268-v3d) has a cache
controller (GCA), which is not present in other V3D generations. Declaring
these differences helps ensure the DTB accurately reflect the hardware
design.

The example was using an incorrect order for the register names. This
commit corrects that by enforcing the order established in the register
items description.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250317-v3d-gpu-reset-fixes-v6-2-f3ee7717ed17@igalia.com
2 months agodrm/v3d: Associate a V3D tech revision to all supported devices
Maíra Canal [Tue, 18 Mar 2025 01:01:09 +0000 (22:01 -0300)]
drm/v3d: Associate a V3D tech revision to all supported devices

The V3D driver currently determines the GPU tech version (33, 41...)
by reading a register. This approach has worked so far since this
information wasn’t needed before powering on the GPU.

V3D 7.1 introduces new registers that must be written to power on the
GPU, requiring us to know the V3D version beforehand. To address this,
associate each supported SoC with the corresponding VideoCore GPU version
as part of the device data.

To prevent possible mistakes, add an assertion to verify that the version
specified in the device data matches the one reported by the hardware.
If there is a mismatch, the kernel will trigger a warning.

With the goal of maintaining consistency around the driver, use `enum
v3d_gen` to assign values to `v3d->ver` and for comparisons with other
V3D generations. Note that all mentions of unsupported or non-existing V3D
generations (such as V3D 4.0) were removed by this commit and replaced
with supported generations without functional changes.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Stefan Wahren <wahrenst@gmx.net>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250317-v3d-gpu-reset-fixes-v6-1-f3ee7717ed17@igalia.com
3 months agodrm/bridge: ti-sn65dsi86: Remove drm_encoder->crtc use
Maxime Ripard [Thu, 13 Mar 2025 12:00:10 +0000 (13:00 +0100)]
drm/bridge: ti-sn65dsi86: Remove drm_encoder->crtc use

The TI sn65dsi86 driver follows the drm_encoder->crtc pointer that is
deprecated and shouldn't be used by atomic drivers.

Fortunately, the atomic hooks provide the drm_atomic_state and we can
access our current CRTC from that, going from the bridge to its encoder,
to its connector, and to its CRTC.

This bridge driver uses the atomic hooks already, but dereferences the
drm_encoder->crtc pointer in functions that don't have access to it.

Let's rework the driver to pass the state where needed, and remove the
need for the drm_encoder->crtc dereference.

Reviewed-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-16-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/bridge: tc358768: Convert to atomic helpers
Maxime Ripard [Thu, 13 Mar 2025 12:00:09 +0000 (13:00 +0100)]
drm/bridge: tc358768: Convert to atomic helpers

The tc358768 driver follows the drm_encoder->crtc pointer that is
deprecated and shouldn't be used by atomic drivers.

Fortunately, the atomic hooks provide the drm_atomic_state and we can
access our current CRTC from that, going from the bridge to its encoder,
to its connector, and to its CRTC.

Let's convert this bridge driver to atomic so we can get rid of the
drm_encoder->crtc dereference.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-15-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/bridge: tc358768: Stop disabling when failing to enable
Maxime Ripard [Thu, 13 Mar 2025 12:00:08 +0000 (13:00 +0100)]
drm/bridge: tc358768: Stop disabling when failing to enable

The tc358768 bridge driver, if enabling it fails, tries to disable it.
This is pretty uncommon in bridge drivers, and also stands in the way
for further reworks.

Worse, since pre_enable and enable aren't expected to fail, disable and
post_disable might be called twice: once to handle the failure, and once
to actually disable the bridge.

Since post_disable uses regulators and clocks, this would lead to enable
count imbalances.

In order to prevent that imbalance, and to allow further reworks, let's
drop the calls to disable and post_disable, but keep the warning to let
users know about what's going on.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-14-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/bridge: tc358775: Switch to atomic commit
Maxime Ripard [Thu, 13 Mar 2025 12:00:07 +0000 (13:00 +0100)]
drm/bridge: tc358775: Switch to atomic commit

The tc358775 driver follows the drm_encoder->crtc pointer that is
deprecated and shouldn't be used by atomic drivers.

Fortunately, the atomic hooks provide the drm_atomic_state and we can
access our current CRTC from that, going from the bridge to its encoder,
to its connector, and to its CRTC.

Let's convert this bridge driver to atomic so we can get rid of the
drm_encoder->crtc dereference.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-13-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/bridge: cdns-csi: Switch to atomic helpers
Maxime Ripard [Thu, 13 Mar 2025 12:00:06 +0000 (13:00 +0100)]
drm/bridge: cdns-csi: Switch to atomic helpers

The Cadence DSI driver follows the drm_encoder->crtc pointer that is
deprecated and shouldn't be used by atomic drivers.

Fortunately, the atomic hooks provide the drm_atomic_state and we can
access our current CRTC from that, going from the bridge to its encoder,
to its connector, and to its CRTC.

Let's convert this bridge driver to atomic so we can get rid of the
drm_encoder->crtc dereference.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-12-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/bridge: Introduce drm_bridge_is_atomic() helper
Maxime Ripard [Thu, 13 Mar 2025 12:00:05 +0000 (13:00 +0100)]
drm/bridge: Introduce drm_bridge_is_atomic() helper

We test for whether the bridge is atomic in several places in the source
code, so let's consolidate them.

Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-11-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/bridge: ti-sn65dsi83: Switch to drm_bridge_helper_reset_crtc
Maxime Ripard [Thu, 13 Mar 2025 12:00:04 +0000 (13:00 +0100)]
drm/bridge: ti-sn65dsi83: Switch to drm_bridge_helper_reset_crtc

Now that we have a helper for bridge drivers to call to reset the output
pipeline, let's use it.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Herve Codina <herve.codina@bootlin.com>
Tested-by: Herve Codina <herve.codina@bootlin.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-10-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/tests: bridge: Provide tests for drm_bridge_helper_reset_crtc
Maxime Ripard [Thu, 13 Mar 2025 12:00:03 +0000 (13:00 +0100)]
drm/tests: bridge: Provide tests for drm_bridge_helper_reset_crtc

Let's provide a bunch of kunit tests to make sure
drm_bridge_helper_reset_crtc() works as expected.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-9-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/bridge: Add helper to reset bridge pipeline
Maxime Ripard [Thu, 13 Mar 2025 12:00:02 +0000 (13:00 +0100)]
drm/bridge: Add helper to reset bridge pipeline

Let's provide an helper to make it easier for bridge drivers to
power-cycle their bridge.

In order to avoid a circular dependency between that new helper and
drm_atomic_helper_reset_crtc(), this new helper will be in a
drm_bridge_helper.c file to follow the pattern we have for other
objects.

Reviewed-by: Herve Codina <herve.codina@bootlin.com>
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
Tested-by: Herve Codina <herve.codina@bootlin.com>
Co-developed-by: Simona Vetter <simona.vetter@intel.com>
Signed-off-by: Simona Vetter <simona.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-8-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/tests: Create tests for drm_atomic
Maxime Ripard [Thu, 13 Mar 2025 12:00:01 +0000 (13:00 +0100)]
drm/tests: Create tests for drm_atomic

We don't have a set of kunit tests for the functions under drm_atomic.h.
Let's use the introduction of drm_atomic_get_connector_for_encoder() to
create some tests for it and thus create that set.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-7-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/tests: hdmi_state_helpers: Switch to new helper
Maxime Ripard [Thu, 13 Mar 2025 12:00:00 +0000 (13:00 +0100)]
drm/tests: hdmi_state_helpers: Switch to new helper

We introduced a new helper that supersedes the light_up_connector()
function in drm_hdmi_state_helper_test, so let's convert all our tests
to it.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-6-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/tests: helpers: Create new helper to enable output
Maxime Ripard [Thu, 13 Mar 2025 11:59:59 +0000 (12:59 +0100)]
drm/tests: helpers: Create new helper to enable output

We'll need the HDMI state tests light_up_connector() function in more
tests, so let's promote it to a helper.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-5-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/atomic: Introduce helper to lookup connector by encoder
Maxime Ripard [Thu, 13 Mar 2025 11:59:58 +0000 (12:59 +0100)]
drm/atomic: Introduce helper to lookup connector by encoder

With the bridges switching over to drm_bridge_connector, the direct
association between a bridge driver and its connector was lost.

This is mitigated for atomic bridge drivers by the fact you can access
the encoder, and then call drm_atomic_get_old_connector_for_encoder() or
drm_atomic_get_new_connector_for_encoder() with drm_atomic_state.

This was also made easier by providing drm_atomic_state directly to all
atomic hooks bridges can implement.

However, bridge drivers don't have a way to access drm_atomic_state
outside of the modeset path, like from the hotplug interrupt path or any
interrupt handler.

Let's introduce a function to retrieve the connector currently assigned
to an encoder, without using drm_atomic_state, to make these drivers'
life easier.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
Tested-by: Herve Codina <herve.codina@bootlin.com>
Co-developed-by: Simona Vetter <simona.vetter@intel.com>
Signed-off-by: Simona Vetter <simona.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-4-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/tests: Add kunit tests for bridges
Maxime Ripard [Thu, 13 Mar 2025 11:59:57 +0000 (12:59 +0100)]
drm/tests: Add kunit tests for bridges

None of the drm_bridge function have kunit tests so far. Let's change
that, starting with drm_bridge_get_current_state().

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-3-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/bridge: Provide a helper to retrieve current bridge state
Maxime Ripard [Thu, 13 Mar 2025 11:59:56 +0000 (12:59 +0100)]
drm/bridge: Provide a helper to retrieve current bridge state

The current bridge state is accessible from the drm_bridge structure,
but since it's fairly indirect it's not easy to figure out.

Provide a helper to retrieve it.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-2-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
3 months agodrm/bridge: Add encoder parameter to drm_bridge_funcs.attach
Maxime Ripard [Thu, 13 Mar 2025 11:59:55 +0000 (12:59 +0100)]
drm/bridge: Add encoder parameter to drm_bridge_funcs.attach

The drm_bridge structure contains an encoder pointer that is widely used
by bridge drivers. This pattern is largely documented as deprecated in
other KMS entities for atomic drivers.

However, one of the main use of that pointer is done in attach to just
call drm_bridge_attach on the next bridge to add it to the bridge list.
While this dereferences the bridge->encoder pointer, it's effectively
the same encoder the bridge was being attached to.

We can make it more explicit by adding the encoder the bridge is
attached to to the list of attach parameters. This also removes the need
to dereference bridge->encoder in most drivers.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-1-511c54a604fb@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>