Skip to content
Permalink
Browse files
sifive/sifive_l2_cache: Align the address to cache line
Signed-off-by: Atish Patra <atish.patra@wdc.com>
  • Loading branch information
atishp04 committed Jun 18, 2021
1 parent 48d2728 commit 3113512fedbd15cf6a83a08b18405fbcfb8d8985
Showing 1 changed file with 35 additions and 35 deletions.
@@ -52,6 +52,41 @@ enum {
DIR_UNCORR,
};

void sifive_l2_flush64_range(unsigned long start, unsigned long len)
{
unsigned long line;

if(!l2_base) {
pr_warn("L2CACHE: base addr invalid, skipping flush\n");
return;
}

/* TODO: if (len == 0), skipping flush or going on? */
if(!len) {
pr_debug("L2CACHE: flush64 range @ 0x%lx(len:0)\n", start);
return;
}

len = len + (start % SIFIVE_L2_FLUSH64_LINE_LEN);
start = ALIGN_DOWN(start, SIFIVE_L2_FLUSH64_LINE_LEN);

/* make sure the address is in the range */
if(start < CONFIG_SIFIVE_L2_FLUSH_START ||
(start + len) > (CONFIG_SIFIVE_L2_FLUSH_START +
CONFIG_SIFIVE_L2_FLUSH_SIZE)) {
WARN(1, "L2CACHE: flush64 out of range: %lx(%lx), skip flush\n",
start, len);
return;
}

mb(); /* sync */
for (line = start; line < start + len;
line += SIFIVE_L2_FLUSH64_LINE_LEN) {
writeq(line, l2_base + SIFIVE_L2_FLUSH64);
mb();
}
}

#ifdef CONFIG_DEBUG_FS
static struct dentry *sifive_test;

@@ -123,41 +158,6 @@ int unregister_sifive_l2_error_notifier(struct notifier_block *nb)
}
EXPORT_SYMBOL_GPL(unregister_sifive_l2_error_notifier);

#ifdef CONFIG_SIFIVE_L2_FLUSH
void sifive_l2_flush64_range(unsigned long start, unsigned long len)
{
unsigned long line;

if(!l2_base) {
pr_warn("L2CACHE: base addr invalid, skipping flush\n");
return;
}

/* TODO: if (len == 0), skipping flush or going on? */
if(!len) {
pr_debug("L2CACHE: flush64 range @ 0x%lx(len:0)\n", start);
return;
}

/* make sure the address is in the range */
if(start < CONFIG_SIFIVE_L2_FLUSH_START ||
(start + len) > (CONFIG_SIFIVE_L2_FLUSH_START +
CONFIG_SIFIVE_L2_FLUSH_SIZE)) {
WARN(1, "L2CACHE: flush64 out of range: %lx(%lx), skip flush\n",
start, len);
return;
}

mb(); /* sync */
for (line = start; line < start + len;
line += SIFIVE_L2_FLUSH64_LINE_LEN) {
writeq(line, l2_base + SIFIVE_L2_FLUSH64);
mb();
}
}
EXPORT_SYMBOL_GPL(sifive_l2_flush64_range);
#endif

static int l2_largest_wayenabled(void)
{
return readl(l2_base + SIFIVE_L2_WAYENABLE) & 0xFF;

0 comments on commit 3113512

Please sign in to comment.