[RAMEN9610-14887][common][9610] wlbt: complete fw_panic_done only on fw_panic
authorPurnendu Kapadia <p.kapadia@samsung.com>
Tue, 23 Apr 2019 09:53:18 +0000 (10:53 +0100)
committerKim Gunho <gunho.kim@samsung.com>
Fri, 28 Jun 2019 14:44:46 +0000 (23:44 +0900)
We want to prevent fw_panic_done completion happening in case of non
fw_panic SABLE trigger. Introduce response codes corresponding to each
situation based on if it is fw_panic or other trigger from wlbtd and
check for specific condition before completing individual completion.

This change is dependent upon corresponding wlbtd v3.1 which is providing
appropriate response_codes.

SCSC-Bug-Id: SSB-51921
Change-Id: Ia11bd8d8abc370f615222a3ce768b749ac876008
Signed-off-by: Purnendu Kapadia <p.kapadia@samsung.com>
drivers/misc/samsung/scsc/scsc_wlbtd.c
drivers/misc/samsung/scsc/scsc_wlbtd.h

index 1c7fdcfb67b87ebcf9927ec2ca6a22b3b55e50f2..123735158b4fb679662ae2419f6e5f67c5404710 100755 (executable)
@@ -23,6 +23,45 @@ static struct wake_lock wlbtd_wakelock;
 /* module parameter controlling recovery handling */
 extern int disable_recovery_handling;
 
+const char *response_code_to_str(int response_code)
+{
+       switch (response_code) {
+       case SCSC_WLBTD_ERR_PARSE_FAILED:
+               return "SCSC_WLBTD_ERR_PARSE_FAILED";
+       case SCSC_WLBTD_FW_PANIC_TAR_GENERATED:
+               return "SCSC_WLBTD_FW_PANIC_TAR_GENERATED";
+       case SCSC_WLBTD_FW_PANIC_ERR_SCRIPT_FILE_NOT_FOUND:
+               return "SCSC_WLBTD_FW_PANIC_ERR_SCRIPT_FILE_NOT_FOUND";
+       case SCSC_WLBTD_FW_PANIC_ERR_NO_DEV:
+               return "SCSC_WLBTD_FW_PANIC_ERR_NO_DEV";
+       case SCSC_WLBTD_FW_PANIC_ERR_MMAP:
+               return "SCSC_WLBTD_FW_PANIC_ERR_MMAP";
+       case SCSC_WLBTD_FW_PANIC_ERR_SABLE_FILE:
+               return "SCSC_WLBTD_FW_PANIC_ERR_SABLE_FILE";
+       case SCSC_WLBTD_FW_PANIC_ERR_TAR:
+               return "SCSC_WLBTD_FW_PANIC_ERR_TAR";
+       case SCSC_WLBTD_OTHER_SBL_GENERATED:
+               return "SCSC_WLBTD_OTHER_SBL_GENERATED";
+       case SCSC_WLBTD_OTHER_TAR_GENERATED:
+               return "SCSC_WLBTD_OTHER_TAR_GENERATED";
+       case SCSC_WLBTD_OTHER_ERR_SCRIPT_FILE_NOT_FOUND:
+               return "SCSC_WLBTD_OTHER_ERR_SCRIPT_FILE_NOT_FOUND";
+       case SCSC_WLBTD_OTHER_ERR_NO_DEV:
+               return "SCSC_WLBTD_OTHER_ERR_NO_DEV";
+       case SCSC_WLBTD_OTHER_ERR_MMAP:
+               return "SCSC_WLBTD_OTHER_ERR_MMAP";
+       case SCSC_WLBTD_OTHER_ERR_SABLE_FILE:
+               return "SCSC_WLBTD_OTHER_ERR_SABLE_FILE";
+       case SCSC_WLBTD_OTHER_ERR_TAR:
+               return "SCSC_WLBTD_OTHER_ERR_TAR";
+       case SCSC_WLBTD_OTHER_IGNORE_TRIGGER:
+               return "SCSC_WLBTD_OTHER_IGNORE_TRIGGER";
+       default:
+               SCSC_TAG_ERR(WLBTD, "UNKNOWN response_code %d", response_code);
+               return "UNKNOWN response_code";
+       }
+}
+
 /**
  * This callback runs whenever the socket receives messages.
  */
@@ -55,8 +94,7 @@ static int msg_from_wlbtd_sable_cb(struct sk_buff *skb, struct genl_info *info)
 
        if (info->attrs[2]) {
                status = nla_get_u16(info->attrs[2]);
-               if (status)
-                       SCSC_TAG_ERR(WLBTD, "%u\n", status);
+               SCSC_TAG_ERR(WLBTD, "%s\n", response_code_to_str(status));
        }
 
        if (disable_recovery_handling == MEMDUMP_FILE_FOR_RECOVERY) {
@@ -69,40 +107,71 @@ static int msg_from_wlbtd_sable_cb(struct sk_buff *skb, struct genl_info *info)
        }
 
        /* completion cases :
-        * 1) for trigger scsc_log_fw_panic only one response from wlbtd when tar done
+        * 1) FW_PANIC_TAR_GENERATED
+        *    for trigger scsc_log_fw_panic only one response from wlbtd when
+        *    tar done
         *    ---> complete fw_panic_done
         * 2) for all other triggers, we get 2 responses
-        *      a) Once .sbl is written
+        *      a) OTHER_SBL_GENERATED
+        *         Once .sbl is written
         *    ---> complete event_done
-        *      b) 2nd time when sable tar is done
-        *         ignore this response and Don't complete
-        * 3) When we get rapid requests for SABLE generation,
+        *      b) OTHER_TAR_GENERATED
+        *         2nd time when sable tar is done
+        *         IGNORE this response and Don't complete
+        * 3) OTHER_IGNORE_TRIGGER
+        *    When we get rapid requests for SABLE generation,
         *    to serialise while processing current request,
         *    we ignore requests other than "fw_panic" in wlbtd and
         *    send a msg "ignoring" back to kernel.
         *    ---> complete event_done
-        * 4) when something failed, file not found
+        * 4) FW_PANIC_ERR_* and OTHER_ERR_*
+        *    when something failed, file not found, mmap failed, etc.
+        *    ---> complete the completion with waiter(s) based on if it was
+        *    a fw_panic trigger or other trigger
+        * 5) ERR_PARSE_FAILED
+        *    When msg parsing fails, wlbtd doesn't know the trigger type
         *    ---> complete the completion with waiter(s)
         */
 
-       if ((strstr(data, "scsc_log_fw_panic") != NULL) ||
-                       (strstr(data, "not found.") != NULL) ||
-                       (strstr(data, "failed"))) {
+       switch (status) {
+       case SCSC_WLBTD_ERR_PARSE_FAILED:
                if (!completion_done(&fw_panic_done)) {
                        SCSC_TAG_INFO(WLBTD, "completing fw_panic_done\n");
                        complete(&fw_panic_done);
-                       return 0;
                }
-       }
-
-       if ((strstr(data, ".sbl") != NULL) ||
-                       (strstr(data, "ignoring") != NULL) ||
-                       (strstr(data, "not found.") != NULL) ||
-                       (strstr(data, "failed"))) {
                if (!completion_done(&event_done)) {
                        SCSC_TAG_INFO(WLBTD, "completing event_done\n");
                        complete(&event_done);
                }
+               break;
+       case SCSC_WLBTD_FW_PANIC_TAR_GENERATED:
+       case SCSC_WLBTD_FW_PANIC_ERR_TAR:
+       case SCSC_WLBTD_FW_PANIC_ERR_SCRIPT_FILE_NOT_FOUND:
+       case SCSC_WLBTD_FW_PANIC_ERR_NO_DEV:
+       case SCSC_WLBTD_FW_PANIC_ERR_MMAP:
+       case SCSC_WLBTD_FW_PANIC_ERR_SABLE_FILE:
+               if (!completion_done(&fw_panic_done)) {
+                       SCSC_TAG_INFO(WLBTD, "completing fw_panic_done\n");
+                       complete(&fw_panic_done);
+               }
+               break;
+       case SCSC_WLBTD_OTHER_TAR_GENERATED:
+               /* ignore */
+               break;
+       case SCSC_WLBTD_OTHER_SBL_GENERATED:
+       case SCSC_WLBTD_OTHER_ERR_TAR:
+       case SCSC_WLBTD_OTHER_ERR_SCRIPT_FILE_NOT_FOUND:
+       case SCSC_WLBTD_OTHER_ERR_NO_DEV:
+       case SCSC_WLBTD_OTHER_ERR_MMAP:
+       case SCSC_WLBTD_OTHER_ERR_SABLE_FILE:
+       case SCSC_WLBTD_OTHER_IGNORE_TRIGGER:
+               if (!completion_done(&event_done)) {
+                       SCSC_TAG_INFO(WLBTD, "completing event_done\n");
+                       complete(&event_done);
+               }
+               break;
+       default:
+               SCSC_TAG_ERR(WLBTD, "UNKNOWN reponse from WLBTD\n");
        }
 
        return 0;
index 12cb8aff7b4529b3137cbeede9ab77e37379de73..41d972b480d4b6c1e95ef75f3edf7a8e167dd77d 100644 (file)
@@ -47,6 +47,30 @@ enum events {
        __EVENT_MAX,
 };
 
+enum scsc_wlbtd_response_codes {
+       /* NOTE: keep the enum in sync with userspace wlbtd */
+       /* parse failed */
+       SCSC_WLBTD_ERR_PARSE_FAILED,
+
+       /* fw_panic trigger */
+       SCSC_WLBTD_FW_PANIC_TAR_GENERATED,
+       SCSC_WLBTD_FW_PANIC_ERR_SCRIPT_FILE_NOT_FOUND,
+       SCSC_WLBTD_FW_PANIC_ERR_NO_DEV,
+       SCSC_WLBTD_FW_PANIC_ERR_MMAP,
+       SCSC_WLBTD_FW_PANIC_ERR_SABLE_FILE,
+       SCSC_WLBTD_FW_PANIC_ERR_TAR,
+
+       /* other triggers */
+       SCSC_WLBTD_OTHER_SBL_GENERATED,
+       SCSC_WLBTD_OTHER_TAR_GENERATED,
+       SCSC_WLBTD_OTHER_ERR_SCRIPT_FILE_NOT_FOUND,
+       SCSC_WLBTD_OTHER_ERR_NO_DEV,
+       SCSC_WLBTD_OTHER_ERR_MMAP,
+       SCSC_WLBTD_OTHER_ERR_SABLE_FILE,
+       SCSC_WLBTD_OTHER_ERR_TAR,
+       SCSC_WLBTD_OTHER_IGNORE_TRIGGER,
+};
+
 static const struct genl_multicast_group scsc_mcgrp[] = {
        { .name = "scsc_mdp_grp", },
 };