| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * vSMPowered(tm) systems specific initialization |
|---|
| 3 | 4 | * Copyright (C) 2005 ScaleMP Inc. |
|---|
| 4 | | - * |
|---|
| 5 | | - * Use of this code is subject to the terms and conditions of the |
|---|
| 6 | | - * GNU general public license version 2. See "COPYING" or |
|---|
| 7 | | - * http://www.gnu.org/licenses/gpl.html |
|---|
| 8 | 5 | * |
|---|
| 9 | 6 | * Ravikiran Thirumalai <kiran@scalemp.com>, |
|---|
| 10 | 7 | * Shai Fultheim <shai@scalemp.com> |
|---|
| .. | .. |
|---|
| 26 | 23 | |
|---|
| 27 | 24 | #define TOPOLOGY_REGISTER_OFFSET 0x10 |
|---|
| 28 | 25 | |
|---|
| 29 | | -#if defined CONFIG_PCI && defined CONFIG_PARAVIRT |
|---|
| 30 | | -/* |
|---|
| 31 | | - * Interrupt control on vSMPowered systems: |
|---|
| 32 | | - * ~AC is a shadow of IF. If IF is 'on' AC should be 'off' |
|---|
| 33 | | - * and vice versa. |
|---|
| 34 | | - */ |
|---|
| 35 | | - |
|---|
| 36 | | -asmlinkage __visible unsigned long vsmp_save_fl(void) |
|---|
| 37 | | -{ |
|---|
| 38 | | - unsigned long flags = native_save_fl(); |
|---|
| 39 | | - |
|---|
| 40 | | - if (!(flags & X86_EFLAGS_IF) || (flags & X86_EFLAGS_AC)) |
|---|
| 41 | | - flags &= ~X86_EFLAGS_IF; |
|---|
| 42 | | - return flags; |
|---|
| 43 | | -} |
|---|
| 44 | | -PV_CALLEE_SAVE_REGS_THUNK(vsmp_save_fl); |
|---|
| 45 | | - |
|---|
| 46 | | -__visible void vsmp_restore_fl(unsigned long flags) |
|---|
| 47 | | -{ |
|---|
| 48 | | - if (flags & X86_EFLAGS_IF) |
|---|
| 49 | | - flags &= ~X86_EFLAGS_AC; |
|---|
| 50 | | - else |
|---|
| 51 | | - flags |= X86_EFLAGS_AC; |
|---|
| 52 | | - native_restore_fl(flags); |
|---|
| 53 | | -} |
|---|
| 54 | | -PV_CALLEE_SAVE_REGS_THUNK(vsmp_restore_fl); |
|---|
| 55 | | - |
|---|
| 56 | | -asmlinkage __visible void vsmp_irq_disable(void) |
|---|
| 57 | | -{ |
|---|
| 58 | | - unsigned long flags = native_save_fl(); |
|---|
| 59 | | - |
|---|
| 60 | | - native_restore_fl((flags & ~X86_EFLAGS_IF) | X86_EFLAGS_AC); |
|---|
| 61 | | -} |
|---|
| 62 | | -PV_CALLEE_SAVE_REGS_THUNK(vsmp_irq_disable); |
|---|
| 63 | | - |
|---|
| 64 | | -asmlinkage __visible void vsmp_irq_enable(void) |
|---|
| 65 | | -{ |
|---|
| 66 | | - unsigned long flags = native_save_fl(); |
|---|
| 67 | | - |
|---|
| 68 | | - native_restore_fl((flags | X86_EFLAGS_IF) & (~X86_EFLAGS_AC)); |
|---|
| 69 | | -} |
|---|
| 70 | | -PV_CALLEE_SAVE_REGS_THUNK(vsmp_irq_enable); |
|---|
| 71 | | - |
|---|
| 72 | | -static unsigned __init vsmp_patch(u8 type, u16 clobbers, void *ibuf, |
|---|
| 73 | | - unsigned long addr, unsigned len) |
|---|
| 74 | | -{ |
|---|
| 75 | | - switch (type) { |
|---|
| 76 | | - case PARAVIRT_PATCH(pv_irq_ops.irq_enable): |
|---|
| 77 | | - case PARAVIRT_PATCH(pv_irq_ops.irq_disable): |
|---|
| 78 | | - case PARAVIRT_PATCH(pv_irq_ops.save_fl): |
|---|
| 79 | | - case PARAVIRT_PATCH(pv_irq_ops.restore_fl): |
|---|
| 80 | | - return paravirt_patch_default(type, clobbers, ibuf, addr, len); |
|---|
| 81 | | - default: |
|---|
| 82 | | - return native_patch(type, clobbers, ibuf, addr, len); |
|---|
| 83 | | - } |
|---|
| 84 | | - |
|---|
| 85 | | -} |
|---|
| 86 | | - |
|---|
| 87 | | -static void __init set_vsmp_pv_ops(void) |
|---|
| 26 | +#ifdef CONFIG_PCI |
|---|
| 27 | +static void __init set_vsmp_ctl(void) |
|---|
| 88 | 28 | { |
|---|
| 89 | 29 | void __iomem *address; |
|---|
| 90 | 30 | unsigned int cap, ctl, cfg; |
|---|
| .. | .. |
|---|
| 109 | 49 | } |
|---|
| 110 | 50 | #endif |
|---|
| 111 | 51 | |
|---|
| 112 | | - if (cap & ctl & (1 << 4)) { |
|---|
| 113 | | - /* Setup irq ops and turn on vSMP IRQ fastpath handling */ |
|---|
| 114 | | - pv_irq_ops.irq_disable = PV_CALLEE_SAVE(vsmp_irq_disable); |
|---|
| 115 | | - pv_irq_ops.irq_enable = PV_CALLEE_SAVE(vsmp_irq_enable); |
|---|
| 116 | | - pv_irq_ops.save_fl = PV_CALLEE_SAVE(vsmp_save_fl); |
|---|
| 117 | | - pv_irq_ops.restore_fl = PV_CALLEE_SAVE(vsmp_restore_fl); |
|---|
| 118 | | - pv_init_ops.patch = vsmp_patch; |
|---|
| 119 | | - ctl &= ~(1 << 4); |
|---|
| 120 | | - } |
|---|
| 121 | 52 | writel(ctl, address + 4); |
|---|
| 122 | 53 | ctl = readl(address + 4); |
|---|
| 123 | 54 | pr_info("vSMP CTL: control set to:0x%08x\n", ctl); |
|---|
| 124 | 55 | |
|---|
| 125 | 56 | early_iounmap(address, 8); |
|---|
| 126 | 57 | } |
|---|
| 127 | | -#else |
|---|
| 128 | | -static void __init set_vsmp_pv_ops(void) |
|---|
| 129 | | -{ |
|---|
| 130 | | -} |
|---|
| 131 | | -#endif |
|---|
| 132 | | - |
|---|
| 133 | | -#ifdef CONFIG_PCI |
|---|
| 134 | 58 | static int is_vsmp = -1; |
|---|
| 135 | 59 | |
|---|
| 136 | 60 | static void __init detect_vsmp_box(void) |
|---|
| .. | .. |
|---|
| 164 | 88 | { |
|---|
| 165 | 89 | return 0; |
|---|
| 166 | 90 | } |
|---|
| 91 | +static void __init set_vsmp_ctl(void) |
|---|
| 92 | +{ |
|---|
| 93 | +} |
|---|
| 167 | 94 | #endif |
|---|
| 168 | 95 | |
|---|
| 169 | 96 | static void __init vsmp_cap_cpus(void) |
|---|
| 170 | 97 | { |
|---|
| 171 | | -#if !defined(CONFIG_X86_VSMP) && defined(CONFIG_SMP) |
|---|
| 98 | +#if !defined(CONFIG_X86_VSMP) && defined(CONFIG_SMP) && defined(CONFIG_PCI) |
|---|
| 172 | 99 | void __iomem *address; |
|---|
| 173 | 100 | unsigned int cfg, topology, node_shift, maxcpus; |
|---|
| 174 | 101 | |
|---|
| .. | .. |
|---|
| 221 | 148 | |
|---|
| 222 | 149 | vsmp_cap_cpus(); |
|---|
| 223 | 150 | |
|---|
| 224 | | - set_vsmp_pv_ops(); |
|---|
| 151 | + set_vsmp_ctl(); |
|---|
| 225 | 152 | return; |
|---|
| 226 | 153 | } |
|---|