| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * BIOS run time interface routines. |
|---|
| 3 | 4 | * |
|---|
| 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> |
|---|
| 20 | 8 | */ |
|---|
| 21 | 9 | |
|---|
| 22 | 10 | #include <linux/efi.h> |
|---|
| .. | .. |
|---|
| 24 | 12 | #include <linux/slab.h> |
|---|
| 25 | 13 | #include <asm/efi.h> |
|---|
| 26 | 14 | #include <linux/io.h> |
|---|
| 15 | +#include <asm/pgalloc.h> |
|---|
| 27 | 16 | #include <asm/uv/bios.h> |
|---|
| 28 | 17 | #include <asm/uv/uv_hub.h> |
|---|
| 18 | + |
|---|
| 19 | +unsigned long uv_systab_phys __ro_after_init = EFI_INVALID_TABLE_ADDR; |
|---|
| 29 | 20 | |
|---|
| 30 | 21 | struct uv_systab *uv_systab; |
|---|
| 31 | 22 | |
|---|
| .. | .. |
|---|
| 41 | 32 | */ |
|---|
| 42 | 33 | return BIOS_STATUS_UNIMPLEMENTED; |
|---|
| 43 | 34 | |
|---|
| 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); |
|---|
| 52 | 36 | |
|---|
| 53 | 37 | return ret; |
|---|
| 54 | 38 | } |
|---|
| 55 | 39 | |
|---|
| 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) |
|---|
| 57 | 42 | { |
|---|
| 58 | 43 | s64 ret; |
|---|
| 59 | 44 | |
|---|
| .. | .. |
|---|
| 65 | 50 | |
|---|
| 66 | 51 | return ret; |
|---|
| 67 | 52 | } |
|---|
| 68 | | -EXPORT_SYMBOL_GPL(uv_bios_call); |
|---|
| 69 | 53 | |
|---|
| 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) |
|---|
| 72 | 56 | { |
|---|
| 73 | 57 | unsigned long bios_flags; |
|---|
| 74 | 58 | s64 ret; |
|---|
| .. | .. |
|---|
| 85 | 69 | return ret; |
|---|
| 86 | 70 | } |
|---|
| 87 | 71 | |
|---|
| 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 | | - |
|---|
| 101 | 72 | long sn_partition_id; |
|---|
| 102 | 73 | EXPORT_SYMBOL_GPL(sn_partition_id); |
|---|
| 103 | 74 | long sn_coherency_id; |
|---|
| 104 | | -EXPORT_SYMBOL_GPL(sn_coherency_id); |
|---|
| 105 | 75 | long sn_region_size; |
|---|
| 106 | 76 | EXPORT_SYMBOL_GPL(sn_region_size); |
|---|
| 107 | 77 | long system_serial_number; |
|---|
| 108 | | -EXPORT_SYMBOL_GPL(system_serial_number); |
|---|
| 109 | 78 | int uv_type; |
|---|
| 110 | | -EXPORT_SYMBOL_GPL(uv_type); |
|---|
| 111 | | - |
|---|
| 112 | 79 | |
|---|
| 113 | 80 | s64 uv_bios_get_sn_info(int fc, int *uvtype, long *partid, long *coher, |
|---|
| 114 | 81 | long *region, long *ssn) |
|---|
| .. | .. |
|---|
| 135 | 102 | *ssn = v1; |
|---|
| 136 | 103 | return ret; |
|---|
| 137 | 104 | } |
|---|
| 138 | | -EXPORT_SYMBOL_GPL(uv_bios_get_sn_info); |
|---|
| 139 | 105 | |
|---|
| 140 | 106 | int |
|---|
| 141 | 107 | uv_bios_mq_watchlist_alloc(unsigned long addr, unsigned int mq_size, |
|---|
| .. | .. |
|---|
| 186 | 152 | return uv_bios_call(UV_BIOS_FREQ_BASE, clock_type, |
|---|
| 187 | 153 | (u64)ticks_per_second, 0, 0, 0); |
|---|
| 188 | 154 | } |
|---|
| 189 | | -EXPORT_SYMBOL_GPL(uv_bios_freq_base); |
|---|
| 190 | 155 | |
|---|
| 191 | 156 | /* |
|---|
| 192 | 157 | * uv_bios_set_legacy_vga_target - Set Legacy VGA I/O Target |
|---|
| .. | .. |
|---|
| 205 | 170 | return uv_bios_call(UV_BIOS_SET_LEGACY_VGA_TARGET, |
|---|
| 206 | 171 | (u64)decode, (u64)domain, (u64)bus, 0, 0); |
|---|
| 207 | 172 | } |
|---|
| 208 | | -EXPORT_SYMBOL_GPL(uv_bios_set_legacy_vga_target); |
|---|
| 209 | 173 | |
|---|
| 210 | | -#ifdef CONFIG_EFI |
|---|
| 211 | | -void uv_bios_init(void) |
|---|
| 174 | +unsigned long get_uv_systab_phys(bool msg) |
|---|
| 212 | 175 | { |
|---|
| 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; |
|---|
| 218 | 181 | } |
|---|
| 182 | + return uv_systab_phys; |
|---|
| 183 | +} |
|---|
| 219 | 184 | |
|---|
| 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)); |
|---|
| 221 | 195 | if (!uv_systab || strncmp(uv_systab->signature, UV_SYSTAB_SIG, 4)) { |
|---|
| 222 | 196 | pr_err("UV: UVsystab: bad signature!\n"); |
|---|
| 223 | 197 | iounmap(uv_systab); |
|---|
| 224 | | - return; |
|---|
| 198 | + return -EINVAL; |
|---|
| 225 | 199 | } |
|---|
| 226 | 200 | |
|---|
| 227 | 201 | /* Starting with UV4 the UV systab size is variable */ |
|---|
| .. | .. |
|---|
| 229 | 203 | int size = uv_systab->size; |
|---|
| 230 | 204 | |
|---|
| 231 | 205 | iounmap(uv_systab); |
|---|
| 232 | | - uv_systab = ioremap(efi.uv_systab, size); |
|---|
| 206 | + uv_systab = ioremap(uv_systab_phys_addr, size); |
|---|
| 233 | 207 | if (!uv_systab) { |
|---|
| 234 | 208 | pr_err("UV: UVsystab: ioremap(%d) failed!\n", size); |
|---|
| 235 | | - return; |
|---|
| 209 | + return -EFAULT; |
|---|
| 236 | 210 | } |
|---|
| 237 | 211 | } |
|---|
| 238 | 212 | pr_info("UV: UVsystab: Revision:%x\n", uv_systab->revision); |
|---|
| 213 | + return 0; |
|---|
| 239 | 214 | } |
|---|
| 240 | | -#endif |
|---|