Commit Graph

20 Commits

Author SHA1 Message Date
Alex Waterman
3c37701377 gpu: nvgpu: Split VIDMEM support from mm_gk20a.c
Split VIDMEM support into its own code files organized as such:

  common/mm/vidmem.c     - Base vidmem support
  common/linux/vidmem.c  - Linux specific user-space interaction
  include/nvgpu/vidmem.h - Vidmem API definitions

Also use the config to enable/disable VIDMEM support in the makefile
and remove as many CONFIG_GK20A_VIDMEM preprocessor checks as possible
from the source code.

And lastly update a while-loop that iterated over an SGT to use the
new for_each construct for iterating over SGTs.

Currently this organization is not perfectly adhered to. More patches
will fix that.

JIRA NVGPU-30
JIRA NVGPU-138

Change-Id: Ic0f4d2cf38b65849c7dc350a69b175421477069c
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1540705
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-10-10 08:01:04 -07:00
Alex Waterman
9d97af9e9f gpu: nvgpu: Return -EINVAL for bad l2 flush args
When the L2 flush IOCTL gets no l2 flush and no fb flush we now
return -EINVAL. This can sometimes happen if the user tries to just
invalidate. Currently we do not support L2 invalidates only.

Bug 1661242

Change-Id: I87f3259bfbd736b5f4222cfe7b3cfa4a6475389e
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1227125
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-10-04 01:51:11 -07:00
Terje Bergstrom
c37c9baae6 gpu: nvgpu: Move CDE code to Linux module
CDE is only used in Linux platforms, and the code is highly dependent
on Linux APIs. Move the common CDE code to Linux module and leave only
the chip specific parts to HAL.

Change-Id: I507fe7eceaf7607303dfdddcf438449a5f582ea7
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1554755
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-09-11 15:10:52 -07:00
Konsta Holtta
17451138cf gpu: nvgpu: hold ch ref when getting ch from fd
Fix a race condition in gk20a_get_channel_from_file() that returns a
channel pointer from an fd: take a reference to the channel before
putting the file ref back. Now the caller is responsible of releasing
the channel reference eventually.

Also document why dbg_session_channel_data has to hold a ref to the
channel file instead of just the channel: that might deadlock if the fds
were closed in "wrong" order.

Change-Id: I8e91b809f5f7b1cb0c1487bd955ad6d643727a53
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1549290
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-09-11 10:34:57 -07:00
Terje Bergstrom
bab823973b gpu: nvgpu: Use accessor for finding struct device
Use dev_from_gk20a() accessor whenever accessing struct device * from
struct gk20a.

JIRA NVGPU-38

Change-Id: Ide9fca3a56436c8f62e7872580a766c4c1e2353e
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: https://git-master/r/1507930
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
2017-06-30 18:34:59 -07:00
Terje Bergstrom
92c43deefc gpu: nvgpu: Remove Linux devnode fields from gk20a
Move Linux devnode related fields to a new header file os_linux.h.

The class structure is defined in module.c, so move its declaration
to module.h.

JIRA NVGPU-38

Change-Id: I5d8920169064f4289ff61004f7f81543a9aba221
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1505927
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-06-21 17:34:49 -07:00
Terje Bergstrom
84703739a5 gpu: nvgpu: Move time correlation to common code
Time correlation does not have chip or OS specific dependencies, so
move it to generic new source file bus.c.

JIRA NVGPU-38

Change-Id: Ic7fdf8c9ccacf05baf1b3438a86b28e517093641
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1505171
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-06-20 11:35:17 -07:00
Thomas Fleury
741e5c4517 gpu: nvgpu: hal for timestamps correlation
In order to perform timestamps correlation for FECS
traces, we need to collect GPU / GPU timestamps
samples. In virtualization case, it is possible for
a guest to get GPU timestamps by using read_ptimer.
However, if the CPU timestamp is read on guest side,
and the GPU timestamp is read on vm-server side,
then it introduces some latency that will create an
artificial offset for GPU timestamps (~2 us in
average). For better CPU / GPU timestamps correlation,
Added a command to collect all timestamps on vm-server
side.

Bug 1900475

Change-Id: Idfdc6ae4c16c501dc5e00053a5b75932c55148d6
Signed-off-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-on: http://git-master/r/1472447
(cherry picked from commit 56f56b5cd9)
Reviewed-on: http://git-master/r/1489183
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-06-15 11:53:10 -07:00
Seema Khowala
3c3c39dfe0 gpu: nvgpu: add prints for ioctl numbers
ioctl function name and number are printed if
gk20a_dbg_fn is enabled. This is good to have for
debugging.

Change-Id: I4d0f99affaba493a4c586559d699f86174e4c64d
Signed-off-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-on: http://git-master/r/1498750
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-06-14 15:24:56 -07:00
Stephen Warren
2e338c77ea gpu: nvgpu: remove duplicate \n from log messages
nvgpu_log/info/warn/err() internally add a \n to the end of the message.
Hence, callers should not include a \n at the end of the message. Doing
so results in duplicate \n being printed, which ends up creating empty
log messages. Remove the duplicate \n from all err/warn messages.

Bug 1928311

Change-Id: I99362c5327f36146f28ba63d4e68181589735c39
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-on: http://git-master/r/1487232
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-05-26 03:34:30 -07:00
Terje Bergstrom
b7fca01b0e gpu: nvgpu: Scrub gk20a_platform dependencies
Remove gk20a_platform dependencies from gk20a.h. This makes
gk20a_platform a Linux platform specific data structure. Add #include
for platform_gk20a.h in the source files that still depend on Linux.

JIRA NVGPU-16

Change-Id: Ib098accd34a1f5066eb8680c387f9b178169f3f0
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1463547
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-05-18 15:14:31 -07:00
David Nieto
4580763b46 gpu: nvgpu: fix K4.9 sparse messages
Fix issues related with wrong storage type for
64 bit variables.

(1) Fixed width of HZ_TO_MHZ constant
(2) changed fence_wait timeout to store unsigned
long

bug 200299572

Change-Id: Ie8f2386b738f3aafce75fc2440947e36befac273
Signed-off-by: David Nieto <dmartineznie@nvidia.com>
Reviewed-on: http://git-master/r/1471611
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2017-04-28 13:44:12 -07:00
Terje Bergstrom
b3e1ce04b9 gpu: nvgpu: Put debugfs dependencies inside #ifdef
Put all debugfs dependencies inside #ifdef CONFIG_DEBUG_FS. This
includes some functions in allocators that were used only for
debugging.

Remove include of linux/debugfs.h on files that do not deal with
debugfs.

linux/debugfs.h implicitly included linux/fs.h, which we relied on.
Add explicit include of linux/fs.h for all files where this is the
case.

Change-Id: I16feffae6b0e3a2edf366075cdc01ade86be06f9
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1467897
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
2017-04-24 11:05:17 -07:00
Konsta Holtta
afe12a49f7 gpu: nvgpu: add missing busy calls for ctrl ioctls
The following ioctls:

- NVGPU_GPU_IOCTL_WAIT_FOR_PAUSE
- NVGPU_GPU_IOCTL_RESUME_FROM_PAUSE
- NVGPU_GPU_IOCTL_TRIGGER_SUSPEND
- NVGPU_GPU_IOCTL_CLEAR_SM_ERRORS

access hardware registers, so they should make sure that the gpu is
powered on first. Add gk20a_{busy,idle}() pairs for them.

Bug 1849661

Change-Id: I7deabf4a2c1c7d069a6134233f8e86df0a2722c8
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: http://git-master/r/1461449
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-04-19 12:15:56 -07:00
Terje Bergstrom
a0fa2b0258 gpu: nvgpu: Add wrapper nvgpu/bug.h
Add wrapper header file nvgpu/bug.h. It #includes <linux/bug.h>
in Linux.

JIRA NVGPU-13

Change-Id: I7bf02ba554333f7cbd79d72bd1cb423c81ebcb49
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1461545
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-04-13 08:56:06 -07:00
Terje Bergstrom
7665421874 gpu: nvgpu: Replace use of bitops.h and kernel.h
Remove use of linux/kernel.h and linux/compiler.h. We don't use
anything in those headers.

Also replace use of linux/bitops.h with new wrapper nvgpu/bitops.h.

JIRA NVGPU-13

Change-Id: Iefa6b4598d5a5e7fc386c0a7a554e778a87010d6
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1460777
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
2017-04-12 07:01:12 -07:00
Terje Bergstrom
3ba374a5d9 gpu: nvgpu: gk20a: Use new error macro
gk20a_err() and gk20a_warn() require a struct device pointer,
which is not portable across operating systems. The new nvgpu_err()
and nvgpu_warn() macros take struct gk20a pointer. Convert code
to use the more portable macros.

JIRA NVGPU-16

Change-Id: Ia51f36d94c5ce57a5a0ab83b3c83a6bce09e2d5c
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1331694
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
2017-04-10 19:04:19 -07:00
Terje Bergstrom
06fe28567d gpu: nvgpu: Move TSG IOCTL code to Linux module
Move TSG IOCTL specific code to Linux module. This clears most
Linux dependencies from tsg_gk20a.c.

Move also remaining file_operations declarations from channel_gk20a.h
to ioctl_channel.h.

JIRA NVGPU-32

Change-Id: Idcc2a525ebe12b30db46c3893a2735509c41ff39
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1330805
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-04-04 10:24:49 -07:00
Terje Bergstrom
1e355ca52e gpu: nvgpu: Split as code to as IOCTL and common
Split as_gk20a.c into two parts:

common/linux/ioctl_as.c deals with as related devnodes and ioctls.
This file contains all the Linux specific parts of as_gk20a.c.

common/as.c deals with general as_gk20a maintenance and is Linux
independent.

JIRA NVGPU-16

Change-Id: I2d8541e0bd6ce159dc6e4de8e819dfcff0fa8f80
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1330803
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
2017-04-02 08:28:22 -07:00
Terje Bergstrom
660c9a9510 gpu: nvgpu: Move ctrl IOCTL creation to Linux module
Move all code related to ctrl devnode to under Linux module.

JIRA NVGPU-16

Change-Id: I834b46ec4172076d7bde459168f1e6bc8c5d6c0c
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1330802
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
2017-04-02 08:28:22 -07:00