Skip to content

Commit ada7339

Browse files
committed
Merge tag 'drm-fixes-for-v4.17-rc8' of git://people.freedesktop.org/~airlied/linux
Pull drm fixes from Dave Airlie: "A few final fixes: i915: - fix for potential Spectre vector in the new query uAPI - fix NULL pointer deref (FDO #106559) - DMI fix to hide LVDS for Radiant P845 (FDO #105468) amdgpu: - suspend/resume DC regression fix - underscan flicker fix on fiji - gamma setting fix after dpms omap: - fix oops regression core: - fix PSR timing dw-hdmi: - fix oops regression" * tag 'drm-fixes-for-v4.17-rc8' of git://people.freedesktop.org/~airlied/linux: drm/amd/display: Update color props when modeset is required drm/amd/display: Make atomic-check validate underscan changes drm/bridge/synopsys: dw-hdmi: fix dw_hdmi_setup_rx_sense drm/amd/display: Fix BUG_ON during CRTC atomic check update drm/i915/query: nospec expects no more than an unsigned long drm/i915/query: Protect tainted function pointer lookup drm/i915/lvds: Move acpi lid notification registration to registration phase drm/i915: Disable LVDS on Radiant P845 drm/omap: fix NULL deref crash with SDI displays drm/psr: Fix missed entry in PSR setup time table.
2 parents 4277e6b + 012cfac commit ada7339

File tree

8 files changed

+91
-44
lines changed

8 files changed

+91
-44
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4555,8 +4555,8 @@ static int dm_update_crtcs_state(struct dc *dc,
45554555
for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
45564556
struct amdgpu_crtc *acrtc = NULL;
45574557
struct amdgpu_dm_connector *aconnector = NULL;
4558-
struct drm_connector_state *new_con_state = NULL;
4559-
struct dm_connector_state *dm_conn_state = NULL;
4558+
struct drm_connector_state *drm_new_conn_state = NULL, *drm_old_conn_state = NULL;
4559+
struct dm_connector_state *dm_new_conn_state = NULL, *dm_old_conn_state = NULL;
45604560
struct drm_plane_state *new_plane_state = NULL;
45614561

45624562
new_stream = NULL;
@@ -4577,19 +4577,23 @@ static int dm_update_crtcs_state(struct dc *dc,
45774577
/* TODO This hack should go away */
45784578
if (aconnector && enable) {
45794579
// Make sure fake sink is created in plug-in scenario
4580-
new_con_state = drm_atomic_get_connector_state(state,
4580+
drm_new_conn_state = drm_atomic_get_new_connector_state(state,
45814581
&aconnector->base);
4582+
drm_old_conn_state = drm_atomic_get_old_connector_state(state,
4583+
&aconnector->base);
45824584

4583-
if (IS_ERR(new_con_state)) {
4584-
ret = PTR_ERR_OR_ZERO(new_con_state);
4585+
4586+
if (IS_ERR(drm_new_conn_state)) {
4587+
ret = PTR_ERR_OR_ZERO(drm_new_conn_state);
45854588
break;
45864589
}
45874590

4588-
dm_conn_state = to_dm_connector_state(new_con_state);
4591+
dm_new_conn_state = to_dm_connector_state(drm_new_conn_state);
4592+
dm_old_conn_state = to_dm_connector_state(drm_old_conn_state);
45894593

45904594
new_stream = create_stream_for_sink(aconnector,
45914595
&new_crtc_state->mode,
4592-
dm_conn_state);
4596+
dm_new_conn_state);
45934597

45944598
/*
45954599
* we can have no stream on ACTION_SET if a display
@@ -4695,20 +4699,30 @@ static int dm_update_crtcs_state(struct dc *dc,
46954699
* We want to do dc stream updates that do not require a
46964700
* full modeset below.
46974701
*/
4698-
if (!enable || !aconnector || modereset_required(new_crtc_state))
4702+
if (!(enable && aconnector && new_crtc_state->enable &&
4703+
new_crtc_state->active))
46994704
continue;
47004705
/*
47014706
* Given above conditions, the dc state cannot be NULL because:
4702-
* 1. We're attempting to enable a CRTC. Which has a...
4703-
* 2. Valid connector attached, and
4704-
* 3. User does not want to reset it (disable or mark inactive,
4705-
* which can happen on a CRTC that's already disabled).
4706-
* => It currently exists.
4707+
* 1. We're in the process of enabling CRTCs (just been added
4708+
* to the dc context, or already is on the context)
4709+
* 2. Has a valid connector attached, and
4710+
* 3. Is currently active and enabled.
4711+
* => The dc stream state currently exists.
47074712
*/
47084713
BUG_ON(dm_new_crtc_state->stream == NULL);
47094714

4710-
/* Color managment settings */
4711-
if (dm_new_crtc_state->base.color_mgmt_changed) {
4715+
/* Scaling or underscan settings */
4716+
if (is_scaling_state_different(dm_old_conn_state, dm_new_conn_state))
4717+
update_stream_scaling_settings(
4718+
&new_crtc_state->mode, dm_new_conn_state, dm_new_crtc_state->stream);
4719+
4720+
/*
4721+
* Color management settings. We also update color properties
4722+
* when a modeset is needed, to ensure it gets reprogrammed.
4723+
*/
4724+
if (dm_new_crtc_state->base.color_mgmt_changed ||
4725+
drm_atomic_crtc_needs_modeset(new_crtc_state)) {
47124726
ret = amdgpu_dm_set_regamma_lut(dm_new_crtc_state);
47134727
if (ret)
47144728
goto fail;

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,7 +2077,7 @@ static irqreturn_t dw_hdmi_hardirq(int irq, void *dev_id)
20772077
return ret;
20782078
}
20792079

2080-
void __dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense)
2080+
void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense)
20812081
{
20822082
mutex_lock(&hdmi->mutex);
20832083

@@ -2103,13 +2103,6 @@ void __dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense)
21032103
}
21042104
mutex_unlock(&hdmi->mutex);
21052105
}
2106-
2107-
void dw_hdmi_setup_rx_sense(struct device *dev, bool hpd, bool rx_sense)
2108-
{
2109-
struct dw_hdmi *hdmi = dev_get_drvdata(dev);
2110-
2111-
__dw_hdmi_setup_rx_sense(hdmi, hpd, rx_sense);
2112-
}
21132106
EXPORT_SYMBOL_GPL(dw_hdmi_setup_rx_sense);
21142107

21152108
static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)
@@ -2145,9 +2138,9 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)
21452138
*/
21462139
if (intr_stat &
21472140
(HDMI_IH_PHY_STAT0_RX_SENSE | HDMI_IH_PHY_STAT0_HPD)) {
2148-
__dw_hdmi_setup_rx_sense(hdmi,
2149-
phy_stat & HDMI_PHY_HPD,
2150-
phy_stat & HDMI_PHY_RX_SENSE);
2141+
dw_hdmi_setup_rx_sense(hdmi,
2142+
phy_stat & HDMI_PHY_HPD,
2143+
phy_stat & HDMI_PHY_RX_SENSE);
21512144

21522145
if ((phy_stat & (HDMI_PHY_RX_SENSE | HDMI_PHY_HPD)) == 0)
21532146
cec_notifier_set_phys_addr(hdmi->cec_notifier,

drivers/gpu/drm/drm_dp_helper.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,7 @@ int drm_dp_psr_setup_time(const u8 psr_cap[EDP_PSR_RECEIVER_CAP_SIZE])
11451145
static const u16 psr_setup_time_us[] = {
11461146
PSR_SETUP_TIME(330),
11471147
PSR_SETUP_TIME(275),
1148+
PSR_SETUP_TIME(220),
11481149
PSR_SETUP_TIME(165),
11491150
PSR_SETUP_TIME(110),
11501151
PSR_SETUP_TIME(55),

drivers/gpu/drm/i915/i915_query.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* Copyright © 2018 Intel Corporation
55
*/
66

7+
#include <linux/nospec.h>
8+
79
#include "i915_drv.h"
810
#include "i915_query.h"
911
#include <uapi/drm/i915_drm.h>
@@ -100,7 +102,7 @@ int i915_query_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
100102

101103
for (i = 0; i < args->num_items; i++, user_item_ptr++) {
102104
struct drm_i915_query_item item;
103-
u64 func_idx;
105+
unsigned long func_idx;
104106
int ret;
105107

106108
if (copy_from_user(&item, user_item_ptr, sizeof(item)))
@@ -109,12 +111,17 @@ int i915_query_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
109111
if (item.query_id == 0)
110112
return -EINVAL;
111113

114+
if (overflows_type(item.query_id - 1, unsigned long))
115+
return -EINVAL;
116+
112117
func_idx = item.query_id - 1;
113118

114-
if (func_idx < ARRAY_SIZE(i915_query_funcs))
119+
ret = -EINVAL;
120+
if (func_idx < ARRAY_SIZE(i915_query_funcs)) {
121+
func_idx = array_index_nospec(func_idx,
122+
ARRAY_SIZE(i915_query_funcs));
115123
ret = i915_query_funcs[func_idx](dev_priv, &item);
116-
else
117-
ret = -EINVAL;
124+
}
118125

119126
/* Only write the length back to userspace if they differ. */
120127
if (ret != item.length && put_user(ret, &user_item_ptr->length))

drivers/gpu/drm/i915/intel_lvds.c

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,36 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
574574
return NOTIFY_OK;
575575
}
576576

577+
static int
578+
intel_lvds_connector_register(struct drm_connector *connector)
579+
{
580+
struct intel_lvds_connector *lvds = to_lvds_connector(connector);
581+
int ret;
582+
583+
ret = intel_connector_register(connector);
584+
if (ret)
585+
return ret;
586+
587+
lvds->lid_notifier.notifier_call = intel_lid_notify;
588+
if (acpi_lid_notifier_register(&lvds->lid_notifier)) {
589+
DRM_DEBUG_KMS("lid notifier registration failed\n");
590+
lvds->lid_notifier.notifier_call = NULL;
591+
}
592+
593+
return 0;
594+
}
595+
596+
static void
597+
intel_lvds_connector_unregister(struct drm_connector *connector)
598+
{
599+
struct intel_lvds_connector *lvds = to_lvds_connector(connector);
600+
601+
if (lvds->lid_notifier.notifier_call)
602+
acpi_lid_notifier_unregister(&lvds->lid_notifier);
603+
604+
intel_connector_unregister(connector);
605+
}
606+
577607
/**
578608
* intel_lvds_destroy - unregister and free LVDS structures
579609
* @connector: connector to free
@@ -586,9 +616,6 @@ static void intel_lvds_destroy(struct drm_connector *connector)
586616
struct intel_lvds_connector *lvds_connector =
587617
to_lvds_connector(connector);
588618

589-
if (lvds_connector->lid_notifier.notifier_call)
590-
acpi_lid_notifier_unregister(&lvds_connector->lid_notifier);
591-
592619
if (!IS_ERR_OR_NULL(lvds_connector->base.edid))
593620
kfree(lvds_connector->base.edid);
594621

@@ -609,8 +636,8 @@ static const struct drm_connector_funcs intel_lvds_connector_funcs = {
609636
.fill_modes = drm_helper_probe_single_connector_modes,
610637
.atomic_get_property = intel_digital_connector_atomic_get_property,
611638
.atomic_set_property = intel_digital_connector_atomic_set_property,
612-
.late_register = intel_connector_register,
613-
.early_unregister = intel_connector_unregister,
639+
.late_register = intel_lvds_connector_register,
640+
.early_unregister = intel_lvds_connector_unregister,
614641
.destroy = intel_lvds_destroy,
615642
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
616643
.atomic_duplicate_state = intel_digital_connector_duplicate_state,
@@ -827,6 +854,14 @@ static const struct dmi_system_id intel_no_lvds[] = {
827854
DMI_EXACT_MATCH(DMI_BOARD_NAME, "D525MW"),
828855
},
829856
},
857+
{
858+
.callback = intel_no_lvds_dmi_callback,
859+
.ident = "Radiant P845",
860+
.matches = {
861+
DMI_MATCH(DMI_SYS_VENDOR, "Radiant Systems Inc"),
862+
DMI_MATCH(DMI_PRODUCT_NAME, "P845"),
863+
},
864+
},
830865

831866
{ } /* terminating entry */
832867
};
@@ -1150,12 +1185,6 @@ void intel_lvds_init(struct drm_i915_private *dev_priv)
11501185

11511186
lvds_encoder->a3_power = lvds & LVDS_A3_POWER_MASK;
11521187

1153-
lvds_connector->lid_notifier.notifier_call = intel_lid_notify;
1154-
if (acpi_lid_notifier_register(&lvds_connector->lid_notifier)) {
1155-
DRM_DEBUG_KMS("lid notifier registration failed\n");
1156-
lvds_connector->lid_notifier.notifier_call = NULL;
1157-
}
1158-
11591188
return;
11601189

11611190
failed:

drivers/gpu/drm/meson/meson_dw_hdmi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ static irqreturn_t dw_hdmi_top_thread_irq(int irq, void *dev_id)
529529
if (stat & HDMITX_TOP_INTR_HPD_RISE)
530530
hpd_connected = true;
531531

532-
dw_hdmi_setup_rx_sense(dw_hdmi->dev, hpd_connected,
532+
dw_hdmi_setup_rx_sense(dw_hdmi->hdmi, hpd_connected,
533533
hpd_connected);
534534

535535
drm_helper_hpd_irq_event(dw_hdmi->encoder.dev);

drivers/gpu/drm/omapdrm/dss/sdi.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int sdi_calc_clock_div(struct sdi_device *sdi, unsigned long pclk,
8282
struct dispc_clock_info *dispc_cinfo)
8383
{
8484
int i;
85-
struct sdi_clk_calc_ctx ctx = { .sdi = sdi };
85+
struct sdi_clk_calc_ctx ctx;
8686

8787
/*
8888
* DSS fclk gives us very few possibilities, so finding a good pixel
@@ -95,6 +95,9 @@ static int sdi_calc_clock_div(struct sdi_device *sdi, unsigned long pclk,
9595
bool ok;
9696

9797
memset(&ctx, 0, sizeof(ctx));
98+
99+
ctx.sdi = sdi;
100+
98101
if (pclk > 1000 * i * i * i)
99102
ctx.pck_min = max(pclk - 1000 * i * i * i, 0lu);
100103
else

include/drm/bridge/dw_hdmi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ struct dw_hdmi *dw_hdmi_bind(struct platform_device *pdev,
151151
struct drm_encoder *encoder,
152152
const struct dw_hdmi_plat_data *plat_data);
153153

154-
void dw_hdmi_setup_rx_sense(struct device *dev, bool hpd, bool rx_sense);
154+
void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense);
155155

156156
void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate);
157157
void dw_hdmi_audio_enable(struct dw_hdmi *hdmi);

0 commit comments

Comments
 (0)