Skip to contentSkip to conversation

drm/v3d: Improve Performance Counters handling

PATCH Applied Maíra Canal 2 participants 11 messages May 12, 2024 – May 29, 2024

Subsystems (3)
lore
Share & tools
lore

Maíra Canal

author maintainer
#0 lore raw

v2 cover drm/v3d: Improve Performance Counters handling

This series has the intention to address two issues with Performance Counters on V3D:

1. Update the number of Performance Counters for V3D 7.1

V3D 7.1 has 93 performance counters, while V3D 4.2 has only 87. Although the series [1] enabled support for V3D 7.1, it didn’t replace the maximum number of performance counters. This led to errors in user space as the Vulkan driver updated the maximum number of performance counters, but the kernel didn’t.

Currently, the user space can request values for performance counters that are greater than 87 and the kernel will return an error instead of the values. That’s why dEQP-VK.query_pool.performance_query.* currently fails on Mesa CI [2]. This series intends to fix the dEQP-VK.query_pool.performance_query.* fail.

2. Make the kernel able to provide the Performance Counter descriptions

Although all the management of the Performance Monitors is done through IOCTLs, which means that the code is in the kernel, the performance counter descriptions are in Mesa. This means two things: (#1) only Mesa has access to the descriptions and (#2) we can have inconsistencies between the information provided by Mesa and the kernel, as seen in the first issue addressed by this series.

To minimize the risk of inconsistencies, this series proposes to use the kernel as a “single source of truth”. Therefore, if there are any changes to the performance monitors, all the changes must be done only in the kernel. This means that all information about the maximum number of performance counters and all the descriptions will now be retrieved from the kernel.

This series is coupled with a Mesa series [3] that enabled the use of the new IOCTL. I appreciate any feedback from both the kernel and Mesa implementations.

[1] https://lore.kernel.org/dri-devel/[email protected]/
[2] https://gitlab.freedesktop.org/mesa/mesa/-/commit/ea1f09a5f21839f4f3b93610b58507c4bd9b9b81
[3] https://gitlab.freedesktop.org/mairacanal/mesa/-/tree/v3dv/fix-perfcnt

Best Regards,
- Maíra Canal

---

v1 -> v2: https://lore.kernel.org/dri-devel/[email protected]/T/

* [5/6] s/DRM_V3D_PARAM_V3D_MAX_PERF_COUNTERS/DRM_V3D_PARAM_MAX_PERF_COUNTERS (Iago Toral)
* [6/6] Include a reference to the new DRM_V3D_PARAM_MAX_PERF_COUNTERS param (Iago Toral)
* Add Iago's R-b (Iago Toral)

Maíra Canal (6):
drm/v3d: Add Performance Counters descriptions for V3D 4.2 and 7.1 drm/v3d: Different V3D versions can have different number of perfcnt drm/v3d: Create a new V3D parameter for the maximum number of perfcnt drm/v3d: Create new IOCTL to expose performance counters information drm/v3d: Use V3D_MAX_COUNTERS instead of V3D_PERFCNT_NUM drm/v3d: Deprecate the use of the Performance Counters enum

 drivers/gpu/drm/v3d/v3d_drv.c                 |  11 +
 drivers/gpu/drm/v3d/v3d_drv.h                 |  14 +-
 drivers/gpu/drm/v3d/v3d_perfmon.c             |  36 ++-
 .../gpu/drm/v3d/v3d_performance_counters.h    | 208 ++++++++++++++++++
 drivers/gpu/drm/v3d/v3d_sched.c               |   2 +-
 include/uapi/drm/v3d_drm.h                    |  48 ++++
 6 files changed, 316 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/v3d/v3d_performance_counters.h
Signature · 1 line
2.44.0
author maintainer
#1 lore raw

PATCH v2 1/6 drm/v3d: Add Performance Counters descriptions for V3D 4.2 and 7.1

Add name, category and description for each one of the 93 performance counters available on V3D.

Note that V3D 4.2 has 87 performance counters, while V3D 7.1 has 93. Therefore, there are two performance counters arrays. The index of the performance counter for each V3D version is represented by its position on the array.

---
 drivers/gpu/drm/v3d/v3d_drv.h                 |   2 +
 .../gpu/drm/v3d/v3d_performance_counters.h    | 208 ++++++++++++++++++
 2 files changed, 210 insertions(+)
 create mode 100644 drivers/gpu/drm/v3d/v3d_performance_counters.h
drivers/gpu/drm/v3d/v3d_drv.h +2 -0
index a2c516fe6d79..671375a3bb66 100644
@@ -11,6 +11,8 @@
 #include <drm/drm_gem_shmem_helper.h>
 #include <drm/gpu_scheduler.h>
 
+#include "v3d_performance_counters.h"
+
 #include "uapi/drm/v3d_drm.h"
 
 struct clk;
drivers/gpu/drm/v3d/v3d_performance_counters.h new file +208 -0

208 lines not on this page · raw message

Signature · 1 line
2.44.0
author maintainer
#2 lore raw

PATCH v2 2/6 drm/v3d: Different V3D versions can have different number of perfcnt

In reply to Maíra Canal

Currently, even though V3D 7.1 has 93 performance counters, it is not possible to create counters bigger than 87, as v3d_perfmon_create_ioctl() understands that counters bigger than 87 are invalid.

Therefore, create a device variable to expose the maximum number of counters for a given V3D version and make v3d_perfmon_create_ioctl() check this variable.

This commit fixes CTS failures in the performance queries tests dEQP-VK.query_pool.performance_query.* [1]

Fixes 6fd9487147c4 ("drm/v3d: add brcm,2712-v3d as a compatible V3D device")
---
 drivers/gpu/drm/v3d/v3d_drv.c     | 7 +++++++
 drivers/gpu/drm/v3d/v3d_drv.h     | 5 +++++
 drivers/gpu/drm/v3d/v3d_perfmon.c | 3 ++-
 3 files changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/v3d/v3d_drv.c +7 -0
index 28b7ddce7747..6b9dd26df9fe 100644
@@ -294,6 +294,13 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 	v3d->cores = V3D_GET_FIELD(ident1, V3D_HUB_IDENT1_NCORES);
 	WARN_ON(v3d->cores > 1); /* multicore not yet implemented */
 
+	if (v3d->ver >= 71)
+		v3d->max_counters = ARRAY_SIZE(v3d_v71_performance_counters);
+	else if (v3d->ver >= 42)
+		v3d->max_counters = ARRAY_SIZE(v3d_v42_performance_counters);
+	else
+		v3d->max_counters = 0;
+
 	v3d->reset = devm_reset_control_get_exclusive(dev, NULL);
 	if (IS_ERR(v3d->reset)) {
 		ret = PTR_ERR(v3d->reset);
drivers/gpu/drm/v3d/v3d_drv.h +5 -0
index 671375a3bb66..bd1e38f7d10a 100644
@@ -104,6 +104,11 @@ struct v3d_dev {
 	int ver;
 	bool single_irq_line;
 
+	/* Different revisions of V3D have different total number of performance
+	 * counters
+	 */
+	unsigned int max_counters;
+
 	void __iomem *hub_regs;
 	void __iomem *core_regs[3];
 	void __iomem *bridge_regs;
drivers/gpu/drm/v3d/v3d_perfmon.c +2 -1
index e1be7368b87d..f268d9466c0f 100644
@@ -123,6 +123,7 @@ int v3d_perfmon_create_ioctl(struct drm_device *dev, void *data,
 {
 	struct v3d_file_priv *v3d_priv = file_priv->driver_priv;
 	struct drm_v3d_perfmon_create *req = data;
+	struct v3d_dev *v3d = v3d_priv->v3d;
 	struct v3d_perfmon *perfmon;
 	unsigned int i;
 	int ret;
@@ -134,7 +135,7 @@ int v3d_perfmon_create_ioctl(struct drm_device *dev, void *data,
 
 	/* Make sure all counters are valid. */
 	for (i = 0; i < req->ncounters; i++) {
-		if (req->counters[i] >= V3D_PERFCNT_NUM)
+		if (req->counters[i] >= v3d->max_counters)
 			return -EINVAL;
 	}
 
Signature · 1 line
2.44.0
author maintainer
#3 lore raw

PATCH v2 3/6 drm/v3d: Create a new V3D parameter for the maximum number of perfcnt

In reply to Maíra Canal

The maximum number of performance counters can change from version to version and it's important for userspace to know this value, as it needs to use the counters for performance queries. Therefore, expose the maximum number of performance counters to userspace as a parameter.

---
 drivers/gpu/drm/v3d/v3d_drv.c | 3 +++
 include/uapi/drm/v3d_drm.h    | 1 +
 2 files changed, 4 insertions(+)
drivers/gpu/drm/v3d/v3d_drv.c +3 -0
index 6b9dd26df9fe..d2c1d5053132 100644
@@ -94,6 +94,9 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data,
 	case DRM_V3D_PARAM_SUPPORTS_CPU_QUEUE:
 		args->value = 1;
 		return 0;
+	case DRM_V3D_PARAM_MAX_PERF_COUNTERS:
+		args->value = v3d->max_counters;
+		return 0;
 	default:
 		DRM_DEBUG("Unknown parameter %d\n", args->param);
 		return -EINVAL;
include/uapi/drm/v3d_drm.h +1 -0
index dce1835eced4..215b01bb69c3 100644
@@ -286,6 +286,7 @@ enum drm_v3d_param {
 	DRM_V3D_PARAM_SUPPORTS_PERFMON,
 	DRM_V3D_PARAM_SUPPORTS_MULTISYNC_EXT,
 	DRM_V3D_PARAM_SUPPORTS_CPU_QUEUE,
+	DRM_V3D_PARAM_MAX_PERF_COUNTERS,
 };
 
 struct drm_v3d_get_param {
Signature · 1 line
2.44.0
author maintainer
#4 lore raw

PATCH v2 4/6 drm/v3d: Create new IOCTL to expose performance counters information

In reply to Maíra Canal

Userspace usually needs some information about the performance counters available. Although we could replicate this information in the kernel and user-space, let's use the kernel as the "single source of truth" to avoid issues in the future (e.g. list of performance counters is updated in user-space, but not in the kernel, generating invalid requests).

Therefore, create a new IOCTL to expose the performance counters information, that is name, category, and description.

---
 drivers/gpu/drm/v3d/v3d_drv.c     |  1 +
 drivers/gpu/drm/v3d/v3d_drv.h     |  2 ++
 drivers/gpu/drm/v3d/v3d_perfmon.c | 33 +++++++++++++++++++++++++++
 include/uapi/drm/v3d_drm.h        | 37 +++++++++++++++++++++++++++++++
 4 files changed, 73 insertions(+)
drivers/gpu/drm/v3d/v3d_drv.c +1 -0
index d2c1d5053132..f7477488b1cc 100644
@@ -211,6 +211,7 @@ static const struct drm_ioctl_desc v3d_drm_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(V3D_PERFMON_DESTROY, v3d_perfmon_destroy_ioctl, DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(V3D_PERFMON_GET_VALUES, v3d_perfmon_get_values_ioctl, DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(V3D_SUBMIT_CPU, v3d_submit_cpu_ioctl, DRM_RENDER_ALLOW | DRM_AUTH),
+	DRM_IOCTL_DEF_DRV(V3D_PERFMON_GET_COUNTER, v3d_perfmon_get_counter_ioctl, DRM_RENDER_ALLOW),
 };
 
 static const struct drm_driver v3d_drm_driver = {
drivers/gpu/drm/v3d/v3d_drv.h +2 -0
index bd1e38f7d10a..44cfddedebde 100644
@@ -582,6 +582,8 @@ int v3d_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
 			      struct drm_file *file_priv);
 int v3d_perfmon_get_values_ioctl(struct drm_device *dev, void *data,
 				 struct drm_file *file_priv);
+int v3d_perfmon_get_counter_ioctl(struct drm_device *dev, void *data,
+				  struct drm_file *file_priv);
 
 /* v3d_sysfs.c */
 int v3d_sysfs_init(struct device *dev);
drivers/gpu/drm/v3d/v3d_perfmon.c +33 -0
index f268d9466c0f..73e2bb8bdb7f 100644
@@ -217,3 +217,36 @@ int v3d_perfmon_get_values_ioctl(struct drm_device *dev, void *data,
 
 	return ret;
 }
+
+int v3d_perfmon_get_counter_ioctl(struct drm_device *dev, void *data,
+				  struct drm_file *file_priv)
+{
+	struct drm_v3d_perfmon_get_counter *req = data;
+	struct v3d_dev *v3d = to_v3d_dev(dev);
+	const struct v3d_perf_counter_desc *counter;
+
+	for (int i = 0; i < ARRAY_SIZE(req->reserved); i++) {
+		if (req->reserved[i] != 0)
+			return -EINVAL;
+	}
+
+	/* Make sure that the counter ID is valid */
+	if (req->counter >= v3d->max_counters)
+		return -EINVAL;
+
+	if (v3d->ver >= 71) {
+		WARN_ON(v3d->max_counters != ARRAY_SIZE(v3d_v71_performance_counters));
+		counter = &v3d_v71_performance_counters[req->counter];
+	} else if (v3d->ver >= 42) {
+		WARN_ON(v3d->max_counters != ARRAY_SIZE(v3d_v42_performance_counters));
+		counter = &v3d_v42_performance_counters[req->counter];
+	} else {
+		return -EOPNOTSUPP;
+	}
+
+	strscpy(req->name, counter->name, sizeof(req->name));
+	strscpy(req->category, counter->category, sizeof(req->category));
+	strscpy(req->description, counter->description, sizeof(req->description));
+
+	return 0;
+}
include/uapi/drm/v3d_drm.h +37 -0
index 215b01bb69c3..0860ddb3d0b6 100644
@@ -42,6 +42,7 @@ extern "C" {
 #define DRM_V3D_PERFMON_DESTROY                   0x09
 #define DRM_V3D_PERFMON_GET_VALUES                0x0a
 #define DRM_V3D_SUBMIT_CPU                        0x0b
+#define DRM_V3D_PERFMON_GET_COUNTER               0x0c
 
 #define DRM_IOCTL_V3D_SUBMIT_CL           DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_SUBMIT_CL, struct drm_v3d_submit_cl)
 #define DRM_IOCTL_V3D_WAIT_BO             DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_WAIT_BO, struct drm_v3d_wait_bo)
@@ -58,6 +59,8 @@ extern "C" {
 #define DRM_IOCTL_V3D_PERFMON_GET_VALUES  DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_PERFMON_GET_VALUES, \
 						   struct drm_v3d_perfmon_get_values)
 #define DRM_IOCTL_V3D_SUBMIT_CPU          DRM_IOW(DRM_COMMAND_BASE + DRM_V3D_SUBMIT_CPU, struct drm_v3d_submit_cpu)
+#define DRM_IOCTL_V3D_PERFMON_GET_COUNTER DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_PERFMON_GET_COUNTER, \
+						   struct drm_v3d_perfmon_get_counter)
 
 #define DRM_V3D_SUBMIT_CL_FLUSH_CACHE             0x01
 #define DRM_V3D_SUBMIT_EXTENSION		  0x02
@@ -718,6 +721,40 @@ struct drm_v3d_perfmon_get_values {
 	__u64 values_ptr;
 };
 
+#define DRM_V3D_PERFCNT_MAX_NAME 64
+#define DRM_V3D_PERFCNT_MAX_CATEGORY 32
+#define DRM_V3D_PERFCNT_MAX_DESCRIPTION 256
+
+/**
+ * struct drm_v3d_perfmon_get_counter - ioctl to get the description of a
+ * performance counter
+ *
+ * As userspace needs to retrieve information about the performance counters
+ * available, this IOCTL allows users to get information about a performance
+ * counter (name, category and description).
+ */
+struct drm_v3d_perfmon_get_counter {
+	/*
+	 * Counter ID
+	 *
+	 * Must be smaller than the maximum number of performance counters, which
+	 * can be retrieve through DRM_V3D_PARAM_MAX_PERF_COUNTERS.
+	 */
+	__u8 counter;
+
+	/* Name of the counter */
+	__u8 name[DRM_V3D_PERFCNT_MAX_NAME];
+
+	/* Category of the counter */
+	__u8 category[DRM_V3D_PERFCNT_MAX_CATEGORY];
+
+	/* Description of the counter */
+	__u8 description[DRM_V3D_PERFCNT_MAX_DESCRIPTION];
+
+	/* mbz */
+	__u8 reserved[7];
+};
+
 #if defined(__cplusplus)
 }
 #endif
Signature · 1 line
2.44.0
author maintainer
#5 lore raw

PATCH v2 5/6 drm/v3d: Use V3D_MAX_COUNTERS instead of V3D_PERFCNT_NUM

In reply to Maíra Canal

V3D_PERFCNT_NUM represents the maximum number of performance counters for V3D 4.2, but not for V3D 7.1. This means that, if we use V3D_PERFCNT_NUM, we might go out-of-bounds on V3D 7.1.

Therefore, use the number of performance counters on V3D 7.1 as the maximum number of counters. This will allow us to create arrays on the stack with reasonable size. Note that userspace must use the value provided by DRM_V3D_PARAM_MAX_PERF_COUNTERS.

---
 drivers/gpu/drm/v3d/v3d_drv.h   | 5 ++++-
 drivers/gpu/drm/v3d/v3d_sched.c | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/v3d/v3d_drv.h +4 -1
index 44cfddedebde..556cbb400ba0 100644
@@ -351,8 +351,11 @@ struct v3d_timestamp_query {
 	struct drm_syncobj *syncobj;
 };
 
+/* Maximum number of performance counters supported by any version of V3D */
+#define V3D_MAX_COUNTERS ARRAY_SIZE(v3d_v71_performance_counters)
+
 /* Number of perfmons required to handle all supported performance counters */
-#define V3D_MAX_PERFMONS DIV_ROUND_UP(V3D_PERFCNT_NUM, \
+#define V3D_MAX_PERFMONS DIV_ROUND_UP(V3D_MAX_COUNTERS, \
 				      DRM_V3D_MAX_PERF_COUNTERS)
 
 struct v3d_performance_query {
drivers/gpu/drm/v3d/v3d_sched.c +1 -1
index 7cd8c335cd9b..03df37a3acf5 100644
@@ -490,7 +490,7 @@ v3d_write_performance_query_result(struct v3d_cpu_job *job, void *data, u32 quer
 	struct v3d_file_priv *v3d_priv = job->base.file->driver_priv;
 	struct v3d_dev *v3d = job->base.v3d;
 	struct v3d_perfmon *perfmon;
-	u64 counter_values[V3D_PERFCNT_NUM];
+	u64 counter_values[V3D_MAX_COUNTERS];
 
 	for (int i = 0; i < performance_query->nperfmons; i++) {
 		perfmon = v3d_perfmon_find(v3d_priv,
Signature · 1 line
2.44.0
author maintainer
#6 lore raw

PATCH v2 6/6 drm/v3d: Deprecate the use of the Performance Counters enum

In reply to Maíra Canal

The Performance Counters enum used to identify the index of each performance counter and provide the total number of performance counters (V3D_PERFCNT_NUM). But, this enum is only valid for V3D 4.2, not for V3D 7.1.

As we implemented a new flexible structure to retrieve performance counters information, we can deprecate this enum.

---
 include/uapi/drm/v3d_drm.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
include/uapi/drm/v3d_drm.h +10 -0
index 0860ddb3d0b6..87fc5bb0a61e 100644
@@ -603,6 +603,16 @@ struct drm_v3d_submit_cpu {
 	__u64 extensions;
 };
 
+/* The performance counters index represented by this enum are deprecated and
+ * must no longer be used. These counters are only valid for V3D 4.2.
+ *
+ * In order to check for performance counter information,
+ * use DRM_IOCTL_V3D_PERFMON_GET_COUNTER.
+ *
+ * Don't use V3D_PERFCNT_NUM to retrieve the maximum number of performance
+ * counters. You should use DRM_IOCTL_V3D_GET_PARAM with the following
+ * parameter: DRM_V3D_PARAM_MAX_PERF_COUNTERS.
+ */
 enum {
 	V3D_PERFCNT_FEP_VALID_PRIMTS_NO_PIXELS,
 	V3D_PERFCNT_FEP_VALID_PRIMS,
Signature · 1 line
2.44.0
author maintainer Applied
#7 lore raw
In reply to Maíra Canal

On 5/12/24 19:23, Maíra Canal wrote:>

Quoted 7 lines

Maíra Canal (6):
drm/v3d: Add Performance Counters descriptions for V3D 4.2 and 7.1 drm/v3d: Different V3D versions can have different number of perfcnt drm/v3d: Create a new V3D parameter for the maximum number of perfcnt drm/v3d: Create new IOCTL to expose performance counters information drm/v3d: Use V3D_MAX_COUNTERS instead of V3D_PERFCNT_NUM drm/v3d: Deprecate the use of the Performance Counters enum >

Quoted 9 lines
  drivers/gpu/drm/v3d/v3d_drv.c                 |  11 +
  drivers/gpu/drm/v3d/v3d_drv.h                 |  14 +-
  drivers/gpu/drm/v3d/v3d_perfmon.c             |  36 ++-
  .../gpu/drm/v3d/v3d_performance_counters.h    | 208 ++++++++++++++++++
  drivers/gpu/drm/v3d/v3d_sched.c               |   2 +-
  include/uapi/drm/v3d_drm.h                    |  48 ++++
  6 files changed, 316 insertions(+), 3 deletions(-)

create mode 100644 drivers/gpu/drm/v3d/v3d_performance_counters.h

Applied to drm-misc/drm-misc-next!

Best Regards,
- Maíra

#8 lore raw
Quoted 18 lines · Maíra Canal

On 5/12/24 19:23, Maíra Canal wrote:>

Quoted 7 lines

Maíra Canal (6):
drm/v3d: Add Performance Counters descriptions for V3D 4.2 and 7.1 drm/v3d: Different V3D versions can have different number of perfcnt drm/v3d: Create a new V3D parameter for the maximum number of perfcnt drm/v3d: Create new IOCTL to expose performance counters information drm/v3d: Use V3D_MAX_COUNTERS instead of V3D_PERFCNT_NUM drm/v3d: Deprecate the use of the Performance Counters enum >

Quoted 9 lines
  drivers/gpu/drm/v3d/v3d_drv.c                 |  11 +
  drivers/gpu/drm/v3d/v3d_drv.h                 |  14 +-
  drivers/gpu/drm/v3d/v3d_perfmon.c             |  36 ++-
  .../gpu/drm/v3d/v3d_performance_counters.h    | 208 ++++++++++++++++++
  drivers/gpu/drm/v3d/v3d_sched.c               |   2 +-
  include/uapi/drm/v3d_drm.h                    |  48 ++++
  6 files changed, 316 insertions(+), 3 deletions(-)

create mode 100644 drivers/gpu/drm/v3d/v3d_performance_counters.h

Quoted 1 line

Applied to drm-misc/drm-misc-next!

What compiler do you use? I'm hitting the same as kernel test robot [1] with arm-linux-gnueabihf-gcc 12.2.0.

In general, I don't think it's a great idea to put arrays in headers, and then include it everywhere via v3d_drv.h. You're not just relying on the compiler to optimize it away in compilation units where its not referenced (likely to happen), but also for the linker to deduplicate rodata (possible, but I'm not sure that it will happen).

I think you need to move the arrays to a .c file, and then either a) add interfaces to access the arrays, or b) declare the arrays and make them global. For the latter you also need to figure out how to expose the size.

BR,
Jani.

[1] https://lore.kernel.org/r/[email protected]

Signature · 1 line
Jani Nikula, Intel
author maintainer
#9 lore raw

Hi Jani,

Quoted 19 lines · Jani Nikula
Quoted 18 lines · Maíra Canal

On 5/12/24 19:23, Maíra Canal wrote:>

Quoted 16 lines

Maíra Canal (6):
drm/v3d: Add Performance Counters descriptions for V3D 4.2 and 7.1 drm/v3d: Different V3D versions can have different number of perfcnt drm/v3d: Create a new V3D parameter for the maximum number of perfcnt drm/v3d: Create new IOCTL to expose performance counters information drm/v3d: Use V3D_MAX_COUNTERS instead of V3D_PERFCNT_NUM drm/v3d: Deprecate the use of the Performance Counters enum >

   drivers/gpu/drm/v3d/v3d_drv.c                 |  11 +
   drivers/gpu/drm/v3d/v3d_drv.h                 |  14 +-
   drivers/gpu/drm/v3d/v3d_perfmon.c             |  36 ++-
   .../gpu/drm/v3d/v3d_performance_counters.h    | 208 ++++++++++++++++++
   drivers/gpu/drm/v3d/v3d_sched.c               |   2 +-
   include/uapi/drm/v3d_drm.h                    |  48 ++++
   6 files changed, 316 insertions(+), 3 deletions(-)

create mode 100644 drivers/gpu/drm/v3d/v3d_performance_counters.h

Quoted 4 lines
Quoted 1 line

Applied to drm-misc/drm-misc-next!

What compiler do you use? I'm hitting the same as kernel test robot [1] with arm-linux-gnueabihf-gcc 12.2.0.

I use clang version 17.0.6.

Quoted 11 lines

In general, I don't think it's a great idea to put arrays in headers, and then include it everywhere via v3d_drv.h. You're not just relying on the compiler to optimize it away in compilation units where its not referenced (likely to happen), but also for the linker to deduplicate rodata (possible, but I'm not sure that it will happen).

I think you need to move the arrays to a .c file, and then either a) add interfaces to access the arrays, or b) declare the arrays and make them global. For the latter you also need to figure out how to expose the size.

I'll write a patch to fix it. Sorry for the disturbance, I didn't notice it with clang.

Best Regards,
- Maíra

Quoted 8 lines

BR,
Jani.

[1] https://lore.kernel.org/r/[email protected]

#10 lore raw
Quoted 36 lines · Maíra Canal

Hi Jani,

Quoted 19 lines · Jani Nikula
Quoted 18 lines · Maíra Canal

On 5/12/24 19:23, Maíra Canal wrote:>

Quoted 16 lines

Maíra Canal (6):
drm/v3d: Add Performance Counters descriptions for V3D 4.2 and 7.1 drm/v3d: Different V3D versions can have different number of perfcnt drm/v3d: Create a new V3D parameter for the maximum number of perfcnt drm/v3d: Create new IOCTL to expose performance counters information drm/v3d: Use V3D_MAX_COUNTERS instead of V3D_PERFCNT_NUM drm/v3d: Deprecate the use of the Performance Counters enum >

   drivers/gpu/drm/v3d/v3d_drv.c                 |  11 +
   drivers/gpu/drm/v3d/v3d_drv.h                 |  14 +-
   drivers/gpu/drm/v3d/v3d_perfmon.c             |  36 ++-
   .../gpu/drm/v3d/v3d_performance_counters.h    | 208 ++++++++++++++++++
   drivers/gpu/drm/v3d/v3d_sched.c               |   2 +-
   include/uapi/drm/v3d_drm.h                    |  48 ++++
   6 files changed, 316 insertions(+), 3 deletions(-)

create mode 100644 drivers/gpu/drm/v3d/v3d_performance_counters.h

Quoted 4 lines
Quoted 1 line

Applied to drm-misc/drm-misc-next!

What compiler do you use? I'm hitting the same as kernel test robot [1] with arm-linux-gnueabihf-gcc 12.2.0.

I use clang version 17.0.6.

Quoted 7 lines

In general, I don't think it's a great idea to put arrays in headers, and then include it everywhere via v3d_drv.h. You're not just relying on the compiler to optimize it away in compilation units where its not referenced (likely to happen), but also for the linker to deduplicate rodata (possible, but I'm not sure that it will happen).

Quoted 7 lines
Quoted 4 lines

I think you need to move the arrays to a .c file, and then either a) add interfaces to access the arrays, or b) declare the arrays and make them global. For the latter you also need to figure out how to expose the size.

I'll write a patch to fix it. Sorry for the disturbance, I didn't notice it with clang.

Another report [1].

BR,
Jani.

[1] https://lore.kernel.org/all/[email protected]

Signature · 1 line
Jani Nikula, Intel