Skip to content

Conversation

minlexx
Copy link
Member

@minlexx minlexx commented May 12, 2025

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.

Reviewed-by: Maxime Ripard <[email protected]>
Signed-off-by: Anusha Srivatsa <[email protected]>
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.

Reviewed-by: Luca Ceresoli <[email protected]>
Reviewed-by: Maxime Ripard <[email protected]>
Signed-off-by: Anusha Srivatsa <[email protected]>
Start moving to the new refcounted allocations using
the new API devm_drm_panel_alloc(). Deprecate any other
allocation.

Reviewed-by: Luca Ceresoli <[email protected]>
Reviewed-by: Maxime Ripard <[email protected]>
Signed-off-by: Anusha Srivatsa <[email protected]>
…evm_kzalloc()

Start using the new helper that does the refcounted
allocations.

Reviewed-by: Luca Ceresoli <[email protected]>
Reviewed-by: Maxime Ripard <[email protected]>
Signed-off-by: Anusha Srivatsa <[email protected]>
@minlexx minlexx force-pushed the alexeymin/6.15-lavender-panel-test branch from 1bedd34 to 1c49cd8 Compare May 13, 2025 19:30
barni2000 added 2 commits May 14, 2025 01:20
Signed-off-by: Barnabás Czémán <[email protected]>
@minlexx minlexx force-pushed the alexeymin/6.15-lavender-panel-test branch from 1c49cd8 to 0e933db Compare May 13, 2025 22:20
minlexx added 3 commits May 14, 2025 11:51
The driver was made with extensibility in mind, but it is not enough.
In preparation for extending the driver with support for more panels,
stop using arrays of nt36672a_panel_cmd, which incorrectly assumed
that all panels will have init sequences consisting of 2 bytes.
This is not true for all panels using nt36672a controller. Instead,
use dedicated init and shutdown functions for each panel. This allows
for more flexibility, solving at least 2 problems:

 * different DSI commands length for different panels
 * different delays for msleep() calls for different panels

Make it so that each panel can initialize the way it prefers.

Combine init sequences in .on_cmds_1 and .on_cmds_2 into a new init
finction, and code from .off_cmds to new off_cmds function. Struct
nt36672a_panel_cmd and function nt36672a_send_cmds() are no longer
needed, remove them.

While doing this, also switch to moderm multi-api for sending
commands, which greatly simplifies error handling using accumulated
error counter.

This refactoring change should have no functional effect on existing
devices.

Signed-off-by: Alexey Minnekhanov <[email protected]>
Add support for Tianma video mode panel based on nt36672a, used in
Xiaomi Redmi Note 7 smartphone (xiaomi-lavender). Tianma panel is
one of the 3 panel variants that you can find inside xiaomi-lavender.

Signed-off-by: Alexey Minnekhanov <[email protected]>
@minlexx minlexx force-pushed the alexeymin/6.15-lavender-panel-test branch from 0e933db to 7b3ab5b Compare May 14, 2025 18:08
@minlexx
Copy link
Member Author

minlexx commented Jun 14, 2025

This was just for testing. It will be done properly and fully in PR #89

@minlexx minlexx closed this Jun 14, 2025
@minlexx minlexx deleted the alexeymin/6.15-lavender-panel-test branch June 14, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants