[RFC][PATCH v2] drm: kirin: Add a mutex to avoid fb initialization race

liuxinliang z.liuxinliang at hisilicon.com
Sat Feb 25 01:45:45 UTC 2017



On 2017/2/25 9:39, liuxinliang wrote:
> Hi John,
>
> The patch seems good to me, except one minus comment.
> Maybe change fb_lock to fbdev_lock would be better.
>
> Thanks,
> -xinliang
>
> On 2017/2/25 9:25, John Stultz wrote:
>> In some cases I've been seeing a race where two framebuffers
>> would be initialized, as kirin_fbdev_output_poll_changed()
>> might get called quickly in succession, resulting in the
>> initialization happening twice. This could cause the system
>> to boot up with a blank screen.
>>
>> This patch adds a simple mutex to serialize it and seems to
>> avoid the race.
>>
>> Suggestions or feedback would be greatly appreciated!
>>
>> Cc: Xinliang Liu <z.liuxinliang at hisilicon.com>
>> Cc: Rongrong Zou <zourongrong at gmail.com>
>> Cc: Xinwei Kong <kong.kongxinwei at hisilicon.com>
>> Cc: Chen Feng <puck.chen at hisilicon.com>
>> Cc: David Airlie <airlied at linux.ie>
>> Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
>> Cc: Sean Paul <seanpaul at chromium.org>
>> Cc: dri-devel at lists.freedesktop.org
>> Signed-off-by: John Stultz <john.stultz at linaro.org>
>> ---
>>   drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 4 ++++
>>   drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 1 +
>>   2 files changed, 5 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c 
>> b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
>> index 7ec93ae..b83556a 100644
>> --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
>> +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
>> @@ -55,6 +55,7 @@ static void kirin_fbdev_output_poll_changed(struct 
>> drm_device *dev)
>>   {
>>       struct kirin_drm_private *priv = dev->dev_private;
>>   +    mutex_lock(&priv->fb_lock);
>>       if (priv->fbdev) {
>>           drm_fbdev_cma_hotplug_event(priv->fbdev);
>>       } else {
>> @@ -63,6 +64,7 @@ static void kirin_fbdev_output_poll_changed(struct 
>> drm_device *dev)
>>           if (IS_ERR(priv->fbdev))
>>               priv->fbdev = NULL;
>>       }
>> +    mutex_unlock(&priv->fb_lock);
>>   }
>>   #endif
>>   @@ -95,6 +97,8 @@ static int kirin_drm_kms_init(struct drm_device 
>> *dev)
>>       if (!priv)
>>           return -ENOMEM;
>>   +    mutex_init(&priv->fb_lock);
And put this line in CONFIG_DRM_FBDEV_EMULATION
>> +
>>       dev->dev_private = priv;
>>       dev_set_drvdata(dev->dev, dev);
>>   diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h 
>> b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h
>> index 7f60c649..9b6d2b1 100644
>> --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h
>> +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h
>> @@ -23,6 +23,7 @@ struct kirin_drm_private {
>>   #ifdef CONFIG_DRM_FBDEV_EMULATION
>>       struct drm_fbdev_cma *fbdev;
>>   #endif
>> +    struct mutex fb_lock;
And here.

-xinliang

>>   };
>>     extern const struct kirin_dc_ops ade_dc_ops;
>




More information about the dri-devel mailing list