[RAMEN9610-19622] Save CP crash infomation when occured reset without dump
authorJiyoung Jeong <ji_0.jeong@samsung.com>
Thu, 14 Mar 2019 15:00:01 +0000 (00:00 +0900)
committerKim Gunho <gunho.kim@samsung.com>
Mon, 9 Sep 2019 11:09:10 +0000 (20:09 +0900)
Change-Id: I2e087a78a4a33f8092b0d4b34d0e6dd70488f47d
Signed-off-by: Jiyoung Jeong <ji_0.jeong@samsung.com>
Signed-off-by: Kim Gunho <gunho.kim@samsung.com>
drivers/misc/modem_if/modem_link_device_shmem.c
drivers/misc/modem_if/modem_link_device_shmem.h
drivers/misc/modem_if/modem_prj.h

index d83ed81d323f17c6c6900ef6b8a5464c04fd41d2..527e63b999682ddd7df1e979d32fe3263886f692 100644 (file)
@@ -2360,6 +2360,66 @@ static void shmem_link_terminate(struct link_device *ld, struct io_device *iod)
        }
 }
 
+static char *shmem_get_srinfo_address(struct link_device *ld)
+{
+       struct shmem_link_device *shmd = to_shmem_link_device(ld);
+       char *base = (u8 __iomem *)shmd->base + SHMEM_SRINFO_OFFSET;
+
+       return base;
+}
+
+static int shmem_ioctl(struct link_device *ld, struct io_device *iod,
+                      unsigned int cmd, unsigned long arg)
+{
+       mif_err("%s: cmd 0x%08X\n", ld->name, cmd);
+
+       switch (cmd) {
+       case IOCTL_MODEM_GET_SHMEM_SRINFO:
+       {
+               struct shmem_srinfo __user *sr_arg =
+                       (struct shmem_srinfo __user *)arg;
+               unsigned count, size = SHMEM_SRINFO_SIZE;
+
+               if (copy_from_user(&count, &sr_arg->size, sizeof(unsigned)))
+                       return -EFAULT;
+
+               mif_info("get srinfo:%s, size = %d\n", iod->name, count);
+
+               size = min(size, count);
+               if (copy_to_user(&sr_arg->size, &size, sizeof(unsigned)))
+                       return -EFAULT;
+
+               if (copy_to_user(sr_arg->buf, shmem_get_srinfo_address(ld),
+                       size))
+                       return -EFAULT;
+               break;
+       }
+
+       case IOCTL_MODEM_SET_SHMEM_SRINFO:
+       {
+               struct shmem_srinfo __user *sr_arg =
+                       (struct shmem_srinfo __user *)arg;
+               unsigned count, size = SHMEM_SRINFO_SIZE;
+
+               if (copy_from_user(&count, &sr_arg->size, sizeof(unsigned)))
+                       return -EFAULT;
+
+               mif_info("set srinfo:%s, size = %d\n", iod->name, count);
+
+               if (copy_from_user(shmem_get_srinfo_address(ld), sr_arg->buf,
+                       min(count, size)))
+                       return -EFAULT;
+               break;
+       }
+
+       default:
+               mif_err("%s: ERR! invalid cmd 0x%08X\n", ld->name, cmd);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 static inline bool valid_bin_range(struct modem_data *modem, struct data_info *di)
 {
        u32 resmem_start, resmem_end;
@@ -2837,7 +2897,6 @@ static const struct attribute_group napi_group = {        \
        .name = "napi",
 };
 #endif /* CONFIG_LINK_DEVICE_NAPI */
-
 struct link_device *shmem_create_link_device(struct platform_device *pdev)
 {
        struct shmem_link_device *shmd = NULL;
@@ -2878,6 +2937,9 @@ struct link_device *shmem_create_link_device(struct platform_device *pdev)
        ld->aligned = 1;
        ld->max_ipc_dev = MAX_EXYNOS_DEVICES;
 
+       /* Set up link device methods */
+       ld->ioctl = shmem_ioctl;
+
        /* Set attributes as a link device */
        ld->terminate_comm = shmem_link_terminate;
        ld->send = shmem_send;
index b65518ee9a1d62778ca790066be0a255032b6188..2586b7c53987164f35dd28190b455beb997c4723 100644 (file)
@@ -53,6 +53,9 @@
 #define SHM_RX_MAX_QOS_TRIGGER_BYTES   6250000 /* Express 100Mbps as Bytes per 0.5ms */
 #define SHM_RX_MIN_QOS_HOLD_MS         500     /* 500ms */
 
+#define SHMEM_SRINFO_OFFSET    0x800   /* 4KB - 2KB */
+#define SHMEM_SRINFO_SIZE              0x400   /* 1KB */
+
 #define TIMER_INTERVAL_NS      500000000       /* 500ms */
 
 struct crash_reason {
@@ -60,6 +63,11 @@ struct crash_reason {
        char string[MEM_CRASH_REASON_SIZE];
 };
 
+struct shmem_srinfo {
+       unsigned int size;
+       char buf[0];
+};
+
 struct shmem_4mb_phys_map {
        u32 magic;
        u32 access;
index 0bbf7f1d4fe3485a0dbdf968506dc2dc92fe25ec..4356cc426ba92ba8197fb8d54ce503994aa47dca 100644 (file)
@@ -78,6 +78,9 @@
 #define IOCTL_MODEM_XMIT_BOOT          _IO('o', 0x40)
 #define IOCTL_MODEM_GET_SHMEM_INFO     _IO('o', 0x41)
 
+#define IOCTL_MODEM_GET_SHMEM_SRINFO   _IO('o', 0x45)
+#define IOCTL_MODEM_SET_SHMEM_SRINFO   _IO('o', 0x46)
+
 /* ioctl command for IPC Logger */
 #define IOCTL_MIF_LOG_DUMP             _IO('o', 0x51)