forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/arch/powerpc/platforms/ps3/mm.c
....@@ -1,21 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * PS3 address space management.
34 *
45 * Copyright (C) 2006 Sony Computer Entertainment Inc.
56 * Copyright 2006 Sony Corp.
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; version 2 of the License.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
197 */
208
219 #include <linux/dma-mapping.h>
....@@ -277,7 +265,7 @@
277265 int result;
278266 u64 muid;
279267
280
- r->size = _ALIGN_DOWN(size, 1 << PAGE_SHIFT_16M);
268
+ r->size = ALIGN_DOWN(size, 1 << PAGE_SHIFT_16M);
281269
282270 DBG("%s:%d requested %lxh\n", __func__, __LINE__, size);
283271 DBG("%s:%d actual %llxh\n", __func__, __LINE__, r->size);
....@@ -409,8 +397,8 @@
409397 unsigned long bus_addr, unsigned long len)
410398 {
411399 struct dma_chunk *c;
412
- unsigned long aligned_bus = _ALIGN_DOWN(bus_addr, 1 << r->page_size);
413
- unsigned long aligned_len = _ALIGN_UP(len+bus_addr-aligned_bus,
400
+ unsigned long aligned_bus = ALIGN_DOWN(bus_addr, 1 << r->page_size);
401
+ unsigned long aligned_len = ALIGN(len+bus_addr-aligned_bus,
414402 1 << r->page_size);
415403
416404 list_for_each_entry(c, &r->chunk_list.head, link) {
....@@ -438,8 +426,8 @@
438426 unsigned long lpar_addr, unsigned long len)
439427 {
440428 struct dma_chunk *c;
441
- unsigned long aligned_lpar = _ALIGN_DOWN(lpar_addr, 1 << r->page_size);
442
- unsigned long aligned_len = _ALIGN_UP(len + lpar_addr - aligned_lpar,
429
+ unsigned long aligned_lpar = ALIGN_DOWN(lpar_addr, 1 << r->page_size);
430
+ unsigned long aligned_len = ALIGN(len + lpar_addr - aligned_lpar,
443431 1 << r->page_size);
444432
445433 list_for_each_entry(c, &r->chunk_list.head, link) {
....@@ -790,8 +778,8 @@
790778 struct dma_chunk *c;
791779 unsigned long phys_addr = is_kernel_addr(virt_addr) ? __pa(virt_addr)
792780 : virt_addr;
793
- unsigned long aligned_phys = _ALIGN_DOWN(phys_addr, 1 << r->page_size);
794
- unsigned long aligned_len = _ALIGN_UP(len + phys_addr - aligned_phys,
781
+ unsigned long aligned_phys = ALIGN_DOWN(phys_addr, 1 << r->page_size);
782
+ unsigned long aligned_len = ALIGN(len + phys_addr - aligned_phys,
795783 1 << r->page_size);
796784 *bus_addr = dma_sb_lpar_to_bus(r, ps3_mm_phys_to_lpar(phys_addr));
797785
....@@ -845,8 +833,8 @@
845833 struct dma_chunk *c;
846834 unsigned long phys_addr = is_kernel_addr(virt_addr) ? __pa(virt_addr)
847835 : virt_addr;
848
- unsigned long aligned_phys = _ALIGN_DOWN(phys_addr, 1 << r->page_size);
849
- unsigned long aligned_len = _ALIGN_UP(len + phys_addr - aligned_phys,
836
+ unsigned long aligned_phys = ALIGN_DOWN(phys_addr, 1 << r->page_size);
837
+ unsigned long aligned_len = ALIGN(len + phys_addr - aligned_phys,
850838 1 << r->page_size);
851839
852840 DBG(KERN_ERR "%s: vaddr=%#lx, len=%#lx\n", __func__,
....@@ -904,9 +892,9 @@
904892 c = dma_find_chunk(r, bus_addr, len);
905893
906894 if (!c) {
907
- unsigned long aligned_bus = _ALIGN_DOWN(bus_addr,
895
+ unsigned long aligned_bus = ALIGN_DOWN(bus_addr,
908896 1 << r->page_size);
909
- unsigned long aligned_len = _ALIGN_UP(len + bus_addr
897
+ unsigned long aligned_len = ALIGN(len + bus_addr
910898 - aligned_bus, 1 << r->page_size);
911899 DBG("%s:%d: not found: bus_addr %llxh\n",
912900 __func__, __LINE__, bus_addr);
....@@ -941,9 +929,9 @@
941929 c = dma_find_chunk(r, bus_addr, len);
942930
943931 if (!c) {
944
- unsigned long aligned_bus = _ALIGN_DOWN(bus_addr,
932
+ unsigned long aligned_bus = ALIGN_DOWN(bus_addr,
945933 1 << r->page_size);
946
- unsigned long aligned_len = _ALIGN_UP(len + bus_addr
934
+ unsigned long aligned_len = ALIGN(len + bus_addr
947935 - aligned_bus,
948936 1 << r->page_size);
949937 DBG("%s:%d: not found: bus_addr %llxh\n",
....@@ -989,7 +977,7 @@
989977 pr_info("%s:%d: forcing 16M pages for linear map\n",
990978 __func__, __LINE__);
991979 r->page_size = PS3_DMA_16M;
992
- r->len = _ALIGN_UP(r->len, 1 << r->page_size);
980
+ r->len = ALIGN(r->len, 1 << r->page_size);
993981 }
994982 }
995983
....@@ -1141,7 +1129,7 @@
11411129 r->offset = lpar_addr;
11421130 if (r->offset >= map.rm.size)
11431131 r->offset -= map.r1.offset;
1144
- r->len = len ? len : _ALIGN_UP(map.total, 1 << r->page_size);
1132
+ r->len = len ? len : ALIGN(map.total, 1 << r->page_size);
11451133
11461134 dev->core.dma_mask = &r->dma_mask;
11471135