aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorIan Munsie <imunsie@au1.ibm.com>2016-05-04 00:52:58 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2016-05-11 07:54:10 -0400
commit3c206fa77aaaac8cd7d4cfcd840c82495b01b288 (patch)
tree359020d4afbb21676e01d3df6dbf903ccdd558a2 /drivers/misc
parent0e5b5ba17ac33a05d9f4a48b5eb8b5e30f2274d7 (diff)
cxl: Ensure PSL interrupt is configured for contexts with no AFU IRQs
In the cxl kernel API, it is possible to create a context and start it without allocating any interrupts. Since we assign or allocate the PSL interrupt when allocating AFU interrupts this will lead to a situation where we start the context with no means to take any faults. The user API is not affected as it always goes through the cxl interrupt allocation code paths and will have the PSL interrupt allocated or assigned, even if no AFU interrupts were requested. This checks that at least one interrupt is configured at the time of attach, and if not it will assign the multiplexed PSL interrupt for powernv, or allocate a single interrupt for PowerVM. Signed-off-by: Ian Munsie <imunsie@au1.ibm.com> Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/cxl/guest.c12
-rw-r--r--drivers/misc/cxl/native.c9
2 files changed, 21 insertions, 0 deletions
diff --git a/drivers/misc/cxl/guest.c b/drivers/misc/cxl/guest.c
index a83acf9f8cd9..769971c065b4 100644
--- a/drivers/misc/cxl/guest.c
+++ b/drivers/misc/cxl/guest.c
@@ -552,6 +552,17 @@ static int attach_afu_directed(struct cxl_context *ctx, u64 wed, u64 amr)
552 552
553 elem->common.sstp0 = cpu_to_be64(ctx->sstp0); 553 elem->common.sstp0 = cpu_to_be64(ctx->sstp0);
554 elem->common.sstp1 = cpu_to_be64(ctx->sstp1); 554 elem->common.sstp1 = cpu_to_be64(ctx->sstp1);
555
556 /*
557 * Ensure we have at least one interrupt allocated to take faults for
558 * kernel contexts that may not have allocated any AFU IRQs at all:
559 */
560 if (ctx->irqs.range[0] == 0) {
561 rc = afu_register_irqs(ctx, 0);
562 if (rc)
563 goto out_free;
564 }
565
555 for (r = 0; r < CXL_IRQ_RANGES; r++) { 566 for (r = 0; r < CXL_IRQ_RANGES; r++) {
556 for (i = 0; i < ctx->irqs.range[r]; i++) { 567 for (i = 0; i < ctx->irqs.range[r]; i++) {
557 if (r == 0 && i == 0) { 568 if (r == 0 && i == 0) {
@@ -597,6 +608,7 @@ static int attach_afu_directed(struct cxl_context *ctx, u64 wed, u64 amr)
597 enable_afu_irqs(ctx); 608 enable_afu_irqs(ctx);
598 } 609 }
599 610
611out_free:
600 free_page((u64)elem); 612 free_page((u64)elem);
601 return rc; 613 return rc;
602} 614}
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index b8b547a162eb..5d4fb9fd84bc 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -534,6 +534,15 @@ static int attach_afu_directed(struct cxl_context *ctx, u64 wed, u64 amr)
534 ctx->elem->common.sstp0 = cpu_to_be64(ctx->sstp0); 534 ctx->elem->common.sstp0 = cpu_to_be64(ctx->sstp0);
535 ctx->elem->common.sstp1 = cpu_to_be64(ctx->sstp1); 535 ctx->elem->common.sstp1 = cpu_to_be64(ctx->sstp1);
536 536
537 /*
538 * Ensure we have the multiplexed PSL interrupt set up to take faults
539 * for kernel contexts that may not have allocated any AFU IRQs at all:
540 */
541 if (ctx->irqs.range[0] == 0) {
542 ctx->irqs.offset[0] = ctx->afu->native->psl_hwirq;
543 ctx->irqs.range[0] = 1;
544 }
545
537 for (r = 0; r < CXL_IRQ_RANGES; r++) { 546 for (r = 0; r < CXL_IRQ_RANGES; r++) {
538 ctx->elem->ivte_offsets[r] = cpu_to_be16(ctx->irqs.offset[r]); 547 ctx->elem->ivte_offsets[r] = cpu_to_be16(ctx->irqs.offset[r]);
539 ctx->elem->ivte_ranges[r] = cpu_to_be16(ctx->irqs.range[r]); 548 ctx->elem->ivte_ranges[r] = cpu_to_be16(ctx->irqs.range[r]);