Commit Graph

8040 Commits

Author SHA1 Message Date
shashank singh
3f65316312 gpu: nvgpu: add bitmask to fault injection
Some APIs(especially that created thread) are hard to test with current
fault injection logic. Introduce bitmask so that the fault injection can
be enabled at any arbitrary iteration.

Bug 200580790

Change-Id: I990ba442d2c1dbd9f44d565bd2ce0196f8653257
Signed-off-by: shashank singh <shashsingh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2268729
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Rajesh Devaraj <rdevaraj@nvidia.com>
Tested-by: Rajesh Devaraj <rdevaraj@nvidia.com>
Reviewed-by: Vaibhav Kachore <vkachore@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
shashank singh
4db949d5b5 gpu: nvgpu: serialize thread exceution to avoid fi races
For some code that is tested using public APIs it's not safe for the
parent thread to continue while the child thread is running. Fault
injection per thread pointer points to the same container for both
parent thread as well as the created one. So, there is chance of a race
in fault injection functionality. Serialize the run so that race can be
mitigated. Caller of nvgpu_thread_create() API should ensure that the
created thread is stopped using some fault injection or otherwise.

Bug 200580790

Change-Id: I334c07c4bac6e43d67de9bfc581dad021e421acd
Signed-off-by: shashank singh <shashsingh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2268133
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Rajesh Devaraj <rdevaraj@nvidia.com>
Tested-by: Rajesh Devaraj <rdevaraj@nvidia.com>
Reviewed-by: Vaibhav Kachore <vkachore@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
rmylavarapu
3dfd87c612 gpu: nvgpu: Refactor PERF Change_Seq unit
-Created ucode_perf_change_seq_inf.h and moved all
 change_seq interface structs and MACROs
-Moved nvgpu_clk_set_req_fll_clk_ps35 from clk unit
 to change_seq unit
-Removed MACROs and includes which are not needed

NVGPU-4448

Change-Id: I04ab32cbc9a1fc827f3360a8ea0f367019981823
Signed-off-by: rmylavarapu <rmylavarapu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2266051
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
rmylavarapu
983c15bca2 gpu: nvgpu: Refactor PERF Pstate unit
-Created ucode_perf_pstate_inf.h and moved all
 pstate interface structs and MACROs.
-Created nvgpu_perf_pstate_get_lpwr_index for getting
 lpwr index
-Created nvgpu_clk_domain_get_from_index for getting
 clk_domain from index
-Removed pstate_get_status code which is not needed
 for tu10a profile
-Removed MACROs and includes which are not needed

NVGPU-4448

Change-Id: I516816a1d92a60a91ea479cb9c334d332d3d7a89
Signed-off-by: rmylavarapu <rmylavarapu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2264716
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mahantesh Kumbar <mkumbar@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
rmylavarapu
8f154fb6eb gpu: nvgpu: Refactor PERF VFE unit
-Created ucode_perf_vfe_inf.h and moved all VFE
 interface structs and MACROs into this header
-Created nvgpu_clk_fll_get_fmargin_idx to get
 freq margin index
-Created nvgpu_vfe_var_get_s_param to read s_param
-Removed MACROs and header includes which are
 not needed

NVGPU-4448

Change-Id: I89f946d555bcbc7823665d2a5a761049f7a5e963
Signed-off-by: rmylavarapu <rmylavarapu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2260150
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mahantesh Kumbar <mkumbar@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Vedashree Vidwans
d0118c297e gpu: nvgpu: Whitelist MISRA 10.3 violations
MISRA rule 10.3 doesn't allow value of an expression to be assigned to a
narrower or different essential type object.
Currently, in nvgpu_do_assert() "false" value is recognized as "signed
8-bit int". And so passing value false to nvgpu_assert converts signed
8-bit int to boolean. This is a coverity bug acknowledged by Synopsys.
This patch adds whitelisting to nvgpu_do_assert() macro.

Bug 2623654
Bug 200510004
Jira NVGPU-4780

Change-Id: Ibe35b30c12e2575f45e25ef21741627957b4ea75
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2271448
GVS: Gerrit_Virtual_Submit
Reviewed-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-by: Adeel Raza <araza@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Deepak Nibade
fa90056392 gpu: nvgpu: unit: add unit test for gr idle hal
Add unit test coverage for HAL function g->ops.gr.init.wait_idle
exposed by common.gr.init subunit.

Jira NVGPU-4458

Change-Id: I66b24b335961dfaf9315b9fcd3a3df421b80a30a
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2274184
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Sagar Kamble
1513061fdd gpu: nvgpu: falcon: test and code updates for more branch coverage
Passing branch of nvgpu_timeout_peek_expired was not covered due to jump
over it in nvgpu_falcon_mem_scrub_wait. Remove that jump to cover the
branch.
Add unit test for covering the error handling in case of read from
DMEM control register returns invalid data using fault injection.

JIRA NVGPU-4814

Change-Id: I9f99186bd2b1c5f39ead130d3161d3e7fa622ac4
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2272937
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
tkudav
7774669a30 gpu: nvgpu: Add branch coverage for common.fbp
Add missing branch coverage for nvgpu_fbp_remove_support()
corresponding to g->fbp == NULL case.

JIRA NVGPU-4679

Change-Id: I2d8e97b0d35a5a6738dc649500e2172560fe121f
Signed-off-by: tkudav <tkudav@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2272934
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Philip Elcan
6800aa7c51 gpu: nvgpu: unit: add worker unit test
Add unit test for worker unit.

To get full coverage, a new fault injection is added for the thread API
nvgpu_thread_is_running to return true after a number of executions.

JIRA NVGPU-915

Change-Id: Ib631d4af7dac3dde37bed3b5de81f3164a6df1b0
Signed-off-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2265714
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Petlozu Pravareshwar
7a1b5c0d44 gpu: nvgpu: unit: update fault injection handler
Update fault injection handling for the following
mock API:
- NvTegraSysGetPlatform()

JIRA NVGPU-3909

Change-Id: I60b218d6e6786ba7b90a1cd1587e5856ad8a197a
Signed-off-by: Petlozu Pravareshwar <petlozup@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2262773
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Sagar Kamble
cdeaf09b2b gpu: nvgpu: falcon: whitelist MISRA 11.3 violations
Whitelist 2 MISRA Rule 11.3 violations in falcon that were approved as
deviations in TID-415. Check for alignment is added before casting the
u8 pointer to u32 pointer and unaligned source buffers are handled
byte by byte.

JIRA NVGPU-4812
JIRA TID-415

Change-Id: Ib7aaced0714029392c9d94468a74f11f182c9d74
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2272752
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vaibhav Kachore <vkachore@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Abdul Salam
052f15deb9 Revert "gpu: nvgpu: Refactor Clk, Volt sub-unit"
This reverts commit 919a08a13bb240354533da27b0335f50c0808e7a.

Bug 2797423

Change-Id: Iaa99b71f172ad5e40a63c57f7b5f8ee7dced57ca
Signed-off-by: Abdul Salam <absalam@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2272966
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Vedashree Vidwans
79c64d64be gpu: nvgpu: fix MISRA Directive 4.7 errors in MM
Directive 4.7 requires function returned error information to be tested
before returning the error. This patch prints error message if returned
value indicates error.

Jira NVGPU-4780

Change-Id: I9e461b94369a72fb695d05a9b6482c9b66ede55d
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2271509
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Vedashree Vidwans
399a8f3125 gpu: nvgpu: unit: nvgpu.hal.fifo.ctxsw_timeout UT
This unit test covers most of the nvgpu.hal.fifo.ctxsw_timeout module
lines and all branches.

Jira NVGPU-4388

Change-Id: I3b3855e6710073c1f878a2f7155a975373094da1
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2264345
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Vedashree Vidwans
6ef960dbc7 gpu: nvgpu: unit: nvgpu.hal.fifo.ramfc unit test
This unit test covers most of the nvgpu.hal.fifo.ramfc module lines and
all branches.

Jira NVGPU-4390

Change-Id: I7ef596089deab6fdb351f239124e59dc416a3aa7
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2260493
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Vedashree Vidwans
9c7051d37f gpu: nvgpu: unit: nvgpu.hal.fifo.ramin unit test
This unit test covers most of the nvgpu.hal.fifo.ramin module lines and
almost all branches.

Jira NVGPU-4391

Change-Id: Iaae4240305822707dd6446cec0ecc9e833ebffdc
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2259638
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Vedashree Vidwans
0ca906a6ad gpu: nvgpu: unit: fifo: fifo unit test
This unit test covers most of the nvgpu.common.fifo.fifo module lines
and almost all branches.

Jira NVGPU-3697

Change-Id: I5722277a3e1630a902f63b707eb3de1c4e1876b0
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2237796
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Vedashree Vidwans
917fb2e2df gpu: nvgpu: unit: fifo: channel unit test
This unit test covers remainder of the nvgpu.common.fifo.channel module
lines and branches.

Jira NVGPU-3696

Change-Id: I590faac1e4340d8fa2e5a7e591249128ec2b8760
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2241973
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Scott Long
83d4e3c7a7 gpu: nvgpu: MISRA 4.5 fixes to mmu code
MISRA Advisory Directive 4.5 states that identifiers in the same
name space with overlapping visibility should be typographically
unambiguous.

In both the nvgpu_locate_pte_last_level() and gp10b_get_pde0_pgz()
routines this violation is raised because a variable used as
a for-loop index ('i') is ambiguous with a parameter that points
to a struct gk20a_mmu_level ('l').

To fix these violations the loop index 'i' is renamed to 'idx'.

Jira NVGPU-3178

Change-Id: I2cec904201075b48ab6ccfbd0ff6d7e9dcac2867
Signed-off-by: Scott Long <scottl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2271456
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Adeel Raza <araza@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
dnibade
27122d10d7 gpu: nvgpu: unit: add unit tests for fe idle and pwr_mode HALs
Add unit test coverage for below HALs in common.gr.init subunit:

- g->ops.gr.init.wait_fe_idle
- g->ops.gr.init.fe_pwr_mode_force_on

Jira NVGPU-4458

Change-Id: I924f9e49abcb5846f24c620bba7fd1c704c36932
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2270652
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
dnibade
f2cc27f3d1 gpu: nvgpu: unit: add more coverage to gr.init config unit test
Add error checking coverage for below gr.init HAL functions in
unit test test_gr_init_hal_config_error_injection()

- g->ops.gr.init.pd_skip_table_gpc
- g->ops.gr.init.load_sw_veid_bundle
- g->ops.gr.init.load_sw_bundle_init
- g->ops.gr.init.load_method_init

Jira NVGPU-4458

Change-Id: I9f28fbbdc4f0160d852ebc2cbb56255ac6a74289
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2270651
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Tejal Kudav <tkudav@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Vedashree Vidwans
e668442e92 gpu: nvgpu: modify nvgpu_timeout_expired() for UT
Currently, nvgpu_timeout_expired returns -ETIMEDOUT almost always.
Modifying the macro provides more control on return value, and we can
return 0 indicating timeout not expired. This will allow timeout not
expired branch cbranch coverage.

Jira NVGPU-4675

Change-Id: Ib83bf15cf5f633639d516a939a7ca52b9866fc51
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2269743
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Tejal Kudav <tkudav@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Philip Elcan
5f8b8f0ef9 gpu: nvgpu: unit: init: check for correct hal
Add check to ensure the gv11b HAL was initialized. This satisfies the
action from the init FMEA to test for the correct HAL.

JIRA NVGPU-4010

Change-Id: I519872c86d204dbbf504da3322a9d0816ffc3b0f
Signed-off-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2266501
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Thomas Fleury
cb273476b6 gpu: nvgpu: unit: branch coverage for tsg
Cover remaining branches for:
- nvgpu_tsg_abort
- nvgpu_tsg_unbind
- nvgpu_tsg_mark_error

Jira NVGPU-4673

Change-Id: I9dacbf286f1a63cb4c82854984d83b6b9d1fcde3
Signed-off-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2266485
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Scott Long
9963b09101 gpu: nvgpu: MISRA 4.5 assert fix
MISRA Advisory Directive 4.5 states that identifiers in the same
name space with overlapping visibility should be typographically
ambiguous.

The use of both ASSERT_CONCAT() and ASSERT_CONCAT_() macros in
the implementation of the nvgpu_static_assert() macro violates
this directive.

This change switches ASSERT_CONCAT() to ASSERT_ADD_INFO() and
ASSERT_CONCAT_() to ASSERT_CONCAT() to eliminate the violation.

Jira NVGPU-3178

Change-Id: I2bf232f3b49267f2f9a211d614969cfc60d3983d
Signed-off-by: Scott Long <scottl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2270893
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Adeel Raza <araza@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Vedashree Vidwans
fb6fec4e3e gpu: nvgpu: modify unit tests to resolve failures
Currently, GVS is failing intermittently for some tests in nvgpu-runlist
and hal/mm/mmu_fault.
This patch resets gk20a structure at the end of each mmu_fault test. The
test_runlist_reload_ids and test_runlist_update_locked tests are
modified to use fifo support environment initialized for nvgpu-runlist
unit test.

Bug 2791755

Change-Id: I0b69b4f216f8f820b0a480ed76170b523b434bef
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2265676
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
tkudav
cb8003d9e0 gpu: nvgpu: Modify common.top for better coverage
Following changes are done to common.top code and UT:

1.Change return type for device_info_parse_enum to void as it can never
return non-zero value.
   - This is a private HAL and is only called by get_device_info HAL.
   - It gets called only for table entry with entry type = enum.
   - So there is no error path left.
This helps remove unnecessary branches and get better branch coverage

2. Check if the data parsing function pointers are not NULL before
parsing the device tree. Return error if there are no functions
to interpret the device_info table registers. Add checks for same in
unit test test_get_device_info().

JIRA NVGPU-2204

Change-Id: I8833da7aa58b070d19b50ee17f64362f301bd792
Signed-off-by: tkudav <tkudav@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2269603
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Scott Long
95c09bdddd gpu: nvgpu: MISRA 4.5 fixes to min_t()
MISRA Advisory Directive 4.5 states that identifiers in the same
name space with overlapping visibility should be typographically
ambiguous.

The uses of 'a'/'__a' and 'b'/'__b' in the implementation of the
min_t() macro are in violation of this directive.

This change switches '__a' to 't_a' and '__b' to 't_b' (where
't_' stands for "typed") to eliminate these violations.

Jira NVGPU-3178

Change-Id: I72394203ae59ba4d64ca5b539943c3efe9660417
Signed-off-by: Scott Long <scottl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2270879
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Adeel Raza <araza@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Vedashree Vidwans
a615604411 gpu: nvgpu: fix MISRA 11.2 nvgpu_sgl
MISRA rule 11.2 doesn't allow conversions of a pointer from or to an
incomplete type. These type of conversions may result in a pointer
aligned incorrectly and may further result in undefined behavior.

This patch addresses rule 11.2 violations related to pointers to and
from struct nvgpu_sgl. This patch replaces struct nvgpu_sgl pointers by
void pointers.

Jira NVGPU-3736

Change-Id: I8fd5766eacace596f2761b308bce79f22f2cb207
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2267876
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Thomas Fleury
6b62e0f79a gpu: nvgpu: engine preempt timeout in safety
Preempt TSG occurs in non-mission mode, when unbinding channel
from TSG, or aborting TSG. Should a preempt not complete on
engine, we expect other HW safety mechanisms such as FECS
watchdog to detect issues that prevented saving current context.
Add BUG_ON when attempting to recover from preempt timeout,
to make sure we got such error, and sw_quiesce has been
requested.

Jira NVGPU-4230

Change-Id: Ia26a61e703f74eb28d29e72e75664ca4ec97a586
Signed-off-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2265082
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Thomas Fleury
07a0fe707f gpu: nvgpu: mmu_fault_id for ce mmu fault handling
gv11b_mm_mmu_fault_handle_mmu_fault_common was calling
gv11b_mm_mmu_fault_handle_mmu_fault_ce for any mmu_engine_id
greater than gmmu_fault_mmu_eng_id_ce0_v().
This include GR engine on gv11b.

Check the range of mmu_fault_id for CEs instead, before
calling gv11b_mm_mmu_fault_handle_mmu_fault_ce.

Jira NVGPU-4511

Change-Id: I28a78872918dc97e0878ef4c116059eaf5d7fa7b
Signed-off-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2264975
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Thomas Fleury
5856b230fb gpu: nvgpu: add gv11b device_info parse data
Device info data format has changed from gp10b to
gv11b, and MMU fault id was incorrectly decoded for GR engine.
Add gv11b_device_info_parse_data HAL to decode device info
data with correct field definitions.

Move gp10b device_info parse data to non-fusa, since
it is not used anymore in safety build.

Jira NVGPU-4511

Change-Id: I2b3f3b5fec977d63a9ad6cfd99c04f375cf997e8
Signed-off-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2262217
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Thomas Fleury
f75a12e9c8 gpu: nvgpu: set id on MMU fault for unbound ch
Currently, gv11b_mm_mmu_fault_handle_mmu_fault_refch does not
set id when MMU fault occurs for a referenceable channel which
is not bound to TSG.

This can later on result in a crash when attempting to access
related channel context, using this unitialized id.

Jira NVGPU-4511

Change-Id: Ic8885ec89076cf8cc6c2b641f4a85e766d4b536a
Signed-off-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2264860
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Abdul Salam
14b218c284 gpu: nvgpu: Refactor Clk, Volt sub-unit
As a part of refactoring, we need to move the volt unit from perf to pmu
as it belongs there and also move the arbitor specific functions under
CLK_ARB as they will be removed from safety build.
This patch does the following
*Move volt struct from perf to pmu
*Move volt setup from pmu_pstate to volt
*Move clk freq related functions into CLK_ARB

NVGPU-4491
NVGPU-4492

Change-Id: I7180cd12bbf91cc4d2e79b6e2d71c16e494c8ff0
Signed-off-by: Abdul Salam <absalam@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2268215
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
tkudav
933b62a36e gpu: nvgpu: Add branch coverage for common.bus
Cover all possible branches for if statements.

JIRA NVGPU-928

Change-Id: I29dfa9e6f061cfae65619e4518ccf685ba9a4bea
Signed-off-by: tkudav <tkudav@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2266235
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
mkumbar
2df0b39957 gpu : nvgpu: pmu: remove fb_surface payload support
fb_surface payload used to send boardobjs for GV100
dGPU, but these are not required as Turing uses super
surface to share boardobjs with PMU Microcode.

JIRA NVGPU-4446

Change-Id: I295a0768bbed6e2dc385c33113669b0ca0a1b9b4
Signed-off-by: mkumbar <mkumbar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2265594
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
dnibade
55ea8a089d gpu: nvgpu: unit: add coverage tests for gr.init config APIs
Add code coverage tests for functions in gr.init subunit that need
tweaks to GR engine configuration for code/branch coverage.

Jira NVGPU-4458

Change-Id: Ic3d1c371768e74bde725bb44361280820ef1a774
Signed-off-by: dnibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2265457
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
dnibade
ab76dc1ad5 gpu: nvgpu: unit: add coverage tests for gops.gr.init.ecc_scrub_reg
Add new unit test to cover gops.gr.init.ecc_scrub_reg HAL function

gops.gr.init.ecc_scrub_reg HAL can generate TIMEOUT errors which are
not returned to caller currently. Update this HAL to return int value
for error propagation.

Jira NVGPU-4458

Change-Id: I98f4d5af2ef17cc4301951fec4d660638c8ef72c
Signed-off-by: dnibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2265456
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
dnibade
5f030d6c52 gpu: nvgpu: unit: add coverage tests for wait_empty and global_pagepool hals
Add new subtests to cover gops.gr.init.wait_empty() and
gops.gr.init.commit_global_pagepool() hals of common.gr.init subunit

Jira NVGPU-4458

Change-Id: Iffc2e95456518234ba6466fe1a9767c0eb53f2e6
Signed-off-by: dnibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2265455
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
tkudav
f0ff9dbafd gpu: nvgpu: Update test types in common.bus SWUTS
Use the updated test types.
Other (setup) --> Other (cleanup)
Feature based --> Feature

Also, change test names to unique identifier to avoid below errors in
SWVS:
Warning doxygenfunction: Unable to resolve multiple matches for
function 'test_xxx' with arguments () in doxygen xml output for
project 'nvgpu_doxygen'...

JIRA NVGPU-4679

Change-Id: If8a6b9ec8b26c3f99bc657bce24751b0e75fabbf
Signed-off-by: tkudav <tkudav@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2269046
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
tkudav
eaf2088217 gpu: nvgpu: Update test types in priv_ring SWUTS
Use the updated test types.
Other (setup) --> Other (cleanup)
Feature based --> Feature

Also, change test names to unique identifier to avoid below errors in
SWVS:
Warning doxygenfunction: Unable to resolve multiple matches for
function 'test_xxx' with arguments () in doxygen xml output for
project 'nvgpu_doxygen'...

JIRA NVGPU-4679

Change-Id: I66cda323387163a41808be09a69f625d53b744ed
Signed-off-by: tkudav <tkudav@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2269041
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
tkudav
d5b2deee29 gpu: nvgpu: Update test types in common.top SWUTS
Use the updated test types.
Other (setup) --> Other (cleanup)
Feature based --> Feature

Also, change test names to unique identifier to avoid below errors in
SWVS:
Warning doxygenfunction: Unable to resolve multiple matches for
function 'test_xxx' with arguments () in doxygen xml output for
project 'nvgpu_doxygen'...

JIRA NVGPU-4679

Change-Id: Ic2701bec2eafa0e64891d5c6d404847f14c41e55
Signed-off-by: tkudav <tkudav@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2268937
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
tkudav
a1259a6795 gpu: nvgpu: Update test types in common.fbp SWUTS
Use the updated test types.
Other (setup) --> Other (cleanup)
Feature based --> Feature

Also, change test names to unique identifier to avoid below errors in
SWVS:
Warning doxygenfunction: Unable to resolve multiple matches for
function 'test_xxx' with arguments () in doxygen xml output for
project 'nvgpu_doxygen'...

JIRA NVGPU-4679

Change-Id: I2bddf608f22d8c9f9dd5fbde9ca39f4417839077
Signed-off-by: tkudav <tkudav@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2267587
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Vaibhav Kachore
85e6ccc4b3 gpu: nvgpu: remove dGPU specific code
- This variable was introduced for MaxP/MaxQ feature which is
supported only on dGPU.
- This patch removes this code from safety build as dGPU is not
supported on it.

Bug 200556366

Change-Id: I1131f756376df587c8a8ed91edd5d62822214a7f
Signed-off-by: Vaibhav Kachore <vkachore@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2268973
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
ddutta
c9bb9da6da gpu: nvgpu: Reduce CCM for nvgpu_channel_setup_bind
A new static function channel_setup_bind_prechecks is constructed.
All precondition checks present in nvgpu_channel_setup_bind are moved
to channel_setup_bind_prechecks.

Jira NVGPU-4063

Change-Id: I1c784bd74628ba95f427d9b53629016e8b0acb9a
Signed-off-by: Debarshi Dutta <ddutta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2268076
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Scott Long
b4dfe2c1f5 gpu: nvgpu: MISRA 12.1 fixes to min()/max()
MISRA Advisory Rule 12.1 states that the precedence of operators
within expressions should be made explicit.

This change modifies the min()/max()/min_t() macro implementations
to eliminate these 12.1 violations.

Jira NVGPU-3178

Change-Id: Ibc1b0bc107d128d300ebdec547417dc7ad201446
Signed-off-by: Scott Long <scottl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2267898
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Scott Long
b28d531089 gpu: nvgpu: MISRA 4.9 fixes
MISRA Advisory Rule 4.9 states that a function should be used in
preference to a function-like macro where they are interchangeable.

This change switches gk20a_from_mm() and gk20a_from_vm() from
macros to static inline functions.

Jira NVGPU-3178

Change-Id: Ie2a7de0196b69d683ade696adf5e4c9412377607
Signed-off-by: Scott Long <scottl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2256273
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
Vedashree Vidwans
0033a4402e gpu: nvgpu: fix userspace build failure
This patch adds a missing backslash to escape newline character.

Jira NVGPU-4675

Change-Id: I9ca82c4fa5dd26905ee4ea983e2a69e2cd04acea
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2267877
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Debarshi Dutta <ddutta@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00
vinodg
f9f0969b86 gpu: nvgpu: fix code complexity in common.gr intr unit
Move warp_sync code to a sub function from
nvgpu_gr_intr_handle_sm_exception function.

Move client signalling code for exception interrupt to a
sub function from gr_intr_handle_exception_interrupts.

Jira NVGPU-4699

Change-Id: I0d15f149fa22cbcdb180b881c01503595a88f7a4
Signed-off-by: vinodg <vinodg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2268310
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2020-12-15 14:10:29 -06:00