Skip to content

Commit fcc8f80

Browse files
drm/xe: Make read_perf_limit_reasons globally accessible
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
1 parent 83ee002 commit fcc8f80

File tree

5 files changed

+33
-29
lines changed

5 files changed

+33
-29
lines changed

drivers/gpu/drm/xe/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ xe-y += xe_bb.o \
8989
xe_gt_mcr.o \
9090
xe_gt_pagefault.o \
9191
xe_gt_sysfs.o \
92-
xe_gt_throttle_sysfs.o \
92+
xe_gt_throttle.o \
9393
xe_gt_tlb_invalidation.o \
9494
xe_gt_topology.o \
9595
xe_guc.o \

drivers/gpu/drm/xe/xe_gt_freq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "xe_device_types.h"
1515
#include "xe_gt_sysfs.h"
16-
#include "xe_gt_throttle_sysfs.h"
16+
#include "xe_gt_throttle.h"
1717
#include "xe_guc_pc.h"
1818
#include "xe_pm.h"
1919

@@ -245,5 +245,5 @@ int xe_gt_freq_init(struct xe_gt *gt)
245245
if (err)
246246
return err;
247247

248-
return xe_gt_throttle_sysfs_init(gt);
248+
return xe_gt_throttle_init(gt);
249249
}

drivers/gpu/drm/xe/xe_gt_throttle_sysfs.c renamed to drivers/gpu/drm/xe/xe_gt_throttle.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
#include "xe_device.h"
1010
#include "xe_gt.h"
1111
#include "xe_gt_sysfs.h"
12-
#include "xe_gt_throttle_sysfs.h"
12+
#include "xe_gt_throttle.h"
1313
#include "xe_mmio.h"
1414
#include "xe_pm.h"
1515

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

38-
static u32 read_perf_limit_reasons(struct xe_gt *gt)
38+
u32 xe_gt_throttle_get_limit_reasons(struct xe_gt *gt)
3939
{
4040
u32 reg;
4141

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

5252
static u32 read_status(struct xe_gt *gt)
5353
{
54-
u32 status = read_perf_limit_reasons(gt) & GT0_PERF_LIMIT_REASONS_MASK;
54+
u32 status = xe_gt_throttle_get_limit_reasons(gt) & GT0_PERF_LIMIT_REASONS_MASK;
5555

5656
return status;
5757
}
5858

5959
static u32 read_reason_pl1(struct xe_gt *gt)
6060
{
61-
u32 pl1 = read_perf_limit_reasons(gt) & POWER_LIMIT_1_MASK;
61+
u32 pl1 = xe_gt_throttle_get_limit_reasons(gt) & POWER_LIMIT_1_MASK;
6262

6363
return pl1;
6464
}
6565

6666
static u32 read_reason_pl2(struct xe_gt *gt)
6767
{
68-
u32 pl2 = read_perf_limit_reasons(gt) & POWER_LIMIT_2_MASK;
68+
u32 pl2 = xe_gt_throttle_get_limit_reasons(gt) & POWER_LIMIT_2_MASK;
6969

7070
return pl2;
7171
}
7272

7373
static u32 read_reason_pl4(struct xe_gt *gt)
7474
{
75-
u32 pl4 = read_perf_limit_reasons(gt) & POWER_LIMIT_4_MASK;
75+
u32 pl4 = xe_gt_throttle_get_limit_reasons(gt) & POWER_LIMIT_4_MASK;
7676

7777
return pl4;
7878
}
7979

8080
static u32 read_reason_thermal(struct xe_gt *gt)
8181
{
82-
u32 thermal = read_perf_limit_reasons(gt) & THERMAL_LIMIT_MASK;
82+
u32 thermal = xe_gt_throttle_get_limit_reasons(gt) & THERMAL_LIMIT_MASK;
8383

8484
return thermal;
8585
}
8686

8787
static u32 read_reason_prochot(struct xe_gt *gt)
8888
{
89-
u32 prochot = read_perf_limit_reasons(gt) & PROCHOT_MASK;
89+
u32 prochot = xe_gt_throttle_get_limit_reasons(gt) & PROCHOT_MASK;
9090

9191
return prochot;
9292
}
9393

9494
static u32 read_reason_ratl(struct xe_gt *gt)
9595
{
96-
u32 ratl = read_perf_limit_reasons(gt) & RATL_MASK;
96+
u32 ratl = xe_gt_throttle_get_limit_reasons(gt) & RATL_MASK;
9797

9898
return ratl;
9999
}
100100

101101
static u32 read_reason_vr_thermalert(struct xe_gt *gt)
102102
{
103-
u32 thermalert = read_perf_limit_reasons(gt) & VR_THERMALERT_MASK;
103+
u32 thermalert = xe_gt_throttle_get_limit_reasons(gt) & VR_THERMALERT_MASK;
104104

105105
return thermalert;
106106
}
107107

108108
static u32 read_reason_vr_tdc(struct xe_gt *gt)
109109
{
110-
u32 tdc = read_perf_limit_reasons(gt) & VR_TDC_MASK;
110+
u32 tdc = xe_gt_throttle_get_limit_reasons(gt) & VR_TDC_MASK;
111111

112112
return tdc;
113113
}
@@ -236,7 +236,7 @@ static void gt_throttle_sysfs_fini(void *arg)
236236
sysfs_remove_group(gt->freq, &throttle_group_attrs);
237237
}
238238

239-
int xe_gt_throttle_sysfs_init(struct xe_gt *gt)
239+
int xe_gt_throttle_init(struct xe_gt *gt)
240240
{
241241
struct xe_device *xe = gt_to_xe(gt);
242242
int err;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Copyright © 2023 Intel Corporation
4+
*/
5+
6+
#ifndef _XE_GT_THROTTLE_H_
7+
#define _XE_GT_THROTTLE_H_
8+
9+
#include <linux/types.h>
10+
11+
struct xe_gt;
12+
13+
int xe_gt_throttle_init(struct xe_gt *gt);
14+
15+
u32 xe_gt_throttle_get_limit_reasons(struct xe_gt *gt);
16+
17+
#endif /* _XE_GT_THROTTLE_H_ */

drivers/gpu/drm/xe/xe_gt_throttle_sysfs.h

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)