Commit 73ebe33f authored by Adam Wujek's avatar Adam Wujek 💬

arch-wrs: add verbosity when double lock/unlock of shmem

Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 68e640ea
...@@ -119,8 +119,7 @@ struct hal_temp_sensors { ...@@ -119,8 +119,7 @@ struct hal_temp_sensors {
}; };
/* This is the overall structure stored in shared memory */ /* This is the overall structure stored in shared memory */
#define HAL_SHMEM_VERSION 10 /* Version 10 because of adding sfp_dom_raw #define HAL_SHMEM_VERSION 11 /* Version 11, changed wrs_shm_head */
has_sfp_diag and read_sfp_diag */
struct hal_shmem_header { struct hal_shmem_header {
int nports; int nports;
......
...@@ -35,6 +35,9 @@ struct wrs_shm_head { ...@@ -35,6 +35,9 @@ struct wrs_shm_head {
unsigned sequence; /* If we need consistency, this is it. LSB bit unsigned sequence; /* If we need consistency, this is it. LSB bit
* informs whether shmem is locked already */ * informs whether shmem is locked already */
unsigned version; /* Version of the data structure */ unsigned version; /* Version of the data structure */
const char *last_write_caller; /* Function of the last wrs_shm_write
* call */
int last_write_line; /* Line of the last wrs_shm_write call */
unsigned data_size; /* Size of it (for binary dumps) */ unsigned data_size; /* Size of it (for binary dumps) */
}; };
...@@ -81,11 +84,11 @@ void *wrs_shm_follow(struct wrs_shm_head *head, void *ptr); ...@@ -81,11 +84,11 @@ void *wrs_shm_follow(struct wrs_shm_head *head, void *ptr);
#define WRS_SHM_WRITE_BEGIN 1 #define WRS_SHM_WRITE_BEGIN 1
#define WRS_SHM_WRITE_END 0 #define WRS_SHM_WRITE_END 0
/* A helper to pass the name of caller function */ /* A helper to pass the name of a caller function and a line of the call */
#define wrs_shm_write(headptr, flags) wrs_shm_write_caller(headptr, flags, \ #define wrs_shm_write(headptr, flags) wrs_shm_write_caller(headptr, flags, \
__func__) __func__, __LINE__)
extern void wrs_shm_write_caller(struct wrs_shm_head *head, int flags, extern void wrs_shm_write_caller(struct wrs_shm_head *head, int flags,
const char *caller); const char *caller, int line);
/* A reader can rely on the sequence number (in the <linux/seqlock.h> way) */ /* A reader can rely on the sequence number (in the <linux/seqlock.h> way) */
extern unsigned wrs_shm_seqbegin(struct wrs_shm_head *head); extern unsigned wrs_shm_seqbegin(struct wrs_shm_head *head);
......
...@@ -216,7 +216,7 @@ void *wrs_shm_follow(struct wrs_shm_head *head, void *ptr) ...@@ -216,7 +216,7 @@ void *wrs_shm_follow(struct wrs_shm_head *head, void *ptr)
/* Before and after writing a chunk of data, act on sequence and stamp */ /* Before and after writing a chunk of data, act on sequence and stamp */
void wrs_shm_write_caller(struct wrs_shm_head *head, int flags, void wrs_shm_write_caller(struct wrs_shm_head *head, int flags,
const char *caller) const char *caller, int line)
{ {
char *msg = "Wrong parameter"; char *msg = "Wrong parameter";
...@@ -233,29 +233,36 @@ void wrs_shm_write_caller(struct wrs_shm_head *head, int flags, ...@@ -233,29 +233,36 @@ void wrs_shm_write_caller(struct wrs_shm_head *head, int flags,
pr_debug("caller of a function wrs_shm_write is %s, called for \"%s\" " pr_debug("caller of a function wrs_shm_write is %s, called for \"%s\" "
"with the flag \"%s\"\n", caller, head->name, msg); "with the flag \"%s\"\n", caller, head->name, msg);
(void) *msg; /* if pr_debug() is empty, we'd have "unused variable" */
head->sequence += 2; head->sequence += 2;
if (flags == WRS_SHM_WRITE_BEGIN) { if (flags == WRS_SHM_WRITE_BEGIN) {
if (head->sequence & WRS_SHM_LOCK_MASK) if (head->sequence & WRS_SHM_LOCK_MASK)
pr_error("Trying to lock already locked shmem on the " pr_error("Trying to lock already locked shmem! "
"write end! Sequence number is %d. The caller" "The sequence number is %d. The current "
" of wrs_shm_write is %s\n", "caller of wrs_shm_write is %s (line %d), "
head->sequence, caller); "previous caller %s (line %d)\n",
head->sequence, caller, line,
head->last_write_caller,
head->last_write_line);
head->sequence |= WRS_SHM_LOCK_MASK; head->sequence |= WRS_SHM_LOCK_MASK;
head->last_write_caller = caller;
head->last_write_line = line;
} }
if (flags == WRS_SHM_WRITE_END) { if (flags == WRS_SHM_WRITE_END) {
/* At end-of-writing update the timestamp too */ /* At end-of-writing update the timestamp too */
head->stamp = get_monotonic_sec(); head->stamp = get_monotonic_sec();
if (!(head->sequence & WRS_SHM_LOCK_MASK)) if (!(head->sequence & WRS_SHM_LOCK_MASK))
pr_error("Trying to unlock already unlocked shmem on " pr_error("Trying to unlock already unlocked shmem! "
"the write begin! Sequence number is %d. The " "The sequence number is %d. The current "
"caller of wrs_shm_write is %s\n", "caller of wrs_shm_write is %s (line %d), "
head->sequence, caller); "previous caller %s (line %d)\n",
head->sequence, caller, line,
head->last_write_caller,
head->last_write_line);
head->sequence &= ~WRS_SHM_LOCK_MASK; head->sequence &= ~WRS_SHM_LOCK_MASK;
head->last_write_caller = caller;
head->last_write_line = line;
} }
return; return;
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
/* Please increment WRS_PPSI_SHMEM_VERSION if you change any exported data /* Please increment WRS_PPSI_SHMEM_VERSION if you change any exported data
* structure */ * structure */
#define WRS_PPSI_SHMEM_VERSION 30 /* added HAL_PORT_STATE_RESET to hal */ #define WRS_PPSI_SHMEM_VERSION 31 /* changed wrs_shm_head */
/* Don't include the Following when this file is included in assembler. */ /* Don't include the Following when this file is included in assembler. */
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment