[Intel-gfx] [PATCH 39/49] drm/i915/chv: use vlv_PLL_is_optimal in chv_find_best_dpll
Jesse Barnes
jbarnes at virtuousgeek.org
Thu Mar 19 13:56:35 PDT 2015
On 03/19/2015 01:55 PM, Imre Deak wrote:
> On Thu, 2015-03-19 at 13:34 -0700, Jesse Barnes wrote:
>> On 03/17/2015 02:40 AM, Imre Deak wrote:
>>> Prepare chv_find_best_dpll to be used for BXT too, where we want to
>>> consider the error between target and calculated frequency too when
>>> choosing a better PLL configuration.
>>>
>>> No functional change.
>>>
>>> Signed-off-by: Imre Deak <imre.deak at intel.com>
>>> ---
>>> drivers/gpu/drm/i915/intel_display.c | 26 ++++++++++++++++++++------
>>> 1 file changed, 20 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>>> index 5874512..9ca84a2 100644
>>> --- a/drivers/gpu/drm/i915/intel_display.c
>>> +++ b/drivers/gpu/drm/i915/intel_display.c
>>> @@ -786,6 +786,16 @@ static bool vlv_PLL_is_optimal(struct drm_device *dev, int target_freq,
>>> unsigned int best_error_ppm,
>>> unsigned int *error_ppm)
>>> {
>>> + /*
>>> + * For CHV ignore the error and consider only the P value.
>>> + * Prefer a bigger P value based on HW requirements.
>>> + */
>>> + if (IS_CHERRYVIEW(dev)) {
>>> + *error_ppm = 0;
>>> +
>>> + return calculated_clock->p > best_clock->p;
>>> + }
>>> +
>>> if (WARN_ON_ONCE(!target_freq))
>>> return false;
>>>
>>> @@ -864,11 +874,13 @@ chv_find_best_dpll(const intel_limit_t *limit, struct intel_crtc *crtc,
>>> intel_clock_t *best_clock)
>>> {
>>> struct drm_device *dev = crtc->base.dev;
>>> + unsigned int best_error_ppm;
>>> intel_clock_t clock;
>>> uint64_t m2;
>>> int found = false;
>>>
>>> memset(best_clock, 0, sizeof(*best_clock));
>>> + best_error_ppm = 1000000;
>>>
>>> /*
>>> * Based on hardware doc, the n always set to 1, and m1 always
>>> @@ -882,6 +894,7 @@ chv_find_best_dpll(const intel_limit_t *limit, struct intel_crtc *crtc,
>>> for (clock.p2 = limit->p2.p2_fast;
>>> clock.p2 >= limit->p2.p2_slow;
>>> clock.p2 -= clock.p2 > 10 ? 2 : 1) {
>>> + unsigned int error_ppm;
>>>
>>> clock.p = clock.p1 * clock.p2;
>>>
>>> @@ -898,12 +911,13 @@ chv_find_best_dpll(const intel_limit_t *limit, struct intel_crtc *crtc,
>>> if (!intel_PLL_is_valid(dev, limit, &clock))
>>> continue;
>>>
>>> - /* based on hardware requirement, prefer bigger p
>>> - */
>>> - if (clock.p > best_clock->p) {
>>> - *best_clock = clock;
>>> - found = true;
>>> - }
>>> + if (!vlv_PLL_is_optimal(dev, target, &clock, best_clock,
>>> + best_error_ppm, &error_ppm))
>>> + continue;
>>> +
>>> + *best_clock = clock;
>>> + best_error_ppm = error_ppm;
>>> + found = true;
>>> }
>>> }
>>>
>>>
>>
>> Looking at it again, maybe vlv_PLL_is_better() might be a better name.
>
> Ok, will change it.
>
>> Also, could you just make the ppm variable a scratch one and ignore it?
>> It just gets set to 0 no matter what, right?
>
> For CHV yes. But the next patch takes the same function into use in BXT
> too, where error_ppm will be set to the actual error, the same way as on
> VLV.
Oh right it's a patch *series*. Ignore the noise. :)
The rename is optional too; I just had to think about it when I saw
>>> + return calculated_clock->p > best_clock->p;
since in that case we're really checking whether the new calculated p
value is better (higher) than the last one. The _is_optimal() name made
me think it should be >= or something. But it's not a big deal.
Thanks,
Jesse
More information about the Intel-gfx
mailing list