Commit Graph

13 Commits

Author SHA1 Message Date
Alex Waterman
22ffbaf6f9 gpu: nvgpu: Fix coverity defect in page allocator
Fix use-after-free overity defect in page allocator. The alloc struct
was getting used after a call for __gk20a_free_pages() which frees
the alloc struct passed in.

Coverity ID: 468942
Bug 200192125

Change-Id: I4f5d32f245efae967050f93c7806290b4bf3591c
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1272730
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-12-20 16:46:33 -08:00
Terje Bergstrom
d29afd2c9e gpu: nvgpu: Fix signed comparison bugs
Fix small problems related to signed versus unsigned comparisons
throughout the driver. Bump up the warning level to prevent such
problems from occuring in future.

Change-Id: I8ff5efb419f664e8a2aedadd6515ae4d18502ae0
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1252068
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2016-11-16 21:35:36 -08:00
Terje Bergstrom
9c8a3df142 gpu: nvgpu: Do not access alloc after freeing it
Move debug write so that we access length and base of allocation
before the alloc structure gets freed.

Change-Id: I02e418f423beaa2b52a32d1abcff327b68dd5fa6
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1249959
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
2016-11-11 08:20:23 -08:00
Alex Waterman
2fa54c94a6 gpu: nvgpu: Remove global debugfs variable
Remove a global debugfs variable and instead save the allocator
debugfs root node in the gk20a struct.

Bug 1799159

Change-Id: If4eed34fa24775e962001e34840b334658f2321c
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1225611
(cherry picked from commit 1908fde10bb1fb60ce898ea329f5a441a3e4297a)
Reviewed-on: http://git-master/r/1242390
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-10-26 11:10:01 -07:00
Konsta Holtta
f5ed470794 gpu: nvgpu: fix page alloc slab error condition
Return NULL instead of ERR_PTR from __gk20a_alloc_slab to be consistent
with __gk20a_alloc_pages, and thus to work with an error check in
gk20a_page_alloc in out-of-memory conditions.

Bug 1799159
JIRA DNVGPU-100

Change-Id: I8c3c0e121840758c6aba860baac86a38e873e359
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: http://git-master/r/1227730
(cherry picked from commit 209927a6b3bae4fddc2a6a745c1b4b1f46c6675c)
Reviewed-on: http://git-master/r/1235192
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Tested-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-10-20 10:44:41 -07:00
Alex Waterman
1cb6d159e2 gpu: nvgpu: Fix coverity problem
Coverity detected a possible overflow during the left shift.
This is likely not a big problem, though, since the number
of pages to allocate would have to be greater than 2^32
(that would be 4 TB of memory assuming 4k page size and the
literal 1 being a signed int by default).

Bug 1799159

Change-Id: Ie1d6522defd13c794eb95aeee8c5c4203db00ebf
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1238632
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-10-20 10:44:39 -07:00
Alex Waterman
ba3dbc452c gpu: nvgpu: Avoid 64 bit division
Avoid doing 64bit division in the page allocator. This causes problems
on 32 bit platforms.

Bug 1799159

Change-Id: I5166a71a4e84454686cce6d6cdca678a862a7ae7
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1236799
(cherry picked from commit 21c091d1c00433acb9965c3d348d16fbb4c50c1a)
Reviewed-on: http://git-master/r/1236195
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2016-10-18 12:24:41 -07:00
Alex Waterman
fc4f0ddddb gpu: nvgpu: SLAB allocation for page allocator
Add the ability to do "SLAB" allocation in the page allocator. This
is generally useful since the allocator manages 64K pages but often
we only need 4k chunks (for example when allocating memory for page
table entries).

Bug 1799159
JIRA DNVGPU-100

Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1225322
(cherry picked from commit 299a5639243e44be504391d9155b4ae17d914aa2)
Change-Id: Ib3a8558d40ba16bd3a413f4fd38b146beaa3c66b
Reviewed-on: http://git-master/r/1227924
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2016-10-18 12:24:33 -07:00
Konsta Holtta
4d07572c82 gpu: nvgpu: add space query in page and buddy allocs
Amount of free space in the buddy allocator is computed from the
complete capacity minus currently used bytes.

The page allocator just queries its underlying allocator.

Bug 1787771
Bug 200233138

Change-Id: I9b6f5ef90119236a13de14e14cd0a3ee72144a11
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: http://git-master/r/1223761
(cherry picked from commit 0b324a60ebdf67e793ade869c252a8ddd56c04f8)
Reviewed-on: http://git-master/r/1235979
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-10-14 08:12:27 -07:00
Alex Waterman
aa14efa2b4 gpu: nvgpu: Carveout support for the page allocator
Implement carveout support by just calling through to the buddy
allocator's carveout support.

Jira DNVGPU-84

Change-Id: I1940873394a4cbff0152f1b6c9c4fd659e0076e1
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1203392
(cherry picked from commit 499ee0407bf525e161a14cfb8bbbc101ac934329)
Reviewed-on: http://git-master/r/1223454
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-09-20 14:56:42 -07:00
Konsta Holtta
6029684eb0 gpu: nvgpu: fix chunk size mismatch in page allocator
When allocating discontiguous memory composed of several chunks,
update also the number of pages used by the current chunk, if a large
chunk was not available and a retry is performed with a smaller one.
Failing to do this would result in too few chunks reserved for a large
enough allocation in certain conditions.

Bug 1805067

Change-Id: I9d14864724d228b42c47eb4669fbe0f789334397
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: http://git-master/r/1214914
(cherry picked from commit 9bece931b13e4dad808622462d4d98d421cfb383)
Reviewed-on: http://git-master/r/1220546
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-09-14 14:13:40 -07:00
Deepak Nibade
50fec50bff gpu: nvgpu: fix memory leak in case of failure
In __gk20a_alloc_pages(), if we fail to allocate a chunk
we free previously allocated chunks in error path
But we do not free up the memory reserved in those chunks
which could lead to OOM situations

Fix this by calling gk20a_free() for each chunk in error
path

Jira DNVGPU-96

Change-Id: I68aa18d68a5282405016e688c790ccbc0c2a0d69
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1203098
(cherry picked from commit f096bd1675600f4e2fc2d686f2911bb945fbbf0b)
Reviewed-on: http://git-master/r/1210952
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-09-01 09:10:45 -07:00
Alex Waterman
448df6ed27 gpu: nvgpu: Implement a vidmem allocator
Implement an allocator suitable for managing the video memory on dGPUs.
It works by allocating chunks from an underlying buddy allocator and
collating the chunks together (similar to what an sgt does in the
wider Linux kernel). This handles the ability to get large buffers in
potentially fragmented memory. The GMMU can then obviously map the
physical vidmem into contiguous GVA spaces.

Jira DNVGPU-96

Change-Id: Ic1d7800b033a170b77790aa23fad6858443d0e89
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1197203
(cherry picked from commit fa44684a843956ae384fef6d7a79b9cbbd04f73e)
Reviewed-on: http://git-master/r/1185231
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-08-30 10:04:10 -07:00