From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v1½ 05/13] drm/i915/dp: generate and cache sink rate array for all DP, not just eDP 1.4
Date: Fri, 27 Jan 2017 22:00:46 +0200 [thread overview]
Message-ID: <20170127200046.GL31595@intel.com> (raw)
In-Reply-To: <87vat0xouy.fsf@intel.com>
On Fri, Jan 27, 2017 at 09:52:05PM +0200, Jani Nikula wrote:
> On Fri, 27 Jan 2017, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> > On Thu, Jan 26, 2017 at 09:44:19PM +0200, Jani Nikula wrote:
> >> There is some conflation related to sink rates, making this change more
> >> complicated than it would otherwise have to be. There are three changes
> >> here that are rather difficult to split up:
> >>
> >> 1) Use the intel_dp->sink_rates array for all DP, not just eDP 1.4. We
> >> initialize it from DPCD on eDP 1.4 like before, but generate it based
> >> on DP_MAX_LINK_RATE on others. This reduces code complexity when we
> >> need to use the sink rates; they are all always in the sink_rates
> >> array.
> >>
> >> 2) Update the sink rate array whenever we read DPCD, and use the
> >> information from there. This increases code readability when we need
> >> the sink rates.
> >>
> >> 3) Disentangle fallback rate limiting from sink rates. In the code, the
> >> max rate is a dynamic property of the *link*, not of the *sink*. Do
> >> the limiting after intersecting the source and sink rates, which are
> >> static properties of the devices.
> >>
> >> This paves the way for follow-up refactoring that I've refrained from
> >> doing here to keep this change as simple as it possibly can.
> >>
> >> Cc: Manasi Navare <manasi.d.navare@intel.com>
> >> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> >> ---
> >> drivers/gpu/drm/i915/intel_dp.c | 76 ++++++++++++++++++---------
> >> drivers/gpu/drm/i915/intel_dp_link_training.c | 3 +-
> >> drivers/gpu/drm/i915/intel_drv.h | 4 +-
> >> 3 files changed, 55 insertions(+), 28 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> >> index cc2523363c8d..d13ce6746542 100644
> >> --- a/drivers/gpu/drm/i915/intel_dp.c
> >> +++ b/drivers/gpu/drm/i915/intel_dp.c
> >> @@ -133,6 +133,34 @@ static void vlv_steal_power_sequencer(struct drm_device *dev,
> >> enum pipe pipe);
> >> static void intel_dp_unset_edid(struct intel_dp *intel_dp);
> >>
> >> +static int intel_dp_num_rates(u8 link_bw_code)
> >> +{
> >> + switch (link_bw_code) {
> >> + default:
> >> + WARN(1, "invalid max DP link bw val %x, using 1.62Gbps\n",
> >> + link_bw_code);
> >> + case DP_LINK_BW_1_62:
> >> + return 1;
> >> + case DP_LINK_BW_2_7:
> >> + return 2;
> >> + case DP_LINK_BW_5_4:
> >> + return 3;
> >> + }
> >> +}
> >> +
> >> +/* update sink rates from dpcd */
> >> +static void intel_dp_set_sink_rates(struct intel_dp *intel_dp)
> >> +{
> >> + int i, num_rates;
> >> +
> >> + num_rates = intel_dp_num_rates(intel_dp->dpcd[DP_MAX_LINK_RATE]);
> >> +
> >> + for (i = 0; i < num_rates; i++)
> >> + intel_dp->sink_rates[i] = default_rates[i];
> >> +
> >> + intel_dp->num_sink_rates = num_rates;
> >> +}
> >> +
> >> static int
> >> intel_dp_max_link_bw(struct intel_dp *intel_dp)
> >> {
> >> @@ -205,19 +233,6 @@ intel_dp_downstream_max_dotclock(struct intel_dp *intel_dp)
> >> return max_dotclk;
> >> }
> >>
> >> -static int
> >> -intel_dp_sink_rates(struct intel_dp *intel_dp, const int **sink_rates)
> >> -{
> >> - if (intel_dp->num_sink_rates) {
> >> - *sink_rates = intel_dp->sink_rates;
> >> - return intel_dp->num_sink_rates;
> >> - }
> >> -
> >> - *sink_rates = default_rates;
> >> -
> >> - return (intel_dp->max_sink_link_bw >> 3) + 1;
> >> -}
> >> -
> >> static void
> >> intel_dp_set_source_rates(struct intel_dp *intel_dp)
> >> {
> >> @@ -285,15 +300,22 @@ static int intel_dp_find_rate(const int *rates, int len, int rate)
> >> static int intel_dp_common_rates(struct intel_dp *intel_dp,
> >> int *common_rates)
> >> {
> >> - const int *sink_rates;
> >> - int sink_len;
> >> + int max_rate = drm_dp_bw_code_to_link_rate(intel_dp->max_sink_link_bw);
> >> + int i, common_len;
> >>
> >> - sink_len = intel_dp_sink_rates(intel_dp, &sink_rates);
> >> + common_len = intersect_rates(intel_dp->source_rates,
> >> + intel_dp->num_source_rates,
> >> + intel_dp->sink_rates,
> >> + intel_dp->num_sink_rates,
> >> + common_rates);
> >>
> >> - return intersect_rates(intel_dp->source_rates,
> >> - intel_dp->num_source_rates,
> >> - sink_rates, sink_len,
> >> - common_rates);
> >> + /* Limit results by potentially reduced max rate */
> >> + for (i = 0; i < common_len; i++) {
> >> + if (common_rates[common_len - i - 1] <= max_rate)
> >> + return common_len - i;
> >> + }
> >> +
> >> + return 0;
> >> }
> >>
> >> static int intel_dp_link_rate_index(struct intel_dp *intel_dp,
> >> @@ -1501,8 +1523,7 @@ static void snprintf_int_array(char *str, size_t len,
> >>
> >> static void intel_dp_print_rates(struct intel_dp *intel_dp)
> >> {
> >> - const int *sink_rates;
> >> - int sink_len, common_len;
> >> + int common_len;
> >> int common_rates[DP_MAX_SUPPORTED_RATES];
> >> char str[128]; /* FIXME: too big for stack? */
> >>
> >> @@ -1513,8 +1534,8 @@ static void intel_dp_print_rates(struct intel_dp *intel_dp)
> >> intel_dp->source_rates, intel_dp->num_source_rates);
> >> DRM_DEBUG_KMS("source rates: %s\n", str);
> >>
> >> - sink_len = intel_dp_sink_rates(intel_dp, &sink_rates);
> >> - snprintf_int_array(str, sizeof(str), sink_rates, sink_len);
> >> + snprintf_int_array(str, sizeof(str),
> >> + intel_dp->sink_rates, intel_dp->num_sink_rates);
> >> DRM_DEBUG_KMS("sink rates: %s\n", str);
> >>
> >> common_len = intel_dp_common_rates(intel_dp, common_rates);
> >> @@ -1580,7 +1601,8 @@ int intel_dp_rate_select(struct intel_dp *intel_dp, int rate)
> >> void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock,
> >> uint8_t *link_bw, uint8_t *rate_select)
> >> {
> >> - if (intel_dp->num_sink_rates) {
> >> + /* eDP 1.4 rate select method. */
> >> + if (is_edp(intel_dp) && intel_dp->edp_dpcd[0] >= 0x03) {
> >
> > I was convinced that this wasn't a mandatory feature, but the spec does
> > seem to say "The table must contain at least one non-zero value at the
> > first (lowest DPCD address) location."
> >
> > But given historical evidence I'm still 99% convinced we'll eventually
> > run into some panel somewhere that does this wrong, so I don't really
> > like this idea.
>
> Then I think this should be fixed in intel_edp_init_dpcd() by a)
> checking that there is at least one non-zero value, falling back to
> intel_dp_set_source_rates() if not, and b) setting a new
> intel_dp->use_rate_selet field at that time, which will be used instead
> of (is_edp(intel_dp) && intel_dp->edp_dpcd[0] >= 0x03). Sound good?
Yep. That should preserve the current behaviour.
--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-01-27 20:00 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-26 19:44 [PATCH v1½ 00/13] drm/i915/dp: link rate and lane count refactoring Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 01/13] drm/i915/dp: use known correct array size in rate_to_index Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 02/13] drm/i915/dp: return errors from rate_to_index() Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 03/13] drm/i915/dp: rename rate_to_index() to intel_dp_find_rate() and reuse Jani Nikula
2017-02-01 21:46 ` Pandiyan, Dhinakaran
2017-02-02 8:44 ` Jani Nikula
2017-02-07 18:38 ` Pandiyan, Dhinakaran
2017-01-26 19:44 ` [PATCH v1½ 04/13] drm/i915/dp: cache source rates at init Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 05/13] drm/i915/dp: generate and cache sink rate array for all DP, not just eDP 1.4 Jani Nikula
2017-01-27 17:28 ` Ville Syrjälä
2017-01-27 19:52 ` Jani Nikula
2017-01-27 20:00 ` Ville Syrjälä [this message]
2017-01-28 10:16 ` [PATCH v2] " Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 06/13] drm/i915/dp: use the sink rates array for max sink rates Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 07/13] drm/i915/dp: cache common rates with " Jani Nikula
2017-02-01 22:08 ` Pandiyan, Dhinakaran
2017-02-02 8:38 ` Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 08/13] drm/i915/dp: do not limit rate seek when not needed Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 09/13] drm/i915/dp: don't call the link parameters sink parameters Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 10/13] drm/i915/dp: add functions for max common link rate and lane count Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 11/13] drm/i915/mst: use max link not sink " Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 12/13] drm/i915/dp: localize link rate index variable more Jani Nikula
2017-02-02 2:54 ` Manasi Navare
2017-02-02 8:42 ` Jani Nikula
2017-02-02 17:29 ` Manasi Navare
2017-02-03 14:11 ` Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 13/13] drm/i915/dp: use readb and writeb calls for single byte DPCD access Jani Nikula
2017-02-01 19:04 ` [PATCH v1½ 00/13] drm/i915/dp: link rate and lane count refactoring Pandiyan, Dhinakaran
2017-02-01 19:40 ` Manasi Navare
2017-02-02 19:01 ` Manasi Navare
2017-02-03 14:16 ` Jani Nikula
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170127200046.GL31595@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.