Lines Matching full:unit

64  * unit->fault_log, and schedules a task.
72 * For the same reason, each translation unit task is executed in its
80 dmar_fault_next(struct dmar_unit *unit, int faultp)
84 if (faultp == unit->fault_log_size)
90 dmar_fault_intr_clear(struct dmar_unit *unit, uint32_t fsts)
96 printf("DMAR%d: Invalidation timed out\n", unit->iommu.unit);
101 unit->iommu.unit);
106 unit->iommu.unit);
110 printf("DMAR%d: Advanced pending fault\n", unit->iommu.unit);
114 printf("DMAR%d: Advanced fault overflow\n", unit->iommu.unit);
118 dmar_write4(unit, DMAR_FSTS_REG, clear);
124 struct dmar_unit *unit;
130 unit = IOMMU2DMAR((struct iommu_unit *)arg);
132 fsts = dmar_read4(unit, DMAR_FSTS_REG);
133 dmar_fault_intr_clear(unit, fsts);
140 frir = (DMAR_CAP_FRO(unit->hw_cap) + fri) * 16;
141 fault_rec[1] = dmar_read8(unit, frir + 8);
144 fault_rec[0] = dmar_read8(unit, frir);
145 dmar_write4(unit, frir + 12, DMAR_FRCD2_F32);
146 DMAR_FAULT_LOCK(unit);
147 faultp = unit->fault_log_head;
148 if (dmar_fault_next(unit, faultp) == unit->fault_log_tail) {
151 unit->fault_log[faultp] = fault_rec[0];
152 unit->fault_log[faultp + 1] = fault_rec[1];
153 unit->fault_log_head = dmar_fault_next(unit, faultp);
156 DMAR_FAULT_UNLOCK(unit);
158 if (fri >= DMAR_CAP_NFR(unit->hw_cap))
176 printf("DMAR%d: Fault Overflow\n", unit->iommu.unit);
177 dmar_write4(unit, DMAR_FSTS_REG, DMAR_FSTS_PFO);
181 taskqueue_enqueue(unit->fault_taskqueue,
182 &unit->fault_task);
190 struct dmar_unit *unit;
195 unit = arg;
196 DMAR_FAULT_LOCK(unit);
198 faultp = unit->fault_log_tail;
199 if (faultp == unit->fault_log_head)
202 fault_rec[0] = unit->fault_log[faultp];
203 fault_rec[1] = unit->fault_log[faultp + 1];
204 unit->fault_log_tail = dmar_fault_next(unit, faultp);
205 DMAR_FAULT_UNLOCK(unit);
208 printf("DMAR%d: ", unit->iommu.unit);
209 DMAR_LOCK(unit);
210 ctx = dmar_find_ctx_locked(unit, sid);
231 DMAR_UNLOCK(unit);
238 DMAR_FAULT_LOCK(unit);
240 DMAR_FAULT_UNLOCK(unit);
244 dmar_clear_faults(struct dmar_unit *unit)
249 for (i = 0; i < DMAR_CAP_NFR(unit->hw_cap); i++) {
250 frir = (DMAR_CAP_FRO(unit->hw_cap) + i) * 16;
251 frec = dmar_read4(unit, frir + 12);
254 dmar_write4(unit, frir + 12, DMAR_FRCD2_F32);
256 fsts = dmar_read4(unit, DMAR_FSTS_REG);
257 dmar_write4(unit, DMAR_FSTS_REG, fsts);
261 dmar_init_fault_log(struct dmar_unit *unit)
264 mtx_init(&unit->fault_lock, "dmarflt", NULL, MTX_SPIN);
265 unit->fault_log_size = 256; /* 128 fault log entries */
266 TUNABLE_INT_FETCH("hw.dmar.fault_log_size", &unit->fault_log_size);
267 if (unit->fault_log_size % 2 != 0)
269 unit->fault_log = malloc(sizeof(uint64_t) * unit->fault_log_size,
272 TASK_INIT(&unit->fault_task, 0, dmar_fault_task, unit);
273 unit->fault_taskqueue = taskqueue_create_fast("dmarff", M_WAITOK,
274 taskqueue_thread_enqueue, &unit->fault_taskqueue);
275 taskqueue_start_threads(&unit->fault_taskqueue, 1, PI_AV,
276 "dmar%d fault taskq", unit->iommu.unit);
278 DMAR_LOCK(unit);
279 dmar_disable_fault_intr(&unit->iommu);
280 dmar_clear_faults(unit);
281 dmar_enable_fault_intr(&unit->iommu);
282 DMAR_UNLOCK(unit);
288 dmar_fini_fault_log(struct dmar_unit *unit)
291 if (unit->fault_taskqueue == NULL)
294 DMAR_LOCK(unit);
295 dmar_disable_fault_intr(&unit->iommu);
296 DMAR_UNLOCK(unit);
298 taskqueue_drain(unit->fault_taskqueue, &unit->fault_task);
299 taskqueue_free(unit->fault_taskqueue);
300 unit->fault_taskqueue = NULL;
301 mtx_destroy(&unit->fault_lock);
303 free(unit->fault_log, M_DEVBUF);
304 unit->fault_log = NULL;
305 unit->fault_log_head = unit->fault_log_tail = 0;
311 struct dmar_unit *unit;
314 unit = IOMMU2DMAR(iommu);
315 DMAR_ASSERT_LOCKED(unit);
316 fectl = dmar_read4(unit, DMAR_FECTL_REG);
318 dmar_write4(unit, DMAR_FECTL_REG, fectl);
324 struct dmar_unit *unit;
327 unit = IOMMU2DMAR(iommu);
328 DMAR_ASSERT_LOCKED(unit);
329 fectl = dmar_read4(unit, DMAR_FECTL_REG);
330 dmar_write4(unit, DMAR_FECTL_REG, fectl | DMAR_FECTL_IM);