All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Hamza Mahfooz <hamza.mahfooz@amd.com>
Cc: "Ian Chen" <ian.chen@amd.com>, "Leo Li" <sunpeng.li@amd.com>,
	"Qingqing Zhuo" <qingqing.zhuo@amd.com>,
	"Pan, Xinhui" <Xinhui.Pan@amd.com>,
	"Rodrigo Siqueira" <Rodrigo.Siqueira@amd.com>,
	linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, "Wayne Lin" <Wayne.Lin@amd.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Sung Joon Kim" <sungjoon.kim@amd.com>
Subject: Re: [PATCH] drm/amd/display: use a more accurate check in dm_helpers_dp_read_dpcd()
Date: Fri, 10 Mar 2023 19:51:13 +0200	[thread overview]
Message-ID: <ZAtuET8c8kSgyX4Y@intel.com> (raw)
In-Reply-To: <ZAttVGN/VdrfkH3y@intel.com>

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

WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Hamza Mahfooz <hamza.mahfooz@amd.com>
Cc: amd-gfx@lists.freedesktop.org, "Ian Chen" <ian.chen@amd.com>,
	"Leo Li" <sunpeng.li@amd.com>,
	"Qingqing Zhuo" <qingqing.zhuo@amd.com>,
	"Pan, Xinhui" <Xinhui.Pan@amd.com>,
	"Rodrigo Siqueira" <Rodrigo.Siqueira@amd.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	"Wayne Lin" <Wayne.Lin@amd.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Sung Joon Kim" <sungjoon.kim@amd.com>
Subject: Re: [PATCH] drm/amd/display: use a more accurate check in dm_helpers_dp_read_dpcd()
Date: Fri, 10 Mar 2023 19:51:13 +0200	[thread overview]
Message-ID: <ZAtuET8c8kSgyX4Y@intel.com> (raw)
In-Reply-To: <ZAttVGN/VdrfkH3y@intel.com>

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

  reply	other threads:[~2023-03-10 17:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09 21:30 [PATCH] drm/amd/display: use a more accurate check in dm_helpers_dp_read_dpcd() Hamza Mahfooz
2023-03-09 21:30 ` Hamza Mahfooz
2023-03-09 21:30 ` Hamza Mahfooz
2023-03-10 17:42 ` Rodrigo Siqueira Jordao
2023-03-10 17:42   ` Rodrigo Siqueira Jordao
2023-03-10 17:42   ` Rodrigo Siqueira Jordao
2023-03-10 17:48 ` Ville Syrjälä
2023-03-10 17:48   ` Ville Syrjälä
2023-03-10 17:51   ` Ville Syrjälä [this message]
2023-03-10 17:51     ` Ville Syrjälä
2023-03-20 20:25     ` Harry Wentland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZAtuET8c8kSgyX4Y@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=Rodrigo.Siqueira@amd.com \
    --cc=Wayne.Lin@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hamza.mahfooz@amd.com \
    --cc=ian.chen@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qingqing.zhuo@amd.com \
    --cc=sungjoon.kim@amd.com \
    --cc=sunpeng.li@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.