Skip to content

Commit 5fa8813

Browse files
committed
Merge tag 'drm-misc-fixes-2022-11-17' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
drm-misc-fixes for v6.1-rc6: - Fix error handling in vc4_atomic_commit_tail() - Set bpc for logictechno panels. - Fix potential memory leak in drm_dev_init() - Fix potential null-ptr-deref in drm_vblank_destroy_worker() - Set lima's clkname corrrectly when regulator is missing. - Small amdgpu fix to gang submission. - Revert hiding unregistered connectors from userspace, as it breaks on DP-MST. - Add workaround for DP++ dual mode adaptors that don't support i2c subaddressing. Signed-off-by: Dave Airlie <[email protected]> From: Maarten Lankhorst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 094226a + 5954acb commit 5fa8813

File tree

9 files changed

+64
-44
lines changed

9 files changed

+64
-44
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ static int amdgpu_cs_p1_ib(struct amdgpu_cs_parser *p,
109109
return r;
110110

111111
++(num_ibs[r]);
112+
p->gang_leader_idx = r;
112113
return 0;
113114
}
114115

@@ -300,7 +301,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p,
300301
if (ret)
301302
goto free_all_kdata;
302303
}
303-
p->gang_leader = p->jobs[p->gang_size - 1];
304+
p->gang_leader = p->jobs[p->gang_leader_idx];
304305

305306
if (p->ctx->vram_lost_counter != p->gang_leader->vram_lost_counter) {
306307
ret = -ECANCELED;
@@ -1195,16 +1196,18 @@ static int amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)
11951196
return r;
11961197
}
11971198

1198-
for (i = 0; i < p->gang_size - 1; ++i) {
1199+
for (i = 0; i < p->gang_size; ++i) {
1200+
if (p->jobs[i] == leader)
1201+
continue;
1202+
11991203
r = amdgpu_sync_clone(&leader->sync, &p->jobs[i]->sync);
12001204
if (r)
12011205
return r;
12021206
}
12031207

1204-
r = amdgpu_ctx_wait_prev_fence(p->ctx, p->entities[p->gang_size - 1]);
1208+
r = amdgpu_ctx_wait_prev_fence(p->ctx, p->entities[p->gang_leader_idx]);
12051209
if (r && r != -ERESTARTSYS)
12061210
DRM_ERROR("amdgpu_ctx_wait_prev_fence failed.\n");
1207-
12081211
return r;
12091212
}
12101213

@@ -1238,9 +1241,12 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
12381241
for (i = 0; i < p->gang_size; ++i)
12391242
drm_sched_job_arm(&p->jobs[i]->base);
12401243

1241-
for (i = 0; i < (p->gang_size - 1); ++i) {
1244+
for (i = 0; i < p->gang_size; ++i) {
12421245
struct dma_fence *fence;
12431246

1247+
if (p->jobs[i] == leader)
1248+
continue;
1249+
12441250
fence = &p->jobs[i]->base.s_fence->scheduled;
12451251
r = amdgpu_sync_fence(&leader->sync, fence);
12461252
if (r)
@@ -1276,7 +1282,10 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
12761282
list_for_each_entry(e, &p->validated, tv.head) {
12771283

12781284
/* Everybody except for the gang leader uses READ */
1279-
for (i = 0; i < (p->gang_size - 1); ++i) {
1285+
for (i = 0; i < p->gang_size; ++i) {
1286+
if (p->jobs[i] == leader)
1287+
continue;
1288+
12801289
dma_resv_add_fence(e->tv.bo->base.resv,
12811290
&p->jobs[i]->base.s_fence->finished,
12821291
DMA_RESV_USAGE_READ);
@@ -1286,7 +1295,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
12861295
e->tv.num_shared = 0;
12871296
}
12881297

1289-
seq = amdgpu_ctx_add_fence(p->ctx, p->entities[p->gang_size - 1],
1298+
seq = amdgpu_ctx_add_fence(p->ctx, p->entities[p->gang_leader_idx],
12901299
p->fence);
12911300
amdgpu_cs_post_dependencies(p);
12921301

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct amdgpu_cs_parser {
5454

5555
/* scheduler job objects */
5656
unsigned int gang_size;
57+
unsigned int gang_leader_idx;
5758
struct drm_sched_entity *entities[AMDGPU_CS_GANG_SIZE];
5859
struct amdgpu_job *jobs[AMDGPU_CS_GANG_SIZE];
5960
struct amdgpu_job *gang_leader;

drivers/gpu/drm/display/drm_dp_dual_mode_helper.c

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,45 @@
6363
ssize_t drm_dp_dual_mode_read(struct i2c_adapter *adapter,
6464
u8 offset, void *buffer, size_t size)
6565
{
66+
u8 zero = 0;
67+
char *tmpbuf = NULL;
68+
/*
69+
* As sub-addressing is not supported by all adaptors,
70+
* always explicitly read from the start and discard
71+
* any bytes that come before the requested offset.
72+
* This way, no matter whether the adaptor supports it
73+
* or not, we'll end up reading the proper data.
74+
*/
6675
struct i2c_msg msgs[] = {
6776
{
6877
.addr = DP_DUAL_MODE_SLAVE_ADDRESS,
6978
.flags = 0,
7079
.len = 1,
71-
.buf = &offset,
80+
.buf = &zero,
7281
},
7382
{
7483
.addr = DP_DUAL_MODE_SLAVE_ADDRESS,
7584
.flags = I2C_M_RD,
76-
.len = size,
85+
.len = size + offset,
7786
.buf = buffer,
7887
},
7988
};
8089
int ret;
8190

91+
if (offset) {
92+
tmpbuf = kmalloc(size + offset, GFP_KERNEL);
93+
if (!tmpbuf)
94+
return -ENOMEM;
95+
96+
msgs[1].buf = tmpbuf;
97+
}
98+
8299
ret = i2c_transfer(adapter, msgs, ARRAY_SIZE(msgs));
100+
if (tmpbuf)
101+
memcpy(buffer, tmpbuf + offset, size);
102+
103+
kfree(tmpbuf);
104+
83105
if (ret < 0)
84106
return ret;
85107
if (ret != ARRAY_SIZE(msgs))
@@ -208,18 +230,6 @@ enum drm_dp_dual_mode_type drm_dp_dual_mode_detect(const struct drm_device *dev,
208230
if (ret)
209231
return DRM_DP_DUAL_MODE_UNKNOWN;
210232

211-
/*
212-
* Sigh. Some (maybe all?) type 1 adaptors are broken and ack
213-
* the offset but ignore it, and instead they just always return
214-
* data from the start of the HDMI ID buffer. So for a broken
215-
* type 1 HDMI adaptor a single byte read will always give us
216-
* 0x44, and for a type 1 DVI adaptor it should give 0x00
217-
* (assuming it implements any registers). Fortunately neither
218-
* of those values will match the type 2 signature of the
219-
* DP_DUAL_MODE_ADAPTOR_ID register so we can proceed with
220-
* the type 2 adaptor detection safely even in the presence
221-
* of broken type 1 adaptors.
222-
*/
223233
ret = drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_ADAPTOR_ID,
224234
&adaptor_id, sizeof(adaptor_id));
225235
drm_dbg_kms(dev, "DP dual mode adaptor ID: %02x (err %zd)\n", adaptor_id, ret);
@@ -233,11 +243,10 @@ enum drm_dp_dual_mode_type drm_dp_dual_mode_detect(const struct drm_device *dev,
233243
return DRM_DP_DUAL_MODE_TYPE2_DVI;
234244
}
235245
/*
236-
* If neither a proper type 1 ID nor a broken type 1 adaptor
237-
* as described above, assume type 1, but let the user know
238-
* that we may have misdetected the type.
246+
* If not a proper type 1 ID, still assume type 1, but let
247+
* the user know that we may have misdetected the type.
239248
*/
240-
if (!is_type1_adaptor(adaptor_id) && adaptor_id != hdmi_id[0])
249+
if (!is_type1_adaptor(adaptor_id))
241250
drm_err(dev, "Unexpected DP dual mode adaptor ID %02x\n", adaptor_id);
242251

243252
}
@@ -343,10 +352,8 @@ EXPORT_SYMBOL(drm_dp_dual_mode_get_tmds_output);
343352
* @enable: enable (as opposed to disable) the TMDS output buffers
344353
*
345354
* Set the state of the TMDS output buffers in the adaptor. For
346-
* type2 this is set via the DP_DUAL_MODE_TMDS_OEN register. As
347-
* some type 1 adaptors have problems with registers (see comments
348-
* in drm_dp_dual_mode_detect()) we avoid touching the register,
349-
* making this function a no-op on type 1 adaptors.
355+
* type2 this is set via the DP_DUAL_MODE_TMDS_OEN register.
356+
* Type1 adaptors do not support any register writes.
350357
*
351358
* Returns:
352359
* 0 on success, negative error code on failure

drivers/gpu/drm/drm_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ static int drm_dev_init(struct drm_device *dev,
615615
mutex_init(&dev->clientlist_mutex);
616616
mutex_init(&dev->master_mutex);
617617

618-
ret = drmm_add_action(dev, drm_dev_init_release, NULL);
618+
ret = drmm_add_action_or_reset(dev, drm_dev_init_release, NULL);
619619
if (ret)
620620
return ret;
621621

drivers/gpu/drm/drm_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ static inline void drm_vblank_flush_worker(struct drm_vblank_crtc *vblank)
104104

105105
static inline void drm_vblank_destroy_worker(struct drm_vblank_crtc *vblank)
106106
{
107-
kthread_destroy_worker(vblank->worker);
107+
if (vblank->worker)
108+
kthread_destroy_worker(vblank->worker);
108109
}
109110

110111
int drm_vblank_worker_init(struct drm_vblank_crtc *vblank);

drivers/gpu/drm/drm_mode_config.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
151151
count = 0;
152152
connector_id = u64_to_user_ptr(card_res->connector_id_ptr);
153153
drm_for_each_connector_iter(connector, &conn_iter) {
154-
if (connector->registration_state != DRM_CONNECTOR_REGISTERED)
155-
continue;
156-
157154
/* only expose writeback connectors if userspace understands them */
158155
if (!file_priv->writeback_connectors &&
159156
(connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK))

drivers/gpu/drm/lima/lima_devfreq.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,22 @@ int lima_devfreq_init(struct lima_device *ldev)
112112
unsigned long cur_freq;
113113
int ret;
114114
const char *regulator_names[] = { "mali", NULL };
115-
const char *clk_names[] = { "core", NULL };
116-
struct dev_pm_opp_config config = {
117-
.regulator_names = regulator_names,
118-
.clk_names = clk_names,
119-
};
120115

121116
if (!device_property_present(dev, "operating-points-v2"))
122117
/* Optional, continue without devfreq */
123118
return 0;
124119

125120
spin_lock_init(&ldevfreq->lock);
126121

127-
ret = devm_pm_opp_set_config(dev, &config);
122+
/*
123+
* clkname is set separately so it is not affected by the optional
124+
* regulator setting which may return error.
125+
*/
126+
ret = devm_pm_opp_set_clkname(dev, "core");
127+
if (ret)
128+
return ret;
129+
130+
ret = devm_pm_opp_set_regulators(dev, regulator_names);
128131
if (ret) {
129132
/* Continue if the optional regulator is missing */
130133
if (ret != -ENODEV)

drivers/gpu/drm/panel/panel-simple.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,6 +2500,7 @@ static const struct display_timing logictechno_lt161010_2nh_timing = {
25002500
static const struct panel_desc logictechno_lt161010_2nh = {
25012501
.timings = &logictechno_lt161010_2nh_timing,
25022502
.num_timings = 1,
2503+
.bpc = 6,
25032504
.size = {
25042505
.width = 154,
25052506
.height = 86,
@@ -2529,6 +2530,7 @@ static const struct display_timing logictechno_lt170410_2whc_timing = {
25292530
static const struct panel_desc logictechno_lt170410_2whc = {
25302531
.timings = &logictechno_lt170410_2whc_timing,
25312532
.num_timings = 1,
2533+
.bpc = 8,
25322534
.size = {
25332535
.width = 217,
25342536
.height = 136,

drivers/gpu/drm/vc4/vc4_kms.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ vc4_hvs_get_new_global_state(struct drm_atomic_state *state)
197197
struct drm_private_state *priv_state;
198198

199199
priv_state = drm_atomic_get_new_private_obj_state(state, &vc4->hvs_channels);
200-
if (IS_ERR(priv_state))
201-
return ERR_CAST(priv_state);
200+
if (!priv_state)
201+
return ERR_PTR(-EINVAL);
202202

203203
return to_vc4_hvs_state(priv_state);
204204
}
@@ -210,8 +210,8 @@ vc4_hvs_get_old_global_state(struct drm_atomic_state *state)
210210
struct drm_private_state *priv_state;
211211

212212
priv_state = drm_atomic_get_old_private_obj_state(state, &vc4->hvs_channels);
213-
if (IS_ERR(priv_state))
214-
return ERR_CAST(priv_state);
213+
if (!priv_state)
214+
return ERR_PTR(-EINVAL);
215215

216216
return to_vc4_hvs_state(priv_state);
217217
}

0 commit comments

Comments
 (0)