drm/i915: Don't try to use negative pll_id.
Subsystems (2)
Rodrigo Vivi
maintainerPATCH 1/1 drm/i915: Don't try to use negative pll_id.
It is unlikely we are getting the -1 here.
But if we propagate that pll_id -1 to the rest of the code we might have funny calculations on link_clock and who knows what registers we end up accessing.
Better to protect the code.
Also better with errno number instead of generic -1.
--- drivers/gpu/drm/i915/intel_ddi.c | 10 ++++++++++ drivers/gpu/drm/i915/intel_dpll_mgr.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +10 -0
@@ -1283,6 +1283,11 @@ static void cnl_ddi_clock_get(struct intel_encoder *encoder, pll_id =intel_get_shared_dpll_id (dev_priv, pipe_config->shared_dpll); +if (pll_id <0 ) { +DRM_ERROR ("PLL not found\n" ); +return ; + } + cfgcr0 =I915_READ (CNL_DPLL_CFGCR0 (pll_id));if (cfgcr0 &DPLL_CFGCR0_HDMI_MODE ) {
@@ -1337,6 +1342,11 @@ static void skl_ddi_clock_get(struct intel_encoder *encoder, pll_id =intel_get_shared_dpll_id (dev_priv, pipe_config->shared_dpll); +if (pll_id <0 ) { +DRM_ERROR ("PLL not found\n" ); +return ; + } + dpll_ctl1 =I915_READ (DPLL_CTRL1 );if (dpll_ctl1 &DPLL_CTRL1_HDMI_MODE (pll_id)) {
drivers/gpu/drm/i915/intel_dpll_mgr.c +1 -1
@@ -102,7 +102,7 @@ intel_get_shared_dpll_id(struct drm_i915_private *dev_priv, {if (WARN_ON (pll < dev_priv->shared_dplls|| pll > &dev_priv->shared_dplls[dev_priv->num_shared_dpll])) -return -1 ; +return -ENOENT ;return (enum intel_dpll_id ) (pll - dev_priv->shared_dplls); }
Signature · 6 lines
2.13.6 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 21 lines · Rodrigo Vivi
It is unlikely we are getting the -1 here.
But if we propagate thatpll_id-1 to the rest of the code we might have funny calculations onlink_clockand who knows what registers we end up accessing.Better to protect the code.
Also better with errno number instead of generic -1.
Cc Manasi Navare <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/intel_ddi.c | 10 ++++++++++ drivers/gpu/drm/i915/intel_dpll_mgr.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_ddi.c +0
-0
drivers/gpu/drm/i915/intel_ddi.c static void cnl_ddi_clock_get(struct intel_encoder *encoder, · line 1291
Quoted 9 lines
drivers/gpu/drm/i915/intel_ddi.c +5
-0@@ -1283,6 +1283,11 @@ static void cnl_ddi_clock_get(struct intel_encoder *encoder, pll_id =intel_get_shared_dpll_id (dev_priv, pipe_config->shared_dpll); +if (pll_id <0 ) { +DRM_ERROR ("PLL not found\n" ); +return ; + } + cfgcr0 =I915_READ (CNL_DPLL_CFGCR0 (pll_id));
Don't we have the dpll state already read out?
crtc_state->dll_hw_state.cfgcr0 etc.?
Quoted 34 lines
drivers/gpu/drm/i915/intel_ddi.c +5
-0if (cfgcr0 &DPLL_CFGCR0_HDMI_MODE ) {@@ -1337,6 +1342,11 @@ static void skl_ddi_clock_get(struct intel_encoder *encoder, pll_id =intel_get_shared_dpll_id (dev_priv, pipe_config->shared_dpll); +if (pll_id <0 ) { +DRM_ERROR ("PLL not found\n" ); +return ; + } + dpll_ctl1 =I915_READ (DPLL_CTRL1 );if (dpll_ctl1 &DPLL_CTRL1_HDMI_MODE (pll_id)) {drivers/gpu/drm/i915/intel_dpll_mgr.c +1
-1@@ -102,7 +102,7 @@ intel_get_shared_dpll_id(struct drm_i915_private *dev_priv, {if (WARN_ON (pll < dev_priv->shared_dplls|| pll > &dev_priv->shared_dplls[dev_priv->num_shared_dpll])) -return -1 ; +return -ENOENT ;return (enum intel_dpll_id ) (pll - dev_priv->shared_dplls); }Signature · 6 lines
2.13.6 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Rodrigo Vivi
maintainerQuoted 34 lines · Ville Syrjälä
Quoted 21 lines · Rodrigo Vivi
It is unlikely we are getting the -1 here.
But if we propagate thatpll_id-1 to the rest of the code we might have funny calculations onlink_clockand who knows what registers we end up accessing.Better to protect the code.
Also better with errno number instead of generic -1.
Cc Manasi Navare <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/intel_ddi.c | 10 ++++++++++ drivers/gpu/drm/i915/intel_dpll_mgr.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_ddi.c +0
-0drivers/gpu/drm/i915/intel_ddi.c static void cnl_ddi_clock_get(struct intel_encoder *encoder, · line 1291
Quoted 9 lines
drivers/gpu/drm/i915/intel_ddi.c +5
-0@@ -1283,6 +1283,11 @@ static void cnl_ddi_clock_get(struct intel_encoder *encoder, pll_id =intel_get_shared_dpll_id (dev_priv, pipe_config->shared_dpll); +if (pll_id <0 ) { +DRM_ERROR ("PLL not found\n" ); +return ; + } + cfgcr0 =I915_READ (CNL_DPLL_CFGCR0 (pll_id));Don't we have the dpll state already read out?
Quoted 1 line
crtc_state->dll_hw_state.cfgcr0etc.?
oh! we do!
Also during calc_wrpll_link we should be using this, shouldn't we?!
Probably my bad when doing this code looking to skl code...
Same thing on skl case, right?!
Quoted 31 lines
Quoted 31 lines
drivers/gpu/drm/i915/intel_ddi.c +5
-0if (cfgcr0 &DPLL_CFGCR0_HDMI_MODE ) {@@ -1337,6 +1342,11 @@ static void skl_ddi_clock_get(struct intel_encoder *encoder, pll_id =intel_get_shared_dpll_id (dev_priv, pipe_config->shared_dpll); +if (pll_id <0 ) { +DRM_ERROR ("PLL not found\n" ); +return ; + } + dpll_ctl1 =I915_READ (DPLL_CTRL1 );if (dpll_ctl1 &DPLL_CTRL1_HDMI_MODE (pll_id)) {drivers/gpu/drm/i915/intel_dpll_mgr.c +1
-1@@ -102,7 +102,7 @@ intel_get_shared_dpll_id(struct drm_i915_private *dev_priv, {if (WARN_ON (pll < dev_priv->shared_dplls|| pll > &dev_priv->shared_dplls[dev_priv->num_shared_dpll])) -return -1 ; +return -ENOENT ;return (enum intel_dpll_id ) (pll - dev_priv->shared_dplls); }Signature · 1 line
2.13.6
Quoted 8 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 2 lines
Ville Syrjälä Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 37 lines · Rodrigo Vivi
Quoted 34 lines · Ville Syrjälä
Quoted 21 lines · Rodrigo Vivi
It is unlikely we are getting the -1 here.
But if we propagate thatpll_id-1 to the rest of the code we might have funny calculations onlink_clockand who knows what registers we end up accessing.Better to protect the code.
Also better with errno number instead of generic -1.
Cc Manasi Navare <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/intel_ddi.c | 10 ++++++++++ drivers/gpu/drm/i915/intel_dpll_mgr.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_ddi.c +0
-0drivers/gpu/drm/i915/intel_ddi.c static void cnl_ddi_clock_get(struct intel_encoder *encoder, · line 1291
Quoted 9 lines
drivers/gpu/drm/i915/intel_ddi.c +5
-0@@ -1283,6 +1283,11 @@ static void cnl_ddi_clock_get(struct intel_encoder *encoder, pll_id =intel_get_shared_dpll_id (dev_priv, pipe_config->shared_dpll); +if (pll_id <0 ) { +DRM_ERROR ("PLL not found\n" ); +return ; + } + cfgcr0 =I915_READ (CNL_DPLL_CFGCR0 (pll_id));Don't we have the dpll state already read out?
Quoted 1 line
crtc_state->dll_hw_state.cfgcr0etc.?
Quoted 7 lines
oh! we do!
Also duringcalc_wrpll_linkwe should be using this, shouldn't we?!Probably my bad when doing this code looking to skl code...
Same thing on skl case, right?!
On all platforms I'd say. This is all probably just leftovers from before we had the dpll manager.
I suspect we should just move all these foo_calc_wrpll_link() etc. functions into the dpll manager. Not sure if we could just directly fill out the port_clock in the dpll manager actually. Hmm. I guess not in the .get_hw_state() at least since we don't pass the full crtc state there. But we could perhaps have some kind of .clock_get() function that'd be similar to the i9xx/vlv/chv_clock_get(), except we'd just call it from the DDI code where we currently call these hand rolled functions.
Quoted 39 lines
Quoted 39 lines
Quoted 35 lines
drivers/gpu/drm/i915/intel_ddi.c +5
-0if (cfgcr0 &DPLL_CFGCR0_HDMI_MODE ) {@@ -1337,6 +1342,11 @@ static void skl_ddi_clock_get(struct intel_encoder *encoder, pll_id =intel_get_shared_dpll_id (dev_priv, pipe_config->shared_dpll); +if (pll_id <0 ) { +DRM_ERROR ("PLL not found\n" ); +return ; + } + dpll_ctl1 =I915_READ (DPLL_CTRL1 );if (dpll_ctl1 &DPLL_CTRL1_HDMI_MODE (pll_id)) {drivers/gpu/drm/i915/intel_dpll_mgr.c +1
-1@@ -102,7 +102,7 @@ intel_get_shared_dpll_id(struct drm_i915_private *dev_priv, {if (WARN_ON (pll < dev_priv->shared_dplls|| pll > &dev_priv->shared_dplls[dev_priv->num_shared_dpll])) -return -1 ; +return -ENOENT ;return (enum intel_dpll_id ) (pll - dev_priv->shared_dplls); }Signature · 6 lines
2.13.6 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 2 lines
Ville Syrjälä Intel OTC
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 21 lines · Rodrigo Vivi
It is unlikely we are getting the -1 here.
But if we propagate thatpll_id-1 to the rest of the code we might have funny calculations onlink_clockand who knows what registers we end up accessing.Better to protect the code.
Also better with errno number instead of generic -1.
Cc Manasi Navare <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/intel_ddi.c | 10 ++++++++++ drivers/gpu/drm/i915/intel_dpll_mgr.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_ddi.c +0
-0
drivers/gpu/drm/i915/intel_ddi.c static void cnl_ddi_clock_get(struct intel_encoder *encoder, · line 1290
Quoted 8 lines
drivers/gpu/drm/i915/intel_ddi.c +5
-0@@ -1283,6 +1283,11 @@ static void cnl_ddi_clock_get(struct intel_encoder *encoder, pll_id =intel_get_shared_dpll_id (dev_priv, pipe_config->shared_dpll); +if (pll_id <0 ) { +DRM_ERROR ("PLL not found\n" ); +return ; + } +
The function intel_get_shared_dpll_id() already has this WARN_ON:
if (WARN_ON(pll < dev_priv->shared_dplls))
and it return pll_id = (pll - dev_priv->shared_dplls);
So shouldnt this already throw a warning in case pll < dev_priv->shared_dplls eventually resulting into a negative pll_id?
Manasi
Quoted 31 lines
drivers/gpu/drm/i915/intel_ddi.c +5
-0cfgcr0 =I915_READ (CNL_DPLL_CFGCR0 (pll_id));if (cfgcr0 &DPLL_CFGCR0_HDMI_MODE ) {@@ -1337,6 +1342,11 @@ static void skl_ddi_clock_get(struct intel_encoder *encoder, pll_id =intel_get_shared_dpll_id (dev_priv, pipe_config->shared_dpll); +if (pll_id <0 ) { +DRM_ERROR ("PLL not found\n" ); +return ; + } + dpll_ctl1 =I915_READ (DPLL_CTRL1 );if (dpll_ctl1 &DPLL_CTRL1_HDMI_MODE (pll_id)) {drivers/gpu/drm/i915/intel_dpll_mgr.c +1
-1@@ -102,7 +102,7 @@ intel_get_shared_dpll_id(struct drm_i915_private *dev_priv, {if (WARN_ON (pll < dev_priv->shared_dplls|| pll > &dev_priv->shared_dplls[dev_priv->num_shared_dpll])) -return -1 ; +return -ENOENT ;return (enum intel_dpll_id ) (pll - dev_priv->shared_dplls); }Signature · 1 line
2.13.6
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Rodrigo Vivi
maintainerQuoted 25 lines · Manasi Navare
Quoted 24 lines · Rodrigo Vivi
It is unlikely we are getting the -1 here.
But if we propagate thatpll_id-1 to the rest of the code we might have funny calculations onlink_clockand who knows what registers we end up accessing.Better to protect the code.
Also better with errno number instead of generic -1.
Cc Manasi Navare <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/intel_ddi.c | 10 ++++++++++ drivers/gpu/drm/i915/intel_dpll_mgr.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_ddi.c +0
-0@@ -1283,6 +1283,11 @@ static void cnl_ddi_clock_get(struct intel_encoder *encoder, pll_id =intel_get_shared_dpll_id (dev_priv, pipe_config->shared_dpll);
Quoted 11 lines
drivers/gpu/drm/i915/intel_ddi.c static void cnl_ddi_clock_get(struct intel_encoder *encoder, · line 1290
Quoted 5 lines
drivers/gpu/drm/i915/intel_ddi.c +5
-0+if (pll_id <0 ) { +DRM_ERROR ("PLL not found\n" ); +return ; + } +The function
intel_get_shared_dpll_id()already has thisWARN_ON:
if (WARN_ON(pll < dev_priv->shared_dplls))
and it returnpll_id= (pll -dev_priv->shared_dplls);
So shouldnt this already throw a warning in case pll <dev_priv->shared_dpllseventually resulting into a negativepll_id?
yeap, we through a warning and return -1.
Then we use the -1 to do some reg access and bits...
Quoted 29 lines
Manasi
Quoted 26 lines
drivers/gpu/drm/i915/intel_ddi.c +5
-0cfgcr0 =I915_READ (CNL_DPLL_CFGCR0 (pll_id));if (cfgcr0 &DPLL_CFGCR0_HDMI_MODE ) {@@ -1337,6 +1342,11 @@ static void skl_ddi_clock_get(struct intel_encoder *encoder, pll_id =intel_get_shared_dpll_id (dev_priv, pipe_config->shared_dpll); +if (pll_id <0 ) { +DRM_ERROR ("PLL not found\n" ); +return ; + } + dpll_ctl1 =I915_READ (DPLL_CTRL1 );if (dpll_ctl1 &DPLL_CTRL1_HDMI_MODE (pll_id)) {drivers/gpu/drm/i915/intel_dpll_mgr.c +1
-1@@ -102,7 +102,7 @@ intel_get_shared_dpll_id(struct drm_i915_private *dev_priv, {if (WARN_ON (pll < dev_priv->shared_dplls|| pll > &dev_priv->shared_dplls[dev_priv->num_shared_dpll])) -return -1 ; +return -ENOENT ;
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/i915/intel_dpll_mgr.c +0
-0return (enum intel_dpll_id ) (pll - dev_priv->shared_dplls); }Signature · 1 line
2.13.6
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915: Don't try to use negative pll_id.
In reply to Rodrigo Vivi== Series Details ==
== Series Details ==
Series: drm/i915: Don't try to use negative pll_id.
URL : https://patchwork.freedesktop.org/series/33004/
State : success
== Summary ==
Series 33004v1 drm/i915: Don't try to use negative pll_id.
https://patchwork.freedesktop.org/api/1.0/series/33004/revisions/1/mbox/
Test gem_mmap_gtt:
Subgroup basic-read-no-prefault:
pass -> DMESG-WARN (fi-bsw-n3050) fdo#103479fdo#103479 https://bugs.freedesktop.org/show_bug.cgi?id=103479
fi-bdw-5557u total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:440s fi-bdw-gvtdvm total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:461s fi-blb-e6850 total:289 pass:223 dwarn:1 dfail:0 fail:0 skip:65 time:385s fi-bsw-n3050 total:289 pass:242 dwarn:1 dfail:0 fail:0 skip:46 time:534s fi-bwr-2160 total:289 pass:183 dwarn:0 dfail:0 fail:0 skip:106 time:274s fi-bxt-dsi total:289 pass:259 dwarn:0 dfail:0 fail:0 skip:30 time:498s fi-bxt-j4205 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:505s fi-byt-j1900 total:289 pass:253 dwarn:1 dfail:0 fail:0 skip:35 time:508s fi-byt-n2820 total:289 pass:249 dwarn:1 dfail:0 fail:0 skip:39 time:488s fi-cfl-s total:289 pass:253 dwarn:4 dfail:0 fail:0 skip:32 time:556s fi-cnl-y total:217 pass:196 dwarn:0 dfail:0 fail:0 skip:20 fi-elk-e7500 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:426s fi-gdg-551 total:289 pass:178 dwarn:1 dfail:0 fail:1 skip:109 time:262s fi-glk-1 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:584s fi-glk-dsi total:289 pass:258 dwarn:0 dfail:0 fail:1 skip:30 time:495s fi-hsw-4770 total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:440s fi-hsw-4770r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:427s fi-ilk-650 total:289 pass:228 dwarn:0 dfail:0 fail:0 skip:61 time:422s fi-ivb-3520m total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:496s fi-ivb-3770 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:465s fi-kbl-7500u total:289 pass:264 dwarn:1 dfail:0 fail:0 skip:24 time:492s fi-kbl-7560u total:289 pass:270 dwarn:0 dfail:0 fail:0 skip:19 time:573s fi-kbl-7567u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:479s fi-kbl-r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:584s fi-pnv-d510 total:289 pass:222 dwarn:1 dfail:0 fail:0 skip:66 time:564s fi-skl-6260u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:458s fi-skl-6600u total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:587s fi-skl-6700hq total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:645s fi-skl-6700k total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:522s fi-skl-6770hq total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:506s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:461s fi-snb-2520m total:289 pass:250 dwarn:0 dfail:0 fail:0 skip:39 time:571s fi-snb-2600 total:289 pass:249 dwarn:0 dfail:0 fail:0 skip:40 time:423s
7da46c0a019ebaec3f67a8a6ccc60a56c2d521b1 drm-tip: 2017y-11m-01d-17h-32m-50s UTC integration manifest 5c1d9a6dbde3 drm/i915: Don't try to use negative pll_id.
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_6303/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.IGT: failure for drm/i915: Don't try to use negative pll_id.
In reply to Rodrigo Vivi== Series Details ==
== Series Details ==
Series: drm/i915: Don't try to use negative pll_id.
URL : https://patchwork.freedesktop.org/series/33004/
State : failure
== Summary ==
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-pri-indfb-multidraw:
pass -> FAIL (shard-hsw)
Test kms_setmode:
Subgroup basic:
fail -> PASS (shard-hsw) fdo#99912
Test perf:
Subgroup oa-exponents:
fail -> PASS (shard-hsw) fdo#102254
Test drv_module_reload:
Subgroup basic-reload:
pass -> DMESG-WARN (shard-hsw) fdo#102707
Test kms_flip:
Subgroup modeset-vs-vblank-race-interruptible:
fail -> PASS (shard-hsw) fdo#103060
Subgroup plain-flip-fb-recreate-interruptible:
pass -> FAIL (shard-hsw) fdo#100368fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
fdo#102254 https://bugs.freedesktop.org/show_bug.cgi?id=102254
fdo#102707 https://bugs.freedesktop.org/show_bug.cgi?id=102707
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
shard-hsw total:2539 pass:1430 dwarn:2 dfail:0 fail:10 skip:1097 time:9225s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_6303/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx