ocxl: Allow contexts to be attached with a NULL mm

If an OpenCAPI context is to be used directly by a kernel driver, there
may not be a suitable mm to use.

The patch makes the mm parameter to ocxl_context_attach optional.

Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
Acked-by: Andrew Donnellan <ajd@linux.ibm.com>
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
Acked-by: Nicholas Piggin <npiggin@gmail.com>
Link: https://lore.kernel.org/r/20190620041203.12274-1-alastair@au1.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Alastair D'Silva
2019-06-20 14:12:01 +10:00
committed by Greg Kroah-Hartman
parent 7ce98fb6c5
commit 60e8523e2e
3 changed files with 35 additions and 7 deletions

View File

@@ -69,6 +69,7 @@ static void xsl_fault_error(void *data, u64 addr, u64 dsisr)
int ocxl_context_attach(struct ocxl_context *ctx, u64 amr, struct mm_struct *mm)
{
int rc;
unsigned long pidr = 0;
// Locks both status & tidr
mutex_lock(&ctx->status_mutex);
@@ -77,9 +78,11 @@ int ocxl_context_attach(struct ocxl_context *ctx, u64 amr, struct mm_struct *mm)
goto out;
}
rc = ocxl_link_add_pe(ctx->afu->fn->link, ctx->pasid,
mm->context.id, ctx->tidr, amr, mm,
xsl_fault_error, ctx);
if (mm)
pidr = mm->context.id;
rc = ocxl_link_add_pe(ctx->afu->fn->link, ctx->pasid, pidr, ctx->tidr,
amr, mm, xsl_fault_error, ctx);
if (rc)
goto out;