Skip to content

Commit 5493bf2

Browse files
committed
Merge tag 'drm-misc-fixes-2024-04-18' of https://gitlab.freedesktop.org/drm/misc/kernel into drm-fixes
Short summary of fixes pull: nouveau: - dp: Don't probe DP ports twice - nv04: Fix OOB access - nv50: Disable AUX bus for disconnected DP ports - nvkm: Fix race condition panel: - Don't unregister DSI devices in several drivers ttm: - Stop pooling cached NUMA pages v3d: - Fix enabled_ns increment vmwgfx: - Fix PRIME import/export - Fix CRTC's atomic check for primary planes - Sort plane formats by preference Signed-off-by: Dave Airlie <[email protected]> From: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 58292f5 + 941c0bd commit 5493bf2

17 files changed

+186
-57
lines changed

drivers/gpu/drm/nouveau/nouveau_bios.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424

2525
#include "nouveau_drv.h"
26+
#include "nouveau_bios.h"
2627
#include "nouveau_reg.h"
2728
#include "dispnv04/hw.h"
2829
#include "nouveau_encoder.h"
@@ -1677,7 +1678,7 @@ apply_dcb_encoder_quirks(struct drm_device *dev, int idx, u32 *conn, u32 *conf)
16771678
*/
16781679
if (nv_match_device(dev, 0x0201, 0x1462, 0x8851)) {
16791680
if (*conn == 0xf2005014 && *conf == 0xffffffff) {
1680-
fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS, 1, 1, 1);
1681+
fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS, 1, 1, DCB_OUTPUT_B);
16811682
return false;
16821683
}
16831684
}
@@ -1763,26 +1764,26 @@ fabricate_dcb_encoder_table(struct drm_device *dev, struct nvbios *bios)
17631764
#ifdef __powerpc__
17641765
/* Apple iMac G4 NV17 */
17651766
if (of_machine_is_compatible("PowerMac4,5")) {
1766-
fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS, 0, all_heads, 1);
1767-
fabricate_dcb_output(dcb, DCB_OUTPUT_ANALOG, 1, all_heads, 2);
1767+
fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS, 0, all_heads, DCB_OUTPUT_B);
1768+
fabricate_dcb_output(dcb, DCB_OUTPUT_ANALOG, 1, all_heads, DCB_OUTPUT_C);
17681769
return;
17691770
}
17701771
#endif
17711772

17721773
/* Make up some sane defaults */
17731774
fabricate_dcb_output(dcb, DCB_OUTPUT_ANALOG,
1774-
bios->legacy.i2c_indices.crt, 1, 1);
1775+
bios->legacy.i2c_indices.crt, 1, DCB_OUTPUT_B);
17751776

17761777
if (nv04_tv_identify(dev, bios->legacy.i2c_indices.tv) >= 0)
17771778
fabricate_dcb_output(dcb, DCB_OUTPUT_TV,
17781779
bios->legacy.i2c_indices.tv,
1779-
all_heads, 0);
1780+
all_heads, DCB_OUTPUT_A);
17801781

17811782
else if (bios->tmds.output0_script_ptr ||
17821783
bios->tmds.output1_script_ptr)
17831784
fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS,
17841785
bios->legacy.i2c_indices.panel,
1785-
all_heads, 1);
1786+
all_heads, DCB_OUTPUT_B);
17861787
}
17871788

17881789
static int

drivers/gpu/drm/nouveau/nouveau_dp.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,18 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector,
225225
u8 *dpcd = nv_encoder->dp.dpcd;
226226
int ret = NOUVEAU_DP_NONE, hpd;
227227

228-
/* If we've already read the DPCD on an eDP device, we don't need to
229-
* reread it as it won't change
228+
/* eDP ports don't support hotplugging - so there's no point in probing eDP ports unless we
229+
* haven't probed them once before.
230230
*/
231-
if (connector->connector_type == DRM_MODE_CONNECTOR_eDP &&
232-
dpcd[DP_DPCD_REV] != 0)
233-
return NOUVEAU_DP_SST;
231+
if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
232+
if (connector->status == connector_status_connected)
233+
return NOUVEAU_DP_SST;
234+
else if (connector->status == connector_status_disconnected)
235+
return NOUVEAU_DP_NONE;
236+
}
237+
238+
// Ensure that the aux bus is enabled for probing
239+
drm_dp_dpcd_set_powered(&nv_connector->aux, true);
234240

235241
mutex_lock(&nv_encoder->dp.hpd_irq_lock);
236242
if (mstm) {
@@ -293,6 +299,13 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector,
293299
if (mstm && !mstm->suspended && ret != NOUVEAU_DP_MST)
294300
nv50_mstm_remove(mstm);
295301

302+
/* GSP doesn't like when we try to do aux transactions on a port it considers disconnected,
303+
* and since we don't really have a usecase for that anyway - just disable the aux bus here
304+
* if we've decided the connector is disconnected
305+
*/
306+
if (ret == NOUVEAU_DP_NONE)
307+
drm_dp_dpcd_set_powered(&nv_connector->aux, false);
308+
296309
mutex_unlock(&nv_encoder->dp.hpd_irq_lock);
297310
return ret;
298311
}

drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,11 @@ nv50_instobj_acquire(struct nvkm_memory *memory)
222222
void __iomem *map = NULL;
223223

224224
/* Already mapped? */
225-
if (refcount_inc_not_zero(&iobj->maps))
225+
if (refcount_inc_not_zero(&iobj->maps)) {
226+
/* read barrier match the wmb on refcount set */
227+
smp_rmb();
226228
return iobj->map;
229+
}
227230

228231
/* Take the lock, and re-check that another thread hasn't
229232
* already mapped the object in the meantime.
@@ -250,6 +253,8 @@ nv50_instobj_acquire(struct nvkm_memory *memory)
250253
iobj->base.memory.ptrs = &nv50_instobj_fast;
251254
else
252255
iobj->base.memory.ptrs = &nv50_instobj_slow;
256+
/* barrier to ensure the ptrs are written before refcount is set */
257+
smp_wmb();
253258
refcount_set(&iobj->maps, 1);
254259
}
255260

drivers/gpu/drm/panel/panel-novatek-nt36672e.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,6 @@ static void nt36672e_panel_remove(struct mipi_dsi_device *dsi)
614614
struct nt36672e_panel *ctx = mipi_dsi_get_drvdata(dsi);
615615

616616
mipi_dsi_detach(ctx->dsi);
617-
mipi_dsi_device_unregister(ctx->dsi);
618-
619617
drm_panel_remove(&ctx->panel);
620618
}
621619

drivers/gpu/drm/panel/panel-visionox-rm69299.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,6 @@ static void visionox_rm69299_remove(struct mipi_dsi_device *dsi)
253253
struct visionox_rm69299 *ctx = mipi_dsi_get_drvdata(dsi);
254254

255255
mipi_dsi_detach(ctx->dsi);
256-
mipi_dsi_device_unregister(ctx->dsi);
257-
258256
drm_panel_remove(&ctx->panel);
259257
}
260258

drivers/gpu/drm/ttm/ttm_pool.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,17 +288,23 @@ static struct ttm_pool_type *ttm_pool_select_type(struct ttm_pool *pool,
288288
enum ttm_caching caching,
289289
unsigned int order)
290290
{
291-
if (pool->use_dma_alloc || pool->nid != NUMA_NO_NODE)
291+
if (pool->use_dma_alloc)
292292
return &pool->caching[caching].orders[order];
293293

294294
#ifdef CONFIG_X86
295295
switch (caching) {
296296
case ttm_write_combined:
297+
if (pool->nid != NUMA_NO_NODE)
298+
return &pool->caching[caching].orders[order];
299+
297300
if (pool->use_dma32)
298301
return &global_dma32_write_combined[order];
299302

300303
return &global_write_combined[order];
301304
case ttm_uncached:
305+
if (pool->nid != NUMA_NO_NODE)
306+
return &pool->caching[caching].orders[order];
307+
302308
if (pool->use_dma32)
303309
return &global_dma32_uncached[order];
304310

@@ -566,11 +572,17 @@ void ttm_pool_init(struct ttm_pool *pool, struct device *dev,
566572
pool->use_dma_alloc = use_dma_alloc;
567573
pool->use_dma32 = use_dma32;
568574

569-
if (use_dma_alloc || nid != NUMA_NO_NODE) {
570-
for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i)
571-
for (j = 0; j < NR_PAGE_ORDERS; ++j)
572-
ttm_pool_type_init(&pool->caching[i].orders[j],
573-
pool, i, j);
575+
for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i) {
576+
for (j = 0; j < NR_PAGE_ORDERS; ++j) {
577+
struct ttm_pool_type *pt;
578+
579+
/* Initialize only pool types which are actually used */
580+
pt = ttm_pool_select_type(pool, i, j);
581+
if (pt != &pool->caching[i].orders[j])
582+
continue;
583+
584+
ttm_pool_type_init(pt, pool, i, j);
585+
}
574586
}
575587
}
576588
EXPORT_SYMBOL(ttm_pool_init);
@@ -599,10 +611,16 @@ void ttm_pool_fini(struct ttm_pool *pool)
599611
{
600612
unsigned int i, j;
601613

602-
if (pool->use_dma_alloc || pool->nid != NUMA_NO_NODE) {
603-
for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i)
604-
for (j = 0; j < NR_PAGE_ORDERS; ++j)
605-
ttm_pool_type_fini(&pool->caching[i].orders[j]);
614+
for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i) {
615+
for (j = 0; j < NR_PAGE_ORDERS; ++j) {
616+
struct ttm_pool_type *pt;
617+
618+
pt = ttm_pool_select_type(pool, i, j);
619+
if (pt != &pool->caching[i].orders[j])
620+
continue;
621+
622+
ttm_pool_type_fini(pt);
623+
}
606624
}
607625

608626
/* We removed the pool types from the LRU, but we need to also make sure

drivers/gpu/drm/v3d/v3d_irq.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ v3d_irq(int irq, void *arg)
105105
struct v3d_file_priv *file = v3d->bin_job->base.file->driver_priv;
106106
u64 runtime = local_clock() - file->start_ns[V3D_BIN];
107107

108-
file->enabled_ns[V3D_BIN] += local_clock() - file->start_ns[V3D_BIN];
109108
file->jobs_sent[V3D_BIN]++;
110109
v3d->queue[V3D_BIN].jobs_sent++;
111110

@@ -126,7 +125,6 @@ v3d_irq(int irq, void *arg)
126125
struct v3d_file_priv *file = v3d->render_job->base.file->driver_priv;
127126
u64 runtime = local_clock() - file->start_ns[V3D_RENDER];
128127

129-
file->enabled_ns[V3D_RENDER] += local_clock() - file->start_ns[V3D_RENDER];
130128
file->jobs_sent[V3D_RENDER]++;
131129
v3d->queue[V3D_RENDER].jobs_sent++;
132130

@@ -147,7 +145,6 @@ v3d_irq(int irq, void *arg)
147145
struct v3d_file_priv *file = v3d->csd_job->base.file->driver_priv;
148146
u64 runtime = local_clock() - file->start_ns[V3D_CSD];
149147

150-
file->enabled_ns[V3D_CSD] += local_clock() - file->start_ns[V3D_CSD];
151148
file->jobs_sent[V3D_CSD]++;
152149
v3d->queue[V3D_CSD].jobs_sent++;
153150

@@ -195,7 +192,6 @@ v3d_hub_irq(int irq, void *arg)
195192
struct v3d_file_priv *file = v3d->tfu_job->base.file->driver_priv;
196193
u64 runtime = local_clock() - file->start_ns[V3D_TFU];
197194

198-
file->enabled_ns[V3D_TFU] += local_clock() - file->start_ns[V3D_TFU];
199195
file->jobs_sent[V3D_TFU]++;
200196
v3d->queue[V3D_TFU].jobs_sent++;
201197

drivers/gpu/drm/vmwgfx/vmwgfx_blit.c

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,10 @@ int vmw_bo_cpu_blit(struct ttm_buffer_object *dst,
456456
.no_wait_gpu = false
457457
};
458458
u32 j, initial_line = dst_offset / dst_stride;
459-
struct vmw_bo_blit_line_data d;
459+
struct vmw_bo_blit_line_data d = {0};
460460
int ret = 0;
461+
struct page **dst_pages = NULL;
462+
struct page **src_pages = NULL;
461463

462464
/* Buffer objects need to be either pinned or reserved: */
463465
if (!(dst->pin_count))
@@ -477,12 +479,35 @@ int vmw_bo_cpu_blit(struct ttm_buffer_object *dst,
477479
return ret;
478480
}
479481

482+
if (!src->ttm->pages && src->ttm->sg) {
483+
src_pages = kvmalloc_array(src->ttm->num_pages,
484+
sizeof(struct page *), GFP_KERNEL);
485+
if (!src_pages)
486+
return -ENOMEM;
487+
ret = drm_prime_sg_to_page_array(src->ttm->sg, src_pages,
488+
src->ttm->num_pages);
489+
if (ret)
490+
goto out;
491+
}
492+
if (!dst->ttm->pages && dst->ttm->sg) {
493+
dst_pages = kvmalloc_array(dst->ttm->num_pages,
494+
sizeof(struct page *), GFP_KERNEL);
495+
if (!dst_pages) {
496+
ret = -ENOMEM;
497+
goto out;
498+
}
499+
ret = drm_prime_sg_to_page_array(dst->ttm->sg, dst_pages,
500+
dst->ttm->num_pages);
501+
if (ret)
502+
goto out;
503+
}
504+
480505
d.mapped_dst = 0;
481506
d.mapped_src = 0;
482507
d.dst_addr = NULL;
483508
d.src_addr = NULL;
484-
d.dst_pages = dst->ttm->pages;
485-
d.src_pages = src->ttm->pages;
509+
d.dst_pages = dst->ttm->pages ? dst->ttm->pages : dst_pages;
510+
d.src_pages = src->ttm->pages ? src->ttm->pages : src_pages;
486511
d.dst_num_pages = PFN_UP(dst->resource->size);
487512
d.src_num_pages = PFN_UP(src->resource->size);
488513
d.dst_prot = ttm_io_prot(dst, dst->resource, PAGE_KERNEL);
@@ -504,6 +529,10 @@ int vmw_bo_cpu_blit(struct ttm_buffer_object *dst,
504529
kunmap_atomic(d.src_addr);
505530
if (d.dst_addr)
506531
kunmap_atomic(d.dst_addr);
532+
if (src_pages)
533+
kvfree(src_pages);
534+
if (dst_pages)
535+
kvfree(dst_pages);
507536

508537
return ret;
509538
}

drivers/gpu/drm/vmwgfx/vmwgfx_bo.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@ static int vmw_bo_init(struct vmw_private *dev_priv,
377377
{
378378
struct ttm_operation_ctx ctx = {
379379
.interruptible = params->bo_type != ttm_bo_type_kernel,
380-
.no_wait_gpu = false
380+
.no_wait_gpu = false,
381+
.resv = params->resv,
381382
};
382383
struct ttm_device *bdev = &dev_priv->bdev;
383384
struct drm_device *vdev = &dev_priv->drm;
@@ -394,8 +395,8 @@ static int vmw_bo_init(struct vmw_private *dev_priv,
394395

395396
vmw_bo_placement_set(vmw_bo, params->domain, params->busy_domain);
396397
ret = ttm_bo_init_reserved(bdev, &vmw_bo->tbo, params->bo_type,
397-
&vmw_bo->placement, 0, &ctx, NULL,
398-
NULL, destroy);
398+
&vmw_bo->placement, 0, &ctx,
399+
params->sg, params->resv, destroy);
399400
if (unlikely(ret))
400401
return ret;
401402

drivers/gpu/drm/vmwgfx/vmwgfx_bo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ struct vmw_bo_params {
5555
enum ttm_bo_type bo_type;
5656
size_t size;
5757
bool pin;
58+
struct dma_resv *resv;
59+
struct sg_table *sg;
5860
};
5961

6062
/**

0 commit comments

Comments
 (0)