Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] drm/atomic: lost driver state in drm_atomic_commit_fill_with_defaults() - [Low] drm/atomic: commit message says -ENOENT instead of -EACCES for split leases - [Low] drm/atomic: incomplete kernel-doc contract for drm_atomic_commit_fill_with_defaults() --
commit e865390bfad964b059339362263f954229009ccf Author: Maxime Ripard <[email protected]> drm/atomic: Allow filling a commit with pristine object states This commit adds drm_atomic_commit_fill_with_defaults() to populate an atomic commit with freshly created default states for CRTCs, planes, connectors, and color operations, scoped to the caller's lease. > A lessee only gets the objects of its lease reset, the other ones > keeping their current state. Partial pipelines aren't supported > though: detaching a plane or a connector from its CRTC, and disabling > a CRTC driving them, both need the two sides in the commit, so a lease > that splits a pipeline is rejected with -ENOENT. [Severity: Low] As reported by Thomas Zimmermann on v12 [1], the code and kernel-doc now return -EACCES for split leases rather than -ENOENT. Should the commit message be updated to match? > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c > index 5036beb2762ad..84af0b6e9bb07 100644 > --- a/drivers/gpu/drm/drm_atomic.c > +++ b/drivers/gpu/drm/drm_atomic.c > @@ -1708,6 +1708,327 @@ bool drm_atomic_implements_create_state(struct > drm_device *dev) > } > EXPORT_SYMBOL(drm_atomic_implements_create_state); > > +/** > + * drm_atomic_commit_fill_with_defaults - populate a commit with pristine > states > + * @file_priv: DRM file the reset was requested from, or NULL > + * @commit: atomic commit to fill [ ... ] > + * Returns: > + * 0 on success, -EACCES if a leased plane or connector is bound to a > + * CRTC that isn't leased or if the lease was revoked, or a negative > + * error code on failure. > + */ > +int drm_atomic_commit_fill_with_defaults(struct drm_file *file_priv, > + struct drm_atomic_commit *commit) [Severity: Low] Since drm_atomic_commit_fill_with_defaults() is exported, should its kernel-doc spell out the caller contract and return values? Callers must pass an empty commit with an initialized acquire_ctx and verify drm_atomic_implements_create_state() beforehand, as the CRTC and plane atomic_create_state hooks are called without NULL checks and existing slots would be overwritten without cleanup. The function also acquires modeset locks that stay held on both success and failure, so callers need to clear partial state on error and handle -EDEADLK backoff. The Returns section omits -EDEADLK, -EOPNOTSUPP (for a hotplugged connector without atomic_create_state), and the -EACCES cases where a leased CRTC drives an unleased plane or connector. [ ... ] > + crtc_state = crtc->funcs->atomic_create_state(crtc); > + if (IS_ERR(crtc_state)) > + return PTR_ERR(crtc_state); [ ... ] > + drm_mode_copy(&crtc_state->adjusted_mode, > + &crtc->state->adjusted_mode); [ ... ] > + plane_state = plane->funcs->atomic_create_state(plane); > + if (IS_ERR(plane_state)) > + return PTR_ERR(plane_state); [ ... ] > + connector_state->best_encoder = connector->state->best_encoder; [Severity: High] Can populating a live commit with atomic_create_state() while carrying over adjusted_mode and best_encoder leave driver-private state zeroed in drivers that satisfy drm_atomic_implements_create_state()? Drivers assume a live atomic commit starts from duplicated state, so skipping a modeset on a reset commit leaves subclass fields unpopulated even after the amdgpu_dm, vc4, and msm/dpu1 adjustments later in the series: - msm/mdp5: keeping a CRTC active with no visible planes sets mdp5_cstate->ctl in mdp5_encoder_atomic_check(), while mdp5_crtc_atomic_check() returns early before setting up pipeline.mixer, causing a NULL pointer dereference on mixer->lm in blend_setup(). mdp5_plane_atomic_check_with_state() also releases hwpipe and r_hwpipe from the new plane state, which are NULL after mdp5_plane_create_state(), leaking the previously assigned pipes. - nouveau dispnv50: on a no-modeset reset keeping the same framebuffer, nv50_wndw_atomic_check_acquire() skips populating asyw->image, causing curs507a_acquire() to fail with -EINVAL and leaving window handles zeroed. nv50_head_atomic_check() similarly leaves head fields zeroed, and resetting connector properties to defaults leaves asyc->set.mask clear so hardware reprogramming is skipped. - arm/komeda: komeda_crtc_create_state() zeroes affected_pipes, clock_ratio, and max_slave_zorder instead of copying them from the old state, so a no-modeset reset leaves clock_ratio zero and passes a zeroed affected_pipes to komeda_release_unclaimed_resources(). [1] https://lore.kernel.org/r/[email protected] -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=3
