<div dir="auto"><p dir="ltr">Reviewed-by: Zhi Wang <<a href="mailto:zhiwang@kernel.org">zhiwang@kernel.org</a>></p><p dir="ltr"><br></p><p dir="ltr">Sorry for the late reply as I was on vacation. </p></div>
<br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 22, 2024, 2:50 PM Kandpal, Suraj <<a href="mailto:suraj.kandpal@intel.com" target="_blank" rel="noreferrer">suraj.kandpal@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> -----Original Message-----<br>
> From: Intel-gfx <<a href="mailto:intel-gfx-bounces@lists.freedesktop.org" rel="noreferrer noreferrer" target="_blank">intel-gfx-bounces@lists.freedesktop.org</a>> On Behalf Of Jani<br>
> Nikula<br>
> Sent: Monday, September 30, 2024 7:24 PM<br>
> To: <a href="mailto:intel-gfx@lists.freedesktop.org" rel="noreferrer noreferrer" target="_blank">intel-gfx@lists.freedesktop.org</a>; <a href="mailto:intel-gvt-dev@lists.freedesktop.org" rel="noreferrer noreferrer" target="_blank">intel-gvt-dev@lists.freedesktop.org</a><br>
> Cc: Nikula, Jani <<a href="mailto:jani.nikula@intel.com" rel="noreferrer noreferrer" target="_blank">jani.nikula@intel.com</a>><br>
> Subject: [RESEND] drm/i915/gvt: use macros from drm_dp.h instead of<br>
> duplication<br>
> <br>
> Use the existing macros in drm_dp.h for DPCD and DP AUX instead of<br>
> duplicating. Remove unused macros, as well as the duplicate definition of<br>
> DPCD_SIZE.<br>
> <br>
> AUX_NATIVE_REPLY_NAK is left unchanged, as it does not match<br>
> DP_AUX_NATIVE_REPLY_NACK, and I'm not sure what the right thing to do is<br>
> here.<br>
<br>
LGTM,<br>
Reviewed-by: Suraj Kandpal <<a href="mailto:suraj.kandpal@intel.com" rel="noreferrer noreferrer" target="_blank">suraj.kandpal@intel.com</a>><br>
<br>
> <br>
> Signed-off-by: Jani Nikula <<a href="mailto:jani.nikula@intel.com" rel="noreferrer noreferrer" target="_blank">jani.nikula@intel.com</a>><br>
> ---<br>
> drivers/gpu/drm/i915/gvt/display.c | 4 ++-<br>
> drivers/gpu/drm/i915/gvt/display.h | 42 ----------------------------<br>
> drivers/gpu/drm/i915/gvt/edid.c | 12 ++++----<br>
> drivers/gpu/drm/i915/gvt/edid.h | 8 ------<br>
> drivers/gpu/drm/i915/gvt/handlers.c | 43 +++++++++++++++++------------<br>
> 5 files changed, 36 insertions(+), 73 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/i915/gvt/display.c<br>
> b/drivers/gpu/drm/i915/gvt/display.c<br>
> index c66d6d3177c8..17f74cb244bb 100644<br>
> --- a/drivers/gpu/drm/i915/gvt/display.c<br>
> +++ b/drivers/gpu/drm/i915/gvt/display.c<br>
> @@ -32,6 +32,8 @@<br>
> *<br>
> */<br>
> <br>
> +#include <drm/display/drm_dp.h><br>
> +<br>
> #include "i915_drv.h"<br>
> #include "i915_reg.h"<br>
> #include "gvt.h"<br>
> @@ -568,7 +570,7 @@ static int setup_virtual_dp_monitor(struct intel_vgpu<br>
> *vgpu, int port_num,<br>
> <br>
> memcpy(port->dpcd->data, dpcd_fix_data, DPCD_HEADER_SIZE);<br>
> port->dpcd->data_valid = true;<br>
> - port->dpcd->data[DPCD_SINK_COUNT] = 0x1;<br>
> + port->dpcd->data[DP_SINK_COUNT] = 0x1;<br>
> port->type = type;<br>
> port->id = resolution;<br>
> port->vrefresh_k = GVT_DEFAULT_REFRESH_RATE * MSEC_PER_SEC;<br>
> diff --git a/drivers/gpu/drm/i915/gvt/display.h<br>
> b/drivers/gpu/drm/i915/gvt/display.h<br>
> index f5616f99ef2f..8090bc53c7e1 100644<br>
> --- a/drivers/gpu/drm/i915/gvt/display.h<br>
> +++ b/drivers/gpu/drm/i915/gvt/display.h<br>
> @@ -59,52 +59,10 @@ struct intel_vgpu;<br>
> <br>
> #define INTEL_GVT_MAX_UEVENT_VARS 3<br>
> <br>
> -/* DPCD start */<br>
> -#define DPCD_SIZE 0x700<br>
> -<br>
> -/* DPCD */<br>
> -#define DP_SET_POWER 0x600<br>
> -#define DP_SET_POWER_D0 0x1<br>
> -#define AUX_NATIVE_WRITE 0x8<br>
> -#define AUX_NATIVE_READ 0x9<br>
> -<br>
> -#define AUX_NATIVE_REPLY_MASK (0x3 << 4)<br>
> -#define AUX_NATIVE_REPLY_ACK (0x0 << 4)<br>
> #define AUX_NATIVE_REPLY_NAK (0x1 << 4)<br>
> -#define AUX_NATIVE_REPLY_DEFER (0x2 << 4)<br>
> <br>
> #define AUX_BURST_SIZE 20<br>
> <br>
> -/* DPCD addresses */<br>
> -#define DPCD_REV 0x000<br>
> -#define DPCD_MAX_LINK_RATE 0x001<br>
> -#define DPCD_MAX_LANE_COUNT 0x002<br>
> -<br>
> -#define DPCD_TRAINING_PATTERN_SET 0x102<br>
> -#define DPCD_SINK_COUNT 0x200<br>
> -#define DPCD_LANE0_1_STATUS 0x202<br>
> -#define DPCD_LANE2_3_STATUS 0x203<br>
> -#define DPCD_LANE_ALIGN_STATUS_UPDATED 0x204<br>
> -#define DPCD_SINK_STATUS 0x205<br>
> -<br>
> -/* link training */<br>
> -#define DPCD_TRAINING_PATTERN_SET_MASK 0x03<br>
> -#define DPCD_LINK_TRAINING_DISABLED 0x00<br>
> -#define DPCD_TRAINING_PATTERN_1 0x01<br>
> -#define DPCD_TRAINING_PATTERN_2 0x02<br>
> -<br>
> -#define DPCD_CP_READY_MASK (1 << 6)<br>
> -<br>
> -/* lane status */<br>
> -#define DPCD_LANES_CR_DONE 0x11<br>
> -#define DPCD_LANES_EQ_DONE 0x22<br>
> -#define DPCD_SYMBOL_LOCKED 0x44<br>
> -<br>
> -#define DPCD_INTERLANE_ALIGN_DONE 0x01<br>
> -<br>
> -#define DPCD_SINK_IN_SYNC 0x03<br>
> -/* DPCD end */<br>
> -<br>
> #define SBI_RESPONSE_MASK 0x3<br>
> #define SBI_RESPONSE_SHIFT 0x1<br>
> #define SBI_STAT_MASK 0x1<br>
> diff --git a/drivers/gpu/drm/i915/gvt/edid.c<br>
> b/drivers/gpu/drm/i915/gvt/edid.c index c022dc736045..0a357ca42db1<br>
> 100644<br>
> --- a/drivers/gpu/drm/i915/gvt/edid.c<br>
> +++ b/drivers/gpu/drm/i915/gvt/edid.c<br>
> @@ -32,6 +32,8 @@<br>
> *<br>
> */<br>
> <br>
> +#include <drm/display/drm_dp.h><br>
> +<br>
> #include "display/intel_dp_aux_regs.h"<br>
> #include "display/intel_gmbus_regs.h"<br>
> #include "gvt.h"<br>
> @@ -504,13 +506,13 @@ void intel_gvt_i2c_handle_aux_ch_write(struct<br>
> intel_vgpu *vgpu,<br>
> }<br>
> <br>
> /* Always set the wanted value for vms. */<br>
> - ret_msg_size = (((op & 0x1) == GVT_AUX_I2C_READ) ? 2 : 1);<br>
> + ret_msg_size = (((op & 0x1) == DP_AUX_I2C_READ) ? 2 : 1);<br>
> vgpu_vreg(vgpu, offset) =<br>
> DP_AUX_CH_CTL_DONE |<br>
> DP_AUX_CH_CTL_MESSAGE_SIZE(ret_msg_size);<br>
> <br>
> if (msg_length == 3) {<br>
> - if (!(op & GVT_AUX_I2C_MOT)) {<br>
> + if (!(op & DP_AUX_I2C_MOT)) {<br>
> /* stop */<br>
> intel_vgpu_init_i2c_edid(vgpu);<br>
> } else {<br>
> @@ -530,7 +532,7 @@ void intel_gvt_i2c_handle_aux_ch_write(struct<br>
> intel_vgpu *vgpu,<br>
> i2c_edid->edid_available = true;<br>
> }<br>
> }<br>
> - } else if ((op & 0x1) == GVT_AUX_I2C_WRITE) {<br>
> + } else if ((op & 0x1) == DP_AUX_I2C_WRITE) {<br>
> /* TODO<br>
> * We only support EDID reading from I2C_over_AUX. And<br>
> * we do not expect the index mode to be used. Right now<br>
> @@ -538,7 +540,7 @@ void intel_gvt_i2c_handle_aux_ch_write(struct<br>
> intel_vgpu *vgpu,<br>
> * support the gfx driver to do EDID access.<br>
> */<br>
> } else {<br>
> - if (drm_WARN_ON(&i915->drm, (op & 0x1) !=<br>
> GVT_AUX_I2C_READ))<br>
> + if (drm_WARN_ON(&i915->drm, (op & 0x1) !=<br>
> DP_AUX_I2C_READ))<br>
> return;<br>
> if (drm_WARN_ON(&i915->drm, msg_length != 4))<br>
> return;<br>
> @@ -553,7 +555,7 @@ void intel_gvt_i2c_handle_aux_ch_write(struct<br>
> intel_vgpu *vgpu,<br>
> * ACK of I2C_WRITE<br>
> * returned byte if it is READ<br>
> */<br>
> - aux_data_for_write |= GVT_AUX_I2C_REPLY_ACK << 24;<br>
> + aux_data_for_write |= DP_AUX_I2C_REPLY_ACK << 24;<br>
> vgpu_vreg(vgpu, offset + 4) = aux_data_for_write; }<br>
> <br>
> diff --git a/drivers/gpu/drm/i915/gvt/edid.h<br>
> b/drivers/gpu/drm/i915/gvt/edid.h index c3b5a55aecb3..13fd06590929<br>
> 100644<br>
> --- a/drivers/gpu/drm/i915/gvt/edid.h<br>
> +++ b/drivers/gpu/drm/i915/gvt/edid.h<br>
> @@ -42,14 +42,6 @@ struct intel_vgpu;<br>
> #define EDID_SIZE 128<br>
> #define EDID_ADDR 0x50 /* Linux hvm EDID addr */<br>
> <br>
> -#define GVT_AUX_NATIVE_WRITE 0x8<br>
> -#define GVT_AUX_NATIVE_READ 0x9<br>
> -#define GVT_AUX_I2C_WRITE 0x0<br>
> -#define GVT_AUX_I2C_READ 0x1<br>
> -#define GVT_AUX_I2C_STATUS 0x2<br>
> -#define GVT_AUX_I2C_MOT 0x4<br>
> -#define GVT_AUX_I2C_REPLY_ACK 0x0<br>
> -<br>
> struct intel_vgpu_edid_data {<br>
> bool data_valid;<br>
> unsigned char edid_block[EDID_SIZE];<br>
> diff --git a/drivers/gpu/drm/i915/gvt/handlers.c<br>
> b/drivers/gpu/drm/i915/gvt/handlers.c<br>
> index 0f09344d3c20..9494d812c00a 100644<br>
> --- a/drivers/gpu/drm/i915/gvt/handlers.c<br>
> +++ b/drivers/gpu/drm/i915/gvt/handlers.c<br>
> @@ -36,6 +36,8 @@<br>
> <br>
> */<br>
> <br>
> +#include <drm/display/drm_dp.h><br>
> +<br>
> #include "i915_drv.h"<br>
> #include "i915_reg.h"<br>
> #include "gvt.h"<br>
> @@ -1129,29 +1131,36 @@ static int dp_aux_ch_ctl_trans_done(struct<br>
> intel_vgpu *vgpu, u32 value, static void dp_aux_ch_ctl_link_training(struct<br>
> intel_vgpu_dpcd_data *dpcd,<br>
> u8 t)<br>
> {<br>
> - if ((t & DPCD_TRAINING_PATTERN_SET_MASK) ==<br>
> DPCD_TRAINING_PATTERN_1) {<br>
> + if ((t & DP_TRAINING_PATTERN_MASK) == DP_TRAINING_PATTERN_1)<br>
> {<br>
> /* training pattern 1 for CR */<br>
> /* set LANE0_CR_DONE, LANE1_CR_DONE */<br>
> - dpcd->data[DPCD_LANE0_1_STATUS] |=<br>
> DPCD_LANES_CR_DONE;<br>
> + dpcd->data[DP_LANE0_1_STATUS] |= DP_LANE_CR_DONE |<br>
> + DP_LANE_CR_DONE << 4;<br>
> /* set LANE2_CR_DONE, LANE3_CR_DONE */<br>
> - dpcd->data[DPCD_LANE2_3_STATUS] |=<br>
> DPCD_LANES_CR_DONE;<br>
> - } else if ((t & DPCD_TRAINING_PATTERN_SET_MASK) ==<br>
> - DPCD_TRAINING_PATTERN_2) {<br>
> + dpcd->data[DP_LANE2_3_STATUS] |= DP_LANE_CR_DONE |<br>
> + DP_LANE_CR_DONE << 4;<br>
> + } else if ((t & DP_TRAINING_PATTERN_MASK) ==<br>
> + DP_TRAINING_PATTERN_2) {<br>
> /* training pattern 2 for EQ */<br>
> /* Set CHANNEL_EQ_DONE and SYMBOL_LOCKED for<br>
> Lane0_1 */<br>
> - dpcd->data[DPCD_LANE0_1_STATUS] |=<br>
> DPCD_LANES_EQ_DONE;<br>
> - dpcd->data[DPCD_LANE0_1_STATUS] |=<br>
> DPCD_SYMBOL_LOCKED;<br>
> + dpcd->data[DP_LANE0_1_STATUS] |=<br>
> DP_LANE_CHANNEL_EQ_DONE |<br>
> + DP_LANE_CHANNEL_EQ_DONE << 4;<br>
> + dpcd->data[DP_LANE0_1_STATUS] |=<br>
> DP_LANE_SYMBOL_LOCKED |<br>
> + DP_LANE_SYMBOL_LOCKED << 4;<br>
> /* Set CHANNEL_EQ_DONE and SYMBOL_LOCKED for<br>
> Lane2_3 */<br>
> - dpcd->data[DPCD_LANE2_3_STATUS] |=<br>
> DPCD_LANES_EQ_DONE;<br>
> - dpcd->data[DPCD_LANE2_3_STATUS] |=<br>
> DPCD_SYMBOL_LOCKED;<br>
> + dpcd->data[DP_LANE2_3_STATUS] |=<br>
> DP_LANE_CHANNEL_EQ_DONE |<br>
> + DP_LANE_CHANNEL_EQ_DONE << 4;<br>
> + dpcd->data[DP_LANE2_3_STATUS] |=<br>
> DP_LANE_SYMBOL_LOCKED |<br>
> + DP_LANE_SYMBOL_LOCKED << 4;<br>
> /* set INTERLANE_ALIGN_DONE */<br>
> - dpcd->data[DPCD_LANE_ALIGN_STATUS_UPDATED] |=<br>
> - DPCD_INTERLANE_ALIGN_DONE;<br>
> - } else if ((t & DPCD_TRAINING_PATTERN_SET_MASK) ==<br>
> - DPCD_LINK_TRAINING_DISABLED) {<br>
> + dpcd->data[DP_LANE_ALIGN_STATUS_UPDATED] |=<br>
> + DP_INTERLANE_ALIGN_DONE;<br>
> + } else if ((t & DP_TRAINING_PATTERN_MASK) ==<br>
> + DP_TRAINING_PATTERN_DISABLE) {<br>
> /* finish link training */<br>
> /* set sink status as synchronized */<br>
> - dpcd->data[DPCD_SINK_STATUS] = DPCD_SINK_IN_SYNC;<br>
> + dpcd->data[DP_SINK_STATUS] = DP_RECEIVE_PORT_0_STATUS<br>
> |<br>
> + DP_RECEIVE_PORT_1_STATUS;<br>
> }<br>
> }<br>
> <br>
> @@ -1206,7 +1215,7 @@ static int dp_aux_ch_ctl_mmio_write(struct<br>
> intel_vgpu *vgpu,<br>
> len = msg & 0xff;<br>
> op = ctrl >> 4;<br>
> <br>
> - if (op == GVT_AUX_NATIVE_WRITE) {<br>
> + if (op == DP_AUX_NATIVE_WRITE) {<br>
> int t;<br>
> u8 buf[16];<br>
> <br>
> @@ -1252,7 +1261,7 @@ static int dp_aux_ch_ctl_mmio_write(struct<br>
> intel_vgpu *vgpu,<br>
> <br>
> dpcd->data[p] = buf[t];<br>
> /* check for link training */<br>
> - if (p == DPCD_TRAINING_PATTERN_SET)<br>
> + if (p == DP_TRAINING_PATTERN_SET)<br>
> dp_aux_ch_ctl_link_training(dpcd,<br>
> buf[t]);<br>
> }<br>
> @@ -1265,7 +1274,7 @@ static int dp_aux_ch_ctl_mmio_write(struct<br>
> intel_vgpu *vgpu,<br>
> return 0;<br>
> }<br>
> <br>
> - if (op == GVT_AUX_NATIVE_READ) {<br>
> + if (op == DP_AUX_NATIVE_READ) {<br>
> int idx, i, ret = 0;<br>
> <br>
> if ((addr + len + 1) >= DPCD_SIZE) {<br>
> --<br>
> 2.39.5<br>
<br>
</blockquote></div>