Ville Syrjälä
1506b10310
drm/msm: Pass along the format info from .fb_create() to drm_helper_mode_fill_fb_struct()
...
Plumb the format info from .fb_create() all the way to
drm_helper_mode_fill_fb_struct() to avoid the redundant
lookups.
For the fbdev case a manual drm_get_format_info() lookup
is needed.
Cc: Rob Clark <robdclark@gmail.com >
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com >
Cc: Dmitry Baryshkov <lumag@kernel.org >
Cc: Sean Paul <sean@poorly.run >
Cc: Marijn Suijten <marijn.suijten@somainline.org >
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de >
Acked-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20250701090722.13645-16-ville.syrjala@linux.intel.com
2025-07-16 20:11:05 +03:00
Ville Syrjälä
a34cc7bf10
drm: Allow the caller to pass in the format info to drm_helper_mode_fill_fb_struct()
...
Soon all drivers should have the format info already available in the
places where they call drm_helper_mode_fill_fb_struct(). Allow it to
be passed along into drm_helper_mode_fill_fb_struct() instead of doing
yet another redundant lookup.
Start by always passing in NULL and still doing the extra lookup.
The actual changes to avoid the lookup will follow.
Done with cocci (with some manual fixups):
@@
identifier dev, fb, mode_cmd;
expression get_format_info;
@@
void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
struct drm_framebuffer *fb,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd)
{
...
- fb->format = get_format_info;
+ fb->format = info ?: get_format_info;
...
}
@@
identifier dev, fb, mode_cmd;
@@
void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
struct drm_framebuffer *fb,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd);
@@
expression dev, fb, mode_cmd;
@@
drm_helper_mode_fill_fb_struct(dev, fb
+ ,NULL
,mode_cmd);
Cc: Alex Deucher <alexander.deucher@amd.com >
Cc: Liviu Dudau <liviu.dudau@arm.com >
Cc: Russell King <linux@armlinux.org.uk >
Cc: Inki Dae <inki.dae@samsung.com >
Cc: Seung-Woo Kim <sw0312.kim@samsung.com >
Cc: Kyungmin Park <kyungmin.park@samsung.com >
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com >
Cc: Rob Clark <robdclark@gmail.com >
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com >
Cc: Dmitry Baryshkov <lumag@kernel.org >
Cc: Sean Paul <sean@poorly.run >
Cc: Marijn Suijten <marijn.suijten@somainline.org >
Cc: Lyude Paul <lyude@redhat.com >
Cc: Danilo Krummrich <dakr@kernel.org >
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com >
Cc: Thierry Reding <thierry.reding@gmail.com >
Cc: Mikko Perttunen <mperttunen@nvidia.com >
Cc: Gerd Hoffmann <kraxel@redhat.com >
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com >
Cc: Gurchetan Singh <gurchetansingh@chromium.org >
Cc: Chia-I Wu <olvaffe@gmail.com >
Cc: Zack Rusin <zack.rusin@broadcom.com >
Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com >
Cc: amd-gfx@lists.freedesktop.org
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: linux-tegra@vger.kernel.org
Cc: virtualization@lists.linux.dev
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de >
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com >
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com >
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20250701090722.13645-6-ville.syrjala@linux.intel.com
2025-07-16 20:04:45 +03:00
Ville Syrjälä
81112eaac5
drm: Pass the format info to .fb_create()
...
Pass along the format information from the top to .fb_create()
so that we can avoid redundant (and somewhat expensive) lookups
in the drivers.
Done with cocci (with some manual fixups):
@@
identifier func =~ ".*create.*";
identifier dev, file, mode_cmd;
@@
struct drm_framebuffer *func(
struct drm_device *dev,
struct drm_file *file,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd)
{
...
(
- const struct drm_format_info *info = drm_get_format_info(...);
|
- const struct drm_format_info *info;
...
- info = drm_get_format_info(...);
)
<...
- if (!info)
- return ...;
...>
}
@@
identifier func =~ ".*create.*";
identifier dev, file, mode_cmd;
@@
struct drm_framebuffer *func(
struct drm_device *dev,
struct drm_file *file,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd)
{
...
}
@find@
identifier fb_create_func =~ ".*create.*";
identifier dev, file, mode_cmd;
@@
struct drm_framebuffer *fb_create_func(
struct drm_device *dev,
struct drm_file *file,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd);
@@
identifier find.fb_create_func;
expression dev, file, mode_cmd;
@@
fb_create_func(dev, file
+ ,info
,mode_cmd)
@@
expression dev, file, mode_cmd;
@@
drm_gem_fb_create(dev, file
+ ,info
,mode_cmd)
@@
expression dev, file, mode_cmd;
@@
drm_gem_fb_create_with_dirty(dev, file
+ ,info
,mode_cmd)
@@
expression dev, file_priv, mode_cmd;
identifier info, fb;
@@
info = drm_get_format_info(...);
...
fb = dev->mode_config.funcs->fb_create(dev, file_priv
+ ,info
,mode_cmd);
@@
identifier dev, file_priv, mode_cmd;
@@
struct drm_mode_config_funcs {
...
struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
struct drm_file *file_priv,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd);
...
};
v2: Fix kernel docs (Laurent)
Fix commit msg (Geert)
Cc: Alex Deucher <alexander.deucher@amd.com >
Cc: Liviu Dudau <liviu.dudau@arm.com >
Cc: Maxime Ripard <mripard@kernel.org >
Cc: Russell King <linux@armlinux.org.uk >
Cc: Inki Dae <inki.dae@samsung.com >
Cc: Seung-Woo Kim <sw0312.kim@samsung.com >
Cc: Kyungmin Park <kyungmin.park@samsung.com >
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com >
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org >
Cc: Philipp Zabel <p.zabel@pengutronix.de >
Cc: Rob Clark <robdclark@gmail.com >
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com >
Cc: Dmitry Baryshkov <lumag@kernel.org >
Cc: Sean Paul <sean@poorly.run >
Cc: Marijn Suijten <marijn.suijten@somainline.org >
Cc: Marek Vasut <marex@denx.de >
Cc: Stefan Agner <stefan@agner.ch >
Cc: Lyude Paul <lyude@redhat.com >
Cc: Danilo Krummrich <dakr@kernel.org >
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com >
Cc: Dave Airlie <airlied@redhat.com >
Cc: Gerd Hoffmann <kraxel@redhat.com >
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com >
Cc: Biju Das <biju.das.jz@bp.renesas.com >
Cc: Sandy Huang <hjc@rock-chips.com >
Cc: "Heiko Stübner" <heiko@sntech.de >
Cc: Andy Yan <andy.yan@rock-chips.com >
Cc: Thierry Reding <thierry.reding@gmail.com >
Cc: Mikko Perttunen <mperttunen@nvidia.com >
Cc: Dave Stevenson <dave.stevenson@raspberrypi.com >
Cc: "Maíra Canal" <mcanal@igalia.com >
Cc: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com >
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com >
Cc: Gurchetan Singh <gurchetansingh@chromium.org >
Cc: Chia-I Wu <olvaffe@gmail.com >
Cc: Zack Rusin <zack.rusin@broadcom.com >
Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com >
Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com >
Cc: amd-gfx@lists.freedesktop.org
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: virtualization@lists.linux.dev
Cc: spice-devel@lists.freedesktop.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com >
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de >
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Acked-by: Liviu Dudau <liviu.dudau@arm.com >
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com >
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20250701090722.13645-5-ville.syrjala@linux.intel.com
2025-07-16 20:03:14 +03:00
Ville Syrjälä
0e7d5874fb
drm: Pass pixel_format+modifier directly to drm_get_format_info()
...
Decouple drm_get_format_info() from struct drm_mode_fb_cmd2 and just
pass the pixel format+modifier combo in by hand.
We may want to use drm_get_format_info() outside of the normal
addfb paths where we won't have a struct drm_mode_fb_cmd2, and
creating a temporary one just for this seems silly.
Done with cocci:
@@
identifier dev, mode_cmd;
@@
struct drm_format_info *
drm_get_format_info(struct drm_device *dev,
- const struct drm_mode_fb_cmd2 *mode_cmd
+ u32 pixel_format, u64 modifier
)
{
<...
(
- mode_cmd->pixel_format
+ pixel_format
|
- mode_cmd->modifier[0]
+ modifier
)
...>
}
@@
identifier dev, mode_cmd;
@@
struct drm_format_info *
drm_get_format_info(struct drm_device *dev,
- const struct drm_mode_fb_cmd2 *mode_cmd
+ u32 pixel_format, u64 modifier
);
@@
expression dev, mode_cmd;
@@
- drm_get_format_info(dev, mode_cmd)
+ drm_get_format_info(dev, mode_cmd->pixel_format, mode_cmd->modifier[0])
v2: Fix kernel docs (Laurent)
Drop drm_mode_fb_cmd2 forward declaration (Thomas)
Cc: Liviu Dudau <liviu.dudau@arm.com >
Cc: Russell King <linux@armlinux.org.uk >
Cc: Inki Dae <inki.dae@samsung.com >
Cc: Seung-Woo Kim <sw0312.kim@samsung.com >
Cc: Kyungmin Park <kyungmin.park@samsung.com >
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com >
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org >
Cc: Philipp Zabel <p.zabel@pengutronix.de >
Cc: Rob Clark <robdclark@gmail.com >
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com >
Cc: Dmitry Baryshkov <lumag@kernel.org >
Cc: Sean Paul <sean@poorly.run >
Cc: Marijn Suijten <marijn.suijten@somainline.org >
Cc: Marek Vasut <marex@denx.de >
Cc: Stefan Agner <stefan@agner.ch >
Cc: Lyude Paul <lyude@redhat.com >
Cc: Danilo Krummrich <dakr@kernel.org >
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com >
Cc: Alex Deucher <alexander.deucher@amd.com >
Cc: Sandy Huang <hjc@rock-chips.com >
Cc: "Heiko Stübner" <heiko@sntech.de >
Cc: Andy Yan <andy.yan@rock-chips.com >
Cc: Thierry Reding <thierry.reding@gmail.com >
Cc: Mikko Perttunen <mperttunen@nvidia.com >
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: amd-gfx@lists.freedesktop.org
Cc: linux-tegra@vger.kernel.org
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de >
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com >
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com >
Link: https://patchwork.freedesktop.org/patch/msgid/20250701090722.13645-3-ville.syrjala@linux.intel.com
2025-07-16 20:01:13 +03:00
Andy Yan
5d156a9c3d
drm/bridge: Pass down connector to drm bridge detect hook
...
In some application scenarios, we hope to get the corresponding
connector when the bridge's detect hook is invoked.
In most cases, we can get the connector by drm_atomic_get_connector_for_encoder
if the encoder attached to the bridge is enabled, however there will
still be some scenarios where the detect hook of the bridge is called
but the corresponding encoder has not been enabled yet. For instance,
this occurs when the device is hot plug in for the first time.
Since the call to bridge's detect is initiated by the connector, passing
down the corresponding connector directly will make things simpler.
Signed-off-by: Andy Yan <andy.yan@rock-chips.com >
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Link: https://lore.kernel.org/r/20250703125027.311109-3-andyshrk@163.com
[DB: added the chunk to the cdn-dp driver]
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
2025-07-14 18:23:18 +03:00
Andy Yan
02bb63d1a5
drm/bridge: Make dp/hdmi_audio_* callback keep the same paramter order with get_modes
...
Make the dp/hdmi_audio_* callback maintain the same parameter order as
get_modes and edid_read: first the bridge, then the connector.
Signed-off-by: Andy Yan <andy.yan@rock-chips.com >
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Link: https://lore.kernel.org/r/20250703125027.311109-2-andyshrk@163.com
[DB: added the chunk to the cdn-dp driver]
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
2025-07-14 18:23:18 +03:00
Rob Clark
8290d37ad2
drm/msm: Small function param doc fix
...
Reported-by: kernel test robot <lkp@intel.com >
Closes: https://lore.kernel.org/oe-kbuild-all/202507032334.9SCwc952-lkp@intel.com/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-05 09:59:12 -07:00
Rob Clark
98f11fd1cf
drm/msm: Take the ioctls away from the KMS-only driver
...
KMS-only drivers should only allocate dumb buffers. The driver custom
ioctls are only meant for the usermode gpu driver (mesa), and not for
general consumption, so they don't make sense for standalone KMS
drivers.
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/662598/
2025-07-05 09:59:12 -07:00
Rob Clark
ee82e5a2c5
drm/msm: Clean up split driver features
...
Avoid the possibility of missing features between the split and unified
drm driver cases by defining DRIVER_FEATURES_GPU / KMS and using those
in the drm_driver initializations.
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/662595/
2025-07-05 09:59:12 -07:00
Dmitry Baryshkov
217ed15bd3
drm/msm: enable separate binding of GPU and display devices
...
There are cases when we want to have separate DRM devices for GPU and
display pipelines.
One example is development, when it is beneficial to be able to bind the
GPU driver separately, without the display pipeline (and without the
hacks adding "amd,imageon" to the compatible string).
Another example is some of Qualcomm platforms, which have two MDSS
units, but only one GPU. With current approach it is next to impossible
to support this usecase properly, while separate binding allows users to
have three DRM devices: two for MDSS units and a single headless GPU.
Add kernel param msm.separate_gpu_kms, which if set to true forces
creation of separate display and GPU DRM devices. Mesa supports this
setup by using the kmsro wrapper.
The param is disabled by default, in order to be able to test userspace
for the compatibility issues. Simple clients are able to handle this
setup automatically.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/662590/
[Rob: renamed the modparam to separate_gpu_kms, and add missing
DRIVER_GEM_GPUVA]
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-05 07:37:21 -07:00
Dmitry Baryshkov
643515a9cd
drm/msm: rework binding of Imageon GPUs
...
Currently the msm driver creates an extra interim platform device for
Imageon GPUs. This is not ideal, as the device doesn't have
corresponding OF node. If the headless mode is used for newer GPUs, then
the msm_use_mmu() function can not detect corresponding IOMMU devices.
Also the DRM device (although it's headless) is created with modesetting
flags being set.
To solve all these issues, rework the way the Imageon devices are bound.
Remove the interim device, don't register a component and instead use a
cut-down version of the normal functions to probe or remove the driver.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/662584/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-05 07:13:35 -07:00
Dmitry Baryshkov
27c3547323
drm/msm: rearrange symbol selection
...
Move symbol selection to be more fine grained: select DP helpers only if
DP driver is also enabled, move KMS and display helpers to the newly
introduced DRM_MSM_KMS.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/662589/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-05 07:13:35 -07:00
Dmitry Baryshkov
4f89cf40d0
drm/msm: bail out late_init_minor() if it is not a GPU device
...
Both perf and hangrd make sense only for GPU devices. Bail out if we are
registering a KMS-only device.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/662583/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-05 07:13:35 -07:00
Dmitry Baryshkov
98290b0a7d
drm/msm: make it possible to disable KMS-related code.
...
If the Adreno device is used in a headless mode, there is no need to
build all KMS components. Build corresponding parts conditionally, only
selecting them if modeset support is actually required.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/662581/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-05 07:13:35 -07:00
Dmitry Baryshkov
e10e1a4010
drm/msm: move KMS driver data to msm_kms
...
Data for HDMI, DSI and DP blocks only makes sense for the KMS parts of
the driver. Move corresponding data pointers from struct msm_drm_private
to struct msm_kms.
Suggested-by: Abhinav Kumar <quic_abhinavk@quicinc.com >
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/662580/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-05 07:13:35 -07:00
Dmitry Baryshkov
0bb2335f06
drm/msm: get rid of msm_drm_private::num_crtcs
...
Drop superfluous msm_drm_private::num_crtcs in favour of using
drm_mode_config::num_crtc or MAX_CRCS as appropriate.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/662578/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-05 07:13:35 -07:00
Dmitry Baryshkov
9d065a3fef
drm/msm/mdp4: get rid of mdp4_crtc.id
...
There is no reason to store CRTC id, it's a part of the drm_crtc. Drop
this member and use drm_crtc.name for the warning message.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/662576/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-05 07:13:35 -07:00
Dmitry Baryshkov
0c2dda82b1
drm/msm: move helper calls to msm_kms.c
...
Extract two more KMS-related codepieces to msm_kms.c, removing last
pieces of KMS code from msm_drv.c.
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com >
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/662574/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-05 07:13:35 -07:00
Dmitry Baryshkov
a409b78fcd
drm/msm: move wq handling to KMS code
...
The global workqueue is only used for vblanks inside KMS code. Move
allocation / flushing / deallcation of it to msm_kms.c
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/662573/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-05 07:13:35 -07:00
Konrad Dybcio
a452510aad
drm/msm/adreno: Switch to the common UBWC config struct
...
Now that Adreno specifics are out of the way, use the common config
(but leave the HBB hardcoding in place until that is wired up on the
other side).
Acked-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/660985/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-04 17:48:41 -07:00
Konrad Dybcio
709dd2ff23
soc: qcom: ubwc: Add #defines for UBWC swizzle bits
...
Make the values a bit more meaningful.
This commit is intentionally cross-subsystem to ease review, as the
patchset is intended to be merged together, with a maintainer
consensus.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/660981/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-04 17:48:40 -07:00
Konrad Dybcio
8f18e87957
drm/msm/a6xx: Simplify min_acc_len calculation
...
It's only necessary for some lower end parts.
Also rename it to min_acc_len_64b to denote that if set, the minimum
access length is 64 bits, 32b otherwise.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/660977/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-04 17:48:40 -07:00
Konrad Dybcio
b6ce504c71
drm/msm/a6xx: Resolve the meaning of rgb565_predicator
...
It's supposed to be on when the UBWC encoder version is >= 4.0.
Drop the per-GPU assignments.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/660975/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-04 17:48:40 -07:00
Konrad Dybcio
c59e9c966e
drm/msm/a6xx: Replace '2' with BIT(1) in level2_swizzling_dis calc
...
ubwc_swizzle is a bitmask. Check for a bit to make it more obvious.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/660973/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-04 17:48:40 -07:00
Konrad Dybcio
87cfc79dcd
drm/msm/a6xx: Resolve the meaning of UBWC_MODE
...
This bit is set iff the UBWC version is 1.0. That notably does not
include QCM2290's "no UBWC".
This commit is intentionally cross-subsystem to ease review, as the
patchset is intended to be merged together, with a maintainer
consensus.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/660971/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-04 17:48:40 -07:00
Konrad Dybcio
32ef24e51f
drm/msm/a6xx: Simplify uavflagprd_inv detection
...
Instead of setting it on a gpu-per-gpu basis, converge it to the
intended "is A650 family or A7xx".
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/660969/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-04 17:48:39 -07:00
Konrad Dybcio
367380d2b5
drm/msm/a6xx: Resolve the meaning of AMSBC
...
The bit must be set to 1 if the UBWC encoder version is >= 3.0, drop it
as a separate field.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/660967/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-04 17:48:39 -07:00
Konrad Dybcio
560c98b4a4
drm/msm/a6xx: Get a handle to the common UBWC config
...
Start the great despaghettification by getting a pointer to the common
UBWC configuration, which houses e.g. UBWC versions that we need to
make decisions.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/660965/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-04 17:48:39 -07:00
Konrad Dybcio
45a2974157
drm/msm: Use the central UBWC config database
...
As discussed a lot in the past, the UBWC config must be coherent across
a number of IP blocks (currently display and GPU, but it also may/will
concern camera/video as the drivers evolve).
So far, we've been trying to keep the values reasonable in each of the
two drivers separately, but it really make sense to do so centrally,
especially given certain fields (e.g. HBB) may need to be gathered
dynamically.
To reduce room for error, move to fetching the config from a central
source, so that the data programmed into the hardware is consistent
across all multimedia blocks that request it.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/660963/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-04 17:48:39 -07:00
Konrad Dybcio
227d4ce0b0
drm/msm: Offset MDSS HBB value by 13
...
The Adreno part of the driver exposes this value to userspace, and the
SMEM data source also presents a x+13 value. Keep things coherent and
make the value uniform across them.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/660961/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
2025-07-04 17:48:39 -07:00
Rob Clark
6733d8276a
drm/msm: Update register xml
...
Sync register xml from mesa commit eb3e0b7164a3 ("freedreno/a6xx: Split
descriptors out into their own file").
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Acked-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com >
Patchwork: https://patchwork.freedesktop.org/patch/662470/
2025-07-04 17:48:39 -07:00
Rob Clark
b74fae5492
drm/msm: Add VM_BIND throttling
...
A large number of (unsorted or separate) small (<2MB) mappings can cause
a lot of, probably unnecessary, prealloc pages. Ie. a single 4k page
size mapping will pre-allocate 3 pages (for levels 2-4) for the
pagetable. Which can chew up a large amount of unneeded memory. So add
a mechanism to put an upper bound on the # of pre-alloc pages.
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661529/
2025-07-04 17:48:39 -07:00
Rob Clark
3bebfd53af
drm/msm: Defer VMA unmap for fb unpins
...
With the conversion to drm_gpuvm, we lost the lazy VMA cleanup, which
means that fb cleanup/unpin when pageflipping to new scanout buffers
immediately unmaps the scanout buffer. This is costly (with tlbinv,
it can be 4-6ms for a 1080p scanout buffer, and more for higher
resolutions)!
To avoid this, introduce a vma_ref, which is incremented whenever
userspace has a GEM handle or dma-buf fd. When unpinning if the
vm is the kms->vm we defer tearing down the VMA until the vma_ref
drops to zero. If the buffer is still part of a flip-chain then
userspace will be holding some sort of reference to the BO, either
via a GEM handle and/or dma-buf fd. So this avoids unmapping the VMA
when there is a strong possibility that it will be needed again.
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661538/
2025-07-04 17:48:38 -07:00
Rob Clark
8d4c21718c
drm/msm: Bump UAPI version
...
Bump version to signal to userspace that VM_BIND is supported.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661535/
2025-07-04 17:48:38 -07:00
Rob Clark
0a1ff88ec5
drm/msm: use trylock for debugfs
...
This resolves a potential deadlock vs msm_gem_vm_close(). Otherwise for
_NO_SHARE buffers msm_gem_describe() could be trying to acquire the
shared vm resv, while already holding priv->obj_lock. But _vm_close()
might drop the last reference to a GEM obj while already holding the vm
resv, and msm_gem_free_object() needs to grab priv->obj_lock, a locking
inversion.
OTOH this is only for debugfs and it isn't critical if we undercount by
skipping a locked obj. So just use trylock() and move along if we can't
get the lock.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661525/
2025-07-04 17:48:38 -07:00
Rob Clark
05a2496834
drm/msm: Add mmu prealloc tracepoint
...
So we can monitor how many pages are getting preallocated vs how many
get used.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661521/
2025-07-04 17:48:38 -07:00
Rob Clark
0b4339c55e
drm/msm: Add VMA unmap reason
...
Make the VM log a bit more useful by providing a reason for the unmap
(ie. closing VM vs evict/purge, etc)
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661527/
2025-07-04 17:48:38 -07:00
Rob Clark
9edc52967c
drm/msm: Add VM logging for VM_BIND updates
...
When userspace opts in to VM_BIND, the submit no longer holds references
keeping the VMA alive. This makes it difficult to distinguish between
UMD/KMD/app bugs. So add a debug option for logging the most recent VM
updates and capturing these in GPU devcoredumps.
The submitqueue id is also captured, a value of zero means the operation
did not go via a submitqueue (ie. comes from msm_gem_vm_close() tearing
down the remaining mappings when the device file is closed.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661518/
2025-07-04 17:48:38 -07:00
Rob Clark
2e6a8a1fe2
drm/msm: Add VM_BIND ioctl
...
Add a VM_BIND ioctl for binding/unbinding buffers into a VM. This is
only supported if userspace has opted in to MSM_PARAM_EN_VM_BIND.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661524/
2025-07-04 17:48:38 -07:00
Rob Clark
ecfd9fa83f
drm/msm: Split out map/unmap ops
...
With async VM_BIND, the actual pgtable updates are deferred.
Synchronously, a list of map/unmap ops will be generated, but the
actual pgtable changes are deferred. To support that, split out
op handlers and change the existing non-VM_BIND paths to use them.
Note in particular, the vma itself may already be destroyed/freed
by the time an UNMAP op runs (or even a MAP op if there is a later
queued UNMAP). For this reason, the op handlers cannot reference
the vma pointer.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661516/
2025-07-04 17:48:38 -07:00
Rob Clark
e601ea31d6
drm/msm: Support pgtable preallocation
...
Introduce a mechanism to count the worst case # of pages required in a
VM_BIND op.
Note that previously we would have had to somehow account for
allocations in unmap, when splitting a block. This behavior was removed
in commit 33729a5fc0 ("iommu/io-pgtable-arm: Remove split on unmap
behavior)"
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661515/
2025-07-04 17:48:37 -07:00
Rob Clark
2b93efeb83
drm/msm: Support IO_PGTABLE_QUIRK_NO_WARN_ON
...
With user managed VMs and multiple queues, it is in theory possible to
trigger map/unmap errors. These will (in a later patch) mark the VM as
unusable. But we want to tell the io-pgtable helpers not to spam the
log. In addition, in the unmap path, we don't want to bail early from
the unmap, to ensure we don't leave some dangling pages mapped.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661520/
2025-07-04 17:48:37 -07:00
Rob Clark
92395af63a
drm/msm: Add VM_BIND submitqueue
...
This submitqueue type isn't tied to a hw ringbuffer, but instead
executes on the CPU for performing async VM_BIND ops.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661517/
2025-07-04 17:48:37 -07:00
Rob Clark
cefb919cfa
drm/msm: Use DMA_RESV_USAGE_BOOKKEEP/KERNEL
...
Any place we wait for a BO to become idle, we should use BOOKKEEP usage,
to ensure that it waits for _any_ activity.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661506/
2025-07-04 17:48:37 -07:00
Rob Clark
e1341f9145
drm/msm: Extract out syncobj helpers
...
We'll be re-using these for the VM_BIND ioctl.
Also, rename a few things in the uapi header to reflect that syncobj use
is not specific to the submit ioctl.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661512/
2025-07-04 17:48:37 -07:00
Rob Clark
06ebb4f043
drm/msm: rd dumping support for sparse
...
As with devcoredump, we need to iterate the VMAs to figure out what to
dump.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661510/
2025-07-04 17:48:37 -07:00
Rob Clark
af9aa6f316
drm/msm: Crashdump support for sparse
...
In this case, we need to iterate the VMAs looking for ones with
MSM_VMA_DUMP flag.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661504/
2025-07-04 17:48:37 -07:00
Rob Clark
4570dbb8a6
drm/msm: rd dumping prep for sparse mappings
...
Similar to the previous commit, add support for dumping partial
mappings.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661514/
2025-07-04 17:48:37 -07:00
Rob Clark
757cff73e1
drm/msm: Crashdump prep for sparse mappings
...
In this case, userspace could request dumping partial GEM obj mappings.
Also drop use of should_dump() helper, which really only makes sense in
the old submit->bos[] table world.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661496/
2025-07-04 17:48:36 -07:00
Rob Clark
b58e12a66e
drm/msm: Add _NO_SHARE flag
...
Buffers that are not shared between contexts can share a single resv
object. This way drm_gpuvm will not track them as external objects, and
submit-time validating overhead will be O(1) for all N non-shared BOs,
instead of O(n).
Signed-off-by: Rob Clark <robdclark@chromium.org >
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com >
Tested-by: Antonino Maniscalco <antomani103@gmail.com >
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com >
Patchwork: https://patchwork.freedesktop.org/patch/661497/
2025-07-04 17:48:36 -07:00