* [PATCH V8 1/5] drm: add drm_file_err function to add process info
@ 2025-04-17 16:10 Sunil Khatri
2025-04-17 16:10 ` [PATCH V8 2/5] drm/amdgpu: add drm_file reference in userq_mgr Sunil Khatri
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Sunil Khatri @ 2025-04-17 16:10 UTC (permalink / raw)
To: dri-devel, amd-gfx, Jani Nikula
Cc: Alex Deucher, Christian König, Tvrtko Ursulin,
Pierre-Eric Pelloux-Prayer, Sunil Khatri
Add a drm helper function which appends the process information for
the drm_file over drm_err formatted output.
v5: change to macro from function (Christian Koenig)
add helper functions for lock/unlock (Christian Koenig)
v6: remove __maybe_unused and make function inline (Jani Nikula)
remove drm_print.h
v7: Use va_format and %pV to concatenate fmt and vargs (Jani Nikula)
v8: Code formatting and typos (Ursulin tvrtko)
Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
---
drivers/gpu/drm/drm_file.c | 34 ++++++++++++++++++++++++++++++++++
include/drm/drm_file.h | 3 +++
2 files changed, 37 insertions(+)
diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index c299cd94d3f7..dd351f601acd 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -986,6 +986,40 @@ void drm_show_fdinfo(struct seq_file *m, struct file *f)
}
EXPORT_SYMBOL(drm_show_fdinfo);
+/**
+ * drm_file_err - log process name, pid and client_name associated with a drm_file
+ * @file_priv: context of interest for process name and pid
+ * @fmt: printf() like format string
+ *
+ * Helper function for clients which needs to log process details such
+ * as name and pid etc along with user logs.
+ */
+void drm_file_err(struct drm_file *file_priv, const char *fmt, ...)
+{
+ va_list args;
+ struct va_format vaf;
+ struct pid *pid;
+ struct task_struct *task;
+ struct drm_device *dev = file_priv->minor->dev;
+
+ va_start(args, fmt);
+ vaf.fmt = fmt;
+ vaf.va = &args;
+
+ mutex_lock(&file_priv->client_name_lock);
+ rcu_read_lock();
+ pid = rcu_dereference(file_priv->pid);
+ task = pid_task(pid, PIDTYPE_TGID);
+
+ drm_err(dev, "comm: %s pid: %d client: %s ... %pV", task ? task->comm : "Unset",
+ task ? task->pid : 0, file_priv->client_name ?: "Unset", &vaf);
+
+ va_end(args);
+ rcu_read_unlock();
+ mutex_unlock(&file_priv->client_name_lock);
+}
+EXPORT_SYMBOL(drm_file_err);
+
/**
* mock_drm_getfile - Create a new struct file for the drm device
* @minor: drm minor to wrap (e.g. #drm_device.primary)
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 94d365b22505..5c3b2aa3e69d 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -446,6 +446,9 @@ static inline bool drm_is_accel_client(const struct drm_file *file_priv)
return file_priv->minor->type == DRM_MINOR_ACCEL;
}
+__printf(2, 3)
+void drm_file_err(struct drm_file *file_priv, const char *fmt, ...);
+
void drm_file_update_pid(struct drm_file *);
struct drm_minor *drm_minor_acquire(struct xarray *minors_xa, unsigned int minor_id);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH V8 2/5] drm/amdgpu: add drm_file reference in userq_mgr
2025-04-17 16:10 [PATCH V8 1/5] drm: add drm_file_err function to add process info Sunil Khatri
@ 2025-04-17 16:10 ` Sunil Khatri
2025-04-22 8:37 ` Christian König
2025-04-17 16:10 ` [PATCH V8 3/5] drm/amdgpu: use drm_file_err in fence timeouts Sunil Khatri
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Sunil Khatri @ 2025-04-17 16:10 UTC (permalink / raw)
To: dri-devel, amd-gfx, Jani Nikula
Cc: Alex Deucher, Christian König, Tvrtko Ursulin,
Pierre-Eric Pelloux-Prayer, Sunil Khatri
drm_file will be used in usermode queues code to
enable better process information in logging and hence
add drm_file part of the userq_mgr struct.
update the drm_file pointer in userq_mgr for each
amdgpu_driver_open_kms.
Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 +
drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 3d319687c1c9..3de3071d66ee 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -1436,6 +1436,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
amdgpu_ctx_mgr_init(&fpriv->ctx_mgr, adev);
+ fpriv->userq_mgr.file = file_priv;
r = amdgpu_userq_mgr_init(&fpriv->userq_mgr, adev);
if (r)
DRM_WARN("Can't setup usermode queues, use legacy workload submission only\n");
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
index b2da513b3d02..29c1360d8c8c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
@@ -79,6 +79,7 @@ struct amdgpu_userq_mgr {
struct amdgpu_device *adev;
struct delayed_work resume_work;
struct list_head list;
+ struct drm_file *file;
};
struct amdgpu_db_info {
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH V8 3/5] drm/amdgpu: use drm_file_err in fence timeouts
2025-04-17 16:10 [PATCH V8 1/5] drm: add drm_file_err function to add process info Sunil Khatri
2025-04-17 16:10 ` [PATCH V8 2/5] drm/amdgpu: add drm_file reference in userq_mgr Sunil Khatri
@ 2025-04-17 16:10 ` Sunil Khatri
2025-04-17 16:10 ` [PATCH V8 4/5] drm/amdgpu: change DRM_ERROR to drm_file_err in amdgpu_userqueue.c Sunil Khatri
` (2 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Sunil Khatri @ 2025-04-17 16:10 UTC (permalink / raw)
To: dri-devel, amd-gfx, Jani Nikula
Cc: Alex Deucher, Christian König, Tvrtko Ursulin,
Pierre-Eric Pelloux-Prayer, Sunil Khatri
use drm_file_err instead of DRM_ERROR which adds
process and pid information in the userqueue error
logging.
Sample log:
[ 19.802315] amdgpu 0000:0a:00.0: [drm] *ERROR* comm: ibus-x11 pid: 2055 client: Unset ... Couldn't unmap all the queues
[ 19.802319] amdgpu 0000:0a:00.0: [drm] *ERROR* comm: ibus-x11 pid: 2055 client: Unset ... Failed to evict userqueue
[ 19.838432] amdgpu 0000:0a:00.0: [drm] *ERROR* comm: systemd-logind pid: 1042 client: Unset ... Couldn't unmap all the queues
[ 19.838436] amdgpu 0000:0a:00.0: [drm] *ERROR* comm: systemd-logind pid: 1042 client: Unset ... Failed to evict userqueue
Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c | 21 ++++++++++++-------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
index 5f87cc8b5bf4..e3290d137017 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
@@ -44,8 +44,9 @@ amdgpu_userqueue_cleanup(struct amdgpu_userq_mgr *uq_mgr,
if (f && !dma_fence_is_signaled(f)) {
ret = dma_fence_wait_timeout(f, true, msecs_to_jiffies(100));
if (ret <= 0) {
- DRM_ERROR("Timed out waiting for fence=%llu:%llu\n",
- f->context, f->seqno);
+ drm_file_err(uq_mgr->file,
+ "Timed out waiting for fence: context=%llu seqno:%llu\n",
+ f->context, f->seqno);
return;
}
}
@@ -480,7 +481,8 @@ amdgpu_userqueue_resume_all(struct amdgpu_userq_mgr *uq_mgr)
}
if (ret)
- DRM_ERROR("Failed to map all the queues\n");
+ drm_file_err(uq_mgr->file, "Failed to map all the queues\n");
+
return ret;
}
@@ -638,7 +640,8 @@ amdgpu_userqueue_suspend_all(struct amdgpu_userq_mgr *uq_mgr)
}
if (ret)
- DRM_ERROR("Couldn't unmap all the queues\n");
+ drm_file_err(uq_mgr->file, "Couldn't unmap all the queues\n");
+
return ret;
}
@@ -655,8 +658,10 @@ amdgpu_userqueue_wait_for_signal(struct amdgpu_userq_mgr *uq_mgr)
continue;
ret = dma_fence_wait_timeout(f, true, msecs_to_jiffies(100));
if (ret <= 0) {
- DRM_ERROR("Timed out waiting for fence=%llu:%llu\n",
- f->context, f->seqno);
+ drm_file_err(uq_mgr->file,
+ "Timed out waiting for fence: context=%llu seqno:%llu\n",
+ f->context, f->seqno);
+
return -ETIMEDOUT;
}
}
@@ -675,13 +680,13 @@ amdgpu_userqueue_suspend(struct amdgpu_userq_mgr *uq_mgr,
/* Wait for any pending userqueue fence work to finish */
ret = amdgpu_userqueue_wait_for_signal(uq_mgr);
if (ret) {
- DRM_ERROR("Not suspending userqueue, timeout waiting for work\n");
+ drm_file_err(uq_mgr->file, "Not suspending userqueue, timeout waiting\n");
return;
}
ret = amdgpu_userqueue_suspend_all(uq_mgr);
if (ret) {
- DRM_ERROR("Failed to evict userqueue\n");
+ drm_file_err(uq_mgr->file, "Failed to evict userqueue\n");
return;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH V8 4/5] drm/amdgpu: change DRM_ERROR to drm_file_err in amdgpu_userqueue.c
2025-04-17 16:10 [PATCH V8 1/5] drm: add drm_file_err function to add process info Sunil Khatri
2025-04-17 16:10 ` [PATCH V8 2/5] drm/amdgpu: add drm_file reference in userq_mgr Sunil Khatri
2025-04-17 16:10 ` [PATCH V8 3/5] drm/amdgpu: use drm_file_err in fence timeouts Sunil Khatri
@ 2025-04-17 16:10 ` Sunil Khatri
2025-04-17 16:10 ` [PATCH V8 5/5] drm/amdgpu: change DRM_DBG_DRIVER to drm_dbg_driver Sunil Khatri
2025-04-22 9:03 ` [PATCH V8 1/5] drm: add drm_file_err function to add process info Christian König
4 siblings, 0 replies; 11+ messages in thread
From: Sunil Khatri @ 2025-04-17 16:10 UTC (permalink / raw)
To: dri-devel, amd-gfx, Jani Nikula
Cc: Alex Deucher, Christian König, Tvrtko Ursulin,
Pierre-Eric Pelloux-Prayer, Sunil Khatri
change the DRM_ERROR to drm_file_err to add process name
and pid to the logging.
Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c | 52 +++++++++++--------
1 file changed, 29 insertions(+), 23 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
index e3290d137017..44805927c612 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
@@ -126,25 +126,25 @@ int amdgpu_userqueue_create_object(struct amdgpu_userq_mgr *uq_mgr,
r = amdgpu_bo_create(adev, &bp, &userq_obj->obj);
if (r) {
- DRM_ERROR("Failed to allocate BO for userqueue (%d)", r);
+ drm_file_err(uq_mgr->file, "Failed to allocate BO for userqueue (%d)", r);
return r;
}
r = amdgpu_bo_reserve(userq_obj->obj, true);
if (r) {
- DRM_ERROR("Failed to reserve BO to map (%d)", r);
+ drm_file_err(uq_mgr->file, "Failed to reserve BO to map (%d)", r);
goto free_obj;
}
r = amdgpu_ttm_alloc_gart(&(userq_obj->obj)->tbo);
if (r) {
- DRM_ERROR("Failed to alloc GART for userqueue object (%d)", r);
+ drm_file_err(uq_mgr->file, "Failed to alloc GART for userqueue object (%d)", r);
goto unresv;
}
r = amdgpu_bo_kmap(userq_obj->obj, &userq_obj->cpu_ptr);
if (r) {
- DRM_ERROR("Failed to map BO for userqueue (%d)", r);
+ drm_file_err(uq_mgr->file, "Failed to map BO for userqueue (%d)", r);
goto unresv;
}
@@ -180,7 +180,7 @@ amdgpu_userqueue_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr,
gobj = drm_gem_object_lookup(filp, db_info->doorbell_handle);
if (gobj == NULL) {
- DRM_ERROR("Can't find GEM object for doorbell\n");
+ drm_file_err(uq_mgr->file, "Can't find GEM object for doorbell\n");
return -EINVAL;
}
@@ -190,13 +190,15 @@ amdgpu_userqueue_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr,
/* Pin the BO before generating the index, unpin in queue destroy */
r = amdgpu_bo_pin(db_obj->obj, AMDGPU_GEM_DOMAIN_DOORBELL);
if (r) {
- DRM_ERROR("[Usermode queues] Failed to pin doorbell object\n");
+ drm_file_err(uq_mgr->file,
+ "[Usermode queues] Failed to pin doorbell object\n");
goto unref_bo;
}
r = amdgpu_bo_reserve(db_obj->obj, true);
if (r) {
- DRM_ERROR("[Usermode queues] Failed to pin doorbell object\n");
+ drm_file_err(uq_mgr->file,
+ "[Usermode queues] Failed to pin doorbell object\n");
goto unpin_bo;
}
@@ -218,7 +220,8 @@ amdgpu_userqueue_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr,
break;
default:
- DRM_ERROR("[Usermode queues] IP %d not support\n", db_info->queue_type);
+ drm_file_err(uq_mgr->file,
+ "[Usermode queues] IP %d not support\n", db_info->queue_type);
r = -EINVAL;
goto unpin_bo;
}
@@ -304,7 +307,8 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
if (args->in.ip_type != AMDGPU_HW_IP_GFX &&
args->in.ip_type != AMDGPU_HW_IP_DMA &&
args->in.ip_type != AMDGPU_HW_IP_COMPUTE) {
- DRM_ERROR("Usermode queue doesn't support IP type %u\n", args->in.ip_type);
+ drm_file_err(uq_mgr->file,
+ "Usermode queue doesn't support IP type %u\n", args->in.ip_type);
return -EINVAL;
}
@@ -330,14 +334,16 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
uq_funcs = adev->userq_funcs[args->in.ip_type];
if (!uq_funcs) {
- DRM_ERROR("Usermode queue is not supported for this IP (%u)\n", args->in.ip_type);
+ drm_file_err(uq_mgr->file,
+ "Usermode queue is not supported for this IP (%u)\n",
+ args->in.ip_type);
r = -EINVAL;
goto unlock;
}
queue = kzalloc(sizeof(struct amdgpu_usermode_queue), GFP_KERNEL);
if (!queue) {
- DRM_ERROR("Failed to allocate memory for queue\n");
+ drm_file_err(uq_mgr->file, "Failed to allocate memory for queue\n");
r = -ENOMEM;
goto unlock;
}
@@ -354,7 +360,7 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
/* Convert relative doorbell offset into absolute doorbell index */
index = amdgpu_userqueue_get_doorbell_index(uq_mgr, &db_info, filp);
if (index == (uint64_t)-EINVAL) {
- DRM_ERROR("Failed to get doorbell for queue\n");
+ drm_file_err(uq_mgr->file, "Failed to get doorbell for queue\n");
kfree(queue);
goto unlock;
}
@@ -363,13 +369,13 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
xa_init_flags(&queue->fence_drv_xa, XA_FLAGS_ALLOC);
r = amdgpu_userq_fence_driver_alloc(adev, queue);
if (r) {
- DRM_ERROR("Failed to alloc fence driver\n");
+ drm_file_err(uq_mgr->file, "Failed to alloc fence driver\n");
goto unlock;
}
r = uq_funcs->mqd_create(uq_mgr, &args->in, queue);
if (r) {
- DRM_ERROR("Failed to create Queue\n");
+ drm_file_err(uq_mgr->file, "Failed to create Queue\n");
amdgpu_userq_fence_driver_free(queue);
kfree(queue);
goto unlock;
@@ -378,7 +384,7 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
qid = idr_alloc(&uq_mgr->userq_idr, queue, 1, AMDGPU_MAX_USERQ_COUNT, GFP_KERNEL);
if (qid < 0) {
- DRM_ERROR("Failed to allocate a queue id\n");
+ drm_file_err(uq_mgr->file, "Failed to allocate a queue id\n");
amdgpu_userq_fence_driver_free(queue);
uq_funcs->mqd_destroy(uq_mgr, queue);
kfree(queue);
@@ -398,7 +404,7 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
r = uq_funcs->map(uq_mgr, queue);
if (r) {
mutex_unlock(&adev->userq_mutex);
- DRM_ERROR("Failed to map Queue\n");
+ drm_file_err(uq_mgr->file, "Failed to map Queue\n");
idr_remove(&uq_mgr->userq_idr, qid);
amdgpu_userq_fence_driver_free(queue);
uq_funcs->mqd_destroy(uq_mgr, queue);
@@ -429,7 +435,7 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void *data,
return -EINVAL;
r = amdgpu_userqueue_create(filp, args);
if (r)
- DRM_ERROR("Failed to create usermode queue\n");
+ drm_file_err(filp, "Failed to create usermode queue\n");
break;
case AMDGPU_USERQ_OP_FREE:
@@ -447,7 +453,7 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void *data,
return -EINVAL;
r = amdgpu_userqueue_destroy(filp, args->in.queue_id);
if (r)
- DRM_ERROR("Failed to destroy usermode queue\n");
+ drm_file_err(filp, "Failed to destroy usermode queue\n");
break;
default:
@@ -520,7 +526,7 @@ amdgpu_userqueue_validate_bos(struct amdgpu_userq_mgr *uq_mgr)
ret = amdgpu_vm_lock_pd(vm, &exec, 2);
drm_exec_retry_on_contention(&exec);
if (unlikely(ret)) {
- DRM_ERROR("Failed to lock PD\n");
+ drm_file_err(uq_mgr->file, "Failed to lock PD\n");
goto unlock_all;
}
@@ -560,7 +566,7 @@ amdgpu_userqueue_validate_bos(struct amdgpu_userq_mgr *uq_mgr)
bo = bo_va->base.bo;
ret = amdgpu_userqueue_validate_vm_bo(NULL, bo);
if (ret) {
- DRM_ERROR("Failed to validate BO\n");
+ drm_file_err(uq_mgr->file, "Failed to validate BO\n");
goto unlock_all;
}
@@ -591,7 +597,7 @@ amdgpu_userqueue_validate_bos(struct amdgpu_userq_mgr *uq_mgr)
ret = amdgpu_eviction_fence_replace_fence(&fpriv->evf_mgr, &exec);
if (ret)
- DRM_ERROR("Failed to replace eviction fence\n");
+ drm_file_err(uq_mgr->file, "Failed to replace eviction fence\n");
unlock_all:
drm_exec_fini(&exec);
@@ -610,13 +616,13 @@ static void amdgpu_userqueue_resume_worker(struct work_struct *work)
ret = amdgpu_userqueue_validate_bos(uq_mgr);
if (ret) {
- DRM_ERROR("Failed to validate BOs to restore\n");
+ drm_file_err(uq_mgr->file, "Failed to validate BOs to restore\n");
goto unlock;
}
ret = amdgpu_userqueue_resume_all(uq_mgr);
if (ret) {
- DRM_ERROR("Failed to resume all queues\n");
+ drm_file_err(uq_mgr->file, "Failed to resume all queues\n");
goto unlock;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH V8 5/5] drm/amdgpu: change DRM_DBG_DRIVER to drm_dbg_driver
2025-04-17 16:10 [PATCH V8 1/5] drm: add drm_file_err function to add process info Sunil Khatri
` (2 preceding siblings ...)
2025-04-17 16:10 ` [PATCH V8 4/5] drm/amdgpu: change DRM_ERROR to drm_file_err in amdgpu_userqueue.c Sunil Khatri
@ 2025-04-17 16:10 ` Sunil Khatri
2025-04-22 9:03 ` [PATCH V8 1/5] drm: add drm_file_err function to add process info Christian König
4 siblings, 0 replies; 11+ messages in thread
From: Sunil Khatri @ 2025-04-17 16:10 UTC (permalink / raw)
To: dri-devel, amd-gfx, Jani Nikula
Cc: Alex Deucher, Christian König, Tvrtko Ursulin,
Pierre-Eric Pelloux-Prayer, Sunil Khatri
update the functions in amdgpu_userqueues.c from
DRM_DBG_DRIVER to drm_dbg_driver so multi gpu instance
can be logged in.
Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
index 44805927c612..0e69cc18af24 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
@@ -228,7 +228,8 @@ amdgpu_userqueue_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr,
index = amdgpu_doorbell_index_on_bar(uq_mgr->adev, db_obj->obj,
db_info->doorbell_offset, db_size);
- DRM_DEBUG_DRIVER("[Usermode queues] doorbell index=%lld\n", index);
+ drm_dbg_driver(adev_to_drm(uq_mgr->adev),
+ "[Usermode queues] doorbell index=%lld\n", index);
amdgpu_bo_unreserve(db_obj->obj);
return index;
@@ -255,7 +256,7 @@ amdgpu_userqueue_destroy(struct drm_file *filp, int queue_id)
queue = amdgpu_userqueue_find(uq_mgr, queue_id);
if (!queue) {
- DRM_DEBUG_DRIVER("Invalid queue id to destroy\n");
+ drm_dbg_driver(adev_to_drm(adev), "Invalid queue id to destroy\n");
mutex_unlock(&uq_mgr->userq_mutex);
return -EINVAL;
}
@@ -457,7 +458,8 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void *data,
break;
default:
- DRM_DEBUG_DRIVER("Invalid user queue op specified: %d\n", args->in.op);
+ drm_dbg_driver(dev, "Invalid user queue op specified: %d\n",
+ args->in.op);
return -EINVAL;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH V8 2/5] drm/amdgpu: add drm_file reference in userq_mgr
2025-04-17 16:10 ` [PATCH V8 2/5] drm/amdgpu: add drm_file reference in userq_mgr Sunil Khatri
@ 2025-04-22 8:37 ` Christian König
2025-04-22 8:57 ` Khatri, Sunil
0 siblings, 1 reply; 11+ messages in thread
From: Christian König @ 2025-04-22 8:37 UTC (permalink / raw)
To: Sunil Khatri, dri-devel, amd-gfx, Jani Nikula
Cc: Alex Deucher, Tvrtko Ursulin, Pierre-Eric Pelloux-Prayer
Am 17.04.25 um 18:10 schrieb Sunil Khatri:
> drm_file will be used in usermode queues code to
> enable better process information in logging and hence
> add drm_file part of the userq_mgr struct.
>
> update the drm_file pointer in userq_mgr for each
> amdgpu_driver_open_kms.
>
> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 +
> drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 3d319687c1c9..3de3071d66ee 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -1436,6 +1436,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
>
> amdgpu_ctx_mgr_init(&fpriv->ctx_mgr, adev);
>
> + fpriv->userq_mgr.file = file_priv;
> r = amdgpu_userq_mgr_init(&fpriv->userq_mgr, adev);
It would be cleaner to give that as parameter to amdgpu_userq_mgr_init() I think.
Apart from that Reviewed-by: Christian König <christian.koenig@amd.com>
Regards,
Christian.
> if (r)
> DRM_WARN("Can't setup usermode queues, use legacy workload submission only\n");
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
> index b2da513b3d02..29c1360d8c8c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
> @@ -79,6 +79,7 @@ struct amdgpu_userq_mgr {
> struct amdgpu_device *adev;
> struct delayed_work resume_work;
> struct list_head list;
> + struct drm_file *file;
> };
>
> struct amdgpu_db_info {
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V8 2/5] drm/amdgpu: add drm_file reference in userq_mgr
2025-04-22 8:37 ` Christian König
@ 2025-04-22 8:57 ` Khatri, Sunil
0 siblings, 0 replies; 11+ messages in thread
From: Khatri, Sunil @ 2025-04-22 8:57 UTC (permalink / raw)
To: Christian König, Sunil Khatri, dri-devel, amd-gfx,
Jani Nikula
Cc: Alex Deucher, Tvrtko Ursulin, Pierre-Eric Pelloux-Prayer
On 4/22/2025 2:07 PM, Christian König wrote:
> Am 17.04.25 um 18:10 schrieb Sunil Khatri:
>> drm_file will be used in usermode queues code to
>> enable better process information in logging and hence
>> add drm_file part of the userq_mgr struct.
>>
>> update the drm_file pointer in userq_mgr for each
>> amdgpu_driver_open_kms.
>>
>> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
>> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 +
>> drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h | 1 +
>> 2 files changed, 2 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> index 3d319687c1c9..3de3071d66ee 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> @@ -1436,6 +1436,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
>>
>> amdgpu_ctx_mgr_init(&fpriv->ctx_mgr, adev);
>>
>> + fpriv->userq_mgr.file = file_priv;
>> r = amdgpu_userq_mgr_init(&fpriv->userq_mgr, adev);
> It would be cleaner to give that as parameter to amdgpu_userq_mgr_init() I think.
>
> Apart from that Reviewed-by: Christian König <christian.koenig@amd.com>
Thanks Chrisitian, i have that in mind already and will make the change
when pushing to asdn after drm patch [first in the series merged and
pulled back in asdn]
Regards
Sunil Khatri
>
> Regards,
> Christian.
>
>> if (r)
>> DRM_WARN("Can't setup usermode queues, use legacy workload submission only\n");
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
>> index b2da513b3d02..29c1360d8c8c 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
>> @@ -79,6 +79,7 @@ struct amdgpu_userq_mgr {
>> struct amdgpu_device *adev;
>> struct delayed_work resume_work;
>> struct list_head list;
>> + struct drm_file *file;
>> };
>>
>> struct amdgpu_db_info {
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V8 1/5] drm: add drm_file_err function to add process info
2025-04-17 16:10 [PATCH V8 1/5] drm: add drm_file_err function to add process info Sunil Khatri
` (3 preceding siblings ...)
2025-04-17 16:10 ` [PATCH V8 5/5] drm/amdgpu: change DRM_DBG_DRIVER to drm_dbg_driver Sunil Khatri
@ 2025-04-22 9:03 ` Christian König
2025-04-28 11:39 ` Khatri, Sunil
4 siblings, 1 reply; 11+ messages in thread
From: Christian König @ 2025-04-22 9:03 UTC (permalink / raw)
To: Sunil Khatri, dri-devel, amd-gfx, Jani Nikula, David Airlie,
Simona Vetter
Cc: Alex Deucher, Tvrtko Ursulin, Pierre-Eric Pelloux-Prayer
Am 17.04.25 um 18:10 schrieb Sunil Khatri:
> Add a drm helper function which appends the process information for
> the drm_file over drm_err formatted output.
>
> v5: change to macro from function (Christian Koenig)
> add helper functions for lock/unlock (Christian Koenig)
>
> v6: remove __maybe_unused and make function inline (Jani Nikula)
> remove drm_print.h
>
> v7: Use va_format and %pV to concatenate fmt and vargs (Jani Nikula)
>
> v8: Code formatting and typos (Ursulin tvrtko)
>
> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Any objections to merge this through amd-staging-drm-next?
The follow up amdgpu patches all depend on stuff in there which is not yet merged to drm-misc-next.
Thanks,
Christian.
> ---
> drivers/gpu/drm/drm_file.c | 34 ++++++++++++++++++++++++++++++++++
> include/drm/drm_file.h | 3 +++
> 2 files changed, 37 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index c299cd94d3f7..dd351f601acd 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -986,6 +986,40 @@ void drm_show_fdinfo(struct seq_file *m, struct file *f)
> }
> EXPORT_SYMBOL(drm_show_fdinfo);
>
> +/**
> + * drm_file_err - log process name, pid and client_name associated with a drm_file
> + * @file_priv: context of interest for process name and pid
> + * @fmt: printf() like format string
> + *
> + * Helper function for clients which needs to log process details such
> + * as name and pid etc along with user logs.
> + */
> +void drm_file_err(struct drm_file *file_priv, const char *fmt, ...)
> +{
> + va_list args;
> + struct va_format vaf;
> + struct pid *pid;
> + struct task_struct *task;
> + struct drm_device *dev = file_priv->minor->dev;
> +
> + va_start(args, fmt);
> + vaf.fmt = fmt;
> + vaf.va = &args;
> +
> + mutex_lock(&file_priv->client_name_lock);
> + rcu_read_lock();
> + pid = rcu_dereference(file_priv->pid);
> + task = pid_task(pid, PIDTYPE_TGID);
> +
> + drm_err(dev, "comm: %s pid: %d client: %s ... %pV", task ? task->comm : "Unset",
> + task ? task->pid : 0, file_priv->client_name ?: "Unset", &vaf);
> +
> + va_end(args);
> + rcu_read_unlock();
> + mutex_unlock(&file_priv->client_name_lock);
> +}
> +EXPORT_SYMBOL(drm_file_err);
> +
> /**
> * mock_drm_getfile - Create a new struct file for the drm device
> * @minor: drm minor to wrap (e.g. #drm_device.primary)
> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
> index 94d365b22505..5c3b2aa3e69d 100644
> --- a/include/drm/drm_file.h
> +++ b/include/drm/drm_file.h
> @@ -446,6 +446,9 @@ static inline bool drm_is_accel_client(const struct drm_file *file_priv)
> return file_priv->minor->type == DRM_MINOR_ACCEL;
> }
>
> +__printf(2, 3)
> +void drm_file_err(struct drm_file *file_priv, const char *fmt, ...);
> +
> void drm_file_update_pid(struct drm_file *);
>
> struct drm_minor *drm_minor_acquire(struct xarray *minors_xa, unsigned int minor_id);
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V8 1/5] drm: add drm_file_err function to add process info
2025-04-22 9:03 ` [PATCH V8 1/5] drm: add drm_file_err function to add process info Christian König
@ 2025-04-28 11:39 ` Khatri, Sunil
2025-04-28 11:49 ` Jani Nikula
0 siblings, 1 reply; 11+ messages in thread
From: Khatri, Sunil @ 2025-04-28 11:39 UTC (permalink / raw)
To: Christian König, Sunil Khatri, dri-devel, amd-gfx,
Jani Nikula, David Airlie, Simona Vetter
Cc: Alex Deucher, Tvrtko Ursulin, Pierre-Eric Pelloux-Prayer
On 4/22/2025 2:33 PM, Christian König wrote:
> Am 17.04.25 um 18:10 schrieb Sunil Khatri:
>> Add a drm helper function which appends the process information for
>> the drm_file over drm_err formatted output.
>>
>> v5: change to macro from function (Christian Koenig)
>> add helper functions for lock/unlock (Christian Koenig)
>>
>> v6: remove __maybe_unused and make function inline (Jani Nikula)
>> remove drm_print.h
>>
>> v7: Use va_format and %pV to concatenate fmt and vargs (Jani Nikula)
>>
>> v8: Code formatting and typos (Ursulin tvrtko)
>>
>> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
>> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
> Any objections to merge this through amd-staging-drm-next?
Gentle reminder here folks ??
> The follow up amdgpu patches all depend on stuff in there which is not yet merged to drm-misc-next.
>
> Thanks,
> Christian.
>
>> ---
>> drivers/gpu/drm/drm_file.c | 34 ++++++++++++++++++++++++++++++++++
>> include/drm/drm_file.h | 3 +++
>> 2 files changed, 37 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
>> index c299cd94d3f7..dd351f601acd 100644
>> --- a/drivers/gpu/drm/drm_file.c
>> +++ b/drivers/gpu/drm/drm_file.c
>> @@ -986,6 +986,40 @@ void drm_show_fdinfo(struct seq_file *m, struct file *f)
>> }
>> EXPORT_SYMBOL(drm_show_fdinfo);
>>
>> +/**
>> + * drm_file_err - log process name, pid and client_name associated with a drm_file
>> + * @file_priv: context of interest for process name and pid
>> + * @fmt: printf() like format string
>> + *
>> + * Helper function for clients which needs to log process details such
>> + * as name and pid etc along with user logs.
>> + */
>> +void drm_file_err(struct drm_file *file_priv, const char *fmt, ...)
>> +{
>> + va_list args;
>> + struct va_format vaf;
>> + struct pid *pid;
>> + struct task_struct *task;
>> + struct drm_device *dev = file_priv->minor->dev;
>> +
>> + va_start(args, fmt);
>> + vaf.fmt = fmt;
>> + vaf.va = &args;
>> +
>> + mutex_lock(&file_priv->client_name_lock);
>> + rcu_read_lock();
>> + pid = rcu_dereference(file_priv->pid);
>> + task = pid_task(pid, PIDTYPE_TGID);
>> +
>> + drm_err(dev, "comm: %s pid: %d client: %s ... %pV", task ? task->comm : "Unset",
>> + task ? task->pid : 0, file_priv->client_name ?: "Unset", &vaf);
>> +
>> + va_end(args);
>> + rcu_read_unlock();
>> + mutex_unlock(&file_priv->client_name_lock);
>> +}
>> +EXPORT_SYMBOL(drm_file_err);
>> +
>> /**
>> * mock_drm_getfile - Create a new struct file for the drm device
>> * @minor: drm minor to wrap (e.g. #drm_device.primary)
>> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
>> index 94d365b22505..5c3b2aa3e69d 100644
>> --- a/include/drm/drm_file.h
>> +++ b/include/drm/drm_file.h
>> @@ -446,6 +446,9 @@ static inline bool drm_is_accel_client(const struct drm_file *file_priv)
>> return file_priv->minor->type == DRM_MINOR_ACCEL;
>> }
>>
>> +__printf(2, 3)
>> +void drm_file_err(struct drm_file *file_priv, const char *fmt, ...);
>> +
>> void drm_file_update_pid(struct drm_file *);
>>
>> struct drm_minor *drm_minor_acquire(struct xarray *minors_xa, unsigned int minor_id);
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V8 1/5] drm: add drm_file_err function to add process info
2025-04-28 11:39 ` Khatri, Sunil
@ 2025-04-28 11:49 ` Jani Nikula
2025-04-30 14:40 ` Khatri, Sunil
0 siblings, 1 reply; 11+ messages in thread
From: Jani Nikula @ 2025-04-28 11:49 UTC (permalink / raw)
To: Khatri, Sunil, Christian König, Sunil Khatri, dri-devel,
amd-gfx, David Airlie, Simona Vetter, Maxime Ripard,
Maarten Lankhorst, Thomas Zimmermann
Cc: Alex Deucher, Tvrtko Ursulin, Pierre-Eric Pelloux-Prayer
On Mon, 28 Apr 2025, "Khatri, Sunil" <sukhatri@amd.com> wrote:
> On 4/22/2025 2:33 PM, Christian König wrote:
>> Am 17.04.25 um 18:10 schrieb Sunil Khatri:
>>> Add a drm helper function which appends the process information for
>>> the drm_file over drm_err formatted output.
>>>
>>> v5: change to macro from function (Christian Koenig)
>>> add helper functions for lock/unlock (Christian Koenig)
>>>
>>> v6: remove __maybe_unused and make function inline (Jani Nikula)
>>> remove drm_print.h
>>>
>>> v7: Use va_format and %pV to concatenate fmt and vargs (Jani Nikula)
>>>
>>> v8: Code formatting and typos (Ursulin tvrtko)
>>>
>>> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
>>> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
>> Any objections to merge this through amd-staging-drm-next?
> Gentle reminder here folks ??
It might help to Cc the drm-misc maintainers, though even that doesn't
always guarantee a reply. ;D
Done now.
Anyway, since I commented on an earlier version, and my feedback was
addressed,
Acked-by: Jani Nikula <jani.nikula@intel.com>
even though that does not help you merge via the amd tree.
BR,
Jani.
>> The follow up amdgpu patches all depend on stuff in there which is not yet merged to drm-misc-next.
>>
>> Thanks,
>> Christian.
>>
>>> ---
>>> drivers/gpu/drm/drm_file.c | 34 ++++++++++++++++++++++++++++++++++
>>> include/drm/drm_file.h | 3 +++
>>> 2 files changed, 37 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
>>> index c299cd94d3f7..dd351f601acd 100644
>>> --- a/drivers/gpu/drm/drm_file.c
>>> +++ b/drivers/gpu/drm/drm_file.c
>>> @@ -986,6 +986,40 @@ void drm_show_fdinfo(struct seq_file *m, struct file *f)
>>> }
>>> EXPORT_SYMBOL(drm_show_fdinfo);
>>>
>>> +/**
>>> + * drm_file_err - log process name, pid and client_name associated with a drm_file
>>> + * @file_priv: context of interest for process name and pid
>>> + * @fmt: printf() like format string
>>> + *
>>> + * Helper function for clients which needs to log process details such
>>> + * as name and pid etc along with user logs.
>>> + */
>>> +void drm_file_err(struct drm_file *file_priv, const char *fmt, ...)
>>> +{
>>> + va_list args;
>>> + struct va_format vaf;
>>> + struct pid *pid;
>>> + struct task_struct *task;
>>> + struct drm_device *dev = file_priv->minor->dev;
>>> +
>>> + va_start(args, fmt);
>>> + vaf.fmt = fmt;
>>> + vaf.va = &args;
>>> +
>>> + mutex_lock(&file_priv->client_name_lock);
>>> + rcu_read_lock();
>>> + pid = rcu_dereference(file_priv->pid);
>>> + task = pid_task(pid, PIDTYPE_TGID);
>>> +
>>> + drm_err(dev, "comm: %s pid: %d client: %s ... %pV", task ? task->comm : "Unset",
>>> + task ? task->pid : 0, file_priv->client_name ?: "Unset", &vaf);
>>> +
>>> + va_end(args);
>>> + rcu_read_unlock();
>>> + mutex_unlock(&file_priv->client_name_lock);
>>> +}
>>> +EXPORT_SYMBOL(drm_file_err);
>>> +
>>> /**
>>> * mock_drm_getfile - Create a new struct file for the drm device
>>> * @minor: drm minor to wrap (e.g. #drm_device.primary)
>>> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
>>> index 94d365b22505..5c3b2aa3e69d 100644
>>> --- a/include/drm/drm_file.h
>>> +++ b/include/drm/drm_file.h
>>> @@ -446,6 +446,9 @@ static inline bool drm_is_accel_client(const struct drm_file *file_priv)
>>> return file_priv->minor->type == DRM_MINOR_ACCEL;
>>> }
>>>
>>> +__printf(2, 3)
>>> +void drm_file_err(struct drm_file *file_priv, const char *fmt, ...);
>>> +
>>> void drm_file_update_pid(struct drm_file *);
>>>
>>> struct drm_minor *drm_minor_acquire(struct xarray *minors_xa, unsigned int minor_id);
--
Jani Nikula, Intel
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH V8 1/5] drm: add drm_file_err function to add process info
2025-04-28 11:49 ` Jani Nikula
@ 2025-04-30 14:40 ` Khatri, Sunil
0 siblings, 0 replies; 11+ messages in thread
From: Khatri, Sunil @ 2025-04-30 14:40 UTC (permalink / raw)
To: Jani Nikula, Koenig, Christian, dri-devel@lists.freedesktop.org,
David Airlie, Simona Vetter, Maxime Ripard, Maarten Lankhorst,
Thomas Zimmermann
Cc: Deucher, Alexander, Tvrtko Ursulin, Pelloux-Prayer, Pierre-Eric
[AMD Official Use Only - AMD Internal Distribution Only]
I am not very familiar with the process here but looking forward to some response based.
"Any objections to merge this through amd-staging-drm-next?
The follow up amdgpu patches all depend on stuff in there which is not yet merged to drm-misc-next.
Christian "
-----Original Message-----
From: Jani Nikula <jani.nikula@linux.intel.com>
Sent: Monday, April 28, 2025 5:20 PM
To: Khatri, Sunil <Sunil.Khatri@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>; dri-devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; David Airlie <airlied@linux.ie>; Simona Vetter <simona@ffwll.ch>; Maxime Ripard <mripard@kernel.org>; Maarten Lankhorst <maarten.lankhorst@linux.intel.com>; Thomas Zimmermann <tzimmermann@suse.de>
Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Tvrtko Ursulin <tvrtko.ursulin@igalia.com>; Pelloux-Prayer, Pierre-Eric <Pierre-eric.Pelloux-prayer@amd.com>
Subject: Re: [PATCH V8 1/5] drm: add drm_file_err function to add process info
On Mon, 28 Apr 2025, "Khatri, Sunil" <sukhatri@amd.com> wrote:
> On 4/22/2025 2:33 PM, Christian König wrote:
>> Am 17.04.25 um 18:10 schrieb Sunil Khatri:
>>> Add a drm helper function which appends the process information for
>>> the drm_file over drm_err formatted output.
>>>
>>> v5: change to macro from function (Christian Koenig)
>>> add helper functions for lock/unlock (Christian Koenig)
>>>
>>> v6: remove __maybe_unused and make function inline (Jani Nikula)
>>> remove drm_print.h
>>>
>>> v7: Use va_format and %pV to concatenate fmt and vargs (Jani Nikula)
>>>
>>> v8: Code formatting and typos (Ursulin tvrtko)
>>>
>>> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
>>> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
>> Any objections to merge this through amd-staging-drm-next?
> Gentle reminder here folks ??
It might help to Cc the drm-misc maintainers, though even that doesn't always guarantee a reply. ;D
Done now.
Anyway, since I commented on an earlier version, and my feedback was addressed,
Acked-by: Jani Nikula <jani.nikula@intel.com>
even though that does not help you merge via the amd tree.
BR,
Jani.
>> The follow up amdgpu patches all depend on stuff in there which is not yet merged to drm-misc-next.
>>
>> Thanks,
>> Christian.
>>
>>> ---
>>> drivers/gpu/drm/drm_file.c | 34 ++++++++++++++++++++++++++++++++++
>>> include/drm/drm_file.h | 3 +++
>>> 2 files changed, 37 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
>>> index c299cd94d3f7..dd351f601acd 100644
>>> --- a/drivers/gpu/drm/drm_file.c
>>> +++ b/drivers/gpu/drm/drm_file.c
>>> @@ -986,6 +986,40 @@ void drm_show_fdinfo(struct seq_file *m, struct file *f)
>>> }
>>> EXPORT_SYMBOL(drm_show_fdinfo);
>>>
>>> +/**
>>> + * drm_file_err - log process name, pid and client_name associated
>>> +with a drm_file
>>> + * @file_priv: context of interest for process name and pid
>>> + * @fmt: printf() like format string
>>> + *
>>> + * Helper function for clients which needs to log process details
>>> +such
>>> + * as name and pid etc along with user logs.
>>> + */
>>> +void drm_file_err(struct drm_file *file_priv, const char *fmt, ...)
>>> +{
>>> + va_list args;
>>> + struct va_format vaf;
>>> + struct pid *pid;
>>> + struct task_struct *task;
>>> + struct drm_device *dev = file_priv->minor->dev;
>>> +
>>> + va_start(args, fmt);
>>> + vaf.fmt = fmt;
>>> + vaf.va = &args;
>>> +
>>> + mutex_lock(&file_priv->client_name_lock);
>>> + rcu_read_lock();
>>> + pid = rcu_dereference(file_priv->pid);
>>> + task = pid_task(pid, PIDTYPE_TGID);
>>> +
>>> + drm_err(dev, "comm: %s pid: %d client: %s ... %pV", task ? task->comm : "Unset",
>>> + task ? task->pid : 0, file_priv->client_name ?: "Unset", &vaf);
>>> +
>>> + va_end(args);
>>> + rcu_read_unlock();
>>> + mutex_unlock(&file_priv->client_name_lock);
>>> +}
>>> +EXPORT_SYMBOL(drm_file_err);
>>> +
>>> /**
>>> * mock_drm_getfile - Create a new struct file for the drm device
>>> * @minor: drm minor to wrap (e.g. #drm_device.primary) diff --git
>>> a/include/drm/drm_file.h b/include/drm/drm_file.h index
>>> 94d365b22505..5c3b2aa3e69d 100644
>>> --- a/include/drm/drm_file.h
>>> +++ b/include/drm/drm_file.h
>>> @@ -446,6 +446,9 @@ static inline bool drm_is_accel_client(const struct drm_file *file_priv)
>>> return file_priv->minor->type == DRM_MINOR_ACCEL;
>>> }
>>>
>>> +__printf(2, 3)
>>> +void drm_file_err(struct drm_file *file_priv, const char *fmt,
>>> +...);
>>> +
>>> void drm_file_update_pid(struct drm_file *);
>>>
>>> struct drm_minor *drm_minor_acquire(struct xarray *minors_xa,
>>> unsigned int minor_id);
--
Jani Nikula, Intel
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-04-30 14:41 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-17 16:10 [PATCH V8 1/5] drm: add drm_file_err function to add process info Sunil Khatri
2025-04-17 16:10 ` [PATCH V8 2/5] drm/amdgpu: add drm_file reference in userq_mgr Sunil Khatri
2025-04-22 8:37 ` Christian König
2025-04-22 8:57 ` Khatri, Sunil
2025-04-17 16:10 ` [PATCH V8 3/5] drm/amdgpu: use drm_file_err in fence timeouts Sunil Khatri
2025-04-17 16:10 ` [PATCH V8 4/5] drm/amdgpu: change DRM_ERROR to drm_file_err in amdgpu_userqueue.c Sunil Khatri
2025-04-17 16:10 ` [PATCH V8 5/5] drm/amdgpu: change DRM_DBG_DRIVER to drm_dbg_driver Sunil Khatri
2025-04-22 9:03 ` [PATCH V8 1/5] drm: add drm_file_err function to add process info Christian König
2025-04-28 11:39 ` Khatri, Sunil
2025-04-28 11:49 ` Jani Nikula
2025-04-30 14:40 ` Khatri, Sunil
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.