aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/cxl/native.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/cxl/native.c')
-rw-r--r--drivers/misc/cxl/native.c54
1 files changed, 32 insertions, 22 deletions
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index 7257e8b8b52d..c147863e149d 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -258,7 +258,7 @@ void cxl_release_spa(struct cxl_afu *afu)
258 } 258 }
259} 259}
260 260
261int cxl_tlb_slb_invalidate(struct cxl *adapter) 261int cxl_invalidate_all_psl(struct cxl *adapter)
262{ 262{
263 unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT); 263 unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT);
264 264
@@ -578,7 +578,7 @@ static void update_ivtes_directed(struct cxl_context *ctx)
578 WARN_ON(add_process_element(ctx)); 578 WARN_ON(add_process_element(ctx));
579} 579}
580 580
581static int attach_afu_directed(struct cxl_context *ctx, u64 wed, u64 amr) 581int cxl_attach_afu_directed_psl(struct cxl_context *ctx, u64 wed, u64 amr)
582{ 582{
583 u32 pid; 583 u32 pid;
584 int result; 584 int result;
@@ -671,7 +671,7 @@ static int deactivate_afu_directed(struct cxl_afu *afu)
671 return 0; 671 return 0;
672} 672}
673 673
674static int activate_dedicated_process(struct cxl_afu *afu) 674int cxl_activate_dedicated_process_psl(struct cxl_afu *afu)
675{ 675{
676 dev_info(&afu->dev, "Activating dedicated process mode\n"); 676 dev_info(&afu->dev, "Activating dedicated process mode\n");
677 677
@@ -694,7 +694,7 @@ static int activate_dedicated_process(struct cxl_afu *afu)
694 return cxl_chardev_d_afu_add(afu); 694 return cxl_chardev_d_afu_add(afu);
695} 695}
696 696
697static void update_ivtes_dedicated(struct cxl_context *ctx) 697void cxl_update_dedicated_ivtes_psl(struct cxl_context *ctx)
698{ 698{
699 struct cxl_afu *afu = ctx->afu; 699 struct cxl_afu *afu = ctx->afu;
700 700
@@ -710,7 +710,7 @@ static void update_ivtes_dedicated(struct cxl_context *ctx)
710 ((u64)ctx->irqs.range[3] & 0xffff)); 710 ((u64)ctx->irqs.range[3] & 0xffff));
711} 711}
712 712
713static int attach_dedicated(struct cxl_context *ctx, u64 wed, u64 amr) 713int cxl_attach_dedicated_process_psl(struct cxl_context *ctx, u64 wed, u64 amr)
714{ 714{
715 struct cxl_afu *afu = ctx->afu; 715 struct cxl_afu *afu = ctx->afu;
716 u64 pid; 716 u64 pid;
@@ -728,7 +728,8 @@ static int attach_dedicated(struct cxl_context *ctx, u64 wed, u64 amr)
728 728
729 cxl_prefault(ctx, wed); 729 cxl_prefault(ctx, wed);
730 730
731 update_ivtes_dedicated(ctx); 731 if (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes)
732 afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx);
732 733
733 cxl_p2n_write(afu, CXL_PSL_AMR_An, amr); 734 cxl_p2n_write(afu, CXL_PSL_AMR_An, amr);
734 735
@@ -778,8 +779,9 @@ static int native_afu_activate_mode(struct cxl_afu *afu, int mode)
778 779
779 if (mode == CXL_MODE_DIRECTED) 780 if (mode == CXL_MODE_DIRECTED)
780 return activate_afu_directed(afu); 781 return activate_afu_directed(afu);
781 if (mode == CXL_MODE_DEDICATED) 782 if ((mode == CXL_MODE_DEDICATED) &&
782 return activate_dedicated_process(afu); 783 (afu->adapter->native->sl_ops->activate_dedicated_process))
784 return afu->adapter->native->sl_ops->activate_dedicated_process(afu);
783 785
784 return -EINVAL; 786 return -EINVAL;
785} 787}
@@ -793,11 +795,13 @@ static int native_attach_process(struct cxl_context *ctx, bool kernel,
793 } 795 }
794 796
795 ctx->kernel = kernel; 797 ctx->kernel = kernel;
796 if (ctx->afu->current_mode == CXL_MODE_DIRECTED) 798 if ((ctx->afu->current_mode == CXL_MODE_DIRECTED) &&
797 return attach_afu_directed(ctx, wed, amr); 799 (ctx->afu->adapter->native->sl_ops->attach_afu_directed))
800 return ctx->afu->adapter->native->sl_ops->attach_afu_directed(ctx, wed, amr);
798 801
799 if (ctx->afu->current_mode == CXL_MODE_DEDICATED) 802 if ((ctx->afu->current_mode == CXL_MODE_DEDICATED) &&
800 return attach_dedicated(ctx, wed, amr); 803 (ctx->afu->adapter->native->sl_ops->attach_dedicated_process))
804 return ctx->afu->adapter->native->sl_ops->attach_dedicated_process(ctx, wed, amr);
801 805
802 return -EINVAL; 806 return -EINVAL;
803} 807}
@@ -830,8 +834,9 @@ static void native_update_ivtes(struct cxl_context *ctx)
830{ 834{
831 if (ctx->afu->current_mode == CXL_MODE_DIRECTED) 835 if (ctx->afu->current_mode == CXL_MODE_DIRECTED)
832 return update_ivtes_directed(ctx); 836 return update_ivtes_directed(ctx);
833 if (ctx->afu->current_mode == CXL_MODE_DEDICATED) 837 if ((ctx->afu->current_mode == CXL_MODE_DEDICATED) &&
834 return update_ivtes_dedicated(ctx); 838 (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes))
839 return ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx);
835 WARN(1, "native_update_ivtes: Bad mode\n"); 840 WARN(1, "native_update_ivtes: Bad mode\n");
836} 841}
837 842
@@ -875,7 +880,7 @@ static int native_get_irq_info(struct cxl_afu *afu, struct cxl_irq_info *info)
875 return 0; 880 return 0;
876} 881}
877 882
878void cxl_native_psl_irq_dump_regs(struct cxl_context *ctx) 883void cxl_native_irq_dump_regs_psl(struct cxl_context *ctx)
879{ 884{
880 u64 fir1, fir2, fir_slice, serr, afu_debug; 885 u64 fir1, fir2, fir_slice, serr, afu_debug;
881 886
@@ -911,7 +916,7 @@ static irqreturn_t native_handle_psl_slice_error(struct cxl_context *ctx,
911 return cxl_ops->ack_irq(ctx, 0, errstat); 916 return cxl_ops->ack_irq(ctx, 0, errstat);
912} 917}
913 918
914static irqreturn_t fail_psl_irq(struct cxl_afu *afu, struct cxl_irq_info *irq_info) 919irqreturn_t cxl_fail_irq_psl(struct cxl_afu *afu, struct cxl_irq_info *irq_info)
915{ 920{
916 if (irq_info->dsisr & CXL_PSL_DSISR_TRANS) 921 if (irq_info->dsisr & CXL_PSL_DSISR_TRANS)
917 cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_AE); 922 cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_AE);
@@ -927,7 +932,7 @@ static irqreturn_t native_irq_multiplexed(int irq, void *data)
927 struct cxl_context *ctx; 932 struct cxl_context *ctx;
928 struct cxl_irq_info irq_info; 933 struct cxl_irq_info irq_info;
929 u64 phreg = cxl_p2n_read(afu, CXL_PSL_PEHandle_An); 934 u64 phreg = cxl_p2n_read(afu, CXL_PSL_PEHandle_An);
930 int ph, ret; 935 int ph, ret = IRQ_HANDLED, res;
931 936
932 /* check if eeh kicked in while the interrupt was in flight */ 937 /* check if eeh kicked in while the interrupt was in flight */
933 if (unlikely(phreg == ~0ULL)) { 938 if (unlikely(phreg == ~0ULL)) {
@@ -938,15 +943,18 @@ static irqreturn_t native_irq_multiplexed(int irq, void *data)
938 } 943 }
939 /* Mask the pe-handle from register value */ 944 /* Mask the pe-handle from register value */
940 ph = phreg & 0xffff; 945 ph = phreg & 0xffff;
941 if ((ret = native_get_irq_info(afu, &irq_info))) { 946 if ((res = native_get_irq_info(afu, &irq_info))) {
942 WARN(1, "Unable to get CXL IRQ Info: %i\n", ret); 947 WARN(1, "Unable to get CXL IRQ Info: %i\n", res);
943 return fail_psl_irq(afu, &irq_info); 948 if (afu->adapter->native->sl_ops->fail_irq)
949 return afu->adapter->native->sl_ops->fail_irq(afu, &irq_info);
950 return ret;
944 } 951 }
945 952
946 rcu_read_lock(); 953 rcu_read_lock();
947 ctx = idr_find(&afu->contexts_idr, ph); 954 ctx = idr_find(&afu->contexts_idr, ph);
948 if (ctx) { 955 if (ctx) {
949 ret = cxl_irq(irq, ctx, &irq_info); 956 if (afu->adapter->native->sl_ops->handle_interrupt)
957 ret = afu->adapter->native->sl_ops->handle_interrupt(irq, ctx, &irq_info);
950 rcu_read_unlock(); 958 rcu_read_unlock();
951 return ret; 959 return ret;
952 } 960 }
@@ -956,7 +964,9 @@ static irqreturn_t native_irq_multiplexed(int irq, void *data)
956 " %016llx\n(Possible AFU HW issue - was a term/remove acked" 964 " %016llx\n(Possible AFU HW issue - was a term/remove acked"
957 " with outstanding transactions?)\n", ph, irq_info.dsisr, 965 " with outstanding transactions?)\n", ph, irq_info.dsisr,
958 irq_info.dar); 966 irq_info.dar);
959 return fail_psl_irq(afu, &irq_info); 967 if (afu->adapter->native->sl_ops->fail_irq)
968 ret = afu->adapter->native->sl_ops->fail_irq(afu, &irq_info);
969 return ret;
960} 970}
961 971
962static void native_irq_wait(struct cxl_context *ctx) 972static void native_irq_wait(struct cxl_context *ctx)