[9610] wlbt: Added modparams to Sable and MXLOGGER
authorCristian Marussi <c.marussi@samsung.com>
Wed, 25 Jul 2018 19:03:12 +0000 (20:03 +0100)
committerhskang <hs1218.kang@samsung.com>
Fri, 17 Aug 2018 00:33:00 +0000 (20:33 -0400)
Sable could be now disabled as a whole using modparams:
file generation is inhibited and MXLOGGER underlying mechanism
is halted, refraining from sending the needed config to FW
MXLOGGER module. All FW logs will suddendly flow to the Host
and NO Sable file could be generated.

Change-Id: I76b15756ed9ec589bce3b7fc17434719fc9ded4c
SCSC-Bug-ID: SSB-42258
Signed-off-by: Cristian Marussi <c.marussi@samsung.com>
drivers/misc/samsung/scsc/fwhdr.c
drivers/misc/samsung/scsc/mxlogger.c
drivers/misc/samsung/scsc/mxlogger.h
drivers/misc/samsung/scsc/scsc_log_collector.c

index c83341be2021519d3d51cbdf9dfe9fa31d27c725..0600ebb6b1740e0bd7e6080184fcf7d398329444 100644 (file)
@@ -65,7 +65,7 @@ static bool fwhdr_parse_v02(char *fw, struct fwhdr *fwhdr)
                fwhdr->const_fw_length = FWHDR_02_CONST_FW_LENGTH(fw);
                fwhdr->hdr_length = FWHDR_02_HDR_LENGTH(fw);
                fwhdr->fw_runtime_length = FWHDR_02_HEADER_FIRMWARE_RUNTIME_LENGTH(fw);
-               SCSC_TAG_INFO(FW_LOAD, "hdr_length=%d", fwhdr->hdr_length);
+               SCSC_TAG_INFO(FW_LOAD, "hdr_length=%d\n", fwhdr->hdr_length);
                fwhdr->r4_panic_record_offset = FWHDR_02_R4_PANIC_RECORD_OFFSET(fw);
                fwhdr->m4_panic_record_offset = FWHDR_02_M4_PANIC_RECORD_OFFSET(fw);
                return true;
index 811b6db3b694af0faee8c9b994733002dfd0de8a..4f73f1edd8ab3f85970e6d05a94ac2ff05492a96 100644 (file)
 #include "mifintrbit.h"
 #include "mxmgmt_transport.h"
 
-static bool mxlogger_forced_disabled = true;
+static bool mxlogger_disabled;
+module_param(mxlogger_disabled, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(mxlogger_disabled, "Disable MXLOGGER Configuration. Effective only at next WLBT boot.");
+
+bool mxlogger_set_enabled_status(bool enable)
+{
+       mxlogger_disabled = !enable;
+
+       SCSC_TAG_INFO(MXMAN, "MXLOGGER has been NOW %sABLED. Effective at next WLBT boot.\n",
+                     mxlogger_disabled ? "DIS" : "EN");
+
+       return mxlogger_disabled;
+}
+EXPORT_SYMBOL(mxlogger_set_enabled_status);
+
+static bool mxlogger_forced_to_host = true;
 
 static void update_fake_observer(void)
 {
-       SCSC_TAG_INFO(MXMAN, "MXLOGGER will now be %sABLED.\n",
-                       mxlogger_forced_disabled ? "DIS" : "EN");
-       if (mxlogger_forced_disabled)
+       if (mxlogger_forced_to_host) {
                mxlogger_register_global_observer("FAKE_OBSERVER");
-       else
+               SCSC_TAG_INFO(MXMAN, "MXLOGGER is now FORCED TO HOST.\n");
+       } else {
                mxlogger_unregister_global_observer("FAKE_OBSERVER");
+               SCSC_TAG_INFO(MXMAN, "MXLOGGER is now operating NORMALLY.\n");
+       }
 }
 
-static int force_disable_mxlogger_set_param_cb(const char *val,
+static int mxlogger_force_to_host_set_param_cb(const char *val,
                                               const struct kernel_param *kp)
 {
        bool nval;
@@ -43,8 +59,8 @@ static int force_disable_mxlogger_set_param_cb(const char *val,
        if (!val || strtobool(val, &nval))
                return -EINVAL;
 
-       if (mxlogger_forced_disabled ^ nval) {
-               mxlogger_forced_disabled = nval;
+       if (mxlogger_forced_to_host ^ nval) {
+               mxlogger_forced_to_host = nval;
                update_fake_observer();
        }
        return 0;
@@ -54,18 +70,18 @@ static int force_disable_mxlogger_set_param_cb(const char *val,
  * As described in struct kernel_param+ops the _get method:
  * -> returns length written or -errno.  Buffer is 4k (ie. be short!)
  */
-static int force_disable_mxlogger_get_param_cb(char *buffer,
+static int mxlogger_force_to_host_get_param_cb(char *buffer,
                                               const struct kernel_param *kp)
 {
-       return sprintf(buffer, "%c", mxlogger_forced_disabled ? 'Y' : 'N');
+       return sprintf(buffer, "%c", mxlogger_forced_to_host ? 'Y' : 'N');
 }
 
-static struct kernel_param_ops force_disable_mxlogger_ops = {
-       .set = force_disable_mxlogger_set_param_cb,
-       .get = force_disable_mxlogger_get_param_cb,
+static struct kernel_param_ops mxlogger_force_to_host_ops = {
+       .set = mxlogger_force_to_host_set_param_cb,
+       .get = mxlogger_force_to_host_get_param_cb,
 };
-module_param_cb(force_disable_mxlogger, &force_disable_mxlogger_ops, NULL, 0644);
-MODULE_PARM_DESC(force_disable_mxlogger, "Force mxlogger to be disabled, using a fake observer.");
+module_param_cb(mxlogger_force_to_host, &mxlogger_force_to_host_ops, NULL, 0644);
+MODULE_PARM_DESC(mxlogger_force_to_host, "Force mxlogger to redirect to Host all the time, using a fake observer.");
 
 /**
  * Observers of log material could come and go before mxman and mxlogger
@@ -480,7 +496,6 @@ int mxlogger_init(struct scsc_mx *mx, struct mxlogger *mxlogger, uint32_t mem_sz
                return -EIO;
        }
 
-       //XXX ???
        if (mem_sz <= (sizeof(struct mxlogger_config_area) + MXLOGGER_IMP_SIZE)) {
                SCSC_TAG_ERR(MXMAN, "Insufficient memory allocation\n");
                return -EIO;
@@ -508,7 +523,6 @@ int mxlogger_init(struct scsc_mx *mx, struct mxlogger *mxlogger, uint32_t mem_sz
        /* Initialize configuration structure */
        SCSC_TAG_INFO(MXMAN, "MXLOGGER Configuration: 0x%x\n", (u32)mxlogger->mifram_ref);
        cfg = (struct mxlogger_config_area *)mxlogger->mem;
-       //memset(cfg, 0, sizeof(struct mxlogger_config_area));
 
        cfg->config.magic_number = MXLOGGER_MAGIG_NUMBER;
        cfg->config.config_major = MXLOGGER_MAJOR;
@@ -585,7 +599,7 @@ int mxlogger_init(struct scsc_mx *mx, struct mxlogger *mxlogger, uint32_t mem_sz
 
        /**
         * Update observers status considering
-        * current value of mxlogger_forced_disabled
+        * current value of mxlogger_forced_to_host
         */
        update_fake_observer();
 
@@ -642,6 +656,11 @@ int mxlogger_init(struct scsc_mx *mx, struct mxlogger *mxlogger, uint32_t mem_sz
 
 int mxlogger_start(struct mxlogger *mxlogger)
 {
+       if (mxlogger_disabled) {
+               SCSC_TAG_WARNING(MXMAN, "MXLOGGER is disabled. Not Starting.\n");
+               return -1;
+       }
+
        SCSC_TAG_INFO(MXMAN, "Starting mxlogger with %d observer[s]\n", mxlogger->observers);
 
        mutex_lock(&mxlogger->lock);
index 6651155dee622da1bd09607645b289a3af77b615..deabe38e7f45b303f29a800932673bbd162c704d 100644 (file)
@@ -206,6 +206,7 @@ int mxlogger_register_observer(struct mxlogger *mxlogger, char *name);
 int mxlogger_unregister_observer(struct mxlogger *mxlogger, char *name);
 int mxlogger_register_global_observer(char *name);
 int mxlogger_unregister_global_observer(char *name);
+bool mxlogger_set_enabled_status(bool enable);
 
 #define MEM_LAYOUT_CHECK()     \
  ({                            \
index 5de3cb990cc673ec5e8033d283b3ff3de82e5349..96a18ac56c453d0335ea8fd8fabbd35737667d1d 100644 (file)
@@ -18,6 +18,8 @@
 #include <scsc/scsc_log_collector.h>
 #include "scsc_log_collector_proc.h"
 #include <scsc/scsc_mx.h>
+#include "mxlogger.h"
+
 #ifdef CONFIG_SCSC_WLBTD
 #include "scsc_wlbtd.h"
 #endif
@@ -49,6 +51,41 @@ static char collection_dir_buf[256] = "/data/exynos/log/wifi";
 module_param_string(collection_target_directory, collection_dir_buf, sizeof(collection_dir_buf), S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(collection_target_directory, "Specify collection target directory");
 
+static bool sable_collection_off;
+static int sable_collection_off_set_param_cb(const char *val,
+                                            const struct kernel_param *kp)
+{
+       bool nval;
+
+       if (!val || strtobool(val, &nval))
+               return -EINVAL;
+
+       if (sable_collection_off ^ nval) {
+               sable_collection_off = nval;
+               mxlogger_set_enabled_status(!sable_collection_off);
+               pr_info("Sable Log Collection is now %sABLED.\n",
+                       sable_collection_off ? "DIS" : "EN");
+       }
+       return 0;
+}
+
+/**
+ * As described in struct kernel_param+ops the _get method:
+ * -> returns length written or -errno.  Buffer is 4k (ie. be short!)
+ */
+static int sable_collection_off_get_param_cb(char *buffer,
+                                            const struct kernel_param *kp)
+{
+       return sprintf(buffer, "%c", sable_collection_off ? 'Y' : 'N');
+}
+
+static struct kernel_param_ops sable_collection_off_ops = {
+       .set = sable_collection_off_set_param_cb,
+       .get = sable_collection_off_get_param_cb,
+};
+module_param_cb(sable_collection_off, &sable_collection_off_ops, NULL, 0644);
+MODULE_PARM_DESC(sable_collection_off, "Disable SABLE Log Collection. This will inhibit also MXLOGGER");
+
 struct scsc_log_client {
        struct list_head list;
        struct scsc_log_collector_client *collect_client;
@@ -90,6 +127,10 @@ int __init scsc_log_collector(void)
        log_status.collection_workq = create_workqueue("log_collector");
        if (log_status.collection_workq)
                INIT_WORK(&log_status.collect_work, collection_worker);
+       /* Update mxlogger status on init.*/
+       pr_info("Sable Log Collection is now %sABLED.\n",
+               sable_collection_off ? "DIS" : "EN");
+       mxlogger_set_enabled_status(!sable_collection_off);
        scsc_log_collect_proc_create();
        return 0;
 }
@@ -365,7 +406,13 @@ exit:
 
 int scsc_log_collector_collect(enum scsc_log_reason reason)
 {
-       int ret;
+       int ret = -1;
+
+       if (sable_collection_off) {
+               pr_info("Sable Log Collection is currently DISABLED (sable_collection_off=Y).\n");
+               pr_info("Ignoring incoming Sable Collection request with Reason=%d.\n", reason);
+               return ret;
+       }
 
        if (collect_to_ram)
                ret = __scsc_log_collector_collect_to_ram(reason);