[v4,1/5] drm/sun4i: Reject fractional source coordinates without scaler
Commit Message
The layer code programs the scaler whenever the source rectangle has a
fractional offset, since only the scaler can apply a sub-pixel phase.
drm_atomic_helper_check_plane_state() with DRM_PLANE_NO_SCALING doesn't
catch that: it only compares the scaling factor, which may still be
exactly 1.0 with fractional source coordinates.
Channels without a scaler would thus have the non-existent scaler
programmed instead of an error being returned. Reject fractional source
coordinates on such channels.
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
---
drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 24 ++++++++++++++++++++----
drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 24 ++++++++++++++++++++----
2 files changed, 40 insertions(+), 8 deletions(-)
Comments
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/sun4i: missing Fixes trailer for fractional source
coordinate check
--
commit 6372f45de588428ede3ebc1410bcfe779db4f206
Author: Jernej Skrabec <jernej.skrabec@gmail.com>
> drm/sun4i: Reject fractional source coordinates without scaler
>
> The layer code programs the scaler whenever the source rectangle has a
> fractional offset, since only the scaler can apply a sub-pixel phase.
> drm_atomic_helper_check_plane_state() with DRM_PLANE_NO_SCALING doesn't
> catch that: it only compares the scaling factor, which may still be
> exactly 1.0 with fractional source coordinates.
>
> Channels without a scaler would thus have the non-existent scaler
> programmed instead of an error being returned. Reject fractional source
> coordinates on such channels.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
[Severity: Low]
This fixes the scaling check introduced when hardware scaling support was
added to DE2. Should this include:
Fixes: b862a648de3b ("drm/sun4i: Add support for HW scaling to DE2")
On Fri, Nov 20, 2026 at 1:54 AM Jernej Skrabec <jernej.skrabec@gmail.com> wrote:
>
> The layer code programs the scaler whenever the source rectangle has a
> fractional offset, since only the scaler can apply a sub-pixel phase.
> drm_atomic_helper_check_plane_state() with DRM_PLANE_NO_SCALING doesn't
> catch that: it only compares the scaling factor, which may still be
> exactly 1.0 with fractional source coordinates.
>
> Channels without a scaler would thus have the non-existent scaler
> programmed instead of an error being returned. Reject fractional source
> coordinates on such channels.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-by: Chen-Yu Tsai <wens@kernel.org>
@@ -179,10 +179,26 @@ static int sun8i_ui_layer_atomic_check(struct drm_plane *plane,
max_scale = SUN8I_UI_SCALER_SCALE_MAX;
}
- return drm_atomic_helper_check_plane_state(new_plane_state,
- crtc_state,
- min_scale, max_scale,
- true, true);
+ ret = drm_atomic_helper_check_plane_state(new_plane_state,
+ crtc_state,
+ min_scale, max_scale,
+ true, true);
+ if (ret)
+ return ret;
+
+ /*
+ * Fractional source coordinates can only be handled by the scaler,
+ * so reject them on channels without one.
+ */
+ if (new_plane_state->visible &&
+ !(layer->cfg->scaler_mask & BIT(layer->channel)) &&
+ ((new_plane_state->src.x1 | new_plane_state->src.y1 |
+ new_plane_state->src.x2 | new_plane_state->src.y2) & 0xffff)) {
+ DRM_DEBUG_DRIVER("Fractional source coordinates need scaler\n");
+ return -EINVAL;
+ }
+
+ return 0;
}
@@ -259,10 +259,26 @@ static int sun8i_vi_layer_atomic_check(struct drm_plane *plane,
max_scale = SUN8I_VI_SCALER_SCALE_MAX;
}
- return drm_atomic_helper_check_plane_state(new_plane_state,
- crtc_state,
- min_scale, max_scale,
- true, true);
+ ret = drm_atomic_helper_check_plane_state(new_plane_state,
+ crtc_state,
+ min_scale, max_scale,
+ true, true);
+ if (ret)
+ return ret;
+
+ /*
+ * Fractional source coordinates can only be handled by the scaler,
+ * so reject them on channels without one.
+ */
+ if (new_plane_state->visible &&
+ !(layer->cfg->scaler_mask & BIT(layer->channel)) &&
+ ((new_plane_state->src.x1 | new_plane_state->src.y1 |
+ new_plane_state->src.x2 | new_plane_state->src.y2) & 0xffff)) {
+ DRM_DEBUG_DRIVER("Fractional source coordinates need scaler\n");
+ return -EINVAL;
+ }
+
+ return 0;
}
static void sun8i_vi_layer_atomic_update(struct drm_plane *plane,