提交 6c310681 编写于 作者: V Vineet Gupta

ARC: cacheflush: No need to retain DC_CTRL from __before_dc_op()

That is because __after_dc_op() already reads it for status check, so it
is better anyways to use that "newer" value.

Also reduces the clutter in callers for passing from/to these routines.
Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
上级 8ea2ddff
...@@ -207,32 +207,33 @@ static inline void __cache_line_loop(unsigned long paddr, unsigned long vaddr, ...@@ -207,32 +207,33 @@ static inline void __cache_line_loop(unsigned long paddr, unsigned long vaddr,
* Machine specific helpers for Entire D-Cache or Per Line ops * Machine specific helpers for Entire D-Cache or Per Line ops
*/ */
static inline unsigned int __before_dc_op(const int op) static inline void __before_dc_op(const int op)
{ {
unsigned int reg = reg;
if (op == OP_FLUSH_N_INV) { if (op == OP_FLUSH_N_INV) {
/* Dcache provides 2 cmd: FLUSH or INV /* Dcache provides 2 cmd: FLUSH or INV
* INV inturn has sub-modes: DISCARD or FLUSH-BEFORE * INV inturn has sub-modes: DISCARD or FLUSH-BEFORE
* flush-n-inv is achieved by INV cmd but with IM=1 * flush-n-inv is achieved by INV cmd but with IM=1
* So toggle INV sub-mode depending on op request and default * So toggle INV sub-mode depending on op request and default
*/ */
reg = read_aux_reg(ARC_REG_DC_CTRL); const unsigned int ctl = ARC_REG_DC_CTRL;
write_aux_reg(ARC_REG_DC_CTRL, reg | DC_CTRL_INV_MODE_FLUSH) write_aux_reg(ctl, read_aux_reg(ctl) | DC_CTRL_INV_MODE_FLUSH);
;
} }
return reg;
} }
static inline void __after_dc_op(const int op, unsigned int reg) static inline void __after_dc_op(const int op)
{ {
if (op & OP_FLUSH) /* flush / flush-n-inv both wait */ if (op & OP_FLUSH) {
while (read_aux_reg(ARC_REG_DC_CTRL) & DC_CTRL_FLUSH_STATUS); const unsigned int ctl = ARC_REG_DC_CTRL;
unsigned int reg;
/* flush / flush-n-inv both wait */
while ((reg = read_aux_reg(ctl)) & DC_CTRL_FLUSH_STATUS)
;
/* Switch back to default Invalidate mode */ /* Switch back to default Invalidate mode */
if (op == OP_FLUSH_N_INV) if (op == OP_FLUSH_N_INV)
write_aux_reg(ARC_REG_DC_CTRL, reg & ~DC_CTRL_INV_MODE_FLUSH); write_aux_reg(ctl, reg & ~DC_CTRL_INV_MODE_FLUSH);
}
} }
/* /*
...@@ -243,10 +244,9 @@ static inline void __after_dc_op(const int op, unsigned int reg) ...@@ -243,10 +244,9 @@ static inline void __after_dc_op(const int op, unsigned int reg)
*/ */
static inline void __dc_entire_op(const int op) static inline void __dc_entire_op(const int op)
{ {
unsigned int ctrl_reg;
int aux; int aux;
ctrl_reg = __before_dc_op(op); __before_dc_op(op);
if (op & OP_INV) /* Inv or flush-n-inv use same cmd reg */ if (op & OP_INV) /* Inv or flush-n-inv use same cmd reg */
aux = ARC_REG_DC_IVDC; aux = ARC_REG_DC_IVDC;
...@@ -255,7 +255,7 @@ static inline void __dc_entire_op(const int op) ...@@ -255,7 +255,7 @@ static inline void __dc_entire_op(const int op)
write_aux_reg(aux, 0x1); write_aux_reg(aux, 0x1);
__after_dc_op(op, ctrl_reg); __after_dc_op(op);
} }
/* For kernel mappings cache operation: index is same as paddr */ /* For kernel mappings cache operation: index is same as paddr */
...@@ -268,15 +268,14 @@ static inline void __dc_line_op(unsigned long paddr, unsigned long vaddr, ...@@ -268,15 +268,14 @@ static inline void __dc_line_op(unsigned long paddr, unsigned long vaddr,
unsigned long sz, const int op) unsigned long sz, const int op)
{ {
unsigned long flags; unsigned long flags;
unsigned int ctrl_reg;
local_irq_save(flags); local_irq_save(flags);
ctrl_reg = __before_dc_op(op); __before_dc_op(op);
__cache_line_loop(paddr, vaddr, sz, op); __cache_line_loop(paddr, vaddr, sz, op);
__after_dc_op(op, ctrl_reg); __after_dc_op(op);
local_irq_restore(flags); local_irq_restore(flags);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册