From: Haren Myneni <haren@linux.ibm.com>
To: Nicholas Piggin <npiggin@gmail.com>,
herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au
Cc: haren@us.ibm.com, hbabu@us.ibm.com
Subject: Re: [PATCH v6 13/17] powerpc/pseries/vas: Setup IRQ and fault handling
Date: Thu, 17 Jun 2021 19:09:01 -0700 [thread overview]
Message-ID: <a19e7839316c9ec4f7901e97b551fcf4219de82f.camel@linux.ibm.com> (raw)
In-Reply-To: <1623972635.u8jj6g26re.astroid@bobo.none>
On Fri, 2021-06-18 at 09:34 +1000, Nicholas Piggin wrote:
> Excerpts from Haren Myneni's message of June 18, 2021 6:37 am:
> > NX generates an interrupt when sees a fault on the user space
> > buffer and the hypervisor forwards that interrupt to OS. Then
> > the kernel handles the interrupt by issuing H_GET_NX_FAULT hcall
> > to retrieve the fault CRB information.
> >
> > This patch also adds changes to setup and free IRQ per each
> > window and also handles the fault by updating the CSB.
>
> In as much as this pretty well corresponds to the PowerNV code
> AFAIKS,
> it looks okay to me.
>
> Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
>
> Could you have an irq handler in your ops vector and have
> the core code set up the irq and call your handler, so the Linux irq
> handling is in one place? Not something for this series, I was just
> wondering.
Not possible to have common core code for IRQ setup.
PowerNV: Every VAS instance will be having IRQ and this setup will be
done during initialization (system boot). A fault FIFO will be assigned
for each instance and registered to VAS so that VAS/NX writes fault CRB
into this FIFO.
PowerVM: Each window will have an IRQ and the setup will be done during
window open.
Thanks
Haren
>
> Thanks,
> Nick
>
> > Signed-off-by: Haren Myneni <haren@linux.ibm.com>
> > ---
> > arch/powerpc/platforms/pseries/vas.c | 102
> > +++++++++++++++++++++++++++
> > 1 file changed, 102 insertions(+)
> >
> > diff --git a/arch/powerpc/platforms/pseries/vas.c
> > b/arch/powerpc/platforms/pseries/vas.c
> > index f5a44f2f0e99..3385b5400cc6 100644
> > --- a/arch/powerpc/platforms/pseries/vas.c
> > +++ b/arch/powerpc/platforms/pseries/vas.c
> > @@ -11,6 +11,7 @@
> > #include <linux/types.h>
> > #include <linux/delay.h>
> > #include <linux/slab.h>
> > +#include <linux/interrupt.h>
> > #include <asm/machdep.h>
> > #include <asm/hvcall.h>
> > #include <asm/plpar_wrappers.h>
> > @@ -155,6 +156,50 @@ int h_query_vas_capabilities(const u64 hcall,
> > u8 query_type, u64 result)
> > }
> > EXPORT_SYMBOL_GPL(h_query_vas_capabilities);
> >
> > +/*
> > + * hcall to get fault CRB from the hypervisor.
> > + */
> > +static int h_get_nx_fault(u32 winid, u64 buffer)
> > +{
> > + long rc;
> > +
> > + rc = plpar_hcall_norets(H_GET_NX_FAULT, winid, buffer);
> > +
> > + if (rc == H_SUCCESS)
> > + return 0;
> > +
> > + pr_err("H_GET_NX_FAULT error: %ld, winid %u, buffer 0x%llx\n",
> > + rc, winid, buffer);
> > + return -EIO;
> > +
> > +}
> > +
> > +/*
> > + * Handle the fault interrupt.
> > + * When the fault interrupt is received for each window, query the
> > + * hypervisor to get the fault CRB on the specific fault. Then
> > + * process the CRB by updating CSB or send signal if the user
> > space
> > + * CSB is invalid.
> > + * Note: The hypervisor forwards an interrupt for each fault
> > request.
> > + * So one fault CRB to process for each H_GET_NX_FAULT hcall.
> > + */
> > +irqreturn_t pseries_vas_fault_thread_fn(int irq, void *data)
> > +{
> > + struct pseries_vas_window *txwin = data;
> > + struct coprocessor_request_block crb;
> > + struct vas_user_win_ref *tsk_ref;
> > + int rc;
> > +
> > + rc = h_get_nx_fault(txwin->vas_win.winid,
> > (u64)virt_to_phys(&crb));
> > + if (!rc) {
> > + tsk_ref = &txwin->vas_win.task_ref;
> > + vas_dump_crb(&crb);
> > + vas_update_csb(&crb, tsk_ref);
> > + }
> > +
> > + return IRQ_HANDLED;
> > +}
> > +
> > /*
> > * Allocate window and setup IRQ mapping.
> > */
> > @@ -166,10 +211,51 @@ static int allocate_setup_window(struct
> > pseries_vas_window *txwin,
> > rc = h_allocate_vas_window(txwin, domain, wintype,
> > DEF_WIN_CREDS);
> > if (rc)
> > return rc;
> > + /*
> > + * On PowerVM, the hypervisor setup and forwards the fault
> > + * interrupt per window. So the IRQ setup and fault handling
> > + * will be done for each open window separately.
> > + */
> > + txwin->fault_virq = irq_create_mapping(NULL, txwin->fault_irq);
> > + if (!txwin->fault_virq) {
> > + pr_err("Failed irq mapping %d\n", txwin->fault_irq);
> > + rc = -EINVAL;
> > + goto out_win;
> > + }
> > +
> > + txwin->name = kasprintf(GFP_KERNEL, "vas-win-%d",
> > + txwin->vas_win.winid);
> > + if (!txwin->name) {
> > + rc = -ENOMEM;
> > + goto out_irq;
> > + }
> > +
> > + rc = request_threaded_irq(txwin->fault_virq, NULL,
> > + pseries_vas_fault_thread_fn,
> > IRQF_ONESHOT,
> > + txwin->name, txwin);
> > + if (rc) {
> > + pr_err("VAS-Window[%d]: Request IRQ(%u) failed with
> > %d\n",
> > + txwin->vas_win.winid, txwin->fault_virq, rc);
> > + goto out_free;
> > + }
> >
> > txwin->vas_win.wcreds_max = DEF_WIN_CREDS;
> >
> > return 0;
> > +out_free:
> > + kfree(txwin->name);
> > +out_irq:
> > + irq_dispose_mapping(txwin->fault_virq);
> > +out_win:
> > + h_deallocate_vas_window(txwin->vas_win.winid);
> > + return rc;
> > +}
> > +
> > +static inline void free_irq_setup(struct pseries_vas_window
> > *txwin)
> > +{
> > + free_irq(txwin->fault_virq, txwin);
> > + kfree(txwin->name);
> > + irq_dispose_mapping(txwin->fault_virq);
> > }
> >
> > static struct vas_window *vas_allocate_window(int vas_id, u64
> > flags,
> > @@ -284,6 +370,11 @@ static struct vas_window
> > *vas_allocate_window(int vas_id, u64 flags,
> > return &txwin->vas_win;
> >
> > out_free:
> > + /*
> > + * Window is not operational. Free IRQ before closing
> > + * window so that do not have to hold mutex.
> > + */
> > + free_irq_setup(txwin);
> > h_deallocate_vas_window(txwin->vas_win.winid);
> > out:
> > atomic_dec(&cop_feat_caps->used_lpar_creds);
> > @@ -303,7 +394,18 @@ static int deallocate_free_window(struct
> > pseries_vas_window *win)
> > {
> > int rc = 0;
> >
> > + /*
> > + * The hypervisor waits for all requests including faults
> > + * are processed before closing the window - Means all
> > + * credits have to be returned. In the case of fault
> > + * request, a credit is returned after OS issues
> > + * H_GET_NX_FAULT hcall.
> > + * So free IRQ after executing H_DEALLOCATE_VAS_WINDOW
> > + * hcall.
> > + */
> > rc = h_deallocate_vas_window(win->vas_win.winid);
> > + if (!rc)
> > + free_irq_setup(win);
> >
> > return rc;
> > }
> > --
> > 2.18.2
> >
> >
> >
next prev parent reply other threads:[~2021-06-18 2:09 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-17 20:24 [PATCH v6 00/17] Enable VAS and NX-GZIP support on PowerVM Haren Myneni
2021-06-17 20:29 ` [PATCH v6 01/17] powerpc/powernv/vas: Release reference to tgid during window close Haren Myneni
2021-06-17 20:29 ` [PATCH v6 02/17] powerpc/vas: Move VAS API to book3s common platform Haren Myneni
2021-06-17 20:30 ` [PATCH v6 03/17] powerpc/powernv/vas: Rename register/unregister functions Haren Myneni
2021-06-17 20:31 ` [PATCH v6 04/17] powerpc/vas: Add platform specific user window operations Haren Myneni
2021-06-17 23:27 ` Nicholas Piggin
2021-06-17 20:31 ` [PATCH v6 05/17] powerpc/vas: Create take/drop pid and mm reference functions Haren Myneni
2021-06-17 20:32 ` [PATCH v6 06/17] powerpc/vas: Move update_csb/dump_crb to common book3s platform Haren Myneni
2021-06-17 23:10 ` Nicholas Piggin
2021-06-17 20:33 ` [PATCH v6 07/17] powerpc/vas: Define and use common vas_window struct Haren Myneni
2021-06-17 20:34 ` [PATCH v6 08/17] powerpc/pseries/vas: Define VAS/NXGZIP hcalls and structs Haren Myneni
2021-06-17 20:34 ` [PATCH v6 09/17] powerpc/vas: Define QoS credit flag to allocate window Haren Myneni
2021-06-17 20:35 ` [PATCH v6 10/17] powerpc/pseries/vas: Add hcall wrappers for VAS handling Haren Myneni
2021-06-17 20:35 ` [PATCH v6 11/17] powerpc/pseries/vas: Implement getting capabilities from hypervisor Haren Myneni
2021-06-17 23:24 ` Nicholas Piggin
2021-06-17 20:36 ` [PATCH v6 12/17] powerpc/pseries/vas: Integrate API with open/close windows Haren Myneni
2021-06-17 23:22 ` Nicholas Piggin
2021-06-18 7:49 ` Haren Myneni
2021-06-19 3:22 ` Nicholas Piggin
2021-06-17 20:37 ` [PATCH v6 13/17] powerpc/pseries/vas: Setup IRQ and fault handling Haren Myneni
2021-06-17 23:34 ` Nicholas Piggin
2021-06-18 2:09 ` Haren Myneni [this message]
2021-06-19 3:22 ` Nicholas Piggin
2021-06-17 20:37 ` [PATCH v6 14/17] crypto/nx: Rename nx-842-pseries file name to nx-common-pseries Haren Myneni
2021-06-17 20:38 ` [PATCH v6 15/17] crypto/nx: Get NX capabilities for GZIP coprocessor type Haren Myneni
2021-06-17 23:35 ` Nicholas Piggin
2021-06-17 20:39 ` [PATCH v6 16/17] crypto/nx: Add sysfs interface to export NX capabilities Haren Myneni
2021-06-17 23:41 ` Nicholas Piggin
2021-06-17 20:39 ` [PATCH v6 17/17] crypto/nx: Register and unregister VAS interface on PowerVM Haren Myneni
2021-06-24 14:03 ` [PATCH v6 00/17] Enable VAS and NX-GZIP support " Michael Ellerman
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=a19e7839316c9ec4f7901e97b551fcf4219de82f.camel@linux.ibm.com \
--to=haren@linux.ibm.com \
--cc=haren@us.ibm.com \
--cc=hbabu@us.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.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