Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
a4a3f276
Commit
a4a3f276
authored
May 25, 2004
by
David S. Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SPARC64]: Implement debugging version of write_trylock().
parent
3bc275e9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
0 deletions
+67
-0
arch/sparc64/lib/debuglocks.c
arch/sparc64/lib/debuglocks.c
+57
-0
include/asm-sparc64/spinlock.h
include/asm-sparc64/spinlock.h
+10
-0
No files found.
arch/sparc64/lib/debuglocks.c
View file @
a4a3f276
...
...
@@ -299,4 +299,61 @@ void _do_write_unlock(rwlock_t *rw)
}
}
int
_do_write_trylock
(
rwlock_t
*
rw
,
char
*
str
)
{
unsigned
long
caller
,
val
;
int
stuck
=
INIT_STUCK
;
int
cpu
=
smp_processor_id
();
int
shown
=
0
;
GET_CALLER
(
caller
);
/* Try to acuire the write bit. */
__asm__
__volatile__
(
" mov 1, %%g3
\n
"
" sllx %%g3, 63, %%g3
\n
"
" ldx [%0], %%g5
\n
"
" brlz,pn %%g5, 1f
\n
"
" or %%g5, %%g3, %%g7
\n
"
" casx [%0], %%g5, %%g7
\n
"
" membar #StoreLoad | #StoreStore
\n
"
" ba,pt %%xcc, 2f
\n
"
" sub %%g5, %%g7, %0
\n
"
"1: mov 1, %0
\n
"
"2:"
:
"=r"
(
val
)
:
"0"
(
&
(
rw
->
lock
))
:
"g3"
,
"g5"
,
"g7"
,
"memory"
);
if
(
val
)
return
0
;
if
((
rw
->
lock
&
((
1UL
<<
63
)
-
1UL
))
!=
0UL
)
{
/* Readers still around, drop the write
* lock, return failure.
*/
__asm__
__volatile__
(
" mov 1, %%g3
\n
"
" sllx %%g3, 63, %%g3
\n
"
"1: ldx [%0], %%g5
\n
"
" andn %%g5, %%g3, %%g7
\n
"
" casx [%0], %%g5, %%g7
\n
"
" cmp %%g5, %%g7
\n
"
" bne,pn %%xcc, 1b
\n
"
" membar #StoreLoad | #StoreStore"
:
/* no outputs */
:
"r"
(
&
(
rw
->
lock
))
:
"g3"
,
"g5"
,
"g7"
,
"cc"
,
"memory"
);
return
0
;
}
/* We have it, say who we are. */
rw
->
writer_pc
=
((
unsigned
int
)
caller
);
rw
->
writer_cpu
=
cpu
;
current
->
thread
.
smp_lock_count
++
;
current
->
thread
.
smp_lock_pc
=
((
unsigned
int
)
caller
);
return
1
;
}
#endif
/* CONFIG_SMP */
include/asm-sparc64/spinlock.h
View file @
a4a3f276
...
...
@@ -144,6 +144,7 @@ extern void _do_read_lock(rwlock_t *rw, char *str);
extern
void
_do_read_unlock
(
rwlock_t
*
rw
,
char
*
str
);
extern
void
_do_write_lock
(
rwlock_t
*
rw
,
char
*
str
);
extern
void
_do_write_unlock
(
rwlock_t
*
rw
);
extern
int
_do_write_trylock
(
rwlock_t
*
rw
,
char
*
str
);
#define _raw_read_lock(lock) \
do { unsigned long flags; \
...
...
@@ -173,6 +174,15 @@ do { unsigned long flags; \
local_irq_restore(flags); \
} while(0)
#define _raw_write_trylock(lock) \
({ unsigned long flags; \
int val; \
local_irq_save(flags); \
val = _do_write_trylock(lock, "write_trylock"); \
local_irq_restore(flags); \
val; \
})
#endif
/* CONFIG_DEBUG_SPINLOCK */
#endif
/* !(__ASSEMBLY__) */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment