/* * Keep a reference on the AFU to make sure it's valid for the * duration of the life of the context
*/
ocxl_afu_get(afu);
*context = ctx; return 0;
}
EXPORT_SYMBOL_GPL(ocxl_context_alloc);
/* * Callback for when a translation fault triggers an error * data: a pointer to the context which triggered the fault * addr: the address that triggered the error * dsisr: the value of the PPC64 dsisr register
*/ staticvoid xsl_fault_error(void *data, u64 addr, u64 dsisr)
{ struct ocxl_context *ctx = data;
/* only one page */ if (vma_pages(vma) != 1) return -EINVAL;
/* check offset validty */ if (!ocxl_afu_irq_get_addr(ctx, irq_id)) return -EINVAL;
/* * trigger page should only be accessible in write mode. * * It's a bit theoretical, as a page mmaped with only * PROT_WRITE is currently readable, but it doesn't hurt.
*/ if ((vma->vm_flags & VM_READ) || (vma->vm_flags & VM_EXEC) ||
!(vma->vm_flags & VM_WRITE)) return -EINVAL;
vm_flags_clear(vma, VM_MAYREAD | VM_MAYEXEC); return 0;
}
int ocxl_context_detach(struct ocxl_context *ctx)
{ struct pci_dev *dev; int afu_control_pos; enum ocxl_context_status status; int rc;
mutex_lock(&ctx->status_mutex);
status = ctx->status;
ctx->status = CLOSED;
mutex_unlock(&ctx->status_mutex); if (status != ATTACHED) return 0;
dev = to_pci_dev(ctx->afu->fn->dev.parent);
afu_control_pos = ctx->afu->config.dvsec_afu_control_pos;
mutex_lock(&ctx->afu->afu_control_lock);
rc = ocxl_config_terminate_pasid(dev, afu_control_pos, ctx->pasid);
mutex_unlock(&ctx->afu->afu_control_lock);
trace_ocxl_terminate_pasid(ctx->pasid, rc); if (rc) { /* * If we timeout waiting for the AFU to terminate the * pasid, then it's dangerous to clean up the Process * Element entry in the SPA, as it may be referenced * in the future by the AFU. In which case, we would * checkstop because of an invalid PE access (FIR * register 2, bit 42). So leave the PE * defined. Caller shouldn't free the context so that * PASID remains allocated. * * A link reset will be required to cleanup the AFU * and the SPA.
*/ if (rc == -EBUSY) return rc;
}
rc = ocxl_link_remove_pe(ctx->afu->fn->link, ctx->pasid); if (rc) {
dev_warn(&dev->dev, "Couldn't remove PE entry cleanly: %d\n", rc);
} return 0;
}
EXPORT_SYMBOL_GPL(ocxl_context_detach);
void ocxl_context_detach_all(struct ocxl_afu *afu)
{ struct ocxl_context *ctx; int tmp;
mutex_lock(&afu->contexts_lock);
idr_for_each_entry(&afu->contexts_idr, ctx, tmp) {
ocxl_context_detach(ctx); /* * We are force detaching - remove any active mmio * mappings so userspace cannot interfere with the * card if it comes back. Easiest way to exercise * this is to unbind and rebind the driver via sysfs * while it is in use.
*/
mutex_lock(&ctx->mapping_lock); if (ctx->mapping)
unmap_mapping_range(ctx->mapping, 0, 0, 1);
mutex_unlock(&ctx->mapping_lock);
}
mutex_unlock(&afu->contexts_lock);
}
ocxl_afu_irq_free_all(ctx);
idr_destroy(&ctx->irq_idr); /* reference to the AFU taken in ocxl_context_alloc() */
ocxl_afu_put(ctx->afu);
kfree(ctx);
}
EXPORT_SYMBOL_GPL(ocxl_context_free);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.