hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/powerpc/platforms/pasemi/iommu.c
....@@ -1,20 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2005-2008, PA Semi, Inc
34 *
45 * Maintained by: Olof Johansson <olof@lixom.net>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
186 */
197
208 #undef DEBUG
....@@ -158,7 +146,7 @@
158146 */
159147 iommu_table_iobmap.it_blocksize = 4;
160148 iommu_table_iobmap.it_ops = &iommu_table_iobmap_ops;
161
- iommu_init_table(&iommu_table_iobmap, 0);
149
+ iommu_init_table(&iommu_table_iobmap, 0, 0, 0);
162150 pr_debug(" <- %s\n", __func__);
163151 }
164152
....@@ -186,7 +174,7 @@
186174 */
187175 if (dev->vendor == 0x1959 && dev->device == 0xa007 &&
188176 !firmware_has_feature(FW_FEATURE_LPAR)) {
189
- dev->dev.dma_ops = &dma_nommu_ops;
177
+ dev->dev.dma_ops = NULL;
190178 /*
191179 * Set the coherent DMA mask to prevent the iommu
192180 * being used unnecessarily
....@@ -208,12 +196,17 @@
208196 pr_debug(" -> %s\n", __func__);
209197
210198 /* For 2G space, 8x64 pages (2^21 bytes) is max total l2 size */
211
- iob_l2_base = (u32 *)__va(memblock_alloc_base(1UL<<21, 1UL<<21, 0x80000000));
199
+ iob_l2_base = memblock_alloc_try_nid_raw(1UL << 21, 1UL << 21,
200
+ MEMBLOCK_LOW_LIMIT, 0x80000000,
201
+ NUMA_NO_NODE);
202
+ if (!iob_l2_base)
203
+ panic("%s: Failed to allocate %lu bytes align=0x%lx max_addr=%x\n",
204
+ __func__, 1UL << 21, 1UL << 21, 0x80000000);
212205
213206 pr_info("IOBMAP L2 allocated at: %p\n", iob_l2_base);
214207
215208 /* Allocate a spare page to map all invalid IOTLB pages. */
216
- tmp = memblock_alloc(IOBMAP_PAGE_SIZE, IOBMAP_PAGE_SIZE);
209
+ tmp = memblock_phys_alloc(IOBMAP_PAGE_SIZE, IOBMAP_PAGE_SIZE);
217210 if (!tmp)
218211 panic("IOBMAP: Cannot allocate spare page!");
219212 /* Empty l1 is marked invalid */
....@@ -269,4 +262,3 @@
269262 pasemi_pci_controller_ops.dma_bus_setup = pci_dma_bus_setup_pasemi;
270263 set_pci_dma_ops(&dma_iommu_ops);
271264 }
272
-