Commit 23c0f3dc authored by Sean Paul's avatar Sean Paul

drm/rockchip: Don't use a delayed worker for psr state changes

The delayed worker isn't needed and is racey. Remove it and do
the state change in line.
Reviewed-by: default avatarYakir Yang <ykk@rock-chips.com>
Tested-by: default avatarYakir Yang <ykk@rock-chips.com>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
parent 18d8d4d2
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "rockchip_drm_psr.h" #include "rockchip_drm_psr.h"
#define PSR_FLUSH_TIMEOUT msecs_to_jiffies(3000) /* 3 seconds */ #define PSR_FLUSH_TIMEOUT msecs_to_jiffies(3000) /* 3 seconds */
#define PSR_SET_DELAY_TIME msecs_to_jiffies(10)
enum psr_state { enum psr_state {
PSR_FLUSH, PSR_FLUSH,
...@@ -31,11 +30,8 @@ struct psr_drv { ...@@ -31,11 +30,8 @@ struct psr_drv {
struct list_head list; struct list_head list;
struct drm_encoder *encoder; struct drm_encoder *encoder;
enum psr_state request_state;
enum psr_state state; enum psr_state state;
struct delayed_work state_work;
struct timer_list flush_timer; struct timer_list flush_timer;
void (*set)(struct drm_encoder *encoder, bool enable); void (*set)(struct drm_encoder *encoder, bool enable);
...@@ -59,11 +55,8 @@ static struct psr_drv *find_psr_by_crtc(struct drm_crtc *crtc) ...@@ -59,11 +55,8 @@ static struct psr_drv *find_psr_by_crtc(struct drm_crtc *crtc)
return psr; return psr;
} }
static void psr_state_work(struct work_struct *work) static void psr_set_state(struct psr_drv *psr, enum psr_state state)
{ {
struct psr_drv *psr = container_of(work, typeof(*psr), state_work.work);
enum psr_state request_state = psr->request_state;
/* /*
* Allowed finite state machine: * Allowed finite state machine:
* *
...@@ -75,24 +68,22 @@ static void psr_state_work(struct work_struct *work) ...@@ -75,24 +68,22 @@ static void psr_state_work(struct work_struct *work)
*/ */
/* Forbid no state change */ /* Forbid no state change */
if (request_state == psr->state) if (state == psr->state)
return; return;
/* Forbid DISABLE change to FLUSH */ /* Forbid DISABLE change to FLUSH */
if (request_state == PSR_FLUSH && psr->state == PSR_DISABLE) if (state == PSR_FLUSH && psr->state == PSR_DISABLE)
return; return;
/* Only wrote in this work, no need lock protection */
psr->state = state;
/* Allow but no need hardware change, just need assign the state */ /* Allow but no need hardware change, just need assign the state */
if (request_state == PSR_DISABLE && psr->state == PSR_FLUSH) { if (state == PSR_DISABLE && psr->state == PSR_FLUSH)
psr->state = request_state;
return; return;
}
/* Only wrote in this work, no need lock protection */
psr->state = request_state;
/* Refact to hardware state change */ /* Refact to hardware state change */
switch (request_state) { switch (psr->state) {
case PSR_ENABLE: case PSR_ENABLE:
psr->set(psr->encoder, true); psr->set(psr->encoder, true);
break; break;
...@@ -104,13 +95,6 @@ static void psr_state_work(struct work_struct *work) ...@@ -104,13 +95,6 @@ static void psr_state_work(struct work_struct *work)
} }
} }
static void psr_set_state(struct psr_drv *psr, enum psr_state state)
{
psr->request_state = state;
schedule_delayed_work(&psr->state_work, PSR_SET_DELAY_TIME);
}
static void psr_flush_handler(unsigned long data) static void psr_flush_handler(unsigned long data)
{ {
struct psr_drv *psr = (struct psr_drv *)data; struct psr_drv *psr = (struct psr_drv *)data;
...@@ -119,7 +103,7 @@ static void psr_flush_handler(unsigned long data) ...@@ -119,7 +103,7 @@ static void psr_flush_handler(unsigned long data)
return; return;
/* State changed between flush time, then keep it */ /* State changed between flush time, then keep it */
if (psr->request_state != PSR_FLUSH) if (psr->state != PSR_FLUSH)
return; return;
psr_set_state(psr, PSR_ENABLE); psr_set_state(psr, PSR_ENABLE);
...@@ -183,7 +167,7 @@ void rockchip_drm_psr_flush(struct drm_device *dev) ...@@ -183,7 +167,7 @@ void rockchip_drm_psr_flush(struct drm_device *dev)
spin_lock_irqsave(&drm_drv->psr_list_lock, flags); spin_lock_irqsave(&drm_drv->psr_list_lock, flags);
list_for_each_entry(psr, &drm_drv->psr_list, list) { list_for_each_entry(psr, &drm_drv->psr_list, list) {
if (psr->request_state == PSR_DISABLE) if (psr->state == PSR_DISABLE)
continue; continue;
mod_timer(&psr->flush_timer, mod_timer(&psr->flush_timer,
...@@ -219,8 +203,6 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder, ...@@ -219,8 +203,6 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder,
setup_timer(&psr->flush_timer, psr_flush_handler, (unsigned long)psr); setup_timer(&psr->flush_timer, psr_flush_handler, (unsigned long)psr);
INIT_DELAYED_WORK(&psr->state_work, psr_state_work);
psr->state = PSR_DISABLE; psr->state = PSR_DISABLE;
psr->encoder = encoder; psr->encoder = encoder;
psr->set = psr_set; psr->set = psr_set;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment