* [PATCH] drm/amd/display: use a more accurate check in dm_helpers_dp_read_dpcd()
@ 2023-03-09 21:30 Hamza Mahfooz
2023-03-10 17:42 ` Rodrigo Siqueira Jordao
2023-03-10 17:48 ` Ville Syrjälä
0 siblings, 2 replies; 5+ messages in thread
From: Hamza Mahfooz @ 2023-03-09 21:30 UTC (permalink / raw)
To: amd-gfx
Cc: Hamza Mahfooz, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Pan, Xinhui, David Airlie,
Daniel Vetter, Lyude Paul, Wayne Lin, Qingqing Zhuo, Ian Chen,
Sung Joon Kim, dri-devel, linux-kernel
We should be checking if drm_dp_dpcd_read() returns the size that we are
asking it to read instead of just checking if it is greater than zero.
Also, we should WARN_ON() here since this condition is only ever met, if
there is an issue worth investigating. So, compare the return value of
drm_dp_dpcd_read() to size and WARN_ON() if they aren't equal.
Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index 8d598b322e5b..ed2ed7b1d869 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -511,8 +511,8 @@ bool dm_helpers_dp_read_dpcd(
return false;
}
- return drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, address,
- data, size) > 0;
+ return !WARN_ON(drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, address,
+ data, size) != size);
}
bool dm_helpers_dp_write_dpcd(
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/amd/display: use a more accurate check in dm_helpers_dp_read_dpcd()
2023-03-09 21:30 [PATCH] drm/amd/display: use a more accurate check in dm_helpers_dp_read_dpcd() Hamza Mahfooz
@ 2023-03-10 17:42 ` Rodrigo Siqueira Jordao
2023-03-10 17:48 ` Ville Syrjälä
1 sibling, 0 replies; 5+ messages in thread
From: Rodrigo Siqueira Jordao @ 2023-03-10 17:42 UTC (permalink / raw)
To: Hamza Mahfooz, amd-gfx
Cc: Harry Wentland, Leo Li, Alex Deucher, Christian König, Pan,
Xinhui, David Airlie, Daniel Vetter, Lyude Paul, Wayne Lin,
Qingqing Zhuo, Ian Chen, Sung Joon Kim, dri-devel, linux-kernel
On 3/9/23 14:30, Hamza Mahfooz wrote:
> We should be checking if drm_dp_dpcd_read() returns the size that we are
> asking it to read instead of just checking if it is greater than zero.
> Also, we should WARN_ON() here since this condition is only ever met, if
> there is an issue worth investigating. So, compare the return value of
> drm_dp_dpcd_read() to size and WARN_ON() if they aren't equal.
>
> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
> ---
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> index 8d598b322e5b..ed2ed7b1d869 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> @@ -511,8 +511,8 @@ bool dm_helpers_dp_read_dpcd(
> return false;
> }
>
> - return drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, address,
> - data, size) > 0;
> + return !WARN_ON(drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, address,
> + data, size) != size);
> }
>
> bool dm_helpers_dp_write_dpcd(
Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
and pushed to amd-staging-drm-next.
Thanks
Siqueira
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/amd/display: use a more accurate check in dm_helpers_dp_read_dpcd()
2023-03-09 21:30 [PATCH] drm/amd/display: use a more accurate check in dm_helpers_dp_read_dpcd() Hamza Mahfooz
2023-03-10 17:42 ` Rodrigo Siqueira Jordao
@ 2023-03-10 17:48 ` Ville Syrjälä
2023-03-10 17:51 ` Ville Syrjälä
1 sibling, 1 reply; 5+ messages in thread
From: Ville Syrjälä @ 2023-03-10 17:48 UTC (permalink / raw)
To: Hamza Mahfooz
Cc: amd-gfx, Ian Chen, Leo Li, Qingqing Zhuo, Pan, Xinhui,
Rodrigo Siqueira, linux-kernel, dri-devel, Wayne Lin,
Alex Deucher, Christian König, Sung Joon Kim
On Thu, Mar 09, 2023 at 04:30:27PM -0500, Hamza Mahfooz wrote:
> We should be checking if drm_dp_dpcd_read() returns the size that we are
> asking it to read instead of just checking if it is greater than zero.
> Also, we should WARN_ON() here since this condition is only ever met, if
> there is an issue worth investigating. So, compare the return value of
> drm_dp_dpcd_read() to size and WARN_ON() if they aren't equal.
>
> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
> ---
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> index 8d598b322e5b..ed2ed7b1d869 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> @@ -511,8 +511,8 @@ bool dm_helpers_dp_read_dpcd(
> return false;
> }
>
> - return drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, address,
> - data, size) > 0;
> + return !WARN_ON(drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, address,
> + data, size) != size);
Just FYI there are devices out there that violate the DP spec and reads
from specific DPCD registers simply fail instead of returning the
expected 0.
> }
>
> bool dm_helpers_dp_write_dpcd(
> --
> 2.39.2
--
Ville Syrjälä
Intel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/amd/display: use a more accurate check in dm_helpers_dp_read_dpcd()
2023-03-10 17:48 ` Ville Syrjälä
@ 2023-03-10 17:51 ` Ville Syrjälä
2023-03-20 20:25 ` Harry Wentland
0 siblings, 1 reply; 5+ messages in thread
From: Ville Syrjälä @ 2023-03-10 17:51 UTC (permalink / raw)
To: Hamza Mahfooz
Cc: amd-gfx, Ian Chen, Leo Li, Qingqing Zhuo, Pan, Xinhui,
Rodrigo Siqueira, linux-kernel, dri-devel, Wayne Lin,
Alex Deucher, Christian König, Sung Joon Kim
On Fri, Mar 10, 2023 at 07:48:04PM +0200, Ville Syrjälä wrote:
> On Thu, Mar 09, 2023 at 04:30:27PM -0500, Hamza Mahfooz wrote:
> > We should be checking if drm_dp_dpcd_read() returns the size that we are
> > asking it to read instead of just checking if it is greater than zero.
> > Also, we should WARN_ON() here since this condition is only ever met, if
> > there is an issue worth investigating. So, compare the return value of
> > drm_dp_dpcd_read() to size and WARN_ON() if they aren't equal.
> >
> > Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
> > ---
> > drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> > index 8d598b322e5b..ed2ed7b1d869 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> > @@ -511,8 +511,8 @@ bool dm_helpers_dp_read_dpcd(
> > return false;
> > }
> >
> > - return drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, address,
> > - data, size) > 0;
> > + return !WARN_ON(drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, address,
> > + data, size) != size);
>
> Just FYI there are devices out there that violate the DP spec and reads
> from specific DPCD registers simply fail instead of returning the
> expected 0.
And of course anyone can yank the cable anytime, so in
fact pretty much any DPCD read can fail.
--
Ville Syrjälä
Intel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/amd/display: use a more accurate check in dm_helpers_dp_read_dpcd()
2023-03-10 17:51 ` Ville Syrjälä
@ 2023-03-20 20:25 ` Harry Wentland
0 siblings, 0 replies; 5+ messages in thread
From: Harry Wentland @ 2023-03-20 20:25 UTC (permalink / raw)
To: Ville Syrjälä, Hamza Mahfooz
Cc: Ian Chen, Leo Li, Qingqing Zhuo, Pan, Xinhui, Rodrigo Siqueira,
linux-kernel, amd-gfx, dri-devel, Wayne Lin, Alex Deucher,
Christian König, Sung Joon Kim
On 3/10/23 12:51, Ville Syrjälä wrote:
> On Fri, Mar 10, 2023 at 07:48:04PM +0200, Ville Syrjälä wrote:
>> On Thu, Mar 09, 2023 at 04:30:27PM -0500, Hamza Mahfooz wrote:
>>> We should be checking if drm_dp_dpcd_read() returns the size that we are
>>> asking it to read instead of just checking if it is greater than zero.
>>> Also, we should WARN_ON() here since this condition is only ever met, if
>>> there is an issue worth investigating. So, compare the return value of
>>> drm_dp_dpcd_read() to size and WARN_ON() if they aren't equal.
>>>
>>> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
>>> ---
>>> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>> index 8d598b322e5b..ed2ed7b1d869 100644
>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>> @@ -511,8 +511,8 @@ bool dm_helpers_dp_read_dpcd(
>>> return false;
>>> }
>>>
>>> - return drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, address,
>>> - data, size) > 0;
>>> + return !WARN_ON(drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, address,
>>> + data, size) != size);
>>
>> Just FYI there are devices out there that violate the DP spec and reads
>> from specific DPCD registers simply fail instead of returning the
>> expected 0.
>
> And of course anyone can yank the cable anytime, so in
> fact pretty much any DPCD read can fail.
>
Thanks for making this very important point. It seems like drm_dp_dpcd_access
checks for that, though, and returns -EPROTO if !(ret == size). So I don't
expect this patch to change any behavior.
Harry
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-20 20:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09 21:30 [PATCH] drm/amd/display: use a more accurate check in dm_helpers_dp_read_dpcd() Hamza Mahfooz
2023-03-10 17:42 ` Rodrigo Siqueira Jordao
2023-03-10 17:48 ` Ville Syrjälä
2023-03-10 17:51 ` Ville Syrjälä
2023-03-20 20:25 ` Harry Wentland
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).