* [PATCH 0/5] Clean series for Link training failure handling
@ 2016-11-19 2:58 Manasi Navare
2016-11-19 2:58 ` [PATCH 1/5] drm: Add a new connector property for link status Manasi Navare
` (4 more replies)
0 siblings, 5 replies; 17+ 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] 17+ messages in thread* [PATCH 1/5] drm: Add a new connector property for link status
2016-11-19 2:58 [PATCH 0/5] Clean series for Link training failure handling Manasi Navare
@ 2016-11-19 2:58 ` Manasi Navare
2016-11-19 2:58 ` [PATCH 2/5] drm: Set DRM connector link status property Manasi Navare
` (3 subsequent siblings)
4 siblings, 0 replies; 17+ messages in thread
From: Manasi Navare @ 2016-11-19 2:58 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Manasi Navare, Daniel Vetter
At the time userspace does setcrtc, we've already promised the mode
would work. The promise is based on the theoretical capabilities of the
link, but it's possible we can't reach this in practice. The DP spec
describes how the link should be reduced, but we can't reduce the link
below the requirements of the mode. Black screen follows.
One idea would be to have setcrtc return a failure. However, it
already should not fail as the atomic checks have passed. It would also
conflict with the idea of making setcrtc asynchronous in the future,
returning before the actual mode setting and link training.
Another idea is to train the link "upfront" at hotplug time, before
pruning the mode list, so that we can do the pruning based on practical
not theoretical capabilities. However, the changes for link training are
pretty drastic, all for the sake of error handling and DP compliance,
when the most common happy day scenario is the current approach of link
training at mode setting time, using the optimal parameters for the
mode. It is also not certain all hardware could do this without the pipe
on; not even all our hardware can do this. Some of this can be solved,
but not trivially.
Both of the above ideas also fail to address link degradation *during*
operation.
The solution is to add a new "link-status" connector property in order
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.
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 GET_CONNECTOR IOCTL, and try again. If the theoretical capabilities of
the link can't be reached, the mode list is trimmed based on that.
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.
v5:
* Added kernel doc for connector standard properties (Daniel Vetter)
v4:
* Rebase on drm-nightly
* Add a detailed commit message (Jani Nikula)
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 | 28 ++++++++++++++++++++++++++--
include/drm/drm_connector.h | 7 ++++++-
include/drm/drm_mode_config.h | 5 +++++
include/uapi/drm/drm_mode.h | 4 ++++
4 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 5a45262..cfb5cf7 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
@@ -616,7 +626,7 @@ int drm_display_info_set_bus_formats(struct drm_display_info *info,
* path property the MST manager created. Userspace cannot change this
* property.
* TILE:
- * Connector tile group property to indicate how a set of DRM connector
+ * Connector tile group property to indicate how a set of DRM connector
* compose together into one logical screen. This is used by both high-res
* external screens (often only using a single cable, but exposing multiple
* DP MST sinks), or high-res integrated panels (like dual-link DSI) which
@@ -625,7 +635,14 @@ int drm_display_info_set_bus_formats(struct drm_display_info *info,
* tiling and virtualize both &drm_crtc and &drm_plane if needed. Drivers
* should update this value using drm_mode_connector_set_tile_property().
* Userspace cannot change this property.
- *
+ * link-status:
+ * Connector link-status property to indicate the status of link during
+ * the modeset. The default value of link-status is "GOOD". If something
+ * fails during modeset, the kernel driver can set this to "BAD", prune
+ * the mode list based on new link parameters and send a hotplug uevent
+ * to notify userspace to re-check the valid modes through GET_CONNECTOR
+ * IOCTL and redo a modeset. Drivers should update this value using
+ * drm_mode_connector_set_link_status_property().
* Connectors also have one standardized atomic property:
*
* CRTC_ID:
@@ -666,6 +683,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 34f9741..ab564e6 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_mode_config.h b/include/drm/drm_mode_config.h
index bf9991b..86faee4 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -431,6 +431,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 728790b..309c478 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -123,6 +123,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] 17+ messages in thread* [PATCH 2/5] drm: Set DRM connector link status property
2016-11-19 2:58 [PATCH 0/5] Clean series for Link training failure handling Manasi Navare
2016-11-19 2:58 ` [PATCH 1/5] drm: Add a new connector property for link status Manasi Navare
@ 2016-11-19 2:58 ` Manasi Navare
2016-11-19 8:25 ` Chris Wilson
2016-11-19 2:59 ` [PATCH 3/5] drm/i915: Update CRTC state if connector link status property changed Manasi Navare
` (2 subsequent siblings)
4 siblings, 1 reply; 17+ messages in thread
From: Manasi Navare @ 2016-11-19 2: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.
v3:
* Updated kernel doc even more (Daniel Vetter)
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 | 37 +++++++++++++++++++++++++++++++++++++
include/drm/drm_connector.h | 2 ++
2 files changed, 39 insertions(+)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index cfb5cf7..b5ca70f 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1019,6 +1019,43 @@ 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
+ * set this link status property to "BAD" and prune the mode list based on new
+ * information. 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.
+ * 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
+ * fails and userspace must select a different display mode.
+ * 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 ab564e6..f47b345 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);
/**
* struct drm_tile_group - Tile group metadata
--
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] 17+ messages in thread* Re: [PATCH 2/5] drm: Set DRM connector link status property
2016-11-19 2:58 ` [PATCH 2/5] drm: Set DRM connector link status property Manasi Navare
@ 2016-11-19 8:25 ` Chris Wilson
0 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2016-11-19 8:25 UTC (permalink / raw)
To: Manasi Navare; +Cc: Daniel Vetter, intel-gfx, dri-devel
On Fri, Nov 18, 2016 at 06:58:59PM -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.
>
> v3:
> * Updated kernel doc even more (Daniel Vetter)
> 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 | 37 +++++++++++++++++++++++++++++++++++++
> include/drm/drm_connector.h | 2 ++
> 2 files changed, 39 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index cfb5cf7..b5ca70f 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -1019,6 +1019,43 @@ 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
> + * set this link status property to "BAD" and prune the mode list based on new
> + * information. 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.
> + * 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
> + * fails and userspace must select a different display mode.
> + * 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);
The comment is just duplicating the code; (i++; /* post-increment i */).
Comments are about why the code exists.
Common practice is to leave a blank line between function preconditions
and the body of actual code.
For example it might be worth explaining why link_status is duplicated
on the connector and in its property (i.e. that is near impossible to
retrieve the value from the property).
> + 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);
--
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 3/5] drm/i915: Update CRTC state if connector link status property changed
2016-11-19 2:58 [PATCH 0/5] Clean series for Link training failure handling Manasi Navare
2016-11-19 2:58 ` [PATCH 1/5] drm: Add a new connector property for link status Manasi Navare
2016-11-19 2:58 ` [PATCH 2/5] drm: Set DRM connector link status property Manasi Navare
@ 2016-11-19 2:59 ` Manasi Navare
2016-11-19 2:59 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
2016-11-19 2:59 ` [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure Manasi Navare
4 siblings, 0 replies; 17+ messages in thread
From: Manasi Navare @ 2016-11-19 2:59 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Manasi Navare, 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 0b16587..2125fd1 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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 17+ 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
` (2 preceding siblings ...)
2016-11-19 2:59 ` [PATCH 3/5] drm/i915: Update CRTC state if connector link status property changed Manasi Navare
@ 2016-11-19 2:59 ` Manasi Navare
2016-11-19 2:59 ` [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure Manasi Navare
4 siblings, 0 replies; 17+ 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] 17+ messages in thread* [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure
2016-11-19 2:58 [PATCH 0/5] Clean series for Link training failure handling Manasi Navare
` (3 preceding siblings ...)
2016-11-19 2:59 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
@ 2016-11-19 2:59 ` Manasi Navare
4 siblings, 0 replies; 17+ 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 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.
v8:
* Set link_status to BAD first and then call mode_valid (Jani Nikula)
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 3a72014..747a2ba 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;
+ DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id,
+ connector->name);
+
+ /* Grab the locks before changing connector property*/
+ mutex_lock(&connector->dev->mode_config.mutex);
+ /* 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);
+ 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);
+ 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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ messages in thread
* [PATCH 0/5] Handle link training failure during modeset
@ 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
0 siblings, 1 reply; 17+ 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] 17+ 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
@ 2016-11-15 3:13 ` Manasi Navare
2016-11-16 17:32 ` Manasi Navare
2016-11-17 12:58 ` Jani Nikula
0 siblings, 2 replies; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ messages in thread
end of thread, other threads:[~2016-11-19 8:25 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-19 2:58 [PATCH 0/5] Clean series for Link training failure handling Manasi Navare
2016-11-19 2:58 ` [PATCH 1/5] drm: Add a new connector property for link status Manasi Navare
2016-11-19 2:58 ` [PATCH 2/5] drm: Set DRM connector link status property Manasi Navare
2016-11-19 8:25 ` Chris Wilson
2016-11-19 2:59 ` [PATCH 3/5] drm/i915: Update CRTC state if connector link status property changed Manasi Navare
2016-11-19 2:59 ` [PATCH 4/5] drm/i915: Find fallback link rate/lane count Manasi Navare
2016-11-19 2:59 ` [PATCH 5/5] drm/i915: Implement Link Rate fallback on Link training failure Manasi Navare
-- strict thread matches above, loose matches on Subject: below --
2016-11-18 7:29 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-15 3:13 [PATCH 0/5] Handle link training failure during modeset 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-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).