Thomas Zimmermann [Tue, 1 Apr 2025 09:37:14 +0000 (11:37 +0200)]
drm/sysfb: Merge primary-plane functions
Merge the primary plane code of ofdrm and simpledrm. Replace the
plane implementation in each driver with the shared helpers. Set
up driver callbacks and format modifiers with initializer macros.
The plane code in ofdrm and simpledrm is very similar. Ofdrm has a
more sophisticated implementation of atomic_disable, which clears
individual scanlines. The code in simpledrm clears the whole buffer
at once. Take the ofdrm version.
Simpledrm supports get_scanout_buffer. Import it into the shared
helpers, which makes it available in ofdrm.
The supported formats are all native formats plus an optional enulated
XRGB8888 if that's not already a native format. Provide an initializer
macro that computes the size of the formats array.
Thomas Zimmermann [Tue, 1 Apr 2025 09:37:13 +0000 (11:37 +0200)]
drm/sysfb: Merge CRTC functions
Merge the CRTC functions of ofdrm and simpledrm. Replace the code
in each driver with the shared helpers. Set up callbacks with
initializer macros.
Ofdrm supports a gamma LUT, while simpledrm does not. So far ofdrm's
LUT size has been hard-coded in the driver CRTC's atomic_check helper.
Now pass the size of the LUT to the sysfb device. Ofdrm's custom
atomic_flush is still required to apply changes to the LUT. Simpledrm
passes a LUT size of 0, which disables the gamma LUT.
Thomas Zimmermann [Tue, 1 Apr 2025 09:37:12 +0000 (11:37 +0200)]
drm/sysfb: Maintain CRTC state in struct drm_sysfb_crtc_state
Move ofdrm's struct ofdrm_crtc_state plus functions to sysfb
helpers and rename everything to drm_sysfb_crtc_state.
The sysfb CRTC state is a regular CRTC state with information on
the primary plane's color format, as required for color management.
Helpers for sysfb planes will later set this up automatically.
In ofdrm and simpledrm, replace existing code with the new helpers.
Ofdrm continues to use the CRTC state for color management. This
has no effect on simpledrm.
Thomas Zimmermann [Tue, 1 Apr 2025 09:37:11 +0000 (11:37 +0200)]
drm/sysfb: Merge connector functions
Merge the connector functions of ofdrm and simpledrm. Replace the
code in each driver with the shared helpers. Set up callbacks with
initializer macros.
No effective code changes. The sysfb connector only returns the
preconfigured display mode.
Thomas Zimmermann [Tue, 1 Apr 2025 09:37:09 +0000 (11:37 +0200)]
drm/sysfb: Provide single mode-init helper
Merge the mode-init functions of ofdrm and simpledrm to the new helper
drm_sysfb_mode(). Also implement the DPI defaults there. Replace the
code in each driver with the shared helper.
Thomas Zimmermann [Tue, 1 Apr 2025 09:37:08 +0000 (11:37 +0200)]
drm/sysfb: Add struct drm_sysfb_device
Add struct drm_sysfb_device that stores the system display's hardware
settings. Further helpers for the mode-setting pipeline will use these
fields. Convert ofdrm and simpledrm by embedding the sysfb device in
their device structs.
Thomas Zimmermann [Tue, 1 Apr 2025 09:37:07 +0000 (11:37 +0200)]
drm: Move sysfb drivers into separate subdirectory
The ofdrm and simpledrm drivers are special as they operate on
externally provided framebuffers. Move them into their own sub-
directory. Will let them share common code.
Thomas Zimmermann [Tue, 1 Apr 2025 09:37:05 +0000 (11:37 +0200)]
drm/ofdrm: Open-code drm_simple_encoder_init()
The helper drm_simple_encoder_init() is a trivial helper around
drm_encoder_init() and therefore deprecated. Open-code the function
and remove the dependency.
Maxime Ripard [Thu, 3 Apr 2025 13:33:33 +0000 (15:33 +0200)]
drm/vc4: tests: Retry pv-muxing tests when EDEADLK
Some functions used by the HVS->PV muxing tests can return with EDEADLK,
meaning the entire sequence should be restarted. It's not a fatal error
and we should treat it as a recoverable error, and recover, instead of
failing the test like we currently do.
Maxime Ripard [Thu, 3 Apr 2025 13:33:32 +0000 (15:33 +0200)]
drm/vc4: tests: Stop allocating the state in test init
The vc4-pv-muxing-combinations and vc5-pv-muxing-combinations test
suites use a common test init function which, in part, allocates the
drm atomic state the test will use.
That allocation relies on drm_kunit_helper_atomic_state_alloc(), and
thus requires a struct drm_modeset_acquire_ctx. This context will then
be stored in the allocated state->acquire_ctx field.
However, the context is local to the test init function, and is cleared
as soon as drm_kunit_helper_atomic_state_alloc() is done. We thus end up
with an dangling pointer to a cleared context in state->acquire_ctx for
our test to consumes.
We should really allocate the context and the state in the test
functions, so we can also control when we're done with it.
Maxime Ripard [Thu, 3 Apr 2025 13:33:30 +0000 (15:33 +0200)]
drm/vc4: tests: Use return instead of assert
The vc4_mock_atomic_add_output() and vc4_mock_atomic_del_output() assert
that the functions they are calling didn't fail. Since some of them can
return EDEADLK, we can't properly deal with it.
Since both functions are expected to return an int, and all caller check
the return value, let's just properly propagate the errors when they
occur.
With that move the increment of the sbuf32 pointer to the end of the
loop, instead of inside the array list initializer, where the
order/sequence of the sbuf32 pointer modifications is not defined.
Fixes: 58523a25cbf7 ("drm/format-helper: Optimize 32-to-24-bpp conversion") Fixes: 3f31a017ddbc ("drm/format-helper: Optimize 32-to-16-bpp conversion") Fixes: 65931bbc5177 ("drm/format-helper: Optimize 32-to-8-bpp conversion") Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: Jocelyn Falempe <jfalempe@redhat.com> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://lore.kernel.org/r/20250402104430.142398-2-matthew.auld@intel.com
Kieran Bingham [Sun, 30 Mar 2025 10:23:53 +0000 (11:23 +0100)]
drm: renesas: Extend RZ/G2L supported KMS formats
The RZ/G2L driver utilises the VSPD to read data from input sources.
The rzg2l_du_kms component lists a restricted subset of the capabilities
of the VSPD which prevents additional formats from being used for
display planes.
The supported display plane formats are mapped in rzg2l_du_vsp_formats[].
Extend the rzg2l_du_format_infos[] table with the corresponding mappings
between the supported DRM formats and the formats exposed by the VSP in
rzg2l_du_vsp_formats, maintaining the same ordering in both tables.
The RPF module on VSPD supports various format conversion and send the
image data to BRS(Blend ROP Sub Unit) for further processing.
Laurent Pinchart [Fri, 21 Mar 2025 10:46:15 +0000 (12:46 +0200)]
drm: renesas: rz-du: Support dmabuf import
The rz-du driver uses GEM DMA helpers, but does not implement the
drm_driver .gem_prime_import_sg_table operation. This prevents
importing dmabufs. Fix it by implementing the missing operation using
the DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE() helper macro.
Biju Das [Tue, 27 Aug 2024 16:37:24 +0000 (17:37 +0100)]
drm: renesas: rz-du: Add Kconfig dependency between RZG2L_DU and RZG2L_MIPI_DSI
Add Kconfig dependency between RZG2L_DU and RZG2L_MIPI_DSI, so that
DSI module has functional dependency on DU. It is similar way that
the R-Car MIPI DSI encoder is handled.
While at it drop ARCH_RENESAS dependency as DRM_RZG2L_DU depend on
ARCH_RZG2L.
drm/shmem-helper: Fix unsetting shmem vaddr while vmap refcount > 0
We switched to use refcount_t for vmaps and missed to change the vunmap
code to properly unset the vmap pointer, which is now cleared while vmap's
refcount > 0. Clear the cached vmap pointer only when refcounting drops to
zero to fix the bug.
Fixes: e1fc39a92332 ("drm/shmem-helper: Use refcount_t for vmap_use_count") Reported-by: Lucas De Marchi <lucas.demarchi@intel.com> Closes: https://lore.kernel.org/dri-devel/20250403105053.788b0f6e@collabora.com/T/#m3dca6d81bedc8d6146a56b82694624fbc6fa4c96 Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Tested-by: Lucas De Marchi <lucas.demarchi@intel.com> Link: https://lore.kernel.org/r/20250403142633.484660-1-dmitry.osipenko@collabora.com
-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/dispnv50/disp.c:779:47: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
-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/nouveau_svm.c:724:44: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
-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/nouveau_fence.c:188:38: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
Imre Deak [Tue, 1 Apr 2025 10:38:46 +0000 (13:38 +0300)]
drm/dp_mst: Use drm_dp_dpcd_write_data() to write GUID for non-root MST branch devices
drm_dp_dpcd_write_data() can be used to write the GUID for a non-root
MST branch device, similarly to writing the GUID to a root MST branch
device, do so.
Imre Deak [Tue, 1 Apr 2025 10:38:45 +0000 (13:38 +0300)]
drm/dp_mst: Fix GUID DPCD write to non-root MST branch devices
The return value on success of drm_dp_send_dpcd_write() called for
non-root MST branch devices from drm_dp_check_mstb_guid() is the number
of bytes transferred. Atm this return value (in case of a complete read)
will be regarded incorrectly as an error by the caller of
drm_dp_check_mstb_guid(). Fix this by converting the return value for a
complete read to the expected success code (0) and for a partial read to
a failure code (-EPROTO).
Fixes: 2554da0de3e8 ("drm/display: dp-mst-topology: use new DCPD access helpers") Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Cc: Lyude Paul <lyude@redhat.com> Reviewed-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Lyude Paul <lyude@redhat.com> Signed-off-by: Imre Deak <imre.deak@intel.com> Link: https://lore.kernel.org/r/20250401103846.686408-1-imre.deak@intel.com
Lyude Paul [Mon, 31 Mar 2025 22:23:55 +0000 (18:23 -0400)]
drm/mode_config: Make drm_mode_config.(max|min)_(width|height) unsigned
It doesn't make much sense to allow devices to specify their min/max
resolution as signed integers, and in Rust with CONFIG_RUST_OVERFLOW_CHECKS
enabled this provides us actual over/underflow checks. Similarly, it
doesn't really make much sense for us to allow devices to specify their
minimum/maximum resolution as signed.
Signed-off-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Maxime Ripard <mripard@kernel.org> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Thomas Zimmermann <tzimmermann@suse.de> Link: https://lore.kernel.org/r/20250331222556.454334-3-lyude@redhat.com
Lyude Paul [Mon, 31 Mar 2025 22:23:54 +0000 (18:23 -0400)]
drm/edid: Use unsigned int in drm_add_modes_noedid()
A negative resolution doesn't really make any sense, so let's make these
parameters unsigned. In C this doesn't make much of a difference, but Rust
is stricter about signed/unsigned casts and additionally can check for
arithmetic over/underflows if CONFIG_RUST_OVERFLOW_CHECKS is enabled.
Signed-off-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Maxime Ripard <mripard@kernel.org> Cc: Thomas Zimmermann <tzimmermann@suse.de> Link: https://lore.kernel.org/r/20250331222556.454334-2-lyude@redhat.com
MAINTAINERS: Add Dmitry Osipenko as drm/virtio co-maintainer
I was helping to co-maintain VirtIO-GPU driver in drm-misc with
permission from Gerd Hoffmann for past 2 years and would like to
receive new patches directly into my inbox. Add myself as co-maintainer.
Rob Clark [Tue, 1 Apr 2025 15:57:58 +0000 (08:57 -0700)]
drm/syncobj: Extend EXPORT_SYNC_FILE for timeline syncobjs
Add support for exporting a dma_fence fd for a specific point on a
timeline. This is needed for vtest/vpipe[1][2] to implement timeline
syncobj support, as it needs a way to turn a point on a timeline back
into a dma_fence fd. It also closes an odd omission from the syncobj
UAPI.
Anusha Srivatsa [Mon, 31 Mar 2025 15:15:26 +0000 (11:15 -0400)]
drm/panel: Add refcount support
Allocate panel via reference counting. Add _get() and _put() helper
functions to ensure panel allocations are refcounted. Avoid use after
free by ensuring panel pointer is valid and can be usable till the last
reference is put.
Anusha Srivatsa [Mon, 31 Mar 2025 15:15:25 +0000 (11:15 -0400)]
drm/panel: Add new helpers for refcounted panel allocatons
Introduce reference counted allocations for panels to avoid
use-after-free. The patch adds the macro devm_drm_bridge_alloc()
to allocate a new refcounted panel. Followed the documentation for
drmm_encoder_alloc() and devm_drm_dev_alloc and other similar
implementations for this purpose.
For ease of implementation, existing line-conversion functions
for 8-bit formats write each pixel individually. Optimize the
performance by writing multiple pixels in a single 32-bit store.
For ease of implementation, existing line-conversion functions
for 16-bit formats write each pixel individually. Optimize the
performance by writing multiple pixels in single 64-bit and 32-bit
stores.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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
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
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>
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.
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.
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.
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.
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.
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.
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.
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
-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]
-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]
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.
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.
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
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.
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
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.
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.
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.
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.