Lines Matching refs:unit

65  * unit->fault_log, and schedules a task.
73 * For the same reason, each translation unit task is executed in its
81 dmar_fault_next(struct dmar_unit *unit, int faultp)
85 if (faultp == unit->fault_log_size)
91 dmar_fault_intr_clear(struct dmar_unit *unit, uint32_t fsts)
97 printf("DMAR%d: Invalidation timed out\n", unit->unit);
102 unit->unit);
107 unit->unit);
111 printf("DMAR%d: Advanced pending fault\n", unit->unit);
115 printf("DMAR%d: Advanced fault overflow\n", unit->unit);
119 dmar_write4(unit, DMAR_FSTS_REG, clear);
125 struct dmar_unit *unit;
131 unit = arg;
133 fsts = dmar_read4(unit, DMAR_FSTS_REG);
134 dmar_fault_intr_clear(unit, fsts);
141 frir = (DMAR_CAP_FRO(unit->hw_cap) + fri) * 16;
142 fault_rec[1] = dmar_read8(unit, frir + 8);
145 fault_rec[0] = dmar_read8(unit, frir);
146 dmar_write4(unit, frir + 12, DMAR_FRCD2_F32);
147 DMAR_FAULT_LOCK(unit);
148 faultp = unit->fault_log_head;
149 if (dmar_fault_next(unit, faultp) == unit->fault_log_tail) {
152 unit->fault_log[faultp] = fault_rec[0];
153 unit->fault_log[faultp + 1] = fault_rec[1];
154 unit->fault_log_head = dmar_fault_next(unit, faultp);
157 DMAR_FAULT_UNLOCK(unit);
159 if (fri >= DMAR_CAP_NFR(unit->hw_cap))
177 printf("DMAR%d: Fault Overflow\n", unit->unit);
178 dmar_write4(unit, DMAR_FSTS_REG, DMAR_FSTS_PFO);
182 taskqueue_enqueue(unit->fault_taskqueue,
183 &unit->fault_task);
191 struct dmar_unit *unit;
196 unit = arg;
197 DMAR_FAULT_LOCK(unit);
199 faultp = unit->fault_log_tail;
200 if (faultp == unit->fault_log_head)
203 fault_rec[0] = unit->fault_log[faultp];
204 fault_rec[1] = unit->fault_log[faultp + 1];
205 unit->fault_log_tail = dmar_fault_next(unit, faultp);
206 DMAR_FAULT_UNLOCK(unit);
209 printf("DMAR%d: ", unit->unit);
210 DMAR_LOCK(unit);
211 ctx = dmar_find_ctx_locked(unit, sid);
232 DMAR_UNLOCK(unit);
239 DMAR_FAULT_LOCK(unit);
241 DMAR_FAULT_UNLOCK(unit);
245 dmar_clear_faults(struct dmar_unit *unit)
250 for (i = 0; i < DMAR_CAP_NFR(unit->hw_cap); i++) {
251 frir = (DMAR_CAP_FRO(unit->hw_cap) + i) * 16;
252 frec = dmar_read4(unit, frir + 12);
255 dmar_write4(unit, frir + 12, DMAR_FRCD2_F32);
257 fsts = dmar_read4(unit, DMAR_FSTS_REG);
258 dmar_write4(unit, DMAR_FSTS_REG, fsts);
262 dmar_init_fault_log(struct dmar_unit *unit)
265 mtx_init(&unit->fault_lock, "dmarflt", NULL, MTX_SPIN);
266 unit->fault_log_size = 256; /* 128 fault log entries */
267 TUNABLE_INT_FETCH("hw.dmar.fault_log_size", &unit->fault_log_size);
268 if (unit->fault_log_size % 2 != 0)
270 unit->fault_log = malloc(sizeof(uint64_t) * unit->fault_log_size,
273 TASK_INIT(&unit->fault_task, 0, dmar_fault_task, unit);
274 unit->fault_taskqueue = taskqueue_create_fast("dmarff", M_WAITOK,
275 taskqueue_thread_enqueue, &unit->fault_taskqueue);
276 taskqueue_start_threads(&unit->fault_taskqueue, 1, PI_AV,
277 "dmar%d fault taskq", unit->unit);
279 DMAR_LOCK(unit);
280 dmar_disable_fault_intr(unit);
281 dmar_clear_faults(unit);
282 dmar_enable_fault_intr(unit);
283 DMAR_UNLOCK(unit);
289 dmar_fini_fault_log(struct dmar_unit *unit)
292 DMAR_LOCK(unit);
293 dmar_disable_fault_intr(unit);
294 DMAR_UNLOCK(unit);
296 if (unit->fault_taskqueue == NULL)
299 taskqueue_drain(unit->fault_taskqueue, &unit->fault_task);
300 taskqueue_free(unit->fault_taskqueue);
301 unit->fault_taskqueue = NULL;
302 mtx_destroy(&unit->fault_lock);
304 free(unit->fault_log, M_DEVBUF);
305 unit->fault_log = NULL;
306 unit->fault_log_head = unit->fault_log_tail = 0;
310 dmar_enable_fault_intr(struct dmar_unit *unit)
314 DMAR_ASSERT_LOCKED(unit);
315 fectl = dmar_read4(unit, DMAR_FECTL_REG);
317 dmar_write4(unit, DMAR_FECTL_REG, fectl);
321 dmar_disable_fault_intr(struct dmar_unit *unit)
325 DMAR_ASSERT_LOCKED(unit);
326 fectl = dmar_read4(unit, DMAR_FECTL_REG);
327 dmar_write4(unit, DMAR_FECTL_REG, fectl | DMAR_FECTL_IM);