diff mbox

[1/2] drm: Add a new connector property for link status

Message ID 1477444595-19656-1-git-send-email-manasi.d.navare@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Navare, Manasi Oct. 26, 2016, 1:16 a.m. UTC
A new optional connector property is added for keeping
track of whether the link is good (link training passed) or
link is bad (link training  failed). If the link status property
is Bad, then userspace should fire off a new modeset at the current
mode even if there have not been any changes in the mode list
or connector status.

Cc: dri-devel@lists.freedesktop.org
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
---
 drivers/gpu/drm/drm_connector.c | 32 ++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h     |  1 +
 include/drm/drm_crtc.h          |  6 ++++++
 include/uapi/drm/drm_mode.h     |  4 ++++
 4 files changed, 43 insertions(+)

Comments

Navare, Manasi Oct. 26, 2016, 1:19 a.m. UTC | #1
Chris,

Would you be able to make the necessary changes in the suerspace
driver so I can do some testing tomorrow?

Manasi

On Tue, Oct 25, 2016 at 06:16:34PM -0700, Manasi Navare wrote:
> A new optional connector property is added for keeping
> track of whether the link is good (link training passed) or
> link is bad (link training  failed). If the link status property
> is Bad, then userspace should fire off a new modeset at the current
> mode even if there have not been any changes in the mode list
> or connector status.
> 
> Cc: dri-devel@lists.freedesktop.org
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> ---
>  drivers/gpu/drm/drm_connector.c | 32 ++++++++++++++++++++++++++++++++
>  include/drm/drm_connector.h     |  1 +
>  include/drm/drm_crtc.h          |  6 ++++++
>  include/uapi/drm/drm_mode.h     |  4 ++++
>  4 files changed, 43 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 2db7fb5..b4ce19f 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -588,6 +588,11 @@ int drm_display_info_set_bus_formats(struct drm_display_info *info,
>  DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
>  		 drm_tv_subconnector_enum_list)
>  
> +static const struct drm_prop_enum_list drm_link_status_enum_list[] = {
> +	{ DRM_MODE_LINK_STATUS_GOOD, "Good" },
> +	{ DRM_MODE_LINK_STATUS_BAD, "Bad" },
> +};
> +
>  int drm_connector_create_standard_properties(struct drm_device *dev)
>  {
>  	struct drm_property *prop;
> @@ -845,6 +850,33 @@ int drm_mode_create_suggested_offset_properties(struct drm_device *dev)
>  EXPORT_SYMBOL(drm_mode_create_suggested_offset_properties);
>  
>  /**
> + * drm_mode_create_link_status_property - Create link status property
> + * @dev: DRM device
> + *
> + * Called by a driver the first time it's needed, must be attached to desired
> + * connectors.
> + * This property is used to indicate whether link sttaus is Good or Bad as
> + * a result fo link training
> + */
> +int drm_mode_create_link_status_property(struct drm_device *dev)
> +{
> +	struct drm_property *link_status;
> +
> +	if (dev->mode_config.link_status_property)
> +		return 0;
> +
> +	link_status =
> +		drm_property_create_enum(dev, 0, "link-status",
> +					 drm_link_status_enum_list,
> +					 ARRAY_SIZE(drm_link_status_enum_list));
> +
> +	dev->mode_config.scaling_mode_property = link_status;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_mode_create_link_status_property);
> +
> +/**
>   * drm_mode_connector_set_path_property - set tile property on connector
>   * @connector: connector to set property on.
>   * @path: path to use for property; must not be NULL.
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index fc9d475..7234c0c 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -759,6 +759,7 @@ int drm_mode_create_tv_properties(struct drm_device *dev,
>  int drm_mode_create_scaling_mode_property(struct drm_device *dev);
>  int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
>  int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
> +int drm_mode_create_link_status_property(struct drm_device *dev);
>  
>  int drm_mode_connector_set_path_property(struct drm_connector *connector,
>  					 const char *path);
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index fa1aa21..3e9c833 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -1343,6 +1343,12 @@ struct drm_mode_config {
>  	 */
>  	struct drm_property *suggested_y_property;
>  
> +	/**
> +	 * @link_status_property: Optional connector property for link status
> +	 * of the connector as a result of link training.
> +	 */
> +	 struct drm_property *link_status_property;
> +
>  	/* dumb ioctl parameters */
>  	uint32_t preferred_depth, prefer_shadow;
>  
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 084b50a..f1b0afd 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -121,6 +121,10 @@
>  #define DRM_MODE_DIRTY_ON       1
>  #define DRM_MODE_DIRTY_ANNOTATE 2
>  
> +/* Link Status options */
> +#define DRM_MODE_LINK_STATUS_GOOD	0
> +#define DRM_MODE_LINK_STATUS_BAD	1
> +
>  struct drm_mode_modeinfo {
>  	__u32 clock;
>  	__u16 hdisplay;
> -- 
> 1.9.1
>
Daniel Vetter Oct. 26, 2016, 5:52 a.m. UTC | #2
On Tue, Oct 25, 2016 at 06:16:34PM -0700, Manasi Navare wrote:
> A new optional connector property is added for keeping
> track of whether the link is good (link training passed) or
> link is bad (link training  failed). If the link status property
> is Bad, then userspace should fire off a new modeset at the current
> mode even if there have not been any changes in the mode list
> or connector status.
> 
> Cc: dri-devel@lists.freedesktop.org
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> ---
>  drivers/gpu/drm/drm_connector.c | 32 ++++++++++++++++++++++++++++++++
>  include/drm/drm_connector.h     |  1 +
>  include/drm/drm_crtc.h          |  6 ++++++
>  include/uapi/drm/drm_mode.h     |  4 ++++
>  4 files changed, 43 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 2db7fb5..b4ce19f 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -588,6 +588,11 @@ int drm_display_info_set_bus_formats(struct drm_display_info *info,
>  DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
>  		 drm_tv_subconnector_enum_list)
>  
> +static const struct drm_prop_enum_list drm_link_status_enum_list[] = {
> +	{ DRM_MODE_LINK_STATUS_GOOD, "Good" },
> +	{ DRM_MODE_LINK_STATUS_BAD, "Bad" },
> +};
> +
>  int drm_connector_create_standard_properties(struct drm_device *dev)
>  {
>  	struct drm_property *prop;
> @@ -845,6 +850,33 @@ int drm_mode_create_suggested_offset_properties(struct drm_device *dev)
>  EXPORT_SYMBOL(drm_mode_create_suggested_offset_properties);
>  
>  /**
> + * drm_mode_create_link_status_property - Create link status property
> + * @dev: DRM device
> + *
> + * Called by a driver the first time it's needed, must be attached to desired
> + * connectors.
> + * This property is used to indicate whether link sttaus is Good or Bad as
> + * a result fo link training
> + */
> +int drm_mode_create_link_status_property(struct drm_device *dev)

I'd go further and just always create this as one of the standard
properties (and always attach it to the connector, like edid), and only
expose helpers to set the link status to good or bad.
-Daniel

> +{
> +	struct drm_property *link_status;
> +
> +	if (dev->mode_config.link_status_property)
> +		return 0;
> +
> +	link_status =
> +		drm_property_create_enum(dev, 0, "link-status",
> +					 drm_link_status_enum_list,
> +					 ARRAY_SIZE(drm_link_status_enum_list));
> +
> +	dev->mode_config.scaling_mode_property = link_status;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_mode_create_link_status_property);
> +
> +/**
>   * drm_mode_connector_set_path_property - set tile property on connector
>   * @connector: connector to set property on.
>   * @path: path to use for property; must not be NULL.
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index fc9d475..7234c0c 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -759,6 +759,7 @@ int drm_mode_create_tv_properties(struct drm_device *dev,
>  int drm_mode_create_scaling_mode_property(struct drm_device *dev);
>  int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
>  int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
> +int drm_mode_create_link_status_property(struct drm_device *dev);
>  
>  int drm_mode_connector_set_path_property(struct drm_connector *connector,
>  					 const char *path);
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index fa1aa21..3e9c833 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -1343,6 +1343,12 @@ struct drm_mode_config {
>  	 */
>  	struct drm_property *suggested_y_property;
>  
> +	/**
> +	 * @link_status_property: Optional connector property for link status
> +	 * of the connector as a result of link training.
> +	 */
> +	 struct drm_property *link_status_property;
> +
>  	/* dumb ioctl parameters */
>  	uint32_t preferred_depth, prefer_shadow;
>  
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 084b50a..f1b0afd 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -121,6 +121,10 @@
>  #define DRM_MODE_DIRTY_ON       1
>  #define DRM_MODE_DIRTY_ANNOTATE 2
>  
> +/* Link Status options */
> +#define DRM_MODE_LINK_STATUS_GOOD	0
> +#define DRM_MODE_LINK_STATUS_BAD	1
> +
>  struct drm_mode_modeinfo {
>  	__u32 clock;
>  	__u16 hdisplay;
> -- 
> 1.9.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Chris Wilson Oct. 26, 2016, 9:27 a.m. UTC | #3
On Tue, Oct 25, 2016 at 06:19:47PM -0700, Manasi Navare wrote:
> Chris,
> 
> Would you be able to make the necessary changes in the suerspace
> driver so I can do some testing tomorrow?
> 
> Manasi
> 
> On Tue, Oct 25, 2016 at 06:16:34PM -0700, Manasi Navare wrote:
> > A new optional connector property is added for keeping
> > track of whether the link is good (link training passed) or
> > link is bad (link training  failed). If the link status property
> > is Bad, then userspace should fire off a new modeset at the current
> > mode even if there have not been any changes in the mode list
> > or connector status.
> > 
> > Cc: dri-devel@lists.freedesktop.org
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Cc: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > ---
> >  drivers/gpu/drm/drm_connector.c | 32 ++++++++++++++++++++++++++++++++
> >  include/drm/drm_connector.h     |  1 +
> >  include/drm/drm_crtc.h          |  6 ++++++
> >  include/uapi/drm/drm_mode.h     |  4 ++++
> >  4 files changed, 43 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> > index 2db7fb5..b4ce19f 100644
> > --- a/drivers/gpu/drm/drm_connector.c
> > +++ b/drivers/gpu/drm/drm_connector.c
> > @@ -588,6 +588,11 @@ int drm_display_info_set_bus_formats(struct drm_display_info *info,
> >  DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
> >  		 drm_tv_subconnector_enum_list)
> >  
> > +static const struct drm_prop_enum_list drm_link_status_enum_list[] = {
> > +	{ DRM_MODE_LINK_STATUS_GOOD, "Good" },
> > +	{ DRM_MODE_LINK_STATUS_BAD, "Bad" },
> > +};
> > +
> >  int drm_connector_create_standard_properties(struct drm_device *dev)
> >  {
> >  	struct drm_property *prop;
> > @@ -845,6 +850,33 @@ int drm_mode_create_suggested_offset_properties(struct drm_device *dev)
> >  EXPORT_SYMBOL(drm_mode_create_suggested_offset_properties);
> >  
> >  /**
> > + * drm_mode_create_link_status_property - Create link status property
> > + * @dev: DRM device
> > + *
> > + * Called by a driver the first time it's needed, must be attached to desired
> > + * connectors.
> > + * This property is used to indicate whether link sttaus is Good or Bad as
> > + * a result fo link training
> > + */
> > +int drm_mode_create_link_status_property(struct drm_device *dev)
> > +{
> > +	struct drm_property *link_status;
> > +
> > +	if (dev->mode_config.link_status_property)
> > +		return 0;
> > +
> > +	link_status =
> > +		drm_property_create_enum(dev, 0, "link-status",

s/0/DRM_MODE_PROP_IMMUTABLE/

Bikeshed commitee: "link-status" or "link status" or "Link status"
		   "Good" or "good"

Do we want a general term such as bad or more specific error? Anything
not !good is an error, so we are always free to add more if need be.
-Chris
Chris Wilson Oct. 26, 2016, 9:42 a.m. UTC | #4
On Wed, Oct 26, 2016 at 07:52:26AM +0200, Daniel Vetter wrote:
> I'd go further and just always create this as one of the standard
> properties (and always attach it to the connector, like edid), and only
> expose helpers to set the link status to good or bad.

One of the sketches for this idea was that this could serve as the
failure notification path for nonblocking modesets (well modesets in
general since it appears returning the error is not going to happen).
-Chris
Jani Nikula Oct. 26, 2016, 9:51 a.m. UTC | #5
On Wed, 26 Oct 2016, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> On Wed, Oct 26, 2016 at 07:52:26AM +0200, Daniel Vetter wrote:
>> I'd go further and just always create this as one of the standard
>> properties (and always attach it to the connector, like edid), and only
>> expose helpers to set the link status to good or bad.
>
> One of the sketches for this idea was that this could serve as the
> failure notification path for nonblocking modesets (well modesets in
> general since it appears returning the error is not going to happen).

In nonblocking modesets, when should we change the status from bad to
good? If the setcrtc returns and userspace looks at link status and sees
it's still bad (because the kernel hasn't gotten around to enabling the
link yet, or whatever), userspace might think it would have to try
again. Do we set it to good immediately on setcrtc ioctl, or add a
"pending" status? Or something better?

BR,
Jani.
Ville Syrjala Oct. 26, 2016, 11:17 a.m. UTC | #6
On Wed, Oct 26, 2016 at 12:51:41PM +0300, Jani Nikula wrote:
> On Wed, 26 Oct 2016, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > On Wed, Oct 26, 2016 at 07:52:26AM +0200, Daniel Vetter wrote:
> >> I'd go further and just always create this as one of the standard
> >> properties (and always attach it to the connector, like edid), and only
> >> expose helpers to set the link status to good or bad.
> >
> > One of the sketches for this idea was that this could serve as the
> > failure notification path for nonblocking modesets (well modesets in
> > general since it appears returning the error is not going to happen).
> 
> In nonblocking modesets, when should we change the status from bad to
> good? If the setcrtc returns and userspace looks at link status and sees
> it's still bad (because the kernel hasn't gotten around to enabling the
> link yet, or whatever), userspace might think it would have to try
> again. Do we set it to good immediately on setcrtc ioctl, or add a
> "pending" status? Or something better?

I was thinking it'd start out as "good" and only change to something
else when things actually go south.

Not sure if we should also want "off" as one of the values, for when
it's really off at the request of the user.
Chris Wilson Oct. 26, 2016, 1:11 p.m. UTC | #7
On Wed, Oct 26, 2016 at 02:17:16PM +0300, Ville Syrjälä wrote:
> On Wed, Oct 26, 2016 at 12:51:41PM +0300, Jani Nikula wrote:
> > On Wed, 26 Oct 2016, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > > On Wed, Oct 26, 2016 at 07:52:26AM +0200, Daniel Vetter wrote:
> > >> I'd go further and just always create this as one of the standard
> > >> properties (and always attach it to the connector, like edid), and only
> > >> expose helpers to set the link status to good or bad.
> > >
> > > One of the sketches for this idea was that this could serve as the
> > > failure notification path for nonblocking modesets (well modesets in
> > > general since it appears returning the error is not going to happen).
> > 
> > In nonblocking modesets, when should we change the status from bad to
> > good? If the setcrtc returns and userspace looks at link status and sees
> > it's still bad (because the kernel hasn't gotten around to enabling the
> > link yet, or whatever), userspace might think it would have to try
> > again. Do we set it to good immediately on setcrtc ioctl, or add a
> > "pending" status? Or something better?
> 
> I was thinking it'd start out as "good" and only change to something
> else when things actually go south.
> 
> Not sure if we should also want "off" as one of the values, for when
> it's really off at the request of the user.

That's something the user knows. At least, if the ddx has output->crtc
set and sees that link-status=off the response is to say "that can't be
me!" and reapply the desired mode, i.e. same response as if the
link-status was bad. Maybe useful for someone else to differentiate?
-Chris
Ville Syrjala Oct. 26, 2016, 1:15 p.m. UTC | #8
On Wed, Oct 26, 2016 at 02:11:00PM +0100, Chris Wilson wrote:
> On Wed, Oct 26, 2016 at 02:17:16PM +0300, Ville Syrjälä wrote:
> > On Wed, Oct 26, 2016 at 12:51:41PM +0300, Jani Nikula wrote:
> > > On Wed, 26 Oct 2016, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > > > On Wed, Oct 26, 2016 at 07:52:26AM +0200, Daniel Vetter wrote:
> > > >> I'd go further and just always create this as one of the standard
> > > >> properties (and always attach it to the connector, like edid), and only
> > > >> expose helpers to set the link status to good or bad.
> > > >
> > > > One of the sketches for this idea was that this could serve as the
> > > > failure notification path for nonblocking modesets (well modesets in
> > > > general since it appears returning the error is not going to happen).
> > > 
> > > In nonblocking modesets, when should we change the status from bad to
> > > good? If the setcrtc returns and userspace looks at link status and sees
> > > it's still bad (because the kernel hasn't gotten around to enabling the
> > > link yet, or whatever), userspace might think it would have to try
> > > again. Do we set it to good immediately on setcrtc ioctl, or add a
> > > "pending" status? Or something better?
> > 
> > I was thinking it'd start out as "good" and only change to something
> > else when things actually go south.
> > 
> > Not sure if we should also want "off" as one of the values, for when
> > it's really off at the request of the user.
> 
> That's something the user knows. At least, if the ddx has output->crtc
> set and sees that link-status=off the response is to say "that can't be
> me!" and reapply the desired mode, i.e. same response as if the
> link-status was bad. Maybe useful for someone else to differentiate?

Dunno really. If we don't add it we have to define what the link status
will indicate when the thing is really off though. With "good" and "bad"
the only options I guess "good" would be the right answer?
Chris Wilson Oct. 26, 2016, 1:29 p.m. UTC | #9
On Wed, Oct 26, 2016 at 04:15:39PM +0300, Ville Syrjälä wrote:
> On Wed, Oct 26, 2016 at 02:11:00PM +0100, Chris Wilson wrote:
> > On Wed, Oct 26, 2016 at 02:17:16PM +0300, Ville Syrjälä wrote:
> > > On Wed, Oct 26, 2016 at 12:51:41PM +0300, Jani Nikula wrote:
> > > > On Wed, 26 Oct 2016, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > > > > On Wed, Oct 26, 2016 at 07:52:26AM +0200, Daniel Vetter wrote:
> > > > >> I'd go further and just always create this as one of the standard
> > > > >> properties (and always attach it to the connector, like edid), and only
> > > > >> expose helpers to set the link status to good or bad.
> > > > >
> > > > > One of the sketches for this idea was that this could serve as the
> > > > > failure notification path for nonblocking modesets (well modesets in
> > > > > general since it appears returning the error is not going to happen).
> > > > 
> > > > In nonblocking modesets, when should we change the status from bad to
> > > > good? If the setcrtc returns and userspace looks at link status and sees
> > > > it's still bad (because the kernel hasn't gotten around to enabling the
> > > > link yet, or whatever), userspace might think it would have to try
> > > > again. Do we set it to good immediately on setcrtc ioctl, or add a
> > > > "pending" status? Or something better?
> > > 
> > > I was thinking it'd start out as "good" and only change to something
> > > else when things actually go south.
> > > 
> > > Not sure if we should also want "off" as one of the values, for when
> > > it's really off at the request of the user.
> > 
> > That's something the user knows. At least, if the ddx has output->crtc
> > set and sees that link-status=off the response is to say "that can't be
> > me!" and reapply the desired mode, i.e. same response as if the
> > link-status was bad. Maybe useful for someone else to differentiate?
> 
> Dunno really. If we don't add it we have to define what the link status
> will indicate when the thing is really off though. With "good" and "bad"
> the only options I guess "good" would be the right answer?

Fair point.

bad = -1, (any specific error can then be -value)
ok = 0,
suspend,
standy,
off, [looking suspiciously like dpms modes :]
?
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 2db7fb5..b4ce19f 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -588,6 +588,11 @@  int drm_display_info_set_bus_formats(struct drm_display_info *info,
 DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
 		 drm_tv_subconnector_enum_list)
 
+static const struct drm_prop_enum_list drm_link_status_enum_list[] = {
+	{ DRM_MODE_LINK_STATUS_GOOD, "Good" },
+	{ DRM_MODE_LINK_STATUS_BAD, "Bad" },
+};
+
 int drm_connector_create_standard_properties(struct drm_device *dev)
 {
 	struct drm_property *prop;
@@ -845,6 +850,33 @@  int drm_mode_create_suggested_offset_properties(struct drm_device *dev)
 EXPORT_SYMBOL(drm_mode_create_suggested_offset_properties);
 
 /**
+ * drm_mode_create_link_status_property - Create link status property
+ * @dev: DRM device
+ *
+ * Called by a driver the first time it's needed, must be attached to desired
+ * connectors.
+ * This property is used to indicate whether link sttaus is Good or Bad as
+ * a result fo link training
+ */
+int drm_mode_create_link_status_property(struct drm_device *dev)
+{
+	struct drm_property *link_status;
+
+	if (dev->mode_config.link_status_property)
+		return 0;
+
+	link_status =
+		drm_property_create_enum(dev, 0, "link-status",
+					 drm_link_status_enum_list,
+					 ARRAY_SIZE(drm_link_status_enum_list));
+
+	dev->mode_config.scaling_mode_property = link_status;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_link_status_property);
+
+/**
  * drm_mode_connector_set_path_property - set tile property on connector
  * @connector: connector to set property on.
  * @path: path to use for property; must not be NULL.
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index fc9d475..7234c0c 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -759,6 +759,7 @@  int drm_mode_create_tv_properties(struct drm_device *dev,
 int drm_mode_create_scaling_mode_property(struct drm_device *dev);
 int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
 int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
+int drm_mode_create_link_status_property(struct drm_device *dev);
 
 int drm_mode_connector_set_path_property(struct drm_connector *connector,
 					 const char *path);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index fa1aa21..3e9c833 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1343,6 +1343,12 @@  struct drm_mode_config {
 	 */
 	struct drm_property *suggested_y_property;
 
+	/**
+	 * @link_status_property: Optional connector property for link status
+	 * of the connector as a result of link training.
+	 */
+	 struct drm_property *link_status_property;
+
 	/* dumb ioctl parameters */
 	uint32_t preferred_depth, prefer_shadow;
 
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 084b50a..f1b0afd 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -121,6 +121,10 @@ 
 #define DRM_MODE_DIRTY_ON       1
 #define DRM_MODE_DIRTY_ANNOTATE 2
 
+/* Link Status options */
+#define DRM_MODE_LINK_STATUS_GOOD	0
+#define DRM_MODE_LINK_STATUS_BAD	1
+
 struct drm_mode_modeinfo {
 	__u32 clock;
 	__u16 hdisplay;