linux/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c

// SPDX-License-Identifier: MIT
/*
 * Copyright © 2022 Intel Corporation
 */

#include <drm/drm_device.h>
#include <linux/sysfs.h>
#include <linux/printk.h>

#include "i915_drv.h"
#include "i915_reg.h"
#include "i915_sysfs.h"
#include "intel_gt.h"
#include "intel_gt_print.h"
#include "intel_gt_regs.h"
#include "intel_gt_sysfs.h"
#include "intel_gt_sysfs_pm.h"
#include "intel_pcode.h"
#include "intel_rc6.h"
#include "intel_rps.h"

enum intel_gt_sysfs_op {};

static int
sysfs_gt_attribute_w_func(struct kobject *kobj, struct attribute *attr,
			  int (func)(struct intel_gt *gt, u32 val), u32 val)
{}

static u32
sysfs_gt_attribute_r_func(struct kobject *kobj, struct attribute *attr,
			  u32 (func)(struct intel_gt *gt),
			  enum intel_gt_sysfs_op op)
{}

/* RC6 interfaces will show the minimum RC6 residency value */
#define sysfs_gt_attribute_r_min_func(d, a, f)

/* Frequency interfaces will show the maximum frequency value */
#define sysfs_gt_attribute_r_max_func(d, a, f)

#define INTEL_GT_SYSFS_SHOW(_name, _attr_type)

#define INTEL_GT_SYSFS_STORE(_name, _func)

#define INTEL_GT_SYSFS_SHOW_MAX(_name)
#define INTEL_GT_SYSFS_SHOW_MIN(_name)

#define INTEL_GT_ATTR_RW(_name)

#define INTEL_GT_ATTR_RO(_name)

#define INTEL_GT_DUAL_ATTR_RW(_name)

#define INTEL_GT_DUAL_ATTR_RO(_name)

static u32 get_residency(struct intel_gt *gt, enum intel_rc6_res_type id)
{}

static ssize_t rc6_enable_show(struct kobject *kobj,
			       struct kobj_attribute *attr,
			       char *buff)
{}

static ssize_t rc6_enable_dev_show(struct device *dev,
				   struct device_attribute *attr,
				   char *buff)
{}

static u32 __rc6_residency_ms_show(struct intel_gt *gt)
{}

static u32 __rc6p_residency_ms_show(struct intel_gt *gt)
{}

static u32 __rc6pp_residency_ms_show(struct intel_gt *gt)
{}

static u32 __media_rc6_residency_ms_show(struct intel_gt *gt)
{}

INTEL_GT_SYSFS_SHOW_MIN(rc6_residency_ms);
INTEL_GT_SYSFS_SHOW_MIN(rc6p_residency_ms);
INTEL_GT_SYSFS_SHOW_MIN(rc6pp_residency_ms);
INTEL_GT_SYSFS_SHOW_MIN(media_rc6_residency_ms);

INTEL_GT_DUAL_ATTR_RO();
INTEL_GT_DUAL_ATTR_RO();
INTEL_GT_DUAL_ATTR_RO();
INTEL_GT_DUAL_ATTR_RO();
INTEL_GT_DUAL_ATTR_RO();

static struct attribute *rc6_attrs[] =;

static struct attribute *rc6p_attrs[] =;

static struct attribute *media_rc6_attrs[] =;

static struct attribute *rc6_dev_attrs[] =;

static struct attribute *rc6p_dev_attrs[] =;

static struct attribute *media_rc6_dev_attrs[] =;

static const struct attribute_group rc6_attr_group[] =;

static const struct attribute_group rc6p_attr_group[] =;

static const struct attribute_group media_rc6_attr_group[] =;

static int __intel_gt_sysfs_create_group(struct kobject *kobj,
					 const struct attribute_group *grp)
{}

static void intel_sysfs_rc6_init(struct intel_gt *gt, struct kobject *kobj)
{}

static u32 __act_freq_mhz_show(struct intel_gt *gt)
{}

static u32 __cur_freq_mhz_show(struct intel_gt *gt)
{}

static u32 __boost_freq_mhz_show(struct intel_gt *gt)
{}

static int __boost_freq_mhz_store(struct intel_gt *gt, u32 val)
{}

static u32 __RP0_freq_mhz_show(struct intel_gt *gt)
{}

static u32 __RPn_freq_mhz_show(struct intel_gt *gt)
{}

static u32 __RP1_freq_mhz_show(struct intel_gt *gt)
{}

static u32 __max_freq_mhz_show(struct intel_gt *gt)
{}

static int __set_max_freq(struct intel_gt *gt, u32 val)
{}

static u32 __min_freq_mhz_show(struct intel_gt *gt)
{}

static int __set_min_freq(struct intel_gt *gt, u32 val)
{}

static u32 __vlv_rpe_freq_mhz_show(struct intel_gt *gt)
{}

INTEL_GT_SYSFS_SHOW_MAX(act_freq_mhz);
INTEL_GT_SYSFS_SHOW_MAX(boost_freq_mhz);
INTEL_GT_SYSFS_SHOW_MAX(cur_freq_mhz);
INTEL_GT_SYSFS_SHOW_MAX(RP0_freq_mhz);
INTEL_GT_SYSFS_SHOW_MAX(RP1_freq_mhz);
INTEL_GT_SYSFS_SHOW_MAX(RPn_freq_mhz);
INTEL_GT_SYSFS_SHOW_MAX(max_freq_mhz);
INTEL_GT_SYSFS_SHOW_MIN(min_freq_mhz);
INTEL_GT_SYSFS_SHOW_MAX(vlv_rpe_freq_mhz);
INTEL_GT_SYSFS_STORE(boost_freq_mhz, __boost_freq_mhz_store);
INTEL_GT_SYSFS_STORE(max_freq_mhz, __set_max_freq);
INTEL_GT_SYSFS_STORE(min_freq_mhz, __set_min_freq);

#define INTEL_GT_RPS_SYSFS_ATTR(_name, _mode, _show, _store, _show_dev, _store_dev)

#define INTEL_GT_RPS_SYSFS_ATTR_RO(_name)
#define INTEL_GT_RPS_SYSFS_ATTR_RW(_name)

/* The below macros generate static structures */
INTEL_GT_RPS_SYSFS_ATTR_RO();
INTEL_GT_RPS_SYSFS_ATTR_RO();
INTEL_GT_RPS_SYSFS_ATTR_RW();
INTEL_GT_RPS_SYSFS_ATTR_RO();
INTEL_GT_RPS_SYSFS_ATTR_RO();
INTEL_GT_RPS_SYSFS_ATTR_RO();
INTEL_GT_RPS_SYSFS_ATTR_RW();
INTEL_GT_RPS_SYSFS_ATTR_RW();
INTEL_GT_RPS_SYSFS_ATTR_RO();

#define GEN6_ATTR(p, s)

#define GEN6_RPS_ATTR
#define GEN6_GT_ATTR

static const struct attribute * const gen6_rps_attrs[] =;
static const struct attribute * const gen6_gt_attrs[]  =;

static ssize_t punit_req_freq_mhz_show(struct kobject *kobj,
				       struct kobj_attribute *attr,
				       char *buff)
{}

static ssize_t slpc_ignore_eff_freq_show(struct kobject *kobj,
					 struct kobj_attribute *attr,
					 char *buff)
{}

static ssize_t slpc_ignore_eff_freq_store(struct kobject *kobj,
					  struct kobj_attribute *attr,
					  const char *buff, size_t count)
{}

struct intel_gt_bool_throttle_attr {};

static ssize_t throttle_reason_bool_show(struct kobject *kobj,
					 struct kobj_attribute *attr,
					 char *buff)
{}

#define INTEL_GT_RPS_BOOL_ATTR_RO(sysfs_func__, mask__)

INTEL_GT_ATTR_RO();
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_status, GT0_PERF_LIMIT_REASONS_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl1, POWER_LIMIT_1_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl2, POWER_LIMIT_2_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl4, POWER_LIMIT_4_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_thermal, THERMAL_LIMIT_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_prochot, PROCHOT_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_ratl, RATL_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_vr_thermalert, VR_THERMALERT_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_vr_tdc, VR_TDC_MASK);

static const struct attribute *throttle_reason_attrs[] =;

/*
 * Scaling for multipliers (aka frequency factors).
 * The format of the value in the register is u8.8.
 *
 * The presentation to userspace is inspired by the perf event framework.
 * See:
 *   Documentation/ABI/testing/sysfs-bus-event_source-devices-events
 * for description of:
 *   /sys/bus/event_source/devices/<pmu>/events/<event>.scale
 *
 * Summary: Expose two sysfs files for each multiplier.
 *
 * 1. File <attr> contains a raw hardware value.
 * 2. File <attr>.scale contains the multiplicative scale factor to be
 *    used by userspace to compute the actual value.
 *
 * So userspace knows that to get the frequency_factor it multiplies the
 * provided value by the specified scale factor and vice-versa.
 *
 * That way there is no precision loss in the kernel interface and API
 * is future proof should one day the hardware register change to u16.u16,
 * on some platform. (Or any other fixed point representation.)
 *
 * Example:
 * File <attr> contains the value 2.5, represented as u8.8 0x0280, which
 * is comprised of:
 * - an integer part of 2
 * - a fractional part of 0x80 (representing 0x80 / 2^8 == 0x80 / 256).
 * File <attr>.scale contains a string representation of floating point
 * value 0.00390625 (which is (1 / 256)).
 * Userspace computes the actual value:
 *   0x0280 * 0.00390625 -> 2.5
 * or converts an actual value to the value to be written into <attr>:
 *   2.5 / 0.00390625 -> 0x0280
 */

#define U8_8_VAL_MASK
#define U8_8_SCALE_TO_VALUE

static ssize_t freq_factor_scale_show(struct kobject *kobj,
				      struct kobj_attribute *attr,
				      char *buff)
{}

static u32 media_ratio_mode_to_factor(u32 mode)
{}

static ssize_t media_freq_factor_show(struct kobject *kobj,
				      struct kobj_attribute *attr,
				      char *buff)
{}

static ssize_t media_freq_factor_store(struct kobject *kobj,
				       struct kobj_attribute *attr,
				       const char *buff, size_t count)
{}

static ssize_t media_RP0_freq_mhz_show(struct kobject *kobj,
				       struct kobj_attribute *attr,
				       char *buff)
{}

static ssize_t media_RPn_freq_mhz_show(struct kobject *kobj,
				       struct kobj_attribute *attr,
				       char *buff)
{}

INTEL_GT_ATTR_RW();
static struct kobj_attribute attr_media_freq_factor_scale =;
INTEL_GT_ATTR_RO();
INTEL_GT_ATTR_RO();

INTEL_GT_ATTR_RW();

static const struct attribute *media_perf_power_attrs[] =;

static ssize_t
rps_up_threshold_pct_show(struct kobject *kobj, struct kobj_attribute *attr,
			  char *buf)
{}

static ssize_t
rps_up_threshold_pct_store(struct kobject *kobj, struct kobj_attribute *attr,
			   const char *buf, size_t count)
{}

static struct kobj_attribute rps_up_threshold_pct =;

static ssize_t
rps_down_threshold_pct_show(struct kobject *kobj, struct kobj_attribute *attr,
			    char *buf)
{}

static ssize_t
rps_down_threshold_pct_store(struct kobject *kobj, struct kobj_attribute *attr,
			     const char *buf, size_t count)
{}

static struct kobj_attribute rps_down_threshold_pct =;

static const struct attribute * const gen6_gt_rps_attrs[] =;

static ssize_t
default_min_freq_mhz_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{}

static struct kobj_attribute default_min_freq_mhz =;

static ssize_t
default_max_freq_mhz_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{}

static struct kobj_attribute default_max_freq_mhz =;

static ssize_t
default_rps_up_threshold_pct_show(struct kobject *kobj,
				  struct kobj_attribute *attr,
				  char *buf)
{}

static struct kobj_attribute default_rps_up_threshold_pct =;

static ssize_t
default_rps_down_threshold_pct_show(struct kobject *kobj,
				    struct kobj_attribute *attr,
				    char *buf)
{}

static struct kobj_attribute default_rps_down_threshold_pct =;

static const struct attribute * const rps_defaults_attrs[] =;

static int intel_sysfs_rps_init(struct intel_gt *gt, struct kobject *kobj)
{}

void intel_gt_sysfs_pm_init(struct intel_gt *gt, struct kobject *kobj)
{}