From bb5ba49137a0c5f4c44facefe2a2ca7aaae57b0a Mon Sep 17 00:00:00 2001 From: Jake Day Date: Thu, 10 Aug 2017 13:53:54 -0400 Subject: [PATCH] misc: ipts: handle gfx event in a separate context --- drivers/misc/ipts/ipts-gfx.c | 44 +++++++++++++--------------- drivers/misc/ipts/ipts-mei.c | 26 ++++++++++++++++ drivers/misc/ipts/ipts-msg-handler.c | 6 ++-- drivers/misc/ipts/ipts.h | 2 ++ 4 files changed, 52 insertions(+), 26 deletions(-) diff --git a/drivers/misc/ipts/ipts-gfx.c b/drivers/misc/ipts/ipts-gfx.c index b831c93ba..ff4356507 100644 --- a/drivers/misc/ipts/ipts-gfx.c +++ b/drivers/misc/ipts/ipts-gfx.c @@ -36,23 +36,9 @@ static void gfx_processing_complete(void *data) static void notify_gfx_status(u32 status, void *data) { ipts_info_t *ipts = data; - ipts_state_t state; - ipts_dbg(ipts, "notify gfx status : %d\n", status); - - state = ipts_get_state(ipts); - - if (state == IPTS_STA_RAW_DATA_STARTED || state == IPTS_STA_HID_STARTED) { - if (status == IPTS_NOTIFY_STA_BACKLIGHT_ON && - ipts->display_status == false) { - ipts_send_sensor_clear_mem_window_cmd(ipts); - ipts->display_status = true; - } else if (status == IPTS_NOTIFY_STA_BACKLIGHT_OFF && - ipts->display_status == true) { - ipts_send_sensor_quiesce_io_cmd(ipts); - ipts->display_status = false; - } - } + ipts->gfx_status = status; + schedule_work(&ipts->gfx_status_work); } static int connect_gfx(ipts_info_t *ipts) @@ -81,9 +67,13 @@ static void disconnect_gfx(ipts_info_t *ipts) intel_ipts_disconnect(ipts->gfx_info.gfx_handle); } +#define RUN_DBG_THREAD + #ifdef RUN_DBG_THREAD #include "../mei/mei_dev.h" +static struct task_struct *dbg_thread; + static void ipts_print_dbg_info(ipts_info_t* ipts) { char fw_sts_str[MEI_FW_STATUS_STR_SZ]; @@ -104,22 +94,24 @@ static void ipts_print_dbg_info(ipts_info_t* ipts) static int ipts_dbg_thread(void *data) { - ipts_info_t *ipts = (ipts_info_t*)data; + ipts_info_t *ipts = (ipts_info_t *)data; - pr_info(">> start debug thread\n"); - while (1) { + pr_info(">> start debug thread\n"); + + while (!kthread_should_stop()) { if (ipts_get_state(ipts) != IPTS_STA_RAW_DATA_STARTED) { - pr_info("state is not IPTS_STA_RAW_DATA_SATARTED\n"); + pr_info("state is not IPTS_STA_RAW_DATA_STARTED : %d\n", + ipts_get_state(ipts)); msleep(5000); continue; } ipts_print_dbg_info(ipts); - msleep(3000); - } + msleep(3000); + } - return 0; + return 0; } #endif @@ -141,7 +133,7 @@ int ipts_open_gpu(ipts_info_t *ipts) } #ifdef RUN_DBG_THREAD - kthread_run(ipts_dbg_thread, (void*)ipts, "ipts_debug"); + dbg_thread = kthread_run(ipts_dbg_thread, (void *)ipts, "ipts_debug"); #endif return 0; @@ -150,6 +142,10 @@ int ipts_open_gpu(ipts_info_t *ipts) void ipts_close_gpu(ipts_info_t *ipts) { disconnect_gfx(ipts); + +#ifdef RUN_DBG_THREAD + kthread_stop(dbg_thread); +#endif } intel_ipts_mapbuffer_t *ipts_map_buffer(ipts_info_t *ipts, u32 size, u32 flags) diff --git a/drivers/misc/ipts/ipts-mei.c b/drivers/misc/ipts/ipts-mei.c index 8c332ba35..39667e75d 100644 --- a/drivers/misc/ipts/ipts-mei.c +++ b/drivers/misc/ipts/ipts-mei.c @@ -110,6 +110,29 @@ static void raw_data_work_func(struct work_struct *work) ipts_handle_processed_data(ipts); } +static void gfx_status_work_func(struct work_struct *work) +{ + ipts_info_t *ipts = container_of(work, ipts_info_t, gfx_status_work); + ipts_state_t state; + int status = ipts->gfx_status; + + ipts_dbg(ipts, "notify gfx status : %d\n", status); + + state = ipts_get_state(ipts); + + if (state == IPTS_STA_RAW_DATA_STARTED || state == IPTS_STA_HID_STARTED) { + if (status == IPTS_NOTIFY_STA_BACKLIGHT_ON && + ipts->display_status == false) { + ipts_send_sensor_clear_mem_window_cmd(ipts); + ipts->display_status = true; + } else if (status == IPTS_NOTIFY_STA_BACKLIGHT_OFF && + ipts->display_status == true) { + ipts_send_sensor_quiesce_io_cmd(ipts); + ipts->display_status = false; + } + } +} + /* event loop */ static int ipts_mei_cl_event_thread(void *data) { @@ -186,6 +209,7 @@ static int ipts_mei_cl_probe(struct mei_cl_device *cldev, INIT_WORK(&ipts->init_work, init_work_func); INIT_WORK(&ipts->raw_data_work, raw_data_work_func); + INIT_WORK(&ipts->gfx_status_work, gfx_status_work_func); ret = sysfs_create_group(&cldev->dev.kobj, &ipts_grp); if (ret != 0) { @@ -215,6 +239,8 @@ static int ipts_mei_cl_remove(struct mei_cl_device *cldev) kthread_stop(ipts->event_loop); + pr_info("IPTS removed\n"); + return 0; } diff --git a/drivers/misc/ipts/ipts-msg-handler.c b/drivers/misc/ipts/ipts-msg-handler.c index e58d1028b..b53f668d6 100644 --- a/drivers/misc/ipts/ipts-msg-handler.c +++ b/drivers/misc/ipts/ipts-msg-handler.c @@ -20,7 +20,8 @@ int ipts_handle_cmd(ipts_info_t *ipts, u32 cmd, void *data, int data_size) ret = mei_cldev_send(ipts->cldev, (u8*)&h2m_msg, len); if (ret < 0) { - ipts_err(ipts, "mei_cldev_send() error 0x%X:%d\n", cmd, ret); + ipts_err(ipts, "mei_cldev_send() error 0x%X:%d\n", + cmd, ret); return ret; } @@ -56,6 +57,7 @@ int ipts_send_sensor_quiesce_io_cmd(ipts_info_t *ipts) ret = ipts_handle_cmd(ipts, TOUCH_SENSOR_QUIESCE_IO_CMD, &quiesce_io_cmd, cmd_len); + return ret; } @@ -326,7 +328,7 @@ int ipts_handle_resp(ipts_info_t *ipts, touch_sensor_msg_m2h_t *m2h_msg, ipts_set_state(ipts, IPTS_STA_RAW_DATA_STARTED); } - ipts_dbg(ipts, "touch enabled\n"); + ipts_err(ipts, "touch enabled %d\n", ipts_get_state(ipts)); break; case TOUCH_SENSOR_HID_READY_FOR_DATA_RSP: diff --git a/drivers/misc/ipts/ipts.h b/drivers/misc/ipts/ipts.h index 8f3b468c5..a7a4846ca 100644 --- a/drivers/misc/ipts/ipts.h +++ b/drivers/misc/ipts/ipts.h @@ -97,6 +97,7 @@ typedef struct ipts_info { struct work_struct init_work; struct work_struct raw_data_work; + struct work_struct gfx_status_work; struct task_struct *event_loop; @@ -119,6 +120,7 @@ typedef struct ipts_info { ipts_gfx_info_t gfx_info; u64 kernel_handle; + int gfx_status; bool display_status; bool switch_sensor_mode;