Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [High] Data race and stale state usage for `allocated_pbn` between 
asynchronous commit tail and synchronous atomic check.
--

commit 60c9feaab7e5f91e4bacf61ee648e76157adea65
Author: Xiao Lu <[email protected]>
drm/dp_mst: Track allocated_pbn from ALLOCATE_PAYLOAD down-reply

This commit stores the allocated_pbn returned by the ALLOCATE_PAYLOAD
down-reply sideband message and uses it to perform bandwidth limit checks
based on the larger of the requested and allocated PBN.

> diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c 
> b/drivers/gpu/drm/display/drm_dp_mst_topology.c
> index 7ce9e212770ad..b0e4cf8458eda 100644
> --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c
[ ... ]
> @@ -3166,10 +3167,14 @@ static int drm_dp_payload_send_msg(struct 
> drm_dp_mst_topology_mgr *mgr,
>        */
>       ret = drm_dp_mst_wait_tx_reply(mstb, txmsg);
>       if (ret > 0) {
> -             if (txmsg->reply.reply_type == DP_SIDEBAND_REPLY_NAK)
> +             if (txmsg->reply.reply_type == DP_SIDEBAND_REPLY_NAK) {
>                       ret = -EINVAL;
> -             else
> +             } else {
> +                     if (payload)
> +                             payload->allocated_pbn =
> +                                     
> txmsg->reply.u.allocate_payload.allocated_pbn;
>                       ret = 0;
> +             }
>       }
>       kfree(txmsg);
>  fail_put:

[Severity: High]
Does modifying payload->allocated_pbn asynchronously here in
drm_dp_payload_send_msg() during the commit tail introduce a data race?

When a non-blocking atomic commit updates the topology, its asynchronous
commit tail waits for the ALLOCATE_PAYLOAD reply. If a subsequent atomic
commit ioctl triggers the atomic check phase concurrently, that check
phase duplicates the MST state without locks, which could capture a
partially updated or zeroed allocated_pbn.

[ ... ]
> @@ -4670,6 +4678,7 @@ void drm_dp_mst_atomic_wait_for_dependencies(struct 
> drm_atomic_commit *state)
>                       new_payload = 
> drm_atomic_get_mst_payload_state(new_mst_state,
>                                                                      
> old_payload->port);
>                       new_payload->vc_start_slot = old_payload->vc_start_slot;
> +                     new_payload->allocated_pbn = old_payload->allocated_pbn;
>                       new_payload->payload_allocation_status =
>                                                       
> old_payload->payload_allocation_status;
>               }

[Severity: High]
Since drm_dp_mst_atomic_wait_for_dependencies() is executed in the commit
tail after dependencies resolve, does copying allocated_pbn here mean the
check phase of the current commit has already executed?

If so, the check phase would have already run using the un-updated, stale
value of allocated_pbn from the previous commit state before this
synchronization occurs.

[ ... ]
> @@ -5352,7 +5361,7 @@ drm_dp_mst_atomic_check_port_bw_limit(struct 
> drm_dp_mst_port *port,
>                       return -EINVAL;
>               }
>  
> -             pbn_used = payload->pbn;
> +             pbn_used = max(payload->pbn, payload->allocated_pbn);
>       } else {
>               pbn_used = drm_dp_mst_atomic_check_mstb_bw_limit(port->mstb,
>                                                                state,

[Severity: High]
Does reading payload->allocated_pbn here in
drm_dp_mst_atomic_check_port_bw_limit() risk bypassing bandwidth validation
if the previous hardware reply hasn't arrived yet?

If unprivileged userspace (like a Wayland compositor) submits rapid
back-to-back atomic commits, the check phase here could evaluate
max(payload->pbn, payload->allocated_pbn) using a stale or zeroed value.
This might allow configurations that exceed link bandwidth because
intermediate branch constraints would be silently ignored.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to