Support host1x actmon
Subsystems (7)
cover Support host1x actmon
Activity monitoring (actmon for short) is a means to dynamically measure the utilization of units in the system to help drive software power management policies.
In Tegra, Dynamic Voltage and Frequency Scaling (DVFS) is the primary dynamic power management mechanism. It uses utilization information from various units to select the most efficient frequency and thereby, voltage that the unit should operate while providing the requisite performance.
Johnny Liu (5):
dt-bindings: display: tegra: Add actmon information
arm64: tegra: Add actmon information
gpu: host1x: Support device monitoring with actmon drm/tegra: nvdec: Register the device with actmon drm/tegra: vic: Register the device with actmon
.../display/tegra/nvidia,tegra20-host1x.yaml | 45 +- arch/arm64/boot/dts/nvidia/tegra234.dtsi | 10 +- drivers/gpu/drm/tegra/nvdec.c | 82 ++- drivers/gpu/drm/tegra/vic.c | 39 +- drivers/gpu/drm/tegra/vic.h | 9 + drivers/gpu/host1x/Makefile | 1 + drivers/gpu/host1x/actmon.c | 558 ++++++++++++++++++ drivers/gpu/host1x/actmon.h | 46 ++ drivers/gpu/host1x/dev.c | 71 ++- drivers/gpu/host1x/dev.h | 59 +- drivers/gpu/host1x/hw/actmon.h | 49 ++ drivers/gpu/host1x/hw/host1x08.c | 6 +- drivers/gpu/host1x/hw/hw_host1x08_common.h | 16 +- drivers/gpu/host1x/hw/intr_general_hw.c | 83 +++ include/linux/host1x.h | 30 +- 15 files changed, 1075 insertions(+), 29 deletions(-) create mode 100644 drivers/gpu/host1x/actmon.c create mode 100644 drivers/gpu/host1x/actmon.h create mode 100644 drivers/gpu/host1x/hw/actmon.h create mode 100644 drivers/gpu/host1x/hw/intr_general_hw.c
Signature · 1 line
2.34.1
PATCH 1/5 dt-bindings: display: tegra: Add actmon information
An activity monitor (actmon) is used to measure the device runtime utilization to help drive software power management policies.
Extend the reg space to include actmon aperture for actmon configuration through host1x.
Extend the number of clocks to include actmon clock, which is shared between unit actmons for different host1x clients.
--- .../display/tegra/nvidia,tegra20-host1x.yaml | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml +39 -6
@@ -32,11 +32,11 @@ properties: reg: minItems: 1 - maxItems: 3 + maxItems: 4 reg-names: minItems: 1 - maxItems: 3 + maxItems: 4 interrupts: minItems: 1
@@ -60,12 +60,12 @@ properties: maxItems: 1 clocks: - description: Must contain one entry, for the module clock. See - ../clocks/clock-bindings.txt for details. + minItems: 1 + maxItems: 2 clock-names: - items: - - const: host1x + minItems: 1 + maxItems: 2 resets: minItems: 1 # MC reset is optional on Tegra186 and later
@@ -132,6 +132,15 @@ allOf: items: - const: syncpt - const: host1x + + clocks: + items: + - description: host1x clock + + clock-names: + items: + - const: host1x + required: - resets - reset-names
@@ -170,6 +179,14 @@ allOf: - const: syncpt - const: host1x + clocks: + items: + - description: host1x clock + + clock-names: + items: + - const: host1x + iommu-map: description: Specification of stream IDs available for memory context device use. Should be a mapping of IDs 0..n to IOMMU entries corresponding to
@@ -195,16 +212,20 @@ allOf: then: properties: reg-names: + minItems: 3 items: - const: common - const: hypervisor - const: vm + - const: actmon reg: + minItems: 3 items: - description: region used by host1x server - description: region used by the hypervisor - description: region assigned to the virtual machine + - description: region used for configuring actmon for host1x clients interrupts: items:
@@ -230,6 +251,18 @@ allOf: - const: syncpt7 - const: host1x + clocks: + minItems: 1 + items: + - description: host1x clock + - description: actmon clock + + clock-names: + minItems: 1 + items: + - const: host1x + - const: actmon + iommu-map: description: Specification of stream IDs available for memory context device use. Should be a mapping of IDs 0..n to IOMMU entries corresponding to
Signature · 1 line
2.34.1
Re: [PATCH v1 1/5] dt-bindings: display: tegra: Add actmon information
Quoted 5 lines · Johnny Liu
An activity monitor (actmon) is used to measure the device runtime utilization to help drive software power management policies.
Extend the reg space to include actmon aperture for actmon configuration through host1x.
We kind of see that from the diff. Say what we do not see, e.g. ABI impact or why this is flexible/optional for existing devices.
Best regards,
Krzysztof
Re: [PATCH v1 1/5] dt-bindings: display: tegra: Add actmon information
Quoted 9 lines · Johnny Liu
Quoted 5 lines
An activity monitor (actmon) is used to measure the device runtime utilization to help drive software power management policies.
Extend the reg space to include actmon aperture for actmon configuration through host1x.
We kind of see that from the diff. Say what we do not see, e.g. ABI impact or why this is flexible/optional for existing devices.
Since actmon is not well-supported for the previous chips (e.g. T210, T186, T194, and etc) in this patch series, it's essential to make the specification of regs property optional for the previous chips.
Enablement/Disablement of actmon won't affect the host1x main functionality. Its main job is to monitor the engines behind the host1x and serve for telemetry purpose.
I could update the commit message to include the above reason. Please let me know if more information is required.
Thanks,
Johnny
Re: [PATCH v1 1/5] dt-bindings: display: tegra: Add actmon information
Quoted 7 lines · Johnny Liu
Quoted 7 lines · Johnny Liu
Quoted 5 lines
An activity monitor (actmon) is used to measure the device runtime utilization to help drive software power management policies.
Extend the reg space to include actmon aperture for actmon configuration through host1x.
Quoted 6 lines
Quoted 2 lines
We kind of see that from the diff. Say what we do not see, e.g. ABI impact or why this is flexible/optional for existing devices.
Since actmon is not well-supported for the previous chips (e.g. T210, T186, T194, and etc) in this patch series, it's essential to make the specification of regs property optional for the previous chips.
Then your schema should express it.
Quoted 7 lines
Enablement/Disablement of actmon won't affect the host1x main functionality. Its main job is to monitor the engines behind the host1x and serve for telemetry purpose.
I could update the commit message to include the above reason. Please let me know if more information is required.
And fix the schema to make it optional only for older variants.
Best regards,
Krzysztof
Re: [PATCH v1 1/5] dt-bindings: display: tegra: Add actmon information
Quoted 8 lines · Johnny Liu
Quoted 7 lines
Quoted 7 lines · Johnny Liu
Quoted 5 lines
An activity monitor (actmon) is used to measure the device runtime utilization to help drive software power management policies.
Extend the reg space to include actmon aperture for actmon configuration through host1x.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
We kind of see that from the diff. Say what we do not see, e.g. ABI impact or why this is flexible/optional for existing devices.
Since actmon is not well-supported for the previous chips (e.g. T210, T186, T194, and etc) in this patch series, it's essential to make the specification of regs property optional for the previous chips.
Then your schema should express it.
Could you explicitly point out which part doesn't express it well?
Considering old variant T194, the schema in this patch already made the specification of actmon related properties optional.
If users specify actmon clock handle in clocks/clock-names properties:
host1x@13e00000 {
compatible = "nvidia,tegra194-host1x";
// ...
clocks = <&bpmp TEGRA194_CLK_HOST1X>,
<&bpmp TEGRA194_CLK_ACTMON>;
clock-names = "host1x", "actmon";
// ...}
Running the dtbs_check will report error WITHOUT this patch will have the following error:
$ make O=out ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml
/out/arch/arm64/boot/dts/nvidia/tegra194-p3509-0000+p3668-0000.dtb: host1x@13e00000: clocks: [[5, 46], [5, 1]] is too long /out/arch/arm64/boot/dts/nvidia/tegra194-p3509-0000+p3668-0000.dtb: host1x@13e00000: clock-names: ['host1x', 'actmon'] is too long
Quoted 9 lines
Quoted 7 lines
Enablement/Disablement of actmon won't affect the host1x main functionality. Its main job is to monitor the engines behind the host1x and serve for telemetry purpose.
I could update the commit message to include the above reason. Please let me know if more information is required.
And fix the schema to make it optional only for older variants.
To maintain backward compatibility, shouldn't we keep the newly added feature optional for all the variants?
Thanks,
Johnny
Re: [PATCH v1 1/5] dt-bindings: display: tegra: Add actmon information
Quoted 11 lines · Johnny Liu
Quoted 11 lines · Johnny Liu
Quoted 10 lines
Quoted 9 lines · Johnny Liu
Quoted 5 lines
An activity monitor (actmon) is used to measure the device runtime utilization to help drive software power management policies.
Extend the reg space to include actmon aperture for actmon configuration through host1x.
We kind of see that from the diff. Say what we do not see, e.g. ABI impact or why this is flexible/optional for existing devices.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Since actmon is not well-supported for the previous chips (e.g. T210, T186, T194, and etc) in this patch series, it's essential to make the specification of regs property optional for the previous chips.
Then your schema should express it.
Could you explicitly point out which part doesn't express it well?
You said it should be optional for previous chip, while this is not made optional for previous chips. You made it optional for newest chips.
Quoted 14 lines
Considering old variant T194, the schema in this patch already made the specification of actmon related properties optional.
If users specify actmon clock handle in clocks/clock-names properties:
host1x@13e00000 { compatible = "nvidia,tegra194-host1x"; // ... clocks = <&bpmp TEGRA194_CLK_HOST1X>, <&bpmp TEGRA194_CLK_ACTMON>; clock-names = "host1x", "actmon"; // ...}
Quoted 7 lines
Running the
dtbs_checkwill report error WITHOUT this patch will have the following error:$ make O=out ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml/out/arch/arm64/boot/dts/nvidia/tegra194-p3509-0000+p3668-0000.dtb: host1x@13e00000: clocks: [[5, 46], [5, 1]] is too long /out/arch/arm64/boot/dts/nvidia/tegra194-p3509-0000+p3668-0000.dtb: host1x@13e00000: clock-names: ['host1x', 'actmon'] is too long
This is not the meaning of word "optional".
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Enablement/Disablement of actmon won't affect the host1x main functionality. Its main job is to monitor the engines behind the host1x and serve for telemetry purpose.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I could update the commit message to include the above reason. Please let me know if more information is required.
And fix the schema to make it optional only for older variants.
To maintain backward compatibility, shouldn't we keep the newly added feature optional for all the variants?
Yes, but it is about driver. Is it optional in the driver?
Your binding says optional but driver says required and will fail. This does not make any sense in the context of this patch and even less in the context of your explanation.
Best regards,
Krzysztof
PATCH 2/5 arm64: tegra: Add actmon information
In reply to Johnny LiuAn activity monitor (actmon) is used to measure the device runtime utilization to help drive software power management policies.
Configuration of actmon is under the host1x address space. Therefore, add the actmon aperture under the host1x.
All unit actmons for host1x clients share the same actmon clock source from host1x. Therefore, add the clock phandle in host1x.
--- arch/arm64/boot/dts/nvidia/tegra234.dtsi | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/nvidia/tegra234.dtsi +6 -4
@@ -4313,8 +4313,9 @@ host1x@13e00000 { compatible = "nvidia,tegra234-host1x"; reg = <0x0 0x13e00000 0x0 0x10000>, <0x0 0x13e10000 0x0 0x10000>, - <0x0 0x13e40000 0x0 0x10000>; - reg-names = "common", "hypervisor", "vm"; + <0x0 0x13e40000 0x0 0x10000>, + <0x0 0x13ef0000 0x0 0x60000>; + reg-names = "common", "hypervisor", "vm", "actmon"; interrupts = <GIC_SPI 448 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 449 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 450 IRQ_TYPE_LEVEL_HIGH>,
@@ -4326,8 +4327,9 @@ host1x@13e00000 { <GIC_SPI 263 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "syncpt0", "syncpt1", "syncpt2", "syncpt3", "syncpt4", "syncpt5", "syncpt6", "syncpt7", "host1x"; - clocks = <&bpmp TEGRA234_CLK_HOST1X>; - clock-names = "host1x"; + clocks = <&bpmp TEGRA234_CLK_HOST1X>, + <&bpmp TEGRA234_CLK_ACTMON>; + clock-names = "host1x", "actmon"; #address-cells = <2>; #size-cells = <2>;
Signature · 1 line
2.34.1
PATCH 3/5 gpu: host1x: Support device monitoring with actmon
In reply to Johnny LiuAn activity monitor (actmon) is used to measure the device runtime utilization to help drive software power management policies, such as device dynamic frequency scaling.
For every host1x client, an actmon is employed to monitor its runtime utilization. Upon detecting an actmon watermark breach against the sampled runtime utilization value, it will trigger an interrupt to the host1x subsystem to trigger device dynamic frequency scaling if supported by the client.
Upon registration with actmon within the host1x subsystem, a host1x client gains the ability to activate/deactivate its own actmon during the device resume/suspend cycle. This ensures that a host1x client runs at the power-optimal frequency when active, while also preventing unnecessary actmon interrupts during periods of inactivity.
--- drivers/gpu/host1x/Makefile | 1 + drivers/gpu/host1x/actmon.c | 558 +++++++++++++++++++++ drivers/gpu/host1x/actmon.h | 46 ++ drivers/gpu/host1x/dev.c | 71 ++- drivers/gpu/host1x/dev.h | 59 ++- drivers/gpu/host1x/hw/actmon.h | 49 ++ drivers/gpu/host1x/hw/host1x08.c | 6 +- drivers/gpu/host1x/hw/hw_host1x08_common.h | 16 +- drivers/gpu/host1x/hw/intr_general_hw.c | 83 +++ include/linux/host1x.h | 30 +- 10 files changed, 903 insertions(+), 16 deletions(-) create mode 100644 drivers/gpu/host1x/actmon.c create mode 100644 drivers/gpu/host1x/actmon.h create mode 100644 drivers/gpu/host1x/hw/actmon.h create mode 100644 drivers/gpu/host1x/hw/intr_general_hw.c
drivers/gpu/host1x/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 host1x-y = \ + actmon.o \ bus.o \ syncpt.o \ dev.o \
drivers/gpu/host1x/actmon.c new file +558 -0
558 lines not on this page · raw message
drivers/gpu/host1x/actmon.h new file +46 -0
46 lines not on this page · raw message
drivers/gpu/host1x/dev.c +67 -4
160 lines not on this page · raw message
drivers/gpu/host1x/dev.h +55 -4
128 lines not on this page · raw message
drivers/gpu/host1x/hw/actmon.h new file +49 -0
49 lines not on this page · raw message
drivers/gpu/host1x/hw/host1x08.c +4 -2
@@ -1,8 +1,8 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Host1x init for Tegra234 SoCs +* SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * -* Copyright (c) 2022 NVIDIA Corporation. +* Host1x init for Tegra234 SoCs */ /* include hw specification */
@@ -15,6 +15,7 @@#include "cdma_hw.c" #include "channel_hw.c" #include "debug_hw.c" +#include "intr_general_hw.c" #include "intr_hw.c" #include "syncpt_hw.c"
@@ -26,6 +27,7 @@ int host1x08_init(struct host1x *host) host->cdma_op = &host1x_cdma_ops; host->cdma_pb_op = &host1x_pushbuffer_ops; host->syncpt_op = &host1x_syncpt_ops; + host->intr_general_op = &host1x_intr_general_ops; host->intr_op = &host1x_intr_ops; host->debug_op = &host1x_debug_ops;
drivers/gpu/host1x/hw/hw_host1x08_common.h +13 -3
@@ -1,6 +1,5 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Copyright (c) 2022 NVIDIA Corporation. +/* SPDX-License-Identifier: GPL-2.0-only +* SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ #define HOST1X_COMMON_OFA_MLOCK 0x4050
@@ -9,3 +8,14 @@#define HOST1X_COMMON_NVENC_MLOCK 0x407c#define HOST1X_COMMON_NVDEC_MLOCK 0x4080#define HOST1X_COMMON_NVJPG_MLOCK 0x4084 + +#define HOST1X_COMMON_INTR_CPU0_MASK 0x4 +#define HOST1X_COMMON_THOST_INTRSTATUS 0x1c +#define HOST1X_COMMON_THOST_INTRMASK 0x30 +#define HOST1X_COMMON_THOST_GLOBAL_INTRMASK 0x44 + +#define HOST1X_COMMON_THOST_INTRMASK_VIC_ACTMON (v) ((v) << 3) +#define HOST1X_COMMON_THOST_INTRMASK_NVDEC_ACTMON (v) ((v) << 4) + +#define HOST1X_COMMON_THOST_INTRSTATUS_VIC_ACTMON_INTR BIT(3) +#define HOST1X_COMMON_THOST_INTRSTATUS_NVDEC_ACTMON_INTR BIT(4)
drivers/gpu/host1x/hw/intr_general_hw.c new file +83 -0
83 lines not on this page · raw message
include/linux/host1x.h +27 -3
@@ -1,6 +1,5 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* -* Copyright (c) 2009-2013, NVIDIA Corporation. All rights reserved. +/* SPDX-License-Identifier: GPL-2.0-only +* SPDX-FileCopyrightText: Copyright (c) 2009-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ #ifndef __LINUX_HOST1X_H
@@ -27,6 +26,13 @@ enum host1x_class { HOST1X_CLASS_OFA = 0xF8, }; +enum host1x_actmon_wmark_event { +HOST1X_ACTMON_AVG_WMARK_BELOW , +HOST1X_ACTMON_AVG_WMARK_ABOVE , +HOST1X_ACTMON_CONSEC_WMARK_BELOW , +HOST1X_ACTMON_CONSEC_WMARK_ABOVE , +}; +struct host1x ;struct host1x_client ;struct iommu_group ;
@@ -68,6 +74,8 @@ static inline void host1x_bo_cache_destroy(struct host1x_bo_cache *cache)* @late_exit: host1x client late tear down code * @suspend: host1x client suspend code * @resume: host1x client resume code +* @get_rate: host1x client get clock rate code +* @actmon_event: host1x client actmon event handling code in threaded interrupt context */ struct host1x_client_ops {int (*early_init)(struct host1x_client *client);
@@ -76,8 +84,13 @@ struct host1x_client_ops {int (*late_exit)(struct host1x_client *client);int (*suspend)(struct host1x_client *client);int (*resume)(struct host1x_client *client); +unsigned long (*get_rate)(struct host1x_client *client); +void (*actmon_event)(struct host1x_client *client, +enum host1x_actmon_wmark_event event); }; +struct host1x_actmon ; +/** * struct host1x_client - host1x client structure * @list: list node for the host1x client
@@ -93,6 +106,7 @@ struct host1x_client_ops {* @usecount: reference count for this structure * @lock: mutex for mutually exclusive concurrency * @cache: host1x buffer object cache +* @actmon: unit actmon for this host1x client */ struct host1x_client {struct list_head list;
@@ -113,6 +127,8 @@ struct host1x_client {struct mutex lock;struct host1x_bo_cache cache; + +struct host1x_actmon *actmon; };/*
@@ -500,4 +516,12 @@ static inline void host1x_memory_context_put(struct host1x_memory_context *cd) }#endif +int host1x_actmon_register (struct host1x_client *client); +void host1x_actmon_unregister (struct host1x_client *client); +void host1x_actmon_enable (struct host1x_client *client); +void host1x_actmon_disable (struct host1x_client *client); +void host1x_actmon_update_client_rate (struct host1x_client *client, +unsigned long rate, +u32 *weight); +#endif
Signature · 1 line
2.34.1
Re: [PATCH v1 3/5] gpu: host1x: Support device monitoring with actmon
Quoted 8 lines · Johnny Liu
drivers/gpu/host1x/actmon.c new file +8
-0+ +static int host1x_actmon_sample_period_set (void *data,u64 val) +{ +struct host1x_actmon *actmon = (struct host1x_actmon *)data; + + actmon->usecs_per_sample = (u32 )val; +host1x_actmon_update_sample_period (actmon); +
drivers/gpu/host1x/actmon.c line 87
Quoted 10 lines
drivers/gpu/host1x/actmon.c new file +10
-0+return 0 ; +} + +DEFINE_SIMPLE_ATTRIBUTE (host1x_actmon_sample_period_fops, + host1x_actmon_sample_period_get, + host1x_actmon_sample_period_set, +"%lld\n" ); + +/** +* host1x_actmon_debug_init - Initialize actmon debugfs
No, debugfs is only for debugging, not for usual interfaces. You now added several driver knobs bypassing any ABI documentation.
Quoted 18 lines
+ * @actmon: the actmon instance being configured
+ * @name: an unique name of the actmon
+ *
+ * There are multiple modules available inside the actmon, and they perform the
+ * signal sampling at the same rate. The debugfs of an actmon will expose this
+ * shared configuration,sample_period, via a debugfs node:
+ * -sample_period:
+ * Sampling period in micro-second of modules inside the actmon
+ */drivers/gpu/host1x/actmon.c new file +9
-0+static void host1x_actmon_debug_init (struct host1x_actmon *actmon,const char *name) +{ +struct host1x *host =dev_get_drvdata (actmon->client->host->parent); + +if (!host->debugfs) { +dev_warn (host->dev,"debugfs is unavailable\n" ); +return ; + } +
drivers/gpu/host1x/actmon.c line 115
Quoted 10 lines
drivers/gpu/host1x/actmon.c new file +10
-0+if (!host->actmon_debugfs) + host->actmon_debugfs =debugfs_create_dir ("actmon" , host->debugfs); + + actmon->debugfs =debugfs_create_dir (name, host->actmon_debugfs); + +/* R/W files */ +debugfs_create_file ("sample_period" ,0644 , actmon->debugfs, actmon, + &host1x_actmon_sample_period_fops); +} +
Best regards,
Krzysztof
Re: [PATCH v1 3/5] gpu: host1x: Support device monitoring with actmon
Quoted 16 lines · Johnny Liu
Quoted 15 lines
drivers/gpu/host1x/actmon.c new file +14
-0+ +static int host1x_actmon_sample_period_set (void *data,u64 val) +{ +struct host1x_actmon *actmon = (struct host1x_actmon *)data; + + actmon->usecs_per_sample = (u32 )val; +host1x_actmon_update_sample_period (actmon); + +return 0 ; +} + +DEFINE_SIMPLE_ATTRIBUTE(host1x_actmon_sample_period_fops, + host1x_actmon_sample_period_get, + host1x_actmon_sample_period_set,
Quoted 8 lines
drivers/gpu/host1x/actmon.c line 87
Quoted 4 lines
drivers/gpu/host1x/actmon.c new file +4
-0+ "%lld\n"); + +/** +* host1x_actmon_debug_init - Initialize actmon debugfs No, debugfs is only for debugging, not for usual interfaces. You now added several driver knobs bypassing any ABI documentation.
Thank you for pointing out the issue. I will expose these control interfaces under sysfs, probably hwmon, in the next patch series.
Quoted 20 lines
Quoted 20 lines
+ * @actmon: the actmon instance being configured
+ * @name: an unique name of the actmon
+ *
+ * There are multiple modules available inside the actmon, and they perform the
+ * signal sampling at the same rate. The debugfs of an actmon will expose this
+ * shared configuration,sample_period, via a debugfs node:
+ * -sample_period:
+ * Sampling period in micro-second of modules inside the actmon
+ */drivers/gpu/host1x/actmon.c new file +11
-0+static void host1x_actmon_debug_init (struct host1x_actmon *actmon,const char *name) +{ +struct host1x *host =dev_get_drvdata (actmon->client->host->parent); + +if (!host->debugfs) { +dev_warn (host->dev,"debugfs is unavailable\n" ); +return ; + } + +if (!host->actmon_debugfs) + host->actmon_debugfs =debugfs_create_dir ("actmon" , host->debugfs);
Quoted 8 lines
drivers/gpu/host1x/actmon.c line 115
Quoted 8 lines
drivers/gpu/host1x/actmon.c new file +8
-0+ + actmon->debugfs =debugfs_create_dir (name, host->actmon_debugfs); + +/* R/W files */ +debugfs_create_file ("sample_period" ,0644 , actmon->debugfs, actmon, + &host1x_actmon_sample_period_fops); +} +
Thanks,
Johnny
PATCH 4/5 drm/tegra: nvdec: Register the device with actmon
In reply to Johnny LiuBy registering the nvdec with actmon, engine load information can be exported to the user through debugfs for engine profiling purpose.
--- drivers/gpu/drm/tegra/nvdec.c | 82 ++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-)
drivers/gpu/drm/tegra/nvdec.c +80 -2
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (c) 2015-2022, NVIDIA Corporation. +* SPDX-FileCopyrightText: Copyright (c) 2015-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ #include <linux/clk.h>
@@ -22,8 +22,21 @@#include "riscv.h" #include "vic.h" -#define NVDEC_FALCON_DEBUGINFO 0x1094 +#define NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_MASK 0xCAU +#define NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_BORPS 0xCBU +#define NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_WEIGHT 0xC9U +#define NVDEC_FALCON_UCLASS_METHOD_OFFSET 0x40 +#define NVDEC_FALCON_UCLASS_METHOD_DATA 0x44 +#define NVDEC_FALCON_DEBUGINFO 0x1094#define NVDEC_TFBIF_TRANSCFG 0x2c44 +#define NVDEC_TFBIF_ACTMON_ACTIVE_MASK 0x2c4c +#define NVDEC_TFBIF_ACTMON_ACTIVE_BORPS 0x2c50 +#define NVDEC_TFBIF_ACTMON_ACTIVE_WEIGHT 0x2c54 + +#define NVDEC_TFBIF_ACTMON_ACTIVE_MASK_STARVED BIT(0) +#define NVDEC_TFBIF_ACTMON_ACTIVE_MASK_STALLED BIT(1) +#define NVDEC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED BIT(2) +#define NVDEC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE BIT(7)struct nvdec_config {const char *firmware;
@@ -306,6 +319,56 @@ static int nvdec_load_falcon_firmware(struct nvdec *nvdec)return err; } +static void nvdec_actmon_reg_init (struct nvdec *nvdec) +{ +if (nvdec->config->has_riscv) { +nvdec_writel (nvdec, +NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_MASK , +NVDEC_FALCON_UCLASS_METHOD_OFFSET ); +nvdec_writel (nvdec, +NVDEC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED | +NVDEC_TFBIF_ACTMON_ACTIVE_MASK_STALLED | +NVDEC_TFBIF_ACTMON_ACTIVE_MASK_STARVED , +NVDEC_FALCON_UCLASS_METHOD_DATA ); +nvdec_writel (nvdec, +NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_BORPS , +NVDEC_FALCON_UCLASS_METHOD_OFFSET ); +nvdec_writel (nvdec, +NVDEC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE , +NVDEC_FALCON_UCLASS_METHOD_DATA ); + }else { +nvdec_writel (nvdec, +NVDEC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED | +NVDEC_TFBIF_ACTMON_ACTIVE_MASK_STALLED | +NVDEC_TFBIF_ACTMON_ACTIVE_MASK_STARVED , +NVDEC_TFBIF_ACTMON_ACTIVE_MASK ); +nvdec_writel (nvdec, +NVDEC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE , +NVDEC_TFBIF_ACTMON_ACTIVE_BORPS ); + } +} + +static void nvdec_count_weight_init (struct nvdec *nvdec,unsigned long rate) +{ +const struct nvdec_config *config = nvdec->config; +struct host1x_client *client = &nvdec->client.base; +u32 weight; + +host1x_actmon_update_client_rate (client, rate, &weight); + +if (!weight) +return ; + +if (!config->has_riscv) { +nvdec_writel (nvdec, weight,NVDEC_TFBIF_ACTMON_ACTIVE_WEIGHT ); + }else { +nvdec_writel (nvdec, +NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_WEIGHT , +NVDEC_FALCON_UCLASS_METHOD_OFFSET ); +nvdec_writel (nvdec, weight,NVDEC_FALCON_UCLASS_METHOD_DATA ); + } +} +static __maybe_unused int nvdec_runtime_resume (struct device *dev) {struct nvdec *nvdec =dev_get_drvdata (dev);
@@ -331,6 +394,10 @@ static __maybe_unused int nvdec_runtime_resume(struct device *dev) goto disable; } +nvdec_actmon_reg_init (nvdec); +nvdec_count_weight_init (nvdec,clk_get_rate (nvdec->clks[0 ].clk)); +host1x_actmon_enable (&nvdec->client.base); +return 0 ; disable:
@@ -346,6 +413,8 @@ static __maybe_unused int nvdec_runtime_suspend(struct device *dev)clk_bulk_disable_unprepare (nvdec->num_clks, nvdec->clks); +host1x_actmon_disable (&nvdec->client.base); +return 0 ; }
@@ -532,12 +601,20 @@ static int nvdec_probe(struct platform_device *pdev) goto exit_falcon; } + err =host1x_actmon_register (&nvdec->client.base); +if (err <0 ) { +dev_info (&pdev->dev,"failed to register host1x actmon: %d\n" , err); + goto exit_client; + } +pm_runtime_enable (dev);pm_runtime_use_autosuspend (dev);pm_runtime_set_autosuspend_delay (dev,500 );return 0 ; +exit_client: +host1x_client_unregister (&nvdec->client.base); exit_falcon:falcon_exit (&nvdec->falcon);
@@ -549,6 +626,7 @@ static void nvdec_remove(struct platform_device *pdev)struct nvdec *nvdec =platform_get_drvdata (pdev);pm_runtime_disable (&pdev->dev); +host1x_actmon_unregister (&nvdec->client.base);host1x_client_unregister (&nvdec->client.base);falcon_exit (&nvdec->falcon); }
Signature · 1 line
2.34.1
PATCH 5/5 drm/tegra: vic: Register the device with actmon
In reply to Johnny LiuBy registering the vic with actmon, engine load information can be exported to the user through debugfs for engine profiling purpose.
--- drivers/gpu/drm/tegra/vic.c | 39 ++++++++++++++++++++++++++++++++++++- drivers/gpu/drm/tegra/vic.h | 9 +++++++++ 2 files changed, 47 insertions(+), 1 deletion(-)
drivers/gpu/drm/tegra/vic.c +38 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (c) 2015, NVIDIA Corporation. +* SPDX-FileCopyrightText: Copyright (c) 2015-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ #include <linux/clk.h>
@@ -302,6 +302,28 @@ static int vic_load_firmware(struct vic *vic)return err; } +static void vic_actmon_reg_init (struct vic *vic) +{ +vic_writel (vic, +VIC_TFBIF_ACTMON_ACTIVE_MASK_STARVED | +VIC_TFBIF_ACTMON_ACTIVE_MASK_STALLED | +VIC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED , +NV_PVIC_TFBIF_ACTMON_ACTIVE_MASK ); +vic_writel (vic, +VIC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE , +NV_PVIC_TFBIF_ACTMON_ACTIVE_BORPS ); +} + +static void vic_count_weight_init (struct vic *vic,unsigned long rate) +{ +struct host1x_client *client = &vic->client.base; +u32 weight =0 ; + +host1x_actmon_update_client_rate (client, rate, &weight); + +if (weight) +vic_writel (vic, weight,NV_PVIC_TFBIF_ACTMON_ACTIVE_WEIGHT ); +}static int __maybe_unused vic_runtime_resume (struct device *dev) {
@@ -328,6 +350,10 @@ static int __maybe_unused vic_runtime_resume(struct device *dev)if (err <0 ) goto assert; +vic_actmon_reg_init (vic); +vic_count_weight_init (vic,clk_get_rate (vic->clk)); +host1x_actmon_enable (&vic->client.base); +return 0 ; assert:
@@ -352,6 +378,8 @@ static int __maybe_unused vic_runtime_suspend(struct device *dev)clk_disable_unprepare (vic->clk); +host1x_actmon_disable (&vic->client.base); +return 0 ; }
@@ -520,12 +548,20 @@ static int vic_probe(struct platform_device *pdev) goto exit_falcon; } + err =host1x_actmon_register (&vic->client.base); +if (err <0 ) { +dev_info (&pdev->dev,"failed to register host1x actmon: %d\n" , err); + goto exit_client; + } +pm_runtime_enable (dev);pm_runtime_use_autosuspend (dev);pm_runtime_set_autosuspend_delay (dev,500 );return 0 ; +exit_client: +host1x_client_unregister (&vic->client.base); exit_falcon:falcon_exit (&vic->falcon);
@@ -537,6 +573,7 @@ static void vic_remove(struct platform_device *pdev)struct vic *vic =platform_get_drvdata (pdev);pm_runtime_disable (&pdev->dev); +host1x_actmon_unregister (&vic->client.base);host1x_client_unregister (&vic->client.base);falcon_exit (&vic->falcon); }
drivers/gpu/drm/tegra/vic.h +9 -0
@@ -21,6 +21,15 @@#define CG_IDLE_CG_EN (1 << 6)#define CG_WAKEUP_DLY_CNT (val) ((val & 0xf) << 16) +#define NV_PVIC_TFBIF_ACTMON_ACTIVE_MASK 0x0000204c +#define NV_PVIC_TFBIF_ACTMON_ACTIVE_BORPS 0x00002050 +#define NV_PVIC_TFBIF_ACTMON_ACTIVE_WEIGHT 0x00002054 + +#define VIC_TFBIF_ACTMON_ACTIVE_MASK_STARVED BIT(0) +#define VIC_TFBIF_ACTMON_ACTIVE_MASK_STALLED BIT(1) +#define VIC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED BIT(2) +#define VIC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE BIT(7) +#define VIC_TFBIF_TRANSCFG 0x00002044#define TRANSCFG_ATT (i, v) (((v) & 0x3) << (i * 4))#define TRANSCFG_SID_HW 0
Signature · 1 line
2.34.1
Quoted 4 lines · Johnny Liu
Activity monitoring (actmon for short) is a means to dynamically measure the utilization of units in the system to help drive software power management policies.
Is this a resend or v2? Please always mark your patches appropriately - see submitting patches document.
b4 diff '[email protected]'
Grabbing thread from lore.kernel.org/all/[email protected]/t.mbox.gz
---
Analyzing 6 messages in the thread
Could not find lower series to compare against.
But I am sure I saw it somewhere...
Or just use b4, so all this problems disappear.
Best regards,
Krzysztof
Quoted 15 lines · Johnny Liu
Quoted 4 lines
Activity monitoring (actmon for short) is a means to dynamically measure the utilization of units in the system to help drive software power management policies.
Is this a resend or v2? Please always mark your patches appropriately - see submitting patches document.
b4 diff '[email protected]'
Grabbing thread from lore.kernel.org/all/[email protected]/t.mbox.gz
---
Analyzing 6 messages in the thread
Could not find lower series to compare against.
Quoted 3 lines
But I am sure I saw it somewhere...
Or just use b4, so all this problems disappear.
This is a resend actually to include all necessary To/Cc entries based on your comment in the previous patch series:
lore.kernel.org/linux-tegra/[email protected]
Previous one doesn't cover all the required reviewers as you mentioned, so I don't consider it as a valid patch series. Therefore, I resend it again and include the required folks and consider it as a brand new patch series.
I would definitely try the b4 tool you recommended and update my workflow. I actually use vanilla git send-mail and git format-patch currently...
Thanks,
Johnny
Quoted 15 lines · Johnny Liu
Quoted 15 lines · Johnny Liu
Quoted 4 lines
Activity monitoring (actmon for short) is a means to dynamically measure the utilization of units in the system to help drive software power management policies.
Is this a resend or v2? Please always mark your patches appropriately - see submitting patches document.
b4 diff '[email protected]'
Grabbing thread from lore.kernel.org/all/[email protected]/t.mbox.gz
---
Analyzing 6 messages in the thread
Could not find lower series to compare against.
Quoted 6 lines
Quoted 3 lines
But I am sure I saw it somewhere...
Or just use b4, so all this problems disappear.
This is a resend actually to include all necessary To/Cc entries based on your comment in the previous patch series:
Then mark patches as RESEND. Please carefully read submitting patches before posting anything.
Best regards,
Krzysztof