drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c- Extension
.c- Size
- 17251 bytes
- Lines
- 616
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
amdgpu.hnbio/nbio_2_3_offset.hnbio/nbio_2_3_sh_mask.hgc/gc_10_1_0_offset.hgc/gc_10_1_0_sh_mask.hsoc15.hnavi10_ih.hsoc15_common.hmxgpu_nv.hamdgpu_reset.h
Detected Declarations
function filesfunction xgpu_nv_mailbox_set_validfunction xgpu_nv_mailbox_peek_msgfunction xgpu_nv_mailbox_rcv_msgfunction xgpu_nv_peek_ackfunction xgpu_nv_poll_ackfunction xgpu_nv_poll_msgfunction xgpu_nv_mailbox_trans_msgfunction xgpu_nv_send_access_requests_with_paramfunction xgpu_nv_send_access_requestsfunction xgpu_nv_request_resetfunction xgpu_nv_request_full_gpu_accessfunction xgpu_nv_release_full_gpu_accessfunction xgpu_nv_request_init_datafunction xgpu_nv_mailbox_ack_irqfunction xgpu_nv_set_mailbox_ack_irqfunction xgpu_nv_ready_to_resetfunction xgpu_nv_wait_resetfunction xgpu_nv_mailbox_flr_workfunction xgpu_nv_mailbox_req_bad_pages_workfunction xgpu_nv_mailbox_handle_bad_pages_workfunction xgpu_nv_set_mailbox_rcv_irqfunction xgpu_nv_mailbox_rcv_irqfunction xgpu_nv_mailbox_set_irq_funcsfunction xgpu_nv_mailbox_add_irq_idfunction xgpu_nv_mailbox_get_irqfunction xgpu_nv_mailbox_put_irqfunction xgpu_nv_ras_poison_handlerfunction xgpu_nv_rcvd_ras_intrfunction xgpu_nv_req_ras_err_countfunction xgpu_nv_req_ras_cper_dumpfunction xgpu_nv_req_ras_bad_pagesfunction xgpu_nv_check_vf_critical_regionfunction xgpu_nv_req_remote_ras_cmd
Annotated Snippet
if (!r) {
dev_dbg(adev->dev, "rcv_msg 0x%x after %llu ms\n",
event, NV_MAILBOX_POLL_MSG_TIMEDOUT - timeout + now);
return 0;
} else if (r == -ENODEV) {
if (!amdgpu_ras_is_rma(adev)) {
ras->is_rma = true;
dev_err(adev->dev, "VF is in an unrecoverable state. "
"Runtime Services are halted.\n");
}
return r;
}
msleep(10);
now = (uint64_t)ktime_to_ms(ktime_get());
} while (timeout > now);
dev_dbg(adev->dev, "nv_poll_msg timed out\n");
return -ETIME;
}
static void xgpu_nv_mailbox_trans_msg (struct amdgpu_device *adev,
enum idh_request req, u32 data1, u32 data2, u32 data3)
{
int r;
uint8_t trn;
/* IMPORTANT:
* clear TRN_MSG_VALID valid to clear host's RCV_MSG_ACK
* and with host's RCV_MSG_ACK cleared hw automatically clear host's RCV_MSG_ACK
* which lead to VF's TRN_MSG_ACK cleared, otherwise below xgpu_nv_poll_ack()
* will return immediatly
*/
do {
xgpu_nv_mailbox_set_valid(adev, false);
trn = xgpu_nv_peek_ack(adev);
if (trn) {
dev_err_ratelimited(adev->dev, "trn=%x ACK should not assert! wait again !\n", trn);
msleep(1);
}
} while (trn);
dev_dbg(adev->dev, "trans_msg req = 0x%x, data1 = 0x%x\n", req, data1);
WREG32_NO_KIQ(mmMAILBOX_MSGBUF_TRN_DW0, req);
WREG32_NO_KIQ(mmMAILBOX_MSGBUF_TRN_DW1, data1);
WREG32_NO_KIQ(mmMAILBOX_MSGBUF_TRN_DW2, data2);
WREG32_NO_KIQ(mmMAILBOX_MSGBUF_TRN_DW3, data3);
xgpu_nv_mailbox_set_valid(adev, true);
/* start to poll ack */
r = xgpu_nv_poll_ack(adev);
if (r)
dev_err(adev->dev, "Doesn't get ack from pf, continue\n");
xgpu_nv_mailbox_set_valid(adev, false);
}
static int xgpu_nv_send_access_requests_with_param(struct amdgpu_device *adev,
enum idh_request req, u32 data1, u32 data2, u32 data3)
{
struct amdgpu_virt *virt = &adev->virt;
int r = 0, retry = 1;
enum idh_event event = -1;
mutex_lock(&virt->access_req_mutex);
send_request:
if (amdgpu_ras_is_rma(adev)) {
r = -ENODEV;
goto out;
}
xgpu_nv_mailbox_trans_msg(adev, req, data1, data2, data3);
switch (req) {
case IDH_REQ_GPU_INIT_ACCESS:
case IDH_REQ_GPU_FINI_ACCESS:
case IDH_REQ_GPU_RESET_ACCESS:
event = IDH_READY_TO_ACCESS_GPU;
break;
case IDH_REQ_GPU_INIT_DATA:
event = IDH_REQ_GPU_INIT_DATA_READY;
break;
case IDH_RAS_POISON:
if (data1 != 0)
event = IDH_RAS_POISON_READY;
break;
case IDH_REQ_RAS_ERROR_COUNT:
event = IDH_RAS_ERROR_COUNT_READY;
Annotation
- Immediate include surface: `amdgpu.h`, `nbio/nbio_2_3_offset.h`, `nbio/nbio_2_3_sh_mask.h`, `gc/gc_10_1_0_offset.h`, `gc/gc_10_1_0_sh_mask.h`, `soc15.h`, `navi10_ih.h`, `soc15_common.h`.
- Detected declarations: `function files`, `function xgpu_nv_mailbox_set_valid`, `function xgpu_nv_mailbox_peek_msg`, `function xgpu_nv_mailbox_rcv_msg`, `function xgpu_nv_peek_ack`, `function xgpu_nv_poll_ack`, `function xgpu_nv_poll_msg`, `function xgpu_nv_mailbox_trans_msg`, `function xgpu_nv_send_access_requests_with_param`, `function xgpu_nv_send_access_requests`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.