History

Merge tag 'drm-fixes-2024-04-19' of https://gitlab.freedesktop.org/drm/kernel

Pull drm fixes from Dave Airlie: "Regular week of fixes, seems to be about right for this time in the release cycle, amdgpu, and nouveau are the main one with some scattered fixes otherwise. ttm: - Stop pooling cached NUMA pages amdgpu: - Fix invalid resource->start check - USB-C DSC fix - Fix a potential UAF in VA IOCTL - Fix visible VRAM handling during faults amdkfd: - Fix memory leak in create_process failure radeon: - Silence UBSAN warnings from variable sized arrays nouveau: - dp: Don't probe DP ports twice - nv04: Fix OOB access - nv50: Disable AUX bus for disconnected DP ports - nvkm: Fix instmem race condition panel: - Don't unregister DSI devices in several drivers v3d: - Fix enabled_ns increment xe: - Fix bo leak on error path during fb init - Fix use-after-free due to order vm is put and destroyed" * tag 'drm-fixes-2024-04-19' of https://gitlab.freedesktop.org/drm/kernel: drm/radeon: silence UBSAN warning (v3) drm/radeon: make -fstrict-flex-arrays=3 happy drm/amdgpu: fix visible VRAM handling during faults drm/amdgpu: validate the parameters of bo mapping operations more clearly Revert "drm/amd/display: fix USB-C flag update after enc10 feature init" drm/amdkfd: Fix memory leak in create_process failure drm/amdgpu: remove invalid resource->start check v2 drm/xe/vm: prevent UAF with asid based lookup drm/xe: Fix bo leak in intel_fb_bo_framebuffer_init drm/panel: novatek-nt36682e: don't unregister DSI device drm/panel: visionox-rm69299: don't unregister DSI device drm/nouveau/dp: Don't probe eDP ports twice harder drm/nouveau/kms/nv50-: Disable AUX bus for disconnected DP ports drm/v3d: Don't increment `enabled_ns` twice drm/vmwgfx: Sort primary plane formats by order of preference drm/vmwgfx: Fix crtc's atomic check conditional drm/vmwgfx: Fix prime import/export drm/ttm: stop pooling cached NUMA pages v2 drm: nv04: Fix out of bounds access nouveau: fix instmem race condition around ptr stores

Linus Torvalds committed 2 years ago

Commit ce944f32 parents 54c2354 52c8b6e30 files · +320 −172Browse files

Unified · Split

30 files
  1. drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 −1
  2. drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +11 −11
  3. drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +0 −22
  4. drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +38 −27
  5. drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +3 −0
  6. drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +46 −26
  7. drivers/gpu/drm/amd/amdkfd/kfd_process.c +2 −2
  8. drivers/gpu/drm/amd/display/dc/dcn32/dcn32_dio_link_encoder.c +3 −5
  9. drivers/gpu/drm/amd/display/dc/dcn35/dcn35_dio_link_encoder.c +2 −2
  10. drivers/gpu/drm/nouveau/nouveau_bios.c +7 −6
  11. drivers/gpu/drm/nouveau/nouveau_dp.c +18 −5
  12. drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c +6 −1
  13. drivers/gpu/drm/panel/panel-novatek-nt36672e.c +0 −2
  14. drivers/gpu/drm/panel/panel-visionox-rm69299.c +0 −2
  15. drivers/gpu/drm/radeon/pptable.h +5 −5
  16. drivers/gpu/drm/radeon/radeon_atombios.c +6 −2
  17. drivers/gpu/drm/ttm/ttm_pool.c +28 −10
  18. drivers/gpu/drm/v3d/v3d_irq.c +0 −4
  19. drivers/gpu/drm/vmwgfx/vmwgfx_blit.c +32 −3
  20. drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +4 −3
  21. drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +2 −0
  22. drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 −0
  23. drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +3 −0
  24. drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +32 −0
  25. drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +8 −3
  26. drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +2 −2
  27. drivers/gpu/drm/vmwgfx/vmwgfx_prime.c +13 −2
  28. drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +30 −14
  29. drivers/gpu/drm/xe/display/intel_fb_bo.c +6 −2
  30. drivers/gpu/drm/xe/xe_vm.c +11 −10
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c+1−1
@@ -819,7 +819,7 @@ retry: · 818 unmodified lines
819819
820820 p->bytes_moved += ctx.bytes_moved;
821821 if (!amdgpu_gmc_vram_full_visible(&adev->gmc) &&
822− amdgpu_bo_in_cpu_visible_vram(bo))
822+ amdgpu_res_cpu_visible(adev, bo->tbo.resource))
823823 p->bytes_moved_vis += ctx.bytes_moved;
824824
825825 if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) {
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c+11−11
@@ -617,8 +617,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev, · 616 unmodified lines
617617 return r;
618618
619619 if (!amdgpu_gmc_vram_full_visible(&adev->gmc) &&
620− bo->tbo.resource->mem_type == TTM_PL_VRAM &&
621− amdgpu_bo_in_cpu_visible_vram(bo))
620+ amdgpu_res_cpu_visible(adev, bo->tbo.resource))
622621 amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved,
623622 ctx.bytes_moved);
624623 else
@@ -1272,23 +1271,25 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, bool evict) · 647 unmodified lines
12721271 void amdgpu_bo_get_memory(struct amdgpu_bo *bo,
12731272 struct amdgpu_mem_stats *stats)
12741273 {
1274+ struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
1275+ struct ttm_resource *res = bo->tbo.resource;
12751276 uint64_t size = amdgpu_bo_size(bo);
12761277 struct drm_gem_object *obj;
12771278 unsigned int domain;
12781279 bool shared;
12791280
12801281 /* Abort if the BO doesn't currently have a backing store */
1281− if (!bo->tbo.resource)
1282+ if (!res)
12821283 return;
12831284
12841285 obj = &bo->tbo.base;
12851286 shared = drm_gem_object_is_shared_for_memory_stats(obj);
12861287
1287− domain = amdgpu_mem_type_to_domain(bo->tbo.resource->mem_type);
1288+ domain = amdgpu_mem_type_to_domain(res->mem_type);
12881289 switch (domain) {
12891290 case AMDGPU_GEM_DOMAIN_VRAM:
12901291 stats->vram += size;
1291− if (amdgpu_bo_in_cpu_visible_vram(bo))
1292+ if (amdgpu_res_cpu_visible(adev, bo->tbo.resource))
12921293 stats->visible_vram += size;
12931294 if (shared)
12941295 stats->vram_shared += size;
@@ -1389,10 +1390,7 @@ vm_fault_t amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo) · 94 unmodified lines
13891390 /* Remember that this BO was accessed by the CPU */
13901391 abo->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
13911392
1392− if (bo->resource->mem_type != TTM_PL_VRAM)
1393− return 0;
1394−
1395− if (amdgpu_bo_in_cpu_visible_vram(abo))
1393+ if (amdgpu_res_cpu_visible(adev, bo->resource))
13961394 return 0;
13971395
13981396 /* Can't move a pinned BO to visible VRAM */
@@ -1415,7 +1413,7 @@ vm_fault_t amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo) · 16 unmodified lines
14151413
14161414 /* this should never happen */
14171415 if (bo->resource->mem_type == TTM_PL_VRAM &&
1418− !amdgpu_bo_in_cpu_visible_vram(abo))
1416+ !amdgpu_res_cpu_visible(adev, bo->resource))
14191417 return VM_FAULT_SIGBUS;
14201418
14211419 ttm_bo_move_to_lru_tail_unlocked(bo);
@@ -1579,6 +1577,7 @@ uint32_t amdgpu_bo_get_preferred_domain(struct amdgpu_device *adev, · 157 unmodified lines
15791577 */
15801578 u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct seq_file *m)
15811579 {
1580+ struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
15821581 struct dma_buf_attachment *attachment;
15831582 struct dma_buf *dma_buf;
15841583 const char *placement;
@@ -1587,10 +1586,11 @@ u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct seq_file *m) · 2 unmodified lines
15871586
15881587 if (dma_resv_trylock(bo->tbo.base.resv)) {
15891588 unsigned int domain;
1589+
15901590 domain = amdgpu_mem_type_to_domain(bo->tbo.resource->mem_type);
15911591 switch (domain) {
15921592 case AMDGPU_GEM_DOMAIN_VRAM:
1593− if (amdgpu_bo_in_cpu_visible_vram(bo))
1593+ if (amdgpu_res_cpu_visible(adev, bo->tbo.resource))
15941594 placement = "VRAM VISIBLE";
15951595 else
15961596 placement = "VRAM";
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h+0−22
@@ -250,28 +250,6 @@ static inline u64 amdgpu_bo_mmap_offset(struct amdgpu_bo *bo) · 249 unmodified lines
250250 return drm_vma_node_offset_addr(&bo->tbo.base.vma_node);
251251 }
252252
253−/**
254− * amdgpu_bo_in_cpu_visible_vram - check if BO is (partly) in visible VRAM
255− */
256−static inline bool amdgpu_bo_in_cpu_visible_vram(struct amdgpu_bo *bo)
257−{
258− struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
259− struct amdgpu_res_cursor cursor;
260−
261− if (!bo->tbo.resource || bo->tbo.resource->mem_type != TTM_PL_VRAM)
262− return false;
263−
264− amdgpu_res_first(bo->tbo.resource, 0, amdgpu_bo_size(bo), &cursor);
265− while (cursor.remaining) {
266− if (cursor.start < adev->gmc.visible_vram_size)
267− return true;
268−
269− amdgpu_res_next(&cursor, cursor.size);
270− }
271−
272− return false;
273−}
274−
275253 /**
276254 * amdgpu_bo_explicit_sync - return whether the bo is explicitly synced
277255 */
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c+38−27
@@ -133,7 +133,7 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, · 132 unmodified lines
133133
134134 } else if (!amdgpu_gmc_vram_full_visible(&adev->gmc) &&
135135 !(abo->flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) &&
136− amdgpu_bo_in_cpu_visible_vram(abo)) {
136+ amdgpu_res_cpu_visible(adev, bo->resource)) {
137137
138138 /* Try evicting to the CPU inaccessible part of VRAM
139139 * first, but only set GTT as busy placement, so this
@@ -403,40 +403,55 @@ error: · 263 unmodified lines
403403 return r;
404404 }
405405
406−/*
407− * amdgpu_mem_visible - Check that memory can be accessed by ttm_bo_move_memcpy
406+/**
407+ * amdgpu_res_cpu_visible - Check that resource can be accessed by CPU
408+ * @adev: amdgpu device
409+ * @res: the resource to check
408410 *
409− * Called by amdgpu_bo_move()
411+ * Returns: true if the full resource is CPU visible, false otherwise.
410412 */
411−static bool amdgpu_mem_visible(struct amdgpu_device *adev,
412− struct ttm_resource *mem)
413+bool amdgpu_res_cpu_visible(struct amdgpu_device *adev,
414+ struct ttm_resource *res)
413415 {
414− u64 mem_size = (u64)mem->size;
415416 struct amdgpu_res_cursor cursor;
416− u64 end;
417417
418− if (mem->mem_type == TTM_PL_SYSTEM ||
419− mem->mem_type == TTM_PL_TT)
418+ if (!res)
419+ return false;
420+
421+ if (res->mem_type == TTM_PL_SYSTEM || res->mem_type == TTM_PL_TT ||
422+ res->mem_type == AMDGPU_PL_PREEMPT)
420423 return true;
421− if (mem->mem_type != TTM_PL_VRAM)
424+
425+ if (res->mem_type != TTM_PL_VRAM)
422426 return false;
423427
424− amdgpu_res_first(mem, 0, mem_size, &cursor);
425− end = cursor.start + cursor.size;
428+ amdgpu_res_first(res, 0, res->size, &cursor);
426429 while (cursor.remaining) {
430+ if ((cursor.start + cursor.size) >= adev->gmc.visible_vram_size)
431+ return false;
427432 amdgpu_res_next(&cursor, cursor.size);
433+ }
428434
429− if (!cursor.remaining)
430− break;
435+ return true;
436+}
431437
432− /* ttm_resource_ioremap only supports contiguous memory */
433− if (end != cursor.start)
434− return false;
438+/*
439+ * amdgpu_res_copyable - Check that memory can be accessed by ttm_bo_move_memcpy
440+ *
441+ * Called by amdgpu_bo_move()
442+ */
443+static bool amdgpu_res_copyable(struct amdgpu_device *adev,
444+ struct ttm_resource *mem)
445+{
446+ if (!amdgpu_res_cpu_visible(adev, mem))
447+ return false;
435448
436− end = cursor.start + cursor.size;
437− }
449+ /* ttm_resource_ioremap only supports contiguous memory */
450+ if (mem->mem_type == TTM_PL_VRAM &&
451+ !(mem->placement & TTM_PL_FLAG_CONTIGUOUS))
452+ return false;
438453
439− return end <= adev->gmc.visible_vram_size;
454+ return true;
440455 }
441456
442457 /*
@@ -529,8 +544,8 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict, · 86 unmodified lines
529544
530545 if (r) {
531546 /* Check that all memory is CPU accessible */
532− if (!amdgpu_mem_visible(adev, old_mem) ||
533− !amdgpu_mem_visible(adev, new_mem)) {
547+ if (!amdgpu_res_copyable(adev, old_mem) ||
548+ !amdgpu_res_copyable(adev, new_mem)) {
534549 pr_err("Move buffer fallback to memcpy unavailable\n");
535550 return r;
536551 }
@@ -557,7 +572,6 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_device *bdev, · 20 unmodified lines
557572 struct ttm_resource *mem)
558573 {
559574 struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
560− size_t bus_size = (size_t)mem->size;
561575
562576 switch (mem->mem_type) {
563577 case TTM_PL_SYSTEM:
@@ -568,9 +582,6 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_device *bdev, · 4 unmodified lines
568582 break;
569583 case TTM_PL_VRAM:
570584 mem->bus.offset = mem->start << PAGE_SHIFT;
571− /* check if it's visible */
572− if ((mem->bus.offset + bus_size) > adev->gmc.visible_vram_size)
573− return -EINVAL;
574585
575586 if (adev->mman.aper_base_kaddr &&
576587 mem->placement & TTM_PL_FLAG_CONTIGUOUS)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h+3−0
@@ -139,6 +139,9 @@ int amdgpu_vram_mgr_reserve_range(struct amdgpu_vram_mgr *mgr, · 138 unmodified lines
139139 int amdgpu_vram_mgr_query_page_status(struct amdgpu_vram_mgr *mgr,
140140 uint64_t start);
141141
142+bool amdgpu_res_cpu_visible(struct amdgpu_device *adev,
143+ struct ttm_resource *res);
144+
142145 int amdgpu_ttm_init(struct amdgpu_device *adev);
143146 void amdgpu_ttm_fini(struct amdgpu_device *adev);
144147 void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c+46−26
@@ -1613,6 +1613,37 @@ static void amdgpu_vm_bo_insert_map(struct amdgpu_device *adev, · 1612 unmodified lines
16131613 trace_amdgpu_vm_bo_map(bo_va, mapping);
16141614 }
16151615
1616+/* Validate operation parameters to prevent potential abuse */
1617+static int amdgpu_vm_verify_parameters(struct amdgpu_device *adev,
1618+ struct amdgpu_bo *bo,
1619+ uint64_t saddr,
1620+ uint64_t offset,
1621+ uint64_t size)
1622+{
1623+ uint64_t tmp, lpfn;
1624+
1625+ if (saddr & AMDGPU_GPU_PAGE_MASK
1626+ || offset & AMDGPU_GPU_PAGE_MASK
1627+ || size & AMDGPU_GPU_PAGE_MASK)
1628+ return -EINVAL;
1629+
1630+ if (check_add_overflow(saddr, size, &tmp)
1631+ || check_add_overflow(offset, size, &tmp)
1632+ || size == 0 /* which also leads to end < begin */)
1633+ return -EINVAL;
1634+
1635+ /* make sure object fit at this offset */
1636+ if (bo && offset + size > amdgpu_bo_size(bo))
1637+ return -EINVAL;
1638+
1639+ /* Ensure last pfn not exceed max_pfn */
1640+ lpfn = (saddr + size - 1) >> AMDGPU_GPU_PAGE_SHIFT;
1641+ if (lpfn >= adev->vm_manager.max_pfn)
1642+ return -EINVAL;
1643+
1644+ return 0;
1645+}
1646+
16161647 /**
16171648 * amdgpu_vm_bo_map - map bo inside a vm
16181649 *
@@ -1639,21 +1670,14 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev, · 20 unmodified lines
16391670 struct amdgpu_bo *bo = bo_va->base.bo;
16401671 struct amdgpu_vm *vm = bo_va->base.vm;
16411672 uint64_t eaddr;
1673+ int r;
16421674
1643− /* validate the parameters */
1644− if (saddr & ~PAGE_MASK || offset & ~PAGE_MASK || size & ~PAGE_MASK)
1645− return -EINVAL;
1646− if (saddr + size <= saddr || offset + size <= offset)
1647− return -EINVAL;
1648−
1649− /* make sure object fit at this offset */
1650− eaddr = saddr + size - 1;
1651− if ((bo && offset + size > amdgpu_bo_size(bo)) ||
1652− (eaddr >= adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT))
1653− return -EINVAL;
1675+ r = amdgpu_vm_verify_parameters(adev, bo, saddr, offset, size);
1676+ if (r)
1677+ return r;
16541678
16551679 saddr /= AMDGPU_GPU_PAGE_SIZE;
1656− eaddr /= AMDGPU_GPU_PAGE_SIZE;
1680+ eaddr = saddr + (size - 1) / AMDGPU_GPU_PAGE_SIZE;
16571681
16581682 tmp = amdgpu_vm_it_iter_first(&vm->va, saddr, eaddr);
16591683 if (tmp) {
@@ -1706,17 +1730,9 @@ int amdgpu_vm_bo_replace_map(struct amdgpu_device *adev, · 46 unmodified lines
17061730 uint64_t eaddr;
17071731 int r;
17081732
1709− /* validate the parameters */
1710− if (saddr & ~PAGE_MASK || offset & ~PAGE_MASK || size & ~PAGE_MASK)
1711− return -EINVAL;
1712− if (saddr + size <= saddr || offset + size <= offset)
1713− return -EINVAL;
1714−
1715− /* make sure object fit at this offset */
1716− eaddr = saddr + size - 1;
1717− if ((bo && offset + size > amdgpu_bo_size(bo)) ||
1718− (eaddr >= adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT))
1719− return -EINVAL;
1733+ r = amdgpu_vm_verify_parameters(adev, bo, saddr, offset, size);
1734+ if (r)
1735+ return r;
17201736
17211737 /* Allocate all the needed memory */
17221738 mapping = kmalloc(sizeof(*mapping), GFP_KERNEL);
@@ -1730,7 +1746,7 @@ int amdgpu_vm_bo_replace_map(struct amdgpu_device *adev, · 7 unmodified lines
17301746 }
17311747
17321748 saddr /= AMDGPU_GPU_PAGE_SIZE;
1733− eaddr /= AMDGPU_GPU_PAGE_SIZE;
1749+ eaddr = saddr + (size - 1) / AMDGPU_GPU_PAGE_SIZE;
17341750
17351751 mapping->start = saddr;
17361752 mapping->last = eaddr;
@@ -1817,10 +1833,14 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev, · 80 unmodified lines
18171833 struct amdgpu_bo_va_mapping *before, *after, *tmp, *next;
18181834 LIST_HEAD(removed);
18191835 uint64_t eaddr;
1836+ int r;
1837+
1838+ r = amdgpu_vm_verify_parameters(adev, NULL, saddr, 0, size);
1839+ if (r)
1840+ return r;
18201841
1821− eaddr = saddr + size - 1;
18221842 saddr /= AMDGPU_GPU_PAGE_SIZE;
1823− eaddr /= AMDGPU_GPU_PAGE_SIZE;
1843+ eaddr = saddr + (size - 1) / AMDGPU_GPU_PAGE_SIZE;
18241844
18251845 /* Allocate all the needed memory */
18261846 before = kzalloc(sizeof(*before), GFP_KERNEL);
drivers/gpu/drm/amd/amdkfd/kfd_process.c+2−2
@@ -819,9 +819,9 @@ struct kfd_process *kfd_create_process(struct task_struct *thread) · 818 unmodified lines
819819 mutex_lock(&kfd_processes_mutex);
820820
821821 if (kfd_is_locked()) {
822− mutex_unlock(&kfd_processes_mutex);
823822 pr_debug("KFD is locked! Cannot create process");
824− return ERR_PTR(-EINVAL);
823+ process = ERR_PTR(-EINVAL);
824+ goto out;
825825 }
826826
827827 /* A prior open of /dev/kfd could have already created the process. */
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_dio_link_encoder.c+3−5
@@ -248,14 +248,12 @@ void dcn32_link_encoder_construct( · 247 unmodified lines
248248 enc10->base.hpd_source = init_data->hpd_source;
249249 enc10->base.connector = init_data->connector;
250250
251− enc10->base.preferred_engine = ENGINE_ID_UNKNOWN;
252−
253− enc10->base.features = *enc_features;
254251 if (enc10->base.connector.id == CONNECTOR_ID_USBC)
255252 enc10->base.features.flags.bits.DP_IS_USB_C = 1;
256253
257− if (enc10->base.connector.id == CONNECTOR_ID_USBC)
258− enc10->base.features.flags.bits.DP_IS_USB_C = 1;
254+ enc10->base.preferred_engine = ENGINE_ID_UNKNOWN;
255+
256+ enc10->base.features = *enc_features;
259257
260258 enc10->base.transmitter = init_data->transmitter;
261259
drivers/gpu/drm/amd/display/dc/dcn35/dcn35_dio_link_encoder.c+2−2
@@ -184,6 +184,8 @@ void dcn35_link_encoder_construct( · 183 unmodified lines
184184 enc10->base.hpd_source = init_data->hpd_source;
185185 enc10->base.connector = init_data->connector;
186186
187+ if (enc10->base.connector.id == CONNECTOR_ID_USBC)
188+ enc10->base.features.flags.bits.DP_IS_USB_C = 1;
187189
188190 enc10->base.preferred_engine = ENGINE_ID_UNKNOWN;
189191
@@ -238,8 +240,6 @@ void dcn35_link_encoder_construct( · 48 unmodified lines
238240 }
239241
240242 enc10->base.features.flags.bits.HDMI_6GB_EN = 1;
241− if (enc10->base.connector.id == CONNECTOR_ID_USBC)
242− enc10->base.features.flags.bits.DP_IS_USB_C = 1;
243243
244244 if (bp_funcs->get_connector_speed_cap_info)
245245 result = bp_funcs->get_connector_speed_cap_info(enc10->base.ctx->dc_bios,
drivers/gpu/drm/nouveau/nouveau_bios.c+7−6
@@ -23,6 +23,7 @@ · 22 unmodified lines
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) · 1648 unmodified lines
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) · 79 unmodified lines
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+18−5
@@ -225,12 +225,18 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector, · 224 unmodified lines
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 @@ out: · 56 unmodified lines
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+6−1
@@ -222,8 +222,11 @@ nv50_instobj_acquire(struct nvkm_memory *memory) · 221 unmodified lines
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) · 20 unmodified lines
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+0−2
@@ -614,8 +614,6 @@ static void nt36672e_panel_remove(struct mipi_dsi_device *dsi) · 613 unmodified lines
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+0−2
@@ -253,8 +253,6 @@ static void visionox_rm69299_remove(struct mipi_dsi_device *dsi) · 252 unmodified lines
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/radeon/pptable.h+5−5
@@ -424,7 +424,7 @@ typedef struct _ATOM_PPLIB_SUMO_CLOCK_INFO{ · 423 unmodified lines
424424 typedef struct _ATOM_PPLIB_STATE_V2
425425 {
426426 //number of valid dpm levels in this state; Driver uses it to calculate the whole
427− //size of the state: sizeof(ATOM_PPLIB_STATE_V2) + (ucNumDPMLevels - 1) * sizeof(UCHAR)
427+ //size of the state: struct_size(ATOM_PPLIB_STATE_V2, clockInfoIndex, ucNumDPMLevels)
428428 UCHAR ucNumDPMLevels;
429429
430430 //a index to the array of nonClockInfos
@@ -432,14 +432,14 @@ typedef struct _ATOM_PPLIB_STATE_V2 · 1 unmodified line
432432 /**
433433 * Driver will read the first ucNumDPMLevels in this array
434434 */
435− UCHAR clockInfoIndex[1];
435+ UCHAR clockInfoIndex[] __counted_by(ucNumDPMLevels);
436436 } ATOM_PPLIB_STATE_V2;
437437
438438 typedef struct _StateArray{
439439 //how many states we have
440440 UCHAR ucNumEntries;
441441
442− ATOM_PPLIB_STATE_V2 states[1];
442+ ATOM_PPLIB_STATE_V2 states[] __counted_by(ucNumEntries);
443443 }StateArray;
444444
445445
@@ -450,7 +450,7 @@ typedef struct _ClockInfoArray{ · 4 unmodified lines
450450 //sizeof(ATOM_PPLIB_CLOCK_INFO)
451451 UCHAR ucEntrySize;
452452
453− UCHAR clockInfo[1];
453+ UCHAR clockInfo[] __counted_by(ucNumEntries);
454454 }ClockInfoArray;
455455
456456 typedef struct _NonClockInfoArray{
@@ -460,7 +460,7 @@ typedef struct _NonClockInfoArray{ · 3 unmodified lines
460460 //sizeof(ATOM_PPLIB_NONCLOCK_INFO)
461461 UCHAR ucEntrySize;
462462
463− ATOM_PPLIB_NONCLOCK_INFO nonClockInfo[1];
463+ ATOM_PPLIB_NONCLOCK_INFO nonClockInfo[] __counted_by(ucNumEntries);
464464 }NonClockInfoArray;
465465
466466 typedef struct _ATOM_PPLIB_Clock_Voltage_Dependency_Record
drivers/gpu/drm/radeon/radeon_atombios.c+6−2
@@ -923,8 +923,12 @@ bool radeon_get_atom_connector_info_from_supported_devices_table(struct · 922 unmodified lines
923923 max_device = ATOM_MAX_SUPPORTED_DEVICE_INFO;
924924
925925 for (i = 0; i < max_device; i++) {
926− ATOM_CONNECTOR_INFO_I2C ci =
927− supported_devices->info.asConnInfo[i];
926+ ATOM_CONNECTOR_INFO_I2C ci;
927+
928+ if (frev > 1)
929+ ci = supported_devices->info_2d1.asConnInfo[i];
930+ else
931+ ci = supported_devices->info.asConnInfo[i];
928932
929933 bios_connectors[i].valid = false;
930934
drivers/gpu/drm/ttm/ttm_pool.c+28−10
@@ -288,17 +288,23 @@ static struct ttm_pool_type *ttm_pool_select_type(struct ttm_pool *pool, · 287 unmodified lines
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, · 261 unmodified lines
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) · 22 unmodified lines
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+0−4
@@ -105,7 +105,6 @@ v3d_irq(int irq, void *arg) · 104 unmodified lines
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) · 14 unmodified lines
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) · 14 unmodified lines
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) · 41 unmodified lines
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+32−3
@@ -456,8 +456,10 @@ int vmw_bo_cpu_blit(struct ttm_buffer_object *dst, · 455 unmodified lines
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, · 13 unmodified lines
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 @@ out: · 15 unmodified lines
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+4−3
@@ -377,7 +377,8 @@ static int vmw_bo_init(struct vmw_private *dev_priv, · 376 unmodified lines
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, · 10 unmodified lines
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+2−0
@@ -55,6 +55,8 @@ struct vmw_bo_params { · 54 unmodified lines
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 /**
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c+1−0
@@ -1628,6 +1628,7 @@ static const struct drm_driver driver = { · 1627 unmodified lines
16281628
16291629 .prime_fd_to_handle = vmw_prime_fd_to_handle,
16301630 .prime_handle_to_fd = vmw_prime_handle_to_fd,
1631+ .gem_prime_import_sg_table = vmw_prime_import_sg_table,
16311632
16321633 .fops = &vmwgfx_driver_fops,
16331634 .name = VMWGFX_DRIVER_NAME,
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h+3−0
@@ -1130,6 +1130,9 @@ extern int vmw_prime_handle_to_fd(struct drm_device *dev, · 1129 unmodified lines
11301130 struct drm_file *file_priv,
11311131 uint32_t handle, uint32_t flags,
11321132 int *prime_fd);
1133+struct drm_gem_object *vmw_prime_import_sg_table(struct drm_device *dev,
1134+ struct dma_buf_attachment *attach,
1135+ struct sg_table *table);
11331136
11341137 /*
11351138 * MemoryOBject management - vmwgfx_mob.c
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c+32−0
@@ -149,6 +149,38 @@ out_no_bo: · 148 unmodified lines
149149 return ret;
150150 }
151151
152+struct drm_gem_object *vmw_prime_import_sg_table(struct drm_device *dev,
153+ struct dma_buf_attachment *attach,
154+ struct sg_table *table)
155+{
156+ int ret;
157+ struct vmw_private *dev_priv = vmw_priv(dev);
158+ struct drm_gem_object *gem = NULL;
159+ struct vmw_bo *vbo;
160+ struct vmw_bo_params params = {
161+ .domain = (dev_priv->has_mob) ? VMW_BO_DOMAIN_SYS : VMW_BO_DOMAIN_VRAM,
162+ .busy_domain = VMW_BO_DOMAIN_SYS,
163+ .bo_type = ttm_bo_type_sg,
164+ .size = attach->dmabuf->size,
165+ .pin = false,
166+ .resv = attach->dmabuf->resv,
167+ .sg = table,
168+
169+ };
170+
171+ dma_resv_lock(params.resv, NULL);
172+
173+ ret = vmw_bo_create(dev_priv, &params, &vbo);
174+ if (ret != 0)
175+ goto out_no_bo;
176+
177+ vbo->tbo.base.funcs = &vmw_gem_object_funcs;
178+
179+ gem = &vbo->tbo.base;
180+out_no_bo:
181+ dma_resv_unlock(params.resv);
182+ return gem;
183+}
152184
153185 int vmw_gem_object_create_ioctl(struct drm_device *dev, void *data,
154186 struct drm_file *filp)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c+8−3
@@ -933,6 +933,7 @@ int vmw_du_cursor_plane_atomic_check(struct drm_plane *plane, · 932 unmodified lines
933933 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
934934 struct drm_atomic_state *state)
935935 {
936+ struct vmw_private *vmw = vmw_priv(crtc->dev);
936937 struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state,
937938 crtc);
938939 struct vmw_display_unit *du = vmw_crtc_to_du(new_state->crtc);
@@ -940,9 +941,13 @@ int vmw_du_crtc_atomic_check(struct drm_crtc *crtc, · 1 unmodified line
940941 bool has_primary = new_state->plane_mask &
941942 drm_plane_mask(crtc->primary);
942943
943− /* We always want to have an active plane with an active CRTC */
944− if (has_primary != new_state->enable)
945− return -EINVAL;
944+ /*
945+ * This is fine in general, but broken userspace might expect
946+ * some actual rendering so give a clue as why it's blank.
947+ */
948+ if (new_state->enable && !has_primary)
949+ drm_dbg_driver(&vmw->drm,
950+ "CRTC without a primary plane will be blank.\n");
946951
947952
948953 if (new_state->connector_mask != connector_mask &&
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h+2−2
@@ -243,10 +243,10 @@ struct vmw_framebuffer_bo { · 242 unmodified lines
243243
244244
245245 static const uint32_t __maybe_unused vmw_primary_plane_formats[] = {
246− DRM_FORMAT_XRGB1555,
247− DRM_FORMAT_RGB565,
248246 DRM_FORMAT_XRGB8888,
249247 DRM_FORMAT_ARGB8888,
248+ DRM_FORMAT_RGB565,
249+ DRM_FORMAT_XRGB1555,
250250 };
251251
252252 static const uint32_t __maybe_unused vmw_cursor_plane_formats[] = {
drivers/gpu/drm/vmwgfx/vmwgfx_prime.c+13−2
@@ -75,8 +75,12 @@ int vmw_prime_fd_to_handle(struct drm_device *dev, · 74 unmodified lines
7575 int fd, u32 *handle)
7676 {
7777 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
78+ int ret = ttm_prime_fd_to_handle(tfile, fd, handle);
7879
79− return ttm_prime_fd_to_handle(tfile, fd, handle);
80+ if (ret)
81+ ret = drm_gem_prime_fd_to_handle(dev, file_priv, fd, handle);
82+
83+ return ret;
8084 }
8185
8286 int vmw_prime_handle_to_fd(struct drm_device *dev,
@@ -85,5 +89,12 @@ int vmw_prime_handle_to_fd(struct drm_device *dev, · 2 unmodified lines
8589 int *prime_fd)
8690 {
8791 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
88− return ttm_prime_handle_to_fd(tfile, handle, flags, prime_fd);
92+ int ret;
93+
94+ if (handle > VMWGFX_NUM_MOB)
95+ ret = ttm_prime_handle_to_fd(tfile, handle, flags, prime_fd);
96+ else
97+ ret = drm_gem_prime_handle_to_fd(dev, file_priv, handle, flags, prime_fd);
98+
99+ return ret;
89100 }
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c+30−14
@@ -188,13 +188,18 @@ static int vmw_ttm_map_dma(struct vmw_ttm_tt *vmw_tt) · 187 unmodified lines
188188 switch (dev_priv->map_mode) {
189189 case vmw_dma_map_bind:
190190 case vmw_dma_map_populate:
191− vsgt->sgt = &vmw_tt->sgt;
192− ret = sg_alloc_table_from_pages_segment(
193− &vmw_tt->sgt, vsgt->pages, vsgt->num_pages, 0,
194− (unsigned long)vsgt->num_pages << PAGE_SHIFT,
195− dma_get_max_seg_size(dev_priv->drm.dev), GFP_KERNEL);
196− if (ret)
197− goto out_sg_alloc_fail;
191+ if (vmw_tt->dma_ttm.page_flags & TTM_TT_FLAG_EXTERNAL) {
192+ vsgt->sgt = vmw_tt->dma_ttm.sg;
193+ } else {
194+ vsgt->sgt = &vmw_tt->sgt;
195+ ret = sg_alloc_table_from_pages_segment(&vmw_tt->sgt,
196+ vsgt->pages, vsgt->num_pages, 0,
197+ (unsigned long)vsgt->num_pages << PAGE_SHIFT,
198+ dma_get_max_seg_size(dev_priv->drm.dev),
199+ GFP_KERNEL);
200+ if (ret)
201+ goto out_sg_alloc_fail;
202+ }
198203
199204 ret = vmw_ttm_map_for_dma(vmw_tt);
200205 if (unlikely(ret != 0))
@@ -209,8 +214,9 @@ static int vmw_ttm_map_dma(struct vmw_ttm_tt *vmw_tt) · 8 unmodified lines
209214 return 0;
210215
211216 out_map_fail:
212− sg_free_table(vmw_tt->vsgt.sgt);
213− vmw_tt->vsgt.sgt = NULL;
217+ drm_warn(&dev_priv->drm, "VSG table map failed!");
218+ sg_free_table(vsgt->sgt);
219+ vsgt->sgt = NULL;
214220 out_sg_alloc_fail:
215221 return ret;
216222 }
@@ -356,15 +362,17 @@ static void vmw_ttm_destroy(struct ttm_device *bdev, struct ttm_tt *ttm) · 139 unmodified lines
356362 static int vmw_ttm_populate(struct ttm_device *bdev,
357363 struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
358364 {
359− int ret;
365+ bool external = (ttm->page_flags & TTM_TT_FLAG_EXTERNAL) != 0;
360366
361− /* TODO: maybe completely drop this ? */
362367 if (ttm_tt_is_populated(ttm))
363368 return 0;
364369
365− ret = ttm_pool_alloc(&bdev->pool, ttm, ctx);
370+ if (external && ttm->sg)
371+ return drm_prime_sg_to_dma_addr_array(ttm->sg,
372+ ttm->dma_address,
373+ ttm->num_pages);
366374
367− return ret;
375+ return ttm_pool_alloc(&bdev->pool, ttm, ctx);
368376 }
369377
370378 static void vmw_ttm_unpopulate(struct ttm_device *bdev,
@@ -372,6 +380,10 @@ static void vmw_ttm_unpopulate(struct ttm_device *bdev, · 1 unmodified line
372380 {
373381 struct vmw_ttm_tt *vmw_tt = container_of(ttm, struct vmw_ttm_tt,
374382 dma_ttm);
383+ bool external = (ttm->page_flags & TTM_TT_FLAG_EXTERNAL) != 0;
384+
385+ if (external)
386+ return;
375387
376388 vmw_ttm_unbind(bdev, ttm);
377389
@@ -390,6 +402,7 @@ static struct ttm_tt *vmw_ttm_tt_create(struct ttm_buffer_object *bo, · 12 unmodified lines
390402 {
391403 struct vmw_ttm_tt *vmw_be;
392404 int ret;
405+ bool external = bo->type == ttm_bo_type_sg;
393406
394407 vmw_be = kzalloc(sizeof(*vmw_be), GFP_KERNEL);
395408 if (!vmw_be)
@@ -398,7 +411,10 @@ static struct ttm_tt *vmw_ttm_tt_create(struct ttm_buffer_object *bo, · 2 unmodified lines
398411 vmw_be->dev_priv = vmw_priv_from_ttm(bo->bdev);
399412 vmw_be->mob = NULL;
400413
401− if (vmw_be->dev_priv->map_mode == vmw_dma_alloc_coherent)
414+ if (external)
415+ page_flags |= TTM_TT_FLAG_EXTERNAL | TTM_TT_FLAG_EXTERNAL_MAPPABLE;
416+
417+ if (vmw_be->dev_priv->map_mode == vmw_dma_alloc_coherent || external)
402418 ret = ttm_sg_tt_init(&vmw_be->dma_ttm, bo, page_flags,
403419 ttm_cached);
404420 else
drivers/gpu/drm/xe/display/intel_fb_bo.c+6−2
@@ -31,7 +31,7 @@ int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb, · 30 unmodified lines
3131
3232 ret = ttm_bo_reserve(&bo->ttm, true, false, NULL);
3333 if (ret)
34− return ret;
34+ goto err;
3535
3636 if (!(bo->flags & XE_BO_SCANOUT_BIT)) {
3737 /*
@@ -42,12 +42,16 @@ int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb, · 4 unmodified lines
4242 */
4343 if (XE_IOCTL_DBG(i915, !list_empty(&bo->ttm.base.gpuva.list))) {
4444 ttm_bo_unreserve(&bo->ttm);
45− return -EINVAL;
45+ ret = -EINVAL;
46+ goto err;
4647 }
4748 bo->flags |= XE_BO_SCANOUT_BIT;
4849 }
4950 ttm_bo_unreserve(&bo->ttm);
51+ return 0;
5052
53+err:
54+ xe_bo_put(bo);
5155 return ret;
5256 }
5357
drivers/gpu/drm/xe/xe_vm.c+11−10
@@ -1577,6 +1577,16 @@ void xe_vm_close_and_put(struct xe_vm *vm) · 1576 unmodified lines
15771577 xe->usm.num_vm_in_fault_mode--;
15781578 else if (!(vm->flags & XE_VM_FLAG_MIGRATION))
15791579 xe->usm.num_vm_in_non_fault_mode--;
1580+
1581+ if (vm->usm.asid) {
1582+ void *lookup;
1583+
1584+ xe_assert(xe, xe->info.has_asid);
1585+ xe_assert(xe, !(vm->flags & XE_VM_FLAG_MIGRATION));
1586+
1587+ lookup = xa_erase(&xe->usm.asid_to_vm, vm->usm.asid);
1588+ xe_assert(xe, lookup == vm);
1589+ }
15801590 mutex_unlock(&xe->usm.lock);
15811591
15821592 for_each_tile(tile, xe, id)
@@ -1592,24 +1602,15 @@ static void vm_destroy_work_func(struct work_struct *w) · 9 unmodified lines
15921602 struct xe_device *xe = vm->xe;
15931603 struct xe_tile *tile;
15941604 u8 id;
1595− void *lookup;
15961605
15971606 /* xe_vm_close_and_put was not called? */
15981607 xe_assert(xe, !vm->size);
15991608
16001609 mutex_destroy(&vm->snap_mutex);
16011610
1602− if (!(vm->flags & XE_VM_FLAG_MIGRATION)) {
1611+ if (!(vm->flags & XE_VM_FLAG_MIGRATION))
16031612 xe_device_mem_access_put(xe);
16041613
1605− if (xe->info.has_asid && vm->usm.asid) {
1606− mutex_lock(&xe->usm.lock);
1607− lookup = xa_erase(&xe->usm.asid_to_vm, vm->usm.asid);
1608− xe_assert(xe, lookup == vm);
1609− mutex_unlock(&xe->usm.lock);
1610− }
1611− }
1612−
16131614 for_each_tile(tile, xe, id)
16141615 XE_WARN_ON(vm->pt_root[id]);
16151616

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t