From mboxrd@z Thu Jan 1 00:00:00 1970 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 8081CCA0EEB for ; Tue, 19 Aug 2025 18:54:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E47510E652; Tue, 19 Aug 2025 18:54:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="X1AHihkA"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 94DC510E652 for ; Tue, 19 Aug 2025 18:54:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1755629640; x=1787165640; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=QMxiI60kTuJpr21EpoVBRUciCMGclP05Y7tKl5hbwNI=; b=X1AHihkAo5ZkzIA/0zSXR1wwOg8y2/pemcnlU0dsFSoecbh2hI8fmLXZ +804fpJE2hSWkDypC2jLZCmEXSNKNRcfnEi2FNdYe03bDAmGuAZaz4PK/ dI42pQSbEFW96oa5451TRRe+7FBlfTu0BSm3a8Le/DKX8DFys/hGk+5yo ZXqfH7kJYELEIT+jq+WPE0vCB+ay1XYfmgQiWH09QuEpymDACZ9raAyIh qBaABGVS4MiG+1fowETNoQMkrgtCE9QlVYY5Q/IcnpsVhom1lSk+bzgm1 TZZShmPdG4DmCClzv3X1H97LGqOdDsloAwdbEZ/DACYIRUI3cFxZ1Z1dO Q==; X-CSE-ConnectionGUID: ZCqKJa1VT7iLJaru35E8hQ== X-CSE-MsgGUID: qTgMUw8vTkmIUKu2DjDIUw== X-IronPort-AV: E=McAfee;i="6800,10657,11527"; a="57952500" X-IronPort-AV: E=Sophos;i="6.17,302,1747724400"; d="scan'208";a="57952500" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2025 11:54:00 -0700 X-CSE-ConnectionGUID: rrTI8YrVQNCP0r8VdBbarA== X-CSE-MsgGUID: iMHfsP+OQFiWRu70N8MJmg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,302,1747724400"; d="scan'208";a="198922575" Received: from lstrano-desk.jf.intel.com ([10.54.39.91]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2025 11:54:00 -0700 From: Matthew Brost To: intel-xe@lists.freedesktop.org Subject: [PATCH v4 1/2] drm/xe: Add clear_stats GT debugfs Date: Tue, 19 Aug 2025 11:53:48 -0700 Message-Id: <20250819185349.2837153-2-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250819185349.2837153-1-matthew.brost@intel.com> References: <20250819185349.2837153-1-matthew.brost@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" It helpful to clear GT stats, run a test cases which is being profiled, and look at the results of the stats from the individual test case. Add clear_stats GT debugfs entry whih allows the clearing of GT stats. v4: - Make clear_stats write only permissions (Himal) Signed-off-by: Matthew Brost --- drivers/gpu/drm/xe/xe_gt_debugfs.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_stats.c | 14 ++++++++++++++ drivers/gpu/drm/xe/xe_gt_stats.h | 1 + 3 files changed, 37 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_gt_debugfs.c b/drivers/gpu/drm/xe/xe_gt_debugfs.c index bf3a67b5951c..2cd14b36c75a 100644 --- a/drivers/gpu/drm/xe/xe_gt_debugfs.c +++ b/drivers/gpu/drm/xe/xe_gt_debugfs.c @@ -363,6 +363,27 @@ static ssize_t write_to_gt_call(const char __user *userbuf, size_t count, loff_t return count; } +static void clear_stats(struct xe_gt *gt) +{ + xe_gt_stats_clear(gt); +} + +static ssize_t clear_stats_write(struct file *file, + const char __user *userbuf, + size_t count, loff_t *ppos) +{ + struct seq_file *s = file->private_data; + struct xe_gt *gt = s->private; + + return write_to_gt_call(userbuf, count, ppos, clear_stats, gt); +} + +static int clear_stats_show(struct seq_file *s, void *unused) +{ + return 0; +} +DEFINE_SHOW_STORE_ATTRIBUTE(clear_stats); + static void force_reset(struct xe_gt *gt) { struct xe_device *xe = gt_to_xe(gt); @@ -448,6 +469,7 @@ void xe_gt_debugfs_register(struct xe_gt *gt) root->d_inode->i_private = gt; /* VF safe */ + debugfs_create_file("clear_stats", 0200, root, gt, &clear_stats_fops); debugfs_create_file("force_reset", 0600, root, gt, &force_reset_fops); debugfs_create_file("force_reset_sync", 0600, root, gt, &force_reset_sync_fops); diff --git a/drivers/gpu/drm/xe/xe_gt_stats.c b/drivers/gpu/drm/xe/xe_gt_stats.c index 30f942671c2b..7e12fc3759e2 100644 --- a/drivers/gpu/drm/xe/xe_gt_stats.c +++ b/drivers/gpu/drm/xe/xe_gt_stats.c @@ -50,3 +50,17 @@ int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p) return 0; } + +/** + * xe_gt_stats_clear - Clear the GT stats + * @gt: GT structure + * + * This clear (zeros) all the available GT stats. + */ +void xe_gt_stats_clear(struct xe_gt *gt) +{ + enum xe_gt_stats_id id; + + for (id = 0; id < __XE_GT_STATS_NUM_IDS; ++id) + atomic64_set(>->stats.counters[id], 0); +} diff --git a/drivers/gpu/drm/xe/xe_gt_stats.h b/drivers/gpu/drm/xe/xe_gt_stats.h index 38325ef53617..e8aea32bc971 100644 --- a/drivers/gpu/drm/xe/xe_gt_stats.h +++ b/drivers/gpu/drm/xe/xe_gt_stats.h @@ -13,6 +13,7 @@ struct drm_printer; #ifdef CONFIG_DEBUG_FS int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p); +void xe_gt_stats_clear(struct xe_gt *gt); void xe_gt_stats_incr(struct xe_gt *gt, const enum xe_gt_stats_id id, int incr); #else static inline void -- 2.34.1