Commit 6f7e234f authored by Simona Vetter's avatar Simona Vetter
Browse files

Merge tag 'drm-misc-fixes-2025-06-06' of...

Merge tag 'drm-misc-fixes-2025-06-06' of https://gitlab.freedesktop.org/drm/misc/kernel

 into drm-fixes

Short summary of fixes pull:

ivpu:
- gem: Use dma-resv lock
- gem. Fix a warning
- Trigger recovery on device engine reset/resume failure

panel:
- panel-simple: Fix settings for Evervision VGG644804

sysfb:
- Fix screen_info type check

video:
- Update screen_info for relocated PCI framebuffers

Signed-off-by: default avatarSimona Vetter <simona.vetter@ffwll.ch>
From: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20250606072853.GA13099@linux.fritz.box
parents 3c4c39cb f670b50e
Loading
Loading
Loading
Loading
+36 −30
Original line number Diff line number Diff line
@@ -33,6 +33,16 @@ static inline void ivpu_dbg_bo(struct ivpu_device *vdev, struct ivpu_bo *bo, con
		 (bool)bo->base.base.import_attach);
}

static inline int ivpu_bo_lock(struct ivpu_bo *bo)
{
	return dma_resv_lock(bo->base.base.resv, NULL);
}

static inline void ivpu_bo_unlock(struct ivpu_bo *bo)
{
	dma_resv_unlock(bo->base.base.resv);
}

/*
 * ivpu_bo_pin() - pin the backing physical pages and map them to VPU.
 *
@@ -43,22 +53,22 @@ static inline void ivpu_dbg_bo(struct ivpu_device *vdev, struct ivpu_bo *bo, con
int __must_check ivpu_bo_pin(struct ivpu_bo *bo)
{
	struct ivpu_device *vdev = ivpu_bo_to_vdev(bo);
	struct sg_table *sgt;
	int ret = 0;

	mutex_lock(&bo->lock);

	ivpu_dbg_bo(vdev, bo, "pin");
	drm_WARN_ON(&vdev->drm, !bo->ctx);

	if (!bo->mmu_mapped) {
		struct sg_table *sgt = drm_gem_shmem_get_pages_sgt(&bo->base);

	sgt = drm_gem_shmem_get_pages_sgt(&bo->base);
	if (IS_ERR(sgt)) {
		ret = PTR_ERR(sgt);
		ivpu_err(vdev, "Failed to map BO in IOMMU: %d\n", ret);
			goto unlock;
		return ret;
	}

	ivpu_bo_lock(bo);

	if (!bo->mmu_mapped) {
		drm_WARN_ON(&vdev->drm, !bo->ctx);
		ret = ivpu_mmu_context_map_sgt(vdev, bo->ctx, bo->vpu_addr, sgt,
					       ivpu_bo_is_snooped(bo));
		if (ret) {
@@ -69,7 +79,7 @@ int __must_check ivpu_bo_pin(struct ivpu_bo *bo)
	}

unlock:
	mutex_unlock(&bo->lock);
	ivpu_bo_unlock(bo);

	return ret;
}
@@ -84,7 +94,7 @@ ivpu_bo_alloc_vpu_addr(struct ivpu_bo *bo, struct ivpu_mmu_context *ctx,
	if (!drm_dev_enter(&vdev->drm, &idx))
		return -ENODEV;

	mutex_lock(&bo->lock);
	ivpu_bo_lock(bo);

	ret = ivpu_mmu_context_insert_node(ctx, range, ivpu_bo_size(bo), &bo->mm_node);
	if (!ret) {
@@ -94,7 +104,7 @@ ivpu_bo_alloc_vpu_addr(struct ivpu_bo *bo, struct ivpu_mmu_context *ctx,
		ivpu_err(vdev, "Failed to add BO to context %u: %d\n", ctx->id, ret);
	}

	mutex_unlock(&bo->lock);
	ivpu_bo_unlock(bo);

	drm_dev_exit(idx);

@@ -105,7 +115,7 @@ static void ivpu_bo_unbind_locked(struct ivpu_bo *bo)
{
	struct ivpu_device *vdev = ivpu_bo_to_vdev(bo);

	lockdep_assert(lockdep_is_held(&bo->lock) || !kref_read(&bo->base.base.refcount));
	lockdep_assert(dma_resv_held(bo->base.base.resv) || !kref_read(&bo->base.base.refcount));

	if (bo->mmu_mapped) {
		drm_WARN_ON(&vdev->drm, !bo->ctx);
@@ -123,14 +133,12 @@ static void ivpu_bo_unbind_locked(struct ivpu_bo *bo)
	if (bo->base.base.import_attach)
		return;

	dma_resv_lock(bo->base.base.resv, NULL);
	if (bo->base.sgt) {
		dma_unmap_sgtable(vdev->drm.dev, bo->base.sgt, DMA_BIDIRECTIONAL, 0);
		sg_free_table(bo->base.sgt);
		kfree(bo->base.sgt);
		bo->base.sgt = NULL;
	}
	dma_resv_unlock(bo->base.base.resv);
}

void ivpu_bo_unbind_all_bos_from_context(struct ivpu_device *vdev, struct ivpu_mmu_context *ctx)
@@ -142,12 +150,12 @@ void ivpu_bo_unbind_all_bos_from_context(struct ivpu_device *vdev, struct ivpu_m

	mutex_lock(&vdev->bo_list_lock);
	list_for_each_entry(bo, &vdev->bo_list, bo_list_node) {
		mutex_lock(&bo->lock);
		ivpu_bo_lock(bo);
		if (bo->ctx == ctx) {
			ivpu_dbg_bo(vdev, bo, "unbind");
			ivpu_bo_unbind_locked(bo);
		}
		mutex_unlock(&bo->lock);
		ivpu_bo_unlock(bo);
	}
	mutex_unlock(&vdev->bo_list_lock);
}
@@ -167,7 +175,6 @@ struct drm_gem_object *ivpu_gem_create_object(struct drm_device *dev, size_t siz
	bo->base.pages_mark_dirty_on_put = true; /* VPU can dirty a BO anytime */

	INIT_LIST_HEAD(&bo->bo_list_node);
	mutex_init(&bo->lock);

	return &bo->base.base;
}
@@ -278,7 +285,8 @@ static void ivpu_gem_bo_free(struct drm_gem_object *obj)
	list_del(&bo->bo_list_node);
	mutex_unlock(&vdev->bo_list_lock);

	drm_WARN_ON(&vdev->drm, !dma_resv_test_signaled(obj->resv, DMA_RESV_USAGE_READ));
	drm_WARN_ON(&vdev->drm, !drm_gem_is_imported(&bo->base.base) &&
		    !dma_resv_test_signaled(obj->resv, DMA_RESV_USAGE_READ));
	drm_WARN_ON(&vdev->drm, ivpu_bo_size(bo) == 0);
	drm_WARN_ON(&vdev->drm, bo->base.vaddr);

@@ -286,8 +294,6 @@ static void ivpu_gem_bo_free(struct drm_gem_object *obj)
	drm_WARN_ON(&vdev->drm, bo->mmu_mapped);
	drm_WARN_ON(&vdev->drm, bo->ctx);

	mutex_destroy(&bo->lock);

	drm_WARN_ON(obj->dev, bo->base.pages_use_count > 1);
	drm_gem_shmem_free(&bo->base);
}
@@ -370,9 +376,9 @@ ivpu_bo_create(struct ivpu_device *vdev, struct ivpu_mmu_context *ctx,
		goto err_put;

	if (flags & DRM_IVPU_BO_MAPPABLE) {
		dma_resv_lock(bo->base.base.resv, NULL);
		ivpu_bo_lock(bo);
		ret = drm_gem_shmem_vmap(&bo->base, &map);
		dma_resv_unlock(bo->base.base.resv);
		ivpu_bo_unlock(bo);

		if (ret)
			goto err_put;
@@ -395,9 +401,9 @@ void ivpu_bo_free(struct ivpu_bo *bo)
	struct iosys_map map = IOSYS_MAP_INIT_VADDR(bo->base.vaddr);

	if (bo->flags & DRM_IVPU_BO_MAPPABLE) {
		dma_resv_lock(bo->base.base.resv, NULL);
		ivpu_bo_lock(bo);
		drm_gem_shmem_vunmap(&bo->base, &map);
		dma_resv_unlock(bo->base.base.resv);
		ivpu_bo_unlock(bo);
	}

	drm_gem_object_put(&bo->base.base);
@@ -416,12 +422,12 @@ int ivpu_bo_info_ioctl(struct drm_device *dev, void *data, struct drm_file *file

	bo = to_ivpu_bo(obj);

	mutex_lock(&bo->lock);
	ivpu_bo_lock(bo);
	args->flags = bo->flags;
	args->mmap_offset = drm_vma_node_offset_addr(&obj->vma_node);
	args->vpu_addr = bo->vpu_addr;
	args->size = obj->size;
	mutex_unlock(&bo->lock);
	ivpu_bo_unlock(bo);

	drm_gem_object_put(obj);
	return ret;
@@ -458,7 +464,7 @@ int ivpu_bo_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file

static void ivpu_bo_print_info(struct ivpu_bo *bo, struct drm_printer *p)
{
	mutex_lock(&bo->lock);
	ivpu_bo_lock(bo);

	drm_printf(p, "%-9p %-3u 0x%-12llx %-10lu 0x%-8x %-4u",
		   bo, bo->ctx_id, bo->vpu_addr, bo->base.base.size,
@@ -475,7 +481,7 @@ static void ivpu_bo_print_info(struct ivpu_bo *bo, struct drm_printer *p)

	drm_printf(p, "\n");

	mutex_unlock(&bo->lock);
	ivpu_bo_unlock(bo);
}

void ivpu_bo_list(struct drm_device *dev, struct drm_printer *p)
+0 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ struct ivpu_bo {
	struct list_head bo_list_node;
	struct drm_mm_node mm_node;

	struct mutex lock; /* Protects: ctx, mmu_mapped, vpu_addr */
	u64 vpu_addr;
	u32 flags;
	u32 job_status; /* Valid only for command buffer */
+4 −2
Original line number Diff line number Diff line
@@ -986,7 +986,8 @@ void ivpu_context_abort_work_fn(struct work_struct *work)
		return;

	if (vdev->fw->sched_mode == VPU_SCHEDULING_MODE_HW)
		ivpu_jsm_reset_engine(vdev, 0);
		if (ivpu_jsm_reset_engine(vdev, 0))
			return;

	mutex_lock(&vdev->context_list_lock);
	xa_for_each(&vdev->context_xa, ctx_id, file_priv) {
@@ -1009,7 +1010,8 @@ void ivpu_context_abort_work_fn(struct work_struct *work)
	if (vdev->fw->sched_mode != VPU_SCHEDULING_MODE_HW)
		goto runtime_put;

	ivpu_jsm_hws_resume_engine(vdev, 0);
	if (ivpu_jsm_hws_resume_engine(vdev, 0))
		return;
	/*
	 * In hardware scheduling mode NPU already has stopped processing jobs
	 * and won't send us any further notifications, thus we have to free job related resources
+7 −2
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
#include "ivpu_hw.h"
#include "ivpu_ipc.h"
#include "ivpu_jsm_msg.h"
#include "ivpu_pm.h"
#include "vpu_jsm_api.h"

const char *ivpu_jsm_msg_type_to_str(enum vpu_ipc_msg_type type)
@@ -163,8 +164,10 @@ int ivpu_jsm_reset_engine(struct ivpu_device *vdev, u32 engine)

	ret = ivpu_ipc_send_receive(vdev, &req, VPU_JSM_MSG_ENGINE_RESET_DONE, &resp,
				    VPU_IPC_CHAN_ASYNC_CMD, vdev->timeout.jsm);
	if (ret)
	if (ret) {
		ivpu_err_ratelimited(vdev, "Failed to reset engine %d: %d\n", engine, ret);
		ivpu_pm_trigger_recovery(vdev, "Engine reset failed");
	}

	return ret;
}
@@ -354,8 +357,10 @@ int ivpu_jsm_hws_resume_engine(struct ivpu_device *vdev, u32 engine)

	ret = ivpu_ipc_send_receive(vdev, &req, VPU_JSM_MSG_HWS_RESUME_ENGINE_DONE, &resp,
				    VPU_IPC_CHAN_ASYNC_CMD, vdev->timeout.jsm);
	if (ret)
	if (ret) {
		ivpu_err_ratelimited(vdev, "Failed to resume engine %d: %d\n", engine, ret);
		ivpu_pm_trigger_recovery(vdev, "Engine resume failed");
	}

	return ret;
}
+18 −8
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ static __init int sysfb_init(void)
{
	struct screen_info *si = &screen_info;
	struct device *parent;
	unsigned int type;
	struct simplefb_platform_data mode;
	const char *name;
	bool compatible;
@@ -170,17 +171,26 @@ static __init int sysfb_init(void)
			goto put_device;
	}

	type = screen_info_video_type(si);

	/* if the FB is incompatible, create a legacy framebuffer device */
	if (si->orig_video_isVGA == VIDEO_TYPE_EFI)
		name = "efi-framebuffer";
	else if (si->orig_video_isVGA == VIDEO_TYPE_VLFB)
		name = "vesa-framebuffer";
	else if (si->orig_video_isVGA == VIDEO_TYPE_VGAC)
		name = "vga-framebuffer";
	else if (si->orig_video_isVGA == VIDEO_TYPE_EGAC)
	switch (type) {
	case VIDEO_TYPE_EGAC:
		name = "ega-framebuffer";
	else
		break;
	case VIDEO_TYPE_VGAC:
		name = "vga-framebuffer";
		break;
	case VIDEO_TYPE_VLFB:
		name = "vesa-framebuffer";
		break;
	case VIDEO_TYPE_EFI:
		name = "efi-framebuffer";
		break;
	default:
		name = "platform-framebuffer";
		break;
	}

	pd = platform_device_alloc(name, 0);
	if (!pd) {
Loading