summaryrefslogtreecommitdiffstats
path: root/wiki/Error-Codes.md
blob: c61da06d75a56c2c55595bc1bff04573fa2e5863 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
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);
}
```