drm/i915/display: Do both crawl and squash when changing cdclk
Subsystems (3)
PATCH 1/2 drm/i915/display: Do both crawl and squash when changing cdclk
From: Ville Syrjälä <[email protected]>
For MTL, changing cdclk from between certain frequencies has both squash and crawl. Use the current cdclk config and the new(desired) cdclk config to construtc a mid cdclk config. Set the cdclk twice:
- Current cdclk -> mid cdclk
- mid cdclk -> desired cdclk
v2: Add check in intel_modeset_calc_cdclk() to avoid cdclk change via modeset for platforms that support squash_crawl sequences(Ville)
v3: Add checks for:
- scenario where only slow clock is used and
cdclk is actually 0 (bringing up display).
- PLLs are on before looking up the waveform.
- Squash and crawl capability checks.(Ville)
v4: Rebase
- Move checks to be more consistent (Ville)
- Add comments (Bala)
v5:
- Further small changes. Move checks around.
- Make if-else better looking (Ville)
--- drivers/gpu/drm/i915/display/intel_cdclk.c | 156 +++++++++++++++++---- 1 file changed, 128 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +128 -28
@@ -1716,37 +1716,74 @@ static void dg2_cdclk_squash_program(struct drm_i915_private *i915,intel_de_write (i915,CDCLK_SQUASH_CTL , squash_ctl); } -static void bxt_set_cdclk (struct drm_i915_private *dev_priv, -const struct intel_cdclk_config *cdclk_config, -enum pipe pipe) +static int cdclk_squash_divider (u16 waveform) +{ +return hweight16 (waveform ?:0xffff ); +} + +static bool cdclk_crawl_and_squash (struct drm_i915_private *i915, +const struct intel_cdclk_config *old_cdclk_config, +const struct intel_cdclk_config *new_cdclk_config, +struct intel_cdclk_config *mid_cdclk_config) +{ +u16 old_waveform, new_waveform, mid_waveform; +int size =16 ; +int div =2 ; + +/* Return if both Squash and Crawl are not present */ +if (!HAS_CDCLK_CRAWL (i915) || !HAS_CDCLK_SQUASH (i915)) +return false; + + old_waveform =cdclk_squash_waveform (i915, old_cdclk_config->cdclk); + new_waveform =cdclk_squash_waveform (i915, new_cdclk_config->cdclk); + +/* Return if Squash only or Crawl only is the desired action */ +if (old_cdclk_config->vco <=0 || new_cdclk_config->vco <=0 || + old_cdclk_config->vco == new_cdclk_config->vco || + old_waveform == new_waveform) +return false; + + *mid_cdclk_config = *new_cdclk_config; + +/* Populate the mid_cdclk_config accordingly. +* - If moving to a higher cdclk, the desired action is squashing. +* The mid cdclk config should have the new (squash) waveform. +* - If moving to a lower cdclk, the desired action is crawling. +* The mid cdclk config should have the new vco. +*/ + +if (cdclk_squash_divider (new_waveform) >cdclk_squash_divider (old_waveform)) { + mid_cdclk_config->vco = old_cdclk_config->vco; + mid_waveform = new_waveform; + }else { + mid_cdclk_config->vco = new_cdclk_config->vco; + mid_waveform = old_waveform; + } + + mid_cdclk_config->cdclk =DIV_ROUND_CLOSEST (cdclk_squash_divider (mid_waveform) * + mid_cdclk_config->vco, size * div); + +/* make sure the mid clock came out sane */ + +drm_WARN_ON (&i915->drm, mid_cdclk_config->cdclk < +min (old_cdclk_config->cdclk, new_cdclk_config->cdclk)); +drm_WARN_ON (&i915->drm, mid_cdclk_config->cdclk > + i915->display.cdclk.max_cdclk_freq); +drm_WARN_ON (&i915->drm,cdclk_squash_waveform (i915, mid_cdclk_config->cdclk) != + mid_waveform); + +return true; +} + +static void _bxt_set_cdclk (struct drm_i915_private *dev_priv, +const struct intel_cdclk_config *cdclk_config, +enum pipe pipe) {int cdclk = cdclk_config->cdclk;int vco = cdclk_config->vco;u32 val;u16 waveform;int clock; -int ret; - -/* Inform power controller of upcoming frequency change. */ -if (DISPLAY_VER (dev_priv) >=11 ) - ret =skl_pcode_request (&dev_priv->uncore,SKL_PCODE_CDCLK_CONTROL , -SKL_CDCLK_PREPARE_FOR_CHANGE , -SKL_CDCLK_READY_FOR_CHANGE , -SKL_CDCLK_READY_FOR_CHANGE ,3 ); -else -/* -* BSpec requires us to wait up to 150usec, but that leads to -* timeouts; the 2ms used here is based on experiment. -*/ - ret =snb_pcode_write_timeout (&dev_priv->uncore, -HSW_PCODE_DE_WRITE_FREQ_REQ , -0x80000000 ,150 ,2 ); -if (ret) { -drm_err (&dev_priv->drm, -"Failed to inform PCU about cdclk change (err %d, freq %d)\n" , - ret, cdclk); -return ; - }if (HAS_CDCLK_CRAWL (dev_priv) && dev_priv->display.cdclk.hw.vco >0 && vco >0 ) {if (dev_priv->display.cdclk.hw.vco != vco)
@@ -1781,6 +1818,44 @@ static void bxt_set_cdclk(struct drm_i915_private *dev_priv,if (pipe !=INVALID_PIPE )intel_crtc_wait_for_next_vblank (intel_crtc_for_pipe (dev_priv, pipe)); +} + +static void bxt_set_cdclk (struct drm_i915_private *dev_priv, +const struct intel_cdclk_config *cdclk_config, +enum pipe pipe) +{ +struct intel_cdclk_config mid_cdclk_config; +int cdclk = cdclk_config->cdclk; +int ret; + +/* Inform power controller of upcoming frequency change. */ +if (DISPLAY_VER (dev_priv) >=11 ) + ret =skl_pcode_request (&dev_priv->uncore,SKL_PCODE_CDCLK_CONTROL , +SKL_CDCLK_PREPARE_FOR_CHANGE , +SKL_CDCLK_READY_FOR_CHANGE , +SKL_CDCLK_READY_FOR_CHANGE ,3 ); +else +/* +* BSpec requires us to wait up to 150usec, but that leads to +* timeouts; the 2ms used here is based on experiment. +*/ + ret =snb_pcode_write_timeout (&dev_priv->uncore, +HSW_PCODE_DE_WRITE_FREQ_REQ , +0x80000000 ,150 ,2 ); +if (ret) { +drm_err (&dev_priv->drm, +"Failed to inform PCU about cdclk change (err %d, freq %d)\n" , + ret, cdclk); +return ; + } + +if (cdclk_crawl_and_squash (dev_priv, &dev_priv->display.cdclk.hw, + cdclk_config, &mid_cdclk_config)) { +_bxt_set_cdclk (dev_priv, &mid_cdclk_config, pipe); +_bxt_set_cdclk (dev_priv, cdclk_config, pipe); + }else { +_bxt_set_cdclk (dev_priv, cdclk_config, pipe); + }if (DISPLAY_VER (dev_priv) >=11 ) { ret = snb_pcode_write(&dev_priv->uncore, SKL_PCODE_CDCLK_CONTROL,
@@ -1953,6 +2028,26 @@ void intel_cdclk_uninit_hw(struct drm_i915_private *i915)skl_cdclk_uninit_hw (i915); } +static bool intel_cdclk_can_crawl_and_squash (struct drm_i915_private *i915, +const struct intel_cdclk_config *a, +const struct intel_cdclk_config *b) +{ +u16 old_waveform; +u16 new_waveform; + +if (a->vco ==0 || b->vco ==0 ) +return false; + +if (!HAS_CDCLK_CRAWL (i915) && !HAS_CDCLK_SQUASH (i915)) +return false; + + old_waveform =cdclk_squash_waveform (i915, a->cdclk); + new_waveform =cdclk_squash_waveform (i915, b->cdclk); + +return a->vco != b->vco && + old_waveform != new_waveform; +} +static bool intel_cdclk_can_crawl (struct drm_i915_private *dev_priv,const struct intel_cdclk_config *a,const struct intel_cdclk_config *b)
@@ -2759,9 +2854,14 @@ int intel_modeset_calc_cdclk(struct intel_atomic_state *state) pipe =INVALID_PIPE ; } -if (intel_cdclk_can_squash (dev_priv, - &old_cdclk_state->actual, - &new_cdclk_state->actual)) { +if (intel_cdclk_can_crawl_and_squash (dev_priv, + &old_cdclk_state->actual, + &new_cdclk_state->actual)) { +drm_dbg_kms (&dev_priv->drm, +"Can change cdclk via crawling and squashing\n" ); + }else if (intel_cdclk_can_squash (dev_priv, + &old_cdclk_state->actual, + &new_cdclk_state->actual)) {drm_dbg_kms (&dev_priv->drm,"Can change cdclk via squashing\n" ); } else if (intel_cdclk_can_crawl(dev_priv,
Signature · 1 line
2.25.1
PATCH 2/2 drm/i915/display: Add CDCLK Support for MTL
As per bSpec MTL has 38.4 MHz Reference clock.
Addin gthe cdclk tables and cdclk_funcs that MTL
will use.
v2: Revert to using bxt_get_cdclk()
BSpec: 65243
--- drivers/gpu/drm/i915/display/intel_cdclk.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +21 -1
@@ -1345,6 +1345,16 @@ static const struct intel_cdclk_vals dg2_cdclk_table[] = { {} }; +static const struct intel_cdclk_vals mtl_cdclk_table[] = { + { .refclk =38400 , .cdclk =172800 , .divider =2 , .ratio =16 , .waveform =0xad5a }, + { .refclk =38400 , .cdclk =192000 , .divider =2 , .ratio =16 , .waveform =0xb6b6 }, + { .refclk =38400 , .cdclk =307200 , .divider =2 , .ratio =16 , .waveform =0x0000 }, + { .refclk =38400 , .cdclk =480000 , .divider =2 , .ratio =25 , .waveform =0x0000 }, + { .refclk =38400 , .cdclk =556800 , .divider =2 , .ratio =29 , .waveform =0x0000 }, + { .refclk =38400 , .cdclk =652800 , .divider =2 , .ratio =34 , .waveform =0x0000 }, + {} +}; +static int bxt_calc_cdclk (struct drm_i915_private *dev_priv,int min_cdclk) {const struct intel_cdclk_vals *table = dev_priv->display.cdclk.table;
@@ -3159,6 +3169,13 @@ u32 intel_read_rawclk(struct drm_i915_private *dev_priv)return freq; } +static const struct intel_cdclk_funcs mtl_cdclk_funcs = { + .get_cdclk = bxt_get_cdclk, + .set_cdclk = bxt_set_cdclk, + .modeset_calc_cdclk = bxt_modeset_calc_cdclk, + .calc_voltage_level = tgl_calc_voltage_level, +}; +static const struct intel_cdclk_funcs tgl_cdclk_funcs = { .get_cdclk = bxt_get_cdclk, .set_cdclk = bxt_set_cdclk,
@@ -3294,7 +3311,10 @@ static const struct intel_cdclk_funcs i830_cdclk_funcs = {*/ void intel_init_cdclk_hooks (struct drm_i915_private *dev_priv) { -if (IS_DG2 (dev_priv)) { +if (IS_METEORLAKE (dev_priv)) { + dev_priv->display.funcs.cdclk = &mtl_cdclk_funcs; + dev_priv->display.cdclk.table = mtl_cdclk_table; + }else if (IS_DG2 (dev_priv)) { dev_priv->display.funcs.cdclk = &tgl_cdclk_funcs; dev_priv->display.cdclk.table = dg2_cdclk_table; }else if (IS_ALDERLAKE_P (dev_priv)) {
Signature · 1 line
2.25.1
Re: [Intel-gfx] [PATCH 2/2] drm/i915/display: Add CDCLK Support for MTL
See below
-----Original Message-----
From: Srivatsa, Anusha <[email protected]>
Sent: Friday, October 28, 2022 2:32 PM
To: [email protected]
Cc: Srivatsa, Anusha <[email protected]>; Taylor, Clinton A <[email protected]>
Subject: [PATCH 2/2] drm/i915/display: Add CDCLK Support for MTL
As per bSpec MTL has 38.4 MHz Reference clock. Addin gthe cdclk tables and cdclk_funcs that MTL will use.
Spelling issue here. With this fixed
-Clint
v2: Revert to using bxt_get_cdclk()
BSpec: 65243
--- drivers/gpu/drm/i915/display/intel_cdclk.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +10 -0
@@ -1345,6 +1345,16 @@ static const struct intel_cdclk_vals dg2_cdclk_table[] = { {} }; +static const struct intel_cdclk_vals mtl_cdclk_table[] = { + { .refclk =38400 , .cdclk =172800 , .divider =2 , .ratio =16 , .waveform =0xad5a }, + { .refclk =38400 , .cdclk =192000 , .divider =2 , .ratio =16 , .waveform =0xb6b6 }, + { .refclk =38400 , .cdclk =307200 , .divider =2 , .ratio =16 , .waveform =0x0000 }, + { .refclk =38400 , .cdclk =480000 , .divider =2 , .ratio =25 , .waveform =0x0000 }, + { .refclk =38400 , .cdclk =556800 , .divider =2 , .ratio =29 , .waveform =0x0000 }, + { .refclk =38400 , .cdclk =652800 , .divider =2 , .ratio =34 , .waveform =0x0000 }, + {} +}; +static int bxt_calc_cdclk (struct drm_i915_private *dev_priv,int min_cdclk) { const struct intel_cdclk_vals *table = dev_priv->display.cdclk.table; @@ -3159,6 +3169,13 @@ u32 intel_read_rawclk(struct drm_i915_private *dev_priv) return freq;
}
+static const struct intel_cdclk_funcs mtl_cdclk_funcs = {
+ .get_cdclk = bxt_get_cdclk,
+ .set_cdclk = bxt_set_cdclk,
+ .modeset_calc_cdclk = bxt_modeset_calc_cdclk,
+ .calc_voltage_level = tgl_calc_voltage_level, };
+
static const struct intel_cdclk_funcs tgl_cdclk_funcs = {
.get_cdclk = bxt_get_cdclk,
.set_cdclk = bxt_set_cdclk,
@@ -3294,7 +3311,10 @@ static const struct intel_cdclk_funcs i830_cdclk_funcs = {
*/
void intel_init_cdclk_hooks(struct drm_i915_private *dev_priv) {
- if (IS_DG2(dev_priv)) {
+ if (IS_METEORLAKE(dev_priv)) {
+ dev_priv->display.funcs.cdclk = &mtl_cdclk_funcs;
+ dev_priv->display.cdclk.table = mtl_cdclk_table;
+ } else if (IS_DG2(dev_priv)) {
dev_priv->display.funcs.cdclk = &tgl_cdclk_funcs; dev_priv->display.cdclk.table = dg2_cdclk_table;
} else if (IS_ALDERLAKE_P(dev_priv)) {
--
2.25.1
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [1/2] drm/i915/display: Do both crawl and squash when changing cdclk
In reply to Anusha Srivatsa== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/i915/display: Do both crawl and squash when changing cdclk
URL : https://patchwork.freedesktop.org/series/110275/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_12317 -> Patchwork_110275v1
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_110275v1 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_110275v1, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110275v1/index.html
Participating hosts (40 -> 39)
------------------------------
Additional (1): fi-pnv-d510
Missing (2): fi-ctg-p8600 fi-cfl-8700k
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_110275v1:
### CI changes ###
#### Possible regressions ####
* boot:
- fi-bxt-dsi: [PASS][1] -> [FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12317/fi-bxt-dsi/boot.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110275v1/fi-bxt-dsi/boot.html
### IGT changes ###
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.
* igt@i915_selftest@live@gt_mocs:
- {bat-rpls-1}: [PASS][3] -> [DMESG-FAIL][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12317/bat-rpls-1/igt@i915_selftest@live@gt_mocs.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110275v1/bat-rpls-1/igt@i915_selftest@live@gt_mocs.html
Known issues
------------
Here are the changes found in Patchwork_110275v1 that come from known issues:
### CI changes ###
#### Possible fixes ####
* boot:
- fi-ilk-650: [FAIL][5] ([i915#7350]) -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12317/fi-ilk-650/boot.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110275v1/fi-ilk-650/boot.html
### IGT changes ###
#### Issues hit ####
* igt@gem_close_race@basic-process:
- fi-icl-u2: [PASS][7] -> [DMESG-WARN][8] ([i915#4890])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12317/fi-icl-u2/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110275v1/fi-icl-u2/igt@[email protected]
* igt@gem_exec_suspend@basic-s3@smem:
- fi-bdw-5557u: [PASS][9] -> [INCOMPLETE][10] ([i915#146])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12317/fi-bdw-5557u/igt@gem_exec_suspend@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110275v1/fi-bdw-5557u/igt@gem_exec_suspend@[email protected]
* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-ilk-650: NOTRUN -> [SKIP][11] ([fdo#109271]) +19 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110275v1/fi-ilk-650/igt@[email protected]
* igt@kms_chamelium@hdmi-edid-read:
- fi-ilk-650: NOTRUN -> [SKIP][12] ([fdo#109271] / [fdo#111827]) +8 similar issues
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110275v1/fi-ilk-650/igt@[email protected]
* igt@kms_psr@primary_page_flip:
- fi-pnv-d510: NOTRUN -> [SKIP][13] ([fdo#109271]) +43 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110275v1/fi-pnv-d510/igt@kms_psr@primary_page_flip.html
#### Possible fixes ####
* igt@gem_exec_suspend@basic-s0@smem:
- {bat-adlm-1}: [DMESG-WARN][14] ([i915#2867]) -> [PASS][15]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12317/bat-adlm-1/igt@gem_exec_suspend@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110275v1/bat-adlm-1/igt@gem_exec_suspend@[email protected]
- {bat-rpls-2}: [DMESG-WARN][16] ([i915#6434]) -> [PASS][17]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12317/bat-rpls-2/igt@gem_exec_suspend@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110275v1/bat-rpls-2/igt@gem_exec_suspend@[email protected]
* igt@i915_selftest@live@migrate:
- {bat-dg2-11}: [DMESG-WARN][18] -> [PASS][19]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12317/bat-dg2-11/igt@i915_selftest@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110275v1/bat-dg2-11/igt@i915_selftest@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#146]: https://gitlab.freedesktop.org/drm/intel/issues/146
[i915#2867]: https://gitlab.freedesktop.org/drm/intel/issues/2867
[i915#4890]: https://gitlab.freedesktop.org/drm/intel/issues/4890
[i915#5537]: https://gitlab.freedesktop.org/drm/intel/issues/5537
[i915#6257]: https://gitlab.freedesktop.org/drm/intel/issues/6257
[i915#6434]: https://gitlab.freedesktop.org/drm/intel/issues/6434
[i915#7029]: https://gitlab.freedesktop.org/drm/intel/issues/7029
[i915#7346]: https://gitlab.freedesktop.org/drm/intel/issues/7346
[i915#7350]: https://gitlab.freedesktop.org/drm/intel/issues/7350
Build changes
-------------
* Linux: CI_DRM_12317 -> Patchwork_110275v1
CI-20190529: 20190529
CI_DRM_12317: 0f9cbc285f7d3d1860f7f903663933f33ff9ae25 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7029: c32cb1e614017f14274d335ac571383799e6c786 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_110275v1: 0f9cbc285f7d3d1860f7f903663933f33ff9ae25 @ git://anongit.freedesktop.org/gfx-ci/linux
### Linux commits
e54876f62707 drm/i915/display: Add CDCLK Support for MTL 5a48b0bcf2e9 drm/i915/display: Do both crawl and squash when changing cdclk
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110275v1/index.html
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: failure for series starting with [1/2] drm/i915/display: Do both crawl and squash when changing cdclk (rev2)
In reply to Anusha Srivatsa== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/i915/display: Do both crawl and squash when changing cdclk (rev2)
URL : https://patchwork.freedesktop.org/series/110275/
State : failure
== Summary ==
Error: patch https://patchwork.freedesktop.org/api/1.0/series/110275/revisions/2/mbox/ not applied
Applying: drm/i915/display: Do both crawl and squash when changing cdclk
Applying: drm/i915/display: Add CDCLK Support for MTL
error: patch fragment without header at line 16: @@ -3294,7 +3311,10 @@ static const struct intel_cdclk_funcs i830_cdclk_funcs = {
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0002 drm/i915/display: Add CDCLK Support for MTL
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".