From: Andrew Donnellan <ajd@linux.ibm.com>
To: "Alastair D'Silva" <alastair@au1.ibm.com>, alastair@d-silva.org
Cc: Frederic Barrat <fbarrat@linux.ibm.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH] ocxl: Allow contexts to be attached with a NULL mm
Date: Tue, 18 Jun 2019 11:50:59 +1000 [thread overview]
Message-ID: <81f8951e-a095-3e13-4229-6475f6a8d4a5@linux.ibm.com> (raw)
In-Reply-To: <20190617044152.13707-1-alastair@au1.ibm.com>
On 17/6/19 2:41 pm, Alastair D'Silva wrote:
> From: Alastair D'Silva <alastair@d-silva.org>
>
> 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>
The one issue I can see here is that using mm == NULL bypasses our
method of enabling/disabling global TLBIs in mm_context_add_copro().
Discussing this privately with Alastair and Fred - this should be fine,
but perhaps we should document that.
> ---
> drivers/misc/ocxl/context.c | 9 ++++++---
> drivers/misc/ocxl/link.c | 12 ++++++++----
> 2 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/misc/ocxl/context.c b/drivers/misc/ocxl/context.c
> index bab9c9364184..994563a078eb 100644
> --- a/drivers/misc/ocxl/context.c
> +++ b/drivers/misc/ocxl/context.c
> @@ -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;
>
> diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
> index cce5b0d64505..43542f124807 100644
> --- a/drivers/misc/ocxl/link.c
> +++ b/drivers/misc/ocxl/link.c
> @@ -523,7 +523,8 @@ int ocxl_link_add_pe(void *link_handle, int pasid, u32 pidr, u32 tidr,
> pe->amr = cpu_to_be64(amr);
> pe->software_state = cpu_to_be32(SPA_PE_VALID);
>
> - mm_context_add_copro(mm);
> + if (mm)
> + mm_context_add_copro(mm);
> /*
> * Barrier is to make sure PE is visible in the SPA before it
> * is used by the device. It also helps with the global TLBI
> @@ -546,7 +547,8 @@ int ocxl_link_add_pe(void *link_handle, int pasid, u32 pidr, u32 tidr,
> * have a reference on mm_users. Incrementing mm_count solves
> * the problem.
> */
> - mmgrab(mm);
> + if (mm)
> + mmgrab(mm);
> trace_ocxl_context_add(current->pid, spa->spa_mem, pasid, pidr, tidr);
> unlock:
> mutex_unlock(&spa->spa_lock);
> @@ -652,8 +654,10 @@ int ocxl_link_remove_pe(void *link_handle, int pasid)
> if (!pe_data) {
> WARN(1, "Couldn't find pe data when removing PE\n");
> } else {
> - mm_context_remove_copro(pe_data->mm);
> - mmdrop(pe_data->mm);
> + if (pe_data->mm) {
> + mm_context_remove_copro(pe_data->mm);
> + mmdrop(pe_data->mm);
> + }
> kfree_rcu(pe_data, rcu);
> }
> unlock:
>
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
next prev parent reply other threads:[~2019-06-18 1:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-17 4:41 [PATCH] ocxl: Allow contexts to be attached with a NULL mm Alastair D'Silva
2019-06-18 1:50 ` Andrew Donnellan [this message]
2019-06-19 10:36 ` Frederic Barrat
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=81f8951e-a095-3e13-4229-6475f6a8d4a5@linux.ibm.com \
--to=ajd@linux.ibm.com \
--cc=alastair@au1.ibm.com \
--cc=alastair@d-silva.org \
--cc=arnd@arndb.de \
--cc=fbarrat@linux.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox