Skip to content

Commit b8ace08

Browse files
arch/tile: fix hardwall for tilegx and generalize for idn and ipi
The hardwall drain code was not properly implemented for tilegx, just tilepro, so you couldn't reliably restart an application that made use of the udn. In addition, the code was only applicable to the udn (user dynamic network). On tilegx there is a second user network that is available (the "idn"), and there is support for having I/O shims deliver user-level interrupts to applications ("ipi") which functions in a very similar way to the inter-core permissions used for udn/idn. So this change also generalizes the code from supporting just the udn to supports udn/idn/ipi on tilegx. By default we now use /dev/hardwall/{udn,idn,ipi} with separate minor numbers for the three devices. Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
1 parent 621b195 commit b8ace08

8 files changed

Lines changed: 636 additions & 280 deletions

File tree

‎arch/tile/include/arch/spr_def_32.h‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,31 @@
6565
#define SPR_EX_CONTEXT_2_1__ICS_RMASK 0x1
6666
#define SPR_EX_CONTEXT_2_1__ICS_MASK 0x4
6767
#define SPR_FAIL 0x4e09
68+
#define SPR_IDN_AVAIL_EN 0x3e05
69+
#define SPR_IDN_CA_DATA 0x0b00
70+
#define SPR_IDN_DATA_AVAIL 0x0b03
71+
#define SPR_IDN_DEADLOCK_TIMEOUT 0x3406
72+
#define SPR_IDN_DEMUX_CA_COUNT 0x0a05
73+
#define SPR_IDN_DEMUX_COUNT_0 0x0a06
74+
#define SPR_IDN_DEMUX_COUNT_1 0x0a07
75+
#define SPR_IDN_DEMUX_CTL 0x0a08
76+
#define SPR_IDN_DEMUX_QUEUE_SEL 0x0a0a
77+
#define SPR_IDN_DEMUX_STATUS 0x0a0b
78+
#define SPR_IDN_DEMUX_WRITE_FIFO 0x0a0c
79+
#define SPR_IDN_DIRECTION_PROTECT 0x2e05
80+
#define SPR_IDN_PENDING 0x0a0e
81+
#define SPR_IDN_REFILL_EN 0x0e05
82+
#define SPR_IDN_SP_FIFO_DATA 0x0a0f
83+
#define SPR_IDN_SP_FIFO_SEL 0x0a10
84+
#define SPR_IDN_SP_FREEZE 0x0a11
85+
#define SPR_IDN_SP_FREEZE__SP_FRZ_MASK 0x1
86+
#define SPR_IDN_SP_FREEZE__DEMUX_FRZ_MASK 0x2
87+
#define SPR_IDN_SP_FREEZE__NON_DEST_EXT_MASK 0x4
88+
#define SPR_IDN_SP_STATE 0x0a12
89+
#define SPR_IDN_TAG_0 0x0a13
90+
#define SPR_IDN_TAG_1 0x0a14
91+
#define SPR_IDN_TAG_VALID 0x0a15
92+
#define SPR_IDN_TILE_COORD 0x0a16
6893
#define SPR_INTCTRL_0_STATUS 0x4a07
6994
#define SPR_INTCTRL_1_STATUS 0x4807
7095
#define SPR_INTCTRL_2_STATUS 0x4607
@@ -87,12 +112,36 @@
87112
#define SPR_INTERRUPT_MASK_SET_1_1 0x480e
88113
#define SPR_INTERRUPT_MASK_SET_2_0 0x460c
89114
#define SPR_INTERRUPT_MASK_SET_2_1 0x460d
115+
#define SPR_MPL_AUX_PERF_COUNT_SET_0 0x6000
116+
#define SPR_MPL_AUX_PERF_COUNT_SET_1 0x6001
117+
#define SPR_MPL_AUX_PERF_COUNT_SET_2 0x6002
90118
#define SPR_MPL_DMA_CPL_SET_0 0x5800
91119
#define SPR_MPL_DMA_CPL_SET_1 0x5801
92120
#define SPR_MPL_DMA_CPL_SET_2 0x5802
93121
#define SPR_MPL_DMA_NOTIFY_SET_0 0x3800
94122
#define SPR_MPL_DMA_NOTIFY_SET_1 0x3801
95123
#define SPR_MPL_DMA_NOTIFY_SET_2 0x3802
124+
#define SPR_MPL_IDN_ACCESS_SET_0 0x0a00
125+
#define SPR_MPL_IDN_ACCESS_SET_1 0x0a01
126+
#define SPR_MPL_IDN_ACCESS_SET_2 0x0a02
127+
#define SPR_MPL_IDN_AVAIL_SET_0 0x3e00
128+
#define SPR_MPL_IDN_AVAIL_SET_1 0x3e01
129+
#define SPR_MPL_IDN_AVAIL_SET_2 0x3e02
130+
#define SPR_MPL_IDN_CA_SET_0 0x3a00
131+
#define SPR_MPL_IDN_CA_SET_1 0x3a01
132+
#define SPR_MPL_IDN_CA_SET_2 0x3a02
133+
#define SPR_MPL_IDN_COMPLETE_SET_0 0x1200
134+
#define SPR_MPL_IDN_COMPLETE_SET_1 0x1201
135+
#define SPR_MPL_IDN_COMPLETE_SET_2 0x1202
136+
#define SPR_MPL_IDN_FIREWALL_SET_0 0x2e00
137+
#define SPR_MPL_IDN_FIREWALL_SET_1 0x2e01
138+
#define SPR_MPL_IDN_FIREWALL_SET_2 0x2e02
139+
#define SPR_MPL_IDN_REFILL_SET_0 0x0e00
140+
#define SPR_MPL_IDN_REFILL_SET_1 0x0e01
141+
#define SPR_MPL_IDN_REFILL_SET_2 0x0e02
142+
#define SPR_MPL_IDN_TIMER_SET_0 0x3400
143+
#define SPR_MPL_IDN_TIMER_SET_1 0x3401
144+
#define SPR_MPL_IDN_TIMER_SET_2 0x3402
96145
#define SPR_MPL_INTCTRL_0_SET_0 0x4a00
97146
#define SPR_MPL_INTCTRL_0_SET_1 0x4a01
98147
#define SPR_MPL_INTCTRL_0_SET_2 0x4a02
@@ -102,6 +151,9 @@
102151
#define SPR_MPL_INTCTRL_2_SET_0 0x4600
103152
#define SPR_MPL_INTCTRL_2_SET_1 0x4601
104153
#define SPR_MPL_INTCTRL_2_SET_2 0x4602
154+
#define SPR_MPL_PERF_COUNT_SET_0 0x4200
155+
#define SPR_MPL_PERF_COUNT_SET_1 0x4201
156+
#define SPR_MPL_PERF_COUNT_SET_2 0x4202
105157
#define SPR_MPL_SN_ACCESS_SET_0 0x0800
106158
#define SPR_MPL_SN_ACCESS_SET_1 0x0801
107159
#define SPR_MPL_SN_ACCESS_SET_2 0x0802
@@ -181,6 +233,7 @@
181233
#define SPR_UDN_DEMUX_STATUS 0x0c0d
182234
#define SPR_UDN_DEMUX_WRITE_FIFO 0x0c0e
183235
#define SPR_UDN_DIRECTION_PROTECT 0x3005
236+
#define SPR_UDN_PENDING 0x0c10
184237
#define SPR_UDN_REFILL_EN 0x1005
185238
#define SPR_UDN_SP_FIFO_DATA 0x0c11
186239
#define SPR_UDN_SP_FIFO_SEL 0x0c12
@@ -195,6 +248,9 @@
195248
#define SPR_UDN_TAG_3 0x0c18
196249
#define SPR_UDN_TAG_VALID 0x0c19
197250
#define SPR_UDN_TILE_COORD 0x0c1a
251+
#define SPR_WATCH_CTL 0x4209
252+
#define SPR_WATCH_MASK 0x420a
253+
#define SPR_WATCH_VAL 0x420b
198254

199255
#endif /* !defined(__ARCH_SPR_DEF_H__) */
200256

‎arch/tile/include/arch/spr_def_64.h‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
#define SPR_EX_CONTEXT_2_1__ICS_RMASK 0x1
5353
#define SPR_EX_CONTEXT_2_1__ICS_MASK 0x4
5454
#define SPR_FAIL 0x2707
55+
#define SPR_IDN_AVAIL_EN 0x1a05
56+
#define SPR_IDN_DATA_AVAIL 0x0a80
57+
#define SPR_IDN_DEADLOCK_TIMEOUT 0x1806
58+
#define SPR_IDN_DEMUX_COUNT_0 0x0a05
59+
#define SPR_IDN_DEMUX_COUNT_1 0x0a06
60+
#define SPR_IDN_DIRECTION_PROTECT 0x1405
61+
#define SPR_IDN_PENDING 0x0a08
5562
#define SPR_ILL_TRANS_REASON__I_STREAM_VA_RMASK 0x1
5663
#define SPR_INTCTRL_0_STATUS 0x2505
5764
#define SPR_INTCTRL_1_STATUS 0x2405
@@ -88,9 +95,27 @@
8895
#define SPR_IPI_MASK_SET_0 0x1f0a
8996
#define SPR_IPI_MASK_SET_1 0x1e0a
9097
#define SPR_IPI_MASK_SET_2 0x1d0a
98+
#define SPR_MPL_AUX_PERF_COUNT_SET_0 0x2100
99+
#define SPR_MPL_AUX_PERF_COUNT_SET_1 0x2101
100+
#define SPR_MPL_AUX_PERF_COUNT_SET_2 0x2102
91101
#define SPR_MPL_AUX_TILE_TIMER_SET_0 0x1700
92102
#define SPR_MPL_AUX_TILE_TIMER_SET_1 0x1701
93103
#define SPR_MPL_AUX_TILE_TIMER_SET_2 0x1702
104+
#define SPR_MPL_IDN_ACCESS_SET_0 0x0a00
105+
#define SPR_MPL_IDN_ACCESS_SET_1 0x0a01
106+
#define SPR_MPL_IDN_ACCESS_SET_2 0x0a02
107+
#define SPR_MPL_IDN_AVAIL_SET_0 0x1a00
108+
#define SPR_MPL_IDN_AVAIL_SET_1 0x1a01
109+
#define SPR_MPL_IDN_AVAIL_SET_2 0x1a02
110+
#define SPR_MPL_IDN_COMPLETE_SET_0 0x0500
111+
#define SPR_MPL_IDN_COMPLETE_SET_1 0x0501
112+
#define SPR_MPL_IDN_COMPLETE_SET_2 0x0502
113+
#define SPR_MPL_IDN_FIREWALL_SET_0 0x1400
114+
#define SPR_MPL_IDN_FIREWALL_SET_1 0x1401
115+
#define SPR_MPL_IDN_FIREWALL_SET_2 0x1402
116+
#define SPR_MPL_IDN_TIMER_SET_0 0x1800
117+
#define SPR_MPL_IDN_TIMER_SET_1 0x1801
118+
#define SPR_MPL_IDN_TIMER_SET_2 0x1802
94119
#define SPR_MPL_INTCTRL_0_SET_0 0x2500
95120
#define SPR_MPL_INTCTRL_0_SET_1 0x2501
96121
#define SPR_MPL_INTCTRL_0_SET_2 0x2502
@@ -100,6 +125,21 @@
100125
#define SPR_MPL_INTCTRL_2_SET_0 0x2300
101126
#define SPR_MPL_INTCTRL_2_SET_1 0x2301
102127
#define SPR_MPL_INTCTRL_2_SET_2 0x2302
128+
#define SPR_MPL_IPI_0 0x1f04
129+
#define SPR_MPL_IPI_0_SET_0 0x1f00
130+
#define SPR_MPL_IPI_0_SET_1 0x1f01
131+
#define SPR_MPL_IPI_0_SET_2 0x1f02
132+
#define SPR_MPL_IPI_1 0x1e04
133+
#define SPR_MPL_IPI_1_SET_0 0x1e00
134+
#define SPR_MPL_IPI_1_SET_1 0x1e01
135+
#define SPR_MPL_IPI_1_SET_2 0x1e02
136+
#define SPR_MPL_IPI_2 0x1d04
137+
#define SPR_MPL_IPI_2_SET_0 0x1d00
138+
#define SPR_MPL_IPI_2_SET_1 0x1d01
139+
#define SPR_MPL_IPI_2_SET_2 0x1d02
140+
#define SPR_MPL_PERF_COUNT_SET_0 0x2000
141+
#define SPR_MPL_PERF_COUNT_SET_1 0x2001
142+
#define SPR_MPL_PERF_COUNT_SET_2 0x2002
103143
#define SPR_MPL_UDN_ACCESS_SET_0 0x0b00
104144
#define SPR_MPL_UDN_ACCESS_SET_1 0x0b01
105145
#define SPR_MPL_UDN_ACCESS_SET_2 0x0b02
@@ -167,6 +207,9 @@
167207
#define SPR_UDN_DEMUX_COUNT_2 0x0b07
168208
#define SPR_UDN_DEMUX_COUNT_3 0x0b08
169209
#define SPR_UDN_DIRECTION_PROTECT 0x1505
210+
#define SPR_UDN_PENDING 0x0b0a
211+
#define SPR_WATCH_MASK 0x200a
212+
#define SPR_WATCH_VAL 0x200b
170213

171214
#endif /* !defined(__ARCH_SPR_DEF_H__) */
172215

‎arch/tile/include/asm/hardwall.h‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,24 @@
1111
* NON INFRINGEMENT. See the GNU General Public License for
1212
* more details.
1313
*
14-
* Provide methods for the HARDWALL_FILE for accessing the UDN.
14+
* Provide methods for access control of per-cpu resources like
15+
* UDN, IDN, or IPI.
1516
*/
1617

1718
#ifndef _ASM_TILE_HARDWALL_H
1819
#define _ASM_TILE_HARDWALL_H
1920

21+
#include <arch/chip.h>
2022
#include <linux/ioctl.h>
2123

2224
#define HARDWALL_IOCTL_BASE 0xa2
2325

2426
/*
2527
* The HARDWALL_CREATE() ioctl is a macro with a "size" argument.
2628
* The resulting ioctl value is passed to the kernel in conjunction
27-
* with a pointer to a little-endian bitmask of cpus, which must be
28-
* physically in a rectangular configuration on the chip.
29+
* with a pointer to a standard kernel bitmask of cpus.
30+
* For network resources (UDN or IDN) the bitmask must physically
31+
* represent a rectangular configuration on the chip.
2932
* The "size" is the number of bytes of cpu mask data.
3033
*/
3134
#define _HARDWALL_CREATE 1
@@ -44,13 +47,7 @@
4447
#define HARDWALL_GET_ID \
4548
_IO(HARDWALL_IOCTL_BASE, _HARDWALL_GET_ID)
4649

47-
#ifndef __KERNEL__
48-
49-
/* This is the canonical name expected by userspace. */
50-
#define HARDWALL_FILE "/dev/hardwall"
51-
52-
#else
53-
50+
#ifdef __KERNEL__
5451
/* /proc hooks for hardwall. */
5552
struct proc_dir_entry;
5653
#ifdef CONFIG_HARDWALL
@@ -59,7 +56,6 @@ int proc_pid_hardwall(struct task_struct *task, char *buffer);
5956
#else
6057
static inline void proc_tile_hardwall_init(struct proc_dir_entry *root) {}
6158
#endif
62-
6359
#endif
6460

6561
#endif /* _ASM_TILE_HARDWALL_H */

‎arch/tile/include/asm/processor.h‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ struct async_tlb {
7676

7777
#ifdef CONFIG_HARDWALL
7878
struct hardwall_info;
79+
struct hardwall_task {
80+
/* Which hardwall is this task tied to? (or NULL if none) */
81+
struct hardwall_info *info;
82+
/* Chains this task into the list at info->task_head. */
83+
struct list_head list;
84+
};
85+
#ifdef __tilepro__
86+
#define HARDWALL_TYPES 1 /* udn */
87+
#else
88+
#define HARDWALL_TYPES 3 /* udn, idn, and ipi */
89+
#endif
7990
#endif
8091

8192
struct thread_struct {
@@ -116,10 +127,8 @@ struct thread_struct {
116127
unsigned long dstream_pf;
117128
#endif
118129
#ifdef CONFIG_HARDWALL
119-
/* Is this task tied to an activated hardwall? */
120-
struct hardwall_info *hardwall;
121-
/* Chains this task into the list at hardwall->list. */
122-
struct list_head hardwall_list;
130+
/* Hardwall information for various resources. */
131+
struct hardwall_task hardwall[HARDWALL_TYPES];
123132
#endif
124133
#if CHIP_HAS_TILE_DMA()
125134
/* Async DMA TLB fault information */

‎arch/tile/include/asm/setup.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ void restrict_dma_mpls(void);
4141
#ifdef CONFIG_HARDWALL
4242
/* User-level network management functions */
4343
void reset_network_state(void);
44-
void grant_network_mpls(void);
45-
void restrict_network_mpls(void);
4644
struct task_struct;
47-
int hardwall_deactivate(struct task_struct *task);
45+
void hardwall_switch_tasks(struct task_struct *prev, struct task_struct *next);
46+
void hardwall_deactivate_all(struct task_struct *task);
47+
int hardwall_ipi_valid(int cpu);
4848

4949
/* Hook hardwall code into changes in affinity. */
5050
#define arch_set_cpus_allowed(p, new_mask) do { \
51-
if (p->thread.hardwall && !cpumask_equal(&p->cpus_allowed, new_mask)) \
52-
hardwall_deactivate(p); \
51+
if (!cpumask_equal(&p->cpus_allowed, new_mask)) \
52+
hardwall_deactivate_all(p); \
5353
} while (0)
5454
#endif
5555

0 commit comments

Comments
 (0)