From patchwork Wed Aug 7 16:08:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mary Guillemard X-Patchwork-Id: 13756489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20113C52D73 for ; Wed, 7 Aug 2024 16:10:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56CEC10E182; Wed, 7 Aug 2024 16:10:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=mary.guillemard@collabora.com header.b="I34VHeWI"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3B89E10E181 for ; Wed, 7 Aug 2024 16:10:00 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1723046991; cv=none; d=zohomail.com; s=zohoarc; b=SrUZFIBqOlA9PjeP7JGaw6mBytuA1/g1tCQ9K0peS9/dlEEHXdqRkQ/ii/bTf2r4LyaWuK1OEd8gfwxmZBd1q8IureevQ9a3j6QBvng/vIt9xuQMPsB4ww+yHjbe/tm7/KgArXoAbHXJI2vxeuLFjoB0UzclmMf5kQgA1JYFeUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723046991; 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=2tbs4O9jIOylAwaDXXbJssc8OYMauxjaFyRX4otVCrY=; b=IASfVySzRLPwcobFwcI74x1POBZJoAggtH1RcuAMPGdmlIxvBwCh8OnCjyjKNCnLwIg4FTwARrCzCSTu4K7/1aQKDbc9RgmZyVpKgPF63rC8x0IPZBMUCMPcRDqr/gZ1X7sWT9a87+2pHhRCcryRLjBuy8Ld8qi4rDygJYtgioo= 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=1723046991; 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=2tbs4O9jIOylAwaDXXbJssc8OYMauxjaFyRX4otVCrY=; b=I34VHeWIv6mLg5s/P1vAemtJUOsVUP2Hlp1kE9RTukKYzM0hAPDCBoBZtYVJWN1H H5c1O/4XkGQM0SphHm5FQKGAHOAezCK1uKxa1JsZqHzGepDYW4hgzfnKYYNo99KmKVA ybSODF0377SEXB/HmnMwEzBd9gSR3Qsq/MbnqI/Y= Received: by mx.zohomail.com with SMTPS id 1723046989747697.3393722421491; Wed, 7 Aug 2024 09:09:49 -0700 (PDT) From: Mary Guillemard To: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, kernel@collabora.com, Mary Guillemard , Boris Brezillon , Rob Herring , Steven Price , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [PATCH 1/3] drm/panfrost: Add SYSTEM_TIMESTAMP and SYSTEM_TIMESTAMP_FREQUENCY parameters Date: Wed, 7 Aug 2024 18:08:57 +0200 Message-ID: <20240807160900.149154-2-mary.guillemard@collabora.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240807160900.149154-1-mary.guillemard@collabora.com> References: <20240807160900.149154-1-mary.guillemard@collabora.com> MIME-Version: 1.0 X-ZohoMailClient: External X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Expose system timestamp and frequency supported by the GPU. Mali uses the generic arch timer as GPU system time so we currently wire cntvct_el0 and cntfrq_el0 respectively to those parameters. We could have directly read those values from userland but handling this here allows us to be future proof in case of errata related to timers for example. This new uAPI will be used in Mesa to implement timestamp queries and VK_KHR_calibrated_timestamps. Signed-off-by: Mary Guillemard --- drivers/gpu/drm/panfrost/panfrost_drv.c | 17 +++++++++++++++++ include/uapi/drm/panfrost_drm.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 671eed4ad890..d94c9bf5a7f9 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -69,6 +69,23 @@ static int panfrost_ioctl_get_param(struct drm_device *ddev, void *data, struct PANFROST_FEATURE_ARRAY(JS_FEATURES, js_features, 15); PANFROST_FEATURE(NR_CORE_GROUPS, nr_core_groups); PANFROST_FEATURE(THREAD_TLS_ALLOC, thread_tls_alloc); + + case DRM_PANFROST_PARAM_SYSTEM_TIMESTAMP: +#ifdef CONFIG_ARM_ARCH_TIMER + param->value = __arch_counter_get_cntvct(); +#else + param->value = 0; +#endif + break; + + case DRM_PANFROST_PARAM_SYSTEM_TIMESTAMP_FREQUENCY: +#ifdef CONFIG_ARM_ARCH_TIMER + param->value = arch_timer_get_cntfrq(); +#else + param->value = 0; +#endif + break; + default: return -EINVAL; } diff --git a/include/uapi/drm/panfrost_drm.h b/include/uapi/drm/panfrost_drm.h index 9f231d40a146..52b050e2b660 100644 --- a/include/uapi/drm/panfrost_drm.h +++ b/include/uapi/drm/panfrost_drm.h @@ -172,6 +172,8 @@ enum drm_panfrost_param { DRM_PANFROST_PARAM_NR_CORE_GROUPS, DRM_PANFROST_PARAM_THREAD_TLS_ALLOC, DRM_PANFROST_PARAM_AFBC_FEATURES, + DRM_PANFROST_PARAM_SYSTEM_TIMESTAMP, + DRM_PANFROST_PARAM_SYSTEM_TIMESTAMP_FREQUENCY, }; struct drm_panfrost_get_param { From patchwork Wed Aug 7 16:08:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mary Guillemard X-Patchwork-Id: 13756490 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A2953C3DA7F for ; Wed, 7 Aug 2024 16:10:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6FF6F10E186; Wed, 7 Aug 2024 16:10:03 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=mary.guillemard@collabora.com header.b="RjUJLLj9"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by gabe.freedesktop.org (Postfix) with ESMTPS id 55CF510E181 for ; Wed, 7 Aug 2024 16:10:02 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1723046993; cv=none; d=zohomail.com; s=zohoarc; b=kHVV3rIPzmwA2HcpXjLPE26bMMKmuDLza/WXLbdHteIx7sN103/Iy8YKnH76LPLiEgBNVwFPwH3tyVwM4Riv12sUxRxo6c+/BKV5JRX26vUjGjd9XO+f82PK80en2z5WPlQZ2AWF16q/pFMGXkrwuc7sqV3zoHLAzfiZe2w7LYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723046993; 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=J29M+xTzHtWGYHNY/aAB6XIac64gox5At2FLEcBydXI=; b=DRs4rbvmSG8J9ugP/4hHMPH6LmvLL8puLvyjQeGX4J4w7b7lkbgtqjHqVdxZFwfZcc5j6iQdNXyOPikdXc80EjS9B058MXTccohLUZM24zy7VGgsp/YksyjQKGQTiInSvR1R2XznIfEDd5OEa1NGbmP4JnSou2c0EMTyLdj2uBU= 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=1723046993; 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=J29M+xTzHtWGYHNY/aAB6XIac64gox5At2FLEcBydXI=; b=RjUJLLj9mzJAKaTlej65pd3DNRRN8diYNYhdgCK/IdxRkpDq5FyzLJvHSvruir6M g0lTWw3LWLJjmCudRovwSlTwAel/x4smjjrywoMuFETf1330Hw5fhhmynOJJ1iKKw2j qg0cmfC5lk4BJSvR+jDJ4+xW19dw4HSScTYnFJeg= Received: by mx.zohomail.com with SMTPS id 1723046992518427.5667049103944; Wed, 7 Aug 2024 09:09:52 -0700 (PDT) From: Mary Guillemard To: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, kernel@collabora.com, Mary Guillemard , Boris Brezillon , Rob Herring , Steven Price , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Subject: [PATCH 2/3] drm/panfrost: Add cycle counter job requirement Date: Wed, 7 Aug 2024 18:08:58 +0200 Message-ID: <20240807160900.149154-3-mary.guillemard@collabora.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240807160900.149154-1-mary.guillemard@collabora.com> References: <20240807160900.149154-1-mary.guillemard@collabora.com> MIME-Version: 1.0 X-ZohoMailClient: External X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Extend the uAPI with a new job requirement flag for cycle counters. This requirement is used by userland to indicate that a job requires cycle counters or system timestamp to be propagated. (for use with write value timestamp jobs) We cannot enable cycle counters unconditionally as this would result in an increase of GPU power consumption. As a result, they should be left off unless required by the application. This new uAPI will be used in Mesa to implement timestamp queries and VK_KHR_shader_clock. Signed-off-by: Mary Guillemard --- include/uapi/drm/panfrost_drm.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/drm/panfrost_drm.h b/include/uapi/drm/panfrost_drm.h index 52b050e2b660..568724be6628 100644 --- a/include/uapi/drm/panfrost_drm.h +++ b/include/uapi/drm/panfrost_drm.h @@ -40,6 +40,7 @@ extern "C" { #define DRM_IOCTL_PANFROST_PERFCNT_DUMP DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_DUMP, struct drm_panfrost_perfcnt_dump) #define PANFROST_JD_REQ_FS (1 << 0) +#define PANFROST_JD_REQ_CYCLE_COUNT (1 << 1) /** * struct drm_panfrost_submit - ioctl argument for submitting commands to the 3D * engine. From patchwork Wed Aug 7 16:08:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mary Guillemard X-Patchwork-Id: 13756491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A913C3DA7F for ; Wed, 7 Aug 2024 16:10:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 90D5710E181; Wed, 7 Aug 2024 16:10:06 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=mary.guillemard@collabora.com header.b="DD6GQlZM"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8D14C10E181 for ; Wed, 7 Aug 2024 16:10:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1723046997; cv=none; d=zohomail.com; s=zohoarc; b=W4Zus2hENAMm5ZsWBInsQ7YmSnMaVHxCP3fyXlLNKxM6XYxDZgkpBa6ZidE8xOX4aExDfS44oDkEyf6qCb6X5J5axGgzGTgVhZrSxgR2htTdshK8qnxA9T3xCm0cqkBrJ5z5/pvIToHAc0tkwJzJXv4qPibHsMCMGkIk8gljqdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723046997; 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=11EFsbnPxyKsf7C0lUvlu5OAIQuBwlJBo38EBnGl8NM=; b=JuM2X7IxN2ir8+zmss1385fx3nafSIOLwZV/+hg1waJ/1a8/CGdpKOqGZmLSH+q0jOfh+NXAjHxZzwUVss0XUQqACL3vggqbPNtMHRvUSX9jyy8hsgJgYA6KxRICQrvgtkppQZhRyy5E6n+PQhgzLgin50NPy6oAy2wj3D8y0RM= 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=1723046997; 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=11EFsbnPxyKsf7C0lUvlu5OAIQuBwlJBo38EBnGl8NM=; b=DD6GQlZM74wIqHMdSHGvkxgpPDo8AariMILBPvvPTmBcqYnOGHynmXkB89eMcZ+n p6z2Qq2N6isSNJ+dxnX7K1LLtz5/nmq4WTO+mZ+Mlbd8hfgxLvoBSuvT4TG6ksEPE/u SuhMsP/2h+rnn46nUmOE+EbtEUsntyHfm17at28k= Received: by mx.zohomail.com with SMTPS id 1723046995358371.2106901029101; Wed, 7 Aug 2024 09:09:55 -0700 (PDT) From: Mary Guillemard To: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, kernel@collabora.com, Mary Guillemard , Boris Brezillon , Rob Herring , Steven Price , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [PATCH 3/3] drm/panfrost: Handle JD_REQ_CYCLE_COUNT Date: Wed, 7 Aug 2024 18:08:59 +0200 Message-ID: <20240807160900.149154-4-mary.guillemard@collabora.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240807160900.149154-1-mary.guillemard@collabora.com> References: <20240807160900.149154-1-mary.guillemard@collabora.com> MIME-Version: 1.0 X-ZohoMailClient: External X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If a job requires cycle counters or system timestamps propagation, we must enable cycle counting before issuing a job and disable it right after the job completes. Since this extends the uAPI and because userland needs a way to advertise features like VK_KHR_shader_clock conditionally, we bumps the driver minor version. Signed-off-by: Mary Guillemard --- drivers/gpu/drm/panfrost/panfrost_drv.c | 8 ++++++-- drivers/gpu/drm/panfrost/panfrost_job.c | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index d94c9bf5a7f9..fe983defdfdf 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -21,6 +21,8 @@ #include "panfrost_gpu.h" #include "panfrost_perfcnt.h" +#define JOB_REQUIREMENTS (PANFROST_JD_REQ_FS | PANFROST_JD_REQ_CYCLE_COUNT) + static bool unstable_ioctls; module_param_unsafe(unstable_ioctls, bool, 0600); @@ -262,7 +264,7 @@ static int panfrost_ioctl_submit(struct drm_device *dev, void *data, if (!args->jc) return -EINVAL; - if (args->requirements && args->requirements != PANFROST_JD_REQ_FS) + if (args->requirements && args->requirements & ~JOB_REQUIREMENTS) return -EINVAL; if (args->out_sync > 0) { @@ -601,6 +603,8 @@ static const struct file_operations panfrost_drm_driver_fops = { * - 1.0 - initial interface * - 1.1 - adds HEAP and NOEXEC flags for CREATE_BO * - 1.2 - adds AFBC_FEATURES query + * - 1.3 - adds JD_REQ_CYCLE_COUNT job requirement for SUBMIT + * - adds SYSTEM_TIMESTAMP and SYSTEM_TIMESTAMP_FREQUENCY queries */ static const struct drm_driver panfrost_drm_driver = { .driver_features = DRIVER_RENDER | DRIVER_GEM | DRIVER_SYNCOBJ, @@ -614,7 +618,7 @@ static const struct drm_driver panfrost_drm_driver = { .desc = "panfrost DRM", .date = "20180908", .major = 1, - .minor = 2, + .minor = 3, .gem_create_object = panfrost_gem_create_object, .gem_prime_import_sg_table = panfrost_gem_prime_import_sg_table, diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c index df49d37d0e7e..d8c215c0c672 100644 --- a/drivers/gpu/drm/panfrost/panfrost_job.c +++ b/drivers/gpu/drm/panfrost/panfrost_job.c @@ -159,6 +159,9 @@ panfrost_dequeue_job(struct panfrost_device *pfdev, int slot) struct panfrost_job *job = pfdev->jobs[slot][0]; WARN_ON(!job); + if (job->requirements & PANFROST_JD_REQ_CYCLE_COUNT) + panfrost_cycle_counter_put(pfdev); + if (job->is_profiled) { if (job->engine_usage) { job->engine_usage->elapsed_ns[slot] += @@ -219,6 +222,9 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) panfrost_job_write_affinity(pfdev, job->requirements, js); + if (job->requirements & PANFROST_JD_REQ_CYCLE_COUNT) + panfrost_cycle_counter_get(pfdev); + /* start MMU, medium priority, cache clean/flush on end, clean/flush on * start */ cfg |= JS_CONFIG_THREAD_PRI(8) | @@ -693,8 +699,12 @@ panfrost_reset(struct panfrost_device *pfdev, spin_lock(&pfdev->js->job_lock); for (i = 0; i < NUM_JOB_SLOTS; i++) { for (j = 0; j < ARRAY_SIZE(pfdev->jobs[0]) && pfdev->jobs[i][j]; j++) { + if (pfdev->jobs[i][j]->requirements & PANFROST_JD_REQ_CYCLE_COUNT) + panfrost_cycle_counter_put(pfdev); + if (pfdev->jobs[i][j]->is_profiled) panfrost_cycle_counter_put(pfdev->jobs[i][j]->pfdev); + pm_runtime_put_noidle(pfdev->dev); panfrost_devfreq_record_idle(&pfdev->pfdevfreq); }