Do not mark shared structures as __packed, it leads to race condition

If structure packed as __packed clang (and probably gcc) generates
code that loads word fields (e.g. tx_pos)  byte-by-byte and if it's
modified by VideoCore in the same time as ARM loads the value result
is going to be mixed combination of bytes from previous value and
new one.
This commit is contained in:
gonzo 2015-02-09 02:31:27 +00:00
parent 17a9c0e974
commit 0e8f15c195

View File

@ -280,7 +280,7 @@ typedef struct vchiq_slot_info_struct {
/* Use two counters rather than one to avoid the need for a mutex. */
short use_count;
short release_count;
} __packed VCHIQ_SLOT_INFO_T; /* XXXGONZO: check it */
} VCHIQ_SLOT_INFO_T;
typedef struct vchiq_service_struct {
VCHIQ_SERVICE_BASE_T base;
@ -381,7 +381,7 @@ typedef struct vchiq_shared_state_struct {
/* Debugging state */
int debug[DEBUG_MAX];
} __packed VCHIQ_SHARED_STATE_T;
} VCHIQ_SHARED_STATE_T;
typedef struct vchiq_slot_zero_struct {
int magic;
@ -395,7 +395,7 @@ typedef struct vchiq_slot_zero_struct {
VCHIQ_SHARED_STATE_T master;
VCHIQ_SHARED_STATE_T slave;
VCHIQ_SLOT_INFO_T slots[VCHIQ_MAX_SLOTS];
} __packed VCHIQ_SLOT_ZERO_T;
} VCHIQ_SLOT_ZERO_T;
struct vchiq_state_struct {
int id;