Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2010 Tilera Corporation. All Rights Reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation, version 2. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or |
| 11 | * NON INFRINGEMENT. See the GNU General Public License for |
| 12 | * more details. |
| 13 | */ |
| 14 | |
| 15 | #ifndef _ASM_TILE_SMP_H |
| 16 | #define _ASM_TILE_SMP_H |
| 17 | |
| 18 | #ifdef CONFIG_SMP |
| 19 | |
| 20 | #include <asm/processor.h> |
| 21 | #include <linux/cpumask.h> |
| 22 | #include <linux/irqreturn.h> |
| 23 | |
| 24 | /* Set up this tile to support receiving hypervisor messages */ |
| 25 | void init_messaging(void); |
| 26 | |
| 27 | /* Set up this tile to support receiving device interrupts and IPIs. */ |
| 28 | void init_per_tile_IRQs(void); |
| 29 | |
| 30 | /* Send a message to processors specified in mask */ |
| 31 | void send_IPI_many(const struct cpumask *mask, int tag); |
| 32 | |
| 33 | /* Send a message to all but the sending processor */ |
| 34 | void send_IPI_allbutself(int tag); |
| 35 | |
| 36 | /* Send a message to a specific processor */ |
| 37 | void send_IPI_single(int dest, int tag); |
| 38 | |
| 39 | /* Process an IPI message */ |
| 40 | void evaluate_message(int tag); |
| 41 | |
| 42 | /* Process an IRQ_RESCHEDULE IPI. */ |
| 43 | irqreturn_t handle_reschedule_ipi(int irq, void *token); |
| 44 | |
| 45 | /* Boot a secondary cpu */ |
| 46 | void online_secondary(void); |
| 47 | |
| 48 | /* Call a function on a specified set of CPUs (may include this one). */ |
| 49 | extern void on_each_cpu_mask(const struct cpumask *mask, |
| 50 | void (*func)(void *), void *info, bool wait); |
| 51 | |
| 52 | /* Topology of the supervisor tile grid, and coordinates of boot processor */ |
| 53 | extern HV_Topology smp_topology; |
| 54 | |
| 55 | /* Accessors for grid size */ |
| 56 | #define smp_height (smp_topology.height) |
| 57 | #define smp_width (smp_topology.width) |
| 58 | |
| 59 | /* Hypervisor message tags sent via the tile send_IPI*() routines. */ |
| 60 | #define MSG_TAG_START_CPU 1 |
| 61 | #define MSG_TAG_STOP_CPU 2 |
| 62 | #define MSG_TAG_CALL_FUNCTION_MANY 3 |
| 63 | #define MSG_TAG_CALL_FUNCTION_SINGLE 4 |
| 64 | |
| 65 | /* Hook for the generic smp_call_function_many() routine. */ |
| 66 | static inline void arch_send_call_function_ipi_mask(struct cpumask *mask) |
| 67 | { |
| 68 | send_IPI_many(mask, MSG_TAG_CALL_FUNCTION_MANY); |
| 69 | } |
| 70 | |
| 71 | /* Hook for the generic smp_call_function_single() routine. */ |
| 72 | static inline void arch_send_call_function_single_ipi(int cpu) |
| 73 | { |
| 74 | send_IPI_single(cpu, MSG_TAG_CALL_FUNCTION_SINGLE); |
| 75 | } |
| 76 | |
| 77 | /* Print out the boot string describing which cpus were disabled. */ |
| 78 | void print_disabled_cpus(void); |
| 79 | |
| 80 | #else /* !CONFIG_SMP */ |
| 81 | |
| 82 | #define on_each_cpu_mask(mask, func, info, wait) \ |
| 83 | do { if (cpumask_test_cpu(0, (mask))) func(info); } while (0) |
| 84 | |
| 85 | #define smp_master_cpu 0 |
| 86 | #define smp_height 1 |
| 87 | #define smp_width 1 |
| 88 | |
| 89 | #endif /* !CONFIG_SMP */ |
| 90 | |
| 91 | |
| 92 | /* Which cpus may be used as the lotar in a page table entry. */ |
| 93 | extern struct cpumask cpu_lotar_map; |
| 94 | #define cpu_is_valid_lotar(cpu) cpumask_test_cpu((cpu), &cpu_lotar_map) |
| 95 | |
| 96 | #if CHIP_HAS_CBOX_HOME_MAP() |
| 97 | /* Which processors are used for hash-for-home mapping */ |
| 98 | extern struct cpumask hash_for_home_map; |
| 99 | #endif |
| 100 | |
| 101 | /* Which cpus can have their cache flushed by hv_flush_remote(). */ |
| 102 | extern struct cpumask cpu_cacheable_map; |
| 103 | #define cpu_cacheable(cpu) cpumask_test_cpu((cpu), &cpu_cacheable_map) |
| 104 | |
| 105 | /* Convert an HV_LOTAR value into a cpu. */ |
| 106 | static inline int hv_lotar_to_cpu(HV_LOTAR lotar) |
| 107 | { |
| 108 | return HV_LOTAR_X(lotar) + (HV_LOTAR_Y(lotar) * smp_width); |
| 109 | } |
| 110 | |
| 111 | /* |
| 112 | * Extension of <linux/cpumask.h> functionality when you just want |
| 113 | * to express a mask or suppression or inclusion region without |
| 114 | * being too concerned about exactly which cpus are valid in that region. |
| 115 | */ |
| 116 | int bitmap_parselist_crop(const char *bp, unsigned long *maskp, int nmaskbits); |
| 117 | |
| 118 | #define cpulist_parse_crop(buf, dst) \ |
| 119 | __cpulist_parse_crop((buf), (dst), NR_CPUS) |
| 120 | static inline int __cpulist_parse_crop(const char *buf, struct cpumask *dstp, |
| 121 | int nbits) |
| 122 | { |
| 123 | return bitmap_parselist_crop(buf, cpumask_bits(dstp), nbits); |
| 124 | } |
| 125 | |
| 126 | #endif /* _ASM_TILE_SMP_H */ |