Commit Graph

5568 Commits

Author SHA1 Message Date
Seshendra Gadagottu
a15d1fa72c gpu: nvgpu: ltc: move chip specific files to hal
Move ltc chip speciifc files to hal from common

JIRA NVGPU-2044

Change-Id: If3f5e77fce1dfa94336e1be616833cef5b91839b
Signed-off-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2070186
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-18 07:45:34 -07:00
ajesh
6be73f561a gpu: nvgpu: use posix cond implementation for qnx
Unify posix cond unit with qnx.

Jira NVGPU-2151

Change-Id: I769f646751299154d7d753228777266e3098c8d3
Signed-off-by: ajesh <akv@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2033596
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-17 23:47:06 -07:00
Seshendra Gadagottu
e6f9033048 gpu: nvgpu: cbc: move cbc de-init sequence
Move cbc_remove_support from gr remove to generic nvgpu
remove sequence.

JIRA NVGPU-2896
JIRA NVGPU-2897

Change-Id: Ia9c1a81e849bfe0dc123a86473ae2b0d77792335
Signed-off-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2074251
Reviewed-by: Automatic_Commit_Validation_User
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>
2019-03-17 05:15:59 -07:00
Seshendra Gadagottu
a2bc7d5923 gpu: nvgpu: cbc: move cbc related code from gr
Moved cbc related code and data from gr to cbc unit.

Ltc and cbc related data is moved from gr header:
1. Ltc related data moved from gr_gk20a -> gk20a and it
will be moved eventually to ltc unit:
u32 slices_per_ltc;
u32 cacheline_size;

2. cbc data moved from gr_gk20a -> nvgpu_cbc
u32 compbit_backing_size;
u32 comptags_per_cacheline;
u32 gobs_per_comptagline_per_slice;
u32 max_comptag_lines;
struct gk20a_comptag_allocator comp_tags;
struct compbit_store_desc compbit_store;

3. Following config data moved gr_gk20a -> gk20a
u32 comptag_mem_deduct;
u32 max_comptag_mem;
These are part of initial config which should be available
during nvgpu_probe. So it can't be moved to nvgpu_cbc.

Modified code to use above updated data structures.

Removed cbc init sequence from gr and added in
common cbc unit. This sequence is getting called
from common nvgpu init code.

JIRA NVGPU-2896
JIRA NVGPU-2897

Change-Id: I1a1b1e73b75396d61de684f413ebc551a1202a57
Signed-off-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2033286
Reviewed-by: svc-misra-checker <svc-misra-checker@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>
2019-03-17 05:15:35 -07:00
Vinod G
ac10ac960f gpu: nvgpu: update nvgpu_gr_init_fs_state
To avoid the other hal calls from gr_gv11b_init_fs_state
and gr_gm20b_init_fs_state hal, move the load_tpc_mask and
load_smid_config hal to nvgpu_gr_init_fs_state common gr function.

bes_zrop_setting and bes_crop_setting for active_ltcs is moved before
the nvgpu_gr_init_fs_state call from those hals.

replace gk20a_writel and gk20a_readl in modified hal function with
nvgpu_writel and nvgpu_readl.

JIRA NVGPU-1885

Change-Id: Ic0bf4a4bfa4da032f33bbe4af89031bbbdd9cd94
Signed-off-by: Vinod G <vinodg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2072414
Reviewed-by: Seshendra Gadagottu <sgadagottu@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>
2019-03-16 10:05:55 -07:00
Vinod G
43672dd237 gpu: nvgpu: gr/init update
move gr_gk20a_init_fs_state function to common/gr/init as
nvgpu_gr_init_fs_state.

JIRA NVGPU-1885

Change-Id: I37aad483be268e2b722883719376beb142c0b7ea
Signed-off-by: Vinod G <vinodg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2072413
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-16 10:05:46 -07:00
Vinod G
e29c1a6c03 gpu: nvgpu: fix MISRA-C violations
Fix some MISRA-C violations in the gr/init hal file.
Rule 2.2 - stored value is overwritten before it can used.
Rule 17.7 - return value of non-void function is unused.

JIRA NVGPU-2951

Change-Id: Ia821ec9bb4f281ff760868189969df9e81bde8d8
Signed-off-by: Vinod G <vinodg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2073035
Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-by: svc-misra-checker <svc-misra-checker@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>
2019-03-16 10:05:31 -07:00
Deepak Nibade
04786d1a2e gpu: nvgpu: add hal.gr.init hal to enable/disable fe_go_idle timeout
Add new hal operation g->ops.gr.init.fe_go_idle_timeout() in hal.gr.init
unit to enable/disable fe_go_idle timeout

Use this hal in gr_gk20a_init_golden_ctx_image() instead of direct
register access

Remove timeout disable/enable code in gk20a_init_sw_bundle() since
parent API gr_gk20a_init_golden_ctx_image() is already taking care of
that

Jira NVGPU-2961

Change-Id: Ice72699059f031ca0b1994fa57661716a6c66cd2
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2072550
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-16 05:06:42 -07:00
Deepak Nibade
15d8941341 gpu: nvgpu: move gr.init_preemption_state HAL to hal.gr.init unit
Move GR HAL operation g->ops.gr.init_preemption_state() to hal.gr.init
unit as g->ops.gr.init.preemption_state()

Create hal.gr.init unit files for gp10b and gv11b and copy over
corresponding functions to new files

This API now takes gfxp_wfi_timeout_unit and gfxp_wfi_timeout_count as
parameter

Define gfxp_wfi_timeout_unit in struct gr_gk20a as a boolean flag named
gfxp_wfi_timeout_unit_usec
Remove GFXP_WFI_TIMEOUT_UNIT_SYSCLK/USEC macros

Jira NVGPU-2961

Change-Id: I4347b1e30c86c231e44cf274adccd8c70addcdab
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2072549
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-16 05:06:28 -07:00
Deepak Nibade
09e2e8c838 gpu: nvgpu: remove write to gr_scc_init_r() register
Register gr_scc_init_r() is deprecated and non-functional since maxwell
Remove write to this register and also remove its accessors

Jira NVGPU-2961

Change-Id: I7ef0c55290003234f795a66435c1f7093827662e
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2072548
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-16 05:06:13 -07:00
Deepak Nibade
7fa2189fb3 gpu: nvgpu: move fecs_trace operations under gr
Move g->ops.fecs_trace.*() HAL operations under gr operations as
g->ops.gr.fecs_trace.*()

Also rename gk20a_ctxsw_*() functions used in common code to the
format nvgpu_gr_fecs_trace_*()

Jira NVGPU-1880

Change-Id: Idf2f8fb3d7ba2832bf1837fd97b70b3cee412123
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2070767
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-16 05:05:41 -07:00
Deepak Nibade
1208ad7cef gpu: nvgpu: rearrange linux specific fecs trace support
We have 3 header files for FECS tracing support
include/nvgpu/gr/fecs_trace.h : common header
include/nvgpu/ctxsw_trace.h : header that includes both common and
                              os-specific functions
os/linux/ctxsw_trace.h : linux specific header

Remove the second header since it is not needed.

Move all structures that are needed in common code to
include/nvgpu/gr/fecs_trace.h
Move all function declarations that are needed in common code to
include/nvgpu/gr/fecs_trace.h
Move all linux specific declarations in os/linux/ctxsw_trace.h and
rename this file as os/linux/fecs_trace_linux.h

Also rename os/linux/ctxsw_trace.c to os/linux/fecs_trace_linux.c

Jira NVGPU-1880

Change-Id: I05cc4489c4b6a64880b7d59c02b22cd2244d5e22
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2070766
Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-16 05:05:32 -07:00
Vinod G
bbb0caa42c gpu: nvgpu: rearrange gr/zbc files
move zbc hal files from common/gr/zbc to hal/gr/zbc directory.
rename gr/zbc/gr_zbc.c -> gr/zbc.c and gr/zbc/gr_zbc.h -> gr/zbc_priv.h

JIRA NVGPU-1882

Change-Id: I58c98c0a494b600a35a576a9d717114023118ee6
Signed-off-by: Vinod G <vinodg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2071962
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-15 12:14:42 -07:00
Sagar Kamble
08aaaecc61 gpu: nvgpu: add EMEM support enabled flag and EMEM mutex
Access to falcon's EMEM has to be synchronized to ensure atomic access
to EMEM control and data registers. Add this locking.
Not all falcons support EMEM hence handle mutex based on the enabled
flag emem_supported that is set only for TU104 currently.

JIRA NVGPU-1993

Change-Id: Idaedfb564ea0068d4690a2717d7983eb2384a69f
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2030618
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>
2019-03-15 02:25:28 -07:00
Sagar Kamble
cfe935ff5c gpu: nvgpu: move falcon_gk20a.c|h to hal/falcon/
Move falcon_gk20a.c|h to hal/falcon/falcon_gk20a.c as per new unit
separation requirement.

JIRA NVGPU-2038

Change-Id: If2b7ff78293fc1bd9983399d2bc5261d2365e7f2
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2072380
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-15 02:25:19 -07:00
Sagar Kamble
51120a4361 gpu: nvgpu: access falcon HAL functions through g->ops
Earlier falcon HAL ops were embedded in the falcon structure. For clear
separation of common and HAL these ops will have to be accessed through
g->ops.falcon interfaces.
With these changes nvgpu_falcon_* functions directly call falcon gpu
ops functions for falcon. Falcon registers and HAL functions are
exported from falcon_gk20a.h. HAL files per platform are now
updated with base falcon functions.
Falcon software state such as is_falcon_supported, is_interrupt_enabled
and flcn_base are set from software init functions defined per chip.

JIRA NVGPU-2038

Change-Id: Ib1729d2833cd2c6c7b2c8ed7cbc17d4d6daeba73
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2023077
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-15 02:25:04 -07:00
Sagar Kamble
f4174ef048 gpu: nvgpu: move nvgpu_falcon struct to nvgpu/falcon.h
This struct was earlier moved to falcon_priv.h to give exclusive access
to only falcon unit. However with HAL unit needing access to this we
need to move it public header nvgpu/falcon.h.

JIRA NVGPU-1993

Change-Id: Ia3b211798009107f64828c9765040d628448812a
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2069688
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-15 02:24:49 -07:00
sumitg
daa4d7e42b gpu: nvgpu: vgpu: correct param to sysfs_attr_init
Pass correct attr parameter to sysfs_attr_init().
This fixes the compilation error on enabling debug
lock alloc.
 error: ‘struct device_attribute’ has no member named ‘key’

Bug 200464909

Change-Id: Ia0d2672b1c8fe9eb4807b4809892dcdc0cff2669
Signed-off-by: sumitg <sumitg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2034954
GVS: Gerrit_Virtual_Submit
Reviewed-by: Debarshi Dutta <ddutta@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-14 21:43:46 -07:00
Thomas Fleury
ffed5095db gpu: nvgpu: move fifo init/deinit code to common
Add fifo sub-unit to common.fifo to handle init/deinit code
and global support functions.

Split init into:
- nvgpu_channel_setup_sw
- nvgpu_tsg_setup_sw
- nvgpu_fifo_setup_sw
- nvgpu_runlist_setup_sw
- nvgpu_engine_setup_sw
- nvgpu_userd_setup_sw
- nvgpu_pbdma_setup_sw

Split de-init into
- nvgpu_channel_cleanup_sw
- nvgpu_tsg_cleanup_sw
- nvgpu_fifo_cleanup_sw
- nvgpu_runlist_cleanup_sw
- nvgpu_engine_cleanup_sw
- nvgpu_userd_cleanup_sw
- nvgpu_pbdma_cleanup_sw

Added the following HALs
- runlist.length_max
- fifo.init_pbdma_info
- fifo.userd_entry_size

Last 2 HALs should be moved resp. to pbdma and userd sub-units,
when available.

Added vgpu implementation of above hals
- vgpu_runlist_length_max
- vgpu_userd_entry_size
- vgpu_channel_count

Use hals in vgpu_fifo_setup_sw.

Jira NVGPU-1306

Change-Id: I954f56be724eee280d7b5f171b1790d33c810470
Signed-off-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2029620
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-14 20:35:22 -07:00
Philip Elcan
f087ec0826 gpu: nvgpu: posix: fix cmpxchg MISRA 17.3 bug
In the commit "gpu: nvgpu: unit: update misc atomics to use gcc
builtins" the cmpxchg macro used by the "POSIX" build changed and
introduced a MISRA 17.3 violation for a macro parameter that needed
parentheses. This updates the macro to resolve this violation.

Change-Id: I16927ecaa751964f8c397c95086c663a683f8241
Signed-off-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2070064
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Tejal Kudav <tkudav@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>
2019-03-14 16:24:39 -07:00
Vinod G
56219f7c10 gpu: nvgpu: add more gr/init hal functions
Register write from gr_gk20a_init_fs_state function are moved to hal.

New hal added for setting the pd_tpc_per_gpc, pd_skip_table_gpc and
cwd_gpcs_tpcs_num.

pd_tpc_per_gpc helps to describe the number of tpcs in each logical
gpc.
pd_skip_table helps to skip certain TPCs during distribution.
cwd_gpcs_tpcs_num helps to set number of tpcs and gpcs in CWD.

remove write for depreciated NV_PBE_PRI_ZROP_SETTING_NUM_ACTIVE_FBPS
and NV_PBE_PRI_CROP_SETTINS_NUM_ACTIVE_FBPS fields from
BES_ZROP_SETTINGS and BES_CROP_SETTINGS registers. Both these fields
changed to NUM_ACTIVE_LTCS from gm20b onwards and those are being
set in existing hal functions.

JIRA NVGPU-2951

Change-Id: I905b98356e8eadaf7e2481850de841c050ea50c5
Signed-off-by: Vinod G <vinodg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2072249
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-14 15:34:53 -07:00
Vinod G
89515b7ac6 gpu: nvgpu: add common.gr.gr unit
add nvgpu_gr_get_idle_timeout function in gr.c
common definitions and function declarations are in gr.h

JIRA NVGPU-1885

Change-Id: Ibe6851757a90ad2d66687f93efd9aba13b40d6f7
Signed-off-by: Vinod G <vinodg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2072050
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-14 15:34:38 -07:00
Vinod G
caac47c4fa gpu: nvgpu: add new gr.init hals
create new hals for wait_idle and wait_fe_idle under gr.init.

modify functions to following hals and use same hals for all chips.
gr_gk20a_wait_idle -> gm20b_gr_init_wait_idle
gr_gk20a_wait_fe_idle -> gm20b_gr_init_wait_fe_idle

JIRA NVGPU-2951

Change-Id: Ie60675a08cba12e31557711b6f05f06879de8965
Signed-off-by: Vinod G <vinodg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2072051
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-14 15:34:24 -07:00
Adeel Raza
79d332aca9 gpu: nvgpu: unit: add VM unit tests
Add VM unit tests for the following requirements:
   - NVGPU-RQCD-45.C1: A valid GPU virtual address is/is not generated
     for the buffer passed into nvgpu_vm_map().
   - NVGPU-RQCD-45.C2: When a GPU virtual address is passed into the
     nvgpu_vm_map() function the resulting GPU virtual address of the
     map does/does not match the requested GPU virtual address.

JIRA NVGPU-1927

Change-Id: I7c9f7204772a611ff7baa56b6434a70d5b70cd27
Signed-off-by: Adeel Raza <araza@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2036213
Reviewed-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Nicolas Benech <nbenech@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-14 15:34:09 -07:00
Seshendra Gadagottu
db339fd52f gpu: nvgpu: therm: move chip specific files to hal
Move thermal chip specific files to hal from common.

JIRA NVGPU-2018

Change-Id: I5022ddb4a2ab7f723936e027ffaa1222272095c0
Signed-off-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2070185
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-14 14:44:45 -07:00
Prateek sethi
c990a3ee2b gpu: nvgpu: add accessors for PMU bar0 status
Add missing register host_err and bar0 error masks to find actual error
type of pmu bar0 pri timeout.

Jira NVGPU-1902

Change-Id: I4ec5a5230517e34bf5a843c2f0d9b0473875350f
Signed-off-by: Prateek sethi <prsethi@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2069182
Reviewed-by: Raghuram Kothakota <rkothakota@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ankur Kishore <ankkishore@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-14 08:05:03 -07:00
Prateek sethi
3859725ea1 gpu: nvgpu: report PMU falcon bar0 errors
Introduce hooks for reporting BAR0 PRI timeout.

Jira NVGPU-1858

Change-Id: I917a7cb2e24b6d4025305e965c00c5551222c00a
Signed-off-by: Prateek sethi <prsethi@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2024488
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-14 08:04:39 -07:00
Alex Waterman
154ffd9dad gpu: nvgpu: Add BYPASS_IOMMU enabled flag
Some chips bypass the IOMMU on tegra. Essentially any chip using
nvlink will fall into this category.

This imposes certain oddities in the memory management for these
chips. For these chips we do not want nor need IOMMU mappings
and the overhead that comes with doing that. Instead nvgpu can
manage allocation of pages itself.

For contiguous memory nvgpu still does need to rely on the CMA.
As such this flag can be used for determining whether to use the
special nvgpu managed page allocation (for normal allocs) or the
DMA API (and therefor the CMA) for contiguous allocs.

Bug 200444660

Change-Id: I3dc4ba6ea9523f2a59966b13527d5a416aaa761a
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2071090
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-14 03:38:55 -07:00
Nicolin Chen
b0d6964325 gpu: nvgpu: Add non-contiguous memory allocation
The latest GPU uses nvlink and its own MMU to access memory,
instead of SMMU like others. So it doesn't go through IOMMU
framework to allocate physically non-contiguous memory. The
DMA API had a pair of downstream functions to allocate the
memory for this situation, but it is removed since it's not
likely acceptable for upstream kernel.

In order not to hack the dma-direct ops that by its meaning
is supposed to provide contiguous memory, this patch adds a
pair of memory-allocation functions inside the gpu driver,
since nvgpu is the only user.

This pair of functions are only used when GPU driver doesn't
go through either dma-direct (FORCE_CONTIGUOUS) or iommu. It
also requires GPU driver to map the non-contiguous pages.

Bug 200444660

Change-Id: I26678a3f8d63bba340872beeecbb7b0e1e7a35fa
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2029680
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>
2019-03-14 03:38:28 -07:00
Nicolin Chen
a8e6d13652 gpu: nvgpu: Delete NVGPU_DMA_FORCE_CONTIGUOUS
The flag NVGPU_DMA_FORCE_CONTIGUOUS simply means that the memory
or the pages should be forced contiguous. Meanwhile, the other
flag NVGPU_DMA_PHYSICALLY_ADDRESSED means that the memory should
be contiguous from GPU perspective, either physically contiguous
when IOMMU is not used, or virtually contiguous by IOMMU.

Thus the NVGPU_DMA_FORCE_CONTIGUOUS flag is now redundant.

This patch cleans up the NVGPU_DMA_FORCE_CONTIGUOUS flag.

Bug 200444660

Change-Id: I63bb06fea728b34ec2c6f831504392d42c426d55
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2035403
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>
2019-03-14 03:38:19 -07:00
Nicolin Chen
ac3c3e2b69 gpu: nvgpu: Simplify nvgpu_dma_free_sys()
The original free routine has three options:
    if (NVGPU_DMA_NO_KERNEL_MAPPING)
        dma_free_attrs(d, mem->aligned_size, mem->priv.pages,
    else if (other flags)
        dma_free_attrs(d, mem->aligned_size, mem->cpu_va,
    else /* No flags */
        dma_free_coherent(d, mem->aligned_size, mem->cpu_va,

The last dma_free_coherent() can be unwrapped to dma_free_attrs
with its dma_attrs=0, while the former two are identical except
cpu_addr. So this patch merges these three into one single call
but differentiate the cpu_addr and dma_attrs parameters.

Note that the dma_free_attrs returns 0 when flags is not set.

Bug 200444660

Change-Id: I92ec0390138c79c5109973e476ea0ea719d4e2b9
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2029679
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>
2019-03-14 03:38:08 -07:00
Aparna Das
5128237bc8 gpu: nvgpu: introduce hal ops for vgpu_vm_init and vgpu_vm_remove
vgpu_vm_init and vgpu_vm_remove are called directly from
common code if virtualization is supported. Introduce mm
HAL ops vm_as_alloc_share and vm_as_free_share and call
these functions through these HAL ops. Also rename these functions
from vgpu_vm_init to vgpu_vm_as_alloc_share and vgpu_vm_remove to
vgpu_vm_as_free_share as these function names are too generic and
rename to reflect their actual functionality.
For now these HAL ops are initialized only for vgpu.

Jira GVSCI-517

Change-Id: I7c5af1ab5a64ce562092f75b1488524e93e8f53f
Signed-off-by: Aparna Das <aparnad@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2032310
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-14 00:08:57 -07:00
Deepak Nibade
95f47ac13c gpu: nvgpu: add new hal.gr.init HAL to reset sys/gpc/be units
gr_gk20a_init_golden_ctx_image() right now resets sys/gpc/be units by
directly accessing gr_fecs_ctxsw_reset_ctl_r() register

Move this register write/read sequence to common.hal.gr.init unit
through HAL operation g->ops.gr.init.override_context_reset()

Use new HAL in gr_gk20a_init_golden_ctx_image()

Also fix the delay() operations. delay() should be added before we read
back gr_fecs_ctxsw_reset_ctl_r() register and not after

Jira NVGPU-2961

Change-Id: I70d3a61b5aa60846815dee52ecac544066542695
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2070608
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-13 11:17:55 -07:00
Deepak Nibade
c4534b5ee3 gpu: nvgpu: add common.hal.gr.init unit
Add new HAL unit common.hal.gr.init with below source files
hal/gr/init/gr_init_gm20b.c
hal/gr/init/gr_init_gm20b.h

In gr_gk20a_init_golden_ctx_image() we force FE power mode on and also
disable it. Extract out this sequence into new unit and expose new HAL
operation that takes a boolean flag to enable/disable power mode

g->ops.gr.init.fe_pwr_mode_force_on()

Use new HAL operation in gr_gk20a_init_golden_ctx_image()
Set this HAL for all the chips

Jira NVGPU-2961

Change-Id: I1dd35d94fda5e5296af67c0abc944e200fb752ea
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2070607
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-13 11:17:40 -07:00
Sagar Kamble
45ee7baab1 gpu: nvgpu: move mailbox0 write to engine bl_bootstrap
Semantics of the engine bootloader bootstrap are to set falcon mailbox0
register to non-zero value and verify that it is cleared to ascertain
successful completion of bootstrap.
Read was done in the engine bl_bootstrap related functions. Hence move
the write as well to those functions.

JIRA NVGPU-1993

Change-Id: I6d04148fbf1d517f0af8b4cfc2ee144d38704647
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2034511
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-13 11:17:15 -07:00
Sagar Kamble
9f68fecb64 gpu: nvgpu: remove nvgpu_falcon_to_gk20a
Remove the API nvgpu_falcon_to_gk20a as that is not needed as we can
pass gk20a struct parameter to emem copy functions directly.

JIRA NVGPU-1993

Change-Id: I2283900268342f9d9b8b5a62024f183624adf79f
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2023080
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-13 11:16:51 -07:00
Sagar Kamble
7a365bc3b4 gpu: nvgpu: check port parameter for falcon memory operations
IMEM and DMEM access should happen with allowed ports. Validate the same
during copy to/from IMEM & DMEM.

JIRA NVGPU-1993

Change-Id: I4ff856ce4ba5e133619e2405238958aa5c1c0da9
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2030623
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>
2019-03-13 11:16:36 -07:00
Sagar Kamble
35ec51cb2e gpu: nvgpu: update hw header with hwcfg1 register and imem, dmem ports values
To validate the imem & dmem port being accessed by nvgpu, allowed ports
need to be known from hwcfg1 register. Update the hw header with these
to use for checking the valid ports in later patch.

JIRA NVGPU-1993

Change-Id: I1146a85d452d02fefcc75065a0cd546fff688fd2
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2030622
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>
2019-03-13 11:16:26 -07:00
Sagar Kamble
0ef974e020 gpu: nvgpu: check for offset alignment in EMEM data transfer
EMEM accesses need to be at the 4-byte aligned offsets. Check for this
in tu104_sec2_emem_transfer.

JIRA NVGPU-1993

Change-Id: Ic9552bdc13278483507b3c23d61bf3d9371a631e
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2030621
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-13 11:16:16 -07:00
Sagar Kamble
3084616f31 gpu: nvgpu: move bl_bootstrap logic to common API
bootloader bootstrap function is actually derived from other falcon
functions hence remove it from the hal file and move the logic to
nvgpu_falcon_bl_bootstrap.

JIRA NVGPU-1993

Change-Id: I37b5c437dbaeab040d6fc1c49179a9bfc500c2c8
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2023075
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>
2019-03-13 11:16:01 -07:00
Sagar Kamble
8da1bde7db gpu: nvgpu: define nvgpu_falcon_get_mem_size
Currently we have DMEM version of the API to get the size of falcon
memory. Let us convert it to generic as needed at multiple places.

JIRA: NVGPU-1993

Change-Id: If612b0a10e27619e4b6132773907eb21f0569a27
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2023074
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-13 11:15:51 -07:00
Sagar Kamble
8765df40b0 gpu: nvgpu: add parameter check to falcon_print_mem
Bounds check was not done while accessing IMEM & DMEM data for printing.

JIRA NVGPU-1993

Change-Id: I7a1bb5fa64c68e643712c4af8b28e94303e213f8
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2030620
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>
2019-03-13 11:15:36 -07:00
Sagar Kamble
ad1842d4a2 gpu: nvgpu: create separate mutex for IMEM and DMEM access
Access to IMEM and DMEM can be done parallely as they have separate
control and data registers. Hence they need not be synchronized
using single copy_lock. Prepare separate mutex locks.

JIRA NVGPU-1993

Change-Id: Ie4bfcb6cef0259c6fb98a86bdbcc378ff5725ee5
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2030617
Reviewed-by: svc-misra-checker <svc-misra-checker@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>
2019-03-13 11:15:26 -07:00
Vinod G
f1c9c1ebc0 gpu: nvgpu: remove unused register and fields
cleanup header for removal of czf_bypass and pd_max_batches support.

JIRA NVGPU-2967

Change-Id: I7a1d8dfeabb87e3653c70a560282f99ff4310ce7
Signed-off-by: Vinod G <vinodg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2071070
Reviewed-by: Automatic_Commit_Validation_User
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>
2019-03-13 08:54:45 -07:00
Vinod G
e8b6580953 gpu: nvgpu: remove pd_max_batches support
remove unused pd_max_batches implementation.
remove pd_max_batches support from gr_gk20a struct and sysfs

Bug 200492671

Change-Id: Ibfd81a6aec88610175495018759c27341b637e52
Signed-off-by: Vinod G <vinodg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2070058
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Seshendra Gadagottu <sgadagottu@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>
2019-03-13 08:54:21 -07:00
Vinod G
3856aa54d8 gpu: nvgpu: remove czf_bypass support
remove unused czf_bypass support
clean up the czf_bypass from sysfs implementation, gr_gk20a struct,
hal support in gp10b for init_czf_bypass and set_czf_bypass.

Bug 200492671

Change-Id: I2412410838581341c777d07cf4b2fad2d4163956
Signed-off-by: Vinod G <vinodg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2070057
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-13 08:54:12 -07:00
Seema Khowala
cb91bf1e13 gpu: nvgpu: protect recovery with engines_reset_mutex
Rename gr_reset_mutex to engines_reset_mutex and acquire it
before initiating recovery. Recovery running in parallel with
engine reset is not recommended.

On hitting engine reset, h/w drops the ctxsw_status to INVALID in
fifo_engine_status register. Also while the engine is held in reset
h/w passes busy/idle straight through. fifo_engine_status registers
are correct in that there is no context switch outstanding
as the CTXSW is aborted when reset is asserted.

Use deferred_reset_mutex to protect deferred_reset_pending variable
If deferred_reset_pending is true then acquire engines_reset_mutex
and call gk20a_fifo_deferred_reset.
gk20a_fifo_deferred_reset would also check the value of
deferred_reset_pending before initiating reset process

Bug 2092051
Bug 2429295
Bug 2484211
Bug 1890287

Change-Id: I47de669a6203e0b2e9a8237ec4e4747339b9837c
Signed-off-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2022373
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-13 06:34:31 -07:00
Seema Khowala
7e2f124fd1 gpu: nvgpu: wait for gr.initialized before changing cg/pg
set gr.initialized to false in the beginning of gk20a_gr_reset() and
set it to true at the end of successful execution of gk20a_gr_reset.

Use gk20a_gr_wait_initialized() to enable/disable cg/pg
functions to make sure engine is out of reset and initialized.

Bug 2092051
Bug 2429295
Bug 2484211
Bug 1890287

Change-Id: Ic7b0b71382c6d852a625c603dad8609c43b7f20f
Signed-off-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2030827
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-13 06:34:17 -07:00
Seema Khowala
672e6bc31e gpu: nvgpu: disable elpg before ctxsw_disable
if fecs is sent stop_ctxsw method, elpg entry/exit cannot happen
and may timeout. It could manifest as different error signatures
depending on when stop_ctxsw fecs method gets sent with respect
to pmu elpg sequence. It could come as pmu halt or abort or
maybe ext error too.

If ctxsw failed to disable, do not read engine info and just abort tsg.

Bug 2092051
Bug 2429295
Bug 2484211
Bug 1890287

Change-Id: I5f3ba07663bcafd3f0083d44c603420b0ccf6945
Signed-off-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2014914
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-03-13 06:34:02 -07:00
Divya Singhatwaria
59bf4b39ff gpu: nvgpu: refactor PG unit
- Move the PG unit source code to common/pmu/pg/ folder
- Separate PG unit headers under include/nvgpu/pmu/pmu_pg.h

NVGPU-1973

Change-Id: I7dfaad9abd809ba8374c3c4380a8d0c857bcab95
Signed-off-by: Divya Singhatwaria <dsinghatwari@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2031676
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>
2019-03-13 04:14:19 -07:00