VBT and I_boost fixes
Subsystems (2)
cover VBT and I_boost fixes
These are required for SKL PV.
I tested these on SNB and SKL.
Antti Koskipaa (2):
drm/i915: Allow parsing of variable size child device entries from VBT drm/i915: Per-DDI I_boost override
drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/gpu/drm/i915/intel_bios.c | 30 ++++++++++++++++++++++++++++-- drivers/gpu/drm/i915/intel_bios.h | 9 +++++++++ drivers/gpu/drm/i915/intel_ddi.c | 38 ++++++++++++++++++++++++++++++-------- 4 files changed, 70 insertions(+), 10 deletions(-)
Signature · 6 lines
2.3.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/2 drm/i915: Allow parsing of variable size child device entries from VBT
VBT version 196 increased the size of common_child_dev_config. The parser code assumed that the size of this structure would not change.
So now, instead of checking for smaller size, check that the VBT entry is not too large and memcpy only child_dev_size amount of data, leaving any trailing entries as zero. If this is not good enough for the future, we can always sprinkle extra version checks in there.
--- drivers/gpu/drm/i915/intel_bios.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_bios.c +7 -2
@@ -1022,10 +1022,15 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } -if (p_defs->child_dev_size <sizeof (*p_child)) { +/* Historically, child_dev_size has to be at least 33 bytes in size. */ +if (p_defs->child_dev_size <33 ) {DRM_ERROR ("General definiton block child device size is too small.\n" );return ; } +if (p_defs->child_dev_size >sizeof (*p_child)) { +DRM_ERROR ("General definiton block child device size is too large.\n" ); +return ; + }/* get the block size of general definitions */ block_size =get_blocksize (p_defs);/* get the number of child device */
@@ -1070,7 +1075,7 @@ parse_device_mapping(struct drm_i915_private *dev_priv, child_dev_ptr = dev_priv->vbt.child_dev + count; count++; -memcpy (child_dev_ptr, p_child,sizeof (*p_child)); +memcpy (child_dev_ptr, p_child, p_defs->child_dev_size); }return ; }
Signature · 6 lines
2.3.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 18 lines · Antti Koskipaa
VBT version 196 increased the size of
common_child_dev_config. The parser code assumed that the size of this structure would not change.So now, instead of checking for smaller size, check that the VBT entry is not too large and memcpy only
child_dev_sizeamount of data, leaving any trailing entries as zero. If this is not good enough for the future, we can always sprinkle extra version checks in there.Signed-off-by Antti Koskipaa <[email protected]>--- drivers/gpu/drm/i915/intel_bios.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_bios.c +0
-0
drivers/gpu/drm/i915/intel_bios.c parse_device_mapping(struct drm_i915_private *dev_priv, · line 1027
Quoted 7 lines
drivers/gpu/drm/i915/intel_bios.c +2
-1@@ -1022,10 +1022,15 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } -if (p_defs->child_dev_size <sizeof (*p_child)) { +/* Historically, child_dev_size has to be at least 33 bytes in size. */ +if (p_defs->child_dev_size <33 ) {DRM_ERROR ("General definiton block child device size is too small.\n" );
"definition"
drivers/gpu/drm/i915/intel_bios.c parse_device_mapping(struct drm_i915_private *dev_priv, · line 1031
Quoted 4 lines
drivers/gpu/drm/i915/intel_bios.c +2
-0return ; } +if (p_defs->child_dev_size >sizeof (*p_child)) { +DRM_ERROR ("General definiton block child device size is too large.\n" );
"definition"
Quoted 17 lines
drivers/gpu/drm/i915/intel_bios.c +3
-1+return ; + }/* get the block size of general definitions */ block_size =get_blocksize (p_defs);/* get the number of child device */ @@ -1070,7 +1075,7 @@ parse_device_mapping(struct drm_i915_private *dev_priv, child_dev_ptr = dev_priv->vbt.child_dev + count; count++; -memcpy (child_dev_ptr, p_child,sizeof (*p_child)); +memcpy (child_dev_ptr, p_child, p_defs->child_dev_size); }return ; }Signature · 1 line
2.3.6
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2] drm/i915: Allow parsing of variable size child device entries from VBT
In reply to Antti KoskipaaQuoted 9 lines · Antti Koskipaa
VBT version 196 increased the size of
common_child_dev_config. The parser code assumed that the size of this structure would not change.So now, instead of checking for smaller size, check that the VBT entry is not too large and memcpy only
child_dev_sizeamount of data, leaving any trailing entries as zero. If this is not good enough for the future, we can always sprinkle extra version checks in there.Signed-off-by Antti Koskipaa <[email protected]>
As I mentioned in the other threads I think with vbt it's not too paranoid to double-check our assumptions. So for each vbt version range I'd like us to check what size we exactly expect. Being super paranoid with vbt is imo good practice since otherwise the hw teams will sneak in another update without us realizing it.
-Daniel
Quoted 41 lines
--- drivers/gpu/drm/i915/intel_bios.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_bios.c +7
-2@@ -1022,10 +1022,15 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } -if (p_defs->child_dev_size <sizeof (*p_child)) { +/* Historically, child_dev_size has to be at least 33 bytes in size. */ +if (p_defs->child_dev_size <33 ) {DRM_ERROR ("General definiton block child device size is too small.\n" );return ; } +if (p_defs->child_dev_size >sizeof (*p_child)) { +DRM_ERROR ("General definiton block child device size is too large.\n" ); +return ; + }/* get the block size of general definitions */ block_size =get_blocksize (p_defs);/* get the number of child device */ @@ -1070,7 +1075,7 @@ parse_device_mapping(struct drm_i915_private *dev_priv, child_dev_ptr = dev_priv->vbt.child_dev + count; count++; -memcpy (child_dev_ptr, p_child,sizeof (*p_child)); +memcpy (child_dev_ptr, p_child, p_defs->child_dev_size); }return ; }Signature · 6 lines
2.3.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Antti Koskipaa
VBT version 196 increased the size of
common_child_dev_config. The parser code assumed that the size of this structure would not change.So now, instead of checking for smaller size, check that the VBT entry is not too large and memcpy only
child_dev_sizeamount of data, leaving any trailing entries as zero. If this is not good enough for the future, we can always sprinkle extra version checks in there.
Quoted 7 lines
Quoted 1 line
Signed-off-by Antti Koskipaa <[email protected]>As I mentioned in the other threads I think with vbt it's not too paranoid to double-check our assumptions. So for each vbt version range I'd like us to check what size we exactly expect. Being super paranoid with vbt is imo good practice since otherwise the hw teams will sneak in another update without us realizing it.
Antti's on vacation now for the next few weeks. Do you need these modifications as a pre-requisite for merging his patch, or can further improvements be submitted separately?
Kind regards, David
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 18 lines · David Weinehall
Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Antti Koskipaa
VBT version 196 increased the size of
common_child_dev_config. The parser code assumed that the size of this structure would not change.So now, instead of checking for smaller size, check that the VBT entry is not too large and memcpy only
child_dev_sizeamount of data, leaving any trailing entries as zero. If this is not good enough for the future, we can always sprinkle extra version checks in there.Quoted 7 lines
Quoted 1 line
Signed-off-by Antti Koskipaa <[email protected]>As I mentioned in the other threads I think with vbt it's not too paranoid to double-check our assumptions. So for each vbt version range I'd like us to check what size we exactly expect. Being super paranoid with vbt is imo good practice since otherwise the hw teams will sneak in another update without us realizing it.
Quoted 3 lines
Antti's on vacation now for the next few weeks. Do you need these modifications as a pre-requisite for merging his patch, or can further improvements be submitted separately?
This patch starts to make our vbt checking lax. I don't want to walk down this road really, so yes I prefer if we just keep on having really strict checks.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2 v2] drm/i915: Allow parsing of variable size child device entries from VBT
In reply to Antti KoskipaaVBT version 196 increased the size of common_child_dev_config. The parser code assumed that the size of this structure would not change.
The modified code now copies the amount needed based on the VBT version, and emits a debug message if the VBT version is unknown (too new); since the struct config block won't shrink in newer versions it should be harmless to copy the maximum known size in such cases, so that's what we do, but emitting the warning is probably sensible anyway.
In the longer run it might make sense to modify the parser code to use a version/feature mapping, rather than hardcoding things like this, but for now the variants are fairly managable.
v2: Stricter size checks
--- drivers/gpu/drm/i915/intel_bios.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_bios.c +22 -4
@@ -1015,15 +1015,33 @@ parse_device_mapping(struct drm_i915_private *dev_priv,const union child_device_config *p_child;union child_device_config *child_dev_ptr;int i, child_device_num, count; -u16 block_size; +u8 expected_size; +u16 block_size; p_defs =find_section (bdb,BDB_GENERAL_DEFINITIONS );if (!p_defs) {DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } -if (p_defs->child_dev_size <sizeof (*p_child)) { -DRM_ERROR ("General definiton block child device size is too small.\n" ); +if (bdb->version <195 ) { + expected_size =33 ; + }else if (bdb->version ==195 ) { + expected_size =37 ; + }else if (bdb->version <=197 ) { + expected_size =38 ; + }else { + expected_size =38 ; +DRM_DEBUG_DRIVER ("Expected child_device_config size for BDB version %u not known; assuming %u\n" , expected_size); + } + +if (expected_size >sizeof (*p_child)) { +DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +return ; + } + +if (p_defs->child_dev_size != expected_size) { +DRM_ERROR ("Size mismatch; child_device_config size=%u (expected %u); bdb->version: %u\n" , + p_defs->child_dev_size, expected_size, bdb->version);return ; }/* get the block size of general definitions */
@@ -1070,7 +1088,7 @@ parse_device_mapping(struct drm_i915_private *dev_priv, child_dev_ptr = dev_priv->vbt.child_dev + count; count++; -memcpy (child_dev_ptr, p_child,sizeof (*p_child)); +memcpy (child_dev_ptr, p_child, p_defs->child_dev_size); }return ; }
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2 v2] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 9 lines · David Weinehall
VBT version 196 increased the size of
common_child_dev_config. The parser code assumed that the size of this structure would not change.The modified code now copies the amount needed based on the VBT version, and emits a debug message if the VBT version is unknown (too new); since the struct config block won't shrink in newer versions it should be harmless to copy the maximum known size in such cases, so that's what we do, but emitting the warning is probably sensible anyway.
Quoted 7 lines
In the longer run it might make sense to modify the parser code to use a version/feature mapping, rather than hardcoding things like this, but for now the variants are fairly managable.
v2: Stricter size checks
Signed-off-by David Weinehall <[email protected]>
Since Chris mentioned that this should fix a regression I applied it to drm-intel-fixes.
-Daniel
Quoted 58 lines
--- drivers/gpu/drm/i915/intel_bios.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/intel_bios.c +22
-4@@ -1015,15 +1015,33 @@ parse_device_mapping(struct drm_i915_private *dev_priv,const union child_device_config *p_child;union child_device_config *child_dev_ptr;int i, child_device_num, count; -u16 block_size; +u8 expected_size; +u16 block_size; p_defs =find_section (bdb,BDB_GENERAL_DEFINITIONS );if (!p_defs) {DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } -if (p_defs->child_dev_size <sizeof (*p_child)) { -DRM_ERROR ("General definiton block child device size is too small.\n" ); +if (bdb->version <195 ) { + expected_size =33 ; + }else if (bdb->version ==195 ) { + expected_size =37 ; + }else if (bdb->version <=197 ) { + expected_size =38 ; + }else { + expected_size =38 ; +DRM_DEBUG_DRIVER ("Expected child_device_config size for BDB version %u not known; assuming %u\n" , expected_size); + } + +if (expected_size >sizeof (*p_child)) { +DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +return ; + } + +if (p_defs->child_dev_size != expected_size) { +DRM_ERROR ("Size mismatch; child_device_config size=%u (expected %u); bdb->version: %u\n" , + p_defs->child_dev_size, expected_size, bdb->version);return ; }/* get the block size of general definitions */ @@ -1070,7 +1088,7 @@ parse_device_mapping(struct drm_i915_private *dev_priv, child_dev_ptr = dev_priv->vbt.child_dev + count; count++; -memcpy (child_dev_ptr, p_child,sizeof (*p_child)); +memcpy (child_dev_ptr, p_child, p_defs->child_dev_size); }return ; }_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2 v2] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · David Weinehall
VBT version 196 increased the size of
common_child_dev_config. The parser code assumed that the size of this structure would not change.The modified code now copies the amount needed based on the VBT version, and emits a debug message if the VBT version is unknown (too new); since the struct config block won't shrink in newer versions it should be harmless to copy the maximum known size in such cases, so that's what we do, but emitting the warning is probably sensible anyway.
In the longer run it might make sense to modify the parser code to use a version/feature mapping, rather than hardcoding things like this, but for now the variants are fairly managable.
Quoted 6 lines
Quoted 3 lines
v2: Stricter size checks
Signed-off-by David Weinehall <[email protected]>Since Chris mentioned that this should fix a regression I applied it to drm-intel-fixes.
Great! Will you merge the other patch in the series to the nightly build?
Regards, David
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2 v2] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 17 lines · David Weinehall
Quoted 16 lines · Daniel Vetter
Quoted 15 lines · David Weinehall
VBT version 196 increased the size of
common_child_dev_config. The parser code assumed that the size of this structure would not change.The modified code now copies the amount needed based on the VBT version, and emits a debug message if the VBT version is unknown (too new); since the struct config block won't shrink in newer versions it should be harmless to copy the maximum known size in such cases, so that's what we do, but emitting the warning is probably sensible anyway.
In the longer run it might make sense to modify the parser code to use a version/feature mapping, rather than hardcoding things like this, but for now the variants are fairly managable.
v2: Stricter size checks
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by David Weinehall <[email protected]>Since Chris mentioned that this should fix a regression I applied it to drm-intel-fixes.
Great! Will you merge the other patch in the series to the nightly build?
I only merged this fast-tracked because it fixes a regression. For the other patch normal review rules still apply (i.e. I won't do it). -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2 v2] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 20 lines · Daniel Vetter
Quoted 19 lines · David Weinehall
Quoted 18 lines · Daniel Vetter
Quoted 16 lines · David Weinehall
VBT version 196 increased the size of
common_child_dev_config. The parser code assumed that the size of this structure would not change.The modified code now copies the amount needed based on the VBT version, and emits a debug message if the VBT version is unknown (too new); since the struct config block won't shrink in newer versions it should be harmless to copy the maximum known size in such cases, so that's what we do, but emitting the warning is probably sensible anyway.
In the longer run it might make sense to modify the parser code to use a version/feature mapping, rather than hardcoding things like this, but for now the variants are fairly managable.
v2: Stricter size checks
Signed-off-by David Weinehall <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Since Chris mentioned that this should fix a regression I applied it to drm-intel-fixes.
Great! Will you merge the other patch in the series to the nightly build?
I only merged this fast-tracked because it fixes a regression. For the other patch normal review rules still apply (i.e. I won't do it).
I wasn't expecting fast tracking. I'd missed the fact that patch 2/2 wasn't reviewed by anyone yet; I've done so now.
Kind regards, David
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2 v2] drm/i915: Allow parsing of variable size child device entries from VBT
In reply to Daniel VetterQuoted 38 lines · Daniel Vetter
Quoted 9 lines · David Weinehall
VBT version 196 increased the size of
common_child_dev_config. The parser code assumed that the size of this structure would not change.The modified code now copies the amount needed based on the VBT version, and emits a debug message if the VBT version is unknown (too new); since the struct config block won't shrink in newer versions it should be harmless to copy the maximum known size in such cases, so that's what we do, but emitting the warning is probably sensible anyway.
Quoted 7 lines
In the longer run it might make sense to modify the parser code to use a version/feature mapping, rather than hardcoding things like this, but for now the variants are fairly managable.
v2: Stricter size checks
Signed-off-by David Weinehall <[email protected]>Since Chris mentioned that this should fix a regression I applied it to drm-intel-fixes.
-DanielQuoted 16 lines
--- drivers/gpu/drm/i915/intel_bios.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/intel_bios.c +2
-1@@ -1015,15 +1015,33 @@ parse_device_mapping(struct drm_i915_private *dev_priv,const union child_device_config *p_child;union child_device_config *child_dev_ptr;int i, child_device_num, count; -u16 block_size; +u8 expected_size; +u16 block_size;
Quoted 16 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_bios.c +0
-1p_defs =find_section (bdb,BDB_GENERAL_DEFINITIONS );if (!p_defs) {DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } -if (p_defs->child_dev_size <sizeof (*p_child)) {drivers/gpu/drm/i915/intel_bios.c parse_device_mapping(struct drm_i915_private *dev_priv, · line 1034
Quoted 10 lines
drivers/gpu/drm/i915/intel_bios.c +9
-1-DRM_ERROR ("General definiton block child device size is too small.\n" ); +if (bdb->version <195 ) { + expected_size =33 ; + }else if (bdb->version ==195 ) { + expected_size =37 ; + }else if (bdb->version <=197 ) { + expected_size =38 ; + }else { + expected_size =38 ; +DRM_DEBUG_DRIVER ("Expected child_device_config size for BDB version %u not known; assuming %u\n" , expected_size);
Hi, the line above throws a warning because there are two '%u' but only one variable. Looks like bdb->version should be the 1st printed value.
Quoted 27 lines
Quoted 22 lines
drivers/gpu/drm/i915/intel_bios.c +11
-1+ } + +if (expected_size >sizeof (*p_child)) { +DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +return ; + } + +if (p_defs->child_dev_size != expected_size) { +DRM_ERROR ("Size mismatch; child_device_config size=%u (expected %u); bdb->version: %u\n" , + p_defs->child_dev_size, expected_size, bdb->version);return ; }/* get the block size of general definitions */ @@ -1070,7 +1088,7 @@ parse_device_mapping(struct drm_i915_private *dev_priv, child_dev_ptr = dev_priv->vbt.child_dev + count; count++; -memcpy (child_dev_ptr, p_child,sizeof (*p_child)); +memcpy (child_dev_ptr, p_child, p_defs->child_dev_size); }return ; }Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2 v2] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 50 lines · Michel Thierry
Quoted 49 lines · Daniel Vetter
Quoted 9 lines · David Weinehall
VBT version 196 increased the size of
common_child_dev_config. The parser code assumed that the size of this structure would not change.The modified code now copies the amount needed based on the VBT version, and emits a debug message if the VBT version is unknown (too new); since the struct config block won't shrink in newer versions it should be harmless to copy the maximum known size in such cases, so that's what we do, but emitting the warning is probably sensible anyway.
Quoted 7 lines
In the longer run it might make sense to modify the parser code to use a version/feature mapping, rather than hardcoding things like this, but for now the variants are fairly managable.
v2: Stricter size checks
Signed-off-by David Weinehall <[email protected]>Since Chris mentioned that this should fix a regression I applied it to drm-intel-fixes.
-DanielQuoted 27 lines
--- drivers/gpu/drm/i915/intel_bios.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/intel_bios.c +6
-3@@ -1015,15 +1015,33 @@ parse_device_mapping(struct drm_i915_private *dev_priv,const union child_device_config *p_child;union child_device_config *child_dev_ptr;int i, child_device_num, count; -u16 block_size; +u8 expected_size; +u16 block_size; p_defs =find_section (bdb,BDB_GENERAL_DEFINITIONS );if (!p_defs) {DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } -if (p_defs->child_dev_size <sizeof (*p_child)) { -DRM_ERROR ("General definiton block child device size is too small.\n" ); +if (bdb->version <195 ) { + expected_size =33 ; + }else if (bdb->version ==195 ) { + expected_size =37 ;
Quoted 8 lines
Quoted 5 lines
drivers/gpu/drm/i915/intel_bios.c parse_device_mapping(struct drm_i915_private *dev_priv, · line 1034
Quoted 5 lines
drivers/gpu/drm/i915/intel_bios.c +5
-0+ }else if (bdb->version <=197 ) { + expected_size =38 ; + }else { + expected_size =38 ; +DRM_DEBUG_DRIVER ("Expected child_device_config size for BDB version %u not known; assuming %u\n" , expected_size);Hi, the line above throws a warning because there are two '%u' but only one variable. Looks like
bdb->versionshould be the 1st printed value.
Good catch, your analysis is indeed correct.
Daniel, will you do the fixup or should I submit a fixed version?
Kind regards, David
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2 v2] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 60 lines · David Weinehall
Quoted 50 lines · Michel Thierry
Quoted 49 lines · Daniel Vetter
Quoted 9 lines · David Weinehall
VBT version 196 increased the size of
common_child_dev_config. The parser code assumed that the size of this structure would not change.The modified code now copies the amount needed based on the VBT version, and emits a debug message if the VBT version is unknown (too new); since the struct config block won't shrink in newer versions it should be harmless to copy the maximum known size in such cases, so that's what we do, but emitting the warning is probably sensible anyway.
Quoted 7 lines
In the longer run it might make sense to modify the parser code to use a version/feature mapping, rather than hardcoding things like this, but for now the variants are fairly managable.
v2: Stricter size checks
Signed-off-by David Weinehall <[email protected]>Since Chris mentioned that this should fix a regression I applied it to drm-intel-fixes.
-DanielQuoted 27 lines
--- drivers/gpu/drm/i915/intel_bios.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/intel_bios.c +6
-3@@ -1015,15 +1015,33 @@ parse_device_mapping(struct drm_i915_private *dev_priv,const union child_device_config *p_child;union child_device_config *child_dev_ptr;int i, child_device_num, count; -u16 block_size; +u8 expected_size; +u16 block_size; p_defs =find_section (bdb,BDB_GENERAL_DEFINITIONS );if (!p_defs) {DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } -if (p_defs->child_dev_size <sizeof (*p_child)) { -DRM_ERROR ("General definiton block child device size is too small.\n" ); +if (bdb->version <195 ) { + expected_size =33 ; + }else if (bdb->version ==195 ) { + expected_size =37 ;Quoted 8 lines
Quoted 5 lines
drivers/gpu/drm/i915/intel_bios.c parse_device_mapping(struct drm_i915_private *dev_priv, · line 1034
Quoted 5 lines
drivers/gpu/drm/i915/intel_bios.c +5
-0+ }else if (bdb->version <=197 ) { + expected_size =38 ; + }else { + expected_size =38 ; +DRM_DEBUG_DRIVER ("Expected child_device_config size for BDB version %u not known; assuming %u\n" , expected_size);Hi, the line above throws a warning because there are two '%u' but only one variable. Looks like
bdb->versionshould be the 1st printed value.
Quoted 3 lines
Good catch, your analysis is indeed correct.
Daniel, will you do the fixup or should I submit a fixed version?
Fixed up locally.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2 v2 addendum] drm/i915: Allow parsing of variable size child device entries from VBT
Some more fixup is needed; the bits from Antti's patch that actually expanded the struct to fully fit the newer versions of the child_device_config was part of the second patch; since that patch hasn't been merged yet we need this bit:
This applies on top of the patch you already merged (the Iboost patch will need corresponding adjustment to
remove the changes I split out):
Expand common_child_dev_config to be able to fit all information defined by the latest VBT specification.
--- intel_bios.c | 7 ++++++- intel_bios.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_bios.c +6 -1
@@ -1038,6 +1038,10 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } +/* Remember to keep this in sync with child_device_config; +* whenever a new feature is added to BDB that causes that +* struct to grow this needs to be updated too +*/ if (bdb->version <195 ) { expected_size =33 ; }else if (bdb->version ==195 ) {
@@ -1051,7 +1055,8 @@ parse_device_mapping(struct drm_i915_private *dev_priv, }if (expected_size >sizeof (*p_child)) { -DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +DRM_ERROR ("child_device_config (size %u) cannot fit in p_child (size %u); bdb->version: %u\n" , + expected_size,sizeof (*p_child), bdb->version);return ; }
drivers/gpu/drm/i915/intel_bios.h +4 -0
@@ -239,6 +239,10 @@ struct common_child_dev_config {u8 not_common2[2 ];u8 ddc_pin;u16 edid_ptr; +u8 obsolete; +u8 flags_1; +u8 not_common3[13 ]; +u8 iboost_level; } __packed;/* This field changes depending on the BDB version, so the most reliable way to
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Jani Nikula
maintainerRe: [PATCH 1/2 v2 addendum] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 24 lines · David Weinehall
Some more fixup is needed; the bits from Antti's patch that actually expanded the struct to fully fit the newer versions of the
child_device_configwas part of the second patch; since that patch hasn't been merged yet we need this bit:This applies on top of the patch you already merged (the Iboost patch will need corresponding adjustment to
remove the changes I split out):Expand
common_child_dev_configto be able to fit all information defined by the latest VBT specification.Signed-off-by David Weinehall <[email protected]>CC Antti Koskipaa <[email protected]>--- intel_bios.c | 7 ++++++- intel_bios.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_bios.c +0
-0
drivers/gpu/drm/i915/intel_bios.c parse_device_mapping(struct drm_i915_private *dev_priv, · line 1044
Quoted 7 lines
drivers/gpu/drm/i915/intel_bios.c +4
-0@@ -1038,6 +1038,10 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } +/* Remember to keep this in sync with child_device_config; +* whenever a new feature is added to BDB that causes that +* struct to grow this needs to be updated too +*/
BUILD_BUG_ON(something about sizeof child device config) ?
Quoted 32 lines
drivers/gpu/drm/i915/intel_bios.c +2
-1if (bdb->version <195 ) { expected_size =33 ; }else if (bdb->version ==195 ) {@@ -1051,7 +1055,8 @@ parse_device_mapping(struct drm_i915_private *dev_priv, }if (expected_size >sizeof (*p_child)) { -DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +DRM_ERROR ("child_device_config (size %u) cannot fit in p_child (size %u); bdb->version: %u\n" , + expected_size,sizeof (*p_child), bdb->version);return ; }drivers/gpu/drm/i915/intel_bios.h +4
-0@@ -239,6 +239,10 @@ struct common_child_dev_config {u8 not_common2[2 ];u8 ddc_pin;u16 edid_ptr; +u8 obsolete; +u8 flags_1; +u8 not_common3[13 ]; +u8 iboost_level; } __packed;/* This field changes depending on the BDB version, so the most reliable way to _______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2 v2 addendum] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 20 lines · Jani Nikula
Quoted 19 lines · David Weinehall
Some more fixup is needed; the bits from Antti's patch that actually expanded the struct to fully fit the newer versions of the
child_device_configwas part of the second patch; since that patch hasn't been merged yet we need this bit:This applies on top of the patch you already merged (the Iboost patch will need corresponding adjustment to
remove the changes I split out):Expand
common_child_dev_configto be able to fit all information defined by the latest VBT specification.Signed-off-by David Weinehall <[email protected]>CC Antti Koskipaa <[email protected]>--- intel_bios.c | 7 ++++++- intel_bios.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)
Quoted 14 lines
drivers/gpu/drm/i915/intel_bios.c parse_device_mapping(struct drm_i915_private *dev_priv, · line 1044
Quoted 12 lines
drivers/gpu/drm/i915/intel_bios.c +4
-0@@ -1038,6 +1038,10 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } +/* Remember to keep this in sync with child_device_config; +* whenever a new feature is added to BDB that causes that +* struct to grow this needs to be updated too +*/
BUILD_BUG_ON(something about sizeof child device config)?
The idea is nice, but... We get the size to copy (expected_size) from the version-switch statement (so it's not available during build); thus we cannot know at compile time whether expected_size is larger than sizeof(child_device_config).
This is yet another argument in favour of a version:feature table I think; that would allow for compile-time validation.
Unless someone else volunteers to refactor this code I can dig in once I get back from vacation.
Kind regards, David
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Jani Nikula
maintainerRe: [PATCH 1/2 v2 addendum] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 41 lines · David Weinehall
Quoted 20 lines · Jani Nikula
Quoted 19 lines · David Weinehall
Some more fixup is needed; the bits from Antti's patch that actually expanded the struct to fully fit the newer versions of the
child_device_configwas part of the second patch; since that patch hasn't been merged yet we need this bit:This applies on top of the patch you already merged (the Iboost patch will need corresponding adjustment to
remove the changes I split out):Expand
common_child_dev_configto be able to fit all information defined by the latest VBT specification.Signed-off-by David Weinehall <[email protected]>CC Antti Koskipaa <[email protected]>--- intel_bios.c | 7 ++++++- intel_bios.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)Quoted 14 lines
drivers/gpu/drm/i915/intel_bios.c parse_device_mapping(struct drm_i915_private *dev_priv, · line 1044
Quoted 12 lines
drivers/gpu/drm/i915/intel_bios.c +4
-0@@ -1038,6 +1038,10 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } +/* Remember to keep this in sync with child_device_config; +* whenever a new feature is added to BDB that causes that +* struct to grow this needs to be updated too +*/
BUILD_BUG_ON(something about sizeof child device config)?The idea is nice, but... We get the size to copy (
expected_size) from the version-switch statement (so it's not available during build); thus we cannot know at compile time whetherexpected_sizeis larger thansizeof(child_device_config).
Quoted 5 lines
This is yet another argument in favour of a version:feature table I think; that would allow for compile-time validation.
Unless someone else volunteers to refactor this code I can dig in once I get back from vacation.
Right. To be clear, my question should not block this from being merged.
BR,
Jani
Quoted 3 lines
Kind regards, David
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Jani Nikula
maintainerRe: [PATCH 1/2 v2 addendum] drm/i915: Allow parsing of variable size child device entries from VBT
In reply to David WeinehallQuoted 35 lines · David Weinehall
Some more fixup is needed; the bits from Antti's patch that actually expanded the struct to fully fit the newer versions of the
child_device_configwas part of the second patch; since that patch hasn't been merged yet we need this bit:This applies on top of the patch you already merged (the Iboost patch will need corresponding adjustment to
remove the changes I split out):Expand
common_child_dev_configto be able to fit all information defined by the latest VBT specification.Signed-off-by David Weinehall <[email protected]>CC Antti Koskipaa <[email protected]>--- intel_bios.c | 7 ++++++- intel_bios.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_bios.c +4
-0@@ -1038,6 +1038,10 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } +/* Remember to keep this in sync with child_device_config; +* whenever a new feature is added to BDB that causes that +* struct to grow this needs to be updated too +*/ if (bdb->version <195 ) { expected_size =33 ; }else if (bdb->version ==195 ) {
drivers/gpu/drm/i915/intel_bios.c parse_device_mapping(struct drm_i915_private *dev_priv, · line 1059
Quoted 6 lines
drivers/gpu/drm/i915/intel_bios.c +2
-1@@ -1051,7 +1055,8 @@ parse_device_mapping(struct drm_i915_private *dev_priv, }if (expected_size >sizeof (*p_child)) { -DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +DRM_ERROR ("child_device_config (size %u) cannot fit in p_child (size %u); bdb->version: %u\n" , + expected_size,sizeof (*p_child), bdb->version);
drivers/gpu/drm/i915/intel_bios.c: In function ‘parse_device_mapping’:drivers/gpu/drm/i915/intel_bios.c:1058:3: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘long unsigned int’ [-Wformat=]
DRM_ERROR("child_device_config (size %u) cannot fit in p_child (size %u); bdb->version: %u\n",
^
CC [M] drivers/gpu/drm/i915/intel_fifo_underrun.o
Quoted 22 lines
drivers/gpu/drm/i915/intel_bios.c +0
-0return ; }drivers/gpu/drm/i915/intel_bios.h +4
-0@@ -239,6 +239,10 @@ struct common_child_dev_config {u8 not_common2[2 ];u8 ddc_pin;u16 edid_ptr; +u8 obsolete; +u8 flags_1; +u8 not_common3[13 ]; +u8 iboost_level; } __packed;/* This field changes depending on the BDB version, so the most reliable way to _______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2 v2 addendum v2] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 38 lines · Jani Nikula
Quoted 37 lines · David Weinehall
Some more fixup is needed; the bits from Antti's patch that actually expanded the struct to fully fit the newer versions of the
child_device_configwas part of the second patch; since that patch hasn't been merged yet we need this bit:This applies on top of the patch you already merged (the Iboost patch will need corresponding adjustment to
remove the changes I split out):Expand
common_child_dev_configto be able to fit all information defined by the latest VBT specification.Signed-off-by David Weinehall <[email protected]>CC Antti Koskipaa <[email protected]>--- intel_bios.c | 7 ++++++- intel_bios.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_bios.c +4
-0@@ -1038,6 +1038,10 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } +/* Remember to keep this in sync with child_device_config; +* whenever a new feature is added to BDB that causes that +* struct to grow this needs to be updated too +*/ if (bdb->version <195 ) { expected_size =33 ; }else if (bdb->version ==195 ) {@@ -1051,7 +1055,8 @@ parse_device_mapping(struct drm_i915_private *dev_priv, }
Quoted 10 lines
drivers/gpu/drm/i915/intel_bios.c parse_device_mapping(struct drm_i915_private *dev_priv, · line 1059
Quoted 4 lines
drivers/gpu/drm/i915/intel_bios.c +2
-1if (expected_size >sizeof (*p_child)) { -DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +DRM_ERROR ("child_device_config (size %u) cannot fit in p_child (size %u); bdb->version: %u\n" , + expected_size,sizeof (*p_child), bdb->version);
drivers/gpu/drm/i915/intel_bios.c: In function ‘parse_device_mapping’:drivers/gpu/drm/i915/intel_bios.c:1058:3: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘long unsigned int’ [-Wformat=]
DRM_ERROR("child_device_config (size %u) cannot fit inp_child(size %u);bdb->version: %u\n",
^
CC [M]drivers/gpu/drm/i915/intel_fifo_underrun.o
Well spotted. Or rather, stupid of me to forget that sizeof yields size_t as type, thus necessitating %zu as conversion specifier.
Fixed version:
Expand common_child_dev_config to be able to fit all information defined by the latest VBT specification.
v2: Use proper conversion specifier for size_t (%zu)
intel_bios.c | 7 ++++++- intel_bios.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_bios.c +6 -1
@@ -1038,6 +1038,10 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } +/* Remember to keep this in sync with child_device_config; +* whenever a new feature is added to BDB that causes that +* struct to grow this needs to be updated too +*/ if (bdb->version <195 ) { expected_size =33 ; }else if (bdb->version ==195 ) {
@@ -1051,7 +1055,8 @@ parse_device_mapping(struct drm_i915_private *dev_priv, }if (expected_size >sizeof (*p_child)) { -DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +DRM_ERROR ("child_device_config (size %u) cannot fit in p_child (size %zu); bdb->version: %u\n" , + expected_size,sizeof (*p_child), bdb->version);return ; }
drivers/gpu/drm/i915/intel_bios.h +4 -0
@@ -239,6 +239,10 @@ struct common_child_dev_config {u8 not_common2[2 ];u8 ddc_pin;u16 edid_ptr; +u8 obsolete; +u8 flags_1; +u8 not_common3[13 ]; +u8 iboost_level; } __packed;/* This field changes depending on the BDB version, so the most reliable way to
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2 v2 addendum v2] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 97 lines · David Weinehall
Quoted 38 lines · Jani Nikula
Quoted 37 lines · David Weinehall
Some more fixup is needed; the bits from Antti's patch that actually expanded the struct to fully fit the newer versions of the
child_device_configwas part of the second patch; since that patch hasn't been merged yet we need this bit:This applies on top of the patch you already merged (the Iboost patch will need corresponding adjustment to
remove the changes I split out):Expand
common_child_dev_configto be able to fit all information defined by the latest VBT specification.Signed-off-by David Weinehall <[email protected]>CC Antti Koskipaa <[email protected]>--- intel_bios.c | 7 ++++++- intel_bios.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_bios.c +4
-0@@ -1038,6 +1038,10 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } +/* Remember to keep this in sync with child_device_config; +* whenever a new feature is added to BDB that causes that +* struct to grow this needs to be updated too +*/ if (bdb->version <195 ) { expected_size =33 ; }else if (bdb->version ==195 ) {@@ -1051,7 +1055,8 @@ parse_device_mapping(struct drm_i915_private *dev_priv, }Quoted 10 lines
drivers/gpu/drm/i915/intel_bios.c parse_device_mapping(struct drm_i915_private *dev_priv, · line 1059
Quoted 4 lines
drivers/gpu/drm/i915/intel_bios.c +2
-1if (expected_size >sizeof (*p_child)) { -DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +DRM_ERROR ("child_device_config (size %u) cannot fit in p_child (size %u); bdb->version: %u\n" , + expected_size,sizeof (*p_child), bdb->version);
drivers/gpu/drm/i915/intel_bios.c: In function ‘parse_device_mapping’:drivers/gpu/drm/i915/intel_bios.c:1058:3: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘long unsigned int’ [-Wformat=]
DRM_ERROR("child_device_config (size %u) cannot fit inp_child(size %u);bdb->version: %u\n",
^
CC [M]drivers/gpu/drm/i915/intel_fifo_underrun.oWell spotted. Or rather, stupid of me to forget that sizeof yields
size_tas type, thus necessitating %zu as conversion specifier.Fixed version:
Expand
common_child_dev_configto be able to fit all information defined by the latest VBT specification.v2: Use proper conversion specifier for
size_t(%zu)Signed-off-by David Weinehall <[email protected]>CC Antti Koskipaa <[email protected]>intel_bios.c | 7 ++++++- intel_bios.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_bios.c +6
-1@@ -1038,6 +1038,10 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } +/* Remember to keep this in sync with child_device_config; +* whenever a new feature is added to BDB that causes that +* struct to grow this needs to be updated too +*/ if (bdb->version <195 ) { expected_size =33 ; }else if (bdb->version ==195 ) {@@ -1051,7 +1055,8 @@ parse_device_mapping(struct drm_i915_private *dev_priv, }if (expected_size >sizeof (*p_child)) { -DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +DRM_ERROR ("child_device_config (size %u) cannot fit in p_child (size %zu); bdb->version: %u\n" , + expected_size,sizeof (*p_child), bdb->version);return ; }drivers/gpu/drm/i915/intel_bios.h +0
-0
drivers/gpu/drm/i915/intel_bios.h struct common_child_dev_config { · line 248
Quoted 10 lines
drivers/gpu/drm/i915/intel_bios.h +4
-0@@ -239,6 +239,10 @@ struct common_child_dev_config {u8 not_common2[2 ];u8 ddc_pin;u16 edid_ptr; +u8 obsolete; +u8 flags_1; +u8 not_common3[13 ]; +u8 iboost_level; } __packed;/* This field changes depending on the BDB version, so the most reliable way to
Please apply this, fixes issues on some machine(s) here. Probably also cc:stable since it applies to BSW as well as SKL.
and the upstream bug could be referenced too, it's
https://bugs.freedesktop.org/show_bug.cgi?id=91613
Signature · 5 lines
t _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Jani Nikula
maintainerRe: [PATCH 1/2 v2 addendum v2] drm/i915: Allow parsing of variable size child device entries from VBT
In reply to David WeinehallQuoted 97 lines · David Weinehall
Quoted 38 lines · Jani Nikula
Quoted 37 lines · David Weinehall
Some more fixup is needed; the bits from Antti's patch that actually expanded the struct to fully fit the newer versions of the
child_device_configwas part of the second patch; since that patch hasn't been merged yet we need this bit:This applies on top of the patch you already merged (the Iboost patch will need corresponding adjustment to
remove the changes I split out):Expand
common_child_dev_configto be able to fit all information defined by the latest VBT specification.Signed-off-by David Weinehall <[email protected]>CC Antti Koskipaa <[email protected]>--- intel_bios.c | 7 ++++++- intel_bios.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_bios.c +4
-0@@ -1038,6 +1038,10 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } +/* Remember to keep this in sync with child_device_config; +* whenever a new feature is added to BDB that causes that +* struct to grow this needs to be updated too +*/ if (bdb->version <195 ) { expected_size =33 ; }else if (bdb->version ==195 ) {@@ -1051,7 +1055,8 @@ parse_device_mapping(struct drm_i915_private *dev_priv, }Quoted 10 lines
drivers/gpu/drm/i915/intel_bios.c parse_device_mapping(struct drm_i915_private *dev_priv, · line 1059
Quoted 4 lines
drivers/gpu/drm/i915/intel_bios.c +2
-1if (expected_size >sizeof (*p_child)) { -DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +DRM_ERROR ("child_device_config (size %u) cannot fit in p_child (size %u); bdb->version: %u\n" , + expected_size,sizeof (*p_child), bdb->version);
drivers/gpu/drm/i915/intel_bios.c: In function ‘parse_device_mapping’:drivers/gpu/drm/i915/intel_bios.c:1058:3: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘long unsigned int’ [-Wformat=]
DRM_ERROR("child_device_config (size %u) cannot fit inp_child(size %u);bdb->version: %u\n",
^
CC [M]drivers/gpu/drm/i915/intel_fifo_underrun.oWell spotted. Or rather, stupid of me to forget that sizeof yields
size_tas type, thus necessitating %zu as conversion specifier.Fixed version:
Expand
common_child_dev_configto be able to fit all information defined by the latest VBT specification.v2: Use proper conversion specifier for
size_t(%zu)Signed-off-by David Weinehall <[email protected]>CC Antti Koskipaa <[email protected]>intel_bios.c | 7 ++++++- intel_bios.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_bios.c +6
-1@@ -1038,6 +1038,10 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } +/* Remember to keep this in sync with child_device_config; +* whenever a new feature is added to BDB that causes that +* struct to grow this needs to be updated too +*/ if (bdb->version <195 ) { expected_size =33 ; }else if (bdb->version ==195 ) {@@ -1051,7 +1055,8 @@ parse_device_mapping(struct drm_i915_private *dev_priv, }if (expected_size >sizeof (*p_child)) { -DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +DRM_ERROR ("child_device_config (size %u) cannot fit in p_child (size %zu); bdb->version: %u\n" , + expected_size,sizeof (*p_child), bdb->version);return ; }drivers/gpu/drm/i915/intel_bios.h +0
-0
drivers/gpu/drm/i915/intel_bios.h struct common_child_dev_config { · line 245
Quoted 7 lines
drivers/gpu/drm/i915/intel_bios.h +4
-0@@ -239,6 +239,10 @@ struct common_child_dev_config {u8 not_common2[2 ];u8 ddc_pin;u16 edid_ptr; +u8 obsolete; +u8 flags_1; +u8 not_common3[13 ]; +u8 iboost_level;
How does this impact the if (p_defs->child_dev_size != sizeof(*p_child)) check in parse_sdvo_device_mapping()?
BR,
Jani.
Quoted 3 lines
drivers/gpu/drm/i915/intel_bios.h +0
-0} __packed;/* This field changes depending on the BDB version, so the most reliable way to
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Jani Nikula
maintainerRe: [PATCH 1/2 v2 addendum v2] drm/i915: Allow parsing of variable size child device entries from VBT
Quoted 93 lines · Jani Nikula
Quoted 92 lines · David Weinehall
Quoted 38 lines · Jani Nikula
Quoted 37 lines · David Weinehall
Some more fixup is needed; the bits from Antti's patch that actually expanded the struct to fully fit the newer versions of the
child_device_configwas part of the second patch; since that patch hasn't been merged yet we need this bit:This applies on top of the patch you already merged (the Iboost patch will need corresponding adjustment to
remove the changes I split out):Expand
common_child_dev_configto be able to fit all information defined by the latest VBT specification.Signed-off-by David Weinehall <[email protected]>CC Antti Koskipaa <[email protected]>--- intel_bios.c | 7 ++++++- intel_bios.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_bios.c +4
-0@@ -1038,6 +1038,10 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } +/* Remember to keep this in sync with child_device_config; +* whenever a new feature is added to BDB that causes that +* struct to grow this needs to be updated too +*/ if (bdb->version <195 ) { expected_size =33 ; }else if (bdb->version ==195 ) {@@ -1051,7 +1055,8 @@ parse_device_mapping(struct drm_i915_private *dev_priv, }Quoted 10 lines
drivers/gpu/drm/i915/intel_bios.c parse_device_mapping(struct drm_i915_private *dev_priv, · line 1059
Quoted 4 lines
drivers/gpu/drm/i915/intel_bios.c +2
-1if (expected_size >sizeof (*p_child)) { -DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +DRM_ERROR ("child_device_config (size %u) cannot fit in p_child (size %u); bdb->version: %u\n" , + expected_size,sizeof (*p_child), bdb->version);
drivers/gpu/drm/i915/intel_bios.c: In function ‘parse_device_mapping’:drivers/gpu/drm/i915/intel_bios.c:1058:3: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘long unsigned int’ [-Wformat=]
DRM_ERROR("child_device_config (size %u) cannot fit inp_child(size %u);bdb->version: %u\n",
^
CC [M]drivers/gpu/drm/i915/intel_fifo_underrun.oWell spotted. Or rather, stupid of me to forget that sizeof yields
size_tas type, thus necessitating %zu as conversion specifier.Fixed version:
Expand
common_child_dev_configto be able to fit all information defined by the latest VBT specification.v2: Use proper conversion specifier for
size_t(%zu)Signed-off-by David Weinehall <[email protected]>CC Antti Koskipaa <[email protected]>intel_bios.c | 7 ++++++- intel_bios.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_bios.c +6
-1@@ -1038,6 +1038,10 @@ parse_device_mapping(struct drm_i915_private *dev_priv,DRM_DEBUG_KMS ("No general definition block is found, no devices defined.\n" );return ; } +/* Remember to keep this in sync with child_device_config; +* whenever a new feature is added to BDB that causes that +* struct to grow this needs to be updated too +*/ if (bdb->version <195 ) { expected_size =33 ; }else if (bdb->version ==195 ) {@@ -1051,7 +1055,8 @@ parse_device_mapping(struct drm_i915_private *dev_priv, }if (expected_size >sizeof (*p_child)) { -DRM_ERROR ("child_device_config cannot fit in p_child\n" ); +DRM_ERROR ("child_device_config (size %u) cannot fit in p_child (size %zu); bdb->version: %u\n" , + expected_size,sizeof (*p_child), bdb->version);return ; }
Quoted 15 lines
drivers/gpu/drm/i915/intel_bios.h struct common_child_dev_config { · line 245
Quoted 12 lines
drivers/gpu/drm/i915/intel_bios.h +4
-0@@ -239,6 +239,10 @@ struct common_child_dev_config {u8 not_common2[2 ];u8 ddc_pin;u16 edid_ptr; +u8 obsolete; +u8 flags_1; +u8 not_common3[13 ]; +u8 iboost_level;How does this impact the if (
p_defs->child_dev_size!=sizeof(*p_child)) check inparse_sdvo_device_mapping()?
Ugh. What a mess the whole child device parsing is.
What's really broken in the current code is *assuming* some expected size for future versions, *and* then refusing to parse if the child dev size has grown. We should just parse *up to* min(VBT reported child dev size, the biggest child dev we know about). The current code keeps us doing busywork whenever someone decides to add a field at the end.
Side note, we have *two* functions and loops iterating child devices. One for new stuff and another for old stuff. Yay.
BR,
Jani.
Quoted 10 lines
BR,
Jani.Quoted 3 lines
drivers/gpu/drm/i915/intel_bios.h +0
-0} __packed;/* This field changes depending on the BDB version, so the most reliable way to Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 drm/i915: Per-DDI I_boost override
In reply to Antti KoskipaaAn OEM may request increased I_boost beyond the recommended values by specifying an I_boost value to be applied to all swing entries for a port. These override values are specified in VBT.
v2: rebase and remove unused iboost_bit variable
Issue: VIZ-5676
--- drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/gpu/drm/i915/intel_bios.c | 21 +++++++++++++++++++++ drivers/gpu/drm/i915/intel_bios.h | 9 +++++++++ drivers/gpu/drm/i915/intel_ddi.c | 38 ++++++++++++++++++++++++++++++-------- 4 files changed, 63 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
@@ -1420,6 +1420,9 @@ struct ddi_vbt_port_info { uint8_t supports_dvi:1; uint8_t supports_hdmi:1; uint8_t supports_dp:1; + +uint8_t dp_boost_level; +uint8_t hdmi_boost_level; };enum psr_lines_to_wait {
drivers/gpu/drm/i915/intel_bios.c +21 -0
@@ -886,6 +886,17 @@ err:memset (dev_priv->vbt.dsi.sequence,0 ,sizeof (dev_priv->vbt.dsi.sequence)); } +static u8 translate_iboost (u8 val) +{ +static const u8 mapping[] = {1 ,3 ,7 };/* See VBT spec */ + +if (val >=ARRAY_SIZE (mapping)) { +DRM_DEBUG_KMS ("Unsupported I_boost value found in VBT (%d), display may not work properly\n" , val); +return 0 ; + } +return mapping[val]; +} +static void parse_ddi_port (struct drm_i915_private *dev_priv,enum port port,const struct bdb_header *bdb) {
@@ -986,6 +997,16 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port, hdmi_level_shift); info->hdmi_level_shift = hdmi_level_shift; } + +/* Parse the I_boost config for SKL and above */ +if (bdb->version >=196 && (child->common.flags_1 &IBOOST_ENABLE )) { + info->dp_boost_level =translate_iboost (child->common.iboost_level &0xF ); +DRM_DEBUG_KMS ("VBT (e)DP boost level for port %c: %d\n" , +port_name (port), info->dp_boost_level); + info->hdmi_boost_level =translate_iboost (child->common.iboost_level >>4 ); +DRM_DEBUG_KMS ("VBT HDMI boost level for port %c: %d\n" , +port_name (port), info->hdmi_boost_level); + } } static void parse_ddi_ports(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_bios.h +9 -0
@@ -231,6 +231,10 @@ struct old_child_dev_config {/* This one contains field offsets that are known to be common for all BDB * versions. Notice that the meaning of the contents contents may still change, * but at least the offsets are consistent. */ + +/* Definitions for flags_1 */ +#define IBOOST_ENABLE (1<<3) +struct common_child_dev_config {u16 handle;u16 device_type;
@@ -239,8 +243,13 @@ struct common_child_dev_config {u8 not_common2[2 ];u8 ddc_pin;u16 edid_ptr; +u8 obsolete; +u8 flags_1; +u8 not_common3[13 ]; +u8 iboost_level; } __packed; +/* This field changes depending on the BDB version, so the most reliable way to * read it is by checking the BDB version and reading the raw pointer. */ union child_device_config {
drivers/gpu/drm/i915/intel_ddi.c +30 -8
@@ -440,6 +440,7 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port, {struct drm_i915_private *dev_priv = dev->dev_private;u32 reg; +u32 iboost_bit =0 ;int i, n_hdmi_entries, n_dp_entries, n_edp_entries, hdmi_default_entry, size;int hdmi_level = dev_priv->vbt.ddi_port_info[port].hdmi_level_shift;
@@ -466,6 +467,10 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port, ddi_translations_hdmi =skl_get_buf_trans_hdmi (dev, &n_hdmi_entries); hdmi_default_entry =8 ; +/* If we're boosting the current, set bit 31 of trans1 */ +if (dev_priv->vbt.ddi_port_info[port].hdmi_boost_level || + dev_priv->vbt.ddi_port_info[port].dp_boost_level) + iboost_bit =1 <<31 ; }else if (IS_BROADWELL (dev)) { ddi_translations_fdi = bdw_ddi_translations_fdi; ddi_translations_dp = bdw_ddi_translations_dp;
@@ -526,7 +531,7 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port, }for (i =0 , reg =DDI_BUF_TRANS (port); i < size; i++) { -I915_WRITE (reg, ddi_translations[i].trans1); +I915_WRITE (reg, ddi_translations[i].trans1 | iboost_bit); reg +=4 ;I915_WRITE (reg, ddi_translations[i].trans2); reg +=4 ;
@@ -541,7 +546,7 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port, hdmi_level = hdmi_default_entry;/* Entry 9 is for HDMI: */ -I915_WRITE (reg, ddi_translations_hdmi[hdmi_level].trans1); +I915_WRITE (reg, ddi_translations_hdmi[hdmi_level].trans1 | iboost_bit); reg +=4 ;I915_WRITE (reg, ddi_translations_hdmi[hdmi_level].trans2); reg +=4 ;
@@ -2078,18 +2083,35 @@ static void skl_ddi_set_iboost(struct drm_device *dev, u32 level,struct drm_i915_private *dev_priv = dev->dev_private;const struct ddi_buf_trans *ddi_translations;uint8_t iboost; +uint8_t dp_iboost, hdmi_iboost;int n_entries;u32 reg; +/* VBT may override standard boost values */ + dp_iboost = dev_priv->vbt.ddi_port_info[port].dp_boost_level; + hdmi_iboost = dev_priv->vbt.ddi_port_info[port].hdmi_boost_level; +if (type ==INTEL_OUTPUT_DISPLAYPORT ) { - ddi_translations =skl_get_buf_trans_dp (dev, &n_entries); - iboost = ddi_translations[port].i_boost; +if (dp_iboost) { + iboost = dp_iboost; + }else { + ddi_translations =skl_get_buf_trans_dp (dev, &n_entries); + iboost = ddi_translations[port].i_boost; + } }else if (type ==INTEL_OUTPUT_EDP ) { - ddi_translations =skl_get_buf_trans_edp (dev, &n_entries); - iboost = ddi_translations[port].i_boost; +if (dp_iboost) { + iboost = dp_iboost; + }else { + ddi_translations =skl_get_buf_trans_edp (dev, &n_entries); + iboost = ddi_translations[port].i_boost; + } }else if (type ==INTEL_OUTPUT_HDMI ) { - ddi_translations =skl_get_buf_trans_hdmi (dev, &n_entries); - iboost = ddi_translations[port].i_boost; +if (hdmi_iboost) { + iboost = hdmi_iboost; + }else { + ddi_translations =skl_get_buf_trans_hdmi (dev, &n_entries); + iboost = ddi_translations[port].i_boost; + } }else {return ; }
Signature · 6 lines
2.3.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2] drm/i915: Per-DDI I_boost override
Quoted 8 lines · Antti Koskipaa
An OEM may request increased
I_boostbeyond the recommended values by specifying anI_boostvalue to be applied to all swing entries for a port. These override values are specified in VBT.v2: rebase and remove unused
iboost_bitvariableIssue: VIZ-5676
Signed-off-by Antti Koskipaa <[email protected]>
Now that patch 1/2 has been updated, I'm ready to give this:
Kind regards, David
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2] drm/i915: Per-DDI I_boost override
Quoted 5 lines · David Weinehall
Quoted 4 lines · Antti Koskipaa
An OEM may request increased
I_boostbeyond the recommended values by specifying anI_boostvalue to be applied to all swing entries for a port. These override values are specified in VBT.
Quoted 8 lines
Quoted 4 lines
v2: rebase and remove unused
iboost_bitvariableIssue: VIZ-5676
Signed-off-by Antti Koskipaa <[email protected]>Now that patch 1/2 has been updated, I'm ready to give this:
Reviewed-by David Weinehall <[email protected]>
Someone needs to ping me in a few weeks about this one again since atm I can't merge it do -next, need a backmerge first.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx