diff options
Diffstat (limited to 'nvdebug.h')
| -rw-r--r-- | nvdebug.h | 293 |
1 files changed, 288 insertions, 5 deletions
| @@ -2,6 +2,7 @@ | |||
| 2 | * SPDX-License-Identifier: MIT | 2 | * SPDX-License-Identifier: MIT |
| 3 | * | 3 | * |
| 4 | * File outline: | 4 | * File outline: |
| 5 | * - Configuration options | ||
| 5 | * - Runlist, preemption, and channel control (FIFO) | 6 | * - Runlist, preemption, and channel control (FIFO) |
| 6 | * - Basic GPU information (MC) | 7 | * - Basic GPU information (MC) |
| 7 | * - Detailed GPU information (PTOP, FUSE, and CE) | 8 | * - Detailed GPU information (PTOP, FUSE, and CE) |
| @@ -20,6 +21,27 @@ | |||
| 20 | // this, so declare as incomplete type to avoid pulling in the nvgpu headers. | 21 | // this, so declare as incomplete type to avoid pulling in the nvgpu headers. |
| 21 | struct gk20a; | 22 | struct gk20a; |
| 22 | 23 | ||
| 24 | // Uncomment to, upon BAR2 access failure, return a PRAMIN-based runlist pointer | ||
| 25 | // in get_runlist_iter(). In order for this pointer to remain valid, PRAMIN | ||
| 26 | // **must** not be moved during runlist traversal. | ||
| 27 | // - The Jetson TX2 has no BAR2, and stores the runlist in VID_MEM, so this | ||
| 28 | // must be enabled to print the runlist on the TX2. | ||
| 29 | // - On the A100 in Google Cloud and H100 in Paperspace, as of Aug 2024, this is | ||
| 30 | // needed, as nvdebug is not finding (at least) runlist0 mapped in BAR2/3. | ||
| 31 | // Automatically disables printing Instance Block and Context State while | ||
| 32 | // traversing the runlist, as these require conflicting uses of PRAMIN (it's | ||
| 33 | // needed to search the page tables for the Instance Block in BAR2/3, and to | ||
| 34 | // access anything in the Context State---aka CTXSW). | ||
| 35 | #define FALLBACK_TO_PRAMIN | ||
| 36 | |||
| 37 | // Starting offset for registers in the corresponding named range | ||
| 38 | // Programmable First-In First-Out unit; also known as "Host" | ||
| 39 | #define NV_PFIFO 0x00002000 // 8 KiB long; ends prior to 0x00004000 | ||
| 40 | // Programmable Channel Control System RAM | ||
| 41 | #define NV_PCCSR 0x00800000 // 16 KiB long; ends prior to 0x00810000 | ||
| 42 | // Programmable TOPology registers | ||
| 43 | #define NV_PTOP 0x00022400 // 1 KiB long; ends prior to 0x00022800 | ||
| 44 | |||
| 23 | /* Runlist Channel | 45 | /* Runlist Channel |
| 24 | A timeslice group (TSG) is composed of channels. Each channel is a FIFO queue | 46 | A timeslice group (TSG) is composed of channels. Each channel is a FIFO queue |
| 25 | of GPU commands. These commands are typically queued from userspace. | 47 | of GPU commands. These commands are typically queued from userspace. |
| @@ -202,7 +224,7 @@ typedef union { | |||
| 202 | Support: Ampere, Hopper, Ada, [newer untested] | 224 | Support: Ampere, Hopper, Ada, [newer untested] |
| 203 | */ | 225 | */ |
| 204 | #define NV_RUNLIST_PREEMPT_GA100 0x098 | 226 | #define NV_RUNLIST_PREEMPT_GA100 0x098 |
| 205 | #define PREEMPT_TYPE_RUNLIST 0 | 227 | #define PREEMPT_TYPE_RUNLIST PREEMPT_TYPE_CHANNEL |
| 206 | 228 | ||
| 207 | /* | 229 | /* |
| 208 | "Initiate a preempt of the engine by writing the bit associated with its | 230 | "Initiate a preempt of the engine by writing the bit associated with its |
| @@ -355,6 +377,14 @@ typedef union { | |||
| 355 | uint64_t raw; | 377 | uint64_t raw; |
| 356 | } runlist_base_tu102_t; | 378 | } runlist_base_tu102_t; |
| 357 | 379 | ||
| 380 | /* | ||
| 381 | LEN : Read/Write | ||
| 382 | OFFSET : Read/Write | ||
| 383 | PREEMPTED_TSGID : Read-only | ||
| 384 | VALID_PREEMPTED_TSGID : Read-only | ||
| 385 | IS_PENDING : Read-only | ||
| 386 | PREEMPTED_OFFSET : Read-only | ||
| 387 | */ | ||
| 358 | typedef union { | 388 | typedef union { |
| 359 | struct { | 389 | struct { |
| 360 | uint16_t len:16; | 390 | uint16_t len:16; |
| @@ -416,6 +446,27 @@ typedef union { | |||
| 416 | uint32_t raw; | 446 | uint32_t raw; |
| 417 | } runlist_channel_config_t; | 447 | } runlist_channel_config_t; |
| 418 | 448 | ||
| 449 | /* Context Switch Timeout Configuration | ||
| 450 | After a task's budget expires, there's a configurable grace period, a | ||
| 451 | "timeout", within which the context needs to complete. After this timeout | ||
| 452 | expires, an interrupt is raised to terminate the task. | ||
| 453 | |||
| 454 | This register configures if such a timeout is enabled and how long the | ||
| 455 | timeout is (the "period"). | ||
| 456 | |||
| 457 | Support: Volta, Turing | ||
| 458 | */ | ||
| 459 | #define NV_PFIFO_ENG_CTXSW_TIMEOUT 0x00002A0C | ||
| 460 | // Support: Ampere | ||
| 461 | #define NV_RUNLIST_ENGINE_CTXSW_TIMEOUT_CONFIG(i) (0x220+(i)*64) | ||
| 462 | typedef union { | ||
| 463 | struct { | ||
| 464 | uint32_t period:31; | ||
| 465 | bool enabled:1; | ||
| 466 | } __attribute__((packed)); | ||
| 467 | uint32_t raw; | ||
| 468 | } ctxsw_timeout_t; | ||
| 469 | |||
| 419 | /* Programmable Channel Control System RAM (PCCSR) | 470 | /* Programmable Channel Control System RAM (PCCSR) |
| 420 | 512-entry array of channel control and status data structures. | 471 | 512-entry array of channel control and status data structures. |
| 421 | 472 | ||
| @@ -477,8 +528,15 @@ typedef union { | |||
| 477 | bool busy:1; | 528 | bool busy:1; |
| 478 | uint32_t :3; | 529 | uint32_t :3; |
| 479 | } __attribute__((packed)); | 530 | } __attribute__((packed)); |
| 531 | struct { | ||
| 532 | uint32_t word1; | ||
| 533 | uint32_t word2; | ||
| 534 | } __attribute__((packed)); | ||
| 480 | uint64_t raw; | 535 | uint64_t raw; |
| 481 | } channel_ctrl_t; | 536 | } channel_ctrl_gf100_t; |
| 537 | |||
| 538 | // TODO: Remove use of deprecated type name | ||
| 539 | typedef channel_ctrl_gf100_t channel_ctrl_t; | ||
| 482 | 540 | ||
| 483 | /* CHannel RAM (CHRAM) (PCCSR replacement on Ampere+) | 541 | /* CHannel RAM (CHRAM) (PCCSR replacement on Ampere+) |
| 484 | Starting with Ampere, channel IDs are no longer unique indexes into the | 542 | Starting with Ampere, channel IDs are no longer unique indexes into the |
| @@ -543,6 +601,8 @@ typedef union { | |||
| 543 | Support: Fermi, Kepler, Maxwell, Pascal, Volta, Turing | 601 | Support: Fermi, Kepler, Maxwell, Pascal, Volta, Turing |
| 544 | */ | 602 | */ |
| 545 | #define NV_PFIFO_SCHED_DISABLE 0x00002630 | 603 | #define NV_PFIFO_SCHED_DISABLE 0x00002630 |
| 604 | // Support: Ampere | ||
| 605 | #define NV_RUNLIST_SCHED_DISABLE 0x094 | ||
| 546 | typedef union { | 606 | typedef union { |
| 547 | struct { | 607 | struct { |
| 548 | bool runlist_0:1; | 608 | bool runlist_0:1; |
| @@ -1018,7 +1078,7 @@ typedef union { | |||
| 1018 | struct { | 1078 | struct { |
| 1019 | uint32_t ptr:28; | 1079 | uint32_t ptr:28; |
| 1020 | enum INST_TARGET target:2; | 1080 | enum INST_TARGET target:2; |
| 1021 | uint32_t :1; | 1081 | uint32_t :1; // disable_cya_debug for BAR2 |
| 1022 | bool is_virtual:1; | 1082 | bool is_virtual:1; |
| 1023 | } __attribute__((packed)); | 1083 | } __attribute__((packed)); |
| 1024 | uint32_t raw; | 1084 | uint32_t raw; |
| @@ -1091,6 +1151,9 @@ typedef union { | |||
| 1091 | Support: Tesla 2.0* through Ampere, Ada | 1151 | Support: Tesla 2.0* through Ampere, Ada |
| 1092 | *FAULT_REPLAY_* fields are Pascal+ only | 1152 | *FAULT_REPLAY_* fields are Pascal+ only |
| 1093 | See also: dev_ram.h (open-gpu-kernel-modules) or dev_ram.ref.txt (open-gpu-doc) | 1153 | See also: dev_ram.h (open-gpu-kernel-modules) or dev_ram.ref.txt (open-gpu-doc) |
| 1154 | |||
| 1155 | It appears that on Hopper, IS_VER2 continues to mean IS_VER2, but if unset, the | ||
| 1156 | alternative is VER3. | ||
| 1094 | */ | 1157 | */ |
| 1095 | #define NV_PRAMIN_PDB_CONFIG_OFF 0x200 | 1158 | #define NV_PRAMIN_PDB_CONFIG_OFF 0x200 |
| 1096 | typedef union { | 1159 | typedef union { |
| @@ -1101,7 +1164,7 @@ typedef union { | |||
| 1101 | bool fault_replay_tex:1; | 1164 | bool fault_replay_tex:1; |
| 1102 | bool fault_replay_gcc:1; | 1165 | bool fault_replay_gcc:1; |
| 1103 | uint32_t :4; | 1166 | uint32_t :4; |
| 1104 | bool is_ver2:1; | 1167 | bool is_ver2:1; // XXX: Not on Hopper. May be set or not for same page_dir. |
| 1105 | bool is_64k_big_page:1; // 128Kb otherwise | 1168 | bool is_64k_big_page:1; // 128Kb otherwise |
| 1106 | uint32_t page_dir_lo:20; | 1169 | uint32_t page_dir_lo:20; |
| 1107 | uint32_t page_dir_hi:32; | 1170 | uint32_t page_dir_hi:32; |
| @@ -1421,6 +1484,182 @@ typedef union { | |||
| 1421 | } page_tbl_entry_v0_t; | 1484 | } page_tbl_entry_v0_t; |
| 1422 | */ | 1485 | */ |
| 1423 | 1486 | ||
| 1487 | /* Fifo Context RAM (RAMFC) and channel INstance RAM (RAMIN) | ||
| 1488 | |||
| 1489 | Each channel is configured with a 4 KiB instance block. The prefix of this | ||
| 1490 | block is referred to as RAMFC and stores channel-specific state for the Host | ||
| 1491 | (aka PFIFO). | ||
| 1492 | |||
| 1493 | "A GPU instance block is a block of memory that contains the state | ||
| 1494 | for a GPU context. A GPU context's instance block consists of Host state, | ||
| 1495 | pointers to each engine's state, and memory management state. A GPU instance | ||
| 1496 | block also contains a pointer to a block of memory that contains that part of a | ||
| 1497 | GPU context's state that a user-level driver may access. A GPU instance block | ||
| 1498 | fits within a single 4K-byte page of memory." | ||
| 1499 | |||
| 1500 | "The NV_RAMFC part of a GPU-instance block contains Host's part of a virtual | ||
| 1501 | GPU's state. Host is referred to as "FIFO". "FC" stands for FIFO Context. | ||
| 1502 | When Host switches from serving one GPU context to serving a second, Host saves | ||
| 1503 | state for the first GPU context to the first GPU context's RAMFC area, and loads | ||
| 1504 | state for the second GPU context from the second GPU context's RAMFC area." | ||
| 1505 | |||
| 1506 | "Every Host word entry in RAMFC directly corresponds to a PRI-accessible | ||
| 1507 | register. For a description of the contents of a RAMFC entry, please see the | ||
| 1508 | description of the corresponding register in "manuals/dev_pbdma.ref". The | ||
| 1509 | offsets of the fields within each entry in RAMFC match those of the | ||
| 1510 | corresponding register in the associated PBDMA unit's PRI space." | ||
| 1511 | |||
| 1512 | In summary, RAMFC includes details such as the head and tail of the pushbuffer, | ||
| 1513 | and RAMIN includes details such as the page table configuration(s). | ||
| 1514 | |||
| 1515 | The instance-global page table (as defined in the PDB field) is only used for | ||
| 1516 | GPU engines which do not support subcontexts (non-VEID engines). | ||
| 1517 | |||
| 1518 | **Not all documented fields are currently populated below.** | ||
| 1519 | |||
| 1520 | Support: *Kepler, *Maxwell, *Pascal, Volta, Turing, Ampere, [newer untested] | ||
| 1521 | *Pre-Volta GPUs do not support subcontexts. | ||
| 1522 | See also: dev_ram.ref.txt and dev_pbdma.ref.txt in NVIDIA's open-gpu-doc | ||
| 1523 | */ | ||
| 1524 | |||
| 1525 | // 16-byte (128-bit) substructure defining a subcontext configuration | ||
| 1526 | typedef struct { | ||
| 1527 | page_dir_config_t pdb; | ||
| 1528 | uint32_t pasid:20; // Process Address Space ID (PASID) used for ATS | ||
| 1529 | uint32_t :11; | ||
| 1530 | bool enable_ats:1; // Enable Address Translation Services (ATS)? | ||
| 1531 | uint32_t pad; | ||
| 1532 | } __attribute__((packed)) subcontext_ctrl_t; | ||
| 1533 | |||
| 1534 | typedef struct { | ||
| 1535 | // Start RAMFC (512 bytes) | ||
| 1536 | uint32_t pad[43]; | ||
| 1537 | uint32_t fc_target:5; // NV_RAMFC_TARGET; off 43 | ||
| 1538 | uint32_t :27; | ||
| 1539 | uint32_t pad2[17]; | ||
| 1540 | uint32_t fc_config_l2:1; // NV_RAMFC_CONFIG; off 61 | ||
| 1541 | uint32_t :3; | ||
| 1542 | uint32_t fc_config_ce_split:1; | ||
| 1543 | uint32_t fc_config_ce_no_throttle:1; | ||
| 1544 | uint32_t :2; | ||
| 1545 | uint32_t fc_config_is_priv:1; // ...AUTH_LEVEL | ||
| 1546 | uint32_t :3; | ||
| 1547 | uint32_t fc_config_userd_writeback:1; // ...USERD_WRITEBACK | ||
| 1548 | uint32_t :19; | ||
| 1549 | uint32_t pad3[1]; | ||
| 1550 | uint32_t fc_chan_info_scg:1; // ...SET_CHANNEL_INFO_SCG_TYPE | ||
| 1551 | uint32_t :7; | ||
