Skip to content

Commit 2a3778e

Browse files
committed
parisc: Refactor alternative code to accept multiple conditions
Allow the alternative loop to accept multiple conditions when replacing existing code, e.g. ALTERNATIVE(ALT_COND_NO_SMP | ALT_COND_RUN_ON_QEMU, INSN_NOP) Signed-off-by: Helge Deller <[email protected]>
1 parent fbdc8f0 commit 2a3778e

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

arch/parisc/kernel/alternative.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
2525
struct alt_instr *entry;
2626
int index = 0, applied = 0;
2727
int num_cpus = num_online_cpus();
28+
u32 cond_check;
29+
30+
cond_check = ALT_COND_ALWAYS |
31+
((num_cpus == 1) ? ALT_COND_NO_SMP : 0) |
32+
((cache_info.dc_size == 0) ? ALT_COND_NO_DCACHE : 0) |
33+
((cache_info.ic_size == 0) ? ALT_COND_NO_ICACHE : 0) |
34+
(running_on_qemu ? ALT_COND_RUN_ON_QEMU : 0) |
35+
((split_tlb == 0) ? ALT_COND_NO_SPLIT_TLB : 0) |
36+
/*
37+
* If the PDC_MODEL capabilities has Non-coherent IO-PDIR bit
38+
* set (bit #61, big endian), we have to flush and sync every
39+
* time IO-PDIR is changed in Ike/Astro.
40+
*/
41+
(((boot_cpu_data.cpu_type > pcxw_) &&
42+
((boot_cpu_data.pdc.capabilities & PDC_MODEL_IOPDIR_FDC) == 0))
43+
? ALT_COND_NO_IOC_FDC : 0);
2844

2945
for (entry = start; entry < end; entry++, index++) {
3046

@@ -38,29 +54,14 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
3854

3955
WARN_ON(!cond);
4056

41-
if (cond != ALT_COND_ALWAYS && no_alternatives)
57+
if ((cond & ALT_COND_ALWAYS) == 0 && no_alternatives)
4258
continue;
4359

4460
pr_debug("Check %d: Cond 0x%x, Replace %02d instructions @ 0x%px with 0x%08x\n",
4561
index, cond, len, from, replacement);
4662

47-
if ((cond & ALT_COND_NO_SMP) && (num_cpus != 1))
48-
continue;
49-
if ((cond & ALT_COND_NO_DCACHE) && (cache_info.dc_size != 0))
50-
continue;
51-
if ((cond & ALT_COND_NO_ICACHE) && (cache_info.ic_size != 0))
52-
continue;
53-
if ((cond & ALT_COND_RUN_ON_QEMU) && !running_on_qemu)
54-
continue;
55-
56-
/*
57-
* If the PDC_MODEL capabilities has Non-coherent IO-PDIR bit
58-
* set (bit #61, big endian), we have to flush and sync every
59-
* time IO-PDIR is changed in Ike/Astro.
60-
*/
61-
if ((cond & ALT_COND_NO_IOC_FDC) &&
62-
((boot_cpu_data.cpu_type <= pcxw_) ||
63-
(boot_cpu_data.pdc.capabilities & PDC_MODEL_IOPDIR_FDC)))
63+
/* Bounce out if none of the conditions are true. */
64+
if ((cond & cond_check) == 0)
6465
continue;
6566

6667
/* Want to replace pdtlb by a pdtlb,l instruction? */

0 commit comments

Comments
 (0)