[v2,1/2] drm/i915/gvt: use the correct length of child_device_config

Submitted by Weinan Li on Sept. 4, 2018, 4:19 a.m.

Details

Message ID 1536034768-6753-2-git-send-email-weinan.z.li@intel.com
State New
Headers show
Series "use correct lenght of child_device_config" ( rev: 1 ) in Intel GVT devel

Not browsing as part of any series.

Commit Message

Weinan Li Sept. 4, 2018, 4:19 a.m.
GVT-g emualte the opregion for guest with bdb version as '186' which
child_device_config length should be '33'.

v2: split into 2 patch. 1st for issue fix, 2nd for code clean up.(Zhenyu)

CC: Xiaolin Zhang <xiaolin.zhang@intel.com>
Signed-off-by: Weinan Li <weinan.z.li@intel.com>
---
 drivers/gpu/drm/i915/gvt/opregion.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/gvt/opregion.c b/drivers/gpu/drm/i915/gvt/opregion.c
index 82586c8..276db53 100644
--- a/drivers/gpu/drm/i915/gvt/opregion.c
+++ b/drivers/gpu/drm/i915/gvt/opregion.c
@@ -42,8 +42,6 @@ 
 #define DEVICE_TYPE_EFP3   0x20
 #define DEVICE_TYPE_EFP4   0x10
 
-#define DEV_SIZE	38
-
 struct opregion_header {
 	u8 signature[16];
 	u32 size;
@@ -63,6 +61,10 @@  struct bdb_data_header {
 	u16 size; /* data size */
 } __packed;
 
+/* For supporting windows guest with opregion, here hardcode the emulated
+ * bdb header version as '186', and the corresponding child_device_config
+ * length should be '33' but not '38'.
+ */
 struct efp_child_device_config {
 	u16 handle;
 	u16 device_type;
@@ -109,12 +111,6 @@  struct efp_child_device_config {
 	u8 mipi_bridge_type; /* 171 */
 	u16 device_class_ext;
 	u8 dvo_function;
-	u8 dp_usb_type_c:1; /* 195 */
-	u8 skip6:7;
-	u8 dp_usb_type_c_2x_gpio_index; /* 195 */
-	u16 dp_usb_type_c_2x_gpio_pin; /* 195 */
-	u8 iboost_dp:4; /* 196 */
-	u8 iboost_hdmi:4; /* 196 */
 } __packed;
 
 struct vbt {
@@ -155,7 +151,7 @@  static void virt_vbt_generation(struct vbt *v)
 	v->header.bdb_offset = offsetof(struct vbt, bdb_header);
 
 	strcpy(&v->bdb_header.signature[0], "BIOS_DATA_BLOCK");
-	v->bdb_header.version = 186; /* child_dev_size = 38 */
+	v->bdb_header.version = 186; /* child_dev_size = 33 */
 	v->bdb_header.header_size = sizeof(v->bdb_header);
 
 	v->bdb_header.bdb_size = sizeof(struct vbt) - sizeof(struct vbt_header)
@@ -169,11 +165,13 @@  static void virt_vbt_generation(struct vbt *v)
 
 	/* child device */
 	num_child = 4; /* each port has one child */
+	v->general_definitions.child_dev_size =
+		sizeof(struct efp_child_device_config);
 	v->general_definitions_header.id = BDB_GENERAL_DEFINITIONS;
 	/* size will include child devices */
 	v->general_definitions_header.size =
-		sizeof(struct bdb_general_definitions) + num_child * DEV_SIZE;
-	v->general_definitions.child_dev_size = DEV_SIZE;
+		sizeof(struct bdb_general_definitions) +
+			num_child * v->general_definitions.child_dev_size;
 
 	/* portA */
 	v->child0.handle = DEVICE_TYPE_EFP1;

Comments

On 2018.09.04 12:19:27 +0800, Weinan Li wrote:
> GVT-g emualte the opregion for guest with bdb version as '186' which
> child_device_config length should be '33'.
> 
> v2: split into 2 patch. 1st for issue fix, 2nd for code clean up.(Zhenyu)
>

Miss Fixes tag for this, pls add. Looks good to me. Thanks!

> CC: Xiaolin Zhang <xiaolin.zhang@intel.com>
> Signed-off-by: Weinan Li <weinan.z.li@intel.com>
> ---
>  drivers/gpu/drm/i915/gvt/opregion.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/opregion.c b/drivers/gpu/drm/i915/gvt/opregion.c
> index 82586c8..276db53 100644
> --- a/drivers/gpu/drm/i915/gvt/opregion.c
> +++ b/drivers/gpu/drm/i915/gvt/opregion.c
> @@ -42,8 +42,6 @@
>  #define DEVICE_TYPE_EFP3   0x20
>  #define DEVICE_TYPE_EFP4   0x10
>  
> -#define DEV_SIZE	38
> -
>  struct opregion_header {
>  	u8 signature[16];
>  	u32 size;
> @@ -63,6 +61,10 @@ struct bdb_data_header {
>  	u16 size; /* data size */
>  } __packed;
>  
> +/* For supporting windows guest with opregion, here hardcode the emulated
> + * bdb header version as '186', and the corresponding child_device_config
> + * length should be '33' but not '38'.
> + */
>  struct efp_child_device_config {
>  	u16 handle;
>  	u16 device_type;
> @@ -109,12 +111,6 @@ struct efp_child_device_config {
>  	u8 mipi_bridge_type; /* 171 */
>  	u16 device_class_ext;
>  	u8 dvo_function;
> -	u8 dp_usb_type_c:1; /* 195 */
> -	u8 skip6:7;
> -	u8 dp_usb_type_c_2x_gpio_index; /* 195 */
> -	u16 dp_usb_type_c_2x_gpio_pin; /* 195 */
> -	u8 iboost_dp:4; /* 196 */
> -	u8 iboost_hdmi:4; /* 196 */
>  } __packed;
>  
>  struct vbt {
> @@ -155,7 +151,7 @@ static void virt_vbt_generation(struct vbt *v)
>  	v->header.bdb_offset = offsetof(struct vbt, bdb_header);
>  
>  	strcpy(&v->bdb_header.signature[0], "BIOS_DATA_BLOCK");
> -	v->bdb_header.version = 186; /* child_dev_size = 38 */
> +	v->bdb_header.version = 186; /* child_dev_size = 33 */
>  	v->bdb_header.header_size = sizeof(v->bdb_header);
>  
>  	v->bdb_header.bdb_size = sizeof(struct vbt) - sizeof(struct vbt_header)
> @@ -169,11 +165,13 @@ static void virt_vbt_generation(struct vbt *v)
>  
>  	/* child device */
>  	num_child = 4; /* each port has one child */
> +	v->general_definitions.child_dev_size =
> +		sizeof(struct efp_child_device_config);
>  	v->general_definitions_header.id = BDB_GENERAL_DEFINITIONS;
>  	/* size will include child devices */
>  	v->general_definitions_header.size =
> -		sizeof(struct bdb_general_definitions) + num_child * DEV_SIZE;
> -	v->general_definitions.child_dev_size = DEV_SIZE;
> +		sizeof(struct bdb_general_definitions) +
> +			num_child * v->general_definitions.child_dev_size;
>  
>  	/* portA */
>  	v->child0.handle = DEVICE_TYPE_EFP1;
> -- 
> 1.9.1
> 
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev