Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
c59428b1
Commit
c59428b1
authored
8 years ago
by
davidcunado-arm
Committed by
GitHub
8 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #761 from soby-mathew/sm/bakery_lock_fixes
Fix normal memory bakery lock implementation
parents
805972fe
95c12559
master
v2.5
v2.5-rc1
v2.5-rc0
v2.4
v2.4-rc2
v2.4-rc1
v2.4-rc0
v2.3
v2.3-rc2
v2.3-rc1
v2.3-rc0
v2.2
v2.2-rc2
v2.2-rc1
v2.2-rc0
v2.1
v2.1-rc1
v2.1-rc0
v2.0
v2.0-rc0
v1.6
v1.6-rc1
v1.6-rc0
v1.5
v1.5-rc3
v1.5-rc2
v1.5-rc1
v1.5-rc0
v1.4
v1.4-rc0
arm_cca_v0.2
arm_cca_v0.1
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/locks/bakery/bakery_lock_normal.c
+21
-8
lib/locks/bakery/bakery_lock_normal.c
with
21 additions
and
8 deletions
+21
-8
lib/locks/bakery/bakery_lock_normal.c
View file @
c59428b1
/*
* Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015
-2016
, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
...
...
@@ -90,6 +90,22 @@ extern void *__PERCPU_BAKERY_LOCK_SIZE__;
#define read_cache_op(addr, cached) if (cached) \
dccivac((uintptr_t)addr)
/* Helper function to check if the lock is acquired */
static
inline
int
is_lock_acquired
(
const
bakery_info_t
*
my_bakery_info
,
int
is_cached
)
{
/*
* Even though lock data is updated only by the owning cpu and
* appropriate cache maintenance operations are performed,
* if the previous update was done when the cpu was not participating
* in coherency, then there is a chance that cache maintenance
* operations were not propagated to all the caches in the system.
* Hence do a `read_cache_op()` prior to read.
*/
read_cache_op
(
my_bakery_info
,
is_cached
);
return
!!
(
bakery_ticket_number
(
my_bakery_info
->
lock_data
));
}
static
unsigned
int
bakery_get_ticket
(
bakery_lock_t
*
lock
,
unsigned
int
me
,
int
is_cached
)
{
...
...
@@ -104,12 +120,8 @@ static unsigned int bakery_get_ticket(bakery_lock_t *lock,
my_bakery_info
=
get_bakery_info
(
me
,
lock
);
assert
(
my_bakery_info
);
/*
* Prevent recursive acquisition.
* Since lock data is written to and cleaned by the owning cpu, it
* doesn't require any cache operations prior to reading the lock data.
*/
assert
(
!
bakery_ticket_number
(
my_bakery_info
->
lock_data
));
/* Prevent recursive acquisition.*/
assert
(
!
is_lock_acquired
(
my_bakery_info
,
is_cached
));
/*
* Tell other contenders that we are through the bakery doorway i.e.
...
...
@@ -222,7 +234,8 @@ void bakery_lock_release(bakery_lock_t *lock)
unsigned
int
is_cached
=
read_sctlr_el3
()
&
SCTLR_C_BIT
;
my_bakery_info
=
get_bakery_info
(
plat_my_core_pos
(),
lock
);
assert
(
bakery_ticket_number
(
my_bakery_info
->
lock_data
));
assert
(
is_lock_acquired
(
my_bakery_info
,
is_cached
));
my_bakery_info
->
lock_data
=
0
;
write_cache_op
(
my_bakery_info
,
is_cached
);
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help