#
37454bcb |
|
14-Sep-2023 |
Justin Stitt <justinstitt@google.com> |
drm/nouveau/pm: refactor deprecated strncpy `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` [2] due to the fact that it guarantees NUL-termination on the destination buffer without unnecessarily NUL-padding. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2] Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt <justinstitt@google.com> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Lyude Paul <lyude@redhat.com> Signed-off-by: Lyude Paul <lyude@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230914-strncpy-drivers-gpu-drm-nouveau-nvkm-engine-pm-base-c-v1-1-4b09ed453f84@google.com
|
#
e73d371a |
|
03-Dec-2020 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/pm: switch to instanced constructor Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Reviewed-by: Lyude Paul <lyude@redhat.com>
|
#
f8106922 |
|
02-Dec-2020 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/perfmon: use private spinlock to control exclusive access to perfmon nvkm_subdev.mutex is going away. Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Reviewed-by: Lyude Paul <lyude@redhat.com>
|
#
acafe7e3 |
|
08-May-2018 |
Kees Cook <keescook@chromium.org> |
treewide: Use struct_size() for kmalloc()-family One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct foo { int stuff; void *entry[]; }; instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL); Instead of leaving these open-coded and prone to type mistakes, we can now use the new struct_size() helper: instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL); This patch makes the changes for kmalloc()-family (and kvmalloc()-family) uses. It was done via automatic conversion with manual review for the "CHECKME" non-standard cases noted below, using the following Coccinelle script: // pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len * // sizeof *pkey_cache->table, GFP_KERNEL); @@ identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc"; expression GFP; identifier VAR, ELEMENT; expression COUNT; @@ - alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP) + alloc(struct_size(VAR, ELEMENT, COUNT), GFP) // mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL); @@ identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc"; expression GFP; identifier VAR, ELEMENT; expression COUNT; @@ - alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP) + alloc(struct_size(VAR, ELEMENT, COUNT), GFP) // Same pattern, but can't trivially locate the trailing element name, // or variable name. @@ identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc"; expression GFP; expression SOMETHING, COUNT, ELEMENT; @@ - alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP) + alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP) Signed-off-by: Kees Cook <keescook@chromium.org>
|
#
ee0d5810 |
|
04-Dec-2017 |
Arnd Bergmann <arnd@arndb.de> |
drm/nouveau: nouveau: use correct string length gcc-8 reports drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c: In function 'nvkm_perfmon_mthd': include/linux/string.h:265:9: error: '__builtin_strncpy' specified bound 64 equals destination size [-Werror=stringop-truncation] We need one less byte or call strlcpy() to make it a nul-terminated string. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
e08a1d97 |
|
23-Oct-2016 |
Baoyou Xie <baoyou.xie@linaro.org> |
drm/nouveau: mark symbols static where possible We get a few warnings when building kernel with W=1: drivers/gpu/drm/nouveau/nvkm/subdev/bios/fan.c:29:1: warning: no previous prototype for 'nvbios_fan_table' [-Wmissing-prototypes] drivers/gpu/drm/nouveau/nvkm/subdev/bios/fan.c:56:1: warning: no previous prototype for 'nvbios_fan_entry' [-Wmissing-prototypes] drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c:184:1: warning: no previous prototype for 'gt215_clk_info' [-Wmissing-prototypes] drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgt215.c:99:1: warning: no previous prototype for 'gt215_link_train_calc' [-Wmissing-prototypes] drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgt215.c:153:1: warning: no previous prototype for 'gt215_link_train' [-Wmissing-prototypes] drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgt215.c:271:1: warning: no previous prototype for 'gt215_link_train_init' [-Wmissing-prototypes] .... In fact, both functions are only used in the file in which they are declared and don't need a declaration, but can be made static. So this patch marks these functions with 'static'. Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
56d06fa2 |
|
08-Apr-2016 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/core: remove pmc_enable argument from subdev ctor These are now specified directly in the MC subdev. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
f01c4e68 |
|
08-Nov-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/nvif: modify nvif_unvers/nvif_unpack macros to be more obvious Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
75445a4d |
|
07-Nov-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/nvif: split out perfmon interface definitions Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
08f7633c |
|
07-Nov-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/nvif: move internal class identifiers to class.h Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
354a2249 |
|
11-Oct-2015 |
Julia Lawall <Julia.Lawall@lip6.fr> |
drm/nouveau/disp,pm: constify nvkm_object_func structures These nvkm_object_func structures are never modified. All other nvkm_object_func structures are declared as const. Done with the help of Coccinelle. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
97070f23 |
|
19-Aug-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/pm: convert to new-style nvkm_engine Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
5ffeb84b |
|
19-Aug-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/pm: convert user classes to new-style nvkm_object Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
2a9f847f |
|
19-Aug-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/device: convert user class to new-style nvkm_object Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
24bd0930 |
|
19-Aug-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/client: convert to new-style nvkm_object Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
6cf813fb |
|
19-Aug-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/device: prepare for new-style subdevs Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
89c651e2 |
|
19-Aug-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/engine: rename some functions to avoid upcoming conflicts Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
aa35888f |
|
19-Aug-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/object: rename some functions to avoid upcoming conflicts Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
a1e88736 |
|
19-Aug-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/device: decouple from engine machinery Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
53003941 |
|
19-Aug-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/core: remove last printks Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
476901ff |
|
19-Aug-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/pm: switch to subdev printk macros Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
846e831d |
|
19-Aug-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/pm: switch to device pri macros Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
8c1aeaa1 |
|
19-Aug-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/pm: cosmetic changes This is purely preparation for upcoming commits, there should be no code changes here. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
9ace404b |
|
19-Aug-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/device: include core/device.h automatically for subdevs/engines Pretty much every subdev/engine is going to need access to nvkm_device shortly to touch registers and/or output messages. The odd placement of the includes is necessary to work around some inter-dependencies that currently exist. This will be fixed later. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
7fe882eb |
|
04-Aug-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: allow zeroed signals to enable sources Hardware signals index 0x00 are defined for some domains and they have to be allowed to enable sources like the others. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
df0b37ee |
|
19-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: expose name of domains This is going to be very useful for GF100+ because each GPC can have its own domain of counters. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
d4a312dc |
|
14-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: some fixes related to sources Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
f21950ea |
|
13-Jun-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/pm: stack perfdom class under perfmon Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
2d4b94b9 |
|
13-Jun-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/pm: swap perfmon/perfdom code to avoid forward decl in next commit Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
6137b5a7 |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: allow the userspace to configure sources Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
0f380436 |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: allow to configure domains instead of simple counters Configuring counters from the userspace require the kernel to handle some logic related to performance counters. Basically, it has to find a free slot to assign a counter, to handle extra counting modes like B4/B6 and it must return and error when it can't configure a counter. In my opinion, the kernel should not handle all of that logic but it should only write the configuration sent by the userspace without checking anything. In other words, it should overwrite the configuration even if it's already counting and do not return any errors. This patch allows the userspace to configure a domain instead of separate counters. This has the advantage to move all of the logic to the userspace. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
3bfdde17 |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: allow the userspace to schedule hardware counters This adds a new method NVIF_PERFCTR_V0_INIT which starts a batch of hardware counters for sampling. This will allow the userspace to start a monitoring session using the INIT method and to stop it with SAMPLE, for example before and after a frame is rendered. This commit temporarily breaks nv_perfmon but this is going to be fixed with the upcoming patch. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
6f99c848 |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: implement NVIF_PERFMON_V0_QUERY_SOURCE method This allows to query the ID, the mask and the user-readable name of sources for each signal. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
50d138d7 |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: allow to query the number of sources for a signal Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
e82661e2 |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoisetœgmail.com> |
drm/nouveau/pm: add concept of sources A source (or multiplexer) is a tuple addr+mask+shift which allows to control a block of signals. The maximum number of sources that a signal can define is arbitrary limited to 8 and this should be large enough. This patch allows to define multi-level of sources for a signal. Each different sources are stored to a global list and will be exposed to the userspace through the nvif interface in order to avoid conflicts. Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
40a3b22c |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: allow to monitor hardware signal index 0x00 This signal index must be always allowed even if it's not clearly defined in a domain in order to monitor a counter like 0x03020100 because it's the default value of signals. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
10a4d2b2 |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: use hardware signals indexes instead of user-readable names Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
e4047599 |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: change signal iter to u16 16 bits is large enough to store the maximum number of signals available for one domain (i.e. 256). Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
3e1b3357 |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: allow to query signals by domain This will allow to configure performance counters with hardware signal indexes instead of user-readable names in an upcoming patch. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
45f0f94d |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: implement NVIF_PERFMON_V0_QUERY_DOMAIN method This allows to query the number of available domains, including the number of hardware counter and the number of signals per domain. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
44d9de58 |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: prevent creating a perfctr object when signals are not found Since a new class has been introduced to query signals, we can now return an error when the userspace wants to monitor unknown signals. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
5a0bc4b5 |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: reorganize the nvif interface This commit introduces the NVIF_IOCTL_NEW_V0_PERFMON class which will be used in order to query domains, signals and sources. This separates the querying and the counting interface. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
a78ce96f |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: remove unused nvkm_perfsig_wrap() function Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Martin Peres <martin.peres@free.fr> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
305c1959 |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: fix a potential race condition when creating an engine context There is always the possiblity that the ppm->context pointer would get partially updated and accidentally would equal ctx. This would allow two contexts to co-exist, which is not acceptable. Moving the test to the critical section takes care of this problem. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Martin Peres <martin.peres@free.fr> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
3693d544 |
|
07-Jun-2015 |
Samuel Pitoiset <samuel.pitoiset@gmail.com> |
drm/nouveau/pm: prevent freeing the wrong engine context This fixes a crash when multiple PM engine contexts are created. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Martin Peres <martin.peres@free.fr> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
4d34686e |
|
13-Jan-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/pm: namespace + nvidia gpu names (no binary change) The namespace of NVKM is being changed to nvkm_ instead of nouveau_, which will be used for the DRM part of the driver. This is being done in order to make it very clear as to what part of the driver a given symbol belongs to, and as a minor step towards splitting the DRM driver out to be able to stand on its own (for virt). Because there's already a large amount of churn here anyway, this is as good a time as any to also switch to NVIDIA's device and chipset naming to ease collaboration with them. A comparison of objdump disassemblies proves no code changes. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|
#
d5752b9b |
|
13-Jan-2015 |
Ben Skeggs <bskeggs@redhat.com> |
drm/nouveau/pm: rename from perfmon (no binary change) Switch to NVIDIA's name for the device. The namespace of NVKM is being changed to nvkm_ instead of nouveau_, which will be used for the DRM part of the driver. This is being done in order to make it very clear as to what part of the driver a given symbol belongs to, and as a minor step towards splitting the DRM driver out to be able to stand on its own (for virt). Because there's already a large amount of churn here anyway, this is as good a time as any to also switch to NVIDIA's device and chipset naming to ease collaboration with them. A comparison of objdump disassemblies proves no code changes. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
|