aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/cxl/native.c
diff options
context:
space:
mode:
authorFrederic Barrat <fbarrat@linux.vnet.ibm.com>2016-03-04 06:26:29 -0500
committerMichael Ellerman <mpe@ellerman.id.au>2016-03-08 21:05:46 -0500
commit2b04cf310ba8c123e9957cfab80274e7606bf53c (patch)
tree38e842b48a0a7f1a0ced74365d5b302895401b30 /drivers/misc/cxl/native.c
parent5be587b1110132b4f05e0bc3515a145365e910fe (diff)
cxl: Rename some bare-metal specific functions
Rename a few functions, changing the 'cxl_' prefix to either 'cxl_pci_' or 'cxl_native_', to make clear that the implementation is bare-metal specific. Those functions will have an equivalent implementation for a guest in a later patch. Co-authored-by: Christophe Lombard <clombard@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clombard@linux.vnet.ibm.com> Reviewed-by: Manoj Kumar <manoj@linux.vnet.ibm.com> Acked-by: Ian Munsie <imunsie@au1.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/misc/cxl/native.c')
-rw-r--r--drivers/misc/cxl/native.c98
1 files changed, 50 insertions, 48 deletions
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index 16d3b1a7d62c..b8a6ad55a5c3 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -80,7 +80,7 @@ int cxl_afu_disable(struct cxl_afu *afu)
80} 80}
81 81
82/* This will disable as well as reset */ 82/* This will disable as well as reset */
83static int __cxl_afu_reset(struct cxl_afu *afu) 83static int native_afu_reset(struct cxl_afu *afu)
84{ 84{
85 pr_devel("AFU reset request\n"); 85 pr_devel("AFU reset request\n");
86 86
@@ -90,7 +90,7 @@ static int __cxl_afu_reset(struct cxl_afu *afu)
90 false); 90 false);
91} 91}
92 92
93static int cxl_afu_check_and_enable(struct cxl_afu *afu) 93static int native_afu_check_and_enable(struct cxl_afu *afu)
94{ 94{
95 if (!cxl_ops->link_ok(afu->adapter)) { 95 if (!cxl_ops->link_ok(afu->adapter)) {
96 WARN(1, "Refusing to enable afu while link down!\n"); 96 WARN(1, "Refusing to enable afu while link down!\n");
@@ -631,7 +631,7 @@ static int deactivate_dedicated_process(struct cxl_afu *afu)
631 return 0; 631 return 0;
632} 632}
633 633
634static int cxl_afu_deactivate_mode(struct cxl_afu *afu, int mode) 634static int native_afu_deactivate_mode(struct cxl_afu *afu, int mode)
635{ 635{
636 if (mode == CXL_MODE_DIRECTED) 636 if (mode == CXL_MODE_DIRECTED)
637 return deactivate_afu_directed(afu); 637 return deactivate_afu_directed(afu);
@@ -640,7 +640,7 @@ static int cxl_afu_deactivate_mode(struct cxl_afu *afu, int mode)
640 return 0; 640 return 0;
641} 641}
642 642
643static int cxl_afu_activate_mode(struct cxl_afu *afu, int mode) 643static int native_afu_activate_mode(struct cxl_afu *afu, int mode)
644{ 644{
645 if (!mode) 645 if (!mode)
646 return 0; 646 return 0;
@@ -660,7 +660,8 @@ static int cxl_afu_activate_mode(struct cxl_afu *afu, int mode)
660 return -EINVAL; 660 return -EINVAL;
661} 661}
662 662
663static int cxl_attach_process(struct cxl_context *ctx, bool kernel, u64 wed, u64 amr) 663static int native_attach_process(struct cxl_context *ctx, bool kernel,
664 u64 wed, u64 amr)
664{ 665{
665 if (!cxl_ops->link_ok(ctx->afu->adapter)) { 666 if (!cxl_ops->link_ok(ctx->afu->adapter)) {
666 WARN(1, "Device link is down, refusing to attach process!\n"); 667 WARN(1, "Device link is down, refusing to attach process!\n");
@@ -697,7 +698,7 @@ static inline int detach_process_native_afu_directed(struct cxl_context *ctx)
697 return 0; 698 return 0;
698} 699}
699 700
700static int cxl_detach_process(struct cxl_context *ctx) 701static int native_detach_process(struct cxl_context *ctx)
701{ 702{
702 trace_cxl_detach(ctx); 703 trace_cxl_detach(ctx);
703 704
@@ -707,7 +708,7 @@ static int cxl_detach_process(struct cxl_context *ctx)
707 return detach_process_native_afu_directed(ctx); 708 return detach_process_native_afu_directed(ctx);
708} 709}
709 710
710static int cxl_get_irq(struct cxl_afu *afu, struct cxl_irq_info *info) 711static int native_get_irq_info(struct cxl_afu *afu, struct cxl_irq_info *info)
711{ 712{
712 u64 pidtid; 713 u64 pidtid;
713 714
@@ -729,7 +730,8 @@ static int cxl_get_irq(struct cxl_afu *afu, struct cxl_irq_info *info)
729 return 0; 730 return 0;
730} 731}
731 732
732static irqreturn_t handle_psl_slice_error(struct cxl_context *ctx, u64 dsisr, u64 errstat) 733static irqreturn_t native_handle_psl_slice_error(struct cxl_context *ctx,
734 u64 dsisr, u64 errstat)
733{ 735{
734 u64 fir1, fir2, fir_slice, serr, afu_debug; 736 u64 fir1, fir2, fir_slice, serr, afu_debug;
735 737
@@ -762,7 +764,7 @@ static irqreturn_t fail_psl_irq(struct cxl_afu *afu, struct cxl_irq_info *irq_in
762 return IRQ_HANDLED; 764 return IRQ_HANDLED;
763} 765}
764 766
765static irqreturn_t cxl_irq_multiplexed(int irq, void *data) 767static irqreturn_t native_irq_multiplexed(int irq, void *data)
766{ 768{
767 struct cxl_afu *afu = data; 769 struct cxl_afu *afu = data;
768 struct cxl_context *ctx; 770 struct cxl_context *ctx;
@@ -770,7 +772,7 @@ static irqreturn_t cxl_irq_multiplexed(int irq, void *data)
770 int ph = cxl_p2n_read(afu, CXL_PSL_PEHandle_An) & 0xffff; 772 int ph = cxl_p2n_read(afu, CXL_PSL_PEHandle_An) & 0xffff;
771 int ret; 773 int ret;
772 774
773 if ((ret = cxl_get_irq(afu, &irq_info))) { 775 if ((ret = native_get_irq_info(afu, &irq_info))) {
774 WARN(1, "Unable to get CXL IRQ Info: %i\n", ret); 776 WARN(1, "Unable to get CXL IRQ Info: %i\n", ret);
775 return fail_psl_irq(afu, &irq_info); 777 return fail_psl_irq(afu, &irq_info);
776 } 778 }
@@ -791,7 +793,7 @@ static irqreturn_t cxl_irq_multiplexed(int irq, void *data)
791 return fail_psl_irq(afu, &irq_info); 793 return fail_psl_irq(afu, &irq_info);
792} 794}
793 795
794static irqreturn_t cxl_slice_irq_err(int irq, void *data) 796static irqreturn_t native_slice_irq_err(int irq, void *data)
795{ 797{
796 struct cxl_afu *afu = data; 798 struct cxl_afu *afu = data;
797 u64 fir_slice, errstat, serr, afu_debug; 799 u64 fir_slice, errstat, serr, afu_debug;
@@ -812,7 +814,7 @@ static irqreturn_t cxl_slice_irq_err(int irq, void *data)
812 return IRQ_HANDLED; 814 return IRQ_HANDLED;
813} 815}
814 816
815static irqreturn_t cxl_irq_err(int irq, void *data) 817static irqreturn_t native_irq_err(int irq, void *data)
816{ 818{
817 struct cxl *adapter = data; 819 struct cxl *adapter = data;
818 u64 fir1, fir2, err_ivte; 820 u64 fir1, fir2, err_ivte;
@@ -833,7 +835,7 @@ static irqreturn_t cxl_irq_err(int irq, void *data)
833 return IRQ_HANDLED; 835 return IRQ_HANDLED;
834} 836}
835 837
836int cxl_register_psl_err_irq(struct cxl *adapter) 838int cxl_native_register_psl_err_irq(struct cxl *adapter)
837{ 839{
838 int rc; 840 int rc;
839 841
@@ -842,7 +844,7 @@ int cxl_register_psl_err_irq(struct cxl *adapter)
842 if (!adapter->irq_name) 844 if (!adapter->irq_name)
843 return -ENOMEM; 845 return -ENOMEM;
844 846
845 if ((rc = cxl_register_one_irq(adapter, cxl_irq_err, adapter, 847 if ((rc = cxl_register_one_irq(adapter, native_irq_err, adapter,
846 &adapter->err_hwirq, 848 &adapter->err_hwirq,
847 &adapter->err_virq, 849 &adapter->err_virq,
848 adapter->irq_name))) { 850 adapter->irq_name))) {
@@ -856,7 +858,7 @@ int cxl_register_psl_err_irq(struct cxl *adapter)
856 return 0; 858 return 0;
857} 859}
858 860
859void cxl_release_psl_err_irq(struct cxl *adapter) 861void cxl_native_release_psl_err_irq(struct cxl *adapter)
860{ 862{
861 if (adapter->err_virq != irq_find_mapping(NULL, adapter->err_hwirq)) 863 if (adapter->err_virq != irq_find_mapping(NULL, adapter->err_hwirq))
862 return; 864 return;
@@ -867,7 +869,7 @@ void cxl_release_psl_err_irq(struct cxl *adapter)
867 kfree(adapter->irq_name); 869 kfree(adapter->irq_name);
868} 870}
869 871
870int cxl_register_serr_irq(struct cxl_afu *afu) 872int cxl_native_register_serr_irq(struct cxl_afu *afu)
871{ 873{
872 u64 serr; 874 u64 serr;
873 int rc; 875 int rc;
@@ -877,7 +879,7 @@ int cxl_register_serr_irq(struct cxl_afu *afu)
877 if (!afu->err_irq_name) 879 if (!afu->err_irq_name)
878 return -ENOMEM; 880 return -ENOMEM;
879 881
880 if ((rc = cxl_register_one_irq(afu->adapter, cxl_slice_irq_err, afu, 882 if ((rc = cxl_register_one_irq(afu->adapter, native_slice_irq_err, afu,
881 &afu->serr_hwirq, 883 &afu->serr_hwirq,
882 &afu->serr_virq, afu->err_irq_name))) { 884 &afu->serr_virq, afu->err_irq_name))) {
883 kfree(afu->err_irq_name); 885 kfree(afu->err_irq_name);
@@ -892,7 +894,7 @@ int cxl_register_serr_irq(struct cxl_afu *afu)
892 return 0; 894 return 0;
893} 895}
894 896
895void cxl_release_serr_irq(struct cxl_afu *afu) 897void cxl_native_release_serr_irq(struct cxl_afu *afu)
896{ 898{
897 if (afu->serr_virq != irq_find_mapping(NULL, afu->serr_hwirq)) 899 if (afu->serr_virq != irq_find_mapping(NULL, afu->serr_hwirq))
898 return; 900 return;
@@ -903,7 +905,7 @@ void cxl_release_serr_irq(struct cxl_afu *afu)
903 kfree(afu->err_irq_name); 905 kfree(afu->err_irq_name);
904} 906}
905 907
906int cxl_register_psl_irq(struct cxl_afu *afu) 908int cxl_native_register_psl_irq(struct cxl_afu *afu)
907{ 909{
908 int rc; 910 int rc;
909 911
@@ -912,7 +914,7 @@ int cxl_register_psl_irq(struct cxl_afu *afu)
912 if (!afu->psl_irq_name) 914 if (!afu->psl_irq_name)
913 return -ENOMEM; 915 return -ENOMEM;
914 916
915 if ((rc = cxl_register_one_irq(afu->adapter, cxl_irq_multiplexed, afu, 917 if ((rc = cxl_register_one_irq(afu->adapter, native_irq_multiplexed, afu,
916 &afu->psl_hwirq, &afu->psl_virq, 918 &afu->psl_hwirq, &afu->psl_virq,
917 afu->psl_irq_name))) { 919 afu->psl_irq_name))) {
918 kfree(afu->psl_irq_name); 920 kfree(afu->psl_irq_name);
@@ -921,7 +923,7 @@ int cxl_register_psl_irq(struct cxl_afu *afu)
921 return rc; 923 return rc;
922} 924}
923 925
924void cxl_release_psl_irq(struct cxl_afu *afu) 926void cxl_native_release_psl_irq(struct cxl_afu *afu)
925{ 927{
926 if (afu->psl_virq != irq_find_mapping(NULL, afu->psl_hwirq)) 928 if (afu->psl_virq != irq_find_mapping(NULL, afu->psl_hwirq))
927 return; 929 return;
@@ -945,7 +947,7 @@ static void recover_psl_err(struct cxl_afu *afu, u64 errstat)
945 cxl_p2n_write(afu, CXL_PSL_ErrStat_An, errstat); 947 cxl_p2n_write(afu, CXL_PSL_ErrStat_An, errstat);
946} 948}
947 949
948static int cxl_ack_irq(struct cxl_context *ctx, u64 tfc, u64 psl_reset_mask) 950static int native_ack_irq(struct cxl_context *ctx, u64 tfc, u64 psl_reset_mask)
949{ 951{
950 trace_cxl_psl_irq_ack(ctx, tfc); 952 trace_cxl_psl_irq_ack(ctx, tfc);
951 if (tfc) 953 if (tfc)
@@ -961,7 +963,7 @@ int cxl_check_error(struct cxl_afu *afu)
961 return (cxl_p1n_read(afu, CXL_PSL_SCNTL_An) == ~0ULL); 963 return (cxl_p1n_read(afu, CXL_PSL_SCNTL_An) == ~0ULL);
962} 964}
963 965
964static int cxl_afu_cr_read64(struct cxl_afu *afu, int cr, u64 off, u64 *out) 966static int native_afu_cr_read64(struct cxl_afu *afu, int cr, u64 off, u64 *out)
965{ 967{
966 if (unlikely(!cxl_ops->link_ok(afu->adapter))) 968 if (unlikely(!cxl_ops->link_ok(afu->adapter)))
967 return -EIO; 969 return -EIO;
@@ -972,7 +974,7 @@ static int cxl_afu_cr_read64(struct cxl_afu *afu, int cr, u64 off, u64 *out)
972 return 0; 974 return 0;
973} 975}
974 976
975static int cxl_afu_cr_read32(struct cxl_afu *afu, int cr, u64 off, u32 *out) 977static int native_afu_cr_read32(struct cxl_afu *afu, int cr, u64 off, u32 *out)
976{ 978{
977 if (unlikely(!cxl_ops->link_ok(afu->adapter))) 979 if (unlikely(!cxl_ops->link_ok(afu->adapter)))
978 return -EIO; 980 return -EIO;
@@ -983,25 +985,25 @@ static int cxl_afu_cr_read32(struct cxl_afu *afu, int cr, u64 off, u32 *out)
983 return 0; 985 return 0;
984} 986}
985 987
986static int cxl_afu_cr_read16(struct cxl_afu *afu, int cr, u64 off, u16 *out) 988static int native_afu_cr_read16(struct cxl_afu *afu, int cr, u64 off, u16 *out)
987{ 989{
988 u64 aligned_off = off & ~0x3L; 990 u64 aligned_off = off & ~0x3L;
989 u32 val; 991 u32 val;
990 int rc; 992 int rc;
991 993
992 rc = cxl_afu_cr_read32(afu, cr, aligned_off, &val); 994 rc = native_afu_cr_read32(afu, cr, aligned_off, &val);
993 if (!rc) 995 if (!rc)
994 *out = (val >> ((off & 0x3) * 8)) & 0xffff; 996 *out = (val >> ((off & 0x3) * 8)) & 0xffff;
995 return rc; 997 return rc;
996} 998}
997 999
998static int cxl_afu_cr_read8(struct cxl_afu *afu, int cr, u64 off, u8 *out) 1000static int native_afu_cr_read8(struct cxl_afu *afu, int cr, u64 off, u8 *out)
999{ 1001{
1000 u64 aligned_off = off & ~0x3L; 1002 u64 aligned_off = off & ~0x3L;
1001 u32 val; 1003 u32 val;
1002 int rc; 1004 int rc;
1003 1005
1004 rc = cxl_afu_cr_read32(afu, cr, aligned_off, &val); 1006 rc = native_afu_cr_read32(afu, cr, aligned_off, &val);
1005 if (!rc) 1007 if (!rc)
1006 *out = (val >> ((off & 0x3) * 8)) & 0xff; 1008 *out = (val >> ((off & 0x3) * 8)) & 0xff;
1007 return rc; 1009 return rc;
@@ -1009,26 +1011,26 @@ static int cxl_afu_cr_read8(struct cxl_afu *afu, int cr, u64 off, u8 *out)
1009 1011
1010const struct cxl_backend_ops cxl_native_ops = { 1012const struct cxl_backend_ops cxl_native_ops = {
1011 .module = THIS_MODULE, 1013 .module = THIS_MODULE,
1012 .adapter_reset = cxl_reset, 1014 .adapter_reset = cxl_pci_reset,
1013 .alloc_one_irq = cxl_alloc_one_irq, 1015 .alloc_one_irq = cxl_pci_alloc_one_irq,
1014 .release_one_irq = cxl_release_one_irq, 1016 .release_one_irq = cxl_pci_release_one_irq,
1015 .alloc_irq_ranges = cxl_alloc_irq_ranges, 1017 .alloc_irq_ranges = cxl_pci_alloc_irq_ranges,
1016 .release_irq_ranges = cxl_release_irq_ranges, 1018 .release_irq_ranges = cxl_pci_release_irq_ranges,
1017 .setup_irq = cxl_setup_irq, 1019 .setup_irq = cxl_pci_setup_irq,
1018 .handle_psl_slice_error = handle_psl_slice_error, 1020 .handle_psl_slice_error = native_handle_psl_slice_error,
1019 .psl_interrupt = NULL, 1021 .psl_interrupt = NULL,
1020 .ack_irq = cxl_ack_irq, 1022 .ack_irq = native_ack_irq,
1021 .attach_process = cxl_attach_process, 1023 .attach_process = native_attach_process,
1022 .detach_process = cxl_detach_process, 1024 .detach_process = native_detach_process,
1023 .link_ok = cxl_adapter_link_ok, 1025 .link_ok = cxl_adapter_link_ok,
1024 .release_afu = cxl_release_afu, 1026 .release_afu = cxl_pci_release_afu,
1025 .afu_read_err_buffer = cxl_afu_read_err_buffer, 1027 .afu_read_err_buffer = cxl_pci_afu_read_err_buffer,
1026 .afu_check_and_enable = cxl_afu_check_and_enable, 1028 .afu_check_and_enable = native_afu_check_and_enable,
1027 .afu_activate_mode = cxl_afu_activate_mode, 1029 .afu_activate_mode = native_afu_activate_mode,
1028 .afu_deactivate_mode = cxl_afu_deactivate_mode, 1030 .afu_deactivate_mode = native_afu_deactivate_mode,
1029 .afu_reset = __cxl_afu_reset, 1031 .afu_reset = native_afu_reset,
1030 .afu_cr_read8 = cxl_afu_cr_read8, 1032 .afu_cr_read8 = native_afu_cr_read8,
1031 .afu_cr_read16 = cxl_afu_cr_read16, 1033 .afu_cr_read16 = native_afu_cr_read16,
1032 .afu_cr_read32 = cxl_afu_cr_read32, 1034 .afu_cr_read32 = native_afu_cr_read32,
1033 .afu_cr_read64 = cxl_afu_cr_read64, 1035 .afu_cr_read64 = native_afu_cr_read64,
1034}; 1036};