* [PATCH 0/5] Handle link training failure during modeset
@ 2016-11-15 3:13 Manasi Navare
2016-11-15 3:13 ` [PATCH 1/5] drm: Add a new connector property for link status Manasi Navare
` (6 more replies)
0 siblings, 7 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-15 3:13 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Manasi Navare
Submitting new series that adds proper commit messages/cover letter
and kernel documentation. It also moved the set_link_status function
to drm core so other kernel drivers can make use of it.
The idea presented in these patches is to address link training failure
in a way that:
a) changes the current happy day scenario as little as possible, to avoid
regressions, b) can be implemented the same way by all drm drivers, c)
is still opt-in for the drivers and userspace, and opting out doesn't
regress the user experience, d) doesn't prevent drivers from
implementing better or alternate approaches, possibly without userspace
involvement. And, of course, handles all the issues presented.
The solution is to add a "link status" connector property. In the usual
happy day scenario, this is always "good". If something fails during or
after a mode set, the kernel driver can set the link status to "bad",
prune the mode list based on new information as necessary, and send a
hotplug uevent for userspace to have it re-check the valid modes through
getconnector, and try again. If the theoretical capabilities of the link
can't be reached, the mode list is trimmed based on that.
If the userspace is not aware of the property, the user experience is
the same as it currently is. If the userspace is aware of the property,
it has a chance to improve user experience. If a drm driver does not
modify the property (it stays "good"), the user experience is the same
as it currently is. A drm driver can also choose to try to handle more
of the failures in kernel, hardware not limiting, or it can choose to
involve userspace more. Up to the drivers.
The reason for adding the property is to handle link training failures,
but it is not limited to DP or link training. For example, if we
implement asynchronous setcrtc, we can use this to report any failures
in that.
Finally, while DP CTS compliance is advertized (which is great, and
could be made to work similarly for all drm drivers), this can be used
for the more important goal of improving user experience on link
training failures, by avoiding black screens.
Acked-by: Tony Cheng <tony.cheng@amd.com>
Acked-by: Harry Wentland <Harry.wentland@amd.com>
Manasi Navare (5):
drm: Add a new connector property for link status
drm: Set DRM connector link status property
drm/i915: Update CRTC state if connector link status property changed
drm/i915: Find fallback link rate/lane count
drm/i915: Implement Link Rate fallback on Link training failure
drivers/gpu/drm/drm_atomic_helper.c | 7 ++
drivers/gpu/drm/drm_connector.c | 55 ++++++++++
drivers/gpu/drm/i915/intel_ddi.c | 21 +++-
drivers/gpu/drm/i915/intel_dp.c | 144 +++++++++++++++++++++++++-
drivers/gpu/drm/i915/intel_dp_link_training.c | 12 ++-
drivers/gpu/drm/i915/intel_drv.h | 10 +-
include/drm/drm_connector.h | 9 +-
include/drm/drm_crtc.h | 5 +
include/uapi/drm/drm_mode.h | 4 +
9 files changed, 257 insertions(+), 10 deletions(-)
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 1/5] drm: Add a new connector property for link status
2016-11-15 3:13 [PATCH 0/5] Handle link training failure during modeset Manasi Navare
@ 2016-11-15 3:13 ` Manasi Navare
2016-11-15 3:13 ` [PATCH 2/5] drm: Set DRM connector link status property Manasi Navare
` (5 subsequent siblings)
6 siblings, 0 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-15 3:13 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Manasi Navare, Daniel Vetter
A new default 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 not good, 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.
Also add link status connector member corersponding to the
decoded value of link status property.
v3:
* Drop "link training" from description since this is
not specific to DP (Jani Nikula)
* Add link status member to store property value locally
(Ville Syrjala)
v2:
* Make this a default connector property (Daniel Vetter)
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
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 | 17 +++++++++++++++++
include/drm/drm_connector.h | 7 ++++++-
include/drm/drm_crtc.h | 5 +++++
include/uapi/drm/drm_mode.h | 4 ++++
4 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 2db7fb5..d4e852f 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -243,6 +243,10 @@ int drm_connector_init(struct drm_device *dev,
drm_object_attach_property(&connector->base,
config->dpms_property, 0);
+ drm_object_attach_property(&connector->base,
+ config->link_status_property,
+ 0);
+
if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
drm_object_attach_property(&connector->base, config->prop_crtc_id, 0);
}
@@ -506,6 +510,12 @@ const char *drm_get_subpixel_order_name(enum subpixel_order order)
};
DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_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" },
+};
+DRM_ENUM_NAME_FN(drm_get_link_status_name, drm_link_status_enum_list)
+
/**
* drm_display_info_set_bus_formats - set the supported bus formats
* @info: display info to store bus formats in
@@ -622,6 +632,13 @@ int drm_connector_create_standard_properties(struct drm_device *dev)
return -ENOMEM;
dev->mode_config.tile_property = prop;
+ prop = drm_property_create_enum(dev, 0, "link-status",
+ drm_link_status_enum_list,
+ ARRAY_SIZE(drm_link_status_enum_list));
+ if (!prop)
+ return -ENOMEM;
+ dev->mode_config.link_status_property = prop;
+
return 0;
}
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 3e97272..ad5c8b0 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -695,6 +695,12 @@ struct drm_connector {
uint8_t num_h_tile, num_v_tile;
uint8_t tile_h_loc, tile_v_loc;
uint16_t tile_h_size, tile_v_size;
+
+ /* Connector Link status
+ * 0: If the link is Good
+ * 1: If the link is Bad
+ */
+ int link_status;
};
#define obj_to_connector(x) container_of(x, struct drm_connector, base)
@@ -767,7 +773,6 @@ 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_connector_set_path_property(struct drm_connector *connector,
const char *path);
int drm_mode_connector_set_tile_property(struct drm_connector *connector);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 8cca2a8..a93148b 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1164,6 +1164,11 @@ struct drm_mode_config {
*/
struct drm_property *tile_property;
/**
+ * @link_status_property: Default connector property for link status
+ * of a connector
+ */
+ struct drm_property *link_status_property;
+ /**
* @plane_type_property: Default plane property to differentiate
* CURSOR, PRIMARY and OVERLAY legacy uses of planes.
*/
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 01000c9..66b145b 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -129,6 +129,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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 2/5] drm: Set DRM connector link status property
2016-11-15 3:13 [PATCH 0/5] Handle link training failure during modeset Manasi Navare
2016-11-15 3:13 ` [PATCH 1/5] drm: Add a new connector property for link status Manasi Navare
@ 2016-11-15 3:13 ` Manasi Navare
2016-11-15 3:23 ` Manasi Navare
` (3 more replies)
2016-11-15 3:13 ` [PATCH 3/5] drm/i915: Update CRTC state if connector link status property changed Manasi Navare
` (4 subsequent siblings)
6 siblings, 4 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-15 3:13 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Daniel Vetter
In the usual working scenarios, this property is "Good".
If something fails during modeset, the DRM driver can
set the link status to "Bad", prune the mode list based on the
link rate/lane count fallback values and send hotplug uevent
so that userspace that is aware of this property can take an
appropriate action by reprobing connectors and re triggering
a modeset to improve user experience and avoid black screens.
In case of userspace that is not aware of this link status
property, the user experience will be unchanged.
The reason for adding the property is to handle link training failures,
but it is not limited to DP or link training. For example, if we
implement asynchronous setcrtc, we can use this to report any failures
in that.
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>
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
---
drivers/gpu/drm/drm_connector.c | 38 ++++++++++++++++++++++++++++++++++++++
include/drm/drm_connector.h | 2 ++
2 files changed, 40 insertions(+)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index d4e852f..09f4093 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -968,6 +968,44 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
}
EXPORT_SYMBOL(drm_mode_connector_update_edid_property);
+/**
+ * drm_mode_connector_set_link_status_property - Set the link status property of
+ * a connector to indicate status of link as a result of link training.
+ * @connector: drm connector
+ * @link_status: new value of link status property (0: Good, 1: Bad)
+ *
+ * In usual working scenario, this link status property will always be set to
+ * "GOOD".
+ * If something fails during or after a mode set, the kernel driver can set this
+ * link status to "BAD", prune the mode list based on new information and send a
+ * hotplug uevent for userspace to have it re-check the valid modes through
+ * Get_connector and try again.
+ *
+ * If userspace is not aware of this property, the user experience is the same
+ * as it currently is. If the userspace is aware of the property, it has a chance
+ * to improve user experience by handling link training failures, avoiding black
+ * screens. The DRM driver can chose to not modify property and keep link status
+ * as "GOOD" always to keep the user experience same as it currently is.
+ *
+ * The reason for adding this property is to handle link training failures, but
+ * it is not limited to DP or link training. For example, if we implement
+ * asynchronous setcrtc, this property can be used to reportany failures in that.
+ *
+ * This function must be called from asynchronous work item.
+ * Returns zero on success and negative errrno on failure.
+ */
+int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
+ uint64_t link_status)
+{
+ struct drm_device *dev = connector->dev;
+
+ connector->link_status = link_status;
+ return drm_object_property_set_value(&connector->base,
+ dev->mode_config.link_status_property,
+ link_status);
+}
+EXPORT_SYMBOL(drm_mode_connector_set_link_status_property);
+
int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
struct drm_property *property,
uint64_t value)
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index ad5c8b0..ac76469 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -778,6 +778,8 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
int drm_mode_connector_set_tile_property(struct drm_connector *connector);
int drm_mode_connector_update_edid_property(struct drm_connector *connector,
const struct edid *edid);
+int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
+ uint64_t link_status);
/**
* drm_for_each_connector - iterate over all connectors
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 2/5] drm: Set DRM connector link status property
2016-11-15 3:13 ` [PATCH 2/5] drm: Set DRM connector link status property Manasi Navare
@ 2016-11-15 3:23 ` Manasi Navare
2016-11-15 7:50 ` Daniel Vetter
2016-11-15 7:49 ` [Intel-gfx] " Daniel Vetter
` (2 subsequent siblings)
3 siblings, 1 reply; 31+ messages in thread
From: Manasi Navare @ 2016-11-15 3:23 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Daniel Vetter
None of the other functions that set the connector property hold the
mode config locks while setting the connector property, I am following
the same convention.
Also we dont need to grab and release the locks in i915_modeset_work_func
that first validates the modes and then sets this link status property.
Manasi
On Mon, Nov 14, 2016 at 07:13:20PM -0800, Manasi Navare wrote:
> In the usual working scenarios, this property is "Good".
> If something fails during modeset, the DRM driver can
> set the link status to "Bad", prune the mode list based on the
> link rate/lane count fallback values and send hotplug uevent
> so that userspace that is aware of this property can take an
> appropriate action by reprobing connectors and re triggering
> a modeset to improve user experience and avoid black screens.
> In case of userspace that is not aware of this link status
> property, the user experience will be unchanged.
>
> The reason for adding the property is to handle link training failures,
> but it is not limited to DP or link training. For example, if we
> implement asynchronous setcrtc, we can use this to report any failures
> in that.
>
> 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>
> Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> ---
> drivers/gpu/drm/drm_connector.c | 38 ++++++++++++++++++++++++++++++++++++++
> include/drm/drm_connector.h | 2 ++
> 2 files changed, 40 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index d4e852f..09f4093 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -968,6 +968,44 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> }
> EXPORT_SYMBOL(drm_mode_connector_update_edid_property);
>
> +/**
> + * drm_mode_connector_set_link_status_property - Set the link status property of
> + * a connector to indicate status of link as a result of link training.
> + * @connector: drm connector
> + * @link_status: new value of link status property (0: Good, 1: Bad)
> + *
> + * In usual working scenario, this link status property will always be set to
> + * "GOOD".
> + * If something fails during or after a mode set, the kernel driver can set this
> + * link status to "BAD", prune the mode list based on new information and send a
> + * hotplug uevent for userspace to have it re-check the valid modes through
> + * Get_connector and try again.
> + *
> + * If userspace is not aware of this property, the user experience is the same
> + * as it currently is. If the userspace is aware of the property, it has a chance
> + * to improve user experience by handling link training failures, avoiding black
> + * screens. The DRM driver can chose to not modify property and keep link status
> + * as "GOOD" always to keep the user experience same as it currently is.
> + *
> + * The reason for adding this property is to handle link training failures, but
> + * it is not limited to DP or link training. For example, if we implement
> + * asynchronous setcrtc, this property can be used to reportany failures in that.
> + *
> + * This function must be called from asynchronous work item.
> + * Returns zero on success and negative errrno on failure.
> + */
> +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> + uint64_t link_status)
> +{
> + struct drm_device *dev = connector->dev;
> +
> + connector->link_status = link_status;
> + return drm_object_property_set_value(&connector->base,
> + dev->mode_config.link_status_property,
> + link_status);
> +}
> +EXPORT_SYMBOL(drm_mode_connector_set_link_status_property);
> +
> int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
> struct drm_property *property,
> uint64_t value)
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index ad5c8b0..ac76469 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -778,6 +778,8 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
> int drm_mode_connector_set_tile_property(struct drm_connector *connector);
> int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> const struct edid *edid);
> +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> + uint64_t link_status);
>
> /**
> * drm_for_each_connector - iterate over all connectors
> --
> 1.9.1
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 2/5] drm: Set DRM connector link status property
2016-11-15 3:23 ` Manasi Navare
@ 2016-11-15 7:50 ` Daniel Vetter
0 siblings, 0 replies; 31+ messages in thread
From: Daniel Vetter @ 2016-11-15 7:50 UTC (permalink / raw)
To: Manasi Navare; +Cc: Daniel Vetter, intel-gfx, dri-devel
On Mon, Nov 14, 2016 at 07:23:33PM -0800, Manasi Navare wrote:
> None of the other functions that set the connector property hold the
> mode config locks while setting the connector property, I am following
> the same convention.
> Also we dont need to grab and release the locks in i915_modeset_work_func
> that first validates the modes and then sets this link status property.
Which other functions don't hold the mode_config.mutex?
-Daniel
>
> Manasi
>
> On Mon, Nov 14, 2016 at 07:13:20PM -0800, Manasi Navare wrote:
> > In the usual working scenarios, this property is "Good".
> > If something fails during modeset, the DRM driver can
> > set the link status to "Bad", prune the mode list based on the
> > link rate/lane count fallback values and send hotplug uevent
> > so that userspace that is aware of this property can take an
> > appropriate action by reprobing connectors and re triggering
> > a modeset to improve user experience and avoid black screens.
> > In case of userspace that is not aware of this link status
> > property, the user experience will be unchanged.
> >
> > The reason for adding the property is to handle link training failures,
> > but it is not limited to DP or link training. For example, if we
> > implement asynchronous setcrtc, we can use this to report any failures
> > in that.
> >
> > 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>
> > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > ---
> > drivers/gpu/drm/drm_connector.c | 38 ++++++++++++++++++++++++++++++++++++++
> > include/drm/drm_connector.h | 2 ++
> > 2 files changed, 40 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> > index d4e852f..09f4093 100644
> > --- a/drivers/gpu/drm/drm_connector.c
> > +++ b/drivers/gpu/drm/drm_connector.c
> > @@ -968,6 +968,44 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> > }
> > EXPORT_SYMBOL(drm_mode_connector_update_edid_property);
> >
> > +/**
> > + * drm_mode_connector_set_link_status_property - Set the link status property of
> > + * a connector to indicate status of link as a result of link training.
> > + * @connector: drm connector
> > + * @link_status: new value of link status property (0: Good, 1: Bad)
> > + *
> > + * In usual working scenario, this link status property will always be set to
> > + * "GOOD".
> > + * If something fails during or after a mode set, the kernel driver can set this
> > + * link status to "BAD", prune the mode list based on new information and send a
> > + * hotplug uevent for userspace to have it re-check the valid modes through
> > + * Get_connector and try again.
> > + *
> > + * If userspace is not aware of this property, the user experience is the same
> > + * as it currently is. If the userspace is aware of the property, it has a chance
> > + * to improve user experience by handling link training failures, avoiding black
> > + * screens. The DRM driver can chose to not modify property and keep link status
> > + * as "GOOD" always to keep the user experience same as it currently is.
> > + *
> > + * The reason for adding this property is to handle link training failures, but
> > + * it is not limited to DP or link training. For example, if we implement
> > + * asynchronous setcrtc, this property can be used to reportany failures in that.
> > + *
> > + * This function must be called from asynchronous work item.
> > + * Returns zero on success and negative errrno on failure.
> > + */
> > +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> > + uint64_t link_status)
> > +{
> > + struct drm_device *dev = connector->dev;
> > +
> > + connector->link_status = link_status;
> > + return drm_object_property_set_value(&connector->base,
> > + dev->mode_config.link_status_property,
> > + link_status);
> > +}
> > +EXPORT_SYMBOL(drm_mode_connector_set_link_status_property);
> > +
> > int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
> > struct drm_property *property,
> > uint64_t value)
> > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> > index ad5c8b0..ac76469 100644
> > --- a/include/drm/drm_connector.h
> > +++ b/include/drm/drm_connector.h
> > @@ -778,6 +778,8 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
> > int drm_mode_connector_set_tile_property(struct drm_connector *connector);
> > int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> > const struct edid *edid);
> > +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> > + uint64_t link_status);
> >
> > /**
> > * drm_for_each_connector - iterate over all connectors
> > --
> > 1.9.1
> >
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [Intel-gfx] [PATCH 2/5] drm: Set DRM connector link status property
2016-11-15 3:13 ` [PATCH 2/5] drm: Set DRM connector link status property Manasi Navare
2016-11-15 3:23 ` Manasi Navare
@ 2016-11-15 7:49 ` Daniel Vetter
2016-11-15 23:56 ` Manasi Navare
2016-11-15 7:53 ` Daniel Vetter
2016-11-16 1:58 ` [PATCH v2 " Manasi Navare
3 siblings, 1 reply; 31+ messages in thread
From: Daniel Vetter @ 2016-11-15 7:49 UTC (permalink / raw)
To: Manasi Navare; +Cc: Daniel Vetter, intel-gfx, dri-devel
On Mon, Nov 14, 2016 at 07:13:20PM -0800, Manasi Navare wrote:
> In the usual working scenarios, this property is "Good".
> If something fails during modeset, the DRM driver can
> set the link status to "Bad", prune the mode list based on the
> link rate/lane count fallback values and send hotplug uevent
> so that userspace that is aware of this property can take an
> appropriate action by reprobing connectors and re triggering
> a modeset to improve user experience and avoid black screens.
> In case of userspace that is not aware of this link status
> property, the user experience will be unchanged.
>
> The reason for adding the property is to handle link training failures,
> but it is not limited to DP or link training. For example, if we
> implement asynchronous setcrtc, we can use this to report any failures
> in that.
>
> 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>
> Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> ---
> drivers/gpu/drm/drm_connector.c | 38 ++++++++++++++++++++++++++++++++++++++
> include/drm/drm_connector.h | 2 ++
> 2 files changed, 40 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index d4e852f..09f4093 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -968,6 +968,44 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> }
> EXPORT_SYMBOL(drm_mode_connector_update_edid_property);
>
> +/**
> + * drm_mode_connector_set_link_status_property - Set the link status property of
> + * a connector to indicate status of link as a result of link training.
iirc this continuation upsets kernel-doc. Did you build the docs and
review them? You need to indent the 2nd line.
Also, might just shorten it to "set link status for a connector", details
are for the text below.
> + * @connector: drm connector
> + * @link_status: new value of link status property (0: Good, 1: Bad)
> + *
> + * In usual working scenario, this link status property will always be set to
> + * "GOOD".
Unecessary linebbreak. Either make a full paragraph (empty line) or
reflow, this here won't survivie kernel-doc formatting.
> + * If something fails during or after a mode set, the kernel driver can set this
> + * link status to "BAD", prune the mode list based on new information and send a
First need to prune the mode list, then set the property. Please reorder
in your text.
> + * hotplug uevent for userspace to have it re-check the valid modes through
> + * Get_connector and try again.
s/Get_connector/GET_CONNECTOR IOCTL/ is the more usual style.
> + *
> + * If userspace is not aware of this property, the user experience is the same
> + * as it currently is. If the userspace is aware of the property, it has a chance
> + * to improve user experience by handling link training failures, avoiding black
> + * screens. The DRM driver can chose to not modify property and keep link status
> + * as "GOOD" always to keep the user experience same as it currently is.
Imo this paragraph isn't needed. Maybe just mention that old userspace
exists:
"Note that a lot of existing userspace doesn't handle this property.
Drivers can therefore not rely on userspace to fix up everything and
should try to handle issues (like just re-training a link) without
userspace's intervention. This should only be used when the current mode
doesn't work any more, and userspace must select a different display
mode."
> + *
> + * The reason for adding this property is to handle link training failures, but
> + * it is not limited to DP or link training. For example, if we implement
> + * asynchronous setcrtc, this property can be used to reportany failures in that.
s/reportany/report/
> + *
> + * This function must be called from asynchronous work item.
This isn't true - it doesn't require an asynchronous work item, but the
locking rules mean that it.
> + * Returns zero on success and negative errrno on failure.
Hm, why can this ever fail? Intuitively this should never fail, and hence
we shouldn't need an error return value.
> + */
> +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> + uint64_t link_status)
> +{
> + struct drm_device *dev = connector->dev;
> +
> + connector->link_status = link_status;
> + return drm_object_property_set_value(&connector->base,
> + dev->mode_config.link_status_property,
> + link_status);
This misses the hotplug_event call from my proposal. Intentionally? Why?
Also: With the current code you require that mode_config.mutex is held by
the caller. Every time you add a library/core function which requires
certain locks to be held, please check that with something like
lockdep_assert_held or similar. Leaking locking rules to callers like this
should be the exception, not the rule.
But with my proposal this function here would grab all necessary locks,
solving that problem, too.
-Daniel
> +}
> +EXPORT_SYMBOL(drm_mode_connector_set_link_status_property);
> +
> int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
> struct drm_property *property,
> uint64_t value)
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index ad5c8b0..ac76469 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -778,6 +778,8 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
> int drm_mode_connector_set_tile_property(struct drm_connector *connector);
> int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> const struct edid *edid);
> +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> + uint64_t link_status);
>
> /**
> * drm_for_each_connector - iterate over all connectors
> --
> 1.9.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 2/5] drm: Set DRM connector link status property
2016-11-15 7:49 ` [Intel-gfx] " Daniel Vetter
@ 2016-11-15 23:56 ` Manasi Navare
2016-11-16 7:35 ` [Intel-gfx] " Daniel Vetter
0 siblings, 1 reply; 31+ messages in thread
From: Manasi Navare @ 2016-11-15 23:56 UTC (permalink / raw)
To: Daniel Vetter; +Cc: Daniel Vetter, intel-gfx, dri-devel
On Tue, Nov 15, 2016 at 08:49:21AM +0100, Daniel Vetter wrote:
> On Mon, Nov 14, 2016 at 07:13:20PM -0800, Manasi Navare wrote:
> > In the usual working scenarios, this property is "Good".
> > If something fails during modeset, the DRM driver can
> > set the link status to "Bad", prune the mode list based on the
> > link rate/lane count fallback values and send hotplug uevent
> > so that userspace that is aware of this property can take an
> > appropriate action by reprobing connectors and re triggering
> > a modeset to improve user experience and avoid black screens.
> > In case of userspace that is not aware of this link status
> > property, the user experience will be unchanged.
> >
> > The reason for adding the property is to handle link training failures,
> > but it is not limited to DP or link training. For example, if we
> > implement asynchronous setcrtc, we can use this to report any failures
> > in that.
> >
> > 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>
> > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > ---
> > drivers/gpu/drm/drm_connector.c | 38 ++++++++++++++++++++++++++++++++++++++
> > include/drm/drm_connector.h | 2 ++
> > 2 files changed, 40 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> > index d4e852f..09f4093 100644
> > --- a/drivers/gpu/drm/drm_connector.c
> > +++ b/drivers/gpu/drm/drm_connector.c
> > @@ -968,6 +968,44 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> > }
> > EXPORT_SYMBOL(drm_mode_connector_update_edid_property);
> >
> > +/**
> > + * drm_mode_connector_set_link_status_property - Set the link status property of
> > + * a connector to indicate status of link as a result of link training.
>
> iirc this continuation upsets kernel-doc. Did you build the docs and
> review them? You need to indent the 2nd line.
>
I built the docs and didnt see any issue with the docs, but I will shorten
the description.
> Also, might just shorten it to "set link status for a connector", details
> are for the text below.
>
> > + * @connector: drm connector
> > + * @link_status: new value of link status property (0: Good, 1: Bad)
> > + *
> > + * In usual working scenario, this link status property will always be set to
> > + * "GOOD".
>
> Unecessary linebbreak. Either make a full paragraph (empty line) or
> reflow, this here won't survivie kernel-doc formatting.
>
Agree, will fix this.
> > + * If something fails during or after a mode set, the kernel driver can set this
> > + * link status to "BAD", prune the mode list based on new information and send a
>
> First need to prune the mode list, then set the property. Please reorder
> in your text.
>
> > + * hotplug uevent for userspace to have it re-check the valid modes through
> > + * Get_connector and try again.
>
> s/Get_connector/GET_CONNECTOR IOCTL/ is the more usual style.
>
> > + *
> > + * If userspace is not aware of this property, the user experience is the same
> > + * as it currently is. If the userspace is aware of the property, it has a chance
> > + * to improve user experience by handling link training failures, avoiding black
> > + * screens. The DRM driver can chose to not modify property and keep link status
> > + * as "GOOD" always to keep the user experience same as it currently is.
>
> Imo this paragraph isn't needed. Maybe just mention that old userspace
> exists:
>
I think keeping this paragraph is important to give the readers good idea of how this
will affect the user experience.
> "Note that a lot of existing userspace doesn't handle this property.
> Drivers can therefore not rely on userspace to fix up everything and
> should try to handle issues (like just re-training a link) without
> userspace's intervention. This should only be used when the current mode
> doesn't work any more, and userspace must select a different display
> mode."
>
But atleast the way i915 uses this is in both cases where current mode
does not get pruned but need sto be retried and also when current mode
is no longer valid and gets pruned and modeset is done at a lower mode.
But in either case if link training fails, this property is set to BAD.
Manasi
> > + *
> > + * The reason for adding this property is to handle link training failures, but
> > + * it is not limited to DP or link training. For example, if we implement
> > + * asynchronous setcrtc, this property can be used to reportany failures in that.
>
> s/reportany/report/
>
> > + *
> > + * This function must be called from asynchronous work item.
>
> This isn't true - it doesn't require an asynchronous work item, but the
> locking rules mean that it.
>
> > + * Returns zero on success and negative errrno on failure.
>
> Hm, why can this ever fail? Intuitively this should never fail, and hence
> we shouldn't need an error return value.
>
Ok, yes agree will change it to return void.
> > + */
> > +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> > + uint64_t link_status)
> > +{
> > + struct drm_device *dev = connector->dev;
> > +
> > + connector->link_status = link_status;
> > + return drm_object_property_set_value(&connector->base,
> > + dev->mode_config.link_status_property,
> > + link_status);
>
> This misses the hotplug_event call from my proposal. Intentionally? Why?
>
> Also: With the current code you require that mode_config.mutex is held by
> the caller. Every time you add a library/core function which requires
> certain locks to be held, please check that with something like
> lockdep_assert_held or similar. Leaking locking rules to callers like this
> should be the exception, not the rule.
>
> But with my proposal this function here would grab all necessary locks,
> solving that problem, too.
> -Daniel
>
As per our IRC chat, I am going to leave ueventc calling to the caller
of this function.
> > +}
> > +EXPORT_SYMBOL(drm_mode_connector_set_link_status_property);
> > +
> > int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
> > struct drm_property *property,
> > uint64_t value)
> > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> > index ad5c8b0..ac76469 100644
> > --- a/include/drm/drm_connector.h
> > +++ b/include/drm/drm_connector.h
> > @@ -778,6 +778,8 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
> > int drm_mode_connector_set_tile_property(struct drm_connector *connector);
> > int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> > const struct edid *edid);
> > +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> > + uint64_t link_status);
> >
> > /**
> > * drm_for_each_connector - iterate over all connectors
> > --
> > 1.9.1
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [Intel-gfx] [PATCH 2/5] drm: Set DRM connector link status property
2016-11-15 23:56 ` Manasi Navare
@ 2016-11-16 7:35 ` Daniel Vetter
0 siblings, 0 replies; 31+ messages in thread
From: Daniel Vetter @ 2016-11-16 7:35 UTC (permalink / raw)
To: Manasi Navare; +Cc: Daniel Vetter, intel-gfx, dri-devel
On Tue, Nov 15, 2016 at 03:56:09PM -0800, Manasi Navare wrote:
> On Tue, Nov 15, 2016 at 08:49:21AM +0100, Daniel Vetter wrote:
> > On Mon, Nov 14, 2016 at 07:13:20PM -0800, Manasi Navare wrote:
> > > + * If userspace is not aware of this property, the user experience is the same
> > > + * as it currently is. If the userspace is aware of the property, it has a chance
> > > + * to improve user experience by handling link training failures, avoiding black
> > > + * screens. The DRM driver can chose to not modify property and keep link status
> > > + * as "GOOD" always to keep the user experience same as it currently is.
> >
> > Imo this paragraph isn't needed. Maybe just mention that old userspace
> > exists:
> >
>
> I think keeping this paragraph is important to give the readers good idea of how this
> will affect the user experience.
Well generally the kernel is _really_ far away from the user experience. I
guess that's what makes this paragraph look strange to me, and why I
reworded it. Generally the next thing that matters from the kernel pov is
the compositor and it's display driver, hence why I used "userspace"
instead of "user experience". What userspace (the code) is supposed to do
is imo really important for new uabi, what the user experience ends up
being, that depends upon the entire stack (of which we control very
little, e.g. on Xorg we'll only send a hotplug event over Xrandr and let
some desktop thing handle the real mode change), and it's also fairly
abstract.
> > "Note that a lot of existing userspace doesn't handle this property.
> > Drivers can therefore not rely on userspace to fix up everything and
> > should try to handle issues (like just re-training a link) without
> > userspace's intervention. This should only be used when the current mode
> > doesn't work any more, and userspace must select a different display
> > mode."
> >
>
> But atleast the way i915 uses this is in both cases where current mode
> does not get pruned but need sto be retried and also when current mode
> is no longer valid and gets pruned and modeset is done at a lower mode.
> But in either case if link training fails, this property is set to BAD.
Yeah, hence "should" and not "must", and even i915 does handle some
situations itself: E.g. if just retraining works out with different
training settings, then we don't need to involve userspace, despite that
the link went bad for a bit.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [Intel-gfx] [PATCH 2/5] drm: Set DRM connector link status property
2016-11-15 3:13 ` [PATCH 2/5] drm: Set DRM connector link status property Manasi Navare
2016-11-15 3:23 ` Manasi Navare
2016-11-15 7:49 ` [Intel-gfx] " Daniel Vetter
@ 2016-11-15 7:53 ` Daniel Vetter
2016-11-16 1:13 ` Manasi Navare
2016-11-16 1:58 ` [PATCH v2 " Manasi Navare
3 siblings, 1 reply; 31+ messages in thread
From: Daniel Vetter @ 2016-11-15 7:53 UTC (permalink / raw)
To: Manasi Navare; +Cc: Daniel Vetter, intel-gfx, dri-devel
On Mon, Nov 14, 2016 at 07:13:20PM -0800, Manasi Navare wrote:
> In the usual working scenarios, this property is "Good".
> If something fails during modeset, the DRM driver can
> set the link status to "Bad", prune the mode list based on the
> link rate/lane count fallback values and send hotplug uevent
> so that userspace that is aware of this property can take an
> appropriate action by reprobing connectors and re triggering
> a modeset to improve user experience and avoid black screens.
> In case of userspace that is not aware of this link status
> property, the user experience will be unchanged.
>
> The reason for adding the property is to handle link training failures,
> but it is not limited to DP or link training. For example, if we
> implement asynchronous setcrtc, we can use this to report any failures
> in that.
>
> 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>
> Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
One more thing I've forgotten: Just adding the kernel-doc isn't enough
yet, we need to link this new property into the overall property
documentations.
We already have a section "KMS Properties" in
Documentation/gpu/drm-kms.rst, I think adding a new sub-section called
"Standard Connector Properties" there with a definition list pointing to
this function here would be best.
-Daniel
> ---
> drivers/gpu/drm/drm_connector.c | 38 ++++++++++++++++++++++++++++++++++++++
> include/drm/drm_connector.h | 2 ++
> 2 files changed, 40 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index d4e852f..09f4093 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -968,6 +968,44 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> }
> EXPORT_SYMBOL(drm_mode_connector_update_edid_property);
>
> +/**
> + * drm_mode_connector_set_link_status_property - Set the link status property of
> + * a connector to indicate status of link as a result of link training.
> + * @connector: drm connector
> + * @link_status: new value of link status property (0: Good, 1: Bad)
> + *
> + * In usual working scenario, this link status property will always be set to
> + * "GOOD".
> + * If something fails during or after a mode set, the kernel driver can set this
> + * link status to "BAD", prune the mode list based on new information and send a
> + * hotplug uevent for userspace to have it re-check the valid modes through
> + * Get_connector and try again.
> + *
> + * If userspace is not aware of this property, the user experience is the same
> + * as it currently is. If the userspace is aware of the property, it has a chance
> + * to improve user experience by handling link training failures, avoiding black
> + * screens. The DRM driver can chose to not modify property and keep link status
> + * as "GOOD" always to keep the user experience same as it currently is.
> + *
> + * The reason for adding this property is to handle link training failures, but
> + * it is not limited to DP or link training. For example, if we implement
> + * asynchronous setcrtc, this property can be used to reportany failures in that.
> + *
> + * This function must be called from asynchronous work item.
> + * Returns zero on success and negative errrno on failure.
> + */
> +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> + uint64_t link_status)
> +{
> + struct drm_device *dev = connector->dev;
> +
> + connector->link_status = link_status;
> + return drm_object_property_set_value(&connector->base,
> + dev->mode_config.link_status_property,
> + link_status);
> +}
> +EXPORT_SYMBOL(drm_mode_connector_set_link_status_property);
> +
> int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
> struct drm_property *property,
> uint64_t value)
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index ad5c8b0..ac76469 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -778,6 +778,8 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
> int drm_mode_connector_set_tile_property(struct drm_connector *connector);
> int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> const struct edid *edid);
> +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> + uint64_t link_status);
>
> /**
> * drm_for_each_connector - iterate over all connectors
> --
> 1.9.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [Intel-gfx] [PATCH 2/5] drm: Set DRM connector link status property
2016-11-15 7:53 ` Daniel Vetter
@ 2016-11-16 1:13 ` Manasi Navare
2016-11-16 7:29 ` Daniel Vetter
0 siblings, 1 reply; 31+ messages in thread
From: Manasi Navare @ 2016-11-16 1:13 UTC (permalink / raw)
To: Daniel Vetter; +Cc: Daniel Vetter, intel-gfx, dri-devel
On Tue, Nov 15, 2016 at 08:53:27AM +0100, Daniel Vetter wrote:
> On Mon, Nov 14, 2016 at 07:13:20PM -0800, Manasi Navare wrote:
> > In the usual working scenarios, this property is "Good".
> > If something fails during modeset, the DRM driver can
> > set the link status to "Bad", prune the mode list based on the
> > link rate/lane count fallback values and send hotplug uevent
> > so that userspace that is aware of this property can take an
> > appropriate action by reprobing connectors and re triggering
> > a modeset to improve user experience and avoid black screens.
> > In case of userspace that is not aware of this link status
> > property, the user experience will be unchanged.
> >
> > The reason for adding the property is to handle link training failures,
> > but it is not limited to DP or link training. For example, if we
> > implement asynchronous setcrtc, we can use this to report any failures
> > in that.
> >
> > 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>
> > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
>
> One more thing I've forgotten: Just adding the kernel-doc isn't enough
> yet, we need to link this new property into the overall property
> documentations.
>
> We already have a section "KMS Properties" in
> Documentation/gpu/drm-kms.rst, I think adding a new sub-section called
> "Standard Connector Properties" there with a definition list pointing to
> this function here would be best.
> -Daniel
>
What about other standard proprties like EDID etc? And could you give an
example for writing out a definition list there pointing to this function?
This .rst file currently consists of kernel::doc:: and paths for .h files
Manasi
> > ---
> > drivers/gpu/drm/drm_connector.c | 38 ++++++++++++++++++++++++++++++++++++++
> > include/drm/drm_connector.h | 2 ++
> > 2 files changed, 40 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> > index d4e852f..09f4093 100644
> > --- a/drivers/gpu/drm/drm_connector.c
> > +++ b/drivers/gpu/drm/drm_connector.c
> > @@ -968,6 +968,44 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> > }
> > EXPORT_SYMBOL(drm_mode_connector_update_edid_property);
> >
> > +/**
> > + * drm_mode_connector_set_link_status_property - Set the link status property of
> > + * a connector to indicate status of link as a result of link training.
> > + * @connector: drm connector
> > + * @link_status: new value of link status property (0: Good, 1: Bad)
> > + *
> > + * In usual working scenario, this link status property will always be set to
> > + * "GOOD".
> > + * If something fails during or after a mode set, the kernel driver can set this
> > + * link status to "BAD", prune the mode list based on new information and send a
> > + * hotplug uevent for userspace to have it re-check the valid modes through
> > + * Get_connector and try again.
> > + *
> > + * If userspace is not aware of this property, the user experience is the same
> > + * as it currently is. If the userspace is aware of the property, it has a chance
> > + * to improve user experience by handling link training failures, avoiding black
> > + * screens. The DRM driver can chose to not modify property and keep link status
> > + * as "GOOD" always to keep the user experience same as it currently is.
> > + *
> > + * The reason for adding this property is to handle link training failures, but
> > + * it is not limited to DP or link training. For example, if we implement
> > + * asynchronous setcrtc, this property can be used to reportany failures in that.
> > + *
> > + * This function must be called from asynchronous work item.
> > + * Returns zero on success and negative errrno on failure.
> > + */
> > +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> > + uint64_t link_status)
> > +{
> > + struct drm_device *dev = connector->dev;
> > +
> > + connector->link_status = link_status;
> > + return drm_object_property_set_value(&connector->base,
> > + dev->mode_config.link_status_property,
> > + link_status);
> > +}
> > +EXPORT_SYMBOL(drm_mode_connector_set_link_status_property);
> > +
> > int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
> > struct drm_property *property,
> > uint64_t value)
> > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> > index ad5c8b0..ac76469 100644
> > --- a/include/drm/drm_connector.h
> > +++ b/include/drm/drm_connector.h
> > @@ -778,6 +778,8 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
> > int drm_mode_connector_set_tile_property(struct drm_connector *connector);
> > int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> > const struct edid *edid);
> > +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> > + uint64_t link_status);
> >
> > /**
> > * drm_for_each_connector - iterate over all connectors
> > --
> > 1.9.1
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [Intel-gfx] [PATCH 2/5] drm: Set DRM connector link status property
2016-11-16 1:13 ` Manasi Navare
@ 2016-11-16 7:29 ` Daniel Vetter
0 siblings, 0 replies; 31+ messages in thread
From: Daniel Vetter @ 2016-11-16 7:29 UTC (permalink / raw)
To: Manasi Navare; +Cc: Daniel Vetter, intel-gfx, dri-devel
On Tue, Nov 15, 2016 at 05:13:43PM -0800, Manasi Navare wrote:
> On Tue, Nov 15, 2016 at 08:53:27AM +0100, Daniel Vetter wrote:
> > On Mon, Nov 14, 2016 at 07:13:20PM -0800, Manasi Navare wrote:
> > > In the usual working scenarios, this property is "Good".
> > > If something fails during modeset, the DRM driver can
> > > set the link status to "Bad", prune the mode list based on the
> > > link rate/lane count fallback values and send hotplug uevent
> > > so that userspace that is aware of this property can take an
> > > appropriate action by reprobing connectors and re triggering
> > > a modeset to improve user experience and avoid black screens.
> > > In case of userspace that is not aware of this link status
> > > property, the user experience will be unchanged.
> > >
> > > The reason for adding the property is to handle link training failures,
> > > but it is not limited to DP or link training. For example, if we
> > > implement asynchronous setcrtc, we can use this to report any failures
> > > in that.
> > >
> > > 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>
> > > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> >
> > One more thing I've forgotten: Just adding the kernel-doc isn't enough
> > yet, we need to link this new property into the overall property
> > documentations.
> >
> > We already have a section "KMS Properties" in
> > Documentation/gpu/drm-kms.rst, I think adding a new sub-section called
> > "Standard Connector Properties" there with a definition list pointing to
> > this function here would be best.
> > -Daniel
> >
>
> What about other standard proprties like EDID etc? And could you give an
> example for writing out a definition list there pointing to this function?
> This .rst file currently consists of kernel::doc:: and paths for .h files
Yeah, none of the standard connector properties are currently documented.
I'll write a quick patch that you can then base yours on.
-Daniel
>
> Manasi
> > > ---
> > > drivers/gpu/drm/drm_connector.c | 38 ++++++++++++++++++++++++++++++++++++++
> > > include/drm/drm_connector.h | 2 ++
> > > 2 files changed, 40 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> > > index d4e852f..09f4093 100644
> > > --- a/drivers/gpu/drm/drm_connector.c
> > > +++ b/drivers/gpu/drm/drm_connector.c
> > > @@ -968,6 +968,44 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> > > }
> > > EXPORT_SYMBOL(drm_mode_connector_update_edid_property);
> > >
> > > +/**
> > > + * drm_mode_connector_set_link_status_property - Set the link status property of
> > > + * a connector to indicate status of link as a result of link training.
> > > + * @connector: drm connector
> > > + * @link_status: new value of link status property (0: Good, 1: Bad)
> > > + *
> > > + * In usual working scenario, this link status property will always be set to
> > > + * "GOOD".
> > > + * If something fails during or after a mode set, the kernel driver can set this
> > > + * link status to "BAD", prune the mode list based on new information and send a
> > > + * hotplug uevent for userspace to have it re-check the valid modes through
> > > + * Get_connector and try again.
> > > + *
> > > + * If userspace is not aware of this property, the user experience is the same
> > > + * as it currently is. If the userspace is aware of the property, it has a chance
> > > + * to improve user experience by handling link training failures, avoiding black
> > > + * screens. The DRM driver can chose to not modify property and keep link status
> > > + * as "GOOD" always to keep the user experience same as it currently is.
> > > + *
> > > + * The reason for adding this property is to handle link training failures, but
> > > + * it is not limited to DP or link training. For example, if we implement
> > > + * asynchronous setcrtc, this property can be used to reportany failures in that.
> > > + *
> > > + * This function must be called from asynchronous work item.
> > > + * Returns zero on success and negative errrno on failure.
> > > + */
> > > +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> > > + uint64_t link_status)
> > > +{
> > > + struct drm_device *dev = connector->dev;
> > > +
> > > + connector->link_status = link_status;
> > > + return drm_object_property_set_value(&connector->base,
> > > + dev->mode_config.link_status_property,
> > > + link_status);
> > > +}
> > > +EXPORT_SYMBOL(drm_mode_connector_set_link_status_property);
> > > +
> > > int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
> > > struct drm_property *property,
> > > uint64_t value)
> > > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> > > index ad5c8b0..ac76469 100644
> > > --- a/include/drm/drm_connector.h
> > > +++ b/include/drm/drm_connector.h
> > > @@ -778,6 +778,8 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
> > > int drm_mode_connector_set_tile_property(struct drm_connector *connector);
> > > int drm_mode_connector_update_edid_property(struct drm_connector *connector,
> > > const struct edid *edid);
> > > +int drm_mode_connector_set_link_status_property(struct drm_connector *connector,
> > > + uint64_t link_status);
> > >
> > > /**
> > > * drm_for_each_connector - iterate over all connectors
> > > --
> > > 1.9.1
> > >
> > > _______________________________________________
> > > Intel-gfx mailing list
> > > Intel-gfx@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> >
> > --
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > http://blog.ffwll.ch
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 2/5] drm: Set DRM connector link status property
2016-11-15 3:13 ` [PATCH 2/5] drm: Set DRM connector link status property Manasi Navare
` (2 preceding siblings ...)
2016-11-15 7:53 ` Daniel Vetter
@ 2016-11-16 1:58 ` Manasi Navare
3 siblings, 0 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-16 1:58 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Manasi Navare, Daniel Vetter
In the usual working scenarios, this property is "Good".
If something fails during modeset, the DRM driver can
set the link status to "Bad", prune the mode list based on the
link rate/lane count fallback values and send hotplug uevent
so that userspace that is aware of this property can take an
appropriate action by reprobing connectors and re triggering
a modeset to improve user experience and avoid black screens.
In case of userspace that is not aware of this link status
property, the user experience will be unchanged.
The reason for adding the property is to handle link training failures,
but it is not limited to DP or link training. For example, if we
implement asynchronous setcrtc, we can use this to report any failures
in that.
v2:
* Update kernel doc, add lockdep_assert_held (Daniel Vetter)
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>
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
---
drivers/gpu/drm/drm_connector.c | 36 ++++++++++++++++++++++++++++++++++++
include/drm/drm_connector.h | 2 ++
2 files changed, 38 insertions(+)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index d4e852f..b942d67 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -968,6 +968,42 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
}
EXPORT_SYMBOL(drm_mode_connector_update_edid_property);
+/**
+ * drm_mode_connector_set_link_status_property - Set link status property of a connector
+ * @connector: drm connector
+ * @link_status: new value of link status property (0: Good, 1: Bad)
+ *
+ * In usual working scenario, this link status property will always be set to
+ * "GOOD". If something fails during or after a mode set, the kernel driver should
+ * prune the mode list based on new information, set this link status property to
+ * "BAD". The caller then needs to send a hotplug uevent for userspace to re-check
+ * the valid modes through GET_CONNECTOR_IOCTL and retry modeset.
+ *
+ * Note that a lot of existing userspace do not handle this property.
+ * If userspace is not aware of this property, the user experience is the same
+ * as it currently is. If the userspace is aware of the property, it has a chance
+ * to improve user experience by handling link training failures, avoiding black
+ * screens. The DRM driver can chose to not modify property and keep link status
+ * as "GOOD" always to keep the user experience same as it currently is.
+ *
+ * The reason for adding this property is to handle link training failures, but
+ * it is not limited to DP or link training. For example, if we implement
+ * asynchronous setcrtc, this property can be used to report any failures in that.
+ */
+void drm_mode_connector_set_link_status_property(struct drm_connector *connector,
+ uint64_t link_status)
+{
+ struct drm_device *dev = connector->dev;
+
+ /* Make sure the mutex is grabbed */
+ lockdep_assert_held(&dev->mode_config.mutex);
+ connector->link_status = link_status;
+ drm_object_property_set_value(&connector->base,
+ dev->mode_config.link_status_property,
+ link_status);
+}
+EXPORT_SYMBOL(drm_mode_connector_set_link_status_property);
+
int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
struct drm_property *property,
uint64_t value)
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index ad5c8b0..b7e2658 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -778,6 +778,8 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
int drm_mode_connector_set_tile_property(struct drm_connector *connector);
int drm_mode_connector_update_edid_property(struct drm_connector *connector,
const struct edid *edid);
+void drm_mode_connector_set_link_status_property(struct drm_connector *connector,
+ uint64_t link_status);
/**
* drm_for_each_connector - iterate over all connectors
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 3/5] drm/i915: Update CRTC state if connector link status property changed
2016-11-15 3:13 [PATCH 0/5] Handle link training failure during modeset Manasi Navare
2016-11-15 3:13 ` [PATCH 1/5] drm: Add a new connector property for link status Manasi Navare
2016-11-15 3:13 ` [PATCH 2/5] drm: Set DRM connector link status property Manasi Navare
@ 2016-11-15 3:13 ` Manasi Navare
2016-11-15 3:13 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
` (3 subsequent siblings)
6 siblings, 0 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-15 3:13 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Daniel Vetter
CRTC state connector_changed needs to be set to true
if connector link status property has changed. This will tell the
driver to do a complete modeset due to change in connector property.
Acked-by: Harry Wentland <harry.wentland@amd.com>
Acked-by: Tony Cheng <tony.cheng@amd.com>
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>
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
---
drivers/gpu/drm/drm_atomic_helper.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 5007796..aeecf2f 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -519,6 +519,13 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state,
connector_state);
if (ret)
return ret;
+
+ if (connector->state->crtc) {
+ crtc_state = drm_atomic_get_existing_crtc_state(state,
+ connector->state->crtc);
+ if (connector->link_status == DRM_MODE_LINK_STATUS_BAD)
+ crtc_state->connectors_changed = true;
+ }
}
/*
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 4/5] drm/i915: Find fallback link rate/lane count
2016-11-15 3:13 [PATCH 0/5] Handle link training failure during modeset Manasi Navare
` (2 preceding siblings ...)
2016-11-15 3:13 ` [PATCH 3/5] drm/i915: Update CRTC state if connector link status property changed Manasi Navare
@ 2016-11-15 3:13 ` Manasi Navare
2016-11-16 17:32 ` Manasi Navare
2016-11-17 12:58 ` Jani Nikula
2016-11-15 3:13 ` [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure Manasi Navare
` (2 subsequent siblings)
6 siblings, 2 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-15 3:13 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Daniel Vetter
If link training fails, then we need to fallback to lower
link rate first and if link training fails at RBR, then
fallback to lower lane count.
This function finds the next lower link rate/lane count
value after link training failure.
v2:
Squash the patch that returns the link rate index (Jani Nikula)
Acked-by: Tony Cheng <tony.cheng@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
---
drivers/gpu/drm/i915/intel_dp.c | 42 ++++++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/intel_drv.h | 6 ++++++
2 files changed, 48 insertions(+)
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index a1b0181..e87b451 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -288,6 +288,48 @@ static int intel_dp_common_rates(struct intel_dp *intel_dp,
common_rates);
}
+static int intel_dp_link_rate_index(struct intel_dp *intel_dp,
+ int *common_rates, int link_rate)
+{
+ int common_len;
+ int index;
+
+ common_len = intel_dp_common_rates(intel_dp, common_rates);
+ for (index = 0; index < common_len; index++) {
+ if (link_rate == common_rates[common_len - index - 1])
+ return common_len - index - 1;
+ }
+
+ return -1;
+}
+
+int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
+ int link_rate, uint8_t lane_count)
+{
+ int common_rates[DP_MAX_SUPPORTED_RATES] = {};
+ int common_len;
+ int link_rate_index = -1;
+
+ common_len = intel_dp_common_rates(intel_dp, common_rates);
+ link_rate_index = intel_dp_link_rate_index(intel_dp,
+ common_rates,
+ link_rate);
+ if (link_rate_index > 0) {
+ intel_dp->fallback_link_rate_index = link_rate_index - 1;
+ intel_dp->fallback_link_rate = common_rates[intel_dp->fallback_link_rate_index];
+ intel_dp->fallback_lane_count = intel_dp_max_lane_count(intel_dp);
+ } else if (lane_count > 1) {
+ intel_dp->fallback_link_rate_index = common_len - 1;
+ intel_dp->fallback_link_rate = common_rates[intel_dp->fallback_link_rate_index];
+ intel_dp->fallback_lane_count = lane_count >> 1;
+ } else {
+ DRM_ERROR("Link Training Unsuccessful\n");
+ return -1;
+ }
+
+ return 0;
+}
+
static enum drm_mode_status
intel_dp_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 75252ec..55ceb44 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -887,6 +887,10 @@ struct intel_dp {
uint32_t DP;
int link_rate;
uint8_t lane_count;
+ int fallback_link_rate;
+ uint8_t fallback_lane_count;
+ int fallback_link_rate_index;
+ bool link_train_failed;
uint8_t sink_count;
bool link_mst;
bool has_audio;
@@ -1383,6 +1387,8 @@ bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
void intel_dp_set_link_params(struct intel_dp *intel_dp,
int link_rate, uint8_t lane_count,
bool link_mst);
+int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
+ int link_rate, uint8_t lane_count);
void intel_dp_start_link_train(struct intel_dp *intel_dp);
void intel_dp_stop_link_train(struct intel_dp *intel_dp);
void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 4/5] drm/i915: Find fallback link rate/lane count
2016-11-15 3:13 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
@ 2016-11-16 17:32 ` Manasi Navare
2016-11-17 12:58 ` Jani Nikula
1 sibling, 0 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-16 17:32 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Daniel Vetter
Jani/Ville , could you please review this patch?
Jani, you had mentioned it looks good and we were only waiting for
ACKs from DRM, so now from the DRM point of view all these patches
are ACKed and it looks good.
But I need r-b for these two i915 specific patches to get them merged.
Regards
Manasi
On Mon, Nov 14, 2016 at 07:13:22PM -0800, Manasi Navare wrote:
> If link training fails, then we need to fallback to lower
> link rate first and if link training fails at RBR, then
> fallback to lower lane count.
> This function finds the next lower link rate/lane count
> value after link training failure.
>
> v2:
> Squash the patch that returns the link rate index (Jani Nikula)
>
> Acked-by: Tony Cheng <tony.cheng@amd.com>
> Acked-by: Harry Wentland <harry.wentland@amd.com>
> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> ---
> drivers/gpu/drm/i915/intel_dp.c | 42 ++++++++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/i915/intel_drv.h | 6 ++++++
> 2 files changed, 48 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index a1b0181..e87b451 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -288,6 +288,48 @@ static int intel_dp_common_rates(struct intel_dp *intel_dp,
> common_rates);
> }
>
> +static int intel_dp_link_rate_index(struct intel_dp *intel_dp,
> + int *common_rates, int link_rate)
> +{
> + int common_len;
> + int index;
> +
> + common_len = intel_dp_common_rates(intel_dp, common_rates);
> + for (index = 0; index < common_len; index++) {
> + if (link_rate == common_rates[common_len - index - 1])
> + return common_len - index - 1;
> + }
> +
> + return -1;
> +}
> +
> +int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> + int link_rate, uint8_t lane_count)
> +{
> + int common_rates[DP_MAX_SUPPORTED_RATES] = {};
> + int common_len;
> + int link_rate_index = -1;
> +
> + common_len = intel_dp_common_rates(intel_dp, common_rates);
> + link_rate_index = intel_dp_link_rate_index(intel_dp,
> + common_rates,
> + link_rate);
> + if (link_rate_index > 0) {
> + intel_dp->fallback_link_rate_index = link_rate_index - 1;
> + intel_dp->fallback_link_rate = common_rates[intel_dp->fallback_link_rate_index];
> + intel_dp->fallback_lane_count = intel_dp_max_lane_count(intel_dp);
> + } else if (lane_count > 1) {
> + intel_dp->fallback_link_rate_index = common_len - 1;
> + intel_dp->fallback_link_rate = common_rates[intel_dp->fallback_link_rate_index];
> + intel_dp->fallback_lane_count = lane_count >> 1;
> + } else {
> + DRM_ERROR("Link Training Unsuccessful\n");
> + return -1;
> + }
> +
> + return 0;
> +}
> +
> static enum drm_mode_status
> intel_dp_mode_valid(struct drm_connector *connector,
> struct drm_display_mode *mode)
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 75252ec..55ceb44 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -887,6 +887,10 @@ struct intel_dp {
> uint32_t DP;
> int link_rate;
> uint8_t lane_count;
> + int fallback_link_rate;
> + uint8_t fallback_lane_count;
> + int fallback_link_rate_index;
> + bool link_train_failed;
> uint8_t sink_count;
> bool link_mst;
> bool has_audio;
> @@ -1383,6 +1387,8 @@ bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> void intel_dp_set_link_params(struct intel_dp *intel_dp,
> int link_rate, uint8_t lane_count,
> bool link_mst);
> +int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> + int link_rate, uint8_t lane_count);
> void intel_dp_start_link_train(struct intel_dp *intel_dp);
> void intel_dp_stop_link_train(struct intel_dp *intel_dp);
> void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
> --
> 1.9.1
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 4/5] drm/i915: Find fallback link rate/lane count
2016-11-15 3:13 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
2016-11-16 17:32 ` Manasi Navare
@ 2016-11-17 12:58 ` Jani Nikula
2016-11-17 19:44 ` Manasi Navare
1 sibling, 1 reply; 31+ messages in thread
From: Jani Nikula @ 2016-11-17 12:58 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Manasi Navare, Daniel Vetter
On Tue, 15 Nov 2016, Manasi Navare <manasi.d.navare@intel.com> wrote:
> If link training fails, then we need to fallback to lower
> link rate first and if link training fails at RBR, then
> fallback to lower lane count.
> This function finds the next lower link rate/lane count
> value after link training failure.
>
> v2:
> Squash the patch that returns the link rate index (Jani Nikula)
>
> Acked-by: Tony Cheng <tony.cheng@amd.com>
> Acked-by: Harry Wentland <harry.wentland@amd.com>
> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> ---
> drivers/gpu/drm/i915/intel_dp.c | 42 ++++++++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/i915/intel_drv.h | 6 ++++++
> 2 files changed, 48 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index a1b0181..e87b451 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -288,6 +288,48 @@ static int intel_dp_common_rates(struct intel_dp *intel_dp,
> common_rates);
> }
>
> +static int intel_dp_link_rate_index(struct intel_dp *intel_dp,
> + int *common_rates, int link_rate)
> +{
> + int common_len;
> + int index;
> +
> + common_len = intel_dp_common_rates(intel_dp, common_rates);
> + for (index = 0; index < common_len; index++) {
> + if (link_rate == common_rates[common_len - index - 1])
> + return common_len - index - 1;
> + }
> +
> + return -1;
> +}
> +
> +int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> + int link_rate, uint8_t lane_count)
> +{
> + int common_rates[DP_MAX_SUPPORTED_RATES] = {};
> + int common_len;
> + int link_rate_index = -1;
> +
> + common_len = intel_dp_common_rates(intel_dp, common_rates);
> + link_rate_index = intel_dp_link_rate_index(intel_dp,
> + common_rates,
> + link_rate);
> + if (link_rate_index > 0) {
> + intel_dp->fallback_link_rate_index = link_rate_index - 1;
> + intel_dp->fallback_link_rate = common_rates[intel_dp->fallback_link_rate_index];
fallback_link_rate_index and fallback_link_rate are two ways to express
the same thing, and you can derive one from the other. When you have
two, you run the risk of having them out of sync. I thought I'd
mentioned this in earlier review.
Please do not store fallback_link_rate_index in intel_dp. Only store
fallback_link_rate. You can use your intel_dp_link_rate_index() function
when you need to convert rate to index.
Moreover, resetting the state becomes more clear when all can be set to
0.
BR,
Jani.
> + intel_dp->fallback_lane_count = intel_dp_max_lane_count(intel_dp);
> + } else if (lane_count > 1) {
> + intel_dp->fallback_link_rate_index = common_len - 1;
> + intel_dp->fallback_link_rate = common_rates[intel_dp->fallback_link_rate_index];
> + intel_dp->fallback_lane_count = lane_count >> 1;
> + } else {
> + DRM_ERROR("Link Training Unsuccessful\n");
> + return -1;
> + }
> +
> + return 0;
> +}
> +
> static enum drm_mode_status
> intel_dp_mode_valid(struct drm_connector *connector,
> struct drm_display_mode *mode)
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 75252ec..55ceb44 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -887,6 +887,10 @@ struct intel_dp {
> uint32_t DP;
> int link_rate;
> uint8_t lane_count;
> + int fallback_link_rate;
> + uint8_t fallback_lane_count;
> + int fallback_link_rate_index;
> + bool link_train_failed;
> uint8_t sink_count;
> bool link_mst;
> bool has_audio;
> @@ -1383,6 +1387,8 @@ bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> void intel_dp_set_link_params(struct intel_dp *intel_dp,
> int link_rate, uint8_t lane_count,
> bool link_mst);
> +int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> + int link_rate, uint8_t lane_count);
> void intel_dp_start_link_train(struct intel_dp *intel_dp);
> void intel_dp_stop_link_train(struct intel_dp *intel_dp);
> void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 4/5] drm/i915: Find fallback link rate/lane count
2016-11-17 12:58 ` Jani Nikula
@ 2016-11-17 19:44 ` Manasi Navare
0 siblings, 0 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-17 19:44 UTC (permalink / raw)
To: Jani Nikula; +Cc: Daniel Vetter, intel-gfx, dri-devel
On Thu, Nov 17, 2016 at 02:58:46PM +0200, Jani Nikula wrote:
> On Tue, 15 Nov 2016, Manasi Navare <manasi.d.navare@intel.com> wrote:
> > If link training fails, then we need to fallback to lower
> > link rate first and if link training fails at RBR, then
> > fallback to lower lane count.
> > This function finds the next lower link rate/lane count
> > value after link training failure.
> >
> > v2:
> > Squash the patch that returns the link rate index (Jani Nikula)
> >
> > Acked-by: Tony Cheng <tony.cheng@amd.com>
> > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Cc: Daniel Vetter <daniel.vetter@intel.com>
> > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > ---
> > drivers/gpu/drm/i915/intel_dp.c | 42 ++++++++++++++++++++++++++++++++++++++++
> > drivers/gpu/drm/i915/intel_drv.h | 6 ++++++
> > 2 files changed, 48 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> > index a1b0181..e87b451 100644
> > --- a/drivers/gpu/drm/i915/intel_dp.c
> > +++ b/drivers/gpu/drm/i915/intel_dp.c
> > @@ -288,6 +288,48 @@ static int intel_dp_common_rates(struct intel_dp *intel_dp,
> > common_rates);
> > }
> >
> > +static int intel_dp_link_rate_index(struct intel_dp *intel_dp,
> > + int *common_rates, int link_rate)
> > +{
> > + int common_len;
> > + int index;
> > +
> > + common_len = intel_dp_common_rates(intel_dp, common_rates);
> > + for (index = 0; index < common_len; index++) {
> > + if (link_rate == common_rates[common_len - index - 1])
> > + return common_len - index - 1;
> > + }
> > +
> > + return -1;
> > +}
> > +
> > +int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> > + int link_rate, uint8_t lane_count)
> > +{
> > + int common_rates[DP_MAX_SUPPORTED_RATES] = {};
> > + int common_len;
> > + int link_rate_index = -1;
> > +
> > + common_len = intel_dp_common_rates(intel_dp, common_rates);
> > + link_rate_index = intel_dp_link_rate_index(intel_dp,
> > + common_rates,
> > + link_rate);
> > + if (link_rate_index > 0) {
> > + intel_dp->fallback_link_rate_index = link_rate_index - 1;
> > + intel_dp->fallback_link_rate = common_rates[intel_dp->fallback_link_rate_index];
>
> fallback_link_rate_index and fallback_link_rate are two ways to express
> the same thing, and you can derive one from the other. When you have
> two, you run the risk of having them out of sync. I thought I'd
> mentioned this in earlier review.
>
> Please do not store fallback_link_rate_index in intel_dp. Only store
> fallback_link_rate. You can use your intel_dp_link_rate_index() function
> when you need to convert rate to index.
>
> Moreover, resetting the state becomes more clear when all can be set to
> 0.
>
> BR,
> Jani.
>
Thanks Jani.
From the previous feedback, I removed the redundant link_train_failed variable
stored in intel_dp, but retained the link_rate_index. I will look at this and see
if this can be optimized.
Manasi
> > + intel_dp->fallback_lane_count = intel_dp_max_lane_count(intel_dp);
> > + } else if (lane_count > 1) {
> > + intel_dp->fallback_link_rate_index = common_len - 1;
> > + intel_dp->fallback_link_rate = common_rates[intel_dp->fallback_link_rate_index];
> > + intel_dp->fallback_lane_count = lane_count >> 1;
> > + } else {
> > + DRM_ERROR("Link Training Unsuccessful\n");
> > + return -1;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > static enum drm_mode_status
> > intel_dp_mode_valid(struct drm_connector *connector,
> > struct drm_display_mode *mode)
> > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > index 75252ec..55ceb44 100644
> > --- a/drivers/gpu/drm/i915/intel_drv.h
> > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > @@ -887,6 +887,10 @@ struct intel_dp {
> > uint32_t DP;
> > int link_rate;
> > uint8_t lane_count;
> > + int fallback_link_rate;
> > + uint8_t fallback_lane_count;
> > + int fallback_link_rate_index;
> > + bool link_train_failed;
> > uint8_t sink_count;
> > bool link_mst;
> > bool has_audio;
> > @@ -1383,6 +1387,8 @@ bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> > void intel_dp_set_link_params(struct intel_dp *intel_dp,
> > int link_rate, uint8_t lane_count,
> > bool link_mst);
> > +int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> > + int link_rate, uint8_t lane_count);
> > void intel_dp_start_link_train(struct intel_dp *intel_dp);
> > void intel_dp_stop_link_train(struct intel_dp *intel_dp);
> > void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
>
> --
> Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure
2016-11-15 3:13 [PATCH 0/5] Handle link training failure during modeset Manasi Navare
` (3 preceding siblings ...)
2016-11-15 3:13 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
@ 2016-11-15 3:13 ` Manasi Navare
2016-11-16 17:34 ` Manasi Navare
2016-11-17 12:49 ` Jani Nikula
2016-11-15 4:24 ` ✓ Fi.CI.BAT: success for Handle Link Training Failure during modeset (rev2) Patchwork
2016-11-17 12:29 ` [PATCH 0/5] Handle link training failure during modeset Jani Nikula
6 siblings, 2 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-15 3:13 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Manasi Navare, Daniel Vetter
If link training at a link rate optimal for a particular
mode fails during modeset's atomic commit phase, then we
let the modeset complete and then retry. We save the link rate
value at which link training failed, update the link status property
to "BAD" and use a lower link rate to prune the modes. It will redo
the modeset on the current mode at lower link rate or if the current
mode gets pruned due to lower link constraints then, it will send a
hotplug uevent for userspace to handle it.
This is also required to pass DP CTS tests 4.3.1.3, 4.3.1.4,
4.3.1.6.
v5:
* Move set link status to drm core (Daniel Vetter, Jani Nikula)
v4:
* Add fallback support for non DDI platforms too
* Set connector->link status inside set_link_status function
(Jani Nikula)
v3:
* Set link status property to BAd unconditionally (Jani Nikula)
* Dont use two separate variables link_train_failed and link_status
to indicate same thing (Jani Nikula)
v2:
* Squashed a few patches (Jani Nikula)
Acked-by: Tony Cheng <tony.cheng@amd.com>
Acked-by: Harry Wentland <Harry.wentland@amd.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
---
drivers/gpu/drm/i915/intel_ddi.c | 21 +++++-
drivers/gpu/drm/i915/intel_dp.c | 102 +++++++++++++++++++++++++-
drivers/gpu/drm/i915/intel_dp_link_training.c | 12 ++-
drivers/gpu/drm/i915/intel_drv.h | 6 +-
4 files changed, 131 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 0ad4e16..57b7ee9 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1684,6 +1684,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
enum port port = intel_ddi_get_encoder_port(encoder);
+ struct intel_connector *intel_connector = intel_dp->attached_connector;
+ struct drm_connector *connector = &intel_connector->base;
intel_dp_set_link_params(intel_dp, link_rate, lane_count,
link_mst);
@@ -1694,7 +1696,24 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
intel_prepare_dp_ddi_buffers(encoder);
intel_ddi_init_dp_buf_reg(encoder);
intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
- intel_dp_start_link_train(intel_dp);
+ if (!intel_dp_start_link_train(intel_dp)) {
+ DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane count = %d",
+ link_rate, lane_count);
+ if (!intel_dp_get_link_train_fallback_values(intel_dp,
+ link_rate,
+ lane_count))
+ /* Schedule a Hotplug Uevent to userspace to start modeset */
+ schedule_work(&intel_connector->modeset_retry_work);
+ } else {
+ DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane count = %d",
+ link_rate, lane_count);
+ intel_dp->fallback_link_rate_index = -1;
+ intel_dp->fallback_link_rate = 0;
+ intel_dp->fallback_lane_count = 0;
+ drm_mode_connector_set_link_status_property(connector,
+ DRM_MODE_LINK_STATUS_GOOD);
+ }
+
if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
intel_dp_stop_link_train(intel_dp);
}
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index e87b451..af2f8b2 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -353,8 +353,14 @@ int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
target_clock = fixed_mode->clock;
}
- max_link_clock = intel_dp_max_link_rate(intel_dp);
- max_lanes = intel_dp_max_lane_count(intel_dp);
+ /* Prune the modes using the fallback link rate/lane count */
+ if (connector->link_status == DRM_MODE_LINK_STATUS_BAD) {
+ max_link_clock = intel_dp->fallback_link_rate;
+ max_lanes = intel_dp->fallback_lane_count;
+ } else {
+ max_link_clock = intel_dp_max_link_rate(intel_dp);
+ max_lanes = intel_dp_max_lane_count(intel_dp);
+ }
max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes);
mode_rate = intel_dp_link_required(target_clock, 18);
@@ -1591,6 +1597,7 @@ static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
enum port port = dp_to_dig_port(intel_dp)->port;
struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->base.crtc);
struct intel_connector *intel_connector = intel_dp->attached_connector;
+ struct drm_connector *connector = &intel_connector->base;
int lane_count, clock;
int min_lane_count = 1;
int max_lane_count = intel_dp_max_lane_count(intel_dp);
@@ -1638,6 +1645,12 @@ static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK)
return false;
+ /* Fall back to lower link rate in case of failure in previous modeset */
+ if (connector->link_status == DRM_MODE_LINK_STATUS_BAD) {
+ min_lane_count = max_lane_count = intel_dp->fallback_lane_count;
+ min_clock = max_clock = intel_dp->fallback_link_rate_index;
+ }
+
DRM_DEBUG_KMS("DP link computation with max lane count %i "
"max bw %d pixel clock %iKHz\n",
max_lane_count, common_rates[max_clock],
@@ -2781,6 +2794,8 @@ static void intel_enable_dp(struct intel_encoder *encoder,
struct drm_device *dev = encoder->base.dev;
struct drm_i915_private *dev_priv = to_i915(dev);
struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
+ struct intel_connector *intel_connector = intel_dp->attached_connector;
+ struct drm_connector *connector = &intel_connector->base;
uint32_t dp_reg = I915_READ(intel_dp->output_reg);
enum pipe pipe = crtc->pipe;
@@ -2811,7 +2826,23 @@ static void intel_enable_dp(struct intel_encoder *encoder,
}
intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
- intel_dp_start_link_train(intel_dp);
+ if (!intel_dp_start_link_train(intel_dp)) {
+ DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane count = %d",
+ intel_dp->link_rate, intel_dp->lane_count);
+ if (!intel_dp_get_link_train_fallback_values(intel_dp,
+ intel_dp->link_rate,
+ intel_dp->lane_count))
+ /* Schedule a Hotplug Uevent to userspace to start modeset */
+ schedule_work(&intel_connector->modeset_retry_work);
+ } else {
+ DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane count = %d",
+ intel_dp->link_rate, intel_dp->lane_count);
+ intel_dp->fallback_link_rate_index = -1;
+ intel_dp->fallback_link_rate = 0;
+ intel_dp->fallback_lane_count = 0;
+ drm_mode_connector_set_link_status_property(connector,
+ DRM_MODE_LINK_STATUS_GOOD);
+ }
intel_dp_stop_link_train(intel_dp);
if (pipe_config->has_audio) {
@@ -4018,6 +4049,8 @@ static void intel_dp_handle_test_request(struct intel_dp *intel_dp)
struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
+ struct intel_connector *intel_connector = intel_dp->attached_connector;
+ struct drm_connector *connector = &intel_connector->base;
/* Suppress underruns caused by re-training */
intel_set_cpu_fifo_underrun_reporting(dev_priv, crtc->pipe, false);
@@ -4025,7 +4058,23 @@ static void intel_dp_handle_test_request(struct intel_dp *intel_dp)
intel_set_pch_fifo_underrun_reporting(dev_priv,
intel_crtc_pch_transcoder(crtc), false);
- intel_dp_start_link_train(intel_dp);
+ if (!intel_dp_start_link_train(intel_dp)) {
+ DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane count = %d",
+ intel_dp->link_rate, intel_dp->lane_count);
+ if (!intel_dp_get_link_train_fallback_values(intel_dp,
+ intel_dp->link_rate,
+ intel_dp->lane_count))
+ /* Schedule a Hotplug Uevent to userspace to start modeset */
+ schedule_work(&intel_connector->modeset_retry_work);
+ } else {
+ DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane count = %d",
+ intel_dp->link_rate, intel_dp->lane_count);
+ intel_dp->fallback_link_rate_index = -1;
+ intel_dp->fallback_link_rate = 0;
+ intel_dp->fallback_lane_count = 0;
+ drm_mode_connector_set_link_status_property(connector,
+ DRM_MODE_LINK_STATUS_GOOD);
+ }
intel_dp_stop_link_train(intel_dp);
/* Keep underrun reporting disabled until things are stable */
@@ -4419,6 +4468,11 @@ static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
intel_dp->compliance_test_active = 0;
intel_dp->compliance_test_type = 0;
intel_dp->compliance_test_data = 0;
+ intel_dp->fallback_link_rate_index = -1;
+ intel_dp->fallback_link_rate = 0;
+ intel_dp->fallback_lane_count = 0;
+ drm_mode_connector_set_link_status_property(connector,
+ DRM_MODE_LINK_STATUS_GOOD);
if (intel_dp->is_mst) {
DRM_DEBUG_KMS("MST device may have disappeared %d vs %d\n",
@@ -4510,6 +4564,11 @@ static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
connector->base.id, connector->name);
+ /* If this is a retry due to link trianing failure */
+ if (status == connector_status_connected &&
+ connector->link_status == DRM_MODE_LINK_STATUS_BAD)
+ return status;
+
/* If full detect is not performed yet, do a full detect */
if (!intel_dp->detect_done)
status = intel_dp_long_pulse(intel_dp->attached_connector);
@@ -5677,6 +5736,37 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
return false;
}
+static void intel_dp_modeset_retry_work_fn(struct work_struct *work)
+{
+ struct intel_connector *intel_connector;
+ struct drm_connector *connector;
+ struct drm_display_mode *mode;
+ bool verbose_prune = true;
+
+ intel_connector = container_of(work, typeof(*intel_connector),
+ modeset_retry_work);
+ connector = &intel_connector->base;
+
+ /* Grab the locks before changing connector property*/
+ mutex_lock(&connector->dev->mode_config.mutex);
+ DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id,
+ connector->name);
+ list_for_each_entry(mode, &connector->modes, head) {
+ mode->status = intel_dp_mode_valid(connector,
+ mode);
+ }
+ drm_mode_prune_invalid(connector->dev, &connector->modes,
+ verbose_prune);
+ /* Set connector link status to BAD and send a Uevent to notify
+ * userspace to do a modeset.
+ */
+ drm_mode_connector_set_link_status_property(connector,
+ DRM_MODE_LINK_STATUS_BAD);
+ mutex_unlock(&connector->dev->mode_config.mutex);
+ /* Send Hotplug uevent so userspace can reprobe */
+ drm_kms_helper_hotplug_event(connector->dev);
+}
+
bool
intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
struct intel_connector *intel_connector)
@@ -5689,6 +5779,10 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
enum port port = intel_dig_port->port;
int type;
+ /* Initialize the work for modeset in case of link train failure */
+ INIT_WORK(&intel_connector->modeset_retry_work,
+ intel_dp_modeset_retry_work_fn);
+
if (WARN(intel_dig_port->max_lanes < 1,
"Not enough lanes (%d) for DP on port %c\n",
intel_dig_port->max_lanes, port_name(port)))
diff --git a/drivers/gpu/drm/i915/intel_dp_link_training.c b/drivers/gpu/drm/i915/intel_dp_link_training.c
index 0048b52..10f81ab 100644
--- a/drivers/gpu/drm/i915/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/intel_dp_link_training.c
@@ -310,9 +310,15 @@ void intel_dp_stop_link_train(struct intel_dp *intel_dp)
DP_TRAINING_PATTERN_DISABLE);
}
-void
+bool
intel_dp_start_link_train(struct intel_dp *intel_dp)
{
- intel_dp_link_training_clock_recovery(intel_dp);
- intel_dp_link_training_channel_equalization(intel_dp);
+ bool ret;
+
+ if (intel_dp_link_training_clock_recovery(intel_dp)) {
+ ret = intel_dp_link_training_channel_equalization(intel_dp);
+ if (ret)
+ return true;
+ }
+ return false;
}
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 55ceb44..88918f4 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -312,6 +312,9 @@ struct intel_connector {
void *port; /* store this opaque as its illegal to dereference it */
struct intel_dp *mst_port;
+
+ /* Work struct to schedule a uevent on link train failure */
+ struct work_struct modeset_retry_work;
};
struct dpll {
@@ -890,7 +893,6 @@ struct intel_dp {
int fallback_link_rate;
uint8_t fallback_lane_count;
int fallback_link_rate_index;
- bool link_train_failed;
uint8_t sink_count;
bool link_mst;
bool has_audio;
@@ -1389,7 +1391,7 @@ void intel_dp_set_link_params(struct intel_dp *intel_dp,
bool link_mst);
int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
int link_rate, uint8_t lane_count);
-void intel_dp_start_link_train(struct intel_dp *intel_dp);
+bool intel_dp_start_link_train(struct intel_dp *intel_dp);
void intel_dp_stop_link_train(struct intel_dp *intel_dp);
void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
void intel_dp_encoder_reset(struct drm_encoder *encoder);
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure
2016-11-15 3:13 ` [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure Manasi Navare
@ 2016-11-16 17:34 ` Manasi Navare
2016-11-17 12:49 ` Jani Nikula
1 sibling, 0 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-16 17:34 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Daniel Vetter
Jani/Ville could you please review this patch?
This has been ACKed by DRM and is good from DRM point fo view.
But I need r-b from either of you for this to get merged.
Regards
Manasi
On Mon, Nov 14, 2016 at 07:13:23PM -0800, Manasi Navare wrote:
> If link training at a link rate optimal for a particular
> mode fails during modeset's atomic commit phase, then we
> let the modeset complete and then retry. We save the link rate
> value at which link training failed, update the link status property
> to "BAD" and use a lower link rate to prune the modes. It will redo
> the modeset on the current mode at lower link rate or if the current
> mode gets pruned due to lower link constraints then, it will send a
> hotplug uevent for userspace to handle it.
>
> This is also required to pass DP CTS tests 4.3.1.3, 4.3.1.4,
> 4.3.1.6.
>
> v5:
> * Move set link status to drm core (Daniel Vetter, Jani Nikula)
> v4:
> * Add fallback support for non DDI platforms too
> * Set connector->link status inside set_link_status function
> (Jani Nikula)
> v3:
> * Set link status property to BAd unconditionally (Jani Nikula)
> * Dont use two separate variables link_train_failed and link_status
> to indicate same thing (Jani Nikula)
> v2:
> * Squashed a few patches (Jani Nikula)
>
> Acked-by: Tony Cheng <tony.cheng@amd.com>
> Acked-by: Harry Wentland <Harry.wentland@amd.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> ---
> drivers/gpu/drm/i915/intel_ddi.c | 21 +++++-
> drivers/gpu/drm/i915/intel_dp.c | 102 +++++++++++++++++++++++++-
> drivers/gpu/drm/i915/intel_dp_link_training.c | 12 ++-
> drivers/gpu/drm/i915/intel_drv.h | 6 +-
> 4 files changed, 131 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> index 0ad4e16..57b7ee9 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -1684,6 +1684,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
> struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
> struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> enum port port = intel_ddi_get_encoder_port(encoder);
> + struct intel_connector *intel_connector = intel_dp->attached_connector;
> + struct drm_connector *connector = &intel_connector->base;
>
> intel_dp_set_link_params(intel_dp, link_rate, lane_count,
> link_mst);
> @@ -1694,7 +1696,24 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
> intel_prepare_dp_ddi_buffers(encoder);
> intel_ddi_init_dp_buf_reg(encoder);
> intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> - intel_dp_start_link_train(intel_dp);
> + if (!intel_dp_start_link_train(intel_dp)) {
> + DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane count = %d",
> + link_rate, lane_count);
> + if (!intel_dp_get_link_train_fallback_values(intel_dp,
> + link_rate,
> + lane_count))
> + /* Schedule a Hotplug Uevent to userspace to start modeset */
> + schedule_work(&intel_connector->modeset_retry_work);
> + } else {
> + DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane count = %d",
> + link_rate, lane_count);
> + intel_dp->fallback_link_rate_index = -1;
> + intel_dp->fallback_link_rate = 0;
> + intel_dp->fallback_lane_count = 0;
> + drm_mode_connector_set_link_status_property(connector,
> + DRM_MODE_LINK_STATUS_GOOD);
> + }
> +
> if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
> intel_dp_stop_link_train(intel_dp);
> }
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index e87b451..af2f8b2 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -353,8 +353,14 @@ int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> target_clock = fixed_mode->clock;
> }
>
> - max_link_clock = intel_dp_max_link_rate(intel_dp);
> - max_lanes = intel_dp_max_lane_count(intel_dp);
> + /* Prune the modes using the fallback link rate/lane count */
> + if (connector->link_status == DRM_MODE_LINK_STATUS_BAD) {
> + max_link_clock = intel_dp->fallback_link_rate;
> + max_lanes = intel_dp->fallback_lane_count;
> + } else {
> + max_link_clock = intel_dp_max_link_rate(intel_dp);
> + max_lanes = intel_dp_max_lane_count(intel_dp);
> + }
>
> max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes);
> mode_rate = intel_dp_link_required(target_clock, 18);
> @@ -1591,6 +1597,7 @@ static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
> enum port port = dp_to_dig_port(intel_dp)->port;
> struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->base.crtc);
> struct intel_connector *intel_connector = intel_dp->attached_connector;
> + struct drm_connector *connector = &intel_connector->base;
> int lane_count, clock;
> int min_lane_count = 1;
> int max_lane_count = intel_dp_max_lane_count(intel_dp);
> @@ -1638,6 +1645,12 @@ static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
> if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK)
> return false;
>
> + /* Fall back to lower link rate in case of failure in previous modeset */
> + if (connector->link_status == DRM_MODE_LINK_STATUS_BAD) {
> + min_lane_count = max_lane_count = intel_dp->fallback_lane_count;
> + min_clock = max_clock = intel_dp->fallback_link_rate_index;
> + }
> +
> DRM_DEBUG_KMS("DP link computation with max lane count %i "
> "max bw %d pixel clock %iKHz\n",
> max_lane_count, common_rates[max_clock],
> @@ -2781,6 +2794,8 @@ static void intel_enable_dp(struct intel_encoder *encoder,
> struct drm_device *dev = encoder->base.dev;
> struct drm_i915_private *dev_priv = to_i915(dev);
> struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
> + struct intel_connector *intel_connector = intel_dp->attached_connector;
> + struct drm_connector *connector = &intel_connector->base;
> uint32_t dp_reg = I915_READ(intel_dp->output_reg);
> enum pipe pipe = crtc->pipe;
>
> @@ -2811,7 +2826,23 @@ static void intel_enable_dp(struct intel_encoder *encoder,
> }
>
> intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> - intel_dp_start_link_train(intel_dp);
> + if (!intel_dp_start_link_train(intel_dp)) {
> + DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane count = %d",
> + intel_dp->link_rate, intel_dp->lane_count);
> + if (!intel_dp_get_link_train_fallback_values(intel_dp,
> + intel_dp->link_rate,
> + intel_dp->lane_count))
> + /* Schedule a Hotplug Uevent to userspace to start modeset */
> + schedule_work(&intel_connector->modeset_retry_work);
> + } else {
> + DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane count = %d",
> + intel_dp->link_rate, intel_dp->lane_count);
> + intel_dp->fallback_link_rate_index = -1;
> + intel_dp->fallback_link_rate = 0;
> + intel_dp->fallback_lane_count = 0;
> + drm_mode_connector_set_link_status_property(connector,
> + DRM_MODE_LINK_STATUS_GOOD);
> + }
> intel_dp_stop_link_train(intel_dp);
>
> if (pipe_config->has_audio) {
> @@ -4018,6 +4049,8 @@ static void intel_dp_handle_test_request(struct intel_dp *intel_dp)
> struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
> struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
> + struct intel_connector *intel_connector = intel_dp->attached_connector;
> + struct drm_connector *connector = &intel_connector->base;
>
> /* Suppress underruns caused by re-training */
> intel_set_cpu_fifo_underrun_reporting(dev_priv, crtc->pipe, false);
> @@ -4025,7 +4058,23 @@ static void intel_dp_handle_test_request(struct intel_dp *intel_dp)
> intel_set_pch_fifo_underrun_reporting(dev_priv,
> intel_crtc_pch_transcoder(crtc), false);
>
> - intel_dp_start_link_train(intel_dp);
> + if (!intel_dp_start_link_train(intel_dp)) {
> + DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane count = %d",
> + intel_dp->link_rate, intel_dp->lane_count);
> + if (!intel_dp_get_link_train_fallback_values(intel_dp,
> + intel_dp->link_rate,
> + intel_dp->lane_count))
> + /* Schedule a Hotplug Uevent to userspace to start modeset */
> + schedule_work(&intel_connector->modeset_retry_work);
> + } else {
> + DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane count = %d",
> + intel_dp->link_rate, intel_dp->lane_count);
> + intel_dp->fallback_link_rate_index = -1;
> + intel_dp->fallback_link_rate = 0;
> + intel_dp->fallback_lane_count = 0;
> + drm_mode_connector_set_link_status_property(connector,
> + DRM_MODE_LINK_STATUS_GOOD);
> + }
> intel_dp_stop_link_train(intel_dp);
>
> /* Keep underrun reporting disabled until things are stable */
> @@ -4419,6 +4468,11 @@ static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> intel_dp->compliance_test_active = 0;
> intel_dp->compliance_test_type = 0;
> intel_dp->compliance_test_data = 0;
> + intel_dp->fallback_link_rate_index = -1;
> + intel_dp->fallback_link_rate = 0;
> + intel_dp->fallback_lane_count = 0;
> + drm_mode_connector_set_link_status_property(connector,
> + DRM_MODE_LINK_STATUS_GOOD);
>
> if (intel_dp->is_mst) {
> DRM_DEBUG_KMS("MST device may have disappeared %d vs %d\n",
> @@ -4510,6 +4564,11 @@ static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
> connector->base.id, connector->name);
>
> + /* If this is a retry due to link trianing failure */
> + if (status == connector_status_connected &&
> + connector->link_status == DRM_MODE_LINK_STATUS_BAD)
> + return status;
> +
> /* If full detect is not performed yet, do a full detect */
> if (!intel_dp->detect_done)
> status = intel_dp_long_pulse(intel_dp->attached_connector);
> @@ -5677,6 +5736,37 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
> return false;
> }
>
> +static void intel_dp_modeset_retry_work_fn(struct work_struct *work)
> +{
> + struct intel_connector *intel_connector;
> + struct drm_connector *connector;
> + struct drm_display_mode *mode;
> + bool verbose_prune = true;
> +
> + intel_connector = container_of(work, typeof(*intel_connector),
> + modeset_retry_work);
> + connector = &intel_connector->base;
> +
> + /* Grab the locks before changing connector property*/
> + mutex_lock(&connector->dev->mode_config.mutex);
> + DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id,
> + connector->name);
> + list_for_each_entry(mode, &connector->modes, head) {
> + mode->status = intel_dp_mode_valid(connector,
> + mode);
> + }
> + drm_mode_prune_invalid(connector->dev, &connector->modes,
> + verbose_prune);
> + /* Set connector link status to BAD and send a Uevent to notify
> + * userspace to do a modeset.
> + */
> + drm_mode_connector_set_link_status_property(connector,
> + DRM_MODE_LINK_STATUS_BAD);
> + mutex_unlock(&connector->dev->mode_config.mutex);
> + /* Send Hotplug uevent so userspace can reprobe */
> + drm_kms_helper_hotplug_event(connector->dev);
> +}
> +
> bool
> intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> struct intel_connector *intel_connector)
> @@ -5689,6 +5779,10 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
> enum port port = intel_dig_port->port;
> int type;
>
> + /* Initialize the work for modeset in case of link train failure */
> + INIT_WORK(&intel_connector->modeset_retry_work,
> + intel_dp_modeset_retry_work_fn);
> +
> if (WARN(intel_dig_port->max_lanes < 1,
> "Not enough lanes (%d) for DP on port %c\n",
> intel_dig_port->max_lanes, port_name(port)))
> diff --git a/drivers/gpu/drm/i915/intel_dp_link_training.c b/drivers/gpu/drm/i915/intel_dp_link_training.c
> index 0048b52..10f81ab 100644
> --- a/drivers/gpu/drm/i915/intel_dp_link_training.c
> +++ b/drivers/gpu/drm/i915/intel_dp_link_training.c
> @@ -310,9 +310,15 @@ void intel_dp_stop_link_train(struct intel_dp *intel_dp)
> DP_TRAINING_PATTERN_DISABLE);
> }
>
> -void
> +bool
> intel_dp_start_link_train(struct intel_dp *intel_dp)
> {
> - intel_dp_link_training_clock_recovery(intel_dp);
> - intel_dp_link_training_channel_equalization(intel_dp);
> + bool ret;
> +
> + if (intel_dp_link_training_clock_recovery(intel_dp)) {
> + ret = intel_dp_link_training_channel_equalization(intel_dp);
> + if (ret)
> + return true;
> + }
> + return false;
> }
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 55ceb44..88918f4 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -312,6 +312,9 @@ struct intel_connector {
> void *port; /* store this opaque as its illegal to dereference it */
>
> struct intel_dp *mst_port;
> +
> + /* Work struct to schedule a uevent on link train failure */
> + struct work_struct modeset_retry_work;
> };
>
> struct dpll {
> @@ -890,7 +893,6 @@ struct intel_dp {
> int fallback_link_rate;
> uint8_t fallback_lane_count;
> int fallback_link_rate_index;
> - bool link_train_failed;
> uint8_t sink_count;
> bool link_mst;
> bool has_audio;
> @@ -1389,7 +1391,7 @@ void intel_dp_set_link_params(struct intel_dp *intel_dp,
> bool link_mst);
> int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> int link_rate, uint8_t lane_count);
> -void intel_dp_start_link_train(struct intel_dp *intel_dp);
> +bool intel_dp_start_link_train(struct intel_dp *intel_dp);
> void intel_dp_stop_link_train(struct intel_dp *intel_dp);
> void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
> void intel_dp_encoder_reset(struct drm_encoder *encoder);
> --
> 1.9.1
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure
2016-11-15 3:13 ` [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure Manasi Navare
2016-11-16 17:34 ` Manasi Navare
@ 2016-11-17 12:49 ` Jani Nikula
2016-11-17 19:55 ` Manasi Navare
1 sibling, 1 reply; 31+ messages in thread
From: Jani Nikula @ 2016-11-17 12:49 UTC (permalink / raw)
To: Manasi Navare, intel-gfx, dri-devel; +Cc: Daniel Vetter
On Tue, 15 Nov 2016, Manasi Navare <manasi.d.navare@intel.com> wrote:
> If link training at a link rate optimal for a particular
> mode fails during modeset's atomic commit phase, then we
> let the modeset complete and then retry. We save the link rate
> value at which link training failed, update the link status property
> to "BAD" and use a lower link rate to prune the modes. It will redo
> the modeset on the current mode at lower link rate or if the current
> mode gets pruned due to lower link constraints then, it will send a
> hotplug uevent for userspace to handle it.
>
> This is also required to pass DP CTS tests 4.3.1.3, 4.3.1.4,
> 4.3.1.6.
>
> v5:
> * Move set link status to drm core (Daniel Vetter, Jani Nikula)
> v4:
> * Add fallback support for non DDI platforms too
> * Set connector->link status inside set_link_status function
> (Jani Nikula)
> v3:
> * Set link status property to BAd unconditionally (Jani Nikula)
> * Dont use two separate variables link_train_failed and link_status
> to indicate same thing (Jani Nikula)
> v2:
> * Squashed a few patches (Jani Nikula)
>
> Acked-by: Tony Cheng <tony.cheng@amd.com>
> Acked-by: Harry Wentland <Harry.wentland@amd.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> ---
> drivers/gpu/drm/i915/intel_ddi.c | 21 +++++-
> drivers/gpu/drm/i915/intel_dp.c | 102 +++++++++++++++++++++++++-
> drivers/gpu/drm/i915/intel_dp_link_training.c | 12 ++-
> drivers/gpu/drm/i915/intel_drv.h | 6 +-
> 4 files changed, 131 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> index 0ad4e16..57b7ee9 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -1684,6 +1684,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
> struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
> struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> enum port port = intel_ddi_get_encoder_port(encoder);
> + struct intel_connector *intel_connector = intel_dp->attached_connector;
> + struct drm_connector *connector = &intel_connector->base;
>
> intel_dp_set_link_params(intel_dp, link_rate, lane_count,
> link_mst);
> @@ -1694,7 +1696,24 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
> intel_prepare_dp_ddi_buffers(encoder);
> intel_ddi_init_dp_buf_reg(encoder);
> intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> - intel_dp_start_link_train(intel_dp);
> + if (!intel_dp_start_link_train(intel_dp)) {
> + DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane count = %d",
> + link_rate, lane_count);
> + if (!intel_dp_get_link_train_fallback_values(intel_dp,
> + link_rate,
> + lane_count))
> + /* Schedule a Hotplug Uevent to userspace to start modeset */
> + schedule_work(&intel_connector->modeset_retry_work);
> + } else {
> + DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane count = %d",
> + link_rate, lane_count);
> + intel_dp->fallback_link_rate_index = -1;
> + intel_dp->fallback_link_rate = 0;
> + intel_dp->fallback_lane_count = 0;
> + drm_mode_connector_set_link_status_property(connector,
> + DRM_MODE_LINK_STATUS_GOOD);
> + }
Code block with intel_dp_start_link_train() failure handling. Okay.
> +
> if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
> intel_dp_stop_link_train(intel_dp);
> }
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index e87b451..af2f8b2 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -353,8 +353,14 @@ int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> target_clock = fixed_mode->clock;
> }
>
> - max_link_clock = intel_dp_max_link_rate(intel_dp);
> - max_lanes = intel_dp_max_lane_count(intel_dp);
> + /* Prune the modes using the fallback link rate/lane count */
> + if (connector->link_status == DRM_MODE_LINK_STATUS_BAD) {
> + max_link_clock = intel_dp->fallback_link_rate;
> + max_lanes = intel_dp->fallback_lane_count;
> + } else {
> + max_link_clock = intel_dp_max_link_rate(intel_dp);
> + max_lanes = intel_dp_max_lane_count(intel_dp);
> + }
>
> max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes);
> mode_rate = intel_dp_link_required(target_clock, 18);
> @@ -1591,6 +1597,7 @@ static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
> enum port port = dp_to_dig_port(intel_dp)->port;
> struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->base.crtc);
> struct intel_connector *intel_connector = intel_dp->attached_connector;
> + struct drm_connector *connector = &intel_connector->base;
> int lane_count, clock;
> int min_lane_count = 1;
> int max_lane_count = intel_dp_max_lane_count(intel_dp);
> @@ -1638,6 +1645,12 @@ static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
> if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK)
> return false;
>
> + /* Fall back to lower link rate in case of failure in previous modeset */
> + if (connector->link_status == DRM_MODE_LINK_STATUS_BAD) {
> + min_lane_count = max_lane_count = intel_dp->fallback_lane_count;
> + min_clock = max_clock = intel_dp->fallback_link_rate_index;
> + }
> +
> DRM_DEBUG_KMS("DP link computation with max lane count %i "
> "max bw %d pixel clock %iKHz\n",
> max_lane_count, common_rates[max_clock],
> @@ -2781,6 +2794,8 @@ static void intel_enable_dp(struct intel_encoder *encoder,
> struct drm_device *dev = encoder->base.dev;
> struct drm_i915_private *dev_priv = to_i915(dev);
> struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
> + struct intel_connector *intel_connector = intel_dp->attached_connector;
> + struct drm_connector *connector = &intel_connector->base;
> uint32_t dp_reg = I915_READ(intel_dp->output_reg);
> enum pipe pipe = crtc->pipe;
>
> @@ -2811,7 +2826,23 @@ static void intel_enable_dp(struct intel_encoder *encoder,
> }
>
> intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> - intel_dp_start_link_train(intel_dp);
> + if (!intel_dp_start_link_train(intel_dp)) {
> + DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane count = %d",
> + intel_dp->link_rate, intel_dp->lane_count);
> + if (!intel_dp_get_link_train_fallback_values(intel_dp,
> + intel_dp->link_rate,
> + intel_dp->lane_count))
> + /* Schedule a Hotplug Uevent to userspace to start modeset */
> + schedule_work(&intel_connector->modeset_retry_work);
> + } else {
> + DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane count = %d",
> + intel_dp->link_rate, intel_dp->lane_count);
> + intel_dp->fallback_link_rate_index = -1;
> + intel_dp->fallback_link_rate = 0;
> + intel_dp->fallback_lane_count = 0;
> + drm_mode_connector_set_link_status_property(connector,
> + DRM_MODE_LINK_STATUS_GOOD);
> + }
Second identical copy of intel_dp_start_link_train() failure handling.
> intel_dp_stop_link_train(intel_dp);
>
> if (pipe_config->has_audio) {
> @@ -4018,6 +4049,8 @@ static void intel_dp_handle_test_request(struct intel_dp *intel_dp)
> struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
> struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
> + struct intel_connector *intel_connector = intel_dp->attached_connector;
> + struct drm_connector *connector = &intel_connector->base;
>
> /* Suppress underruns caused by re-training */
> intel_set_cpu_fifo_underrun_reporting(dev_priv, crtc->pipe, false);
> @@ -4025,7 +4058,23 @@ static void intel_dp_handle_test_request(struct intel_dp *intel_dp)
> intel_set_pch_fifo_underrun_reporting(dev_priv,
> intel_crtc_pch_transcoder(crtc), false);
>
> - intel_dp_start_link_train(intel_dp);
> + if (!intel_dp_start_link_train(intel_dp)) {
> + DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane count = %d",
> + intel_dp->link_rate, intel_dp->lane_count);
> + if (!intel_dp_get_link_train_fallback_values(intel_dp,
> + intel_dp->link_rate,
> + intel_dp->lane_count))
> + /* Schedule a Hotplug Uevent to userspace to start modeset */
> + schedule_work(&intel_connector->modeset_retry_work);
> + } else {
> + DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane count = %d",
> + intel_dp->link_rate, intel_dp->lane_count);
> + intel_dp->fallback_link_rate_index = -1;
> + intel_dp->fallback_link_rate = 0;
> + intel_dp->fallback_lane_count = 0;
> + drm_mode_connector_set_link_status_property(connector,
> + DRM_MODE_LINK_STATUS_GOOD);
> + }
Third identical copy of intel_dp_start_link_train() failure
handling. Please abstract.
Why don't all intel_dp_start_link_train() calls need this? Could the
above code be *within* intel_dp_start_link_train()?
> intel_dp_stop_link_train(intel_dp);
>
> /* Keep underrun reporting disabled until things are stable */
> @@ -4419,6 +4468,11 @@ static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> intel_dp->compliance_test_active = 0;
> intel_dp->compliance_test_type = 0;
> intel_dp->compliance_test_data = 0;
> + intel_dp->fallback_link_rate_index = -1;
> + intel_dp->fallback_link_rate = 0;
> + intel_dp->fallback_lane_count = 0;
> + drm_mode_connector_set_link_status_property(connector,
> + DRM_MODE_LINK_STATUS_GOOD);
>
> if (intel_dp->is_mst) {
> DRM_DEBUG_KMS("MST device may have disappeared %d vs %d\n",
> @@ -4510,6 +4564,11 @@ static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
> connector->base.id, connector->name);
>
> + /* If this is a retry due to link trianing failure */
> + if (status == connector_status_connected &&
> + connector->link_status == DRM_MODE_LINK_STATUS_BAD)
> + return status;
> +
> /* If full detect is not performed yet, do a full detect */
> if (!intel_dp->detect_done)
> status = intel_dp_long_pulse(intel_dp->attached_connector);
> @@ -5677,6 +5736,37 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
> return false;
> }
>
> +static void intel_dp_modeset_retry_work_fn(struct work_struct *work)
> +{
> + struct intel_connector *intel_connector;
> + struct drm_connector *connector;
> + struct drm_display_mode *mode;
> + bool verbose_prune = true;
> +
> + intel_connector = container_of(work, typeof(*intel_connector),
> + modeset_retry_work);
> + connector = &intel_connector->base;
> +
> + /* Grab the locks before changing connector property*/
> + mutex_lock(&connector->dev->mode_config.mutex);
> + DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id,
> + connector->name);
> + list_for_each_entry(mode, &connector->modes, head) {
> + mode->status = intel_dp_mode_valid(connector,
> + mode);
> + }
> + drm_mode_prune_invalid(connector->dev, &connector->modes,
> + verbose_prune);
> + /* Set connector link status to BAD and send a Uevent to notify
> + * userspace to do a modeset.
> + */
> + drm_mode_connector_set_link_status_property(connector,
> + DRM_MODE_LINK_STATUS_BAD);
> + mutex_unlock(&connector->dev->mode_config.mutex);
> + /* Send Hotplug uevent so userspace can reprobe */
> + drm_kms_helper_hotplug_event(connector->dev);
> +}
> +
> bool
> intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> struct intel_connector *intel_connector)
> @@ -5689,6 +5779,10 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
> enum port port = intel_dig_port->port;
> int type;
>
> + /* Initialize the work for modeset in case of link train failure */
> + INIT_WORK(&intel_connector->modeset_retry_work,
> + intel_dp_modeset_retry_work_fn);
> +
> if (WARN(intel_dig_port->max_lanes < 1,
> "Not enough lanes (%d) for DP on port %c\n",
> intel_dig_port->max_lanes, port_name(port)))
> diff --git a/drivers/gpu/drm/i915/intel_dp_link_training.c b/drivers/gpu/drm/i915/intel_dp_link_training.c
> index 0048b52..10f81ab 100644
> --- a/drivers/gpu/drm/i915/intel_dp_link_training.c
> +++ b/drivers/gpu/drm/i915/intel_dp_link_training.c
> @@ -310,9 +310,15 @@ void intel_dp_stop_link_train(struct intel_dp *intel_dp)
> DP_TRAINING_PATTERN_DISABLE);
> }
>
> -void
> +bool
> intel_dp_start_link_train(struct intel_dp *intel_dp)
> {
> - intel_dp_link_training_clock_recovery(intel_dp);
> - intel_dp_link_training_channel_equalization(intel_dp);
> + bool ret;
> +
> + if (intel_dp_link_training_clock_recovery(intel_dp)) {
> + ret = intel_dp_link_training_channel_equalization(intel_dp);
> + if (ret)
> + return true;
> + }
> + return false;
Usually happy day scenario goes at the top indentation level, and errors
are handled in the nested cases with early returns. Compare with:
intel_dp_start_link_train(struct intel_dp *intel_dp)
{
if (!intel_dp_link_training_clock_recovery(intel_dp))
return false;
if (!intel_dp_link_training_channel_equalization(intel_dp))
return false;
return true;
}
> }
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 55ceb44..88918f4 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -312,6 +312,9 @@ struct intel_connector {
> void *port; /* store this opaque as its illegal to dereference it */
>
> struct intel_dp *mst_port;
> +
> + /* Work struct to schedule a uevent on link train failure */
> + struct work_struct modeset_retry_work;
> };
>
> struct dpll {
> @@ -890,7 +893,6 @@ struct intel_dp {
> int fallback_link_rate;
> uint8_t fallback_lane_count;
> int fallback_link_rate_index;
> - bool link_train_failed;
> uint8_t sink_count;
> bool link_mst;
> bool has_audio;
> @@ -1389,7 +1391,7 @@ void intel_dp_set_link_params(struct intel_dp *intel_dp,
> bool link_mst);
> int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> int link_rate, uint8_t lane_count);
> -void intel_dp_start_link_train(struct intel_dp *intel_dp);
> +bool intel_dp_start_link_train(struct intel_dp *intel_dp);
> void intel_dp_stop_link_train(struct intel_dp *intel_dp);
> void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
> void intel_dp_encoder_reset(struct drm_encoder *encoder);
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure
2016-11-17 12:49 ` Jani Nikula
@ 2016-11-17 19:55 ` Manasi Navare
0 siblings, 0 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-17 19:55 UTC (permalink / raw)
To: Jani Nikula; +Cc: Daniel Vetter, intel-gfx, dri-devel
On Thu, Nov 17, 2016 at 02:49:02PM +0200, Jani Nikula wrote:
> On Tue, 15 Nov 2016, Manasi Navare <manasi.d.navare@intel.com> wrote:
> > If link training at a link rate optimal for a particular
> > mode fails during modeset's atomic commit phase, then we
> > let the modeset complete and then retry. We save the link rate
> > value at which link training failed, update the link status property
> > to "BAD" and use a lower link rate to prune the modes. It will redo
> > the modeset on the current mode at lower link rate or if the current
> > mode gets pruned due to lower link constraints then, it will send a
> > hotplug uevent for userspace to handle it.
> >
> > This is also required to pass DP CTS tests 4.3.1.3, 4.3.1.4,
> > 4.3.1.6.
> >
> > v5:
> > * Move set link status to drm core (Daniel Vetter, Jani Nikula)
> > v4:
> > * Add fallback support for non DDI platforms too
> > * Set connector->link status inside set_link_status function
> > (Jani Nikula)
> > v3:
> > * Set link status property to BAd unconditionally (Jani Nikula)
> > * Dont use two separate variables link_train_failed and link_status
> > to indicate same thing (Jani Nikula)
> > v2:
> > * Squashed a few patches (Jani Nikula)
> >
> > Acked-by: Tony Cheng <tony.cheng@amd.com>
> > Acked-by: Harry Wentland <Harry.wentland@amd.com>
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Cc: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > ---
> > drivers/gpu/drm/i915/intel_ddi.c | 21 +++++-
> > drivers/gpu/drm/i915/intel_dp.c | 102 +++++++++++++++++++++++++-
> > drivers/gpu/drm/i915/intel_dp_link_training.c | 12 ++-
> > drivers/gpu/drm/i915/intel_drv.h | 6 +-
> > 4 files changed, 131 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> > index 0ad4e16..57b7ee9 100644
> > --- a/drivers/gpu/drm/i915/intel_ddi.c
> > +++ b/drivers/gpu/drm/i915/intel_ddi.c
> > @@ -1684,6 +1684,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
> > struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
> > struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> > enum port port = intel_ddi_get_encoder_port(encoder);
> > + struct intel_connector *intel_connector = intel_dp->attached_connector;
> > + struct drm_connector *connector = &intel_connector->base;
> >
> > intel_dp_set_link_params(intel_dp, link_rate, lane_count,
> > link_mst);
> > @@ -1694,7 +1696,24 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
> > intel_prepare_dp_ddi_buffers(encoder);
> > intel_ddi_init_dp_buf_reg(encoder);
> > intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> > - intel_dp_start_link_train(intel_dp);
> > + if (!intel_dp_start_link_train(intel_dp)) {
> > + DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane count = %d",
> > + link_rate, lane_count);
> > + if (!intel_dp_get_link_train_fallback_values(intel_dp,
> > + link_rate,
> > + lane_count))
> > + /* Schedule a Hotplug Uevent to userspace to start modeset */
> > + schedule_work(&intel_connector->modeset_retry_work);
> > + } else {
> > + DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane count = %d",
> > + link_rate, lane_count);
> > + intel_dp->fallback_link_rate_index = -1;
> > + intel_dp->fallback_link_rate = 0;
> > + intel_dp->fallback_lane_count = 0;
> > + drm_mode_connector_set_link_status_property(connector,
> > + DRM_MODE_LINK_STATUS_GOOD);
> > + }
>
> Code block with intel_dp_start_link_train() failure handling. Okay.
>
> > +
> > if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
> > intel_dp_stop_link_train(intel_dp);
> > }
> > diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> > index e87b451..af2f8b2 100644
> > --- a/drivers/gpu/drm/i915/intel_dp.c
> > +++ b/drivers/gpu/drm/i915/intel_dp.c
> > @@ -353,8 +353,14 @@ int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> > target_clock = fixed_mode->clock;
> > }
> >
> > - max_link_clock = intel_dp_max_link_rate(intel_dp);
> > - max_lanes = intel_dp_max_lane_count(intel_dp);
> > + /* Prune the modes using the fallback link rate/lane count */
> > + if (connector->link_status == DRM_MODE_LINK_STATUS_BAD) {
> > + max_link_clock = intel_dp->fallback_link_rate;
> > + max_lanes = intel_dp->fallback_lane_count;
> > + } else {
> > + max_link_clock = intel_dp_max_link_rate(intel_dp);
> > + max_lanes = intel_dp_max_lane_count(intel_dp);
> > + }
> >
> > max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes);
> > mode_rate = intel_dp_link_required(target_clock, 18);
> > @@ -1591,6 +1597,7 @@ static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
> > enum port port = dp_to_dig_port(intel_dp)->port;
> > struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->base.crtc);
> > struct intel_connector *intel_connector = intel_dp->attached_connector;
> > + struct drm_connector *connector = &intel_connector->base;
> > int lane_count, clock;
> > int min_lane_count = 1;
> > int max_lane_count = intel_dp_max_lane_count(intel_dp);
> > @@ -1638,6 +1645,12 @@ static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
> > if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK)
> > return false;
> >
> > + /* Fall back to lower link rate in case of failure in previous modeset */
> > + if (connector->link_status == DRM_MODE_LINK_STATUS_BAD) {
> > + min_lane_count = max_lane_count = intel_dp->fallback_lane_count;
> > + min_clock = max_clock = intel_dp->fallback_link_rate_index;
> > + }
> > +
> > DRM_DEBUG_KMS("DP link computation with max lane count %i "
> > "max bw %d pixel clock %iKHz\n",
> > max_lane_count, common_rates[max_clock],
> > @@ -2781,6 +2794,8 @@ static void intel_enable_dp(struct intel_encoder *encoder,
> > struct drm_device *dev = encoder->base.dev;
> > struct drm_i915_private *dev_priv = to_i915(dev);
> > struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
> > + struct intel_connector *intel_connector = intel_dp->attached_connector;
> > + struct drm_connector *connector = &intel_connector->base;
> > uint32_t dp_reg = I915_READ(intel_dp->output_reg);
> > enum pipe pipe = crtc->pipe;
> >
> > @@ -2811,7 +2826,23 @@ static void intel_enable_dp(struct intel_encoder *encoder,
> > }
> >
> > intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> > - intel_dp_start_link_train(intel_dp);
> > + if (!intel_dp_start_link_train(intel_dp)) {
> > + DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane count = %d",
> > + intel_dp->link_rate, intel_dp->lane_count);
> > + if (!intel_dp_get_link_train_fallback_values(intel_dp,
> > + intel_dp->link_rate,
> > + intel_dp->lane_count))
> > + /* Schedule a Hotplug Uevent to userspace to start modeset */
> > + schedule_work(&intel_connector->modeset_retry_work);
> > + } else {
> > + DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane count = %d",
> > + intel_dp->link_rate, intel_dp->lane_count);
> > + intel_dp->fallback_link_rate_index = -1;
> > + intel_dp->fallback_link_rate = 0;
> > + intel_dp->fallback_lane_count = 0;
> > + drm_mode_connector_set_link_status_property(connector,
> > + DRM_MODE_LINK_STATUS_GOOD);
> > + }
>
> Second identical copy of intel_dp_start_link_train() failure handling.
>
> > intel_dp_stop_link_train(intel_dp);
> >
> > if (pipe_config->has_audio) {
> > @@ -4018,6 +4049,8 @@ static void intel_dp_handle_test_request(struct intel_dp *intel_dp)
> > struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
> > struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> > struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
> > + struct intel_connector *intel_connector = intel_dp->attached_connector;
> > + struct drm_connector *connector = &intel_connector->base;
> >
> > /* Suppress underruns caused by re-training */
> > intel_set_cpu_fifo_underrun_reporting(dev_priv, crtc->pipe, false);
> > @@ -4025,7 +4058,23 @@ static void intel_dp_handle_test_request(struct intel_dp *intel_dp)
> > intel_set_pch_fifo_underrun_reporting(dev_priv,
> > intel_crtc_pch_transcoder(crtc), false);
> >
> > - intel_dp_start_link_train(intel_dp);
> > + if (!intel_dp_start_link_train(intel_dp)) {
> > + DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane count = %d",
> > + intel_dp->link_rate, intel_dp->lane_count);
> > + if (!intel_dp_get_link_train_fallback_values(intel_dp,
> > + intel_dp->link_rate,
> > + intel_dp->lane_count))
> > + /* Schedule a Hotplug Uevent to userspace to start modeset */
> > + schedule_work(&intel_connector->modeset_retry_work);
> > + } else {
> > + DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane count = %d",
> > + intel_dp->link_rate, intel_dp->lane_count);
> > + intel_dp->fallback_link_rate_index = -1;
> > + intel_dp->fallback_link_rate = 0;
> > + intel_dp->fallback_lane_count = 0;
> > + drm_mode_connector_set_link_status_property(connector,
> > + DRM_MODE_LINK_STATUS_GOOD);
> > + }
>
> Third identical copy of intel_dp_start_link_train() failure
> handling. Please abstract.
>
> Why don't all intel_dp_start_link_train() calls need this? Could the
> above code be *within* intel_dp_start_link_train()?
>
Actually the same codeblock got repeated since I expanded this
failure handling to all DDI and non DDI platforms and to all cases
where link training happens.
I think instead of adding to intel_dp_start_link_train, I can create
another separate function for link_train_failure handling which can be
called at all these places. Having it in a separate function would
make it more intuitive that if start_linj_train failed then we are
calling this failure handling code block.
Let me know what you think.
Regards
Manasi
> > intel_dp_stop_link_train(intel_dp);
> >
> > /* Keep underrun reporting disabled until things are stable */
> > @@ -4419,6 +4468,11 @@ static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> > intel_dp->compliance_test_active = 0;
> > intel_dp->compliance_test_type = 0;
> > intel_dp->compliance_test_data = 0;
> > + intel_dp->fallback_link_rate_index = -1;
> > + intel_dp->fallback_link_rate = 0;
> > + intel_dp->fallback_lane_count = 0;
> > + drm_mode_connector_set_link_status_property(connector,
> > + DRM_MODE_LINK_STATUS_GOOD);
> >
> > if (intel_dp->is_mst) {
> > DRM_DEBUG_KMS("MST device may have disappeared %d vs %d\n",
> > @@ -4510,6 +4564,11 @@ static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> > DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
> > connector->base.id, connector->name);
> >
> > + /* If this is a retry due to link trianing failure */
> > + if (status == connector_status_connected &&
> > + connector->link_status == DRM_MODE_LINK_STATUS_BAD)
> > + return status;
> > +
> > /* If full detect is not performed yet, do a full detect */
> > if (!intel_dp->detect_done)
> > status = intel_dp_long_pulse(intel_dp->attached_connector);
> > @@ -5677,6 +5736,37 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
> > return false;
> > }
> >
> > +static void intel_dp_modeset_retry_work_fn(struct work_struct *work)
> > +{
> > + struct intel_connector *intel_connector;
> > + struct drm_connector *connector;
> > + struct drm_display_mode *mode;
> > + bool verbose_prune = true;
> > +
> > + intel_connector = container_of(work, typeof(*intel_connector),
> > + modeset_retry_work);
> > + connector = &intel_connector->base;
> > +
> > + /* Grab the locks before changing connector property*/
> > + mutex_lock(&connector->dev->mode_config.mutex);
> > + DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id,
> > + connector->name);
> > + list_for_each_entry(mode, &connector->modes, head) {
> > + mode->status = intel_dp_mode_valid(connector,
> > + mode);
> > + }
> > + drm_mode_prune_invalid(connector->dev, &connector->modes,
> > + verbose_prune);
> > + /* Set connector link status to BAD and send a Uevent to notify
> > + * userspace to do a modeset.
> > + */
> > + drm_mode_connector_set_link_status_property(connector,
> > + DRM_MODE_LINK_STATUS_BAD);
> > + mutex_unlock(&connector->dev->mode_config.mutex);
> > + /* Send Hotplug uevent so userspace can reprobe */
> > + drm_kms_helper_hotplug_event(connector->dev);
> > +}
> > +
> > bool
> > intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> > struct intel_connector *intel_connector)
> > @@ -5689,6 +5779,10 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
> > enum port port = intel_dig_port->port;
> > int type;
> >
> > + /* Initialize the work for modeset in case of link train failure */
> > + INIT_WORK(&intel_connector->modeset_retry_work,
> > + intel_dp_modeset_retry_work_fn);
> > +
> > if (WARN(intel_dig_port->max_lanes < 1,
> > "Not enough lanes (%d) for DP on port %c\n",
> > intel_dig_port->max_lanes, port_name(port)))
> > diff --git a/drivers/gpu/drm/i915/intel_dp_link_training.c b/drivers/gpu/drm/i915/intel_dp_link_training.c
> > index 0048b52..10f81ab 100644
> > --- a/drivers/gpu/drm/i915/intel_dp_link_training.c
> > +++ b/drivers/gpu/drm/i915/intel_dp_link_training.c
> > @@ -310,9 +310,15 @@ void intel_dp_stop_link_train(struct intel_dp *intel_dp)
> > DP_TRAINING_PATTERN_DISABLE);
> > }
> >
> > -void
> > +bool
> > intel_dp_start_link_train(struct intel_dp *intel_dp)
> > {
> > - intel_dp_link_training_clock_recovery(intel_dp);
> > - intel_dp_link_training_channel_equalization(intel_dp);
> > + bool ret;
> > +
> > + if (intel_dp_link_training_clock_recovery(intel_dp)) {
> > + ret = intel_dp_link_training_channel_equalization(intel_dp);
> > + if (ret)
> > + return true;
> > + }
> > + return false;
>
> Usually happy day scenario goes at the top indentation level, and errors
> are handled in the nested cases with early returns. Compare with:
>
> intel_dp_start_link_train(struct intel_dp *intel_dp)
> {
> if (!intel_dp_link_training_clock_recovery(intel_dp))
> return false;
>
> if (!intel_dp_link_training_channel_equalization(intel_dp))
> return false;
>
> return true;
> }
>
Agreed.
> > }
> > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > index 55ceb44..88918f4 100644
> > --- a/drivers/gpu/drm/i915/intel_drv.h
> > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > @@ -312,6 +312,9 @@ struct intel_connector {
> > void *port; /* store this opaque as its illegal to dereference it */
> >
> > struct intel_dp *mst_port;
> > +
> > + /* Work struct to schedule a uevent on link train failure */
> > + struct work_struct modeset_retry_work;
> > };
> >
> > struct dpll {
> > @@ -890,7 +893,6 @@ struct intel_dp {
> > int fallback_link_rate;
> > uint8_t fallback_lane_count;
> > int fallback_link_rate_index;
> > - bool link_train_failed;
> > uint8_t sink_count;
> > bool link_mst;
> > bool has_audio;
> > @@ -1389,7 +1391,7 @@ void intel_dp_set_link_params(struct intel_dp *intel_dp,
> > bool link_mst);
> > int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> > int link_rate, uint8_t lane_count);
> > -void intel_dp_start_link_train(struct intel_dp *intel_dp);
> > +bool intel_dp_start_link_train(struct intel_dp *intel_dp);
> > void intel_dp_stop_link_train(struct intel_dp *intel_dp);
> > void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
> > void intel_dp_encoder_reset(struct drm_encoder *encoder);
>
> --
> Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* ✓ Fi.CI.BAT: success for Handle Link Training Failure during modeset (rev2)
2016-11-15 3:13 [PATCH 0/5] Handle link training failure during modeset Manasi Navare
` (4 preceding siblings ...)
2016-11-15 3:13 ` [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure Manasi Navare
@ 2016-11-15 4:24 ` Patchwork
2016-11-17 12:29 ` [PATCH 0/5] Handle link training failure during modeset Jani Nikula
6 siblings, 0 replies; 31+ messages in thread
From: Patchwork @ 2016-11-15 4:24 UTC (permalink / raw)
To: Navare, Manasi D; +Cc: intel-gfx
== Series Details ==
Series: Handle Link Training Failure during modeset (rev2)
URL : https://patchwork.freedesktop.org/series/15080/
State : success
== Summary ==
Series 15080v2 Handle Link Training Failure during modeset
https://patchwork.freedesktop.org/api/1.0/series/15080/revisions/2/mbox/
fi-bdw-5557u total:244 pass:229 dwarn:0 dfail:0 fail:0 skip:15
fi-bsw-n3050 total:244 pass:204 dwarn:0 dfail:0 fail:0 skip:40
fi-bxt-t5700 total:244 pass:216 dwarn:0 dfail:0 fail:0 skip:28
fi-byt-j1900 total:244 pass:216 dwarn:0 dfail:0 fail:0 skip:28
fi-byt-n2820 total:244 pass:212 dwarn:0 dfail:0 fail:0 skip:32
fi-hsw-4770 total:244 pass:224 dwarn:0 dfail:0 fail:0 skip:20
fi-hsw-4770r total:244 pass:224 dwarn:0 dfail:0 fail:0 skip:20
fi-ilk-650 total:244 pass:191 dwarn:0 dfail:0 fail:0 skip:53
fi-ivb-3520m total:244 pass:222 dwarn:0 dfail:0 fail:0 skip:22
fi-ivb-3770 total:244 pass:222 dwarn:0 dfail:0 fail:0 skip:22
fi-kbl-7200u total:244 pass:222 dwarn:0 dfail:0 fail:0 skip:22
fi-skl-6260u total:244 pass:230 dwarn:0 dfail:0 fail:0 skip:14
fi-skl-6700hq total:244 pass:223 dwarn:0 dfail:0 fail:0 skip:21
fi-snb-2520m total:244 pass:212 dwarn:0 dfail:0 fail:0 skip:32
fi-snb-2600 total:244 pass:211 dwarn:0 dfail:0 fail:0 skip:33
2f21978cfd8984c79e4cbd77ce63d9f73fe226ef drm-intel-nightly: 2016y-11m-14d-21h-23m-10s UTC integration manifest
91a9d22 drm/i915: Implement Link Rate fallback on Link training failure
0b79f50 drm/i915: Find fallback link rate/lane count
f5c4dd7 drm/i915: Update CRTC state if connector link status property changed
79fe862 drm: Set DRM connector link status property
2f286cb drm: Add a new connector property for link status
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_2993/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] Handle link training failure during modeset
2016-11-15 3:13 [PATCH 0/5] Handle link training failure during modeset Manasi Navare
` (5 preceding siblings ...)
2016-11-15 4:24 ` ✓ Fi.CI.BAT: success for Handle Link Training Failure during modeset (rev2) Patchwork
@ 2016-11-17 12:29 ` Jani Nikula
2016-11-17 19:48 ` Manasi Navare
6 siblings, 1 reply; 31+ messages in thread
From: Jani Nikula @ 2016-11-17 12:29 UTC (permalink / raw)
To: Manasi Navare, intel-gfx, dri-devel
On Tue, 15 Nov 2016, Manasi Navare <manasi.d.navare@intel.com> wrote:
> Submitting new series that adds proper commit messages/cover letter
> and kernel documentation. It also moved the set_link_status function
> to drm core so other kernel drivers can make use of it.
>
> The idea presented in these patches is to address link training failure
> in a way that:
> a) changes the current happy day scenario as little as possible, to avoid
> regressions, b) can be implemented the same way by all drm drivers, c)
> is still opt-in for the drivers and userspace, and opting out doesn't
> regress the user experience, d) doesn't prevent drivers from
> implementing better or alternate approaches, possibly without userspace
> involvement. And, of course, handles all the issues presented.
>
> The solution is to add a "link status" connector property. In the usual
> happy day scenario, this is always "good". If something fails during or
> after a mode set, the kernel driver can set the link status to "bad",
> prune the mode list based on new information as necessary, and send a
> hotplug uevent for userspace to have it re-check the valid modes through
> getconnector, and try again. If the theoretical capabilities of the link
> can't be reached, the mode list is trimmed based on that.
>
> If the userspace is not aware of the property, the user experience is
> the same as it currently is. If the userspace is aware of the property,
> it has a chance to improve user experience. If a drm driver does not
> modify the property (it stays "good"), the user experience is the same
> as it currently is. A drm driver can also choose to try to handle more
> of the failures in kernel, hardware not limiting, or it can choose to
> involve userspace more. Up to the drivers.
>
> The reason for adding the property is to handle link training failures,
> but it is not limited to DP or link training. For example, if we
> implement asynchronous setcrtc, we can use this to report any failures
> in that.
>
> Finally, while DP CTS compliance is advertized (which is great, and
> could be made to work similarly for all drm drivers), this can be used
> for the more important goal of improving user experience on link
> training failures, by avoiding black screens.
Since I went through the trouble of writing this, you might as well add
it to patch 1/5 commit message so it benefits the posterity.
> Acked-by: Tony Cheng <tony.cheng@amd.com>
> Acked-by: Harry Wentland <Harry.wentland@amd.com>
These must go to patch 1/5 commit message.
BR,
Jani.
>
> Manasi Navare (5):
> drm: Add a new connector property for link status
> drm: Set DRM connector link status property
> drm/i915: Update CRTC state if connector link status property changed
> drm/i915: Find fallback link rate/lane count
> drm/i915: Implement Link Rate fallback on Link training failure
>
> drivers/gpu/drm/drm_atomic_helper.c | 7 ++
> drivers/gpu/drm/drm_connector.c | 55 ++++++++++
> drivers/gpu/drm/i915/intel_ddi.c | 21 +++-
> drivers/gpu/drm/i915/intel_dp.c | 144 +++++++++++++++++++++++++-
> drivers/gpu/drm/i915/intel_dp_link_training.c | 12 ++-
> drivers/gpu/drm/i915/intel_drv.h | 10 +-
> include/drm/drm_connector.h | 9 +-
> include/drm/drm_crtc.h | 5 +
> include/uapi/drm/drm_mode.h | 4 +
> 9 files changed, 257 insertions(+), 10 deletions(-)
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] Handle link training failure during modeset
2016-11-17 12:29 ` [PATCH 0/5] Handle link training failure during modeset Jani Nikula
@ 2016-11-17 19:48 ` Manasi Navare
0 siblings, 0 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-17 19:48 UTC (permalink / raw)
To: Jani Nikula; +Cc: intel-gfx, dri-devel
On Thu, Nov 17, 2016 at 02:29:30PM +0200, Jani Nikula wrote:
> On Tue, 15 Nov 2016, Manasi Navare <manasi.d.navare@intel.com> wrote:
> > Submitting new series that adds proper commit messages/cover letter
> > and kernel documentation. It also moved the set_link_status function
> > to drm core so other kernel drivers can make use of it.
> >
> > The idea presented in these patches is to address link training failure
> > in a way that:
> > a) changes the current happy day scenario as little as possible, to avoid
> > regressions, b) can be implemented the same way by all drm drivers, c)
> > is still opt-in for the drivers and userspace, and opting out doesn't
> > regress the user experience, d) doesn't prevent drivers from
> > implementing better or alternate approaches, possibly without userspace
> > involvement. And, of course, handles all the issues presented.
> >
> > The solution is to add a "link status" connector property. In the usual
> > happy day scenario, this is always "good". If something fails during or
> > after a mode set, the kernel driver can set the link status to "bad",
> > prune the mode list based on new information as necessary, and send a
> > hotplug uevent for userspace to have it re-check the valid modes through
> > getconnector, and try again. If the theoretical capabilities of the link
> > can't be reached, the mode list is trimmed based on that.
> >
> > If the userspace is not aware of the property, the user experience is
> > the same as it currently is. If the userspace is aware of the property,
> > it has a chance to improve user experience. If a drm driver does not
> > modify the property (it stays "good"), the user experience is the same
> > as it currently is. A drm driver can also choose to try to handle more
> > of the failures in kernel, hardware not limiting, or it can choose to
> > involve userspace more. Up to the drivers.
> >
> > The reason for adding the property is to handle link training failures,
> > but it is not limited to DP or link training. For example, if we
> > implement asynchronous setcrtc, we can use this to report any failures
> > in that.
> >
> > Finally, while DP CTS compliance is advertized (which is great, and
> > could be made to work similarly for all drm drivers), this can be used
> > for the more important goal of improving user experience on link
> > training failures, by avoiding black screens.
>
> Since I went through the trouble of writing this, you might as well add
> it to patch 1/5 commit message so it benefits the posterity.
>
Yes, I have also added most of this to the kernel documentation
for the link status property. But I will also add this to Patch 1/5 commit message.
Should we explain the alternative approaches as well over there?
Manasi
> > Acked-by: Tony Cheng <tony.cheng@amd.com>
> > Acked-by: Harry Wentland <Harry.wentland@amd.com>
>
> These must go to patch 1/5 commit message.
>
> BR,
> Jani.
>
>
>
> >
> > Manasi Navare (5):
> > drm: Add a new connector property for link status
> > drm: Set DRM connector link status property
> > drm/i915: Update CRTC state if connector link status property changed
> > drm/i915: Find fallback link rate/lane count
> > drm/i915: Implement Link Rate fallback on Link training failure
> >
> > drivers/gpu/drm/drm_atomic_helper.c | 7 ++
> > drivers/gpu/drm/drm_connector.c | 55 ++++++++++
> > drivers/gpu/drm/i915/intel_ddi.c | 21 +++-
> > drivers/gpu/drm/i915/intel_dp.c | 144 +++++++++++++++++++++++++-
> > drivers/gpu/drm/i915/intel_dp_link_training.c | 12 ++-
> > drivers/gpu/drm/i915/intel_drv.h | 10 +-
> > include/drm/drm_connector.h | 9 +-
> > include/drm/drm_crtc.h | 5 +
> > include/uapi/drm/drm_mode.h | 4 +
> > 9 files changed, 257 insertions(+), 10 deletions(-)
>
> --
> Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 0/5] Clean series for Link training failure handling
@ 2016-11-19 2:58 Manasi Navare
2016-11-19 2:59 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
0 siblings, 1 reply; 31+ messages in thread
From: Manasi Navare @ 2016-11-19 2:58 UTC (permalink / raw)
To: intel-gfx, dri-devel
The idea presented in these patches is to address link training failure
in a way that:
a) changes the current happy day scenario as little as possible, to avoid
regressions, b) can be implemented the same way by all drm drivers, c)
is still opt-in for the drivers and userspace, and opting out doesn't
regress the user experience, d) doesn't prevent drivers from
implementing better or alternate approaches, possibly without userspace
involvement. And, of course, handles all the issues presented.
The solution is to add a "link status" connector property. In the usual
happy day scenario, this is always "good". If something fails during or
after a mode set, the kernel driver can set the link status to "bad",
prune the mode list based on new information as necessary, and send a
hotplug uevent for userspace to have it re-check the valid modes through
getconnector, and try again. If the theoretical capabilities of the link
can't be reached, the mode list is trimmed based on that.
If the userspace is not aware of the property, the user experience is
the same as it currently is. If the userspace is aware of the property,
it has a chance to improve user experience. If a drm driver does not
modify the property (it stays "good"), the user experience is the same
as it currently is. A drm driver can also choose to try to handle more
of the failures in kernel, hardware not limiting, or it can choose to
involve userspace more. Up to the drivers.
The reason for adding the property is to handle link training failures,
but it is not limited to DP or link training. For example, if we
implement asynchronous setcrtc, we can use this to report any failures
in that.
Finally, while DP CTS compliance is advertized (which is great, and
could be made to work similarly for all drm drivers), this can be used
for the more important goal of improving user experience on link
training failures, by avoiding black screens.
Manasi Navare (5):
drm: Add a new connector property for link status
drm: Set DRM connector link status property
drm/i915: Update CRTC state if connector link status property changed
drm/i915: Find fallback link rate/lane count
drm/i915: Implement Link Rate fallback on Link training failure
drivers/gpu/drm/drm_atomic_helper.c | 7 ++
drivers/gpu/drm/drm_connector.c | 65 +++++++++++++++-
drivers/gpu/drm/i915/intel_dp.c | 103 +++++++++++++++++++++++++-
drivers/gpu/drm/i915/intel_dp_link_training.c | 28 ++++++-
drivers/gpu/drm/i915/intel_drv.h | 7 ++
include/drm/drm_connector.h | 9 ++-
include/drm/drm_mode_config.h | 5 ++
include/uapi/drm/drm_mode.h | 4 +
8 files changed, 221 insertions(+), 7 deletions(-)
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 4/5] drm/i915: Find fallback link rate/lane count
2016-11-19 2:58 [PATCH 0/5] Clean series for Link training failure handling Manasi Navare
@ 2016-11-19 2:59 ` Manasi Navare
0 siblings, 0 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-19 2:59 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Manasi Navare, Daniel Vetter
If link training fails, then we need to fallback to lower
link rate first and if link training fails at RBR, then
fallback to lower lane count.
This function finds the next lower link rate/lane count
value after link training failure.
v5:
* Start the fallback at the lane count value passed not
the max lane count (Jani Nikula)
v4:
* Remove the redundant variable link_train_failed
v3:
* Remove fallback_link_rate_index variable, just obtain
that using the helper intel_dp_link_rate_index (Jani Nikula)
v2:
Squash the patch that returns the link rate index (Jani Nikula)
Acked-by: Tony Cheng <tony.cheng@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
---
drivers/gpu/drm/i915/intel_dp.c | 40 ++++++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/intel_drv.h | 4 ++++
2 files changed, 44 insertions(+)
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 90283ed..3a72014 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -288,6 +288,46 @@ static int intel_dp_common_rates(struct intel_dp *intel_dp,
common_rates);
}
+static int intel_dp_link_rate_index(struct intel_dp *intel_dp,
+ int *common_rates, int link_rate)
+{
+ int common_len;
+ int index;
+
+ common_len = intel_dp_common_rates(intel_dp, common_rates);
+ for (index = 0; index < common_len; index++) {
+ if (link_rate == common_rates[common_len - index - 1])
+ return common_len - index - 1;
+ }
+
+ return -1;
+}
+
+int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
+ int link_rate, uint8_t lane_count)
+{
+ int common_rates[DP_MAX_SUPPORTED_RATES] = {};
+ int common_len;
+ int link_rate_index = -1;
+
+ common_len = intel_dp_common_rates(intel_dp, common_rates);
+ link_rate_index = intel_dp_link_rate_index(intel_dp,
+ common_rates,
+ link_rate);
+ if (link_rate_index > 0) {
+ intel_dp->fallback_link_rate = common_rates[link_rate_index - 1];
+ intel_dp->fallback_lane_count = lane_count;
+ } else if (lane_count > 1) {
+ intel_dp->fallback_link_rate = common_rates[common_len - 1];
+ intel_dp->fallback_lane_count = lane_count >> 1;
+ } else {
+ DRM_ERROR("Link Training Unsuccessful\n");
+ return -1;
+ }
+
+ return 0;
+}
+
static enum drm_mode_status
intel_dp_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index cd132c2..e1c43a9 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -887,6 +887,8 @@ struct intel_dp {
uint32_t DP;
int link_rate;
uint8_t lane_count;
+ int fallback_link_rate;
+ uint8_t fallback_lane_count;
uint8_t sink_count;
bool link_mst;
bool has_audio;
@@ -1383,6 +1385,8 @@ bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
void intel_dp_set_link_params(struct intel_dp *intel_dp,
int link_rate, uint8_t lane_count,
bool link_mst);
+int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
+ int link_rate, uint8_t lane_count);
void intel_dp_start_link_train(struct intel_dp *intel_dp);
void intel_dp_stop_link_train(struct intel_dp *intel_dp);
void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure
@ 2016-11-18 7:29 Manasi Navare
0 siblings, 0 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-18 7:29 UTC (permalink / raw)
To: dri-devel, intel-gfx; +Cc: Daniel Vetter
If link training at a link rate optimal for a particular
mode fails during modeset's atomic commit phase, then we
let the modeset complete and then retry. We save the link rate
value at which link training failed, update the link status property
to "BAD" and use a lower link rate to prune the modes. It will redo
the modeset on the current mode at lower link rate or if the current
mode gets pruned due to lower link constraints then, it will send a
hotplug uevent for userspace to handle it.
This is also required to pass DP CTS tests 4.3.1.3, 4.3.1.4,
4.3.1.6.
v7:
Remove the redundant variable in previous patch itself
v6:
* Obtain link rate index from fallback_link_rate using
the helper intel_dp_link_rate_index (Jani Nikula)
* Include fallback within intel_dp_start_link_train (Jani Nikula)
v5:
* Move set link status to drm core (Daniel Vetter, Jani Nikula)
v4:
* Add fallback support for non DDI platforms too
* Set connector->link status inside set_link_status function
(Jani Nikula)
v3:
* Set link status property to BAd unconditionally (Jani Nikula)
* Dont use two separate variables link_train_failed and link_status
to indicate same thing (Jani Nikula)
v2:
* Squashed a few patches (Jani Nikula)
Acked-by: Tony Cheng <tony.cheng@amd.com>
Acked-by: Harry Wentland <Harry.wentland@amd.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
---
drivers/gpu/drm/i915/intel_dp.c | 63 ++++++++++++++++++++++++++-
drivers/gpu/drm/i915/intel_dp_link_training.c | 28 +++++++++++-
drivers/gpu/drm/i915/intel_drv.h | 3 ++
3 files changed, 90 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 4fb89e1..a56a34d 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -351,8 +351,14 @@ int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
target_clock = fixed_mode->clock;
}
- max_link_clock = intel_dp_max_link_rate(intel_dp);
- max_lanes = intel_dp_max_lane_count(intel_dp);
+ /* Prune the modes using the fallback link rate/lane count */
+ if (connector->link_status == DRM_MODE_LINK_STATUS_BAD) {
+ max_link_clock = intel_dp->fallback_link_rate;
+ max_lanes = intel_dp->fallback_lane_count;
+ } else {
+ max_link_clock = intel_dp_max_link_rate(intel_dp);
+ max_lanes = intel_dp_max_lane_count(intel_dp);
+ }
max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes);
mode_rate = intel_dp_link_required(target_clock, 18);
@@ -1588,6 +1594,7 @@ static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
enum port port = dp_to_dig_port(intel_dp)->port;
struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->base.crtc);
struct intel_connector *intel_connector = intel_dp->attached_connector;
+ struct drm_connector *connector = &intel_connector->base;
int lane_count, clock;
int min_lane_count = 1;
int max_lane_count = intel_dp_max_lane_count(intel_dp);
@@ -1635,6 +1642,14 @@ static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK)
return false;
+ /* Fall back to lower link rate in case of failure in previous modeset */
+ if (connector->link_status == DRM_MODE_LINK_STATUS_BAD) {
+ min_lane_count = max_lane_count = intel_dp->fallback_lane_count;
+ min_clock = max_clock = intel_dp_link_rate_index(intel_dp,
+ common_rates,
+ intel_dp->fallback_link_rate);
+ }
+
DRM_DEBUG_KMS("DP link computation with max lane count %i "
"max bw %d pixel clock %iKHz\n",
max_lane_count, common_rates[max_clock],
@@ -4415,6 +4430,10 @@ static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
intel_dp->compliance_test_active = 0;
intel_dp->compliance_test_type = 0;
intel_dp->compliance_test_data = 0;
+ intel_dp->fallback_link_rate = 0;
+ intel_dp->fallback_lane_count = 0;
+ drm_mode_connector_set_link_status_property(connector,
+ DRM_MODE_LINK_STATUS_GOOD);
if (intel_dp->is_mst) {
DRM_DEBUG_KMS("MST device may have disappeared %d vs %d\n",
@@ -4506,6 +4525,11 @@ static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
connector->base.id, connector->name);
+ /* If this is a retry due to link trianing failure */
+ if (status == connector_status_connected &&
+ connector->link_status == DRM_MODE_LINK_STATUS_BAD)
+ return status;
+
/* If full detect is not performed yet, do a full detect */
if (!intel_dp->detect_done)
status = intel_dp_long_pulse(intel_dp->attached_connector);
@@ -5671,6 +5695,37 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
return false;
}
+static void intel_dp_modeset_retry_work_fn(struct work_struct *work)
+{
+ struct intel_connector *intel_connector;
+ struct drm_connector *connector;
+ struct drm_display_mode *mode;
+ bool verbose_prune = true;
+
+ intel_connector = container_of(work, typeof(*intel_connector),
+ modeset_retry_work);
+ connector = &intel_connector->base;
+
+ /* Grab the locks before changing connector property*/
+ mutex_lock(&connector->dev->mode_config.mutex);
+ DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id,
+ connector->name);
+ list_for_each_entry(mode, &connector->modes, head) {
+ mode->status = intel_dp_mode_valid(connector,
+ mode);
+ }
+ drm_mode_prune_invalid(connector->dev, &connector->modes,
+ verbose_prune);
+ /* Set connector link status to BAD and send a Uevent to notify
+ * userspace to do a modeset.
+ */
+ drm_mode_connector_set_link_status_property(connector,
+ DRM_MODE_LINK_STATUS_BAD);
+ mutex_unlock(&connector->dev->mode_config.mutex);
+ /* Send Hotplug uevent so userspace can reprobe */
+ drm_kms_helper_hotplug_event(connector->dev);
+}
+
bool
intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
struct intel_connector *intel_connector)
@@ -5683,6 +5738,10 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
enum port port = intel_dig_port->port;
int type;
+ /* Initialize the work for modeset in case of link train failure */
+ INIT_WORK(&intel_connector->modeset_retry_work,
+ intel_dp_modeset_retry_work_fn);
+
if (WARN(intel_dig_port->max_lanes < 1,
"Not enough lanes (%d) for DP on port %c\n",
intel_dig_port->max_lanes, port_name(port)))
diff --git a/drivers/gpu/drm/i915/intel_dp_link_training.c b/drivers/gpu/drm/i915/intel_dp_link_training.c
index 0048b52..cc243db 100644
--- a/drivers/gpu/drm/i915/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/intel_dp_link_training.c
@@ -313,6 +313,30 @@ void intel_dp_stop_link_train(struct intel_dp *intel_dp)
void
intel_dp_start_link_train(struct intel_dp *intel_dp)
{
- intel_dp_link_training_clock_recovery(intel_dp);
- intel_dp_link_training_channel_equalization(intel_dp);
+ struct intel_connector *intel_connector = intel_dp->attached_connector;
+ struct drm_connector *connector = &intel_connector->base;
+
+ if (!intel_dp_link_training_clock_recovery(intel_dp))
+ goto failure_handling;
+ if (!intel_dp_link_training_channel_equalization(intel_dp))
+ goto failure_handling;
+
+ /* Reset the Link Train Values */
+ DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane count = %d",
+ intel_dp->link_rate, intel_dp->lane_count);
+ intel_dp->fallback_link_rate = 0;
+ intel_dp->fallback_lane_count = 0;
+ drm_mode_connector_set_link_status_property(connector,
+ DRM_MODE_LINK_STATUS_GOOD);
+ return;
+
+ failure_handling:
+ DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane count = %d",
+ intel_dp->link_rate, intel_dp->lane_count);
+ if (!intel_dp_get_link_train_fallback_values(intel_dp,
+ intel_dp->link_rate,
+ intel_dp->lane_count))
+ /* Schedule a Hotplug Uevent to userspace to start modeset */
+ schedule_work(&intel_connector->modeset_retry_work);
+ return;
}
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index e1c43a9..33be66f 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -315,6 +315,9 @@ struct intel_connector {
void *port; /* store this opaque as its illegal to dereference it */
struct intel_dp *mst_port;
+
+ /* Work struct to schedule a uevent on link train failure */
+ struct work_struct modeset_retry_work;
};
struct dpll {
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 0/5] Link Training failure handling during modeset
@ 2016-11-18 7:13 Manasi Navare
2016-11-18 7:13 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
0 siblings, 1 reply; 31+ messages in thread
From: Manasi Navare @ 2016-11-18 7:13 UTC (permalink / raw)
To: dri-devel, intel-gfx; +Cc: Manasi Navare
Submitting this series again since it had to be rebased dur to changes
in drm that got merged.
The idea presented in these patches is to address link training failure
in a way that:
a) changes the current happy day scenario as little as possible, to avoid
regressions, b) can be implemented the same way by all drm drivers, c)
is still opt-in for the drivers and userspace, and opting out doesn't
regress the user experience, d) doesn't prevent drivers from
implementing better or alternate approaches, possibly without userspace
involvement. And, of course, handles all the issues presented.
The solution is to add a "link status" connector property. In the usual
happy day scenario, this is always "good". If something fails during or
after a mode set, the kernel driver can set the link status to "bad",
prune the mode list based on new information as necessary, and send a
hotplug uevent for userspace to have it re-check the valid modes through
getconnector, and try again. If the theoretical capabilities of the link
can't be reached, the mode list is trimmed based on that.
If the userspace is not aware of the property, the user experience is
the same as it currently is. If the userspace is aware of the property,
it has a chance to improve user experience. If a drm driver does not
modify the property (it stays "good"), the user experience is the same
as it currently is. A drm driver can also choose to try to handle more
of the failures in kernel, hardware not limiting, or it can choose to
involve userspace more. Up to the drivers.
The reason for adding the property is to handle link training failures,
but it is not limited to DP or link training. For example, if we
implement asynchronous setcrtc, we can use this to report any failures
in that.
Finally, while DP CTS compliance is advertized (which is great, and
could be made to work similarly for all drm drivers), this can be used
for the more important goal of improving user experience on link
training failures, by avoiding black screens.
Manasi Navare (5):
drm: Add a new connector property for link status
drm: Set DRM connector link status property
drm/i915: Update CRTC state if connector link status property changed
drm/i915: Find fallback link rate/lane count
drm/i915: Implement Link Rate fallback on Link training failure
drivers/gpu/drm/drm_atomic_helper.c | 7 ++
drivers/gpu/drm/drm_connector.c | 54 ++++++++++++++
drivers/gpu/drm/i915/intel_dp.c | 103 +++++++++++++++++++++++++-
drivers/gpu/drm/i915/intel_dp_link_training.c | 28 ++++++-
drivers/gpu/drm/i915/intel_drv.h | 7 ++
include/drm/drm_connector.h | 9 ++-
include/drm/drm_mode_config.h | 5 ++
include/uapi/drm/drm_mode.h | 4 +
8 files changed, 212 insertions(+), 5 deletions(-)
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 4/5] drm/i915: Find fallback link rate/lane count
2016-11-18 7:13 [PATCH 0/5] Link Training failure handling during modeset Manasi Navare
@ 2016-11-18 7:13 ` Manasi Navare
2016-11-18 7:29 ` Manasi Navare
0 siblings, 1 reply; 31+ messages in thread
From: Manasi Navare @ 2016-11-18 7:13 UTC (permalink / raw)
To: dri-devel, intel-gfx; +Cc: Daniel Vetter
If link training fails, then we need to fallback to lower
link rate first and if link training fails at RBR, then
fallback to lower lane count.
This function finds the next lower link rate/lane count
value after link training failure.
v3:
* Remove fallback_link_rate_index variable, just obtain
that using the helper intel_dp_link_rate_index (Jani Nikula)
v2:
Squash the patch that returns the link rate index (Jani Nikula)
Acked-by: Tony Cheng <tony.cheng@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
---
drivers/gpu/drm/i915/intel_dp.c | 40 ++++++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/intel_drv.h | 5 +++++
2 files changed, 45 insertions(+)
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 90283ed..4fb89e1 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -288,6 +288,46 @@ static int intel_dp_common_rates(struct intel_dp *intel_dp,
common_rates);
}
+static int intel_dp_link_rate_index(struct intel_dp *intel_dp,
+ int *common_rates, int link_rate)
+{
+ int common_len;
+ int index;
+
+ common_len = intel_dp_common_rates(intel_dp, common_rates);
+ for (index = 0; index < common_len; index++) {
+ if (link_rate == common_rates[common_len - index - 1])
+ return common_len - index - 1;
+ }
+
+ return -1;
+}
+
+int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
+ int link_rate, uint8_t lane_count)
+{
+ int common_rates[DP_MAX_SUPPORTED_RATES] = {};
+ int common_len;
+ int link_rate_index = -1;
+
+ common_len = intel_dp_common_rates(intel_dp, common_rates);
+ link_rate_index = intel_dp_link_rate_index(intel_dp,
+ common_rates,
+ link_rate);
+ if (link_rate_index > 0) {
+ intel_dp->fallback_link_rate = common_rates[link_rate_index - 1];
+ intel_dp->fallback_lane_count = intel_dp_max_lane_count(intel_dp);
+ } else if (lane_count > 1) {
+ intel_dp->fallback_link_rate = common_rates[common_len - 1];
+ intel_dp->fallback_lane_count = lane_count >> 1;
+ } else {
+ DRM_ERROR("Link Training Unsuccessful\n");
+ return -1;
+ }
+
+ return 0;
+}
+
static enum drm_mode_status
intel_dp_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index cd132c2..3f6b4c9 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -887,6 +887,9 @@ struct intel_dp {
uint32_t DP;
int link_rate;
uint8_t lane_count;
+ int fallback_link_rate;
+ uint8_t fallback_lane_count;
+ bool link_train_failed;
uint8_t sink_count;
bool link_mst;
bool has_audio;
@@ -1383,6 +1386,8 @@ bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
void intel_dp_set_link_params(struct intel_dp *intel_dp,
int link_rate, uint8_t lane_count,
bool link_mst);
+int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
+ int link_rate, uint8_t lane_count);
void intel_dp_start_link_train(struct intel_dp *intel_dp);
void intel_dp_stop_link_train(struct intel_dp *intel_dp);
void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 4/5] drm/i915: Find fallback link rate/lane count
2016-11-18 7:13 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
@ 2016-11-18 7:29 ` Manasi Navare
2016-11-18 13:22 ` Jani Nikula
0 siblings, 1 reply; 31+ messages in thread
From: Manasi Navare @ 2016-11-18 7:29 UTC (permalink / raw)
To: dri-devel, intel-gfx; +Cc: Daniel Vetter
If link training fails, then we need to fallback to lower
link rate first and if link training fails at RBR, then
fallback to lower lane count.
This function finds the next lower link rate/lane count
value after link training failure.
v4:
* Remove the redundant variable link_train_failed
v3:
* Remove fallback_link_rate_index variable, just obtain
that using the helper intel_dp_link_rate_index (Jani Nikula)
v2:
Squash the patch that returns the link rate index (Jani Nikula)
Acked-by: Tony Cheng <tony.cheng@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
---
drivers/gpu/drm/i915/intel_dp.c | 40 ++++++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/intel_drv.h | 4 ++++
2 files changed, 44 insertions(+)
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 90283ed..4fb89e1 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -288,6 +288,46 @@ static int intel_dp_common_rates(struct intel_dp *intel_dp,
common_rates);
}
+static int intel_dp_link_rate_index(struct intel_dp *intel_dp,
+ int *common_rates, int link_rate)
+{
+ int common_len;
+ int index;
+
+ common_len = intel_dp_common_rates(intel_dp, common_rates);
+ for (index = 0; index < common_len; index++) {
+ if (link_rate == common_rates[common_len - index - 1])
+ return common_len - index - 1;
+ }
+
+ return -1;
+}
+
+int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
+ int link_rate, uint8_t lane_count)
+{
+ int common_rates[DP_MAX_SUPPORTED_RATES] = {};
+ int common_len;
+ int link_rate_index = -1;
+
+ common_len = intel_dp_common_rates(intel_dp, common_rates);
+ link_rate_index = intel_dp_link_rate_index(intel_dp,
+ common_rates,
+ link_rate);
+ if (link_rate_index > 0) {
+ intel_dp->fallback_link_rate = common_rates[link_rate_index - 1];
+ intel_dp->fallback_lane_count = intel_dp_max_lane_count(intel_dp);
+ } else if (lane_count > 1) {
+ intel_dp->fallback_link_rate = common_rates[common_len - 1];
+ intel_dp->fallback_lane_count = lane_count >> 1;
+ } else {
+ DRM_ERROR("Link Training Unsuccessful\n");
+ return -1;
+ }
+
+ return 0;
+}
+
static enum drm_mode_status
intel_dp_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index cd132c2..e1c43a9 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -887,6 +887,8 @@ struct intel_dp {
uint32_t DP;
int link_rate;
uint8_t lane_count;
+ int fallback_link_rate;
+ uint8_t fallback_lane_count;
uint8_t sink_count;
bool link_mst;
bool has_audio;
@@ -1383,6 +1385,8 @@ bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
void intel_dp_set_link_params(struct intel_dp *intel_dp,
int link_rate, uint8_t lane_count,
bool link_mst);
+int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
+ int link_rate, uint8_t lane_count);
void intel_dp_start_link_train(struct intel_dp *intel_dp);
void intel_dp_stop_link_train(struct intel_dp *intel_dp);
void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 4/5] drm/i915: Find fallback link rate/lane count
2016-11-18 7:29 ` Manasi Navare
@ 2016-11-18 13:22 ` Jani Nikula
2016-11-18 15:39 ` Manasi Navare
0 siblings, 1 reply; 31+ messages in thread
From: Jani Nikula @ 2016-11-18 13:22 UTC (permalink / raw)
To: dri-devel, intel-gfx; +Cc: Manasi Navare, Daniel Vetter
On Fri, 18 Nov 2016, Manasi Navare <manasi.d.navare@intel.com> wrote:
> If link training fails, then we need to fallback to lower
> link rate first and if link training fails at RBR, then
> fallback to lower lane count.
> This function finds the next lower link rate/lane count
> value after link training failure.
>
> v4:
> * Remove the redundant variable link_train_failed
> v3:
> * Remove fallback_link_rate_index variable, just obtain
> that using the helper intel_dp_link_rate_index (Jani Nikula)
> v2:
> Squash the patch that returns the link rate index (Jani Nikula)
>
> Acked-by: Tony Cheng <tony.cheng@amd.com>
> Acked-by: Harry Wentland <harry.wentland@amd.com>
> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> ---
> drivers/gpu/drm/i915/intel_dp.c | 40 ++++++++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/i915/intel_drv.h | 4 ++++
> 2 files changed, 44 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index 90283ed..4fb89e1 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -288,6 +288,46 @@ static int intel_dp_common_rates(struct intel_dp *intel_dp,
> common_rates);
> }
>
> +static int intel_dp_link_rate_index(struct intel_dp *intel_dp,
> + int *common_rates, int link_rate)
> +{
> + int common_len;
> + int index;
> +
> + common_len = intel_dp_common_rates(intel_dp, common_rates);
> + for (index = 0; index < common_len; index++) {
> + if (link_rate == common_rates[common_len - index - 1])
> + return common_len - index - 1;
> + }
> +
> + return -1;
> +}
> +
> +int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> + int link_rate, uint8_t lane_count)
> +{
> + int common_rates[DP_MAX_SUPPORTED_RATES] = {};
> + int common_len;
> + int link_rate_index = -1;
> +
> + common_len = intel_dp_common_rates(intel_dp, common_rates);
> + link_rate_index = intel_dp_link_rate_index(intel_dp,
> + common_rates,
> + link_rate);
> + if (link_rate_index > 0) {
> + intel_dp->fallback_link_rate = common_rates[link_rate_index - 1];
> + intel_dp->fallback_lane_count = intel_dp_max_lane_count(intel_dp);
So you first try lower and lower link rates, until you're at the
lowest...
> + } else if (lane_count > 1) {
> + intel_dp->fallback_link_rate = common_rates[common_len - 1];
> + intel_dp->fallback_lane_count = lane_count >> 1;
...and then go to highest rate, double lane count, and go back back to
reducing link rate. Rinse and repeat.
Problem is, lane_count will always be > 1, and you'll keep doubling lane
count without bounds if link training persistently fails, and I don't
think you'll reach the below else branch.
I regret that I haven't caught all of these issues all at once; it is in
part testament to the fact that the state machine here is not easy to
follow.
BR,
Jani.
> + } else {
> + DRM_ERROR("Link Training Unsuccessful\n");
> + return -1;
> + }
> +
> + return 0;
> +}
> +
> static enum drm_mode_status
> intel_dp_mode_valid(struct drm_connector *connector,
> struct drm_display_mode *mode)
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index cd132c2..e1c43a9 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -887,6 +887,8 @@ struct intel_dp {
> uint32_t DP;
> int link_rate;
> uint8_t lane_count;
> + int fallback_link_rate;
> + uint8_t fallback_lane_count;
> uint8_t sink_count;
> bool link_mst;
> bool has_audio;
> @@ -1383,6 +1385,8 @@ bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> void intel_dp_set_link_params(struct intel_dp *intel_dp,
> int link_rate, uint8_t lane_count,
> bool link_mst);
> +int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> + int link_rate, uint8_t lane_count);
> void intel_dp_start_link_train(struct intel_dp *intel_dp);
> void intel_dp_stop_link_train(struct intel_dp *intel_dp);
> void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 4/5] drm/i915: Find fallback link rate/lane count
2016-11-18 13:22 ` Jani Nikula
@ 2016-11-18 15:39 ` Manasi Navare
2016-11-19 2:09 ` Manasi Navare
0 siblings, 1 reply; 31+ messages in thread
From: Manasi Navare @ 2016-11-18 15:39 UTC (permalink / raw)
To: Jani Nikula; +Cc: Daniel Vetter, intel-gfx, dri-devel
On Fri, Nov 18, 2016 at 03:22:49PM +0200, Jani Nikula wrote:
> On Fri, 18 Nov 2016, Manasi Navare <manasi.d.navare@intel.com> wrote:
> > If link training fails, then we need to fallback to lower
> > link rate first and if link training fails at RBR, then
> > fallback to lower lane count.
> > This function finds the next lower link rate/lane count
> > value after link training failure.
> >
> > v4:
> > * Remove the redundant variable link_train_failed
> > v3:
> > * Remove fallback_link_rate_index variable, just obtain
> > that using the helper intel_dp_link_rate_index (Jani Nikula)
> > v2:
> > Squash the patch that returns the link rate index (Jani Nikula)
> >
> > Acked-by: Tony Cheng <tony.cheng@amd.com>
> > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Cc: Daniel Vetter <daniel.vetter@intel.com>
> > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > ---
> > drivers/gpu/drm/i915/intel_dp.c | 40 ++++++++++++++++++++++++++++++++++++++++
> > drivers/gpu/drm/i915/intel_drv.h | 4 ++++
> > 2 files changed, 44 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> > index 90283ed..4fb89e1 100644
> > --- a/drivers/gpu/drm/i915/intel_dp.c
> > +++ b/drivers/gpu/drm/i915/intel_dp.c
> > @@ -288,6 +288,46 @@ static int intel_dp_common_rates(struct intel_dp *intel_dp,
> > common_rates);
> > }
> >
> > +static int intel_dp_link_rate_index(struct intel_dp *intel_dp,
> > + int *common_rates, int link_rate)
> > +{
> > + int common_len;
> > + int index;
> > +
> > + common_len = intel_dp_common_rates(intel_dp, common_rates);
> > + for (index = 0; index < common_len; index++) {
> > + if (link_rate == common_rates[common_len - index - 1])
> > + return common_len - index - 1;
> > + }
> > +
> > + return -1;
> > +}
> > +
> > +int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> > + int link_rate, uint8_t lane_count)
> > +{
> > + int common_rates[DP_MAX_SUPPORTED_RATES] = {};
> > + int common_len;
> > + int link_rate_index = -1;
> > +
> > + common_len = intel_dp_common_rates(intel_dp, common_rates);
> > + link_rate_index = intel_dp_link_rate_index(intel_dp,
> > + common_rates,
> > + link_rate);
> > + if (link_rate_index > 0) {
> > + intel_dp->fallback_link_rate = common_rates[link_rate_index - 1];
> > + intel_dp->fallback_lane_count = intel_dp_max_lane_count(intel_dp);
>
> So you first try lower and lower link rates, until you're at the
> lowest...
>
Yes so first it tries to lower the link rate until it goes to the lowes i.e RBR.
All this link rate reduction happens with lane count set to maximum.
> > + } else if (lane_count > 1) {
> > + intel_dp->fallback_link_rate = common_rates[common_len - 1];
> > + intel_dp->fallback_lane_count = lane_count >> 1;
>
> ...and then go to highest rate, double lane count, and go back back to
> reducing link rate. Rinse and repeat.
>
So after link rate reaches RBR, it checks if lane count is > 1 and if it is then
it jumps the link rate back to highest supported and reduces the link rate from
4 to 2 to 1.
> Problem is, lane_count will always be > 1, and you'll keep doubling lane
> count without bounds if link training persistently fails, and I don't
> think you'll reach the below else branch.
>
So since I am reducing the lane count in each iteration, lane_count >> 1, at some point
it will go to 0 and that point it will exit with DRM_ERROR that link train failed
because at thatpoint we have exhausted trying all the link raterate and lane count
combinations.
I am never doubling the link rate for it to reach out of bounds, infact I am reducing
the link rate to half each time (right shifting lane count) so at some point lane count will
fall to less than 0 when it will fall into the last else part.
Regards
Manasi
> I regret that I haven't caught all of these issues all at once; it is in
> part testament to the fact that the state machine here is not easy to
> follow.
>
> BR,
> Jani.
>
> > + } else {
> > + DRM_ERROR("Link Training Unsuccessful\n");
> > + return -1;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > static enum drm_mode_status
> > intel_dp_mode_valid(struct drm_connector *connector,
> > struct drm_display_mode *mode)
> > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > index cd132c2..e1c43a9 100644
> > --- a/drivers/gpu/drm/i915/intel_drv.h
> > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > @@ -887,6 +887,8 @@ struct intel_dp {
> > uint32_t DP;
> > int link_rate;
> > uint8_t lane_count;
> > + int fallback_link_rate;
> > + uint8_t fallback_lane_count;
> > uint8_t sink_count;
> > bool link_mst;
> > bool has_audio;
> > @@ -1383,6 +1385,8 @@ bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> > void intel_dp_set_link_params(struct intel_dp *intel_dp,
> > int link_rate, uint8_t lane_count,
> > bool link_mst);
> > +int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> > + int link_rate, uint8_t lane_count);
> > void intel_dp_start_link_train(struct intel_dp *intel_dp);
> > void intel_dp_stop_link_train(struct intel_dp *intel_dp);
> > void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
>
> --
> Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 4/5] drm/i915: Find fallback link rate/lane count
2016-11-18 15:39 ` Manasi Navare
@ 2016-11-19 2:09 ` Manasi Navare
0 siblings, 0 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-19 2:09 UTC (permalink / raw)
To: Jani Nikula; +Cc: Daniel Vetter, intel-gfx, dri-devel
On Fri, Nov 18, 2016 at 07:39:50AM -0800, Manasi Navare wrote:
> On Fri, Nov 18, 2016 at 03:22:49PM +0200, Jani Nikula wrote:
> > On Fri, 18 Nov 2016, Manasi Navare <manasi.d.navare@intel.com> wrote:
> > > If link training fails, then we need to fallback to lower
> > > link rate first and if link training fails at RBR, then
> > > fallback to lower lane count.
> > > This function finds the next lower link rate/lane count
> > > value after link training failure.
> > >
> > > v4:
> > > * Remove the redundant variable link_train_failed
> > > v3:
> > > * Remove fallback_link_rate_index variable, just obtain
> > > that using the helper intel_dp_link_rate_index (Jani Nikula)
> > > v2:
> > > Squash the patch that returns the link rate index (Jani Nikula)
> > >
> > > Acked-by: Tony Cheng <tony.cheng@amd.com>
> > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > Cc: Daniel Vetter <daniel.vetter@intel.com>
> > > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > > ---
> > > drivers/gpu/drm/i915/intel_dp.c | 40 ++++++++++++++++++++++++++++++++++++++++
> > > drivers/gpu/drm/i915/intel_drv.h | 4 ++++
> > > 2 files changed, 44 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> > > index 90283ed..4fb89e1 100644
> > > --- a/drivers/gpu/drm/i915/intel_dp.c
> > > +++ b/drivers/gpu/drm/i915/intel_dp.c
> > > @@ -288,6 +288,46 @@ static int intel_dp_common_rates(struct intel_dp *intel_dp,
> > > common_rates);
> > > }
> > >
> > > +static int intel_dp_link_rate_index(struct intel_dp *intel_dp,
> > > + int *common_rates, int link_rate)
> > > +{
> > > + int common_len;
> > > + int index;
> > > +
> > > + common_len = intel_dp_common_rates(intel_dp, common_rates);
> > > + for (index = 0; index < common_len; index++) {
> > > + if (link_rate == common_rates[common_len - index - 1])
> > > + return common_len - index - 1;
> > > + }
> > > +
> > > + return -1;
> > > +}
> > > +
> > > +int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> > > + int link_rate, uint8_t lane_count)
> > > +{
> > > + int common_rates[DP_MAX_SUPPORTED_RATES] = {};
> > > + int common_len;
> > > + int link_rate_index = -1;
> > > +
> > > + common_len = intel_dp_common_rates(intel_dp, common_rates);
> > > + link_rate_index = intel_dp_link_rate_index(intel_dp,
> > > + common_rates,
> > > + link_rate);
> > > + if (link_rate_index > 0) {
> > > + intel_dp->fallback_link_rate = common_rates[link_rate_index - 1];
> > > + intel_dp->fallback_lane_count = intel_dp_max_lane_count(intel_dp);
> >
> > So you first try lower and lower link rates, until you're at the
> > lowest...
> >
>
> Yes so first it tries to lower the link rate until it goes to the lowes i.e RBR.
> All this link rate reduction happens with lane count set to maximum.
>
> > > + } else if (lane_count > 1) {
> > > + intel_dp->fallback_link_rate = common_rates[common_len - 1];
> > > + intel_dp->fallback_lane_count = lane_count >> 1;
> >
> > ...and then go to highest rate, double lane count, and go back back to
> > reducing link rate. Rinse and repeat.
> >
>
> So after link rate reaches RBR, it checks if lane count is > 1 and if it is then
> it jumps the link rate back to highest supported and reduces the link rate from
> 4 to 2 to 1.
>
> > Problem is, lane_count will always be > 1, and you'll keep doubling lane
> > count without bounds if link training persistently fails, and I don't
> > think you'll reach the below else branch.
> >
>
> So since I am reducing the lane count in each iteration, lane_count >> 1, at some point
> it will go to 0 and that point it will exit with DRM_ERROR that link train failed
> because at thatpoint we have exhausted trying all the link raterate and lane count
> combinations.
> I am never doubling the link rate for it to reach out of bounds, infact I am reducing
> the link rate to half each time (right shifting lane count) so at some point lane count will
> fall to less than 0 when it will fall into the last else part.
>
> Regards
> Manasi
>
>
The only problem i found is that I am setting lane count to max lane count which is wrong
in each iteration it should be set to lane count being passed in and it should start from that value and fallback.
So for Ex: If the first modeset is trying to train link at 2.7 and 4 lanes and link training fails,
Iteration 1 : 1.62 and 4 if this fails
Iteration 2: max link rate 5.4 and 2 (reduced lane count is halved)
Iteration 3: 2.7 and 2
Iteration 4: 1.62 and 2
Iteration 5: 5.4 and 1
iteration 6: 2.7 and 1
Iteration 7: 1.62 and 1
If this fails then it will return an error that Link training is failed.
Manasi
> > I regret that I haven't caught all of these issues all at once; it is in
> > part testament to the fact that the state machine here is not easy to
> > follow.
> >
> > BR,
> > Jani.
> >
>
> > > + } else {
> > > + DRM_ERROR("Link Training Unsuccessful\n");
> > > + return -1;
> > > + }
> > > +
> > > + return 0;
> > > +}
> > > +
> > > static enum drm_mode_status
> > > intel_dp_mode_valid(struct drm_connector *connector,
> > > struct drm_display_mode *mode)
> > > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > > index cd132c2..e1c43a9 100644
> > > --- a/drivers/gpu/drm/i915/intel_drv.h
> > > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > > @@ -887,6 +887,8 @@ struct intel_dp {
> > > uint32_t DP;
> > > int link_rate;
> > > uint8_t lane_count;
> > > + int fallback_link_rate;
> > > + uint8_t fallback_lane_count;
> > > uint8_t sink_count;
> > > bool link_mst;
> > > bool has_audio;
> > > @@ -1383,6 +1385,8 @@ bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> > > void intel_dp_set_link_params(struct intel_dp *intel_dp,
> > > int link_rate, uint8_t lane_count,
> > > bool link_mst);
> > > +int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> > > + int link_rate, uint8_t lane_count);
> > > void intel_dp_start_link_train(struct intel_dp *intel_dp);
> > > void intel_dp_stop_link_train(struct intel_dp *intel_dp);
> > > void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
> >
> > --
> > Jani Nikula, Intel Open Source Technology Center
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 0/5] Handle Link Training Failure during modeset
@ 2016-11-10 4:42 Manasi Navare
2016-11-10 4:42 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
0 siblings, 1 reply; 31+ messages in thread
From: Manasi Navare @ 2016-11-10 4:42 UTC (permalink / raw)
To: dri-devel, intel-gfx
Link training failure is handled by lowering the link rate first
until it reaches the minimum and keeping the lane count maximum
and then lowering the lane count until it reaches minimim. These
fallback values are saved and hotplug uevent is sent to the userspace
after setting the connector link status property to BAD. Userspace
should triiger another modeset on a uevent and if link status property
is BAD. This will retrain the link at fallback values.
This is repeated until the link is successfully trained.
This has been validated to pass DP compliance.
Manasi Navare (5):
drm: Add a new connector property for link status
drm/i915: Set link status property for DP connector
drm/i915: Update CRTC state if connector link status property changed
drm/i915: Find fallback link rate/lane count
drm/i915: Implement Link Rate fallback on Link training failure
drivers/gpu/drm/drm_atomic_helper.c | 7 ++
drivers/gpu/drm/drm_connector.c | 17 ++++
drivers/gpu/drm/i915/intel_ddi.c | 21 +++-
drivers/gpu/drm/i915/intel_dp.c | 138 +++++++++++++++++++++++++-
drivers/gpu/drm/i915/intel_dp_link_training.c | 12 ++-
drivers/gpu/drm/i915/intel_drv.h | 12 ++-
include/drm/drm_connector.h | 7 +-
include/drm/drm_crtc.h | 5 +
include/uapi/drm/drm_mode.h | 4 +
9 files changed, 214 insertions(+), 9 deletions(-)
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 4/5] drm/i915: Find fallback link rate/lane count
2016-11-10 4:42 [PATCH 0/5] Handle Link Training Failure during modeset Manasi Navare
@ 2016-11-10 4:42 ` Manasi Navare
0 siblings, 0 replies; 31+ messages in thread
From: Manasi Navare @ 2016-11-10 4:42 UTC (permalink / raw)
To: dri-devel, intel-gfx; +Cc: Daniel Vetter
If link training fails, then we need to fallback to lower
link rate first and if link training fails at RBR, then
fallback to lower lane count.
This function finds the next lower link rate/lane count
value after link training failure.
v2:
Squash the patch that returns the link rate index (Jani Nikula)
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
---
drivers/gpu/drm/i915/intel_dp.c | 42 ++++++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/intel_drv.h | 6 ++++++
2 files changed, 48 insertions(+)
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 1f1760f..9694857 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -288,6 +288,48 @@ static int intel_dp_common_rates(struct intel_dp *intel_dp,
common_rates);
}
+static int intel_dp_link_rate_index(struct intel_dp *intel_dp,
+ int *common_rates, int link_rate)
+{
+ int common_len;
+ int index;
+
+ common_len = intel_dp_common_rates(intel_dp, common_rates);
+ for (index = 0; index < common_len; index++) {
+ if (link_rate == common_rates[common_len - index - 1])
+ return common_len - index - 1;
+ }
+
+ return -1;
+}
+
+int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
+ int link_rate, uint8_t lane_count)
+{
+ int common_rates[DP_MAX_SUPPORTED_RATES] = {};
+ int common_len;
+ int link_rate_index = -1;
+
+ common_len = intel_dp_common_rates(intel_dp, common_rates);
+ link_rate_index = intel_dp_link_rate_index(intel_dp,
+ common_rates,
+ link_rate);
+ if (link_rate_index > 0) {
+ intel_dp->fallback_link_rate_index = link_rate_index - 1;
+ intel_dp->fallback_link_rate = common_rates[intel_dp->fallback_link_rate_index];
+ intel_dp->fallback_lane_count = intel_dp_max_lane_count(intel_dp);
+ } else if (lane_count > 1) {
+ intel_dp->fallback_link_rate_index = common_len - 1;
+ intel_dp->fallback_link_rate = common_rates[intel_dp->fallback_link_rate_index];
+ intel_dp->fallback_lane_count = lane_count >> 1;
+ } else {
+ DRM_ERROR("Link Training Unsuccessful\n");
+ return -1;
+ }
+
+ return 0;
+}
+
static enum drm_mode_status
intel_dp_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 856dd41..4a49a2d 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -888,6 +888,10 @@ struct intel_dp {
uint32_t DP;
int link_rate;
uint8_t lane_count;
+ int fallback_link_rate;
+ uint8_t fallback_lane_count;
+ int fallback_link_rate_index;
+ bool link_train_failed;
uint8_t sink_count;
bool link_mst;
bool has_audio;
@@ -1386,6 +1390,8 @@ int intel_dp_set_link_status_property(struct drm_connector *connector,
void intel_dp_set_link_params(struct intel_dp *intel_dp,
int link_rate, uint8_t lane_count,
bool link_mst);
+int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
+ int link_rate, uint8_t lane_count);
void intel_dp_start_link_train(struct intel_dp *intel_dp);
void intel_dp_stop_link_train(struct intel_dp *intel_dp);
void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 31+ messages in thread
end of thread, other threads:[~2016-11-19 2:59 UTC | newest]
Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-15 3:13 [PATCH 0/5] Handle link training failure during modeset Manasi Navare
2016-11-15 3:13 ` [PATCH 1/5] drm: Add a new connector property for link status Manasi Navare
2016-11-15 3:13 ` [PATCH 2/5] drm: Set DRM connector link status property Manasi Navare
2016-11-15 3:23 ` Manasi Navare
2016-11-15 7:50 ` Daniel Vetter
2016-11-15 7:49 ` [Intel-gfx] " Daniel Vetter
2016-11-15 23:56 ` Manasi Navare
2016-11-16 7:35 ` [Intel-gfx] " Daniel Vetter
2016-11-15 7:53 ` Daniel Vetter
2016-11-16 1:13 ` Manasi Navare
2016-11-16 7:29 ` Daniel Vetter
2016-11-16 1:58 ` [PATCH v2 " Manasi Navare
2016-11-15 3:13 ` [PATCH 3/5] drm/i915: Update CRTC state if connector link status property changed Manasi Navare
2016-11-15 3:13 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
2016-11-16 17:32 ` Manasi Navare
2016-11-17 12:58 ` Jani Nikula
2016-11-17 19:44 ` Manasi Navare
2016-11-15 3:13 ` [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure Manasi Navare
2016-11-16 17:34 ` Manasi Navare
2016-11-17 12:49 ` Jani Nikula
2016-11-17 19:55 ` Manasi Navare
2016-11-15 4:24 ` ✓ Fi.CI.BAT: success for Handle Link Training Failure during modeset (rev2) Patchwork
2016-11-17 12:29 ` [PATCH 0/5] Handle link training failure during modeset Jani Nikula
2016-11-17 19:48 ` Manasi Navare
-- strict thread matches above, loose matches on Subject: below --
2016-11-19 2:58 [PATCH 0/5] Clean series for Link training failure handling Manasi Navare
2016-11-19 2:59 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
2016-11-18 7:29 [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure Manasi Navare
2016-11-18 7:13 [PATCH 0/5] Link Training failure handling during modeset Manasi Navare
2016-11-18 7:13 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
2016-11-18 7:29 ` Manasi Navare
2016-11-18 13:22 ` Jani Nikula
2016-11-18 15:39 ` Manasi Navare
2016-11-19 2:09 ` Manasi Navare
2016-11-10 4:42 [PATCH 0/5] Handle Link Training Failure during modeset Manasi Navare
2016-11-10 4:42 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
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.