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 B7D5CC77B73 for ; Wed, 31 May 2023 05:33:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7292A10E1B1; Wed, 31 May 2023 05:33:16 +0000 (UTC) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id CFB6110E1B1 for ; Wed, 31 May 2023 05:33:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685511193; x=1717047193; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=YAFk/YO6pVcfMg9qfVNVq3biFwr8GXCwEd+YbvD2qSo=; b=a6/C8/tNqmXogrnHGZV8nmhrWzf6L/qqIIHzVTVR72nwBZ+QcM0XzHSF 9DxJ6ZhEm0+U9jGTt4lVlkdx4Y5bJoaIvVBsHV9xj3wWj5P97GSSpykIL MUP2NwTvpS9nPUvNao9vcmz+WZS9eaed38f+1jkT1NrpXPPXAlZR8AlTm L7K31SG4Ubw0UUci7BBOXxVO0GfmAO0MXMBUhRIM6InXZlQuFLC3ANqxF 4piZ+BHDpbeuNv3VzDVyBRRrFf3TVDjAyOYheUu98P4D92oMAhlETn7Ve UirgeFVLX7ZC2Nj8loYCLxXDrFxDRDXX7ug5Sas38pDvQ3wkyqc/Qg+f3 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="418635680" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="418635680" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 22:33:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="684273118" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="684273118" Received: from adixit-mobl.amr.corp.intel.com (HELO adixit-arch.intel.com) ([10.209.8.169]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 22:33:13 -0700 Date: Tue, 30 May 2023 22:32:54 -0700 Message-ID: <87a5xlhxq1.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Sujaritha Sundaresan In-Reply-To: <20230530103421.2824622-2-sujaritha.sundaresan@intel.com> References: <20230530103421.2824622-1-sujaritha.sundaresan@intel.com> <20230530103421.2824622-2-sujaritha.sundaresan@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Subject: Re: [Intel-xe] [PATCH 1/1] [RFC]drm/xe: Adding throttle reasons sysfs attributes 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: , Cc: Anshuman Gupta , intel-xe@lists.freedesktop.org Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" On Tue, 30 May 2023 03:34:21 -0700, Sujaritha Sundaresan wrote: > Hi Suja, > Adding throttle reasons sysfs attributes. I am not sure about the location for these sysfs files. And whether or not these are being exposed using hwmon or not in xe. I believe the patch will have to wait for someone like Rodrigo to look at (unless another xe developer knows) but we can fix other things meanwhile. Also one more comment: didn't we want to expose the upper 16 bits too (the log bits) or only the lower 16 bits (status bits)? Though the log bits can be a separate patch too. > > Signed-off-by: Sujaritha Sundaresan > --- > drivers/gpu/drm/xe/regs/xe_gt_regs.h | 12 +++++ > drivers/gpu/drm/xe/xe_guc_pc.c | 67 ++++++++++++++++++++++++++++ > 2 files changed, 79 insertions(+) > > diff --git a/drivers/gpu/drm/xe/regs/xe_gt_regs.h b/drivers/gpu/drm/xe/regs/xe_gt_regs.h > index e64e5c0733d6..e7fe8a3e348e 100644 > --- a/drivers/gpu/drm/xe/regs/xe_gt_regs.h > +++ b/drivers/gpu/drm/xe/regs/xe_gt_regs.h > @@ -374,4 +374,16 @@ > #define XEHPC_BCS5_BCS6_INTR_MASK XE_REG(0x190118) > #define XEHPC_BCS7_BCS8_INTR_MASK XE_REG(0x19011c) > > +#define GT0_PERF_LIMIT_REASONS XE_REG(0x1381a8) > +#define GT0_PERF_LIMIT_REASONS_MASK 0xde3 > +#define PROCHOT_MASK REG_BIT(0) > +#define THERMAL_LIMIT_MASK REG_BIT(1) > +#define RATL_MASK REG_BIT(5) > +#define VR_THERMALERT_MASK REG_BIT(6) > +#define VR_TDC_MASK REG_BIT(7) > +#define POWER_LIMIT_4_MASK REG_BIT(8) > +#define POWER_LIMIT_1_MASK REG_BIT(10) > +#define POWER_LIMIT_2_MASK REG_BIT(11) > +#define MTL_MEDIA_PERF_LIMIT_REASONS XE_REG(0x138030) > + > #endif > diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c > index e799faa1c6b8..363332881e4d 100644 > --- a/drivers/gpu/drm/xe/xe_guc_pc.c > +++ b/drivers/gpu/drm/xe/xe_guc_pc.c > @@ -638,6 +638,73 @@ static const struct attribute *pc_attrs[] = { > NULL > }; > > +static inline > +xe_reg_t xe_gt_perf_limit_reasons_reg(struct xe_gt *gt) I don't see xe_reg_t being typedef'd anywhere, only 'struct xe_reg'? > +{ > + if (xe_gt_is_media_type(gt)) > + return MTL_MEDIA_PERF_LIMIT_REASONS; > + > + return GT0_PERF_LIMIT_REASONS; > +} > + > +struct xe_gt_bool_throttle_attr { > + struct attribute attr; > + ssize_t (*show)(struct device *dev, struct device_attribute *attr, > + char *buf); > + xe_reg_t (*reg32)(struct xe_gt *gt); > + u32 mask; > +}; > + > +bool xe_mmio_mask_read(struct xe_gt *gt, > + xe_reg_t reg32, u32 mask) > +{ > + return xe_mmio_read32(gt, reg32) & mask; > +} > + > +static ssize_t throttle_reason_bool_show(struct device *dev, > + struct device_attribute *attr, > + char *buff) > +{ > + struct kobject *kobj = &dev->kobj; > + struct xe_gt *gt = kobj_to_gt(kobj); > + struct xe_gt_bool_throttle_attr *t_attr = > + (struct xe_gt_bool_throttle_attr *) attr; > + bool val = xe_mmio_mask_read(>->rps, t_attr->reg32(gt), t_attr->mask); > + > + return sysfs_emit(buff, "%u\n", val); > +} > + > +#define XE_GT_BOOL_ATTR_RO(sysfs_func__, mask__) \ > +struct xe_gt_bool_throttle_attr attr_##sysfs_func__ = { \ > + .attr = { .name = __stringify(sysfs_func__), .mode = 0444 }, \ > + .show = throttle_reason_bool_show, \ > + .reg32 = xe_gt_perf_limit_reasons_reg, \ > + .mask = mask__, \ > +} > + > +static XE_GT_BOOL_ATTR_RO(throttle_reason_status, GT0_PERF_LIMIT_REASONS_MASK); > +static XE_GT_BOOL_ATTR_RO(throttle_reason_pl1, POWER_LIMIT_1_MASK); > +static XE_GT_BOOL_ATTR_RO(throttle_reason_pl2, POWER_LIMIT_2_MASK); > +static XE_GT_BOOL_ATTR_RO(throttle_reason_pl4, POWER_LIMIT_4_MASK); > +static XE_GT_BOOL_ATTR_RO(throttle_reason_thermal, THERMAL_LIMIT_MASK); > +static XE_GT_BOOL_ATTR_RO(throttle_reason_prochot, PROCHOT_MASK); > +static XE_GT_BOOL_ATTR_RO(throttle_reason_ratl, RATL_MASK); > +static XE_GT_BOOL_ATTR_RO(throttle_reason_vr_thermalert, VR_THERMALERT_MASK); > +static XE_GT_BOOL_ATTR_RO(throttle_reason_vr_tdc, VR_TDC_MASK); > + > +static const struct attribute *throttle_reason_attrs[] = { > + &dev_attr_throttle_reason_status.attr, > + &dev_attr_throttle_reason_pl1.attr, > + &dev_attr_throttle_reason_pl2.attr, > + &dev_attr_throttle_reason_pl4.attr, > + &dev_attr_throttle_reason_thermal.attr, > + &dev_attr_throttle_reason_prochot.attr, > + &dev_attr_throttle_reason_ratl.attr, > + &dev_attr_throttle_reason_vr_thermalert.attr, > + &dev_attr_throttle_reason_vr_tdc.attr, > + NULL > +}; Also don't see these attributes actually being created, using sysfs_create_files etc. So has this patch been compiled/tested? > + > static void mtl_init_fused_rp_values(struct xe_guc_pc *pc) > { > struct xe_gt *gt = pc_to_gt(pc); > -- > 2.25.1 > Thanks. -- Ashutosh