From nobody Sun Feb 8 11:16:32 2026 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 31297310629 for ; Tue, 23 Dec 2025 16:25:37 +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=1766507140; cv=pass; b=M4qZXExZncj7i+9ZCsjUxHbI9ecui35fpZKubeYMhW9OM6rDSE9fcOQfskvVHUrWAyvFZAiA6ZAyG1emBWhwOdXFF1Orgsro8vDnSEwDp8Wd7wQITyGa4Khia8K2X3wI7BJLkIp5G64uY0KTaxefIhi788MteZeY9pJcLJq2neg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766507140; c=relaxed/simple; bh=vVn/wO/+4XUojj94m0bZGxaTUHsCn0nEywBnu0xo+9I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SLkPil2BrTK233XIHQJjxaBhnGecwELUGiV7I45h/kGjZx5ncmSzX0hAnQtui/7wehGCm0Sp/QyYbxJR5Dd9rUqFycMB9mfX/UnPNQ4W2iJ0Iue3dg7r5gMv/955nPvwAKDO/R065wRwBz6GMRF7reHa/J0kC6Ut6ZLSkEdugio= 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=nicolas.frattaroli@collabora.com header.b=IDcQsHXl; 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=nicolas.frattaroli@collabora.com header.b="IDcQsHXl" ARC-Seal: i=1; a=rsa-sha256; t=1766507123; cv=none; d=zohomail.com; s=zohoarc; b=HVbbGvLHekgPr5641NqwAIAJGJgFjDFNk8+N8ND81da7NqzCjLg3693x1hKAiEzzJsHW7jvvKYpfXTPXjAg8RYG5RBraS9/I0WdDALvBiFKq44+g2WdXleqaTw7jpZRVQWSVTTaVq+m3EpTdMtjyDv5ElyS55gcpjLIOCKrdXQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766507123; h=Content-Type: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=k8u4+nzu8W/Uq0lgz2yIwAyjxKovyCJGOYbFD9VAkc0=; b=F5gFX0aXS2kHvseFkQYdN/D2RoeChVAtHugZjrkSOHS/1U/kcajEA0kOwAaymCTEAHdSQaocp0jc05FzcFnmQW3z19stLY5i7kneo3tDg7sVMKOZ9odYuS9M+e4WqL+9w53eetzTdwmcS2lkOW1AShw5sOr5fSLA9/1S1y/NFKo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1766507123; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=k8u4+nzu8W/Uq0lgz2yIwAyjxKovyCJGOYbFD9VAkc0=; b=IDcQsHXlzfv42pxjn7BATIj7Jud0bxATqDLxHlAJhn6SXtFMsV22iIkzFyrTyZ6j pJxzLmwgVoRuMdL9cE8k3xb1+CQhcWv2Z7LKQdGJ2owoLNXb0G1WVRdv7ouVXX1AVAu AuDpEl3I0YQGTtUthLhWMUU3vyn3zmlmKGGnO63s= Received: by mx.zohomail.com with SMTPS id 1766507121698471.45413460247414; Tue, 23 Dec 2025 08:25:21 -0800 (PST) From: Nicolas Frattaroli Date: Tue, 23 Dec 2025 17:24:58 +0100 Subject: [PATCH v6 1/3] drm/panthor: Extend IRQ helpers for mask modification/restoration Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251223-panthor-tracepoints-v6-1-d3c998ee9efc@collabora.com> References: <20251223-panthor-tracepoints-v6-0-d3c998ee9efc@collabora.com> In-Reply-To: <20251223-panthor-tracepoints-v6-0-d3c998ee9efc@collabora.com> To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chia-I Wu , Karunika Choo Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 The current IRQ helpers do not guarantee mutual exclusion that covers the entire transaction from accessing the mask member and modifying the mask register. This makes it hard, if not impossible, to implement mask modification helpers that may change one of these outside the normal suspend/resume/isr code paths. Add a spinlock to struct panthor_irq that protects both the mask member and register. Acquire it in all code paths that access these, but drop it before processing the threaded handler function. Then, add the aforementioned new helpers: mask_enable, mask_disable, and resume_restore. The first two work by ORing and NANDing the mask bits, and the latter relies on the new behaviour that panthor_irq::mask is not set to 0 on suspend. panthor_irq::suspended remains an atomic, as it's necessarily written to outside the mask_lock in the suspend path. Signed-off-by: Nicolas Frattaroli --- drivers/gpu/drm/panthor/panthor_device.h | 68 +++++++++++++++++++++++++++-= ---- 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/pan= thor/panthor_device.h index f35e52b9546a..bf554cf376fb 100644 --- a/drivers/gpu/drm/panthor/panthor_device.h +++ b/drivers/gpu/drm/panthor/panthor_device.h @@ -73,11 +73,14 @@ struct panthor_irq { /** @irq: IRQ number. */ int irq; =20 - /** @mask: Current mask being applied to xxx_INT_MASK. */ + /** @mask: Values to write to xxx_INT_MASK if active. */ u32 mask; =20 /** @suspended: Set to true when the IRQ is suspended. */ atomic_t suspended; + + /** @mask_lock: protects modifications to _INT_MASK and @mask */ + spinlock_t mask_lock; }; =20 /** @@ -410,6 +413,8 @@ static irqreturn_t panthor_ ## __name ## _irq_raw_handl= er(int irq, void *data) struct panthor_irq *pirq =3D data; \ struct panthor_device *ptdev =3D pirq->ptdev; \ \ + guard(spinlock_irqsave)(&pirq->mask_lock); \ + \ if (atomic_read(&pirq->suspended)) \ return IRQ_NONE; \ if (!gpu_read(ptdev, __reg_prefix ## _INT_STAT)) \ @@ -424,9 +429,14 @@ static irqreturn_t panthor_ ## __name ## _irq_threaded= _handler(int irq, void *da struct panthor_irq *pirq =3D data; \ struct panthor_device *ptdev =3D pirq->ptdev; \ irqreturn_t ret =3D IRQ_NONE; \ + u32 mask; \ + \ + scoped_guard(spinlock_irqsave, &pirq->mask_lock) { \ + mask =3D pirq->mask; \ + } \ \ while (true) { \ - u32 status =3D gpu_read(ptdev, __reg_prefix ## _INT_RAWSTAT) & pirq->mas= k; \ + u32 status =3D (gpu_read(ptdev, __reg_prefix ## _INT_RAWSTAT) & mask); \ \ if (!status) \ break; \ @@ -435,26 +445,44 @@ static irqreturn_t panthor_ ## __name ## _irq_threade= d_handler(int irq, void *da ret =3D IRQ_HANDLED; \ } \ \ - if (!atomic_read(&pirq->suspended)) \ - gpu_write(ptdev, __reg_prefix ## _INT_MASK, pirq->mask); \ + scoped_guard(spinlock_irqsave, &pirq->mask_lock) { \ + if (!atomic_read(&pirq->suspended)) { \ + /* Only restore the bits that were used and are still enabled */ \ + gpu_write(ptdev, __reg_prefix ## _INT_MASK, \ + gpu_read(ptdev, __reg_prefix ## _INT_MASK) | \ + (mask & pirq->mask)); \ + } \ + } \ \ return ret; \ } \ \ static inline void panthor_ ## __name ## _irq_suspend(struct panthor_irq *= pirq) \ { \ - pirq->mask =3D 0; \ - gpu_write(pirq->ptdev, __reg_prefix ## _INT_MASK, 0); \ + scoped_guard(spinlock_irqsave, &pirq->mask_lock) { \ + gpu_write(pirq->ptdev, __reg_prefix ## _INT_MASK, 0); \ + } \ synchronize_irq(pirq->irq); \ atomic_set(&pirq->suspended, true); \ } \ \ static inline void panthor_ ## __name ## _irq_resume(struct panthor_irq *p= irq, u32 mask) \ { \ - atomic_set(&pirq->suspended, false); \ + guard(spinlock_irqsave)(&pirq->mask_lock); \ + \ pirq->mask =3D mask; \ - gpu_write(pirq->ptdev, __reg_prefix ## _INT_CLEAR, mask); \ - gpu_write(pirq->ptdev, __reg_prefix ## _INT_MASK, mask); \ + atomic_set(&pirq->suspended, false); \ + gpu_write(pirq->ptdev, __reg_prefix ## _INT_CLEAR, pirq->mask); \ + gpu_write(pirq->ptdev, __reg_prefix ## _INT_MASK, pirq->mask); \ +} \ + \ +static inline void panthor_ ## __name ## _irq_resume_restore(struct pantho= r_irq *pirq) \ +{ \ + guard(spinlock_irqsave)(&pirq->mask_lock); \ + \ + atomic_set(&pirq->suspended, false); \ + gpu_write(pirq->ptdev, __reg_prefix ## _INT_CLEAR, pirq->mask); \ + gpu_write(pirq->ptdev, __reg_prefix ## _INT_MASK, pirq->mask); \ } \ \ static int panthor_request_ ## __name ## _irq(struct panthor_device *ptdev= , \ @@ -463,13 +491,33 @@ static int panthor_request_ ## __name ## _irq(struct = panthor_device *ptdev, \ { \ pirq->ptdev =3D ptdev; \ pirq->irq =3D irq; \ - panthor_ ## __name ## _irq_resume(pirq, mask); \ + pirq->mask =3D mask; \ + spin_lock_init(&pirq->mask_lock); \ + panthor_ ## __name ## _irq_resume_restore(pirq); \ \ return devm_request_threaded_irq(ptdev->base.dev, irq, \ panthor_ ## __name ## _irq_raw_handler, \ panthor_ ## __name ## _irq_threaded_handler, \ IRQF_SHARED, KBUILD_MODNAME "-" # __name, \ pirq); \ +} \ + \ +static inline void panthor_ ## __name ## _irq_mask_enable(struct panthor_i= rq *pirq, u32 mask) \ +{ \ + guard(spinlock_irqsave)(&pirq->mask_lock); \ + \ + pirq->mask |=3D mask; \ + if (!atomic_read(&pirq->suspended)) \ + gpu_write(pirq->ptdev, __reg_prefix ## _INT_MASK, pirq->mask); \ +} \ + \ +static inline void panthor_ ## __name ## _irq_mask_disable(struct panthor_= irq *pirq, u32 mask) \ +{ \ + guard(spinlock_irqsave)(&pirq->mask_lock); \ + \ + pirq->mask &=3D ~mask; \ + if (!atomic_read(&pirq->suspended)) \ + gpu_write(pirq->ptdev, __reg_prefix ## _INT_MASK, pirq->mask); \ } =20 extern struct workqueue_struct *panthor_cleanup_wq; --=20 2.52.0 From nobody Sun Feb 8 11:16:32 2026 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 454FA3328FD for ; Tue, 23 Dec 2025 16:25:42 +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=1766507146; cv=pass; b=PU78w+WfqkrO0FM3EiTBo9UdVFnRybpUtlRNt+i8YPrS0lg0i+gYzJuOTdASxTSecQzy7VuRXZYwwyo0zYy7mk58YG3+roTwEfCGY+2g5L4b+Q2pFxS4kmgADFZs+uqtSm7HN1cvH6vfB1/7/SjsxjsBmTDPL8hbSuoMg8zL3+U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766507146; c=relaxed/simple; bh=UPshLAmUWcfdYTZvB4PdgrVxIfPBvDcv20xx3exESNE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ua+j3n81azFtSi5Pmm+yjwOyaWbPPBoivM6EuJ3+yzbnn38HkumiAaEcncHGY2od3sZ21gYEPhN0UBB+zO2Qagm/FtO/JL4OPB8HvCHP12xU/B9D6wJPiCgE8FM5qJECDT5L2XEhyWR7vdZfxrH3kNNFvbqyjdNZtxvpoNpBD/w= 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=nicolas.frattaroli@collabora.com header.b=YMNSBZza; 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=nicolas.frattaroli@collabora.com header.b="YMNSBZza" ARC-Seal: i=1; a=rsa-sha256; t=1766507127; cv=none; d=zohomail.com; s=zohoarc; b=FRk9l2M2oMKfPZmjWUqxJXqq3C3o+Cxodl/5Q4w9xo6AoJwgVj3n3j2Vqboqz0kKk84kYBcWL4+NKXNt2/b1QbGep6Gmmb+vTG4R6LkCZJeLt0tbTR96Qq6RlPNVGKj61XCHzcQg7jUmkBIL6jwfqNs54ZnFpaREJZ9rRzktMNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766507127; h=Content-Type: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=fP4Ult4IiCglBm44aZ9Nl/gu90LlcKEXWw30G3qrSXI=; b=jrqvWYZfb+zT5X2ZEenLMHaTzofWwVPq24Zcu3vjMfmg/OfOYVxDxnqtZXwIOmRDSMMRGmQOoryTvc7Ste7XG9pjY34uZ3z3dSvs5Z+4jN5Vib3HYgzDWvakdTg8beLLEXSlhst67Vd0uaudLhD8YIKY6rthkgrqDreVGBsHNq4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1766507127; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=fP4Ult4IiCglBm44aZ9Nl/gu90LlcKEXWw30G3qrSXI=; b=YMNSBZzago9Z7tcNmvri69fjFLvyZVaFlY7wbg+CTryZsiBNmkc0ntjqoLtMGUgC dNsg74EYeCv+kmGs+awC7/JNYNW0kSt6U00Eik4b9Hm0rQb49EF+JC9Rr8qVpZeaUrq u6e/rN9hxr8xINoSli2l+TwgXnRZnZpcg+Pn2ZOg= Received: by mx.zohomail.com with SMTPS id 1766507125254181.2609560362199; Tue, 23 Dec 2025 08:25:25 -0800 (PST) From: Nicolas Frattaroli Date: Tue, 23 Dec 2025 17:24:59 +0100 Subject: [PATCH v6 2/3] drm/panthor: Add tracepoint for hardware utilisation changes Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251223-panthor-tracepoints-v6-2-d3c998ee9efc@collabora.com> References: <20251223-panthor-tracepoints-v6-0-d3c998ee9efc@collabora.com> In-Reply-To: <20251223-panthor-tracepoints-v6-0-d3c998ee9efc@collabora.com> To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chia-I Wu , Karunika Choo Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 Mali GPUs have three registers that indicate which parts of the hardware are powered at any moment. These take the form of bitmaps. In the case of SHADER_READY for example, a high bit indicates that the shader core corresponding to that bit index is powered on. These bitmaps aren't solely contiguous bits, as it's common to have holes in the sequence of shader core indices, and the actual set of which cores are present is defined by the "shader present" register. When the GPU finishes a power state transition, it fires a GPU_IRQ_POWER_CHANGED_ALL interrupt. After such an interrupt is received, the _READY registers will contain new interesting data. During power transitions, the GPU_IRQ_POWER_CHANGED interrupt will fire, and the registers will likewise contain potentially changed data. This is not to be confused with the PWR_IRQ_POWER_CHANGED_ALL interrupt, which is something related to Mali v14+'s power control logic. The _READY registers and corresponding interrupts are already available in v9 and onwards. Expose the data as a tracepoint to userspace. This allows users to debug various scenarios and gather interesting information, such as: knowing how much hardware is lit up at any given time, correlating graphics corruption with a specific powered shader core, measuring when hardware is allowed to go to a powered off state again, and so on. The registration/unregistration functions for the tracepoint go through a wrapper in panthor_hw.c, so that v14+ can implement the same tracepoint by adding its hardware specific IRQ on/off callbacks to the panthor_hw.ops member. Signed-off-by: Nicolas Frattaroli --- drivers/gpu/drm/panthor/panthor_gpu.c | 30 +++++++++++++++- drivers/gpu/drm/panthor/panthor_gpu.h | 2 ++ drivers/gpu/drm/panthor/panthor_hw.c | 62 +++++++++++++++++++++++++++++= ++++ drivers/gpu/drm/panthor/panthor_hw.h | 8 +++++ drivers/gpu/drm/panthor/panthor_trace.h | 58 ++++++++++++++++++++++++++++++ 5 files changed, 159 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panthor/panthor_gpu.c b/drivers/gpu/drm/pantho= r/panthor_gpu.c index 057e167468d0..fc0a8c2aa7c7 100644 --- a/drivers/gpu/drm/panthor/panthor_gpu.c +++ b/drivers/gpu/drm/panthor/panthor_gpu.c @@ -22,6 +22,9 @@ #include "panthor_hw.h" #include "panthor_regs.h" =20 +#define CREATE_TRACE_POINTS +#include "panthor_trace.h" + /** * struct panthor_gpu - GPU block management data. */ @@ -48,6 +51,9 @@ struct panthor_gpu { GPU_IRQ_RESET_COMPLETED | \ GPU_IRQ_CLEAN_CACHES_COMPLETED) =20 +#define GPU_POWER_INTERRUPTS_MASK \ + (GPU_IRQ_POWER_CHANGED | GPU_IRQ_POWER_CHANGED_ALL) + static void panthor_gpu_coherency_set(struct panthor_device *ptdev) { gpu_write(ptdev, GPU_COHERENCY_PROTOCOL, @@ -80,6 +86,12 @@ static void panthor_gpu_irq_handler(struct panthor_devic= e *ptdev, u32 status) { gpu_write(ptdev, GPU_INT_CLEAR, status); =20 + if (tracepoint_enabled(gpu_power_status) && (status & GPU_POWER_INTERRUPT= S_MASK)) + trace_gpu_power_status(ptdev->base.dev, + gpu_read64(ptdev, SHADER_READY), + gpu_read64(ptdev, TILER_READY), + gpu_read64(ptdev, L2_READY)); + if (status & GPU_IRQ_FAULT) { u32 fault_status =3D gpu_read(ptdev, GPU_FAULT_STATUS); u64 address =3D gpu_read64(ptdev, GPU_FAULT_ADDR); @@ -157,6 +169,22 @@ int panthor_gpu_init(struct panthor_device *ptdev) return 0; } =20 +int panthor_gpu_power_changed_on(struct panthor_device *ptdev) +{ + guard(pm_runtime_active)(ptdev->base.dev); + + panthor_gpu_irq_mask_enable(&ptdev->gpu->irq, GPU_POWER_INTERRUPTS_MASK); + + return 0; +} + +void panthor_gpu_power_changed_off(struct panthor_device *ptdev) +{ + guard(pm_runtime_active)(ptdev->base.dev); + + panthor_gpu_irq_mask_disable(&ptdev->gpu->irq, GPU_POWER_INTERRUPTS_MASK); +} + /** * panthor_gpu_block_power_off() - Power-off a specific block of the GPU * @ptdev: Device. @@ -395,7 +423,7 @@ void panthor_gpu_suspend(struct panthor_device *ptdev) */ void panthor_gpu_resume(struct panthor_device *ptdev) { - panthor_gpu_irq_resume(&ptdev->gpu->irq, GPU_INTERRUPTS_MASK); + panthor_gpu_irq_resume_restore(&ptdev->gpu->irq); panthor_hw_l2_power_on(ptdev); } =20 diff --git a/drivers/gpu/drm/panthor/panthor_gpu.h b/drivers/gpu/drm/pantho= r/panthor_gpu.h index 12e66f48ced1..12c263a39928 100644 --- a/drivers/gpu/drm/panthor/panthor_gpu.h +++ b/drivers/gpu/drm/panthor/panthor_gpu.h @@ -51,5 +51,7 @@ int panthor_gpu_l2_power_on(struct panthor_device *ptdev); int panthor_gpu_flush_caches(struct panthor_device *ptdev, u32 l2, u32 lsc, u32 other); int panthor_gpu_soft_reset(struct panthor_device *ptdev); +void panthor_gpu_power_changed_off(struct panthor_device *ptdev); +int panthor_gpu_power_changed_on(struct panthor_device *ptdev); =20 #endif diff --git a/drivers/gpu/drm/panthor/panthor_hw.c b/drivers/gpu/drm/panthor= /panthor_hw.c index 87ebb7ae42c4..ae3320d0e251 100644 --- a/drivers/gpu/drm/panthor/panthor_hw.c +++ b/drivers/gpu/drm/panthor/panthor_hw.c @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 or MIT /* Copyright 2025 ARM Limited. All rights reserved. */ =20 +#include + #include =20 #include "panthor_device.h" @@ -29,6 +31,8 @@ static struct panthor_hw panthor_hw_arch_v10 =3D { .soft_reset =3D panthor_gpu_soft_reset, .l2_power_off =3D panthor_gpu_l2_power_off, .l2_power_on =3D panthor_gpu_l2_power_on, + .power_changed_off =3D panthor_gpu_power_changed_off, + .power_changed_on =3D panthor_gpu_power_changed_on, }, }; =20 @@ -53,6 +57,64 @@ static struct panthor_hw_entry panthor_hw_match[] =3D { }, }; =20 +static int panthor_hw_set_power_tracing(struct device *dev, void *data) +{ + struct panthor_device *ptdev =3D dev_get_drvdata(dev); + + if (!ptdev) + return -ENODEV; + + if (!ptdev->hw) + return 0; + + if (data) { + if (ptdev->hw->ops.power_changed_on) + return ptdev->hw->ops.power_changed_on(ptdev); + } else { + if (ptdev->hw->ops.power_changed_off) + ptdev->hw->ops.power_changed_off(ptdev); + } + + return 0; +} + +int panthor_hw_power_status_register(void) +{ + struct device_driver *drv; + int ret; + + drv =3D driver_find("panthor", &platform_bus_type); + if (!drv) + return -ENODEV; + + ret =3D driver_for_each_device(drv, NULL, (void *)true, + panthor_hw_set_power_tracing); + + return ret; +} + +void panthor_hw_power_status_unregister(void) +{ + struct device_driver *drv; + int ret; + + drv =3D driver_find("panthor", &platform_bus_type); + if (!drv) + return; + + ret =3D driver_for_each_device(drv, NULL, NULL, panthor_hw_set_power_trac= ing); + + /* + * Ideally, it'd be possible to ask driver_for_each_device to hand us + * another "start" to keep going after the failing device, but it + * doesn't do that. Minor inconvenience in what is probably a bad day + * on the computer already though. + */ + if (ret) + pr_warn("Couldn't mask power IRQ for at least one device: %pe\n", + ERR_PTR(ret)); +} + static char *get_gpu_model_name(struct panthor_device *ptdev) { const u32 gpu_id =3D ptdev->gpu_info.gpu_id; diff --git a/drivers/gpu/drm/panthor/panthor_hw.h b/drivers/gpu/drm/panthor= /panthor_hw.h index 56c68c1e9c26..2c28aea82841 100644 --- a/drivers/gpu/drm/panthor/panthor_hw.h +++ b/drivers/gpu/drm/panthor/panthor_hw.h @@ -19,6 +19,12 @@ struct panthor_hw_ops { =20 /** @l2_power_on: L2 power on function pointer */ int (*l2_power_on)(struct panthor_device *ptdev); + + /** @power_changed_on: Start listening to power change IRQs */ + int (*power_changed_on)(struct panthor_device *ptdev); + + /** @power_changed_off: Stop listening to power change IRQs */ + void (*power_changed_off)(struct panthor_device *ptdev); }; =20 /** @@ -32,6 +38,8 @@ struct panthor_hw { }; =20 int panthor_hw_init(struct panthor_device *ptdev); +int panthor_hw_power_status_register(void); +void panthor_hw_power_status_unregister(void); =20 static inline int panthor_hw_soft_reset(struct panthor_device *ptdev) { diff --git a/drivers/gpu/drm/panthor/panthor_trace.h b/drivers/gpu/drm/pant= hor/panthor_trace.h new file mode 100644 index 000000000000..5bd420894745 --- /dev/null +++ b/drivers/gpu/drm/panthor/panthor_trace.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0 or MIT */ +/* Copyright 2025 Collabora ltd. */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM panthor + +#if !defined(__PANTHOR_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ) +#define __PANTHOR_TRACE_H__ + +#include +#include + +#include "panthor_hw.h" + +/** + * gpu_power_status - called whenever parts of GPU hardware are turned on = or off + * @dev: pointer to the &struct device, for printing the device name + * @shader_bitmap: bitmap where a high bit indicates the shader core at a = given + * bit index is on, and a low bit indicates a shader core = is + * either powered off or absent + * @tiler_bitmap: bitmap where a high bit indicates the tiler unit at a gi= ven + * bit index is on, and a low bit indicates a tiler unit is + * either powered off or absent + * @l2_bitmap: bitmap where a high bit indicates the L2 cache at a given b= it + * index is on, and a low bit indicates the L2 cache is either + * powered off or absent + */ +TRACE_EVENT_FN(gpu_power_status, + TP_PROTO(const struct device *dev, u64 shader_bitmap, u64 tiler_bitmap, + u64 l2_bitmap), + TP_ARGS(dev, shader_bitmap, tiler_bitmap, l2_bitmap), + TP_STRUCT__entry( + __string(dev_name, dev_name(dev)) + __field(u64, shader_bitmap) + __field(u64, tiler_bitmap) + __field(u64, l2_bitmap) + ), + TP_fast_assign( + __assign_str(dev_name); + __entry->shader_bitmap =3D shader_bitmap; + __entry->tiler_bitmap =3D tiler_bitmap; + __entry->l2_bitmap =3D l2_bitmap; + ), + TP_printk("%s: shader_bitmap=3D0x%llx tiler_bitmap=3D0x%llx l2_bitmap=3D0= x%llx", + __get_str(dev_name), __entry->shader_bitmap, __entry->tiler_bitmap, + __entry->l2_bitmap + ), + panthor_hw_power_status_register, panthor_hw_power_status_unregister +); + +#endif /* __PANTHOR_TRACE_H__ */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE panthor_trace + +#include --=20 2.52.0 From nobody Sun Feb 8 11:16:32 2026 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 9B9202773C3 for ; Tue, 23 Dec 2025 16:25:44 +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=1766507146; cv=pass; b=VC0kxjWJdHl+cmqUOj7EEY3LIe4T9gT/+Rd9XWnOZ4vM3bDFt3wDbQoQR1SeTdfQmY8CYVQVF3KUnCZAW7FVOq5ia+MroC4eUMyUhrwsNn2SPu94iKLcranDIiIiwgXTqd6/Sv7+B4MpbRBj0j1+rDpWOZvOi8Cn3rbgKyJ9OOM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766507146; c=relaxed/simple; bh=AYjyM3dIBGHKRG6cxc8HSQ2XMYuKPKbEu5ANHmBuV2c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QHuxyAyaFBjKjjcIWjJ+TMX4+Ll1hWZsfWRv8/e6OP5+ngjAuoyWasbuMqm5Ivvl7pN7PHr/qGTDno6sgefsSTIqjnxbOvTrhvmVGU1QYNQfVxikRKq3PtahQSAHtm75ez6jeTOwSXathxa5MFrU3tGNVyovcDAEzlfzPUWoutE= 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=nicolas.frattaroli@collabora.com header.b=IS7Qe4Ei; 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=nicolas.frattaroli@collabora.com header.b="IS7Qe4Ei" ARC-Seal: i=1; a=rsa-sha256; t=1766507129; cv=none; d=zohomail.com; s=zohoarc; b=V2clX0Kvg5oWkJLam0pH18JaY194skq5UEgEtQjKbT5sVo5v27QwuSqP62oc8xysnNscsIE+7zenLtXtVDmhmFGfaOeb+7XsAz83lAZXEe0YRraP7MmGgcHzbiJG61kKaIkX947m+hlObXVqdZ177Oxws3MrvYhtA0ysY6aXAKc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766507129; h=Content-Type: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=loq07D1mkSWL4qXJm2L3GeV4pBmAabcjQO2c0yX94eI=; b=aotGdYG3d/TAoL/XRLv6blb0NWA50qBGxOF56vDrZ2SC2LZcxQv/c3wLI5tAUbzY7B6Hc4/aSLiPMZos276HkJRKpeGpNtECIC+8Z6qyXkIQ9CL0YKhc1L5ilpgdI40/3bqnfyhVtjYXxX43RqUT13H6xzTTbGpwJsm9GrS0RhQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1766507129; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=loq07D1mkSWL4qXJm2L3GeV4pBmAabcjQO2c0yX94eI=; b=IS7Qe4EiWJ0DHtXXXQApKbNdjHbhxsshaacffARVA+Fd9DGlaUdgbCgmEluWKdRf l8Lxkf4F9UHrs9A0kjNG/pnwAt8AlAct430hO2WAO4wrqbNwCH8v75TWzYucGAL72n2 GU89T8Ioh9VnwwjeWBi01SLK5ieQOkMILqug8yXE= Received: by mx.zohomail.com with SMTPS id 1766507128694407.5909844696057; Tue, 23 Dec 2025 08:25:28 -0800 (PST) From: Nicolas Frattaroli Date: Tue, 23 Dec 2025 17:25:00 +0100 Subject: [PATCH v6 3/3] drm/panthor: Add gpu_job_irq tracepoint Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251223-panthor-tracepoints-v6-3-d3c998ee9efc@collabora.com> References: <20251223-panthor-tracepoints-v6-0-d3c998ee9efc@collabora.com> In-Reply-To: <20251223-panthor-tracepoints-v6-0-d3c998ee9efc@collabora.com> To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chia-I Wu , Karunika Choo Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 Mali's CSF firmware triggers the job IRQ whenever there's new firmware events for processing. While this can be a global event (BIT(31) of the status register), it's usually an event relating to a command stream group (the other bit indices). Panthor throws these events onto a workqueue for processing outside the IRQ handler. It's therefore useful to have an instrumented tracepoint that goes beyond the generic IRQ tracepoint for this specific case, as it can be augmented with additional data, namely the events bit mask. This can then be used to debug problems relating to GPU jobs events not being processed quickly enough. The duration_ns field can be used to work backwards from when the tracepoint fires (at the end of the IRQ handler) to figure out when the interrupt itself landed, providing not just information on how long the work queueing took, but also when the actual interrupt itself arrived. With this information in hand, the IRQ handler itself being slow can be excluded as a possible source of problems, and attention can be directed to the workqueue processing instead. Signed-off-by: Nicolas Frattaroli --- drivers/gpu/drm/panthor/panthor_fw.c | 13 +++++++++++++ drivers/gpu/drm/panthor/panthor_trace.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor= /panthor_fw.c index a64ec8756bed..513ed42f7b41 100644 --- a/drivers/gpu/drm/panthor/panthor_fw.c +++ b/drivers/gpu/drm/panthor/panthor_fw.c @@ -26,6 +26,7 @@ #include "panthor_mmu.h" #include "panthor_regs.h" #include "panthor_sched.h" +#include "panthor_trace.h" =20 #define CSF_FW_NAME "mali_csffw.bin" =20 @@ -1060,6 +1061,12 @@ static void panthor_fw_init_global_iface(struct pant= hor_device *ptdev) =20 static void panthor_job_irq_handler(struct panthor_device *ptdev, u32 stat= us) { + u32 duration; + u64 start; + + if (tracepoint_enabled(gpu_job_irq)) + start =3D ktime_get_ns(); + gpu_write(ptdev, JOB_INT_CLEAR, status); =20 if (!ptdev->fw->booted && (status & JOB_INT_GLOBAL_IF)) @@ -1072,6 +1079,12 @@ static void panthor_job_irq_handler(struct panthor_d= evice *ptdev, u32 status) return; =20 panthor_sched_report_fw_events(ptdev, status); + + if (tracepoint_enabled(gpu_job_irq)) { + if (check_sub_overflow(ktime_get_ns(), start, &duration)) + duration =3D U32_MAX; + trace_gpu_job_irq(ptdev->base.dev, status, duration); + } } PANTHOR_IRQ_HANDLER(job, JOB, panthor_job_irq_handler); =20 diff --git a/drivers/gpu/drm/panthor/panthor_trace.h b/drivers/gpu/drm/pant= hor/panthor_trace.h index 5bd420894745..6ffeb4fe6599 100644 --- a/drivers/gpu/drm/panthor/panthor_trace.h +++ b/drivers/gpu/drm/panthor/panthor_trace.h @@ -48,6 +48,34 @@ TRACE_EVENT_FN(gpu_power_status, panthor_hw_power_status_register, panthor_hw_power_status_unregister ); =20 +/** + * gpu_job_irq - called after a job interrupt from firmware completes + * @dev: pointer to the &struct device, for printing the device name + * @events: bitmask of BIT(CSG id) | BIT(31) for a global event + * @duration_ns: Nanoseconds between job IRQ handler entry and exit + * + * The panthor_job_irq_handler() function instrumented by this tracepoint = exits + * once it has queued the firmware interrupts for processing, not when the + * firmware interrupts are fully processed. This tracepoint allows for deb= ugging + * issues with delays in the workqueue's processing of events. + */ +TRACE_EVENT(gpu_job_irq, + TP_PROTO(const struct device *dev, u32 events, u32 duration_ns), + TP_ARGS(dev, events, duration_ns), + TP_STRUCT__entry( + __string(dev_name, dev_name(dev)) + __field(u32, events) + __field(u32, duration_ns) + ), + TP_fast_assign( + __assign_str(dev_name); + __entry->events =3D events; + __entry->duration_ns =3D duration_ns; + ), + TP_printk("%s: events=3D0x%x duration_ns=3D%d", __get_str(dev_name), + __entry->events, __entry->duration_ns) +); + #endif /* __PANTHOR_TRACE_H__ */ =20 #undef TRACE_INCLUDE_PATH --=20 2.52.0