Skip to content

Commit

Permalink
drm/xe: Make read_perf_limit_reasons globally accessible
Browse files Browse the repository at this point in the history
Other driver code beyond the sysfs interface wants to know about
throttling. So make the query function globally accessible.

v2: Revert include order change (review feedback from Lucas)
v3: Remove '_sysfs' from throttle file names and keep limit query in
the same file rather than moving elsewhere (review feedback from
Rodrigo).
v4: Correct #include while renaming header file (review feedback
from Lucas).

Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240518043700.3264362-2-John.C.Harrison@Intel.com
  • Loading branch information
John Harrison authored and John Harrison committed May 23, 2024
1 parent 83ee002 commit fcc8f80
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/xe/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ xe-y += xe_bb.o \
xe_gt_mcr.o \
xe_gt_pagefault.o \
xe_gt_sysfs.o \
xe_gt_throttle_sysfs.o \
xe_gt_throttle.o \
xe_gt_tlb_invalidation.o \
xe_gt_topology.o \
xe_guc.o \
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/xe/xe_gt_freq.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include "xe_device_types.h"
#include "xe_gt_sysfs.h"
#include "xe_gt_throttle_sysfs.h"
#include "xe_gt_throttle.h"
#include "xe_guc_pc.h"
#include "xe_pm.h"

Expand Down Expand Up @@ -245,5 +245,5 @@ int xe_gt_freq_init(struct xe_gt *gt)
if (err)
return err;

return xe_gt_throttle_sysfs_init(gt);
return xe_gt_throttle_init(gt);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#include "xe_device.h"
#include "xe_gt.h"
#include "xe_gt_sysfs.h"
#include "xe_gt_throttle_sysfs.h"
#include "xe_gt_throttle.h"
#include "xe_mmio.h"
#include "xe_pm.h"

/**
* DOC: Xe GT Throttle
*
* Provides sysfs entries for frequency throttle reasons in GT
* Provides sysfs entries and other helpers for frequency throttle reasons in GT
*
* device/gt#/freq0/throttle/status - Overall status
* device/gt#/freq0/throttle/reason_pl1 - Frequency throttle due to PL1
Expand All @@ -35,7 +35,7 @@ dev_to_gt(struct device *dev)
return kobj_to_gt(dev->kobj.parent);
}

static u32 read_perf_limit_reasons(struct xe_gt *gt)
u32 xe_gt_throttle_get_limit_reasons(struct xe_gt *gt)
{
u32 reg;

Expand All @@ -51,63 +51,63 @@ static u32 read_perf_limit_reasons(struct xe_gt *gt)

static u32 read_status(struct xe_gt *gt)
{
u32 status = read_perf_limit_reasons(gt) & GT0_PERF_LIMIT_REASONS_MASK;
u32 status = xe_gt_throttle_get_limit_reasons(gt) & GT0_PERF_LIMIT_REASONS_MASK;

return status;
}

static u32 read_reason_pl1(struct xe_gt *gt)
{
u32 pl1 = read_perf_limit_reasons(gt) & POWER_LIMIT_1_MASK;
u32 pl1 = xe_gt_throttle_get_limit_reasons(gt) & POWER_LIMIT_1_MASK;

return pl1;
}

static u32 read_reason_pl2(struct xe_gt *gt)
{
u32 pl2 = read_perf_limit_reasons(gt) & POWER_LIMIT_2_MASK;
u32 pl2 = xe_gt_throttle_get_limit_reasons(gt) & POWER_LIMIT_2_MASK;

return pl2;
}

static u32 read_reason_pl4(struct xe_gt *gt)
{
u32 pl4 = read_perf_limit_reasons(gt) & POWER_LIMIT_4_MASK;
u32 pl4 = xe_gt_throttle_get_limit_reasons(gt) & POWER_LIMIT_4_MASK;

return pl4;
}

static u32 read_reason_thermal(struct xe_gt *gt)
{
u32 thermal = read_perf_limit_reasons(gt) & THERMAL_LIMIT_MASK;
u32 thermal = xe_gt_throttle_get_limit_reasons(gt) & THERMAL_LIMIT_MASK;

return thermal;
}

static u32 read_reason_prochot(struct xe_gt *gt)
{
u32 prochot = read_perf_limit_reasons(gt) & PROCHOT_MASK;
u32 prochot = xe_gt_throttle_get_limit_reasons(gt) & PROCHOT_MASK;

return prochot;
}

static u32 read_reason_ratl(struct xe_gt *gt)
{
u32 ratl = read_perf_limit_reasons(gt) & RATL_MASK;
u32 ratl = xe_gt_throttle_get_limit_reasons(gt) & RATL_MASK;

return ratl;
}

static u32 read_reason_vr_thermalert(struct xe_gt *gt)
{
u32 thermalert = read_perf_limit_reasons(gt) & VR_THERMALERT_MASK;
u32 thermalert = xe_gt_throttle_get_limit_reasons(gt) & VR_THERMALERT_MASK;

return thermalert;
}

static u32 read_reason_vr_tdc(struct xe_gt *gt)
{
u32 tdc = read_perf_limit_reasons(gt) & VR_TDC_MASK;
u32 tdc = xe_gt_throttle_get_limit_reasons(gt) & VR_TDC_MASK;

return tdc;
}
Expand Down Expand Up @@ -236,7 +236,7 @@ static void gt_throttle_sysfs_fini(void *arg)
sysfs_remove_group(gt->freq, &throttle_group_attrs);
}

int xe_gt_throttle_sysfs_init(struct xe_gt *gt)
int xe_gt_throttle_init(struct xe_gt *gt)
{
struct xe_device *xe = gt_to_xe(gt);
int err;
Expand Down
17 changes: 17 additions & 0 deletions drivers/gpu/drm/xe/xe_gt_throttle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2023 Intel Corporation
*/

#ifndef _XE_GT_THROTTLE_H_
#define _XE_GT_THROTTLE_H_

#include <linux/types.h>

struct xe_gt;

int xe_gt_throttle_init(struct xe_gt *gt);

u32 xe_gt_throttle_get_limit_reasons(struct xe_gt *gt);

#endif /* _XE_GT_THROTTLE_H_ */
13 changes: 0 additions & 13 deletions drivers/gpu/drm/xe/xe_gt_throttle_sysfs.h

This file was deleted.

0 comments on commit fcc8f80

Please sign in to comment.