[v3,2/2] drm/i915/gvt: align the child_device_config

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

Details

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

Not browsing as part of any series.

Commit Message

Weinan Li Sept. 4, 2018, 6:13 a.m.
GVT-g emulate opregion for VM with self-defined child_device_config,
here refine it to align with the graphics driver, and remove the unused
fields.

Signed-off-by: Weinan Li <weinan.z.li@intel.com>
---
 drivers/gpu/drm/i915/gvt/opregion.c | 124 +++++++++++++++++++++++-------------
 1 file changed, 80 insertions(+), 44 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 276db53..5895869 100644
--- a/drivers/gpu/drm/i915/gvt/opregion.c
+++ b/drivers/gpu/drm/i915/gvt/opregion.c
@@ -63,54 +63,90 @@  struct bdb_data_header {
 
 /* 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'.
+ * length should be '33' but not '38'. Define one new struct named as
+ * efp_child_device_config which is one copy of child_device_config but
+ * without fields which added from version '195'.
  */
 struct efp_child_device_config {
 	u16 handle;
 	u16 device_type;
-	u16 device_class;
-	u8 i2c_speed;
-	u8 dp_onboard_redriver; /* 158 */
-	u8 dp_ondock_redriver; /* 158 */
-	u8 hdmi_level_shifter_value:4; /* 169 */
-	u8 hdmi_max_data_rate:4; /* 204 */
-	u16 dtd_buf_ptr; /* 161 */
-	u8 edidless_efp:1; /* 161 */
-	u8 compression_enable:1; /* 198 */
-	u8 compression_method:1; /* 198 */
-	u8 ganged_edp:1; /* 202 */
-	u8 skip0:4;
-	u8 compression_structure_index:4; /* 198 */
-	u8 skip1:4;
-	u8 slave_port; /*  202 */
-	u8 skip2;
+
+	union {
+		u8  device_id[10]; /* ascii string */
+		struct {
+			u8 i2c_speed;
+			u8 dp_onboard_redriver;			/* 158 */
+			u8 dp_ondock_redriver;			/* 158 */
+			u8 hdmi_level_shifter_value:4;		/* 169 */
+			u8 hdmi_max_data_rate:4;		/* 204 */
+			u16 dtd_buf_ptr;			/* 161 */
+			u8 edidless_efp:1;			/* 161 */
+			u8 compression_enable:1;		/* 198 */
+			u8 compression_method:1;		/* 198 */
+			u8 ganged_edp:1;			/* 202 */
+			u8 reserved0:4;
+			u8 compression_structure_index:4;	/* 198 */
+			u8 reserved1:4;
+			u8 slave_port;				/* 202 */
+			u8 reserved2;
+		} __packed;
+	} __packed;
+
+	u16 addin_offset;
 	u8 dvo_port;
-	u8 i2c_pin; /* for add-in card */
-	u8 slave_addr; /* for add-in card */
+	u8 i2c_pin;
+	u8 slave_addr;
 	u8 ddc_pin;
 	u16 edid_ptr;
-	u8 dvo_config;
-	u8 efp_docked_port:1; /* 158 */
-	u8 lane_reversal:1; /* 184 */
-	u8 onboard_lspcon:1; /* 192 */
-	u8 iboost_enable:1; /* 196 */
-	u8 hpd_invert:1; /* BXT 196 */
-	u8 slip3:3;
-	u8 hdmi_compat:1;
-	u8 dp_compat:1;
-	u8 tmds_compat:1;
-	u8 skip4:5;
-	u8 aux_channel;
-	u8 dongle_detect;
-	u8 pipe_cap:2;
-	u8 sdvo_stall:1; /* 158 */
-	u8 hpd_status:2;
-	u8 integrated_encoder:1;
-	u8 skip5:2;
-	u8 dvo_wiring;
-	u8 mipi_bridge_type; /* 171 */
-	u16 device_class_ext;
+	u8 dvo_cfg; /* See DEVICE_CFG_* above */
+
+	union {
+		struct {
+			u8 dvo2_port;
+			u8 i2c2_pin;
+			u8 slave2_addr;
+			u8 ddc2_pin;
+		} __packed;
+		struct {
+			u8 efp_routed:1;			/* 158 */
+			u8 lane_reversal:1;			/* 184 */
+			u8 lspcon:1;				/* 192 */
+			u8 iboost:1;				/* 196 */
+			u8 hpd_invert:1;			/* 196 */
+			u8 flag_reserved:3;
+			u8 hdmi_support:1;			/* 158 */
+			u8 dp_support:1;			/* 158 */
+			u8 tmds_support:1;			/* 158 */
+			u8 support_reserved:5;
+			u8 aux_channel;
+			u8 dongle_detect;
+		} __packed;
+	} __packed;
+
+	union {
+		u8 capabilities;
+		struct {
+			u8 pipe_cap:2;
+			u8 sdvo_stall:1;
+			u8 hpd_status:2;
+			u8 integrated_encoder:1;		/* 158 */
+			u8 skip5:2;
+		} __packed;
+	} __packed;
+
+	u8 dvo_wiring; /* See DEVICE_WIRE_* above */
+
+	union {
+		u8 dvo2_wiring;
+		u8 mipi_bridge_type;				/* 171 */
+	} __packed;
+
+	u16 extended_type;
 	u8 dvo_function;
+	/* u8 flags2;						 195 */
+	/* u8 dp_gpio_index;					 195 */
+	/* u16 dp_gpio_pin_num;					 195 */
+	/* u8 iboost_level;					 196 */
 } __packed;
 
 struct vbt {
@@ -178,7 +214,7 @@  static void virt_vbt_generation(struct vbt *v)
 	v->child0.device_type = DEVICE_TYPE_DP;
 	v->child0.dvo_port = DVO_PORT_DPA;
 	v->child0.aux_channel = DP_AUX_A;
-	v->child0.dp_compat = true;
+	v->child0.dp_support = true;
 	v->child0.integrated_encoder = true;
 
 	/* portB */
@@ -186,7 +222,7 @@  static void virt_vbt_generation(struct vbt *v)
 	v->child1.device_type = DEVICE_TYPE_DP;
 	v->child1.dvo_port = DVO_PORT_DPB;
 	v->child1.aux_channel = DP_AUX_B;
-	v->child1.dp_compat = true;
+	v->child1.dp_support = true;
 	v->child1.integrated_encoder = true;
 
 	/* portC */
@@ -194,7 +230,7 @@  static void virt_vbt_generation(struct vbt *v)
 	v->child2.device_type = DEVICE_TYPE_DP;
 	v->child2.dvo_port = DVO_PORT_DPC;
 	v->child2.aux_channel = DP_AUX_C;
-	v->child2.dp_compat = true;
+	v->child2.dp_support = true;
 	v->child2.integrated_encoder = true;
 
 	/* portD */
@@ -202,7 +238,7 @@  static void virt_vbt_generation(struct vbt *v)
 	v->child3.device_type = DEVICE_TYPE_DP;
 	v->child3.dvo_port = DVO_PORT_DPD;
 	v->child3.aux_channel = DP_AUX_D;
-	v->child3.dp_compat = true;
+	v->child3.dp_support = true;
 	v->child3.integrated_encoder = true;
 
 	/* driver features */

Comments


looks good for me.
Reviewed-by: Xiaolin Zhang <xiaolin.zhang@intel.com>

On 09/04/2018 02:20 PM, Weinan Li wrote:
> GVT-g emulate opregion for VM with self-defined child_device_config,
> here refine it to align with the graphics driver, and remove the unused
> fields.
>
> Signed-off-by: Weinan Li <weinan.z.li@intel.com>
> ---
>  drivers/gpu/drm/i915/gvt/opregion.c | 124 +++++++++++++++++++++++-------------
>  1 file changed, 80 insertions(+), 44 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gvt/opregion.c b/drivers/gpu/drm/i915/gvt/opregion.c
> index 276db53..5895869 100644
> --- a/drivers/gpu/drm/i915/gvt/opregion.c
> +++ b/drivers/gpu/drm/i915/gvt/opregion.c
> @@ -63,54 +63,90 @@ struct bdb_data_header {
>  
>  /* 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'.
> + * length should be '33' but not '38'. Define one new struct named as
> + * efp_child_device_config which is one copy of child_device_config but
> + * without fields which added from version '195'.
>   */
>  struct efp_child_device_config {
>  	u16 handle;
>  	u16 device_type;
> -	u16 device_class;
> -	u8 i2c_speed;
> -	u8 dp_onboard_redriver; /* 158 */
> -	u8 dp_ondock_redriver; /* 158 */
> -	u8 hdmi_level_shifter_value:4; /* 169 */
> -	u8 hdmi_max_data_rate:4; /* 204 */
> -	u16 dtd_buf_ptr; /* 161 */
> -	u8 edidless_efp:1; /* 161 */
> -	u8 compression_enable:1; /* 198 */
> -	u8 compression_method:1; /* 198 */
> -	u8 ganged_edp:1; /* 202 */
> -	u8 skip0:4;
> -	u8 compression_structure_index:4; /* 198 */
> -	u8 skip1:4;
> -	u8 slave_port; /*  202 */
> -	u8 skip2;
> +
> +	union {
> +		u8  device_id[10]; /* ascii string */
> +		struct {
> +			u8 i2c_speed;
> +			u8 dp_onboard_redriver;			/* 158 */
> +			u8 dp_ondock_redriver;			/* 158 */
> +			u8 hdmi_level_shifter_value:4;		/* 169 */
> +			u8 hdmi_max_data_rate:4;		/* 204 */
> +			u16 dtd_buf_ptr;			/* 161 */
> +			u8 edidless_efp:1;			/* 161 */
> +			u8 compression_enable:1;		/* 198 */
> +			u8 compression_method:1;		/* 198 */
> +			u8 ganged_edp:1;			/* 202 */
> +			u8 reserved0:4;
> +			u8 compression_structure_index:4;	/* 198 */
> +			u8 reserved1:4;
> +			u8 slave_port;				/* 202 */
> +			u8 reserved2;
> +		} __packed;
> +	} __packed;
> +
> +	u16 addin_offset;
>  	u8 dvo_port;
> -	u8 i2c_pin; /* for add-in card */
> -	u8 slave_addr; /* for add-in card */
> +	u8 i2c_pin;
> +	u8 slave_addr;
>  	u8 ddc_pin;
>  	u16 edid_ptr;
> -	u8 dvo_config;
> -	u8 efp_docked_port:1; /* 158 */
> -	u8 lane_reversal:1; /* 184 */
> -	u8 onboard_lspcon:1; /* 192 */
> -	u8 iboost_enable:1; /* 196 */
> -	u8 hpd_invert:1; /* BXT 196 */
> -	u8 slip3:3;
> -	u8 hdmi_compat:1;
> -	u8 dp_compat:1;
> -	u8 tmds_compat:1;
> -	u8 skip4:5;
> -	u8 aux_channel;
> -	u8 dongle_detect;
> -	u8 pipe_cap:2;
> -	u8 sdvo_stall:1; /* 158 */
> -	u8 hpd_status:2;
> -	u8 integrated_encoder:1;
> -	u8 skip5:2;
> -	u8 dvo_wiring;
> -	u8 mipi_bridge_type; /* 171 */
> -	u16 device_class_ext;
> +	u8 dvo_cfg; /* See DEVICE_CFG_* above */
> +
> +	union {
> +		struct {
> +			u8 dvo2_port;
> +			u8 i2c2_pin;
> +			u8 slave2_addr;
> +			u8 ddc2_pin;
> +		} __packed;
> +		struct {
> +			u8 efp_routed:1;			/* 158 */
> +			u8 lane_reversal:1;			/* 184 */
> +			u8 lspcon:1;				/* 192 */
> +			u8 iboost:1;				/* 196 */
> +			u8 hpd_invert:1;			/* 196 */
> +			u8 flag_reserved:3;
> +			u8 hdmi_support:1;			/* 158 */
> +			u8 dp_support:1;			/* 158 */
> +			u8 tmds_support:1;			/* 158 */
> +			u8 support_reserved:5;
> +			u8 aux_channel;
> +			u8 dongle_detect;
> +		} __packed;
> +	} __packed;
> +
> +	union {
> +		u8 capabilities;
> +		struct {
> +			u8 pipe_cap:2;
> +			u8 sdvo_stall:1;
> +			u8 hpd_status:2;
> +			u8 integrated_encoder:1;		/* 158 */
> +			u8 skip5:2;
> +		} __packed;
> +	} __packed;
> +
> +	u8 dvo_wiring; /* See DEVICE_WIRE_* above */
> +
> +	union {
> +		u8 dvo2_wiring;
> +		u8 mipi_bridge_type;				/* 171 */
> +	} __packed;
> +
> +	u16 extended_type;
>  	u8 dvo_function;
> +	/* u8 flags2;						 195 */
> +	/* u8 dp_gpio_index;					 195 */
> +	/* u16 dp_gpio_pin_num;					 195 */
> +	/* u8 iboost_level;					 196 */
>  } __packed;
>  
>  struct vbt {
> @@ -178,7 +214,7 @@ static void virt_vbt_generation(struct vbt *v)
>  	v->child0.device_type = DEVICE_TYPE_DP;
>  	v->child0.dvo_port = DVO_PORT_DPA;
>  	v->child0.aux_channel = DP_AUX_A;
> -	v->child0.dp_compat = true;
> +	v->child0.dp_support = true;
>  	v->child0.integrated_encoder = true;
>  
>  	/* portB */
> @@ -186,7 +222,7 @@ static void virt_vbt_generation(struct vbt *v)
>  	v->child1.device_type = DEVICE_TYPE_DP;
>  	v->child1.dvo_port = DVO_PORT_DPB;
>  	v->child1.aux_channel = DP_AUX_B;
> -	v->child1.dp_compat = true;
> +	v->child1.dp_support = true;
>  	v->child1.integrated_encoder = true;
>  
>  	/* portC */
> @@ -194,7 +230,7 @@ static void virt_vbt_generation(struct vbt *v)
>  	v->child2.device_type = DEVICE_TYPE_DP;
>  	v->child2.dvo_port = DVO_PORT_DPC;
>  	v->child2.aux_channel = DP_AUX_C;
> -	v->child2.dp_compat = true;
> +	v->child2.dp_support = true;
>  	v->child2.integrated_encoder = true;
>  
>  	/* portD */
> @@ -202,7 +238,7 @@ static void virt_vbt_generation(struct vbt *v)
>  	v->child3.device_type = DEVICE_TYPE_DP;
>  	v->child3.dvo_port = DVO_PORT_DPD;
>  	v->child3.aux_channel = DP_AUX_D;
> -	v->child3.dp_compat = true;
> +	v->child3.dp_support = true;
>  	v->child3.integrated_encoder = true;
>  
>  	/* driver features */