Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues: - [High] NULL pointer dereference when enabling CRTC without a primary plane framebuffer. Pre-existing issues: - [High] Unsafe direct access of global plane and CRTC state pointers in atomic commit callbacks. -- commit 6344532446cab68117e44660f110ef0c8aec15d7 Author: Ze Huang <[email protected]> drm/arcpgu: replace struct drm_simple_display_pipe with regular atomic helpers This commit replaces drm_simple_display_pipe with regular atomic helpers. It instantiates the plane, CRTC, and encoder directly, wiring them up with standard atomic helpers to remove the dependency on the simple-KMS interface. > diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c > index c93d61ac0bb75..375cdb79e4e89 100644 > --- a/drivers/gpu/drm/tiny/arcpgu.c > +++ b/drivers/gpu/drm/tiny/arcpgu.c [ ... ] > @@ -117,7 +117,7 @@ static const u32 arc_pgu_supported_formats[] = { > > static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu) > { > - const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb; > + const struct drm_framebuffer *fb = arcpgu->plane.state->fb; [Severity: High] This isn't a bug introduced by this patch, but does reading the global plane->state pointer here instead of using the state passed via the drm_atomic_commit parameter cause issues during non-blocking atomic commits? If multiple non-blocking commits are queued rapidly, the global pointers advance to the newest state. When the first commit's commit_tail finally executes, reading plane->state directly instead of extracting the specific commit's state could cause the older commit to program the hardware using a future commit's state. [Severity: High] Can this dereference a NULL pointer if the CRTC is enabled without a primary plane framebuffer? The transition from drm_simple_display_pipe to generic atomic helpers removed the underlying protection that previously prevented the CRTC from enabling without a valid framebuffer. If userspace performs an atomic commit that enables the CRTC but sets the primary plane's framebuffer to 0 (NULL), drm_atomic_helper_check_crtc_primary_plane verifies the plane is attached but does not enforce plane_state->fb != NULL. This would allow the commit to proceed to arcpgu_crtc_helper_atomic_enable(), which calls arc_pgu_mode_set(), and then arc_pgu_set_pxl_fmt(), blindly dereferencing fb->format->format here. > uint32_t pixel_format = fb->format->format; > u32 format = DRM_FORMAT_INVALID; > int i; [ ... ] > @@ -155,7 +155,7 @@ static enum drm_mode_status arc_pgu_mode_valid(struct > drm_simple_display_pipe *p > > static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu) > { > - struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode; > + struct drm_display_mode *m = &arcpgu->crtc.state->adjusted_mode; [Severity: High] This is a pre-existing issue, but could reading the global crtc->state pointer directly cause hardware state corruption or frame tearing? Similar to the plane state issue above, if rapid non-blocking atomic commits are generated, arc_pgu_mode_set() might read from the newest global state rather than the specific commit's state object. > u32 val; > > arc_pgu_write(arcpgu, ARCPGU_REG_FMT, [ ... ] > @@ -218,35 +218,106 @@ static void arc_pgu_disable(struct > drm_simple_display_pipe *pipe) > ~ARCPGU_CTRL_ENABLE_MASK); > } > > -static void arc_pgu_update(struct drm_simple_display_pipe *pipe, > - struct drm_plane_state *state) > +static void arcpgu_plane_helper_atomic_update(struct drm_plane *plane, > + struct drm_atomic_commit *state) > { > struct arcpgu_drm_private *arcpgu; > struct drm_gem_dma_object *gem; > > - if (!pipe->plane.state->fb) > + if (!plane->state->fb) [Severity: High] This is a pre-existing issue, but does arcpgu_plane_helper_atomic_update() safely handle non-blocking atomic commits when reading plane->state->fb directly? Reading the global plane->state pointer instead of extracting the new plane state from the drm_atomic_commit parameter could result in the same race condition during asynchronous commit_tail execution. > return; > > - arcpgu = pipe_to_arcpgu_priv(pipe); > - gem = drm_fb_dma_get_gem_obj(pipe->plane.state->fb, 0); > + arcpgu = dev_to_arcpgu(plane->dev); > + gem = drm_fb_dma_get_gem_obj(plane->state->fb, 0); > arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->dma_addr); > } -- Sashiko AI review ยท https://sashiko.dev/#/patchset/20260705-drm-simple-kms-removal-v1-0-b4e1ca053...@oss.qualcomm.com?part=1
