@@ -189,7 +189,7 @@ static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags)
drm_dev->dev_private = private;
INIT_LIST_HEAD(&private->psr_list);
- mutex_init(&private->psr_list_mutex);
+ spin_lock_init(&private->psr_list_lock);
drm_mode_config_init(drm_dev);
@@ -75,7 +75,7 @@ struct rockchip_drm_private {
struct drm_mm mm;
struct list_head psr_list;
- struct mutex psr_list_mutex;
+ spinlock_t psr_list_lock;
};
void rockchip_drm_atomic_work(struct work_struct *work);
@@ -41,17 +41,18 @@ static struct psr_drv *find_psr_by_crtc(struct drm_crtc *crtc)
{
struct rockchip_drm_private *drm_drv = crtc->dev->dev_private;
struct psr_drv *psr;
+ unsigned long flags;
- mutex_lock(&drm_drv->psr_list_mutex);
+ spin_lock_irqsave(&drm_drv->psr_list_lock, flags);
list_for_each_entry(psr, &drm_drv->psr_list, list) {
- if (psr->encoder->crtc == crtc) {
- mutex_unlock(&drm_drv->psr_list_mutex);
- return psr;
- }
+ if (psr->encoder->crtc == crtc)
+ goto out;
}
- mutex_unlock(&drm_drv->psr_list_mutex);
+ psr = ERR_PTR(-ENODEV);
- return ERR_PTR(-ENODEV);
+out:
+ spin_unlock_irqrestore(&drm_drv->psr_list_lock, flags);
+ return psr;
}
static void psr_set_state(struct psr_drv *psr, enum psr_state state)
@@ -142,8 +143,9 @@ void rockchip_drm_psr_flush(struct drm_device *dev)
{
struct rockchip_drm_private *drm_drv = dev->dev_private;
struct psr_drv *psr;
+ unsigned long flags;
- mutex_lock(&drm_drv->psr_list_mutex);
+ spin_lock_irqsave(&drm_drv->psr_list_lock, flags);
list_for_each_entry(psr, &drm_drv->psr_list, list) {
if (psr->state == PSR_DISABLE)
continue;
@@ -153,7 +155,7 @@ void rockchip_drm_psr_flush(struct drm_device *dev)
psr_set_state(psr, PSR_FLUSH);
}
- mutex_unlock(&drm_drv->psr_list_mutex);
+ spin_unlock_irqrestore(&drm_drv->psr_list_lock, flags);
}
EXPORT_SYMBOL(rockchip_drm_psr_flush);
@@ -170,6 +172,7 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder,
{
struct rockchip_drm_private *drm_drv = encoder->dev->dev_private;
struct psr_drv *psr;
+ unsigned long flags;
if (!encoder || !psr_set)
return -EINVAL;
@@ -186,9 +189,9 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder,
psr->encoder = encoder;
psr->set = psr_set;
- mutex_lock(&drm_drv->psr_list_mutex);
+ spin_lock_irqsave(&drm_drv->psr_list_lock, flags);
list_add_tail(&psr->list, &drm_drv->psr_list);
- mutex_unlock(&drm_drv->psr_list_mutex);
+ spin_unlock_irqrestore(&drm_drv->psr_list_lock, flags);
return 0;
}
@@ -206,8 +209,9 @@ void rockchip_drm_psr_unregister(struct drm_encoder *encoder)
{
struct rockchip_drm_private *drm_drv = encoder->dev->dev_private;
struct psr_drv *psr, *n;
+ unsigned long flags;
- mutex_lock(&drm_drv->psr_list_mutex);
+ spin_lock_irqsave(&drm_drv->psr_list_lock, flags);
list_for_each_entry_safe(psr, n, &drm_drv->psr_list, list) {
if (psr->encoder == encoder) {
del_timer(&psr->flush_timer);
@@ -215,6 +219,6 @@ void rockchip_drm_psr_unregister(struct drm_encoder *encoder)
kfree(psr);
}
}
- mutex_unlock(&drm_drv->psr_list_mutex);
+ spin_unlock_irqrestore(&drm_drv->psr_list_lock, flags);
}
EXPORT_SYMBOL(rockchip_drm_psr_unregister);
Since it needs to be taken in the vblank_enable/disable stack, which is protected by another spinlock. This lock should be completely uncontested, since it's only taken in find_psr and register, which is only called on init. Signed-off-by: Sean Paul <seanpaul@chromium.org> --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_psr.c | 30 ++++++++++++++++------------- 3 files changed, 19 insertions(+), 15 deletions(-)