Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/powernv: remove unused NPU DMA code

None of these routines were ever used anywhere in the kernel tree
since they were added to the kernel.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Christoph Hellwig and committed by
Michael Ellerman
7eb3cf76 c498a4f9

-581
-2
arch/powerpc/include/asm/book3s/64/mmu.h
··· 116 116 /* Number of users of the external (Nest) MMU */ 117 117 atomic_t copros; 118 118 119 - /* NPU NMMU context */ 120 - struct npu_context *npu_context; 121 119 struct hash_mm_context *hash_context; 122 120 123 121 unsigned long vdso_base;
-22
arch/powerpc/include/asm/powernv.h
··· 11 11 #define _ASM_POWERNV_H 12 12 13 13 #ifdef CONFIG_PPC_POWERNV 14 - #define NPU2_WRITE 1 15 14 extern void powernv_set_nmmu_ptcr(unsigned long ptcr); 16 - extern struct npu_context *pnv_npu2_init_context(struct pci_dev *gpdev, 17 - unsigned long flags, 18 - void (*cb)(struct npu_context *, void *), 19 - void *priv); 20 - extern void pnv_npu2_destroy_context(struct npu_context *context, 21 - struct pci_dev *gpdev); 22 - extern int pnv_npu2_handle_fault(struct npu_context *context, uintptr_t *ea, 23 - unsigned long *flags, unsigned long *status, 24 - int count); 25 15 26 16 void pnv_program_cpu_hotplug_lpcr(unsigned int cpu, u64 lpcr_val); 27 17 28 18 void pnv_tm_init(void); 29 19 #else 30 20 static inline void powernv_set_nmmu_ptcr(unsigned long ptcr) { } 31 - static inline struct npu_context *pnv_npu2_init_context(struct pci_dev *gpdev, 32 - unsigned long flags, 33 - struct npu_context *(*cb)(struct npu_context *, void *), 34 - void *priv) { return ERR_PTR(-ENODEV); } 35 - static inline void pnv_npu2_destroy_context(struct npu_context *context, 36 - struct pci_dev *gpdev) { } 37 - 38 - static inline int pnv_npu2_handle_fault(struct npu_context *context, 39 - uintptr_t *ea, unsigned long *flags, 40 - unsigned long *status, int count) { 41 - return -ENODEV; 42 - } 43 21 44 22 static inline void pnv_tm_init(void) { } 45 23 #endif
-1
arch/powerpc/mm/book3s64/mmu_context.c
··· 179 179 */ 180 180 asm volatile("ptesync;isync" : : : "memory"); 181 181 182 - mm->context.npu_context = NULL; 183 182 mm->context.hash_context = NULL; 184 183 185 184 return index;
-556
arch/powerpc/platforms/powernv/npu-dma.c
··· 22 22 23 23 #include "pci.h" 24 24 25 - /* 26 - * spinlock to protect initialisation of an npu_context for a particular 27 - * mm_struct. 28 - */ 29 - static DEFINE_SPINLOCK(npu_context_lock); 30 - 31 25 static struct pci_dev *get_pci_dev(struct device_node *dn) 32 26 { 33 27 struct pci_dn *pdn = PCI_DN(dn); ··· 369 375 /* An NPU descriptor, valid for POWER9 only */ 370 376 struct npu { 371 377 int index; 372 - __be64 *mmio_atsd_regs[NV_NMMU_ATSD_REGS]; 373 - unsigned int mmio_atsd_count; 374 - 375 - /* Bitmask for MMIO register usage */ 376 - unsigned long mmio_atsd_usage; 377 - 378 - /* Do we need to explicitly flush the nest mmu? */ 379 - bool nmmu_flush; 380 - 381 378 struct npu_comp npucomp; 382 379 }; 383 380 ··· 625 640 } 626 641 #endif /* CONFIG_IOMMU_API */ 627 642 628 - /* Maximum number of nvlinks per npu */ 629 - #define NV_MAX_LINKS 6 630 - 631 - /* Maximum index of npu2 hosts in the system. Always < NV_MAX_NPUS */ 632 - static int max_npu2_index; 633 - 634 - struct npu_context { 635 - struct mm_struct *mm; 636 - struct pci_dev *npdev[NV_MAX_NPUS][NV_MAX_LINKS]; 637 - struct mmu_notifier mn; 638 - struct kref kref; 639 - bool nmmu_flush; 640 - 641 - /* Callback to stop translation requests on a given GPU */ 642 - void (*release_cb)(struct npu_context *context, void *priv); 643 - 644 - /* 645 - * Private pointer passed to the above callback for usage by 646 - * device drivers. 647 - */ 648 - void *priv; 649 - }; 650 - 651 - struct mmio_atsd_reg { 652 - struct npu *npu; 653 - int reg; 654 - }; 655 - 656 - /* 657 - * Find a free MMIO ATSD register and mark it in use. Return -ENOSPC 658 - * if none are available. 659 - */ 660 - static int get_mmio_atsd_reg(struct npu *npu) 661 - { 662 - int i; 663 - 664 - for (i = 0; i < npu->mmio_atsd_count; i++) { 665 - if (!test_bit(i, &npu->mmio_atsd_usage)) 666 - if (!test_and_set_bit_lock(i, &npu->mmio_atsd_usage)) 667 - return i; 668 - } 669 - 670 - return -ENOSPC; 671 - } 672 - 673 - static void put_mmio_atsd_reg(struct npu *npu, int reg) 674 - { 675 - clear_bit_unlock(reg, &npu->mmio_atsd_usage); 676 - } 677 - 678 - /* MMIO ATSD register offsets */ 679 - #define XTS_ATSD_LAUNCH 0 680 - #define XTS_ATSD_AVA 1 681 - #define XTS_ATSD_STAT 2 682 - 683 - static unsigned long get_atsd_launch_val(unsigned long pid, unsigned long psize) 684 - { 685 - unsigned long launch = 0; 686 - 687 - if (psize == MMU_PAGE_COUNT) { 688 - /* IS set to invalidate entire matching PID */ 689 - launch |= PPC_BIT(12); 690 - } else { 691 - /* AP set to invalidate region of psize */ 692 - launch |= (u64)mmu_get_ap(psize) << PPC_BITLSHIFT(17); 693 - } 694 - 695 - /* PRS set to process-scoped */ 696 - launch |= PPC_BIT(13); 697 - 698 - /* PID */ 699 - launch |= pid << PPC_BITLSHIFT(38); 700 - 701 - /* Leave "No flush" (bit 39) 0 so every ATSD performs a flush */ 702 - 703 - return launch; 704 - } 705 - 706 - static void mmio_atsd_regs_write(struct mmio_atsd_reg 707 - mmio_atsd_reg[NV_MAX_NPUS], unsigned long offset, 708 - unsigned long val) 709 - { 710 - struct npu *npu; 711 - int i, reg; 712 - 713 - for (i = 0; i <= max_npu2_index; i++) { 714 - reg = mmio_atsd_reg[i].reg; 715 - if (reg < 0) 716 - continue; 717 - 718 - npu = mmio_atsd_reg[i].npu; 719 - __raw_writeq_be(val, npu->mmio_atsd_regs[reg] + offset); 720 - } 721 - } 722 - 723 - static void mmio_invalidate_pid(struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS], 724 - unsigned long pid) 725 - { 726 - unsigned long launch = get_atsd_launch_val(pid, MMU_PAGE_COUNT); 727 - 728 - /* Invalidating the entire process doesn't use a va */ 729 - mmio_atsd_regs_write(mmio_atsd_reg, XTS_ATSD_LAUNCH, launch); 730 - } 731 - 732 - static void mmio_invalidate_range(struct mmio_atsd_reg 733 - mmio_atsd_reg[NV_MAX_NPUS], unsigned long pid, 734 - unsigned long start, unsigned long psize) 735 - { 736 - unsigned long launch = get_atsd_launch_val(pid, psize); 737 - 738 - /* Write all VAs first */ 739 - mmio_atsd_regs_write(mmio_atsd_reg, XTS_ATSD_AVA, start); 740 - 741 - /* Issue one barrier for all address writes */ 742 - eieio(); 743 - 744 - /* Launch */ 745 - mmio_atsd_regs_write(mmio_atsd_reg, XTS_ATSD_LAUNCH, launch); 746 - } 747 - 748 - #define mn_to_npu_context(x) container_of(x, struct npu_context, mn) 749 - 750 - static void mmio_invalidate_wait( 751 - struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS]) 752 - { 753 - struct npu *npu; 754 - int i, reg; 755 - 756 - /* Wait for all invalidations to complete */ 757 - for (i = 0; i <= max_npu2_index; i++) { 758 - if (mmio_atsd_reg[i].reg < 0) 759 - continue; 760 - 761 - /* Wait for completion */ 762 - npu = mmio_atsd_reg[i].npu; 763 - reg = mmio_atsd_reg[i].reg; 764 - while (__raw_readq(npu->mmio_atsd_regs[reg] + XTS_ATSD_STAT)) 765 - cpu_relax(); 766 - } 767 - } 768 - 769 - /* 770 - * Acquires all the address translation shootdown (ATSD) registers required to 771 - * launch an ATSD on all links this npu_context is active on. 772 - */ 773 - static void acquire_atsd_reg(struct npu_context *npu_context, 774 - struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS]) 775 - { 776 - int i, j; 777 - struct npu *npu; 778 - struct pci_dev *npdev; 779 - 780 - for (i = 0; i <= max_npu2_index; i++) { 781 - mmio_atsd_reg[i].reg = -1; 782 - for (j = 0; j < NV_MAX_LINKS; j++) { 783 - /* 784 - * There are no ordering requirements with respect to 785 - * the setup of struct npu_context, but to ensure 786 - * consistent behaviour we need to ensure npdev[][] is 787 - * only read once. 788 - */ 789 - npdev = READ_ONCE(npu_context->npdev[i][j]); 790 - if (!npdev) 791 - continue; 792 - 793 - npu = pci_bus_to_host(npdev->bus)->npu; 794 - if (!npu) 795 - continue; 796 - 797 - mmio_atsd_reg[i].npu = npu; 798 - mmio_atsd_reg[i].reg = get_mmio_atsd_reg(npu); 799 - while (mmio_atsd_reg[i].reg < 0) { 800 - mmio_atsd_reg[i].reg = get_mmio_atsd_reg(npu); 801 - cpu_relax(); 802 - } 803 - break; 804 - } 805 - } 806 - } 807 - 808 - /* 809 - * Release previously acquired ATSD registers. To avoid deadlocks the registers 810 - * must be released in the same order they were acquired above in 811 - * acquire_atsd_reg. 812 - */ 813 - static void release_atsd_reg(struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS]) 814 - { 815 - int i; 816 - 817 - for (i = 0; i <= max_npu2_index; i++) { 818 - /* 819 - * We can't rely on npu_context->npdev[][] being the same here 820 - * as when acquire_atsd_reg() was called, hence we use the 821 - * values stored in mmio_atsd_reg during the acquire phase 822 - * rather than re-reading npdev[][]. 823 - */ 824 - if (mmio_atsd_reg[i].reg < 0) 825 - continue; 826 - 827 - put_mmio_atsd_reg(mmio_atsd_reg[i].npu, mmio_atsd_reg[i].reg); 828 - } 829 - } 830 - 831 - /* 832 - * Invalidate a virtual address range 833 - */ 834 - static void mmio_invalidate(struct npu_context *npu_context, 835 - unsigned long start, unsigned long size) 836 - { 837 - struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS]; 838 - unsigned long pid = npu_context->mm->context.id; 839 - unsigned long atsd_start = 0; 840 - unsigned long end = start + size - 1; 841 - int atsd_psize = MMU_PAGE_COUNT; 842 - 843 - /* 844 - * Convert the input range into one of the supported sizes. If the range 845 - * doesn't fit, use the next larger supported size. Invalidation latency 846 - * is high, so over-invalidation is preferred to issuing multiple 847 - * invalidates. 848 - * 849 - * A 4K page size isn't supported by NPU/GPU ATS, so that case is 850 - * ignored. 851 - */ 852 - if (size == SZ_64K) { 853 - atsd_start = start; 854 - atsd_psize = MMU_PAGE_64K; 855 - } else if (ALIGN_DOWN(start, SZ_2M) == ALIGN_DOWN(end, SZ_2M)) { 856 - atsd_start = ALIGN_DOWN(start, SZ_2M); 857 - atsd_psize = MMU_PAGE_2M; 858 - } else if (ALIGN_DOWN(start, SZ_1G) == ALIGN_DOWN(end, SZ_1G)) { 859 - atsd_start = ALIGN_DOWN(start, SZ_1G); 860 - atsd_psize = MMU_PAGE_1G; 861 - } 862 - 863 - if (npu_context->nmmu_flush) 864 - /* 865 - * Unfortunately the nest mmu does not support flushing specific 866 - * addresses so we have to flush the whole mm once before 867 - * shooting down the GPU translation. 868 - */ 869 - flush_all_mm(npu_context->mm); 870 - 871 - /* 872 - * Loop over all the NPUs this process is active on and launch 873 - * an invalidate. 874 - */ 875 - acquire_atsd_reg(npu_context, mmio_atsd_reg); 876 - 877 - if (atsd_psize == MMU_PAGE_COUNT) 878 - mmio_invalidate_pid(mmio_atsd_reg, pid); 879 - else 880 - mmio_invalidate_range(mmio_atsd_reg, pid, atsd_start, 881 - atsd_psize); 882 - 883 - mmio_invalidate_wait(mmio_atsd_reg); 884 - 885 - /* 886 - * The GPU requires two flush ATSDs to ensure all entries have been 887 - * flushed. We use PID 0 as it will never be used for a process on the 888 - * GPU. 889 - */ 890 - mmio_invalidate_pid(mmio_atsd_reg, 0); 891 - mmio_invalidate_wait(mmio_atsd_reg); 892 - mmio_invalidate_pid(mmio_atsd_reg, 0); 893 - mmio_invalidate_wait(mmio_atsd_reg); 894 - 895 - release_atsd_reg(mmio_atsd_reg); 896 - } 897 - 898 - static void pnv_npu2_mn_release(struct mmu_notifier *mn, 899 - struct mm_struct *mm) 900 - { 901 - struct npu_context *npu_context = mn_to_npu_context(mn); 902 - 903 - /* Call into device driver to stop requests to the NMMU */ 904 - if (npu_context->release_cb) 905 - npu_context->release_cb(npu_context, npu_context->priv); 906 - 907 - /* 908 - * There should be no more translation requests for this PID, but we 909 - * need to ensure any entries for it are removed from the TLB. 910 - */ 911 - mmio_invalidate(npu_context, 0, ~0UL); 912 - } 913 - 914 - static void pnv_npu2_mn_invalidate_range(struct mmu_notifier *mn, 915 - struct mm_struct *mm, 916 - unsigned long start, unsigned long end) 917 - { 918 - struct npu_context *npu_context = mn_to_npu_context(mn); 919 - mmio_invalidate(npu_context, start, end - start); 920 - } 921 - 922 - static const struct mmu_notifier_ops nv_nmmu_notifier_ops = { 923 - .release = pnv_npu2_mn_release, 924 - .invalidate_range = pnv_npu2_mn_invalidate_range, 925 - }; 926 - 927 - /* 928 - * Call into OPAL to setup the nmmu context for the current task in 929 - * the NPU. This must be called to setup the context tables before the 930 - * GPU issues ATRs. pdev should be a pointed to PCIe GPU device. 931 - * 932 - * A release callback should be registered to allow a device driver to 933 - * be notified that it should not launch any new translation requests 934 - * as the final TLB invalidate is about to occur. 935 - * 936 - * Returns an error if there no contexts are currently available or a 937 - * npu_context which should be passed to pnv_npu2_handle_fault(). 938 - * 939 - * mmap_sem must be held in write mode and must not be called from interrupt 940 - * context. 941 - */ 942 - struct npu_context *pnv_npu2_init_context(struct pci_dev *gpdev, 943 - unsigned long flags, 944 - void (*cb)(struct npu_context *, void *), 945 - void *priv) 946 - { 947 - int rc; 948 - u32 nvlink_index; 949 - struct device_node *nvlink_dn; 950 - struct mm_struct *mm = current->mm; 951 - struct npu *npu; 952 - struct npu_context *npu_context; 953 - struct pci_controller *hose; 954 - 955 - /* 956 - * At present we don't support GPUs connected to multiple NPUs and I'm 957 - * not sure the hardware does either. 958 - */ 959 - struct pci_dev *npdev = pnv_pci_get_npu_dev(gpdev, 0); 960 - 961 - if (!npdev) 962 - /* No nvlink associated with this GPU device */ 963 - return ERR_PTR(-ENODEV); 964 - 965 - /* We only support DR/PR/HV in pnv_npu2_map_lpar_dev() */ 966 - if (flags & ~(MSR_DR | MSR_PR | MSR_HV)) 967 - return ERR_PTR(-EINVAL); 968 - 969 - nvlink_dn = of_parse_phandle(npdev->dev.of_node, "ibm,nvlink", 0); 970 - if (WARN_ON(of_property_read_u32(nvlink_dn, "ibm,npu-link-index", 971 - &nvlink_index))) 972 - return ERR_PTR(-ENODEV); 973 - 974 - if (!mm || mm->context.id == 0) { 975 - /* 976 - * Kernel thread contexts are not supported and context id 0 is 977 - * reserved on the GPU. 978 - */ 979 - return ERR_PTR(-EINVAL); 980 - } 981 - 982 - hose = pci_bus_to_host(npdev->bus); 983 - npu = hose->npu; 984 - if (!npu) 985 - return ERR_PTR(-ENODEV); 986 - 987 - /* 988 - * We store the npu pci device so we can more easily get at the 989 - * associated npus. 990 - */ 991 - spin_lock(&npu_context_lock); 992 - npu_context = mm->context.npu_context; 993 - if (npu_context) { 994 - if (npu_context->release_cb != cb || 995 - npu_context->priv != priv) { 996 - spin_unlock(&npu_context_lock); 997 - return ERR_PTR(-EINVAL); 998 - } 999 - 1000 - WARN_ON(!kref_get_unless_zero(&npu_context->kref)); 1001 - } 1002 - spin_unlock(&npu_context_lock); 1003 - 1004 - if (!npu_context) { 1005 - /* 1006 - * We can set up these fields without holding the 1007 - * npu_context_lock as the npu_context hasn't been returned to 1008 - * the caller meaning it can't be destroyed. Parallel allocation 1009 - * is protected against by mmap_sem. 1010 - */ 1011 - rc = -ENOMEM; 1012 - npu_context = kzalloc(sizeof(struct npu_context), GFP_KERNEL); 1013 - if (npu_context) { 1014 - kref_init(&npu_context->kref); 1015 - npu_context->mm = mm; 1016 - npu_context->mn.ops = &nv_nmmu_notifier_ops; 1017 - rc = __mmu_notifier_register(&npu_context->mn, mm); 1018 - } 1019 - 1020 - if (rc) { 1021 - kfree(npu_context); 1022 - return ERR_PTR(rc); 1023 - } 1024 - 1025 - mm->context.npu_context = npu_context; 1026 - } 1027 - 1028 - npu_context->release_cb = cb; 1029 - npu_context->priv = priv; 1030 - 1031 - /* 1032 - * npdev is a pci_dev pointer setup by the PCI code. We assign it to 1033 - * npdev[][] to indicate to the mmu notifiers that an invalidation 1034 - * should also be sent over this nvlink. The notifiers don't use any 1035 - * other fields in npu_context, so we just need to ensure that when they 1036 - * deference npu_context->npdev[][] it is either a valid pointer or 1037 - * NULL. 1038 - */ 1039 - WRITE_ONCE(npu_context->npdev[npu->index][nvlink_index], npdev); 1040 - 1041 - if (!npu->nmmu_flush) { 1042 - /* 1043 - * If we're not explicitly flushing ourselves we need to mark 1044 - * the thread for global flushes 1045 - */ 1046 - npu_context->nmmu_flush = false; 1047 - mm_context_add_copro(mm); 1048 - } else 1049 - npu_context->nmmu_flush = true; 1050 - 1051 - return npu_context; 1052 - } 1053 - EXPORT_SYMBOL(pnv_npu2_init_context); 1054 - 1055 - static void pnv_npu2_release_context(struct kref *kref) 1056 - { 1057 - struct npu_context *npu_context = 1058 - container_of(kref, struct npu_context, kref); 1059 - 1060 - if (!npu_context->nmmu_flush) 1061 - mm_context_remove_copro(npu_context->mm); 1062 - 1063 - npu_context->mm->context.npu_context = NULL; 1064 - } 1065 - 1066 - /* 1067 - * Destroy a context on the given GPU. May free the npu_context if it is no 1068 - * longer active on any GPUs. Must not be called from interrupt context. 1069 - */ 1070 - void pnv_npu2_destroy_context(struct npu_context *npu_context, 1071 - struct pci_dev *gpdev) 1072 - { 1073 - int removed; 1074 - struct npu *npu; 1075 - struct pci_dev *npdev = pnv_pci_get_npu_dev(gpdev, 0); 1076 - struct device_node *nvlink_dn; 1077 - u32 nvlink_index; 1078 - struct pci_controller *hose; 1079 - 1080 - if (WARN_ON(!npdev)) 1081 - return; 1082 - 1083 - hose = pci_bus_to_host(npdev->bus); 1084 - npu = hose->npu; 1085 - if (!npu) 1086 - return; 1087 - nvlink_dn = of_parse_phandle(npdev->dev.of_node, "ibm,nvlink", 0); 1088 - if (WARN_ON(of_property_read_u32(nvlink_dn, "ibm,npu-link-index", 1089 - &nvlink_index))) 1090 - return; 1091 - WRITE_ONCE(npu_context->npdev[npu->index][nvlink_index], NULL); 1092 - spin_lock(&npu_context_lock); 1093 - removed = kref_put(&npu_context->kref, pnv_npu2_release_context); 1094 - spin_unlock(&npu_context_lock); 1095 - 1096 - /* 1097 - * We need to do this outside of pnv_npu2_release_context so that it is 1098 - * outside the spinlock as mmu_notifier_destroy uses SRCU. 1099 - */ 1100 - if (removed) { 1101 - mmu_notifier_unregister(&npu_context->mn, 1102 - npu_context->mm); 1103 - 1104 - kfree(npu_context); 1105 - } 1106 - 1107 - } 1108 - EXPORT_SYMBOL(pnv_npu2_destroy_context); 1109 - 1110 - /* 1111 - * Assumes mmap_sem is held for the contexts associated mm. 1112 - */ 1113 - int pnv_npu2_handle_fault(struct npu_context *context, uintptr_t *ea, 1114 - unsigned long *flags, unsigned long *status, int count) 1115 - { 1116 - u64 rc = 0, result = 0; 1117 - int i, is_write; 1118 - struct page *page[1]; 1119 - const char __user *u; 1120 - char c; 1121 - 1122 - /* mmap_sem should be held so the struct_mm must be present */ 1123 - struct mm_struct *mm = context->mm; 1124 - 1125 - WARN_ON(!rwsem_is_locked(&mm->mmap_sem)); 1126 - 1127 - for (i = 0; i < count; i++) { 1128 - is_write = flags[i] & NPU2_WRITE; 1129 - rc = get_user_pages_remote(NULL, mm, ea[i], 1, 1130 - is_write ? FOLL_WRITE : 0, 1131 - page, NULL, NULL); 1132 - 1133 - if (rc != 1) { 1134 - status[i] = rc; 1135 - result = -EFAULT; 1136 - continue; 1137 - } 1138 - 1139 - /* Make sure partition scoped tree gets a pte */ 1140 - u = page_address(page[0]); 1141 - if (__get_user(c, u)) 1142 - result = -EFAULT; 1143 - 1144 - status[i] = 0; 1145 - put_page(page[0]); 1146 - } 1147 - 1148 - return result; 1149 - } 1150 - EXPORT_SYMBOL(pnv_npu2_handle_fault); 1151 - 1152 643 int pnv_npu2_init(struct pci_controller *hose) 1153 644 { 1154 - unsigned int i; 1155 - u64 mmio_atsd; 1156 645 static int npu_index; 1157 646 struct npu *npu; 1158 647 int ret; ··· 635 1176 if (!npu) 636 1177 return -ENOMEM; 637 1178 638 - npu->nmmu_flush = of_property_read_bool(hose->dn, "ibm,nmmu-flush"); 639 - 640 - for (i = 0; i < ARRAY_SIZE(npu->mmio_atsd_regs) && 641 - !of_property_read_u64_index(hose->dn, "ibm,mmio-atsd", 642 - i, &mmio_atsd); i++) 643 - npu->mmio_atsd_regs[i] = ioremap(mmio_atsd, 32); 644 - 645 - pr_info("NPU%d: Found %d MMIO ATSD registers", hose->global_number, i); 646 - npu->mmio_atsd_count = i; 647 - npu->mmio_atsd_usage = 0; 648 1179 npu_index++; 649 1180 if (WARN_ON(npu_index >= NV_MAX_NPUS)) { 650 1181 ret = -ENOSPC; 651 1182 goto fail_exit; 652 1183 } 653 - max_npu2_index = npu_index; 654 1184 npu->index = npu_index; 655 1185 hose->npu = npu; 656 1186 657 1187 return 0; 658 1188 659 1189 fail_exit: 660 - for (i = 0; i < npu->mmio_atsd_count; ++i) 661 - iounmap(npu->mmio_atsd_regs[i]); 662 - 663 1190 kfree(npu); 664 - 665 1191 return ret; 666 1192 } 667 1193