From nobody Fri Nov 29 15:49:40 2024 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 155A6178CEA for ; Wed, 18 Sep 2024 08:54:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726649662; cv=pass; b=ZAZ35qfpQlhLMPOh79Jp//Ru3zc+8sDvVZvyD7yewvskyJu6/V+p4q0/xjcKV2qoPD32dHOn8JGHkumnT+0seme0lYRzaWZjz5qyBKBgL/o2Tuxa0d+7pn8jaril/+5gJ5eGsmdOBHNdlezdodgpwZh9hMnt7501ezux2glJCDA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726649662; c=relaxed/simple; bh=A9htr5uNBobR9Zo7NlE3z/xLseWXoh4xd36OWcAv4Yw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OGOe8e3KUt92/I4KNPiCS6t/m0JLnwF/6s6u/3hRlLpJsAwkCymbGCdtL/O3lVnmglb78thFBCMaMr03naRT297rdE2SC+eWKx1PW6pPtgtHWreT/YQC8TVv0NfgR+LjSpxNHcZrwRYKnhe1ceJZfY0UL58wyJLDeD/Q+D23458= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=mary.guillemard@collabora.com header.b=Mm8uHSi6; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=mary.guillemard@collabora.com header.b="Mm8uHSi6" ARC-Seal: i=1; a=rsa-sha256; t=1726649645; cv=none; d=zohomail.com; s=zohoarc; b=RUrYgcd7PD+TuAaomlFOcCCP3Q6Cl1q6+a2quiqOJ8LtS+OoMGy7I7J18AxB4U++QK0dS+CJ6J+krrU2f0kzrO0ZA+laPVQhdNJ95CPGHJKYUSeYEyHxAjf4JkCIhrPZqEhGhGHGCwdcahHW45M4gOCGdQDuC5MzUH91rI66Z2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726649645; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=V4Q6bjiiwoxxooBzGyx0yM63Xs5VG7E0q48VV9hRoE4=; b=h42FYfJ2fjjivP/IHJa2n1fyEV1PDv398RVVTH3rfU9kaz2m+Y4OL0+yeaCD/GYrJOYXQ8/lMD/LGcWcZ8uWjgwrasom91tk2XQ5UEttoTGepl3dlErPvUylE2By8CVHb/6wgZfFsSvTEVkkrFMdV18OfLi2wMxDBmR1EX2DPXs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=mary.guillemard@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1726649645; s=zohomail; d=collabora.com; i=mary.guillemard@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=V4Q6bjiiwoxxooBzGyx0yM63Xs5VG7E0q48VV9hRoE4=; b=Mm8uHSi6ddkmePCdsJEj5Hq7JHMKRh2WFWHQyN7+7o5wradSxsjrbG4FvKMMTjBd Z0nwSt5wILHhPaUoGVbbGsWyxSh2Kf/AAB9jTQi++EABLrtgk4lSPcT/4r2JSxaDWY6 PrjxQwhLhYBvaIbAxwd61/mSsWBrNe8DVMvTCjjM= Received: by mx.zohomail.com with SMTPS id 1726649643043342.89420907457327; Wed, 18 Sep 2024 01:54:03 -0700 (PDT) From: Mary Guillemard To: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, Boris Brezillon , Christopher Healy , kernel@collabora.com, Mary Guillemard , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [PATCH 1/2] drm/panthor: Add csg_priority to panthor_group Date: Wed, 18 Sep 2024 10:50:55 +0200 Message-ID: <20240918085056.24422-3-mary.guillemard@collabora.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240918085056.24422-2-mary.guillemard@collabora.com> References: <20240918085056.24422-2-mary.guillemard@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Keep track of the csg priority in panthor_group when the group is scheduled/active. This is useful to know the actual priority in use in the firmware group slot. Signed-off-by: Mary Guillemard --- drivers/gpu/drm/panthor/panthor_sched.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/pant= hor/panthor_sched.c index 86908ada7335..f15abeef4ece 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -574,6 +574,13 @@ struct panthor_group { */ int csg_id; =20 + /** + * @csg_id: Priority of the FW group slot. + * + * -1 when the group is not scheduled/active. + */ + int csg_priority; + /** * @destroyed: True when the group has been destroyed. * @@ -894,11 +901,12 @@ group_get(struct panthor_group *group) * group_bind_locked() - Bind a group to a group slot * @group: Group. * @csg_id: Slot. + * @csg_priority: Priority of the slot. * * Return: 0 on success, a negative error code otherwise. */ static int -group_bind_locked(struct panthor_group *group, u32 csg_id) +group_bind_locked(struct panthor_group *group, u32 csg_id, u32 csg_priorit= y) { struct panthor_device *ptdev =3D group->ptdev; struct panthor_csg_slot *csg_slot; @@ -917,6 +925,7 @@ group_bind_locked(struct panthor_group *group, u32 csg_= id) csg_slot =3D &ptdev->scheduler->csg_slots[csg_id]; group_get(group); group->csg_id =3D csg_id; + group->csg_priority =3D csg_priority; =20 /* Dummy doorbell allocation: doorbell is assigned to the group and * all queues use the same doorbell. @@ -956,6 +965,7 @@ group_unbind_locked(struct panthor_group *group) slot =3D &ptdev->scheduler->csg_slots[group->csg_id]; panthor_vm_idle(group->vm); group->csg_id =3D -1; + group->csg_priority =3D -1; =20 /* Tiler OOM events will be re-issued next time the group is scheduled. */ atomic_set(&group->tiler_oom, 0); @@ -2193,8 +2203,9 @@ tick_ctx_apply(struct panthor_scheduler *sched, struc= t panthor_sched_tick_ctx *c =20 csg_iface =3D panthor_fw_get_csg_iface(ptdev, csg_id); csg_slot =3D &sched->csg_slots[csg_id]; - group_bind_locked(group, csg_id); - csg_slot_prog_locked(ptdev, csg_id, new_csg_prio--); + group_bind_locked(group, csg_id, new_csg_prio); + csg_slot_prog_locked(ptdev, csg_id, new_csg_prio); + new_csg_prio--; csgs_upd_ctx_queue_reqs(ptdev, &upd_ctx, csg_id, group->state =3D=3D PANTHOR_CS_GROUP_SUSPENDED ? CSG_STATE_RESUME : CSG_STATE_START, @@ -3111,6 +3122,7 @@ int panthor_group_create(struct panthor_file *pfile, kref_init(&group->refcount); group->state =3D PANTHOR_CS_GROUP_CREATED; group->csg_id =3D -1; + group->csg_priority =3D -1; =20 group->ptdev =3D ptdev; group->max_compute_cores =3D group_args->max_compute_cores; --=20 2.46.0 From nobody Fri Nov 29 15:49:40 2024 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9AC017ADF6 for ; Wed, 18 Sep 2024 08:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726649663; cv=pass; b=YPbHr2JHKfjAwKPHC5Tv3tO6Hj8sQZW+uO4ho85/adaZ2hiJzTaD0zBwFyTso2K5/cys79c8bnyNZM6OpecnLbFnrsdNBCw0CjoFfwuU/XMT9ArZ2OBdSP6nYvpZDGqkR7VVsumsoi3sW+GVCTDExQ4Gg0d9ypJ3vhapnp39Vow= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726649663; c=relaxed/simple; bh=l9wfXNqJwfX/Kwz4zDjUltuz/Rk/EBxudFwhEP7WTts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pzIdGlN4IEtn2f2YClJvqvT9HsPQ0BVRqjdSIN0HIh9wG0uIM/Kv/AHwtoA7RMlLhjZIhV+ZwhDtvR5/zIwMBUIfyYdu8nTOQKI3WsSZK7a1EhnHv7pG82b0zEjwrSRjHwKfKfY9Vhx3Nza0ZKzZ8JPH+a0KbTiTje5E+zcpnpM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=mary.guillemard@collabora.com header.b=lHkVF0ht; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=mary.guillemard@collabora.com header.b="lHkVF0ht" ARC-Seal: i=1; a=rsa-sha256; t=1726649647; cv=none; d=zohomail.com; s=zohoarc; b=SJRn11XEnlanBSLP6sC6TyydwVCQ7DYRENByuQGuJ+MfT1y8n0nk/fsTKL+uCidVfbOx9krD2QJpCFhrZbdVLIBXwiM47n+BgYy9GhUQPiOdleaQGliEaNH+/PHGgrAboRnpMQwfEhzYYwb4ohFH88cpdoEr5P1IuwV/cYtKukk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726649647; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=dllsse1ukskOvEmQg/58+68rmkSOqjApie4FUwPoeJ8=; b=g5T/SE9hQRiTWOlBVkeNbZX6BZgvWjzdFZq/PlcHDfr8Wrozv4aD3i+CWpO2vcHXIfJs162KgW8HBsuYBWchqNeGsDAE9qZCJvT37oj0427KRYUjgcRv37cEENNhea5ZbfM0xmRQAN7WLrQMmJydRPbVBOVgUdZGtbbKRvynA0A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=mary.guillemard@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1726649647; s=zohomail; d=collabora.com; i=mary.guillemard@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=dllsse1ukskOvEmQg/58+68rmkSOqjApie4FUwPoeJ8=; b=lHkVF0ht7fLVQf0t/YOZqEqBad2J9SXtJvsiDvvYlPQNePJDCHW0noZeQe1Z0bXD PVF4y+oLCkybyeuIKiRS9MP6MAf9XALc9PF38oEMOGCBRyVYC+0E0CgNK8QP1QcujUn 3sw9y0Vsnt+b6nuoh0SXqrigbsvdKwN+uy7Q3lLM= Received: by mx.zohomail.com with SMTPS id 1726649646092669.3219050924438; Wed, 18 Sep 2024 01:54:06 -0700 (PDT) From: Mary Guillemard To: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, Boris Brezillon , Christopher Healy , kernel@collabora.com, Mary Guillemard , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [PATCH 2/2] drm/panthor: Expose scheduler groups info in debugfs Date: Wed, 18 Sep 2024 10:50:56 +0200 Message-ID: <20240918085056.24422-4-mary.guillemard@collabora.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240918085056.24422-2-mary.guillemard@collabora.com> References: <20240918085056.24422-2-mary.guillemard@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" This adds a new debugfs file named "sched_groups" allowing a user to query information about all userspace clients scheduler groups. As we uses drm_device.filelist to achieve it, we also expose the client_id with the task information to differentiate one client from another inside the same task. Signed-off-by: Mary Guillemard --- drivers/gpu/drm/panthor/panthor_drv.c | 1 + drivers/gpu/drm/panthor/panthor_sched.c | 127 ++++++++++++++++++++++++ drivers/gpu/drm/panthor/panthor_sched.h | 4 + 3 files changed, 132 insertions(+) diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/pantho= r/panthor_drv.c index 0d825d63d712..aa390597d355 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -1450,6 +1450,7 @@ static const struct file_operations panthor_drm_drive= r_fops =3D { static void panthor_debugfs_init(struct drm_minor *minor) { panthor_mmu_debugfs_init(minor); + panthor_sched_debugfs_init(minor); } #endif =20 diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/pant= hor/panthor_sched.c index f15abeef4ece..0c1ddbfbe164 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 or MIT /* Copyright 2023 Collabora ltd. */ =20 +#include #include #include #include @@ -3581,3 +3582,129 @@ int panthor_sched_init(struct panthor_device *ptdev) ptdev->scheduler =3D sched; return 0; } + +#ifdef CONFIG_DEBUG_FS +static const char *panthor_csg_priority_names[PANTHOR_CSG_PRIORITY_COUNT] = =3D { + "LOW", + "MEDIUM", + "HIGH", + "REALTIME" +}; + +static const char *panthor_group_state_names[PANTHOR_CS_GROUP_UNKNOWN_STAT= E] =3D { + "CREATED", + "ACTIVE", + "SUSPENDED", + "TERMINATED" +}; + +static void show_panthor_queue(const struct panthor_queue *queue, + u32 queue_index, + struct seq_file *m) +{ + seq_printf(m, "queue %u:", queue_index); + seq_printf(m, " priority %u", queue->priority); + seq_printf(m, " doorbell_id %d", queue->doorbell_id); + seq_puts(m, "\n"); +} + +static void show_panthor_group(struct panthor_group *group, + u32 group_handle, + struct seq_file *m) +{ + u32 i; + + group_get(group); + + seq_printf(m, "group %u:", group_handle); + seq_printf(m, " priority %s", group->priority < PANTHOR_CSG_PRIORITY_COUN= T ? + panthor_csg_priority_names[group->priority] : "UNKNOWN"); + seq_printf(m, " state %s", group->state < PANTHOR_CS_GROUP_UNKNOWN_STATE ? + panthor_group_state_names[group->state] : "UNKNOWN"); + seq_printf(m, " csg_id %d", group->csg_id); + seq_printf(m, " csg_priority %d", group->csg_priority); + seq_printf(m, " compute_core_mask 0x%016llx", group->compute_core_mask); + seq_printf(m, " fragment_core_mask 0x%016llx", group->fragment_core_mask); + seq_printf(m, " tiler_core_mask 0x%016llx", group->tiler_core_mask); + seq_printf(m, " max_compute_cores %d", group->max_compute_cores); + seq_printf(m, " max_fragment_cores %d", group->max_fragment_cores); + seq_printf(m, " max_tiler_cores %d", group->max_tiler_cores); + seq_puts(m, "\n"); + + for (i =3D 0; i < group->queue_count; i++) + show_panthor_queue(group->queues[i], i, m); + + group_put(group); +} + +static int show_file_group_pool(const struct panthor_file *pfile, struct s= eq_file *m) +{ + struct panthor_group_pool *gpool =3D pfile->groups; + struct panthor_group *group; + unsigned long i; + + if (IS_ERR_OR_NULL(gpool)) + return 0; + + xa_for_each(&gpool->xa, i, group) + show_panthor_group(group, i, m); + + return 0; +} + +static int show_each_file(struct seq_file *m, void *arg) +{ + struct drm_info_node *node =3D (struct drm_info_node *)m->private; + struct drm_device *ddev =3D node->minor->dev; + int (*show)(const struct panthor_file *, struct seq_file *) =3D node->inf= o_ent->data; + struct drm_file *file; + int ret; + + ret =3D mutex_lock_interruptible(&ddev->filelist_mutex); + if (ret) + return ret; + + list_for_each_entry(file, &ddev->filelist, lhead) { + struct task_struct *task; + struct panthor_file *pfile =3D file->driver_priv; + struct pid *pid; + + /* + * Although we have a valid reference on file->pid, that does + * not guarantee that the task_struct who called get_pid() is + * still alive (e.g. get_pid(current) =3D> fork() =3D> exit()). + * Therefore, we need to protect this ->comm access using RCU. + */ + rcu_read_lock(); + pid =3D rcu_dereference(file->pid); + task =3D pid_task(pid, PIDTYPE_TGID); + seq_printf(m, "client_id %8llu pid %8d command %s:\n", file->client_id, + pid_nr(pid), task ? task->comm : ""); + rcu_read_unlock(); + + ret =3D show(pfile, m); + if (ret < 0) + break; + + seq_puts(m, "\n"); + } + + mutex_unlock(&ddev->filelist_mutex); + return ret; +} + +static struct drm_info_list panthor_sched_debugfs_list[] =3D { + { "sched_groups", show_each_file, 0, show_file_group_pool }, +}; + +/** + * panthor_sched_debugfs_init() - Initialize scheduler debugfs entries + * @minor: Minor. + */ +void panthor_sched_debugfs_init(struct drm_minor *minor) +{ + drm_debugfs_create_files(panthor_sched_debugfs_list, + ARRAY_SIZE(panthor_sched_debugfs_list), + minor->debugfs_root, minor); +} +#endif /* CONFIG_DEBUG_FS */ diff --git a/drivers/gpu/drm/panthor/panthor_sched.h b/drivers/gpu/drm/pant= hor/panthor_sched.h index 3a30d2328b30..577239aa66bf 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.h +++ b/drivers/gpu/drm/panthor/panthor_sched.h @@ -47,4 +47,8 @@ void panthor_sched_resume(struct panthor_device *ptdev); void panthor_sched_report_mmu_fault(struct panthor_device *ptdev); void panthor_sched_report_fw_events(struct panthor_device *ptdev, u32 even= ts); =20 +#ifdef CONFIG_DEBUG_FS +void panthor_sched_debugfs_init(struct drm_minor *minor); +#endif + #endif --=20 2.46.0