[NEUS7920-133][9610] wlbt: Add observer information in sbl header
authorAlbert Cano <a.canocamps@samsung.com>
Tue, 12 Mar 2019 16:07:55 +0000 (16:07 +0000)
committerYoungmin Nam <youngmin.nam@samsung.com>
Tue, 21 May 2019 10:45:22 +0000 (19:45 +0900)
Sable user should be notified of the presence of one or more observers
when the trigger collection occurs. This will help to indicate that the
mxlog and udi chunks might be out of date.

The presence of observer[s] is included in a new field of the sable
header.

To indicate to the decoder the new header structure, it has been decided
to increase the sbl version from 2.0 to 2.1

Change-Id: I6b87ab2f950300482d2025a0c79914c5d24751b8
SCSC-Bug-Id: SSB-50521
Signed-off-by: Albert Cano <a.canocamps@samsung.com>
drivers/misc/samsung/scsc/mxlogger.c
drivers/misc/samsung/scsc/scsc_log_collector.c
include/scsc/scsc_log_collector.h

index 4d46c8b8b70e6a5be444f0b11ca79bc8ad460950..e98030be13ea323f96c78a991d12eb0e35b50854 100644 (file)
@@ -758,8 +758,14 @@ int mxlogger_start(struct mxlogger *mxlogger)
                 */
                mxlogger_enable(mxlogger, true);
                mxlogger_to_shared_dram(mxlogger);
+#ifdef CONFIG_SCSC_LOG_COLLECTION
+               scsc_log_collector_is_observer(false);
+#endif
        } else {
                mxlogger_to_host(mxlogger);
+#ifdef CONFIG_SCSC_LOG_COLLECTION
+               scsc_log_collector_is_observer(true);
+#endif
                /* Enabling AFTER communicating direction HOST
                 * to avoid wrongly spilling messages into the
                 * rings early at start (like at boot).
@@ -802,6 +808,9 @@ void mxlogger_deinit(struct scsc_mx *mx, struct mxlogger *mxlogger)
        mxlogger->configured = false;
        mxlogger->initialized = false;
        mxlogger_to_host(mxlogger);
+#ifdef CONFIG_SCSC_LOG_COLLECTION
+       scsc_log_collector_is_observer(true);
+#endif
        mxlogger_enable(mxlogger, false);
        mxmgmt_transport_register_channel_handler(scsc_mx_get_mxmgmt_transport(mxlogger->mx),
                                                  MMTRANS_CHAN_ID_MAXWELL_LOGGING,
@@ -836,6 +845,9 @@ int mxlogger_register_observer(struct mxlogger *mxlogger, char *name)
 
        /* Switch logs to host */
        mxlogger_to_host(mxlogger);
+#ifdef CONFIG_SCSC_LOG_COLLECTION
+       scsc_log_collector_is_observer(true);
+#endif
 
        mutex_unlock(&mxlogger->lock);
 
@@ -857,8 +869,12 @@ int mxlogger_unregister_observer(struct mxlogger *mxlogger, char *name)
        SCSC_TAG_INFO(MXMAN, "UN-register observer[%d] --  %s\n",
                      mxlogger->observers, name);
 
-       if (mxlogger->observers == 0)
+       if (mxlogger->observers == 0) {
                mxlogger_to_shared_dram(mxlogger);
+#ifdef CONFIG_SCSC_LOG_COLLECTION
+               scsc_log_collector_is_observer(false);
+#endif
+       }
 
        mutex_unlock(&mxlogger->lock);
 
index 76347ce4da4063653c3de4b038454c134e634135..3e895c049c19bc555e0b43e795d543d0f6c2b98e 100644 (file)
@@ -113,6 +113,7 @@ struct scsc_log_status {
        enum scsc_log_reason    collect_reason;
        u16 reason_code;
        struct mutex collection_serial;
+       bool observer_present;
 } log_status;
 
 static DEFINE_MUTEX(log_mutex);
@@ -404,6 +405,7 @@ static int __scsc_log_collector_collect(enum scsc_log_reason reason, u16 reason_
        sbl_header.num_chunks = num_chunks;
        sbl_header.trigger = reason;
        sbl_header.reason_code = reason_code;
+       sbl_header.observer = log_status.observer_present;
        sbl_header.offset_data = first_chunk_pos;
        mxman_get_fw_version(version_fw, SCSC_LOG_FW_VERSION_SIZE);
        memcpy(sbl_header.fw_version, version_fw, SCSC_LOG_FW_VERSION_SIZE);
@@ -524,6 +526,12 @@ void scsc_log_collector_write_fapi(char __user *buf, size_t len)
 }
 EXPORT_SYMBOL(scsc_log_collector_write_fapi);
 
+void scsc_log_collector_is_observer(bool observer)
+{
+       log_status.observer_present = observer;
+}
+EXPORT_SYMBOL(scsc_log_collector_is_observer);
+
 MODULE_DESCRIPTION("SCSC Log collector");
 MODULE_AUTHOR("SLSI");
 MODULE_LICENSE("GPL and additional rights");
index 13429ed7db4c9e2bb7db743c06ceea9e10df5143..30983bcb4c2717d0b8ba04573d6f9a31bcb89fa3 100644 (file)
@@ -9,7 +9,7 @@
 
 /* High nibble is Major, Low nibble is Minor */
 #define SCSC_LOG_HEADER_VERSION_MAJOR  0x02
-#define SCSC_LOG_HEADER_VERSION_MINOR  0x00
+#define SCSC_LOG_HEADER_VERSION_MINOR  0x01
 /* Magic string. 4 bytes "SCSC"*/
 /* Header version. 1 byte */
 /* Num chunks. 1 byte */
 /* Collection reason. 1 byte */
 /* Reserved. 1 byte */
 /* Reason Code . 2 bytes */
-#define SCSC_LOG_HEADER_SIZE           (12)
+/* Observer present . 1 bytes */
+#define SCSC_LOG_HEADER_SIZE           (13)
 #define SCSC_LOG_FW_VERSION_SIZE       (128)
 #define SCSC_LOG_HOST_VERSION_SIZE     (64)
 #define SCSC_LOG_FAPI_VERSION_SIZE     (64)
 /* Reserved 2 . 4 byte */
-#define SCSC_LOG_RESERVED_2            4
+#define SCSC_LOG_RESERVED_2            3
 /* Ideally header + versions should be 16 bytes aligne*/
 #define SCSC_SUPPORTED_CHUNKS_HEADER    48
 
@@ -105,6 +106,7 @@ struct scsc_log_sbl_header {
        char host_version[SCSC_LOG_HOST_VERSION_SIZE];
        char fapi_version[SCSC_LOG_FAPI_VERSION_SIZE];
        u16  reason_code;
+       bool observer;
        u8   reserved2[SCSC_LOG_RESERVED_2];
        char supported_chunks[SCSC_SUPPORTED_CHUNKS_HEADER];
 } __packed;
@@ -133,6 +135,9 @@ unsigned char *scsc_log_collector_get_buffer(void);
 /* Public method to register FAPI version. */
 void scsc_log_collector_write_fapi(char __user *buf, size_t len);
 
+/* Public method to notify the presence/absense of observers */
+void scsc_log_collector_is_observer(bool observer);
+
 void scsc_log_collector_schedule_collection(enum scsc_log_reason reason, u16 reason_code);
 int scsc_log_collector_write(char __user *buf, size_t count, u8 align);
 #endif /* __SCSC_LOG_COLLECTOR_H__ */