From mboxrd@z Thu Jan 1 00:00:00 1970 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 3FC15B640 for ; Sun, 11 Jan 2026 11:50:18 +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=1768132219; cv=pass; b=mH5t0aJx4co0NFNSHyy1CBkUsvXmJh4P7ufxbmmAcbk7T5tBP3zwqsSwraajSi/AmqieDCohxA8qOSyyTgZWtsYA0brAXsWKmSF5bk+8nKcjX7DLKOp0cHCKbT6UVCVPG5DufdCE/ZshCh7zBaM6tAgx/kyukU8+xmcmNGDwyDU= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768132219; c=relaxed/simple; bh=58LR6eNoHpT9vxFZyZuSqvbhb2NHBNcm8DyreGftAYU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RcOCkvP21mP1J4+GMK+uxyy20G6fKQ0mZSIrwd/OYIGjmOB6QS1HSVHbLFhippJhTWdg1TN2R0Cs93Pe8I0W6Ii0k5XX4vj4pzgqtJmhXekNRwvNsodGP7OBIiJXH9JvbKSyig9YBsh1x21RD7JQLmUVu5TgXBE4fy6GTSsk7Vk= 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=b4uzreFK; 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="b4uzreFK" ARC-Seal: i=1; a=rsa-sha256; t=1768132200; cv=none; d=zohomail.com; s=zohoarc; b=AMszW9mzf7RCdeBG2YkCxGzO98dzh32zKD5ITI/LuFt7NF/5Yp1DJofQHgcKF7vVwUfwM3UyN1a7Vh3IWiu5qyztHFMHOdHpKNOVbmWC8H05KbXgkxe6ZryoaFA86XWyGaeaTeiLUg3TjzrRXr4qUZCdc3WKxa8l0QcmAy1FRHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768132200; 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=9IkfbEtla6YJHcufGJvw4Hf3TfZP9r5IxC6tRB8yI4E=; b=jLZA7LMxL/Dbgb0KNnwHWUCKzhLAYf6B0ehJduY52J/VTHsp8h7vRy7iqVtwIlCJBXp2k/JWArag60aptwFU4fJkPHPaWg0wYvlKb4sA+wwOv6XEEiD3n1pZ3reyDVn2d9EYl985t66ak8aiWkgj/1f4qNISVkMuV9DzaRcYuZs= 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=1768132200; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type:Message-Id:Reply-To; bh=9IkfbEtla6YJHcufGJvw4Hf3TfZP9r5IxC6tRB8yI4E=; b=b4uzreFKEuiEKgyqhG38Yy3toSpMApuPJhUtHOGnehPn/AnariO4HsgW54Iodukw wcrhYEmS0tCnUY2n2C2lBqEB4JmW0fxDrMp74J1h/WeVFhlxsbxHDL75Njp2g7xWd2b n0hUxURr1iDOa02VdEABiLYo74Sq/nWypupknSOA= Received: by mx.zohomail.com with SMTPS id 1768132199201551.1665896418114; Sun, 11 Jan 2026 03:49:59 -0800 (PST) From: Nicolas Frattaroli To: Boris Brezillon , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chia-I Wu , Karunika Choo , Steven Price Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH v7 4/4] drm/panthor: Add gpu_job_irq tracepoint Date: Sun, 11 Jan 2026 12:49:53 +0100 Message-ID: <5773030.GXAFRqVoOG@workhorse> In-Reply-To: <0772b791-85ad-4eb0-8c71-daeae74f0b79@arm.com> References: <20260108-panthor-tracepoints-v7-0-afeae181f74a@collabora.com> <20260108-panthor-tracepoints-v7-4-afeae181f74a@collabora.com> <0772b791-85ad-4eb0-8c71-daeae74f0b79@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" On Friday, 9 January 2026 17:23:32 Central European Standard Time Steven Price wrote: > On 08/01/2026 14:19, Nicolas Frattaroli wrote: > > 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 0e46625f7621..b3b48c1b049c 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" > > > > #define CSF_FW_NAME "mali_csffw.bin" > > > > @@ -1060,6 +1061,12 @@ static void panthor_fw_init_global_iface(struct panthor_device *ptdev) > > > > static void panthor_job_irq_handler(struct panthor_device *ptdev, u32 status) > > { > > + u32 duration; > > + u64 start; > > + > > + if (tracepoint_enabled(gpu_job_irq)) > > + start = ktime_get_ns(); > > + > > gpu_write(ptdev, JOB_INT_CLEAR, status); > > > > if (!ptdev->fw->booted && (status & JOB_INT_GLOBAL_IF)) > > @@ -1072,6 +1079,12 @@ static void panthor_job_irq_handler(struct panthor_device *ptdev, u32 status) > > return; > > > > panthor_sched_report_fw_events(ptdev, status); > > + > > + if (tracepoint_enabled(gpu_job_irq)) { > > + if (check_sub_overflow(ktime_get_ns(), start, &duration)) > > It's minor but if the tracepoint was enabled during the handler, the > duration will use start uninitialised. It's probably best to initialise > start just to avoid a potential stack leak. Good catch. Should I unconditionally initialize it to ktime_get_ns(), or do we want to avoid a call into that and initialize it to something that will result in a nonsense duration? Alternatively we initialize it to 0 and skip the tracepoint if !start. My gut tells me reading the monotonic clock shouldn't be considered expensive, though having the tracepoint overhead with an inactive tracepoint be within a Planck time of "free" would be preferable, so I'm leaning towards u64 start = 0; if (tracepoint_enabled(gpu_job_irq)) start = ktime_get_ns(); ... if (start && tracepoint_enabled(gpu_job_irq)) { ... Kind regards, Nicolas Frattaroli > > Thanks, > Steve > > > + duration = U32_MAX; > > + trace_gpu_job_irq(ptdev->base.dev, status, duration); > > + } > > } > > PANTHOR_IRQ_HANDLER(job, JOB, panthor_job_irq_handler); > > > > diff --git a/drivers/gpu/drm/panthor/panthor_trace.h b/drivers/gpu/drm/panthor/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 > > ); > > > > +/** > > + * 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 debugging > > + * 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 = events; > > + __entry->duration_ns = duration_ns; > > + ), > > + TP_printk("%s: events=0x%x duration_ns=%d", __get_str(dev_name), > > + __entry->events, __entry->duration_ns) > > +); > > + > > #endif /* __PANTHOR_TRACE_H__ */ > > > > #undef TRACE_INCLUDE_PATH > > > >