DragonFlyBSD Kernel Audit
DF-1558 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/amd/display/dc/dce/dce_link_encoder.c
+++ b/sys/dev/drm/amd/display/dc/dce/dce_link_encoder.c
@@ -1366,16 +1366,18 @@ void dce110_link_encoder_enable_hpd(struct link_encoder *enc)
 void dce110_link_encoder_enable_hpd(struct link_encoder *enc)
 {
 	struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
 	struct dc_context *ctx = enc110->base.ctx;
 	uint32_t addr = HPD_REG(DC_HPD_CONTROL);
-	uint32_t hpd_enable = 0;
 	uint32_t value = dm_read_reg(ctx, addr);

-	get_reg_field_value(hpd_enable, DC_HPD_CONTROL, DC_HPD_EN);
-
-	if (hpd_enable == 0)
-		set_reg_field_value(value, 1, DC_HPD_CONTROL, DC_HPD_EN);
+	/* Read the current DC_HPD_EN bit; if it is not already set, set it and
+	 * write the modified value back to hardware. */
+	if (((HPD0_DC_HPD_CONTROL__DC_HPD_EN_MASK & value) >>
+					HPD0_DC_HPD_CONTROL__DC_HPD_EN__SHIFT) == 0) {
+		set_reg_field_value(value, 1, DC_HPD_CONTROL, DC_HPD_EN);
+		dm_write_reg(ctx, addr, value);
+	}
 }

 void dce110_link_encoder_disable_hpd(struct link_encoder *enc)
 {
 	struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
 	struct dc_context *ctx = enc110->base.ctx;
 	uint32_t addr = HPD_REG(DC_HPD_CONTROL);
 	uint32_t value = dm_read_reg(ctx, addr);

 	set_reg_field_value(value, 0, DC_HPD_CONTROL, DC_HPD_EN);
+	dm_write_reg(ctx, addr, value);
 }