From: Michael Neuling <mikey@neuling.org>
To: Ian Munsie <imunsie@au1.ibm.com>
Cc: mpe <mpe@ellerman.id.au>, benh <benh@kernel.crashing.org>,
"Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>,
linuxppc-dev <linuxppc-dev@ozlabs.org>,
"Manoj N. Kumar" <manoj@linux.vnet.ibm.com>,
brking <brking@linux.vnet.ibm.com>,
Daniel Axtens <dja@axtens.net>
Subject: Re: [PATCH 19/19] cxl: Add AFU virtual PHB and kernel API
Date: Mon, 25 May 2015 14:12:56 +1000 [thread overview]
Message-ID: <1432527176.29580.4.camel@neuling.org> (raw)
In-Reply-To: <1432193794-sup-4147@delenn.ozlabs.ibm.com>
On Thu, 2015-05-21 at 18:58 +1000, Ian Munsie wrote:
> Hi Mikey,
>=20
> > +/* wrappers around afu_* file ops which are EXPORTED */
>=20
> This is fine, though alternatively you could export the original
> functions directly from file.c (feel free to rename them to your
> versions if you do change it) - I don't really mind either way :)
I'll probably just keep it so all the API functions are in one spot.
> > +static void cxl_pci_reset_secondary_bus(struct pci_dev *dev)
> > +{
> > + /* Should we do an AFU reset here ? */
>=20
> I'm still not sure what the best answer should be to this question... At
> the moment it's working fine without an afu reset here, so we can delay
> adding it until (and if) it becomes clear we need it?
Yeah I think I'll leave it out
> Could this be called while the afu is in use (need to be careful), or
> should it only ever be called when the afu is inactive (afu reset should
> be safe)?
Yeah, I assume we'd need to give some EEH events to the attached driver
so they could handle the AFU losing all that state/contexts.
> > +/*
> > + * Context lifetime overview:
> > + *
> > + * An AFU context may be inited and then started and stoppped multiple=
times
> > + * before it's released. ie.
> > + * - cxl_dev_context_init()
> > + * - cxl_start_context()
> > + * - cxl_stop_context()
> > + * - cxl_start_context()
> > + * - cxl_stop_context()
> > + * ...repeat...
> > + * - cxl_release_context()
> > + * Once released, a context can't be started again.
>=20
> Ok, we'll need to be a little careful here as this differs from the
> userspace api (which cannot reuse a context and relies on the file
> descriptor release() to stop the context).
>=20
> Let's see...
Yep. =20
>=20
> > +int cxl_start_context(struct cxl_context *ctx, u64 wed,
> > + struct task_struct *task)
> > +{
> > + int rc =3D 0;
> > + bool kernel =3D true;
> > +
> > + pr_devel("%s: pe: %i\n", __func__, ctx->pe);
> > +
> > + mutex_lock(&ctx->status_mutex);
> > + if (ctx->status =3D=3D STARTED)
> > + goto out; /* already started */
> > + if (task) {
> > + ctx->pid =3D get_task_pid(task, PIDTYPE_PID);
> > + get_pid(ctx->pid);
>=20
> OK, this pid is put in the release call (in reclaim_ctx, which is an rcu
> callback from cxl_context_free), which means if we reuse a context we
> will prevent the pid from ever being reused, reducing the total number
> of runnable processes by one.
As discussed offline, I've moved this around.
> > + kernel =3D false;
> > + }
> > +
> > + cxl_ctx_get();
>=20
> Likewise this is mirrored in the release call instead of the stop call,
> so if we reuse a context we will then permanently mark cxl as being in
> use, which will then permanently enable the slbia hook.
Ditto.
>=20
> > + if ((rc =3D cxl_attach_process(ctx, kernel, wed , 0))) {
> > + put_pid(ctx->pid);
> > + cxl_ctx_put();
> > + goto out;
> > + }
> > +
> > + ctx->status =3D STARTED;
> > + get_device(&ctx->afu->dev);
> > +out:
> > + mutex_unlock(&ctx->status_mutex);
> > + return rc;
> > +}
> > +EXPORT_SYMBOL_GPL(cxl_start_context);
>=20
> > +/* Stop a context. Returns 0 on success, otherwise -Errno */
> > +int cxl_stop_context(struct cxl_context *ctx)
> > +{
> > + int rc;
> > +
> > + rc =3D __detach_context(ctx);
> > + if (!rc)
> > + put_device(&ctx->afu->dev);
> > + return rc;
> > +}
> > +EXPORT_SYMBOL_GPL(cxl_stop_context);
>=20
> > +int cxl_release_context(struct cxl_context *ctx)
> > +{
> > + if (ctx->status !=3D CLOSED)
> > + return -EBUSY;
> > +
> > + cxl_context_free(ctx);
> > +
> > + cxl_ctx_put();
> > + return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(cxl_release_context);
>=20
> Otherwise it looks good :)
Thanks,
Mikey
>=20
> Cheers,
> -Ian
>=20
prev parent reply other threads:[~2015-05-25 4:12 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-19 11:22 [PATCH 00/19] cxl: Add AFU virtual PHB and in kernel API Michael Neuling
2015-05-19 11:22 ` [PATCH 01/19] powerpc/copro: Fix faulting kernel segments Michael Neuling
2015-05-21 8:59 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 02/19] powerpc/pci: Export symbols for CXL Michael Neuling
2015-05-19 11:22 ` [PATCH 03/19] powerpc/pci: Add release_device() hook to phb ops Michael Neuling
2015-05-19 11:22 ` [PATCH 04/19] powerpc: Add cxl context to device archdata Michael Neuling
2015-05-19 11:22 ` [PATCH 05/19] cxl: Document external user of existing API Michael Neuling
2015-05-21 9:01 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 06/19] cxl: Add shutdown hook Michael Neuling
2015-05-21 9:06 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 07/19] cxl: Re-order card init to check the VSEC earlier Michael Neuling
2015-05-21 9:09 ` Ian Munsie
2015-05-22 5:26 ` Michael Neuling
2015-05-19 11:22 ` [PATCH 08/19] cxl: Dump debug info on the AFU configuration record Michael Neuling
2015-05-21 9:10 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 09/19] cxl: Add cookie parameter to afu_release_irqs() Michael Neuling
2015-05-21 9:10 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 10/19] cxl: Rework detach context functions Michael Neuling
2015-05-21 9:13 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 11/19] cxl: cxl_afu_reset() -> __cxl_afu_reset() Michael Neuling
2015-05-21 9:14 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 12/19] cxl: Export some symbols Michael Neuling
2015-05-21 9:16 ` Ian Munsie
2015-05-26 1:22 ` Michael Neuling
2015-05-19 11:22 ` [PATCH 13/19] cxl: Only check pid for userspace contexts Michael Neuling
2015-05-21 9:16 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 14/19] cxl: Split afu_register_irqs() function Michael Neuling
2015-05-21 9:17 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 15/19] cxl: Configure PSL for kernel contexts Michael Neuling
2015-05-21 9:32 ` Ian Munsie
2015-05-22 5:28 ` Michael Neuling
2015-05-19 11:22 ` [PATCH 16/19] cxl: Cleanup Makefile Michael Neuling
2015-05-21 9:32 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 17/19] cxl: Move include file cxl.h -> cxl-base.h Michael Neuling
2015-05-21 9:33 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 18/19] cxl: Export file ops for use by API Michael Neuling
2015-05-21 9:37 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 19/19] cxl: Add AFU virtual PHB and kernel API Michael Neuling
2015-05-21 8:58 ` Ian Munsie
2015-05-25 4:12 ` Michael Neuling [this message]
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=1432527176.29580.4.camel@neuling.org \
--to=mikey@neuling.org \
--cc=benh@kernel.crashing.org \
--cc=brking@linux.vnet.ibm.com \
--cc=dja@axtens.net \
--cc=imunsie@au1.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=manoj@linux.vnet.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=mrochs@linux.vnet.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).