mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-02 06:06:53 +07:00
Blackfin: push SRAM locks down into related ifdefs
Rather than defining the locks and initializing them all the time, only do so when we actually need them (i.e. the SRAM regions exist). This avoids dead data and code bloat during runtime. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
parent
9c954f8941
commit
81c969a8bc
@ -42,11 +42,6 @@
|
|||||||
#include <asm/mem_map.h>
|
#include <asm/mem_map.h>
|
||||||
#include "blackfin_sram.h"
|
#include "blackfin_sram.h"
|
||||||
|
|
||||||
static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t, l1sram_lock);
|
|
||||||
static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t, l1_data_sram_lock);
|
|
||||||
static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t, l1_inst_sram_lock);
|
|
||||||
static spinlock_t l2_sram_lock ____cacheline_aligned_in_smp;
|
|
||||||
|
|
||||||
/* the data structure for L1 scratchpad and DATA SRAM */
|
/* the data structure for L1 scratchpad and DATA SRAM */
|
||||||
struct sram_piece {
|
struct sram_piece {
|
||||||
void *paddr;
|
void *paddr;
|
||||||
@ -55,6 +50,7 @@ struct sram_piece {
|
|||||||
struct sram_piece *next;
|
struct sram_piece *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t, l1sram_lock);
|
||||||
static DEFINE_PER_CPU(struct sram_piece, free_l1_ssram_head);
|
static DEFINE_PER_CPU(struct sram_piece, free_l1_ssram_head);
|
||||||
static DEFINE_PER_CPU(struct sram_piece, used_l1_ssram_head);
|
static DEFINE_PER_CPU(struct sram_piece, used_l1_ssram_head);
|
||||||
|
|
||||||
@ -68,12 +64,18 @@ static DEFINE_PER_CPU(struct sram_piece, free_l1_data_B_sram_head);
|
|||||||
static DEFINE_PER_CPU(struct sram_piece, used_l1_data_B_sram_head);
|
static DEFINE_PER_CPU(struct sram_piece, used_l1_data_B_sram_head);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if L1_DATA_A_LENGTH || L1_DATA_B_LENGTH
|
||||||
|
static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t, l1_data_sram_lock);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if L1_CODE_LENGTH != 0
|
#if L1_CODE_LENGTH != 0
|
||||||
|
static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t, l1_inst_sram_lock);
|
||||||
static DEFINE_PER_CPU(struct sram_piece, free_l1_inst_sram_head);
|
static DEFINE_PER_CPU(struct sram_piece, free_l1_inst_sram_head);
|
||||||
static DEFINE_PER_CPU(struct sram_piece, used_l1_inst_sram_head);
|
static DEFINE_PER_CPU(struct sram_piece, used_l1_inst_sram_head);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if L2_LENGTH != 0
|
#if L2_LENGTH != 0
|
||||||
|
static spinlock_t l2_sram_lock ____cacheline_aligned_in_smp;
|
||||||
static struct sram_piece free_l2_sram_head, used_l2_sram_head;
|
static struct sram_piece free_l2_sram_head, used_l2_sram_head;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -225,10 +227,10 @@ static void __init l2_sram_init(void)
|
|||||||
printk(KERN_INFO "Blackfin L2 SRAM: %d KB (%d KB free)\n",
|
printk(KERN_INFO "Blackfin L2 SRAM: %d KB (%d KB free)\n",
|
||||||
L2_LENGTH >> 10,
|
L2_LENGTH >> 10,
|
||||||
free_l2_sram_head.next->size >> 10);
|
free_l2_sram_head.next->size >> 10);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* mutex initialize */
|
/* mutex initialize */
|
||||||
spin_lock_init(&l2_sram_lock);
|
spin_lock_init(&l2_sram_lock);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init bfin_sram_init(void)
|
static int __init bfin_sram_init(void)
|
||||||
@ -416,18 +418,17 @@ EXPORT_SYMBOL(sram_free);
|
|||||||
|
|
||||||
void *l1_data_A_sram_alloc(size_t size)
|
void *l1_data_A_sram_alloc(size_t size)
|
||||||
{
|
{
|
||||||
|
#if L1_DATA_A_LENGTH != 0
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
void *addr = NULL;
|
void *addr;
|
||||||
unsigned int cpu;
|
unsigned int cpu;
|
||||||
|
|
||||||
cpu = get_cpu();
|
cpu = get_cpu();
|
||||||
/* add mutex operation */
|
/* add mutex operation */
|
||||||
spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags);
|
spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags);
|
||||||
|
|
||||||
#if L1_DATA_A_LENGTH != 0
|
|
||||||
addr = _sram_alloc(size, &per_cpu(free_l1_data_A_sram_head, cpu),
|
addr = _sram_alloc(size, &per_cpu(free_l1_data_A_sram_head, cpu),
|
||||||
&per_cpu(used_l1_data_A_sram_head, cpu));
|
&per_cpu(used_l1_data_A_sram_head, cpu));
|
||||||
#endif
|
|
||||||
|
|
||||||
/* add mutex operation */
|
/* add mutex operation */
|
||||||
spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags);
|
spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags);
|
||||||
@ -437,11 +438,15 @@ void *l1_data_A_sram_alloc(size_t size)
|
|||||||
(long unsigned int)addr, size);
|
(long unsigned int)addr, size);
|
||||||
|
|
||||||
return addr;
|
return addr;
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(l1_data_A_sram_alloc);
|
EXPORT_SYMBOL(l1_data_A_sram_alloc);
|
||||||
|
|
||||||
int l1_data_A_sram_free(const void *addr)
|
int l1_data_A_sram_free(const void *addr)
|
||||||
{
|
{
|
||||||
|
#if L1_DATA_A_LENGTH != 0
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int cpu;
|
unsigned int cpu;
|
||||||
@ -450,18 +455,17 @@ int l1_data_A_sram_free(const void *addr)
|
|||||||
/* add mutex operation */
|
/* add mutex operation */
|
||||||
spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags);
|
spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags);
|
||||||
|
|
||||||
#if L1_DATA_A_LENGTH != 0
|
|
||||||
ret = _sram_free(addr, &per_cpu(free_l1_data_A_sram_head, cpu),
|
ret = _sram_free(addr, &per_cpu(free_l1_data_A_sram_head, cpu),
|
||||||
&per_cpu(used_l1_data_A_sram_head, cpu));
|
&per_cpu(used_l1_data_A_sram_head, cpu));
|
||||||
#else
|
|
||||||
ret = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* add mutex operation */
|
/* add mutex operation */
|
||||||
spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags);
|
spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags);
|
||||||
put_cpu();
|
put_cpu();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(l1_data_A_sram_free);
|
EXPORT_SYMBOL(l1_data_A_sram_free);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user