hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/x86/platform/uv/bios_uv.c
....@@ -1,22 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * BIOS run time interface routines.
34 *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License as published by
6
- * the Free Software Foundation; either version 2 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program; if not, write to the Free Software
16
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
- *
18
- * Copyright (c) 2008-2009 Silicon Graphics, Inc. All Rights Reserved.
19
- * Copyright (c) Russ Anderson <rja@sgi.com>
5
+ * (C) Copyright 2020 Hewlett Packard Enterprise Development LP
6
+ * Copyright (C) 2007-2017 Silicon Graphics, Inc. All rights reserved.
7
+ * Copyright (c) Russ Anderson <rja@sgi.com>
208 */
219
2210 #include <linux/efi.h>
....@@ -24,8 +12,11 @@
2412 #include <linux/slab.h>
2513 #include <asm/efi.h>
2614 #include <linux/io.h>
15
+#include <asm/pgalloc.h>
2716 #include <asm/uv/bios.h>
2817 #include <asm/uv/uv_hub.h>
18
+
19
+unsigned long uv_systab_phys __ro_after_init = EFI_INVALID_TABLE_ADDR;
2920
3021 struct uv_systab *uv_systab;
3122
....@@ -41,19 +32,13 @@
4132 */
4233 return BIOS_STATUS_UNIMPLEMENTED;
4334
44
- /*
45
- * If EFI_OLD_MEMMAP is set, we need to fall back to using our old EFI
46
- * callback method, which uses efi_call() directly, with the kernel page tables:
47
- */
48
- if (unlikely(test_bit(EFI_OLD_MEMMAP, &efi.flags)))
49
- ret = efi_call((void *)__va(tab->function), (u64)which, a1, a2, a3, a4, a5);
50
- else
51
- ret = efi_call_virt_pointer(tab, function, (u64)which, a1, a2, a3, a4, a5);
35
+ ret = efi_call_virt_pointer(tab, function, (u64)which, a1, a2, a3, a4, a5);
5236
5337 return ret;
5438 }
5539
56
-s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5)
40
+static s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4,
41
+ u64 a5)
5742 {
5843 s64 ret;
5944
....@@ -65,10 +50,9 @@
6550
6651 return ret;
6752 }
68
-EXPORT_SYMBOL_GPL(uv_bios_call);
6953
70
-s64 uv_bios_call_irqsave(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3,
71
- u64 a4, u64 a5)
54
+static s64 uv_bios_call_irqsave(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3,
55
+ u64 a4, u64 a5)
7256 {
7357 unsigned long bios_flags;
7458 s64 ret;
....@@ -85,30 +69,13 @@
8569 return ret;
8670 }
8771
88
-s64 uv_bios_call_reentrant(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3,
89
- u64 a4, u64 a5)
90
-{
91
- s64 ret;
92
-
93
- preempt_disable();
94
- ret = uv_bios_call(which, a1, a2, a3, a4, a5);
95
- preempt_enable();
96
-
97
- return ret;
98
-}
99
-
100
-
10172 long sn_partition_id;
10273 EXPORT_SYMBOL_GPL(sn_partition_id);
10374 long sn_coherency_id;
104
-EXPORT_SYMBOL_GPL(sn_coherency_id);
10575 long sn_region_size;
10676 EXPORT_SYMBOL_GPL(sn_region_size);
10777 long system_serial_number;
108
-EXPORT_SYMBOL_GPL(system_serial_number);
10978 int uv_type;
110
-EXPORT_SYMBOL_GPL(uv_type);
111
-
11279
11380 s64 uv_bios_get_sn_info(int fc, int *uvtype, long *partid, long *coher,
11481 long *region, long *ssn)
....@@ -135,7 +102,6 @@
135102 *ssn = v1;
136103 return ret;
137104 }
138
-EXPORT_SYMBOL_GPL(uv_bios_get_sn_info);
139105
140106 int
141107 uv_bios_mq_watchlist_alloc(unsigned long addr, unsigned int mq_size,
....@@ -186,7 +152,6 @@
186152 return uv_bios_call(UV_BIOS_FREQ_BASE, clock_type,
187153 (u64)ticks_per_second, 0, 0, 0);
188154 }
189
-EXPORT_SYMBOL_GPL(uv_bios_freq_base);
190155
191156 /*
192157 * uv_bios_set_legacy_vga_target - Set Legacy VGA I/O Target
....@@ -205,23 +170,32 @@
205170 return uv_bios_call(UV_BIOS_SET_LEGACY_VGA_TARGET,
206171 (u64)decode, (u64)domain, (u64)bus, 0, 0);
207172 }
208
-EXPORT_SYMBOL_GPL(uv_bios_set_legacy_vga_target);
209173
210
-#ifdef CONFIG_EFI
211
-void uv_bios_init(void)
174
+unsigned long get_uv_systab_phys(bool msg)
212175 {
213
- uv_systab = NULL;
214
- if ((efi.uv_systab == EFI_INVALID_TABLE_ADDR) ||
215
- !efi.uv_systab || efi_runtime_disabled()) {
216
- pr_crit("UV: UVsystab: missing\n");
217
- return;
176
+ if ((uv_systab_phys == EFI_INVALID_TABLE_ADDR) ||
177
+ !uv_systab_phys || efi_runtime_disabled()) {
178
+ if (msg)
179
+ pr_crit("UV: UVsystab: missing\n");
180
+ return 0;
218181 }
182
+ return uv_systab_phys;
183
+}
219184
220
- uv_systab = ioremap(efi.uv_systab, sizeof(struct uv_systab));
185
+int uv_bios_init(void)
186
+{
187
+ unsigned long uv_systab_phys_addr;
188
+
189
+ uv_systab = NULL;
190
+ uv_systab_phys_addr = get_uv_systab_phys(1);
191
+ if (!uv_systab_phys_addr)
192
+ return -EEXIST;
193
+
194
+ uv_systab = ioremap(uv_systab_phys_addr, sizeof(struct uv_systab));
221195 if (!uv_systab || strncmp(uv_systab->signature, UV_SYSTAB_SIG, 4)) {
222196 pr_err("UV: UVsystab: bad signature!\n");
223197 iounmap(uv_systab);
224
- return;
198
+ return -EINVAL;
225199 }
226200
227201 /* Starting with UV4 the UV systab size is variable */
....@@ -229,12 +203,12 @@
229203 int size = uv_systab->size;
230204
231205 iounmap(uv_systab);
232
- uv_systab = ioremap(efi.uv_systab, size);
206
+ uv_systab = ioremap(uv_systab_phys_addr, size);
233207 if (!uv_systab) {
234208 pr_err("UV: UVsystab: ioremap(%d) failed!\n", size);
235
- return;
209
+ return -EFAULT;
236210 }
237211 }
238212 pr_info("UV: UVsystab: Revision:%x\n", uv_systab->revision);
213
+ return 0;
239214 }
240
-#endif