hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/gpu/drm/i915/gvt/edid.c
....@@ -77,16 +77,32 @@
7777 return chr;
7878 }
7979
80
+static inline int cnp_get_port_from_gmbus0(u32 gmbus0)
81
+{
82
+ int port_select = gmbus0 & _GMBUS_PIN_SEL_MASK;
83
+ int port = -EINVAL;
84
+
85
+ if (port_select == GMBUS_PIN_1_BXT)
86
+ port = PORT_B;
87
+ else if (port_select == GMBUS_PIN_2_BXT)
88
+ port = PORT_C;
89
+ else if (port_select == GMBUS_PIN_3_BXT)
90
+ port = PORT_D;
91
+ else if (port_select == GMBUS_PIN_4_CNP)
92
+ port = PORT_E;
93
+ return port;
94
+}
95
+
8096 static inline int bxt_get_port_from_gmbus0(u32 gmbus0)
8197 {
8298 int port_select = gmbus0 & _GMBUS_PIN_SEL_MASK;
8399 int port = -EINVAL;
84100
85
- if (port_select == 1)
101
+ if (port_select == GMBUS_PIN_1_BXT)
86102 port = PORT_B;
87
- else if (port_select == 2)
103
+ else if (port_select == GMBUS_PIN_2_BXT)
88104 port = PORT_C;
89
- else if (port_select == 3)
105
+ else if (port_select == GMBUS_PIN_3_BXT)
90106 port = PORT_D;
91107 return port;
92108 }
....@@ -96,13 +112,13 @@
96112 int port_select = gmbus0 & _GMBUS_PIN_SEL_MASK;
97113 int port = -EINVAL;
98114
99
- if (port_select == 2)
115
+ if (port_select == GMBUS_PIN_VGADDC)
100116 port = PORT_E;
101
- else if (port_select == 4)
117
+ else if (port_select == GMBUS_PIN_DPC)
102118 port = PORT_C;
103
- else if (port_select == 5)
119
+ else if (port_select == GMBUS_PIN_DPB)
104120 port = PORT_B;
105
- else if (port_select == 6)
121
+ else if (port_select == GMBUS_PIN_DPD)
106122 port = PORT_D;
107123 return port;
108124 }
....@@ -119,7 +135,7 @@
119135 static int gmbus0_mmio_write(struct intel_vgpu *vgpu,
120136 unsigned int offset, void *p_data, unsigned int bytes)
121137 {
122
- struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
138
+ struct drm_i915_private *i915 = vgpu->gvt->gt->i915;
123139 int port, pin_select;
124140
125141 memcpy(&vgpu_vreg(vgpu, offset), p_data, bytes);
....@@ -131,11 +147,13 @@
131147 if (pin_select == 0)
132148 return 0;
133149
134
- if (IS_BROXTON(dev_priv))
150
+ if (IS_BROXTON(i915))
135151 port = bxt_get_port_from_gmbus0(pin_select);
152
+ else if (IS_COFFEELAKE(i915) || IS_COMETLAKE(i915))
153
+ port = cnp_get_port_from_gmbus0(pin_select);
136154 else
137155 port = get_port_from_gmbus0(pin_select);
138
- if (WARN_ON(port < 0))
156
+ if (drm_WARN_ON(&i915->drm, port < 0))
139157 return 0;
140158
141159 vgpu->display.i2c_edid.state = I2C_GMBUS;
....@@ -258,7 +276,9 @@
258276 static int gmbus3_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
259277 void *p_data, unsigned int bytes)
260278 {
261
- WARN_ON(1);
279
+ struct drm_i915_private *i915 = vgpu->gvt->gt->i915;
280
+
281
+ drm_WARN_ON(&i915->drm, 1);
262282 return 0;
263283 }
264284
....@@ -340,6 +360,9 @@
340360 /**
341361 * intel_gvt_i2c_handle_gmbus_read - emulate gmbus register mmio read
342362 * @vgpu: a vGPU
363
+ * @offset: reg offset
364
+ * @p_data: data return buffer
365
+ * @bytes: access data length
343366 *
344367 * This function is used to emulate gmbus register mmio read
345368 *
....@@ -350,7 +373,9 @@
350373 int intel_gvt_i2c_handle_gmbus_read(struct intel_vgpu *vgpu,
351374 unsigned int offset, void *p_data, unsigned int bytes)
352375 {
353
- if (WARN_ON(bytes > 8 && (offset & (bytes - 1))))
376
+ struct drm_i915_private *i915 = vgpu->gvt->gt->i915;
377
+
378
+ if (drm_WARN_ON(&i915->drm, bytes > 8 && (offset & (bytes - 1))))
354379 return -EINVAL;
355380
356381 if (offset == i915_mmio_reg_offset(PCH_GMBUS2))
....@@ -365,6 +390,9 @@
365390 /**
366391 * intel_gvt_i2c_handle_gmbus_write - emulate gmbus register mmio write
367392 * @vgpu: a vGPU
393
+ * @offset: reg offset
394
+ * @p_data: data return buffer
395
+ * @bytes: access data length
368396 *
369397 * This function is used to emulate gmbus register mmio write
370398 *
....@@ -375,7 +403,9 @@
375403 int intel_gvt_i2c_handle_gmbus_write(struct intel_vgpu *vgpu,
376404 unsigned int offset, void *p_data, unsigned int bytes)
377405 {
378
- if (WARN_ON(bytes > 8 && (offset & (bytes - 1))))
406
+ struct drm_i915_private *i915 = vgpu->gvt->gt->i915;
407
+
408
+ if (drm_WARN_ON(&i915->drm, bytes > 8 && (offset & (bytes - 1))))
379409 return -EINVAL;
380410
381411 if (offset == i915_mmio_reg_offset(PCH_GMBUS0))
....@@ -437,6 +467,9 @@
437467 /**
438468 * intel_gvt_i2c_handle_aux_ch_write - emulate AUX channel register write
439469 * @vgpu: a vGPU
470
+ * @port_idx: port index
471
+ * @offset: reg offset
472
+ * @p_data: write ptr
440473 *
441474 * This function is used to emulate AUX channel register write
442475 *
....@@ -446,6 +479,7 @@
446479 unsigned int offset,
447480 void *p_data)
448481 {
482
+ struct drm_i915_private *i915 = vgpu->gvt->gt->i915;
449483 struct intel_vgpu_i2c_edid *i2c_edid = &vgpu->display.i2c_edid;
450484 int msg_length, ret_msg_size;
451485 int msg, addr, ctrl, op;
....@@ -505,9 +539,9 @@
505539 * support the gfx driver to do EDID access.
506540 */
507541 } else {
508
- if (WARN_ON((op & 0x1) != GVT_AUX_I2C_READ))
542
+ if (drm_WARN_ON(&i915->drm, (op & 0x1) != GVT_AUX_I2C_READ))
509543 return;
510
- if (WARN_ON(msg_length != 4))
544
+ if (drm_WARN_ON(&i915->drm, msg_length != 4))
511545 return;
512546 if (i2c_edid->edid_available && i2c_edid->slave_selected) {
513547 unsigned char val = edid_get_byte(vgpu);