Commit Graph

44 Commits

Author SHA1 Message Date
charliej
31cf676050 DCE KMD: Add timeout into synchronous IPC calls
This is for avoiding kernel hang when DCE FW fails to respond.
Failures of IPC call will return -ERESTARTSYS or -ETIMEOUT, which
will be handled by caller functions:
1. tegra_dce_client_ipc_send_recv (EXPORT_SYMBOL)
   This is module export symbol and caller have the responsibility
   of checking return value.
2. DCE FSM event handler
   Error return will change back to previous state.

DCE_IPC_TIMEOUT_MS_MAX is set to 10000[ms]
SHA computation time on SC7 entry request can go up 2sec.
Host tolerance time must be larger than this.

Jira TDS-16567
https://nvbugspro.nvidia.com/bug/5335034

Change-Id: I5d77a9497f14f305d07b98e39a58fbcecafedf92
Signed-off-by: charliej <charliej@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3358620
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Tested-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
(cherry picked from commit 6c2ab3c78ce7cba0e88455b263d51d1a88c03927)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3402917
2025-07-24 10:20:36 +00:00
jaiyasha
c89da8defd DCE-KMD: Add support for logging infra
- Allocate DMA mapped buffer from DCE-KMD and pass it to DCE FW through
  admin-cmd calls.
- Add debugfs node to retrieve buffer data and print through seq file.
- Add support to clear log buffer

JIRA TDS-15963

Change-Id: Ied4ffe1df14c8db61cfe15e6442f55e8306530b8
Signed-off-by: jaiyasha <jaiyasha@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3117241
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
Tested-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
2025-07-24 10:20:35 +00:00
Mahesh Kumar
a23d954e3e platform: dce: Add bootsrap2 command
Add support to the bootstrap command over the admin channel,
which will be called when a client registers. This command will
perform steps that must be performed only after the client is ready.

TODO: This bootstrap-2 command will be replaced by the existing
bootstrap command which we call during DCE-FW bootstrapping once
we split admin bootstrapping and RM bootstrapping in the DCE-KMD.

Jira TDS-17135

Change-Id: I55330b9ce73e1acf20e2a80d392d7984c91ed65f
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3274949
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
2025-07-24 10:19:17 +00:00
anupamg
2f69bee627 DCE-KMD: Update shared files licenses
- Updates licenses for DCE-KMD files that are shared with HVRTOS.
    - Update from GPL-2.0 to MIT as we use these files in both
      open source and closed source context.

JIRA TDS-16741

Change-Id: Icf7aeb737f2f3b294bb9ff9c36d5ed7220c13dea
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3293404
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
2025-07-24 10:19:14 +00:00
anupamg
2bed40f6fe DCE-KMD: Refactor dce-os-worker.c/.h
- dce-os-worker.c/.h module exposes functionality which allows
  DCE KMD clients to wait/signal events.

- The current abstraction of this module has following drawbacks
  which this change attempts to address:
    * Name: dce-os-worker is a misnomer
        - Rename to dce-wait-cond.c/.h and make it a dce-kmd core file.
        - Rename functions accordingly.
    * dce-os-worker module initializes data structures from tegra_dce
      which makes it ineligible for re-use.
        - dce-client-ipc can re-use this module as it uses exact
          same functionality.
        - But this module is tied with DCE-KMD core such that it has
          functions that operate on fixed known inputs.
            - dce_os_work_cond_sw_resource_init/deinit()
                Inits/Deinits most but not all condition var resources
                from tegra_dce. Eg. dce-client-ipc resources
                are not initialized.
                    - Move this function to new core file:dce-waiters.c
            - All other functions require msg_id as input and can only
              operate on DCE_WAIT* resources making it ineligible
              to be used by other clients like dce-client-ipc.
                    - Refactor these fucntions to operate on
                      individual wait conditions so that all DCE-KMD
                      core modules can reuse them.

- Additionally, this change will also remove unused functions
  and macros from dce-os-cond.c/.h

- dce-client-ipc will also switch to use dce-wait-cond interface
  for client ipc waits.

- Make dce-os-cond.h a common file and move OS specific impl
  to dce-os-cond-internal.h

JIRA TDS-16581

Change-Id: Ie8c6ec724e48cde66917fab4aa43e7da464ef8fb
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3258562
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
2025-07-24 10:19:13 +00:00
anupamg
0137495706 DCE-KMD: Make dce-client-ipc.c core file
- This change will remove linux nuances from dce-client-ipc.c
  file and make it a core DCE-KMD file agnostic to OS.

- To do that, dce-client-ipc module will repalce linux specific
  nuances for work queue related functionality with
  dce-os-work module.

- Further to support existing dce_client_ipc asyn callback function
  we need to make worker queue more generic by allowing clients
  to pass any data of their choice as data param to the
  callback function.

- Also take this opportunity to make following functions static:
    - dce_resume_work_fn()
    - dce_bootstrap_work_fn()

JIRA TDS-16581

Change-Id: I741b8675dd67ef932ee462e16cad016cbe8b7e2c
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3257808
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
2025-07-24 10:19:13 +00:00
anupamg
801a2e1d07 DCE-KMD: Update DCE OS Worker Queue abstraction
- This is pre-req to make dce-client-ipc.c a core file and use
  it for HVRTOS as well.

- dce-client-ipc.c uses worker queues today to manage async events.
  But instead of using existing dce-os-work abstraction it
  directly uses linux structs/calls.

- Current dce-os-work abstraction cannot be used as is for
  dce-client-ipc.c as it only allows scheduling work
  to system hipri work queue. But dce-client-ipc creates
  and schedules work to a new worker queue.

- To allow dce-client-ipc.c use exising dce-os-work abstraction,
  we need to make it more generic such that work can be scheduled
  either to a new queue or existing system hipri work queue.

- This CL will update worker queue abstraction to make it more generic
  and start using it for usecases which use default sys hipri WQ.

- There will be a follow-up CL for dce-client-ipc to start using
  this abstraction.

- Further, this change will also make WQ and work structs
  opaque and make dce-os-work.h a common header.

JIRA TDS-16126

Change-Id: I4d8a274a277f6dc08dc67847c1e3a3e35fb839b0
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3257738
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
2025-07-24 10:19:13 +00:00
anupamg
71f130a999 DCE-KMD: Address admin buffer sync access issue
- I2b8a24f9044bc08e10e5ff8cbf0c3f51fa53ff53 change introduced
  an issue of concurrent accesses of admin message buffer
  by different admin channel clients.

- This change will fix this issue by adding set of buffers per admin
  channel client.

- When a admin channel client wants to use a buffer it will
  have to request using it's client ID.
  Buffer will be granted only if at least one buffer for that client
  is not in use.

- Admin channel clients must release the buffer once done with the
  usage so that it's available for other accesses by the same client.

- Do we need a mutex to protect this array?
    1) There's no issue if different clients are trying to get/put
       buffers concurrently since each query will operate on
       separate per client array.
    2) We've an assumption that none of the clients will be active
       during init. This is also documented as part of function
       documentation.
    3) Will we ever have a usecase where a same client does
       get/put concurrently?
    4) Is it possible for a client to be active during de-init?

- If answer to 3 or 4 is yes then we still need a mutex to protect
  the buffers.
    - Currently we've assumed that there woudn't be concurrent
      operations during init/deinit and on same client so
      we're not introducing any mutex.

JIRA TDS-16126

Change-Id: I2ab640dc7c8ee6dedc9179dbb726368c3cb7d65f
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3249307
Reviewed-by: svcacv <svcacv@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
0becc78306 DCE-KMD: Add helper macro to check non NULL
- This is a follow-up CL to address a comment in
  I885348a09eaac6e4362c89b59880fbd32d77d3b5

- This change will add a  helper macro, DCE_WARN_ON_NOT_NULL(x),
  to print a warning message if the input param is not NULL.
    - Added to dce.h

JIRA TDS-16126

Change-Id: I9b2c4ea89fa1682d18c20f68b14ab7696917f261
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3251828
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
48cb79c312 DCE-KMD: Rename dce-worker.c/.h
- dce-worker.c has os specific implementations.

- Therefore rename it to dce-os-worker.c/.h.

- Also rename functions accordingly.

JIRA TDS-16126

Change-Id: I8e1301659c65cca7c3735f4af1f1a7039409cbbe
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3233180
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
7970c223dc DCE-KMD: OS abstraction renaming
- Rename following functions from dce-os-utils.c from
  dce_*() to dce_os_*()
    dce_get_phys_stream_id
    dce_get_dce_stream_id
    dce_get_fw_vm_index
    dce_get_fw_carveout_id
    dce_is_physical_id_valid
    dce_get_fw_dce_addr
    dce_get_fw_phy_addr
    dce_get_fw_name
    dce_thread*
    dce_ipc_init_region_info
    dce_ipc_de_init_region_info

- Move include/dce-thread.h to
  os/linux/include/dce-os-thread.h

JIRA TDS-16126

Change-Id: I42bfe95aa81823dc077ae0964eb6288a1f25fc17
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3233170
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
c0e60a639a DCE-KMD: Update DCE OS abstraction - Part 6
Module covered: dce-workqueue

This is not a functional change. It does the following:
1) Move include/dce-workqueue.h to
   os/linux/include/dce-os-work.h

2) s/dce_work/dce_os_work/g

3) s/dce_init_work/dce_os_work_init/g

4) s/dce_schedule_work/dce_os_work_schedule/g

5) Remove intermediate os header os/include/os-dce-workqueue.h
   and replace all includes directly with <dce-os-work.h>

JIRA TDS-16126

Change-Id: I4d88cf68a187a061fd0c8c084ea074fb9e74d315
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3228552
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
562347a94e DCE-KMD: Update DCE OS abstraction - Part 4
Module covered in this CL: dce-cond

This is not a functional CL. It does the following.
1) Move os/include/linux-kmd/os-cond.h to
   os/linux/include/dce-os-cond.h

2) s/dce_cond/dce_os_cond/g

3) s/DCE_COND/DCE_OS_COND/g

4) Delete intermediate include os/include/os-cond.h and replace
   all includes with <dce-os-cond.h>

JIRA TDS-16126

Change-Id: Ib4f3cbe5402b2abe114be89f36e25a6fe47e8b13
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3228543
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
ff65048da5 DCE-KMD: Update DCE OS abstraction - Part 3
Modules covered in this CL: dce-lock

This is not a function CL. It does the following:
1) Move dce-lock.h to os/linux/include/dce-os-lock.h
2) s/dce_mutex/dce_os_mutex/g
3) Remove intermediate includes previously introduced:
    a) Delete os/include/os-lock.h

JIRA TDS-16126

Change-Id: I994bcbf75ec87461c0dc2714b300d0ad1e3ee018
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3228541
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
ea36afee6c DCE-KMD: Update OS abstraction - Part 2
Modules covered in this CL:
1) dce-os-log

This is not a functional CL. It does the following:
1) Rename dce_<info/err/debug/warn> to
   dce_os_<info/err/debug/warn>

2) Rename dce_log_msg() to dce_os_log_msg()

3) Rename DCE_<WARNING/ERROR/INFO/DEBUG> to
   DCE_OS_<WARNING/ERROR/INFO/DEBUG>

4) Move dce-log.h to os/linux/include/dce-os-log.h

5) Stop using old abstraction:
    a) Replace <os-dce-log.h> includes with <dce-os-log.h>

6) Delete all related old deprecated log files:
    a) os/include/linux-kmd/os-dce-log.h
    b) os/include/os-dce-log.h

JIRA TDS-16126

Change-Id: I75ebe98a785c298678d80371184efae6e46932ee
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3228536
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
f03b71480a DCE-KMD: Add new DCE OS interface: types.h
- This change will add new DCE OS interface for types.h.

- This DCE OS interface layer will act as entry point to OS layer
  from core DCE-KMD code.

- The intended usage is as follows.
    - DCE-KMD core will include respective OS header file from
      DCE OS interface.
        Eg. In dce-fsm.c
            #include <dce-os-types.h>
    - DCE OS interface will further include OS specific files
        Eg. In dce-os-types.h
            #include <os-types.h>
    - OS specific files will reside in respective OS specific paths.
        Eg. for Linux the path will be
            kernel/nvidia-oot/../dce/os/include/linux/os-types.h
        For HVRTOS the path will be
            display/server/os/include/hvrtos/os-types.h
    - The OS specific paths will be directly included in respective
      OS makefiles during compilation so that we don't need to use
      ifdefs within DCE OS interface layer.

- This is first change to follow this convention for types.h.
  We will have follow-up CLs to follow this suite for all other
  OS dependencies for DCE-KMD.

JIRA TDS-16126

Change-Id: Ied7bee6eac5de9134b973e74020df200707afa10
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3224052
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
f5d25922eb DCE-KMD: admin: Allocate msg buffer at init time
- Reserve message buffer for DCE admin channel at init time
  since dynamic memory allocations are restricted on HVRTOS.
    - Free this during channel deinit.

- Use this reserved message buffer at all other callsites.

JIRA TDS-16052

Change-Id: I2b8a24f9044bc08e10e5ff8cbf0c3f51fa53ff53
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3180403
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
84e1c1d01f DCE-KMD: Decouple resources init and start logic
- In DCE_KMD, dce_fsm_start() schedules start of state machine
  functionality which involves the waiting for DCE-FW boot completion,
  IPC admin setup and communication etc.

- HVRTOS restricts certain functionalities like waiting on events,
  acquiring locks, etc in initialize phase.

- Also for HVRTOS we are executing worker queue work in same
  thread context directly from where it's called from.

- For above reasons, we need to decouple SW resource allocation and
  init logic and actual execution start logic which was part of
  dce_driver_init() earlier into 2 phases:
    - dce_driver_init()
        - This will do all resource allocation/init and will be called
          during resource initialization phase.
            - Module probe for Linux
            - Initialize() context for HVRTOS.
    - dce_driver_start()
        - This will start actual DCE logic execution after all
          resources are allocated and initialized and will be executed
          separately.
            - In Linux, both will be executed from the same probe
              while in HVRTOS, the former is in process initialize
              stage and dce_driver_start is run in the
              Thread initialize stage.

JIRA TDS-16052

Change-Id: I1176d748bc705106bb0c8ca7e647713abf2d4a00
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3192613
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
66b010a691 DCE-KMD: Use OS abstraction for work queue
- Start using OS abstraction for work queue.

JIRA TDS-16052

Change-Id: Ic8fa7b5aa38e92be1fd6dc1ddb07be4ecf7bad68
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3188432
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
6aed7136dd DCE-KMD: Decouple dce-thread.h from dce.h
- dce-thread.h only used in dce-util-common.c so move it from
  dce.h to dce-util-common.c

- The dce_thread*() APIs in dce-util-common.c are unused.

- This change is required to avoid creating these unused APIs
  for other OSs like HVRTOS.

JIRA TDS-16052

Change-Id: I67e5e7201671aa6ddc07bfb4a869c825fb53e6c5
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3172731
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
aec0d24ecd DCE-KMD: Use OS abstraction for condition vars
- Use OS abstraction added to display/drivers/server
  for OS condition variables support.

JIRA TDS-16052

Change-Id: If4ae2698308f1a037e5e0d6ec0c9724695a008d3
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3172718
Reviewed-by: Arun Swain <arswain@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
59ead11048 DCE-KMD: Use OS abstraction for locking
- Use OS abstraction added to display/drivers/server
  for OS locking support.

JIRA TDS-16052

Change-Id: I3678458e8cf62a29cc313c4b3abae38188eb0fa6
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3172702
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
4a07fca949 DCE-KMD: Use OS abstraction for logging
- Use OS abstraction added to display/drivers/server
  for OS logging support.

JIRA TDS-16052

Change-Id: I73f36f1c50b52f5323496bb6dc180b1bd8ddabe3
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3172655
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
0dfd61c0e7 DCE-KMD: Use OS abstraction for dce_device
- Use OS abstraction added to display/drivers/server
  for dce_device.

JIRA TDS-16052

Change-Id: I2339ad423ad38e8c3ba0f3205d80f172a4d0abe9
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3172565
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
2025-07-24 10:19:12 +00:00
anupamg
8533f2be4a DCE-KMD: Use OS abstraction for types.h
- DCE-KMD code is only compiled on Linux Kernel today. So it has
  some linux specific dependencies.

- We will be compiling the same code for new DispalySerer HVRTOS
  process. To support this we will need to abstract out OS
  specific dependencies from DCE-KMD.

- Common OS abstraction code will be developed under display/drivers/
  server/ repo.

- DCE-KMD will start using that os abtsaction and this is the first
  CL towards that effort.

JIRA TDS-16052

Change-Id: I51fba684ac285139225a2999338e73c724d9d499
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3167249
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
2025-07-24 10:19:12 +00:00
Mahesh Kumar
99b291c567 platform: dce: remove unused parameter
This patch removes unused parameter w_type from dce_admin_ipc_wait
function.

Jira TDS-15438

Change-Id: Ida2bbca042a32b5aede32821157995b4aaa2db47
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3236783
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2025-07-24 10:19:09 +00:00
Mahesh Kumar
9a401f8077 platform: dce: Halify HSP functions
This patch Halify HSP access functions. SOC-specific HSP functions
are assigned during driver prob based on of_device_is_compatible check.

Jira TDS-15438

Change-Id: Ia8d68cd658eaa06dd5d06e8ba92f32907a31fd4f
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3225858
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2025-07-24 10:19:09 +00:00
Laxman Dewangan
b20c5f57e3 dce: Use SPDX license GPL 2.0-only format
Use SPDX license GPL-V2.0 format and change Nvidia
copyright year to include 2023.

Bug 4078035

Change-Id: Icc0060431eb8d9c470a44f4cee50913cc1d8048a
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2890656
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-21 11:41:56 -07:00
Mahesh Kumar
873e421d95 platform: dce: Add Debugfs support for Perf
Add debugfs nodes
 - start/stop perf stats.
 - read perf stat stats
 - set the format type as csv or xml

Add debugfs to capture perf events
 - Can enable specific perf events
through debugfs node.

Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Change-Id: I0a7833d7a8f04296ba3806f4f2a218175080d2e2
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2765513
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
Tested-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 19:36:09 +00:00
Mahesh Kumar
387a379024 platform: dce: add wait in ipc registration
If DCE bootstrapping is not complete, client registration may fail or
result in IPC failures.
Wait for bootstrapping to complete before registering any IPC-Client.
Use high priority work queue to schedule bootstrap work.

Bug 3583331
Bug 3826630

Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Change-Id: I0facfe225e1550c795c2de7b42916416faa3bcaa
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2834857
Reviewed-by: Arun Swain <arswain@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2824219
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
2023-04-14 19:23:43 +00:00
Mahesh Kumar
75bfcf326d platform: dce: Add suspend resume hooks
Add suspend resume hooks function and handling of sc7 events.

Bug 3583331
Bug 3826630

Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Change-Id: I920b02ad46a76330febe666fe17e8d328f744b1d
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2834856
Reviewed-by: Arun Swain <arswain@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2824218
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
2023-04-14 19:23:43 +00:00
Adeel Raza
c032aa992e platform: tegra: dce: Add debugfs for external tests
External clients such as MODS require the ability to run tests. Add
support for this feature. Currently only the following 2 external client
tests are supported:
  - MODS ALU test
  - MODS DMA test

Bug 3198239
JIRA TDS-6362

Change-Id: I18c20a9fa5d2606056d65b76fbaae9b0c81746d4
Signed-off-by: Adeel Raza <araza@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2606595
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 19:23:43 +00:00
Mahesh Kumar
8ef1f2db87 platform: dce: FSM incremental fixes
This patch addresses design review comments for FSM
 - Add comment to update design doc on FSM update
 - Create wrapper function to check bootcmd complete status
 - move bootstrapping functions to dce_bootstrap.c file
 - Fix sw resource init/deinit function name

Bug 3583331

Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Change-Id: I77f05135f7ec1882922907f8acef50def639d26d
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2758902
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Mahesh Kumar
5aa80075ad platform: dce: remove use of of_irq_xxx
of_irq_xxx faimly of functions are not exported by Kernel.
use platform_irq_count and platform_get_irq APIs instead.

This patch also moves dce_platform_data elements to dce_device
struct to keep dce_platform_data constant.

Bug 3581824

Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Change-Id: I5ea13ea039ef1464e678f0604a045a6ab67bc16f
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2755141
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Mahesh Kumar
df0f2d1a74 platform: dce: add support for multiple HSP
Change-Id: Ia6d3278b89f5ba34bd6bbbd80820279e4e06fc0b
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2727625
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 19:23:43 +00:00
Mahesh Kumar
28a1cfd1c1 platform: dce: reworked dce FSM design
Redesign DCE KMD drive state machine to handle new PM events.

Bug 3583331

Change-Id: I89adcfa2f311a9a1e86b70e14821468203365266
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2673665
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Mahesh Kumar
a6cc70f8d5 platform: dce: remove debugfs on deinit
Current code does not remove debugfs node on deinit.
This patch fixes the same.

Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Change-Id: I9ceb78b73d71aca0a2363df0408bf6a85ca91834
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2743215
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Mahesh Kumar
716c1f3cdb platform: dce: functionality fixes
This patch make changes to

declare of_device_id __weak so that other declarations
can take precedence.
validate return value from find_first_bit function to avoid overflow
when No bits are set.
%s/dce_stream_id/stream_id/

Jira TDS-9583

Change-Id: I85c681b904c7a4f9df76ec8387231a17de2e6d77
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2645913
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
2023-04-14 19:23:43 +00:00
Sahil Mukund Patki
e384d775a5 platform: tegra: dce: fix debugfs compilation error
The file dce-debug.c is only used when CONFIG_DEBUG_FS is enabled.
Compilation errors occur when CONFIG_DEBUG_FS is disabled.
Moreover the function "dce_init_debug" is defined in dce-debug.c.
Since compilation of this file only occurs when debugfs is enabled,
the declaration of the function should only be done when debugfs is
enabled.

This patch fixes the compilation errors by compiling the above
mentioned file only when debugfs is enabled. Also the declaration of
"dce_init_debug" is guarded by CONFIG_DEBUG_FS since it is only used
when debugfs is enabled.

Bug 200755555

Change-Id: I0077e0c7a722ed515b0bcdfdd82c94a371f5aae3
Signed-off-by: Sahil Mukund Patki <spatki@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2583640
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Pritesh Raithatha <praithatha@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Mahesh Kumar
4730a3c30c platform: tegra: dce: Add debugfs for echo cmd
This patch adds a debug node to send ADMIN_ECHO commands to the DCE.
node takes number of echo commands to be sent as input.

JIRA TDS-5692

Change-Id: If3cfcef3b0ac703754ee9a4146ab417978cdbe46
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2487659
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Adeel Raza <araza@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Mahesh Kumar
4653b0d74e platform: tegra: dce: Admin rpc post boot support
Current code assumes no RPC message on Admin-channel post boot. So
 - Admin RPC reply post-boot are not passed to the process issuing the
RPC instead expect dce_worker to handle the reply.
 - dce_worker doesn't wait for > 1 RPC reply from DCE-Core post boot.

This patch Adds support to send RPC over Admin channel post boot and
also adds support to wake-up the process issued RPC and waiting for
reply.

JIRA TDS-6381

Change-Id: Ifa85f8686c4aee86eb8efc69f85e552ca6f605c5
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2500788
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 19:23:43 +00:00
Mahesh Kumar
35242999ff platform: tegra: dce: Add WQ to handle async IPC
In current code RPC ack events are handled by thread issuing RPC but
Async-IPC events are handled in the bottom-half with interrupt disabled.
This may delay delivery of RPC ack if async-IPC handling is hogging the
CPU. It can also lead to a race condition where the RPC caller takes
the lock, issues a RPC and waits for a reply. And in-between KMD receives
an Async IPC and wants to take the same lock.
As IPC code is running with interrupt disabled, RPC-reply interrupt will
not be notified and will result in a deadlock.

This patch creates a Workqueue to handle Async IPC events.

JIRA TDS-6381

Change-Id: If7d69ef50298ad9364e9e494a32cf483ecfb744e
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2485764
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: Adeel Raza <araza@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Mahesh Kumar
dc3e980731 tegra: dce: Add debugfs node to show boot status
This patch adds a debugfs node to show DCE boot status.

It also adds following dce boot marker in logs
  - DCE_BOOT_DONE
  - DCE_BOOT_FAILED

JIRA TDS-5691

Change-Id: Iada5c1234e5e5f1a5e7afd88dcb94c2da6a3fe1c
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2361287
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: Santosh Galma <galmar@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Arun Swain
606f03fbf2 platform: tegra: dce: add dce kernel driver
For T23x, we have a separate R5 based cluster
named as Display Controller Engine(DCE) to run
our Display RM code. This driver will run on CPU
with the following functionality:

Via debugfs for test and bring-up purposes:
1. Reads the DCE firmware image into DRAM.
2. Sets up DCE AST to cover the DCE firmware image.
3. Sets up R5 reset vector to point to DCE firmware
entry point
4. Brings DCE out of reset
5. Dumps various regsiters for debug

In production env:
1. Manages interrupts to CPU from DCE
2. Uses bootstrap command interface to define Admin
IPC
3. Locks down bootstrap command interface
4. Uses Admin IPC to define message IPC
5. Uses Admin IPC to define message IPC payload area
6. Uses Admin IPC to set IPC channels
6. Uses Admin IPC to define crashdump area
(optional)
7. Provides IPC interfaces for any DCE Client running
on CCPLEX including Display RM.
8. Uses Admin IPC to set logging level (optional)

This patch puts a framework in place with the
following features :
1. Firmware Loading
2. AST Configuration
3. DCE Reset with EVP Programming
4. Logging Infra
5. Debugfs Support
6. Interrupt Handling
7. Mailbox Programming
8. IPC Programming
9. DCE Client Interface
10. Ftrace Support for debug purposes

Change-Id: Idd28cd9254706c7313f531fcadaa7024a5b344e7
Signed-off-by: Arun Swain <arswain@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2289865
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: Mitch Luban <mluban@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Mahesh Kumar <mahkumar@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 19:23:43 +00:00