History log of /linux-master/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c
Revision Date Author Comments
# 939fcf7b 18-Sep-2023 Justin Stitt <justinstitt@google.com>

drm/etnaviv: Replace strncpy with strscpy_pad

`strncpy` is deprecated for use on NUL-terminated destination strings [1].

We should prefer more robust and less ambiguous string interfaces.

A suitable replacement is `strscpy_pad` due to the fact that it
guarantees NUL-termination on the destination buffer whilst maintaining
the NUL-padding behavior that strncpy provides.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Cc: Bo YU <tsu.yubo@gmail.com>
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com>
[lst: changed subject according to suggestion from Kees]
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# a5cafb90 14-Aug-2020 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: add pipe_select(..) helper

Replace the open coded pixel pipe selection pattern with a function.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# bbab2be7 14-Aug-2020 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: add total hi bandwidth perfcounter

These two perf counters represent the total read and write
GPU bandwidth in terms of 64bits.

The used sequence was taken from Vivante kernel driver.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# 658690d8 14-Aug-2020 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: call perf_reg_read(..)

Replace the open coded access pattern with a function call.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# 77dfb36a 14-Aug-2020 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: rename pipe_reg_read(..)

pipe_reg_read(..) iterates over all pixel pipes, selects a perf counter
register and sums the actual perf counter value. Rename the function
to reflect more what it is actual doing.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# 40b697e25 18-May-2020 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: fix perfmon domain interation

The GC860 has one GPU device which has a 2d and 3d core. In this case
we want to expose perfmon information for both cores.

The driver has one array which contains all possible perfmon domains
with some meta data - doms_meta. Here we can see that for the GC860
two elements of that array are relevant:

doms_3d: is at index 0 in the doms_meta array with 8 perfmon domains
doms_2d: is at index 1 in the doms_meta array with 1 perfmon domain

The userspace driver wants to get a list of all perfmon domains and
their perfmon signals. This is done by iterating over all domains and
their signals. If the userspace driver wants to access the domain with
id 8 the kernel driver fails and returns invalid data from doms_3d with
and invalid offset.

This results in:
Unable to handle kernel paging request at virtual address 00000000

On such a device it is not possible to use the userspace driver at all.

The fix for this off-by-one error is quite simple.

Reported-by: Paul Cercueil <paul@crapouillou.net>
Tested-by: Paul Cercueil <paul@crapouillou.net>
Fixes: ed1dd899baa3 ("drm/etnaviv: rework perfmon query infrastructure")
Cc: stable@vger.kernel.org
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# ed1dd899 28-Feb-2020 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: rework perfmon query infrastructure

Report the correct perfmon domains and signals depending
on the supported feature flags.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 9e2c2e273012 ("drm/etnaviv: add infrastructure to query perf counter")
Cc: stable@vger.kernel.org
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# 15ff4a7b 31-Jul-2019 Christian Gmeiner <christian.gmeiner@gmail.com>

etnaviv: perfmon: fix total and idle HI cyleces readout

As seen at CodeAurora's linux-imx git repo in imx_4.19.35_1.0.0 branch.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# 1b53591a 02-Aug-2019 Christian Gmeiner <christian.gmeiner@gmail.com>

etnaviv: fix whitespace errors

Changes in V2:
- use indentation as suggested by Philipp Zabel.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# f5fd9fd4 13-Jul-2018 Dan Carpenter <dan.carpenter@oracle.com>

drm/etnaviv: fix some off by one bugs

The ->nr_signal is the supposed to be the number of elements in the
->signal array. There was one place where it was 5 but it was supposed
to be 4. That looks like a copy and paste bug. There were also two
checks that were off by one.

Fixes: 9e2c2e273012 ("drm/etnaviv: add infrastructure to query perf counter")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Tested-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# f6ffbd4f 08-May-2018 Lucas Stach <l.stach@pengutronix.de>

drm/etnaviv: replace license text with SPDX tags

This replaces the repetitive GPL-2.0 license text in code and header files
with the SPDX tags. Generated hardware headers aren't changed, as any changes
there need to be done in the upstream rnndb repository.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>


# 7a9c0fe2 24-Nov-2017 Lucas Stach <l.stach@pengutronix.de>

drm/etnaviv: use submit exec_state for perfmon sampling

The GPU exec state may have changed at the time when the perfmon sampling
is done, as it reflects the state of the last submission, not the current
GPU execution state.

So for proper sampling we must use the submit exec_state.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# 49168ee9 24-Sep-2017 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: add MC perf domain

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# 9646025e 24-Sep-2017 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: add TX perf domain

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# 91a9a17b 24-Sep-2017 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: add RA perf domain

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# a515264c 24-Sep-2017 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: add SE perf domain

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# c3787ff6 24-Sep-2017 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: add PA perf domain

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# 98b2482e 24-Sep-2017 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: add SH perf domain

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# a3d0c390 24-Sep-2017 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: add PE perf domain

We need to iterate over all pixel pipelines to get overall value.

Changes from v4 -> v5:
- switch back to pixel pipe 0 to prevent GPU hang
- PIXELS_RENDERED_2D is exposed for 2D pipe

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# 33deff0a 24-Sep-2017 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: add HI perf domain

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# 249300c7 24-Sep-2017 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: add performance monitor request processing

Changes v4 -> v5
- make use of doms_meta array

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# 46df52cd 24-Sep-2017 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: add performance monitor request validation

Check if the selected domain and signal combination exists.

Changes from v4 to v5
- add exec_state parameter

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>


# 9e2c2e27 24-Sep-2017 Christian Gmeiner <christian.gmeiner@gmail.com>

drm/etnaviv: add infrastructure to query perf counter

Make it possible that userspace can query all performance domains and
its signals. This information is needed to sample those signals via
submit ioctl.

At the moment no performance domain is available.

Changes from v1 -> v2:
- use a 16 bit value for signals
- fix padding issues
- add id member to domain and signal struct

Changes v4 -> v5
- provide for each pipe an own set of pm domains

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>