lkml.org 
[lkml]   [2017]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/7] MIPS: Octeon: Add a global resource manager.
> +static void res_mgr_lock(void)
> +{
> + unsigned int tmp;
> + u64 lock = (u64)&res_mgr_info->rlock;
> +
> + __asm__ __volatile__(
> + ".set noreorder\n"
> + "1: ll %[tmp], 0(%[addr])\n"
> + " bnez %[tmp], 1b\n"
> + " li %[tmp], 1\n"
> + " sc %[tmp], 0(%[addr])\n"
> + " beqz %[tmp], 1b\n"
> + " nop\n"
> + ".set reorder\n" :
> + [tmp] "=&r"(tmp) :
> + [addr] "r"(lock) :
> + "memory");
> +}
> +
> +static void res_mgr_unlock(void)
> +{
> + u64 lock = (u64)&res_mgr_info->rlock;
> +
> + /* Wait until all resource operations finish before unlocking. */
> + mb();
> + __asm__ __volatile__(
> + "sw $0, 0(%[addr])\n" : :
> + [addr] "r"(lock) :
> + "memory");
> +
> + /* Force a write buffer flush. */
> + mb();
> +}

It would be good to add some justification for using your own locks,
rather than standard linux locks.

Is there anything specific to your hardware in this resource manager?
I'm just wondering if this should be generic, put somewhere in lib. Or
maybe there is already something generic, and you should be using it,
not re-inventing the wheel again.

Andrew

\
 
 \ /
  Last update: 2017-11-02 13:25    [W:0.111 / U:0.864 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site