From b9721d275cc2c5e6c07371239c827e0faf05a6b9 Mon Sep 17 00:00:00 2001 From: Alastair D'Silva Date: Wed, 27 Mar 2019 16:31:33 +1100 Subject: ocxl: Allow external drivers to use OpenCAPI contexts Most OpenCAPI operations require a valid context, so exposing these functions to external drivers is necessary. Signed-off-by: Alastair D'Silva Reviewed-by: Greg Kurz Acked-by: Frederic Barrat Signed-off-by: Michael Ellerman --- include/misc/ocxl.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'include/misc') diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h index 8bafd748e380..e4704632eac5 100644 --- a/include/misc/ocxl.h +++ b/include/misc/ocxl.h @@ -48,6 +48,7 @@ struct ocxl_fn_config { // These are opaque outside the ocxl driver struct ocxl_afu; struct ocxl_fn; +struct ocxl_context; // Device detection & initialisation @@ -116,6 +117,44 @@ const struct ocxl_fn_config *ocxl_function_config(struct ocxl_fn *fn); */ void ocxl_function_close(struct ocxl_fn *fn); +// Context allocation + +/** + * Allocate an OpenCAPI context + * + * @context: The OpenCAPI context to allocate, must be freed with ocxl_context_free + * @afu: The AFU the context belongs to + * @mapping: The mapping to unmap when the context is closed (may be NULL) + */ +int ocxl_context_alloc(struct ocxl_context **context, struct ocxl_afu *afu, + struct address_space *mapping); + +/** + * Free an OpenCAPI context + * + * @ctx: The OpenCAPI context to free + */ +void ocxl_context_free(struct ocxl_context *ctx); + +/** + * Grant access to an MM to an OpenCAPI context + * @ctx: The OpenCAPI context to attach + * @amr: The value of the AMR register to restrict access + * @mm: The mm to attach to the context + * + * Returns 0 on success, negative on failure + */ +int ocxl_context_attach(struct ocxl_context *ctx, u64 amr, + struct mm_struct *mm); + +/** + * Detach an MM from an OpenCAPI context + * @ctx: The OpenCAPI context to attach + * + * Returns 0 on success, negative on failure + */ +int ocxl_context_detach(struct ocxl_context *ctx); + // AFU Metadata /** -- cgit v1.2.3-59-g8ed1b