From: Michael Neuling <mikey@neuling.org>
To: mpe@ellerman.id.au, benh@kernel.crashing.org
Cc: imunsie@au.ibm.com, linuxppc-dev@ozlabs.org, mikey@neuling.org,
Daniel Axtens <dja@axtens.net>,
"Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>,
"Manoj N. Kumar" <manoj@linux.vnet.ibm.com>,
brking@linux.vnet.ibm.com
Subject: [PATCH v2 16/21] cxl: Configure PSL for kernel contexts and merge code
Date: Tue, 26 May 2015 10:20:13 +1000 [thread overview]
Message-ID: <1432599618-26844-17-git-send-email-mikey@neuling.org> (raw)
In-Reply-To: <1432599618-26844-1-git-send-email-mikey@neuling.org>
This updates AFU directed and dedicated modes for contexts attached to the
kernel.
The SR (similar to the MSR in the core) calculation is getting
quite complex and is duplicated in AFU directed and dedicated
modes. This patch also merges this SR calculation for these modes.
Signed-off-by: Michael Neuling <mikey@neuling.org>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
---
drivers/misc/cxl/native.c | 63 ++++++++++++++++++++++++++---------------------
1 file changed, 35 insertions(+), 28 deletions(-)
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index 615ccbf..a4b40d7 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -430,9 +430,30 @@ err:
#define set_endian(sr) ((sr) &= ~(CXL_PSL_SR_An_LE))
#endif
+static u64 calculate_sr(struct cxl_context *ctx)
+{
+ u64 sr = 0;
+
+ if (ctx->master)
+ sr |= CXL_PSL_SR_An_MP;
+ if (mfspr(SPRN_LPCR) & LPCR_TC)
+ sr |= CXL_PSL_SR_An_TC;
+ if (ctx->kernel) {
+ sr |= CXL_PSL_SR_An_R | (mfmsr() & MSR_SF);
+ sr |= CXL_PSL_SR_An_HV;
+ } else {
+ sr |= CXL_PSL_SR_An_PR | CXL_PSL_SR_An_R;
+ set_endian(sr);
+ sr &= ~(CXL_PSL_SR_An_HV);
+ if (!test_tsk_thread_flag(current, TIF_32BIT))
+ sr |= CXL_PSL_SR_An_SF;
+ }
+ return sr;
+}
+
static int attach_afu_directed(struct cxl_context *ctx, u64 wed, u64 amr)
{
- u64 sr;
+ u32 pid;
int r, result;
cxl_assign_psn_space(ctx);
@@ -442,22 +463,13 @@ static int attach_afu_directed(struct cxl_context *ctx, u64 wed, u64 amr)
ctx->elem->haurp = 0; /* disable */
ctx->elem->sdr = cpu_to_be64(mfspr(SPRN_SDR1));
- sr = 0;
- if (ctx->master)
- sr |= CXL_PSL_SR_An_MP;
- if (mfspr(SPRN_LPCR) & LPCR_TC)
- sr |= CXL_PSL_SR_An_TC;
- /* HV=0, PR=1, R=1 for userspace
- * For kernel contexts: this would need to change
- */
- sr |= CXL_PSL_SR_An_PR | CXL_PSL_SR_An_R;
- set_endian(sr);
- sr &= ~(CXL_PSL_SR_An_HV);
- if (!test_tsk_thread_flag(current, TIF_32BIT))
- sr |= CXL_PSL_SR_An_SF;
- ctx->elem->common.pid = cpu_to_be32(current->pid);
+ pid = current->pid;
+ if (ctx->kernel)
+ pid = 0;
ctx->elem->common.tid = 0;
- ctx->elem->sr = cpu_to_be64(sr);
+ ctx->elem->common.pid = cpu_to_be32(pid);
+
+ ctx->elem->sr = cpu_to_be64(calculate_sr(ctx));
ctx->elem->common.csrp = 0; /* disable */
ctx->elem->common.aurp0 = 0; /* disable */
@@ -530,20 +542,15 @@ static int activate_dedicated_process(struct cxl_afu *afu)
static int attach_dedicated(struct cxl_context *ctx, u64 wed, u64 amr)
{
struct cxl_afu *afu = ctx->afu;
- u64 sr;
+ u64 pid;
int rc;
- sr = 0;
- set_endian(sr);
- if (ctx->master)
- sr |= CXL_PSL_SR_An_MP;
- if (mfspr(SPRN_LPCR) & LPCR_TC)
- sr |= CXL_PSL_SR_An_TC;
- sr |= CXL_PSL_SR_An_PR | CXL_PSL_SR_An_R;
- if (!test_tsk_thread_flag(current, TIF_32BIT))
- sr |= CXL_PSL_SR_An_SF;
- cxl_p2n_write(afu, CXL_PSL_PID_TID_An, (u64)current->pid << 32);
- cxl_p1n_write(afu, CXL_PSL_SR_An, sr);
+ pid = (u64)current->pid << 32;
+ if (ctx->kernel)
+ pid = 0;
+ cxl_p2n_write(afu, CXL_PSL_PID_TID_An, pid);
+
+ cxl_p1n_write(afu, CXL_PSL_SR_An, calculate_sr(ctx));
if ((rc = cxl_write_sstp(afu, ctx->sstp0, ctx->sstp1)))
return rc;
--
2.1.0
next prev parent reply other threads:[~2015-05-26 0:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-26 0:19 [PATCH v2 00/21] cxl: Add AFU virtual PHB and in kernel API Michael Neuling
2015-05-26 0:19 ` [PATCH v2 01/21] powerpc/copro: Fix faulting kernel segments Michael Neuling
2015-05-26 0:19 ` [PATCH v2 02/21] powerpc/pci: Export symbols for CXL Michael Neuling
2015-05-26 0:20 ` [PATCH v2 03/21] powerpc/pci: Add release_device() hook to phb ops Michael Neuling
2015-05-26 0:20 ` [PATCH v2 04/21] powerpc: Add cxl context to device archdata Michael Neuling
2015-05-26 0:20 ` [PATCH v2 05/21] powerpc/pci: Add shutdown hook to pci_controller_ops Michael Neuling
2015-05-26 0:20 ` [PATCH v2 06/21] cxl: Document external user of existing API Michael Neuling
2015-05-26 0:20 ` [PATCH v2 07/21] cxl: Add shutdown hook Michael Neuling
2015-05-26 0:20 ` [PATCH v2 08/21] cxl: Re-order card init to check the VSEC earlier Michael Neuling
2015-05-26 0:20 ` [PATCH v2 09/21] cxl: Dump debug info on the AFU configuration record Michael Neuling
2015-05-26 0:20 ` [PATCH v2 10/21] cxl: Add cookie parameter to afu_release_irqs() Michael Neuling
2015-05-26 0:20 ` [PATCH v2 11/21] cxl: Rework detach context functions Michael Neuling
2015-05-26 0:20 ` [PATCH v2 12/21] cxl: cxl_afu_reset() -> __cxl_afu_reset() Michael Neuling
2015-05-26 0:20 ` [PATCH v2 13/21] cxl: Export some symbols Michael Neuling
2015-05-26 0:20 ` [PATCH v2 14/21] cxl: Only check pid for userspace contexts Michael Neuling
2015-05-26 0:20 ` [PATCH v2 15/21] cxl: Split afu_register_irqs() function Michael Neuling
2015-05-26 0:20 ` Michael Neuling [this message]
2015-05-26 0:20 ` [PATCH v2 17/21] cxl: Rework context lifetimes Michael Neuling
2015-05-26 0:20 ` [PATCH v2 18/21] cxl: Cleanup Makefile Michael Neuling
2015-05-26 0:20 ` [PATCH v2 19/21] cxl: Move include file cxl.h -> cxl-base.h Michael Neuling
2015-05-26 0:20 ` [PATCH v2 20/21] cxl: Export file ops for use by API Michael Neuling
2015-05-26 0:20 ` [PATCH v2 21/21] cxl: Add AFU virtual PHB and kernel API Michael Neuling
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=1432599618-26844-17-git-send-email-mikey@neuling.org \
--to=mikey@neuling.org \
--cc=benh@kernel.crashing.org \
--cc=brking@linux.vnet.ibm.com \
--cc=dja@axtens.net \
--cc=imunsie@au.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).