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 D0B53C25B74 for ; Fri, 24 May 2024 19:01:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A16210F645; Fri, 24 May 2024 19:01:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="aPH1ee1g"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1ECF410F633 for ; Fri, 24 May 2024 19:01:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716577300; x=1748113300; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=NDnEhtSrFj17c6DemYfUFVm0DPZMfA4TiBAcIwcsbxA=; b=aPH1ee1gXULlBnFP6uqhZBKLiKlNCu7AqkO+tweCh9b4xzM5ZAgTc/uw igMmfu+DbMsrEc3zkgMSLuI8eTK0cm9pqAF+ByyzdGJ7lE3Pz+IxyPmqv 5FKSivrStiP/jF1xW4AECwy+qThtEQd6AicxDlQwFfV/LYb8uUPW7qA14 Ic4yk5Z/TyUsjH1gmcV0QH5SBX1ZLAh/rRyVpxeJWjkhlnhcZCBUizfQu Av4VRMvzv07RbvmosP89s1EJhRcSPCSLmUSnz6812zECzPPSPA2G47vDz 8UoIoaMVpf6VtgTljmM/BbXGMj0cbb+oi0TpWnDgEf5Y037b/mZqhQtEj g==; X-CSE-ConnectionGUID: I/x9Qb3TRO2xBq4x7PPf/A== X-CSE-MsgGUID: VGbLlAvQRN+ztzTF7oGaOQ== X-IronPort-AV: E=McAfee;i="6600,9927,11082"; a="13090707" X-IronPort-AV: E=Sophos;i="6.08,186,1712646000"; d="scan'208";a="13090707" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2024 12:01:39 -0700 X-CSE-ConnectionGUID: YgaWHTHnSCuc4wi+unO5FQ== X-CSE-MsgGUID: Xg9G2wv8T9W8UwVWWQGfnQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,186,1712646000"; d="scan'208";a="38694578" Received: from orsosgc001.jf.intel.com ([10.165.21.138]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2024 12:01:39 -0700 From: Ashutosh Dixit To: intel-xe@lists.freedesktop.org Subject: [PATCH 02/17] drm/xe/perf/uapi: Add perf_stream_paranoid sysctl Date: Fri, 24 May 2024 12:01:19 -0700 Message-ID: <20240524190134.134226-3-ashutosh.dixit@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240524190134.134226-1-ashutosh.dixit@intel.com> References: <20240524190134.134226-1-ashutosh.dixit@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" Normally only superuser/root can access perf counter data. However, superuser can set perf_stream_paranoid sysctl to 0 to allow non-privileged users to also access perf data. perf_stream_paranoid is introduced at the perf layer to allow different perf stream types to share this access mechanism. Reviewed-by: Umesh Nerlige Ramappa Signed-off-by: Ashutosh Dixit --- drivers/gpu/drm/xe/xe_module.c | 5 +++++ drivers/gpu/drm/xe/xe_perf.c | 28 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_perf.h | 4 ++++ 3 files changed, 37 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_module.c b/drivers/gpu/drm/xe/xe_module.c index 3edeb30d5ccb..893858a2eea0 100644 --- a/drivers/gpu/drm/xe/xe_module.c +++ b/drivers/gpu/drm/xe/xe_module.c @@ -11,6 +11,7 @@ #include "xe_drv.h" #include "xe_hw_fence.h" #include "xe_pci.h" +#include "xe_perf.h" #include "xe_sched_job.h" struct xe_modparam xe_modparam = { @@ -78,6 +79,10 @@ static const struct init_funcs init_funcs[] = { .init = xe_register_pci_driver, .exit = xe_unregister_pci_driver, }, + { + .init = xe_perf_sysctl_register, + .exit = xe_perf_sysctl_unregister, + }, }; static int __init xe_init(void) diff --git a/drivers/gpu/drm/xe/xe_perf.c b/drivers/gpu/drm/xe/xe_perf.c index a130076b59aa..37538e98dcc0 100644 --- a/drivers/gpu/drm/xe/xe_perf.c +++ b/drivers/gpu/drm/xe/xe_perf.c @@ -4,9 +4,13 @@ */ #include +#include #include "xe_perf.h" +u32 xe_perf_stream_paranoid = true; +static struct ctl_table_header *sysctl_header; + int xe_perf_ioctl(struct drm_device *dev, void *data, struct drm_file *file) { struct drm_xe_perf_param *arg = data; @@ -19,3 +23,27 @@ int xe_perf_ioctl(struct drm_device *dev, void *data, struct drm_file *file) return -EINVAL; } } + +static struct ctl_table perf_ctl_table[] = { + { + .procname = "perf_stream_paranoid", + .data = &xe_perf_stream_paranoid, + .maxlen = sizeof(xe_perf_stream_paranoid), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, + {} +}; + +int xe_perf_sysctl_register(void) +{ + sysctl_header = register_sysctl("dev/xe", perf_ctl_table); + return 0; +} + +void xe_perf_sysctl_unregister(void) +{ + unregister_sysctl_table(sysctl_header); +} diff --git a/drivers/gpu/drm/xe/xe_perf.h b/drivers/gpu/drm/xe/xe_perf.h index 254cc7cf49fe..1ff0a07ebab3 100644 --- a/drivers/gpu/drm/xe/xe_perf.h +++ b/drivers/gpu/drm/xe/xe_perf.h @@ -11,6 +11,10 @@ struct drm_device; struct drm_file; +extern u32 xe_perf_stream_paranoid; + int xe_perf_ioctl(struct drm_device *dev, void *data, struct drm_file *file); +int xe_perf_sysctl_register(void); +void xe_perf_sysctl_unregister(void); #endif -- 2.41.0