diff options
-rw-r--r-- | litmus/cache_proc.c | 23 | ||||
-rw-r--r-- | litmus/color_shm.c | 116 |
2 files changed, 123 insertions, 16 deletions
diff --git a/litmus/cache_proc.c b/litmus/cache_proc.c index 2f308142d2da..01350294afaf 100644 --- a/litmus/cache_proc.c +++ b/litmus/cache_proc.c | |||
@@ -410,7 +410,9 @@ void do_partition(enum crit_level lv, int cpu) | |||
410 | 410 | ||
411 | } | 411 | } |
412 | barrier(); | 412 | barrier(); |
413 | cache_lockdown(regs, cpu); | 413 | //cache_lockdown(regs, cpu); |
414 | writel_relaxed(regs, cache_base + L2X0_LOCKDOWN_WAY_D_BASE + cpu * L2X0_LOCKDOWN_STRIDE); | ||
415 | writel_relaxed(regs, cache_base + L2X0_LOCKDOWN_WAY_I_BASE + cpu * L2X0_LOCKDOWN_STRIDE); | ||
414 | barrier(); | 416 | barrier(); |
415 | 417 | ||
416 | raw_spin_unlock_irqrestore(&cache_lock, flags); | 418 | raw_spin_unlock_irqrestore(&cache_lock, flags); |
@@ -418,6 +420,25 @@ void do_partition(enum crit_level lv, int cpu) | |||
418 | flush_cache(0); | 420 | flush_cache(0); |
419 | } | 421 | } |
420 | 422 | ||
423 | void lock_cache(int cpu, u32 val) | ||
424 | { | ||
425 | unsigned long flags; | ||
426 | |||
427 | local_irq_save(flags); | ||
428 | if (val != 0xffffffff) { | ||
429 | writel_relaxed(val, cache_base + L2X0_LOCKDOWN_WAY_D_BASE + | ||
430 | cpu * L2X0_LOCKDOWN_STRIDE); | ||
431 | writel_relaxed(val, cache_base + L2X0_LOCKDOWN_WAY_I_BASE + | ||
432 | cpu * L2X0_LOCKDOWN_STRIDE); | ||
433 | } | ||
434 | else { | ||
435 | int i; | ||
436 | for (i = 0; i < 4; i++) | ||
437 | do_partition(CRIT_LEVEL_A, i); | ||
438 | } | ||
439 | local_irq_restore(flags); | ||
440 | } | ||
441 | |||
421 | int use_part_proc_handler(struct ctl_table *table, int write, void __user *buffer, | 442 | int use_part_proc_handler(struct ctl_table *table, int write, void __user *buffer, |
422 | size_t *lenp, loff_t *ppos) | 443 | size_t *lenp, loff_t *ppos) |
423 | { | 444 | { |
diff --git a/litmus/color_shm.c b/litmus/color_shm.c index 1d77957607f0..d4913cd5f213 100644 --- a/litmus/color_shm.c +++ b/litmus/color_shm.c | |||
@@ -21,16 +21,23 @@ | |||
21 | #define NUM_COLORS 16 | 21 | #define NUM_COLORS 16 |
22 | 22 | ||
23 | static struct mutex dev_lock; | 23 | static struct mutex dev_lock; |
24 | static int bypass_cache; | ||
24 | 25 | ||
25 | struct ioctl_cmd { | 26 | struct color_ioctl_cmd { |
26 | unsigned int color; | 27 | unsigned int color; |
27 | unsigned int bank; | 28 | unsigned int bank; |
28 | }; | 29 | }; |
29 | 30 | ||
30 | #define SET_COLOR_SHM_CMD \ | 31 | struct color_ioctl_offset { |
31 | _IOW(SHM_MAJOR, 0x1, struct ioctl_cmd) | 32 | unsigned long offset; |
33 | int lock; | ||
34 | }; | ||
35 | |||
36 | #define SET_COLOR_SHM_CMD _IOW(SHM_MAJOR, 0x1, struct color_ioctl_cmd) | ||
37 | #define SET_COLOR_SHM_OFFSET _IOW(SHM_MAJOR, 0x2, struct color_ioctl_offset) | ||
32 | 38 | ||
33 | struct ioctl_cmd color_param; | 39 | struct color_ioctl_cmd color_param; |
40 | struct color_ioctl_offset color_offset; | ||
34 | 41 | ||
35 | static int mmap_common_checks(struct vm_area_struct *vma) | 42 | static int mmap_common_checks(struct vm_area_struct *vma) |
36 | { | 43 | { |
@@ -66,6 +73,8 @@ static int do_map_colored_page(struct vm_area_struct *vma, | |||
66 | const unsigned long color_no) | 73 | const unsigned long color_no) |
67 | { | 74 | { |
68 | int err = 0; | 75 | int err = 0; |
76 | unsigned long offset = 2048; | ||
77 | |||
69 | struct page *page = get_colored_page(color_no); | 78 | struct page *page = get_colored_page(color_no); |
70 | 79 | ||
71 | if (!page) { | 80 | if (!page) { |
@@ -77,12 +86,16 @@ static int do_map_colored_page(struct vm_area_struct *vma, | |||
77 | 86 | ||
78 | printk(KERN_INFO "vma: %p addr: 0x%lx color_no: %lu\n", | 87 | printk(KERN_INFO "vma: %p addr: 0x%lx color_no: %lu\n", |
79 | vma, addr, color_no); | 88 | vma, addr, color_no); |
89 | |||
90 | printk(KERN_INFO "vm_start: %lu vm_end: %lu\n", | ||
91 | vma->vm_start, vma->vm_end); | ||
80 | 92 | ||
81 | printk(KERN_INFO "inserting page (pa: 0x%lx) at vaddr: 0x%lx " | 93 | printk(KERN_INFO "inserting page (pa: 0x%lx) at vaddr: 0x%lx " |
82 | "flags: 0x%lx prot: 0x%lx\n", | 94 | "flags: 0x%lx prot: 0x%lx\n", |
83 | page_to_phys(page), addr, | 95 | page_to_phys(page), addr, |
84 | vma->vm_flags, pgprot_val(vma->vm_page_prot)); | 96 | vma->vm_flags, pgprot_val(vma->vm_page_prot)); |
85 | 97 | ||
98 | |||
86 | err = vm_insert_page(vma, addr, page); | 99 | err = vm_insert_page(vma, addr, page); |
87 | if (err) { | 100 | if (err) { |
88 | printk(KERN_INFO "vm_insert_page() failed (%d)\n", err); | 101 | printk(KERN_INFO "vm_insert_page() failed (%d)\n", err); |
@@ -101,9 +114,8 @@ static int do_map_colored_pages(struct vm_area_struct *vma) | |||
101 | int cur_bank = -1, cur_color = -1, err = 0; | 114 | int cur_bank = -1, cur_color = -1, err = 0; |
102 | int colors[16] = {0}, banks[8] = {0}; | 115 | int colors[16] = {0}, banks[8] = {0}; |
103 | 116 | ||
104 | //#ifdef CONFIG_PLUGIN_COLOR_UNCACHABLE | 117 | if (bypass_cache == 1) |
105 | // vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); | 118 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); |
106 | //#endif | ||
107 | 119 | ||
108 | for (i = 0; i < NUM_BANKS; i++) { | 120 | for (i = 0; i < NUM_BANKS; i++) { |
109 | if (((color_param.bank >> i)&0x1) == 1) | 121 | if (((color_param.bank >> i)&0x1) == 1) |
@@ -233,6 +245,11 @@ static int litmus_color_shm_mmap(struct file *filp, struct vm_area_struct *vma) | |||
233 | printk(KERN_INFO "color_info not set.\n"); | 245 | printk(KERN_INFO "color_info not set.\n"); |
234 | return -EINVAL; | 246 | return -EINVAL; |
235 | } | 247 | } |
248 | if (color_offset.offset == 0xffffffff || color_offset.lock == -1) { | ||
249 | printk(KERN_INFO "color_offset not set.\n"); | ||
250 | return -EINVAL; | ||
251 | } | ||
252 | |||
236 | err = mmap_common_checks(vma); | 253 | err = mmap_common_checks(vma); |
237 | if (err) { | 254 | if (err) { |
238 | TRACE_CUR("failed mmap common checks\n"); | 255 | TRACE_CUR("failed mmap common checks\n"); |
@@ -247,6 +264,11 @@ static int litmus_color_shm_mmap(struct file *filp, struct vm_area_struct *vma) | |||
247 | TRACE_CUR("flags=0x%lx prot=0x%lx\n", vma->vm_flags, | 264 | TRACE_CUR("flags=0x%lx prot=0x%lx\n", vma->vm_flags, |
248 | pgprot_val(vma->vm_page_prot)); | 265 | pgprot_val(vma->vm_page_prot)); |
249 | out: | 266 | out: |
267 | color_param.color == 0x00000000; | ||
268 | color_param.bank == 0x00000000; | ||
269 | color_offset.offset == 0xffffffff; | ||
270 | color_offset.lock == -1; | ||
271 | |||
250 | return err; | 272 | return err; |
251 | 273 | ||
252 | } | 274 | } |
@@ -254,8 +276,9 @@ out: | |||
254 | static long litmus_color_shm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | 276 | static long litmus_color_shm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
255 | { | 277 | { |
256 | long err = -ENOIOCTLCMD; | 278 | long err = -ENOIOCTLCMD; |
257 | struct ioctl_cmd param; | 279 | struct color_ioctl_cmd color_info; |
258 | 280 | struct color_ioctl_offset color_off; | |
281 | |||
259 | printk(KERN_INFO "color_shm ioctl\n"); | 282 | printk(KERN_INFO "color_shm ioctl\n"); |
260 | 283 | ||
261 | if (_IOC_TYPE(cmd) != SHM_MAJOR) | 284 | if (_IOC_TYPE(cmd) != SHM_MAJOR) |
@@ -264,14 +287,25 @@ static long litmus_color_shm_ioctl(struct file *filp, unsigned int cmd, unsigned | |||
264 | 287 | ||
265 | switch (cmd) { | 288 | switch (cmd) { |
266 | case SET_COLOR_SHM_CMD: | 289 | case SET_COLOR_SHM_CMD: |
267 | err = copy_from_user(¶m, (void*)arg, sizeof(struct ioctl_cmd)); | 290 | |
291 | err = copy_from_user(&color_info, (void*)arg, sizeof(struct color_ioctl_cmd)); | ||
268 | 292 | ||
269 | color_param.color = param.color; | 293 | color_param.color = color_info.color; |
270 | color_param.bank = param.bank; | 294 | color_param.bank = color_info.bank; |
271 | printk(KERN_INFO "COLOR = %x\n", color_param.color); | 295 | printk(KERN_INFO "COLOR = %x\n", color_param.color); |
272 | printk(KERN_INFO "BANK = %x\n", color_param.bank); | 296 | printk(KERN_INFO "BANK = %x\n", color_param.bank); |
273 | err = 0; | 297 | err = 0; |
274 | break; | 298 | break; |
299 | case SET_COLOR_SHM_OFFSET: | ||
300 | err = copy_from_user(&color_off, (void*)arg, sizeof(struct color_ioctl_offset)); | ||
301 | |||
302 | color_offset.offset = color_off.offset; | ||
303 | color_offset.lock = color_off.lock; | ||
304 | printk(KERN_INFO "OFFSET = %x\n", color_offset.offset); | ||
305 | printk(KERN_INFO "LOCK = %d\n", color_offset.lock); | ||
306 | err = 0; | ||
307 | break; | ||
308 | |||
275 | default: | 309 | default: |
276 | printk(KERN_INFO "Invalid IOCTL CMD\n"); | 310 | printk(KERN_INFO "Invalid IOCTL CMD\n"); |
277 | err = -EINVAL; | 311 | err = -EINVAL; |
@@ -292,15 +326,67 @@ static struct miscdevice litmus_color_shm_dev = { | |||
292 | .fops = &litmus_color_shm_fops, | 326 | .fops = &litmus_color_shm_fops, |
293 | }; | 327 | }; |
294 | 328 | ||
329 | struct mutex bypass_mutex; | ||
330 | |||
331 | int bypass_proc_handler(struct ctl_table *table, int write, | ||
332 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
333 | { | ||
334 | int ret, mode; | ||
335 | |||
336 | mutex_lock(&bypass_mutex); | ||
337 | ret = proc_dointvec(table, write, buffer, lenp, ppos); | ||
338 | printk(KERN_INFO "shm_bypass = %d\n", bypass_cache); | ||
339 | mutex_unlock(&bypass_mutex); | ||
340 | |||
341 | return ret; | ||
342 | } | ||
343 | |||
344 | static int zero = 0; | ||
345 | static int one = 1; | ||
346 | |||
347 | static struct ctl_table cache_table[] = | ||
348 | { | ||
349 | { | ||
350 | .procname = "shm_bypass", | ||
351 | .mode = 0666, | ||
352 | .proc_handler = bypass_proc_handler, | ||
353 | .data = &bypass_cache, | ||
354 | .maxlen = sizeof(bypass_cache), | ||
355 | .extra1 = &zero, | ||
356 | .extra2 = &one, | ||
357 | }, | ||
358 | { } | ||
359 | }; | ||
360 | |||
361 | static struct ctl_table litmus_dir_table[] = { | ||
362 | { | ||
363 | .procname = "litmus", | ||
364 | .mode = 0555, | ||
365 | .child = cache_table, | ||
366 | }, | ||
367 | { } | ||
368 | }; | ||
369 | |||
370 | static struct ctl_table_header *litmus_sysctls; | ||
371 | |||
295 | static int __init init_color_shm_devices(void) | 372 | static int __init init_color_shm_devices(void) |
296 | { | 373 | { |
297 | int err; | 374 | int err; |
298 | 375 | ||
299 | printk(KERN_INFO "Registering LITMUS^RT color_shm devices.\n"); | 376 | printk(KERN_INFO "Registering LITMUS^RT color_shm devices.\n"); |
377 | litmus_sysctls = register_sysctl_table(litmus_dir_table); | ||
378 | if (!litmus_sysctls) { | ||
379 | printk(KERN_WARNING "Could not register LITMUS^RT color_shm sysctl.\n"); | ||
380 | err = -EFAULT; | ||
381 | } | ||
382 | |||
300 | mutex_init(&dev_lock); | 383 | mutex_init(&dev_lock); |
301 | color_param.color = 0x0000ffff; | 384 | mutex_init(&bypass_mutex); |
302 | color_param.bank = 0x000000ff; | 385 | color_param.color = 0x00000000; |
303 | 386 | color_param.bank = 0x00000000; | |
387 | color_offset.offset = 0xffffffff; | ||
388 | color_offset.lock = -1; | ||
389 | bypass_cache = 0; | ||
304 | err = misc_register(&litmus_color_shm_dev); | 390 | err = misc_register(&litmus_color_shm_dev); |
305 | 391 | ||
306 | return err; | 392 | return err; |