diff options
Diffstat (limited to 'wiki/Error-Codes.md')
| -rw-r--r-- | wiki/Error-Codes.md | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/wiki/Error-Codes.md b/wiki/Error-Codes.md new file mode 100644 index 0000000..c61da06 --- /dev/null +++ b/wiki/Error-Codes.md @@ -0,0 +1,198 @@ +# GSP Error Codes + +## Standard POSIX Errors (Negative Return Values) + +| Code | Hex | Name | Description | +|------|-----|------|-------------| +| 0 | 0x00000000 | OK | Success | +| -1 | 0xFFFFFFFF | EPERM | Operation not permitted | +| -2 | 0xFFFFFFFE | ENOENT | No such file/entry | +| -3 | 0xFFFFFFFD | EINVAL | Invalid argument | +| -6 | 0xFFFFFFFA | ENODEV | No such device | +| -12 | 0xFFFFFFF4 | ENOMEM | Out of memory | +| -16 | 0xFFFFFFEE | EBUSY | Device/resource busy | +| -22 | 0xFFFFFFEA | EINVAL | Invalid argument | +| -28 | 0xFFFFFFE4 | ENOSPC | No space left on device | +| -37 | 0xFFFFFFDB | ENOLCK | No locks available | +| -56 | 0xFFFFFFC8 | EBADMSG | Bad message | +| -84 | 0xFFFFFFAC | EOVERFLOW | Value too large | +| -90 | 0xFFFFA6 | ENOSTR | Not a stream | +| -91 | 0xFFFFA5 | ENODATA | No data available | +| -94 | 0xFFFFA2 | ENOSR | Out of streams resources | +| -97 | 0xFFFFFF9F | EPROTO | Protocol error | +| -111 | 0xFFFFFF91 | ETIMEDOUT | Connection timed out | + +## GSP-Specific Error Codes (Observed in Firmware) + +### Memory Errors +| Code | Hex | Name | Description | +|------|-----|------|-------------| +| 0x1E | 0x0000001E | ETIME | WPR/RPC timeout | +| 0x1F | 0x0000001F | EDEV | Device error | +| 0x25 | 0x00000025 | EOVERFLOW | Region/offset overflow | +| 0x37 | 0x00000037 | EINVAL | Invalid alignment/size | +| 0x51 | 0x00000051 | ENOMEM | Allocator exhausted | +| 0x56 | 0x00000056 | EBUSY | Resource busy | +| 0xFFFF | 0xFFFFFFFF | EPERM | Permission denied | + +### RPC Errors +| Code | Hex | Name | Description | +|------|-----|------|-------------| +| 0x1D | 0x0000001D | EFAULT | Bad address in RPC | +| 0x1E | 0x0000001E | ETIMEDOUT | RPC timeout | +| 0x1F | 0x0000001F | EPROTO | Protocol violation | +| 0x20 | 0x00000020 | EBADRPC | Invalid RPC type | +| 0x21 | 0x00000021 | EBADSEQ | Sequence mismatch | +| 0x22 | 0x00000022 | EBADSIZE | Payload size error | + +### BAR Errors +| Code | Hex | Name | Description | +|------|-----|------|-------------| +| 0x30 | 0x00000030 | EBARINVAL | Invalid BAR index | +| 0x31 | 0x00000031 | EBARPERM | BAR access denied | +| 0x32 | 0x00000032 | EBARSIZE | Aperture size error | +| 0x33 | 0x00000033 | EBARALIGN | Alignment error | +| 0x34 | 0x00000034 | EBARRANGE | Offset out of range | +| 0x35 | 0x00000035 | EBARBUSY | BAR busy | + +### WPR Errors +| Code | Hex | Name | Description | +|------|-----|------|-------------| +| 0x40 | 0x00000040 | EWPRINVAL | Invalid WPR region | +| 0x41 | 0x00000041 | EWPRPERM | WPR permission denied | +| 0x42 | 0x00000042 | EWPROVERLAP | Overlapping WPR regions | +| 0x43 | 0x00000043 | EWPRBUSY | WPR operation in progress | +| 0x44 | 0x00000044 | EWPRTIMEOUT | WPR timeout | + +### Migration Errors +| Code | Hex | Name | Description | +|------|-----|------|-------------| +| 0x50 | 0x00000050 | EMIGINVAL | Invalid migration phase | +| 0x51 | 0x00000051 | EMIGNOMEM | Migration buffer OOM | +| 0x52 | 0x00000052 | EMIGBUSY | Migration in progress | +| 0x53 | 0x00000053 | EMIGPHASE | Phase mismatch | +| 0x54 | 0x00000054 | EMIGVERIFY | Verification failed | +| 0x55 | 0x00000055 | EMIGCOMMIT | Commit failed | +| 0x56 | 0x00000056 | EMIGABORT | Migration aborted | + +### Scheduler Errors +| Code | Hex | Name | Description | +|------|-----|------|-------------| +| 0x60 | 0x00000060 | ESCHINVAL | Invalid schedule params | +| 0x61 | 0x00000061 | ESCHPRIO | Priority error | +| 0x62 | 0x00000062 | ESCHYIELD | Yield failed | +| 0x63 | 0x00000063 | ESCHPREEMPT | Preemption error | + +### Notification Errors +| Code | Hex | Name | Description | +|------|-----|------|-------------| +| 0x70 | 0x00000070 | ENOTIFYINVAL | Invalid notification | +| 0x71 | 0x00000071 | ENOTIFYBUSY | Notification queue full | +| 0x72 | 0x00000072 | ENOTIFYDROP | Notification dropped | + +## Error Code Mapping (Kernel Driver) + +```c +static int gsp_errno_to_errno(int gsp_err) { + switch (gsp_err) { + case 0: return 0; + case -1: return -EPERM; + case -2: return -ENOENT; + case -3: return -EINVAL; + case -6: return -ENODEV; + case -12: return -ENOMEM; + case -16: return -EBUSY; + case -22: return -EINVAL; + case -28: return -ENOSPC; + case -37: return -ENOLCK; + case -56: return -EBADMSG; + case -84: return -EOVERFLOW; + case -90: return -ENOSTR; + case -91: return -ENODATA; + case -94: return -ENOSR; + case -97: return -EPROTO; + case -111: return -ETIMEDOUT; + + // GSP-specific + case 0x1E: return -ETIMEDOUT; + case 0x1F: return -EIO; + case 0x25: return -EOVERFLOW; + case 0x37: return -EINVAL; + case 0x51: return -ENOMEM; + case 0x56: return -EBUSY; + case 0xFFFF: return -EPERM; + + // BAR + case 0x30: return -EINVAL; + case 0x31: return -EPERM; + case 0x32: return -EINVAL; + case 0x33: return -EINVAL; + case 0x34: return -ERANGE; + case 0x35: return -EBUSY; + + // WPR + case 0x40: return -EINVAL; + case 0x41: return -EPERM; + case 0x42: return -EEXIST; + case 0x43: return -EBUSY; + case 0x44: return -ETIMEDOUT; + + // Migration + case 0x50: return -EINVAL; + case 0x51: return -ENOMEM; + case 0x52: return -EBUSY; + case 0x53: return -EINVAL; + case 0x54: return -EIO; + case 0x55: return -EIO; + case 0x56: return -ECANCELED; + + // Scheduler + case 0x60: return -EINVAL; + case 0x61: return -EINVAL; + case 0x62: return -EAGAIN; + case 0x63: return -EAGAIN; + + // Notification + case 0x70: return -EINVAL; + case 0x71: return -EAGAIN; + case 0x72: return -ENOBUFS; + + default: return -EIO; + } +} +``` + +## Debugging Error Codes + +### GSP Log Format +``` +GSP_ERROR: rpc_type=0x0A seq=0x1234 err=0x31 (EBARPERM) vf=2 addr=0x7F000000 +``` + +### Common Error Scenarios + +| Scenario | Error Code | Resolution | +|----------|------------|------------| +| VF writes to unmapped BAR | 0x31 (EBARPERM) | Check VF BAR config | +| Migration verify fails | 0x54 (EMIGVERIFY) | Check memory integrity | +| WPR timeout on page fault | 0x44 (EWPRTIMEOUT) | Increase timeout | +| RPC sequence mismatch | 0x21 (EBADSEQ) | Reset RPC client | +| Allocator exhausted | 0x51 (ENOMEM) | Free unused VF memory | +| BAR aperture too small | 0x32 (EBARSIZE) | Increase aperture | + +### Error Injection (Testing) +```c +// Inject errors for testing +#define GSP_INJECT_ERROR(rpc_type, err_code) \ + gsp_test_inject_error(gsp, rpc_type, err_code) + +void gsp_test_inject_error(struct gsp_device *gsp, + uint32_t rpc_type, int err_code) { + struct inject_payload p = { + .rpc_type = rpc_type, + .error_code = err_code, + .enable = 1, + }; + gsp_rpc_send_sync(gsp->rpc, RPC_DEBUG, &p, sizeof(p), NULL, NULL); +} +```
\ No newline at end of file |
