summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/css_gr_gk20a.c
diff options
context:
space:
mode:
authorLeonid Moiseichuk <lmoiseichuk@nvidia.com>2015-06-02 09:36:43 -0400
committerTerje Bergstrom <tbergstrom@nvidia.com>2015-06-06 10:23:53 -0400
commitd5fd0689c23683c161128cf9b51077d3b8c1c2bc (patch)
tree60a7722a550c2bb41c17123e6f9c717ba119e786 /drivers/gpu/nvgpu/gk20a/css_gr_gk20a.c
parent837ceffcab417865db8adbdf1a2038ebde8ec1a5 (diff)
gpu: nvgpu: minor cleanups in cyclestats snapshots
There are two minor cleanups of cyclestats snapshots code implemented: 1. In case of unacceptably small buffer passed as a cyclestats snapshot it causes a kernel panic during list element removal: NvRmGpuTest_Channel_Cyclestats_Snapshot_Gen for 1 clients, each has 4 KB mappings and 1 perfmons [ 304.533073] Unable to handle kernel NULL .... address 00000008 [ 304.541825] pgd = ffffffc04fc9f000 [ 304.545277] [00000008] *pgd=0000000000000000 [ 304.549554] Internal error: Oops: 96000045 [#1] PREEMPT SMPa .... [ 304.584978] PC is at css_gr_free_client_data+0x28/0xe4 [ 304.590105] LR is at gr_gk20a_css_attach+0x6e0/0x700 2. Also fix with improved allocation of perfmon IDs implemented. Bug 1573150 Change-Id: I58b753434141bf573463563fdd699c11ea914943 Signed-off-by: Leonid Moiseichuk <lmoiseichuk@nvidia.com> Reviewed-on: http://git-master/r/751385 (cherry picked from commit e9314c29df3fb708a20fff58cfa64c2ead857b0f) Reviewed-on: http://git-master/r/753275 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/css_gr_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/css_gr_gk20a.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/css_gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/css_gr_gk20a.c
index 7509acd7..e8da54fb 100644
--- a/drivers/gpu/nvgpu/gk20a/css_gr_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/css_gr_gk20a.c
@@ -504,12 +504,17 @@ static u32 css_gr_allocate_perfmon_ids(struct gk20a_cs_snapshot *data,
504 if (!count || count > CSS_MAX_PERFMON_IDS - CSS_FIRST_PERFMON_ID) 504 if (!count || count > CSS_MAX_PERFMON_IDS - CSS_FIRST_PERFMON_ID)
505 return 0; 505 return 0;
506 506
507 for (f = CSS_FIRST_PERFMON_ID; f < e; f++) { 507 for (f = CSS_FIRST_PERFMON_ID; f <= e; f++) {
508 u32 slots = 0; 508 u32 slots;
509 u32 cur; 509 u32 cur;
510 u32 end = f + count; 510 u32 end;
511
512 if (CSS_PERFMON_GET(pids, f))
513 continue;
511 514
512 /* lookup for continuous hole [f, f+count) of unused bits */ 515 /* lookup for continuous hole [f, f+count) of unused bits */
516 slots = 0;
517 end = f + count;
513 for (cur = f; cur < end; cur++) { 518 for (cur = f; cur < end; cur++) {
514 if (CSS_PERFMON_GET(pids, cur)) 519 if (CSS_PERFMON_GET(pids, cur))
515 break; 520 break;
@@ -556,7 +561,9 @@ static int css_gr_free_client_data(struct gk20a_cs_snapshot *data,
556{ 561{
557 int ret = 0; 562 int ret = 0;
558 563
559 list_del(&client->list); 564 if (client->list.next && client->list.prev)
565 list_del(&client->list);
566
560 if (client->perfmon_start && client->perfmon_count) { 567 if (client->perfmon_start && client->perfmon_count) {
561 if (client->perfmon_count != css_gr_release_perfmon_ids(data, 568 if (client->perfmon_count != css_gr_release_perfmon_ids(data,
562 client->perfmon_start, client->perfmon_count)) 569 client->perfmon_start, client->perfmon_count))