2022-06-02 22:36:24

by Lyude Paul

[permalink] [raw]
Subject: [PATCH 1/3] drm/display/dp_mst: Don't validate port refs in drm_dp_check_and_send_link_address()

Drive-by cleanup, we don't need to validate the port references here as we
already previously went through the effort of refactoring things such that
we're guaranteed to be able to access ->mstb and ->port safely from
drm_dp_check_and_send_link_address(), since the only two places in the
codebase that drop an MST reference in such a way that it would remove it
from the topology are both protected under probe_lock.

Thanks for that, past Lyude!

Signed-off-by: Lyude Paul <[email protected]>
---
drivers/gpu/drm/display/drm_dp_mst_topology.c | 22 +++++--------------
1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c
index 67b3b9697da7..d84673b3294b 100644
--- a/drivers/gpu/drm/display/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c
@@ -2666,24 +2666,14 @@ static int drm_dp_check_and_send_link_address(struct drm_dp_mst_topology_mgr *mg
}

list_for_each_entry(port, &mstb->ports, next) {
- struct drm_dp_mst_branch *mstb_child = NULL;
-
- if (port->input || !port->ddps)
+ if (port->input || !port->ddps || !port->mstb)
continue;

- if (port->mstb)
- mstb_child = drm_dp_mst_topology_get_mstb_validated(
- mgr, port->mstb);
-
- if (mstb_child) {
- ret = drm_dp_check_and_send_link_address(mgr,
- mstb_child);
- drm_dp_mst_topology_put_mstb(mstb_child);
- if (ret == 1)
- changed = true;
- else if (ret < 0)
- return ret;
- }
+ ret = drm_dp_check_and_send_link_address(mgr, port->mstb);
+ if (ret == 1)
+ changed = true;
+ else if (ret < 0)
+ return ret;
}

return changed;
--
2.35.3



2022-06-13 10:00:50

by Lin, Wayne

[permalink] [raw]
Subject: RE: [PATCH 1/3] drm/display/dp_mst: Don't validate port refs in drm_dp_check_and_send_link_address()

[Public]

Thanks, Lyude.

Feel free to add
Reviewed-by: Wayne Lin <[email protected]>

> -----Original Message-----
> From: Lyude Paul <[email protected]>
> Sent: Friday, June 3, 2022 4:18 AM
> To: [email protected]
> Cc: David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Thomas
> Zimmermann <[email protected]>; Lin, Wayne
> <[email protected]>; Jani Nikula <[email protected]>; Lakha,
> Bhawanpreet <[email protected]>; Rajkumar Subbiah
> <[email protected]>; open list <[email protected]>
> Subject: [PATCH 1/3] drm/display/dp_mst: Don't validate port refs in
> drm_dp_check_and_send_link_address()
>
> Drive-by cleanup, we don't need to validate the port references here as we
> already previously went through the effort of refactoring things such that
> we're guaranteed to be able to access ->mstb and ->port safely from
> drm_dp_check_and_send_link_address(), since the only two places in the
> codebase that drop an MST reference in such a way that it would remove it
> from the topology are both protected under probe_lock.
>
> Thanks for that, past Lyude!
>
> Signed-off-by: Lyude Paul <[email protected]>
> ---
> drivers/gpu/drm/display/drm_dp_mst_topology.c | 22 +++++--------------
> 1 file changed, 6 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c
> b/drivers/gpu/drm/display/drm_dp_mst_topology.c
> index 67b3b9697da7..d84673b3294b 100644
> --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c
> @@ -2666,24 +2666,14 @@ static int
> drm_dp_check_and_send_link_address(struct drm_dp_mst_topology_mgr
> *mg
> }
>
> list_for_each_entry(port, &mstb->ports, next) {
> - struct drm_dp_mst_branch *mstb_child = NULL;
> -
> - if (port->input || !port->ddps)
> + if (port->input || !port->ddps || !port->mstb)
> continue;
>
> - if (port->mstb)
> - mstb_child =
> drm_dp_mst_topology_get_mstb_validated(
> - mgr, port->mstb);
> -
> - if (mstb_child) {
> - ret = drm_dp_check_and_send_link_address(mgr,
> - mstb_child);
> - drm_dp_mst_topology_put_mstb(mstb_child);
> - if (ret == 1)
> - changed = true;
> - else if (ret < 0)
> - return ret;
> - }
> + ret = drm_dp_check_and_send_link_address(mgr, port-
> >mstb);
> + if (ret == 1)
> + changed = true;
> + else if (ret < 0)
> + return ret;
> }
>
> return changed;
> --
> 2.35.3

--
Regards,
Wayne