aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/mm/sram-alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin/mm/sram-alloc.c')
-rw-r--r--arch/blackfin/mm/sram-alloc.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/arch/blackfin/mm/sram-alloc.c b/arch/blackfin/mm/sram-alloc.c
index f068c11ea98f..627e04b5ba9a 100644
--- a/arch/blackfin/mm/sram-alloc.c
+++ b/arch/blackfin/mm/sram-alloc.c
@@ -17,6 +17,7 @@
17#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
18#include <linux/spinlock.h> 18#include <linux/spinlock.h>
19#include <linux/rtc.h> 19#include <linux/rtc.h>
20#include <linux/slab.h>
20#include <asm/blackfin.h> 21#include <asm/blackfin.h>
21#include <asm/mem_map.h> 22#include <asm/mem_map.h>
22#include "blackfin_sram.h" 23#include "blackfin_sram.h"
@@ -255,7 +256,8 @@ static void *_sram_alloc(size_t size, struct sram_piece *pfree_head,
255 plast->next = pslot->next; 256 plast->next = pslot->next;
256 pavail = pslot; 257 pavail = pslot;
257 } else { 258 } else {
258 pavail = kmem_cache_alloc(sram_piece_cache, GFP_KERNEL); 259 /* use atomic so our L1 allocator can be used atomically */
260 pavail = kmem_cache_alloc(sram_piece_cache, GFP_ATOMIC);
259 261
260 if (!pavail) 262 if (!pavail)
261 return NULL; 263 return NULL;
@@ -402,7 +404,7 @@ void *l1_data_A_sram_alloc(size_t size)
402 void *addr; 404 void *addr;
403 unsigned int cpu; 405 unsigned int cpu;
404 406
405 cpu = get_cpu(); 407 cpu = smp_processor_id();
406 /* add mutex operation */ 408 /* add mutex operation */
407 spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags); 409 spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags);
408 410
@@ -411,7 +413,6 @@ void *l1_data_A_sram_alloc(size_t size)
411 413
412 /* add mutex operation */ 414 /* add mutex operation */
413 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags); 415 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags);
414 put_cpu();
415 416
416 pr_debug("Allocated address in l1_data_A_sram_alloc is 0x%lx+0x%lx\n", 417 pr_debug("Allocated address in l1_data_A_sram_alloc is 0x%lx+0x%lx\n",
417 (long unsigned int)addr, size); 418 (long unsigned int)addr, size);
@@ -430,7 +431,7 @@ int l1_data_A_sram_free(const void *addr)
430 int ret; 431 int ret;
431 unsigned int cpu; 432 unsigned int cpu;
432 433
433 cpu = get_cpu(); 434 cpu = smp_processor_id();
434 /* add mutex operation */ 435 /* add mutex operation */
435 spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags); 436 spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags);
436 437
@@ -439,7 +440,6 @@ int l1_data_A_sram_free(const void *addr)
439 440
440 /* add mutex operation */ 441 /* add mutex operation */
441 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags); 442 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags);
442 put_cpu();
443 443
444 return ret; 444 return ret;
445#else 445#else
@@ -455,7 +455,7 @@ void *l1_data_B_sram_alloc(size_t size)
455 void *addr; 455 void *addr;
456 unsigned int cpu; 456 unsigned int cpu;
457 457
458 cpu = get_cpu(); 458 cpu = smp_processor_id();
459 /* add mutex operation */ 459 /* add mutex operation */
460 spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags); 460 spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags);
461 461
@@ -464,7 +464,6 @@ void *l1_data_B_sram_alloc(size_t size)
464 464
465 /* add mutex operation */ 465 /* add mutex operation */
466 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags); 466 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags);
467 put_cpu();
468 467
469 pr_debug("Allocated address in l1_data_B_sram_alloc is 0x%lx+0x%lx\n", 468 pr_debug("Allocated address in l1_data_B_sram_alloc is 0x%lx+0x%lx\n",
470 (long unsigned int)addr, size); 469 (long unsigned int)addr, size);
@@ -483,7 +482,7 @@ int l1_data_B_sram_free(const void *addr)
483 int ret; 482 int ret;
484 unsigned int cpu; 483 unsigned int cpu;
485 484
486 cpu = get_cpu(); 485 cpu = smp_processor_id();
487 /* add mutex operation */ 486 /* add mutex operation */
488 spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags); 487 spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags);
489 488
@@ -492,7 +491,6 @@ int l1_data_B_sram_free(const void *addr)
492 491
493 /* add mutex operation */ 492 /* add mutex operation */
494 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags); 493 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags);
495 put_cpu();
496 494
497 return ret; 495 return ret;
498#else 496#else
@@ -540,7 +538,7 @@ void *l1_inst_sram_alloc(size_t size)
540 void *addr; 538 void *addr;
541 unsigned int cpu; 539 unsigned int cpu;
542 540
543 cpu = get_cpu(); 541 cpu = smp_processor_id();
544 /* add mutex operation */ 542 /* add mutex operation */
545 spin_lock_irqsave(&per_cpu(l1_inst_sram_lock, cpu), flags); 543 spin_lock_irqsave(&per_cpu(l1_inst_sram_lock, cpu), flags);
546 544
@@ -549,7 +547,6 @@ void *l1_inst_sram_alloc(size_t size)
549 547
550 /* add mutex operation */ 548 /* add mutex operation */
551 spin_unlock_irqrestore(&per_cpu(l1_inst_sram_lock, cpu), flags); 549 spin_unlock_irqrestore(&per_cpu(l1_inst_sram_lock, cpu), flags);
552 put_cpu();
553 550
554 pr_debug("Allocated address in l1_inst_sram_alloc is 0x%lx+0x%lx\n", 551 pr_debug("Allocated address in l1_inst_sram_alloc is 0x%lx+0x%lx\n",
555 (long unsigned int)addr, size); 552 (long unsigned int)addr, size);
@@ -568,7 +565,7 @@ int l1_inst_sram_free(const void *addr)
568 int ret; 565 int ret;
569 unsigned int cpu; 566 unsigned int cpu;
570 567
571 cpu = get_cpu(); 568 cpu = smp_processor_id();
572 /* add mutex operation */ 569 /* add mutex operation */
573 spin_lock_irqsave(&per_cpu(l1_inst_sram_lock, cpu), flags); 570 spin_lock_irqsave(&per_cpu(l1_inst_sram_lock, cpu), flags);
574 571
@@ -577,7 +574,6 @@ int l1_inst_sram_free(const void *addr)
577 574
578 /* add mutex operation */ 575 /* add mutex operation */
579 spin_unlock_irqrestore(&per_cpu(l1_inst_sram_lock, cpu), flags); 576 spin_unlock_irqrestore(&per_cpu(l1_inst_sram_lock, cpu), flags);
580 put_cpu();
581 577
582 return ret; 578 return ret;
583#else 579#else
@@ -593,7 +589,7 @@ void *l1sram_alloc(size_t size)
593 void *addr; 589 void *addr;
594 unsigned int cpu; 590 unsigned int cpu;
595 591
596 cpu = get_cpu(); 592 cpu = smp_processor_id();
597 /* add mutex operation */ 593 /* add mutex operation */
598 spin_lock_irqsave(&per_cpu(l1sram_lock, cpu), flags); 594 spin_lock_irqsave(&per_cpu(l1sram_lock, cpu), flags);
599 595
@@ -602,7 +598,6 @@ void *l1sram_alloc(size_t size)
602 598
603 /* add mutex operation */ 599 /* add mutex operation */
604 spin_unlock_irqrestore(&per_cpu(l1sram_lock, cpu), flags); 600 spin_unlock_irqrestore(&per_cpu(l1sram_lock, cpu), flags);
605 put_cpu();
606 601
607 return addr; 602 return addr;
608} 603}
@@ -614,7 +609,7 @@ void *l1sram_alloc_max(size_t *psize)
614 void *addr; 609 void *addr;
615 unsigned int cpu; 610 unsigned int cpu;
616 611
617 cpu = get_cpu(); 612 cpu = smp_processor_id();
618 /* add mutex operation */ 613 /* add mutex operation */
619 spin_lock_irqsave(&per_cpu(l1sram_lock, cpu), flags); 614 spin_lock_irqsave(&per_cpu(l1sram_lock, cpu), flags);
620 615
@@ -623,7 +618,6 @@ void *l1sram_alloc_max(size_t *psize)
623 618
624 /* add mutex operation */ 619 /* add mutex operation */
625 spin_unlock_irqrestore(&per_cpu(l1sram_lock, cpu), flags); 620 spin_unlock_irqrestore(&per_cpu(l1sram_lock, cpu), flags);
626 put_cpu();
627 621
628 return addr; 622 return addr;
629} 623}
@@ -635,7 +629,7 @@ int l1sram_free(const void *addr)
635 int ret; 629 int ret;
636 unsigned int cpu; 630 unsigned int cpu;
637 631
638 cpu = get_cpu(); 632 cpu = smp_processor_id();
639 /* add mutex operation */ 633 /* add mutex operation */
640 spin_lock_irqsave(&per_cpu(l1sram_lock, cpu), flags); 634 spin_lock_irqsave(&per_cpu(l1sram_lock, cpu), flags);
641 635
@@ -644,7 +638,6 @@ int l1sram_free(const void *addr)
644 638
645 /* add mutex operation */ 639 /* add mutex operation */
646 spin_unlock_irqrestore(&per_cpu(l1sram_lock, cpu), flags); 640 spin_unlock_irqrestore(&per_cpu(l1sram_lock, cpu), flags);
647 put_cpu();
648 641
649 return ret; 642 return ret;
650} 643}