On 2014년 09월 30일 20:29, Andrzej Hajda wrote:
> Hi Inki,
>
> Gently ping.
Hi Andrzej,
I merged it to local repository to test. But now exynos drm doesn't work
correctly since pulling drm-next of Dave regardless of your patch.
Problems are,
1. error occurs when we try to test modetest with -v option from second
times.
2. error occurs when we try to test unbind.
Now we are checking these problems. Can you try to also check it?
Thanks,
Inki Dae
>
> Andrzej
>
> On 09/10/2014 01:53 PM, Andrzej Hajda wrote:
>> The patch replaces separate calls to driver (de)registration by
>> loops over the array of drivers. As a result it significantly
>> decreases number of ifdefs. Additionally it moves device registration
>> related ifdefs to header file.
>>
>> Signed-off-by: Andrzej Hajda <[email protected]>
>> ---
>> Hi Inki,
>>
>> During testing your component match support patch [1] I have prepared patch
>> removing most ifdefs from exynos_drm_drv.c. It is based on your patch, but
>> I can rebase it if necessary.
>>
>> [1]: http://permalink.gmane.org/gmane.linux.kernel.samsung-soc/37031
>>
>> Regards
>> Andrzej
>> ---
>> drivers/gpu/drm/exynos/exynos_drm_drv.c | 170 +++++++-------------------------
>> drivers/gpu/drm/exynos/exynos_drm_drv.h | 25 +++--
>> 2 files changed, 48 insertions(+), 147 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> index b2c710a..a660e46 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> @@ -553,74 +553,54 @@ static const struct component_master_ops exynos_drm_ops = {
>> .unbind = exynos_drm_unbind,
>> };
>>
>> -static int exynos_drm_platform_probe(struct platform_device *pdev)
>> -{
>> - struct component_match *match;
>> - int ret;
>> -
>> - pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
>> - exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls);
>> -
>> +static struct platform_driver * const exynos_drm_drivers[] = {
>> #ifdef CONFIG_DRM_EXYNOS_FIMD
>> - ret = platform_driver_register(&fimd_driver);
>> - if (ret < 0)
>> - return ret;
>> + &fimd_driver,
>> #endif
>> -
>> #ifdef CONFIG_DRM_EXYNOS_DP
>> - ret = platform_driver_register(&dp_driver);
>> - if (ret < 0)
>> - goto err_unregister_fimd_drv;
>> + &dp_driver,
>> #endif
>> -
>> #ifdef CONFIG_DRM_EXYNOS_DSI
>> - ret = platform_driver_register(&dsi_driver);
>> - if (ret < 0)
>> - goto err_unregister_dp_drv;
>> + &dsi_driver,
>> #endif
>> -
>> #ifdef CONFIG_DRM_EXYNOS_HDMI
>> - ret = platform_driver_register(&mixer_driver);
>> - if (ret < 0)
>> - goto err_unregister_dsi_drv;
>> - ret = platform_driver_register(&hdmi_driver);
>> - if (ret < 0)
>> - goto err_unregister_mixer_drv;
>> + &mixer_driver,
>> + &hdmi_driver,
>> #endif
>> -
>> #ifdef CONFIG_DRM_EXYNOS_G2D
>> - ret = platform_driver_register(&g2d_driver);
>> - if (ret < 0)
>> - goto err_unregister_hdmi_drv;
>> + &g2d_driver,
>> #endif
>> -
>> #ifdef CONFIG_DRM_EXYNOS_FIMC
>> - ret = platform_driver_register(&fimc_driver);
>> - if (ret < 0)
>> - goto err_unregister_g2d_drv;
>> + &fimc_driver,
>> #endif
>> -
>> #ifdef CONFIG_DRM_EXYNOS_ROTATOR
>> - ret = platform_driver_register(&rotator_driver);
>> - if (ret < 0)
>> - goto err_unregister_fimc_drv;
>> + &rotator_driver,
>> #endif
>> -
>> #ifdef CONFIG_DRM_EXYNOS_GSC
>> - ret = platform_driver_register(&gsc_driver);
>> - if (ret < 0)
>> - goto err_unregister_rotator_drv;
>> + &gsc_driver,
>> #endif
>> -
>> #ifdef CONFIG_DRM_EXYNOS_IPP
>> - ret = platform_driver_register(&ipp_driver);
>> - if (ret < 0)
>> - goto err_unregister_gsc_drv;
>> + &ipp_driver,
>> +#endif
>> +};
>> +
>> +static int exynos_drm_platform_probe(struct platform_device *pdev)
>> +{
>> + struct component_match *match;
>> + int ret, i;
>> +
>> + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
>> + exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls);
>> +
>> + for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
>> + ret = platform_driver_register(exynos_drm_drivers[i]);
>> + if (ret < 0)
>> + goto err_unregister_drivers;
>> + }
>>
>> ret = exynos_platform_device_ipp_register();
>> if (ret < 0)
>> - goto err_unregister_ipp_drv;
>> -#endif
>> + goto err_unregister_drivers;
>>
>> match = exynos_drm_match_add(&pdev->dev);
>> if (IS_ERR(match)) {
>> @@ -632,96 +612,24 @@ static int exynos_drm_platform_probe(struct platform_device *pdev)
>> match);
>>
>> err_unregister_ipp_dev:
>> -
>> -#ifdef CONFIG_DRM_EXYNOS_IPP
>> exynos_platform_device_ipp_unregister();
>> -err_unregister_ipp_drv:
>> - platform_driver_unregister(&ipp_driver);
>> -err_unregister_gsc_drv:
>> -#endif
>>
>> -#ifdef CONFIG_DRM_EXYNOS_GSC
>> - platform_driver_unregister(&gsc_driver);
>> -err_unregister_rotator_drv:
>> -#endif
>> +err_unregister_drivers:
>> + while (--i >= 0)
>> + platform_driver_unregister(exynos_drm_drivers[i]);
>>
>> -#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>> - platform_driver_unregister(&rotator_driver);
>> -err_unregister_fimc_drv:
>> -#endif
>> -
>> -#ifdef CONFIG_DRM_EXYNOS_FIMC
>> - platform_driver_unregister(&fimc_driver);
>> -err_unregister_g2d_drv:
>> -#endif
>> -
>> -#ifdef CONFIG_DRM_EXYNOS_G2D
>> - platform_driver_unregister(&g2d_driver);
>> -err_unregister_hdmi_drv:
>> -#endif
>> -
>> -#ifdef CONFIG_DRM_EXYNOS_HDMI
>> - platform_driver_unregister(&hdmi_driver);
>> -err_unregister_mixer_drv:
>> - platform_driver_unregister(&mixer_driver);
>> -err_unregister_dsi_drv:
>> -#endif
>> -
>> -#ifdef CONFIG_DRM_EXYNOS_DSI
>> - platform_driver_unregister(&dsi_driver);
>> -err_unregister_dp_drv:
>> -#endif
>> -
>> -#ifdef CONFIG_DRM_EXYNOS_DP
>> - platform_driver_unregister(&dp_driver);
>> -err_unregister_fimd_drv:
>> -#endif
>> -
>> -#ifdef CONFIG_DRM_EXYNOS_FIMD
>> - platform_driver_unregister(&fimd_driver);
>> -#endif
>> return ret;
>> }
>>
>> static int exynos_drm_platform_remove(struct platform_device *pdev)
>> {
>> -#ifdef CONFIG_DRM_EXYNOS_IPP
>> - exynos_platform_device_ipp_unregister();
>> - platform_driver_unregister(&ipp_driver);
>> -#endif
>> -
>> -#ifdef CONFIG_DRM_EXYNOS_GSC
>> - platform_driver_unregister(&gsc_driver);
>> -#endif
>> -
>> -#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>> - platform_driver_unregister(&rotator_driver);
>> -#endif
>> -
>> -#ifdef CONFIG_DRM_EXYNOS_FIMC
>> - platform_driver_unregister(&fimc_driver);
>> -#endif
>> -
>> -#ifdef CONFIG_DRM_EXYNOS_G2D
>> - platform_driver_unregister(&g2d_driver);
>> -#endif
>> -
>> -#ifdef CONFIG_DRM_EXYNOS_HDMI
>> - platform_driver_unregister(&mixer_driver);
>> - platform_driver_unregister(&hdmi_driver);
>> -#endif
>> + int i;
>>
>> -#ifdef CONFIG_DRM_EXYNOS_FIMD
>> - platform_driver_unregister(&fimd_driver);
>> -#endif
>> + exynos_platform_device_ipp_unregister();
>>
>> -#ifdef CONFIG_DRM_EXYNOS_DSI
>> - platform_driver_unregister(&dsi_driver);
>> -#endif
>> + for (i = ARRAY_SIZE(exynos_drm_drivers) - 1; i >= 0; --i)
>> + platform_driver_unregister(exynos_drm_drivers[i]);
>>
>> -#ifdef CONFIG_DRM_EXYNOS_DP
>> - platform_driver_unregister(&dp_driver);
>> -#endif
>> component_master_del(&pdev->dev, &exynos_drm_ops);
>> return 0;
>> }
>> @@ -745,11 +653,9 @@ static int exynos_drm_init(void)
>> if (IS_ERR(exynos_drm_pdev))
>> return PTR_ERR(exynos_drm_pdev);
>>
>> -#ifdef CONFIG_DRM_EXYNOS_VIDI
>> ret = exynos_drm_probe_vidi();
>> if (ret < 0)
>> goto err_unregister_pd;
>> -#endif
>>
>> ret = platform_driver_register(&exynos_drm_platform_driver);
>> if (ret)
>> @@ -758,11 +664,9 @@ static int exynos_drm_init(void)
>> return 0;
>>
>> err_remove_vidi:
>> -#ifdef CONFIG_DRM_EXYNOS_VIDI
>> exynos_drm_remove_vidi();
>>
>> err_unregister_pd:
>> -#endif
>> platform_device_unregister(exynos_drm_pdev);
>>
>> return ret;
>> @@ -771,9 +675,9 @@ err_unregister_pd:
>> static void exynos_drm_exit(void)
>> {
>> platform_driver_unregister(&exynos_drm_platform_driver);
>> -#ifdef CONFIG_DRM_EXYNOS_VIDI
>> +
>> exynos_drm_remove_vidi();
>> -#endif
>> +
>> platform_device_unregister(exynos_drm_pdev);
>> }
>>
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> index 69a6fa3..76d5d02 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> @@ -324,15 +324,14 @@ int exynos_platform_device_hdmi_register(void);
>> */
>> void exynos_platform_device_hdmi_unregister(void);
>>
>> -/*
>> - * this function registers exynos drm ipp platform device.
>> - */
>> +#ifdef CONFIG_DRM_EXYNOS_IPP
>> int exynos_platform_device_ipp_register(void);
>> -
>> -/*
>> - * this function unregisters exynos drm ipp platform device if it exists.
>> - */
>> void exynos_platform_device_ipp_unregister(void);
>> +#else
>> +static inline int exynos_platform_device_ipp_register(void) { return 0; }
>> +static inline void exynos_platform_device_ipp_unregister(void) {}
>> +#endif
>> +
>>
>> #ifdef CONFIG_DRM_EXYNOS_DPI
>> struct exynos_drm_display * exynos_dpi_probe(struct device *dev);
>> @@ -343,15 +342,13 @@ exynos_dpi_probe(struct device *dev) { return NULL; }
>> static inline int exynos_dpi_remove(struct device *dev) { return 0; }
>> #endif
>>
>> -/*
>> - * this function registers exynos drm vidi platform device/driver.
>> - */
>> +#ifdef CONFIG_DRM_EXYNOS_VIDI
>> int exynos_drm_probe_vidi(void);
>> -
>> -/*
>> - * this function unregister exynos drm vidi platform device/driver.
>> - */
>> void exynos_drm_remove_vidi(void);
>> +#else
>> +static inline int exynos_drm_probe_vidi(void) { return 0; }
>> +static inline void exynos_drm_remove_vidi(void) {}
>> +#endif
>>
>> /* This function creates a encoder and a connector, and initializes them. */
>> int exynos_drm_create_enc_conn(struct drm_device *dev,
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
On 2014년 10월 01일 14:48, Inki Dae wrote:
> On 2014년 09월 30일 20:29, Andrzej Hajda wrote:
>> Hi Inki,
>>
>> Gently ping.
>
> Hi Andrzej,
>
> I merged it to local repository to test. But now exynos drm doesn't work
> correctly since pulling drm-next of Dave regardless of your patch.
>
> Problems are,
> 1. error occurs when we try to test modetest with -v option from second
> times.
> 2. error occurs when we try to test unbind.
>
> Now we are checking these problems. Can you try to also check it?
In addition, we are testing it on trats2 board.
>
> Thanks,
> Inki Dae
>
>>
>> Andrzej
>>
>> On 09/10/2014 01:53 PM, Andrzej Hajda wrote:
>>> The patch replaces separate calls to driver (de)registration by
>>> loops over the array of drivers. As a result it significantly
>>> decreases number of ifdefs. Additionally it moves device registration
>>> related ifdefs to header file.
>>>
>>> Signed-off-by: Andrzej Hajda <[email protected]>
>>> ---
>>> Hi Inki,
>>>
>>> During testing your component match support patch [1] I have prepared patch
>>> removing most ifdefs from exynos_drm_drv.c. It is based on your patch, but
>>> I can rebase it if necessary.
>>>
>>> [1]: http://permalink.gmane.org/gmane.linux.kernel.samsung-soc/37031
>>>
>>> Regards
>>> Andrzej
>>> ---
>>> drivers/gpu/drm/exynos/exynos_drm_drv.c | 170 +++++++-------------------------
>>> drivers/gpu/drm/exynos/exynos_drm_drv.h | 25 +++--
>>> 2 files changed, 48 insertions(+), 147 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> index b2c710a..a660e46 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> @@ -553,74 +553,54 @@ static const struct component_master_ops exynos_drm_ops = {
>>> .unbind = exynos_drm_unbind,
>>> };
>>>
>>> -static int exynos_drm_platform_probe(struct platform_device *pdev)
>>> -{
>>> - struct component_match *match;
>>> - int ret;
>>> -
>>> - pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
>>> - exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls);
>>> -
>>> +static struct platform_driver * const exynos_drm_drivers[] = {
>>> #ifdef CONFIG_DRM_EXYNOS_FIMD
>>> - ret = platform_driver_register(&fimd_driver);
>>> - if (ret < 0)
>>> - return ret;
>>> + &fimd_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_DP
>>> - ret = platform_driver_register(&dp_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_fimd_drv;
>>> + &dp_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_DSI
>>> - ret = platform_driver_register(&dsi_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_dp_drv;
>>> + &dsi_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_HDMI
>>> - ret = platform_driver_register(&mixer_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_dsi_drv;
>>> - ret = platform_driver_register(&hdmi_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_mixer_drv;
>>> + &mixer_driver,
>>> + &hdmi_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_G2D
>>> - ret = platform_driver_register(&g2d_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_hdmi_drv;
>>> + &g2d_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_FIMC
>>> - ret = platform_driver_register(&fimc_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_g2d_drv;
>>> + &fimc_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>> - ret = platform_driver_register(&rotator_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_fimc_drv;
>>> + &rotator_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_GSC
>>> - ret = platform_driver_register(&gsc_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_rotator_drv;
>>> + &gsc_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_IPP
>>> - ret = platform_driver_register(&ipp_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_gsc_drv;
>>> + &ipp_driver,
>>> +#endif
>>> +};
>>> +
>>> +static int exynos_drm_platform_probe(struct platform_device *pdev)
>>> +{
>>> + struct component_match *match;
>>> + int ret, i;
>>> +
>>> + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
>>> + exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls);
>>> +
>>> + for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
>>> + ret = platform_driver_register(exynos_drm_drivers[i]);
>>> + if (ret < 0)
>>> + goto err_unregister_drivers;
>>> + }
>>>
>>> ret = exynos_platform_device_ipp_register();
>>> if (ret < 0)
>>> - goto err_unregister_ipp_drv;
>>> -#endif
>>> + goto err_unregister_drivers;
>>>
>>> match = exynos_drm_match_add(&pdev->dev);
>>> if (IS_ERR(match)) {
>>> @@ -632,96 +612,24 @@ static int exynos_drm_platform_probe(struct platform_device *pdev)
>>> match);
>>>
>>> err_unregister_ipp_dev:
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_IPP
>>> exynos_platform_device_ipp_unregister();
>>> -err_unregister_ipp_drv:
>>> - platform_driver_unregister(&ipp_driver);
>>> -err_unregister_gsc_drv:
>>> -#endif
>>>
>>> -#ifdef CONFIG_DRM_EXYNOS_GSC
>>> - platform_driver_unregister(&gsc_driver);
>>> -err_unregister_rotator_drv:
>>> -#endif
>>> +err_unregister_drivers:
>>> + while (--i >= 0)
>>> + platform_driver_unregister(exynos_drm_drivers[i]);
>>>
>>> -#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>> - platform_driver_unregister(&rotator_driver);
>>> -err_unregister_fimc_drv:
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_FIMC
>>> - platform_driver_unregister(&fimc_driver);
>>> -err_unregister_g2d_drv:
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_G2D
>>> - platform_driver_unregister(&g2d_driver);
>>> -err_unregister_hdmi_drv:
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_HDMI
>>> - platform_driver_unregister(&hdmi_driver);
>>> -err_unregister_mixer_drv:
>>> - platform_driver_unregister(&mixer_driver);
>>> -err_unregister_dsi_drv:
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_DSI
>>> - platform_driver_unregister(&dsi_driver);
>>> -err_unregister_dp_drv:
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_DP
>>> - platform_driver_unregister(&dp_driver);
>>> -err_unregister_fimd_drv:
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_FIMD
>>> - platform_driver_unregister(&fimd_driver);
>>> -#endif
>>> return ret;
>>> }
>>>
>>> static int exynos_drm_platform_remove(struct platform_device *pdev)
>>> {
>>> -#ifdef CONFIG_DRM_EXYNOS_IPP
>>> - exynos_platform_device_ipp_unregister();
>>> - platform_driver_unregister(&ipp_driver);
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_GSC
>>> - platform_driver_unregister(&gsc_driver);
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>> - platform_driver_unregister(&rotator_driver);
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_FIMC
>>> - platform_driver_unregister(&fimc_driver);
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_G2D
>>> - platform_driver_unregister(&g2d_driver);
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_HDMI
>>> - platform_driver_unregister(&mixer_driver);
>>> - platform_driver_unregister(&hdmi_driver);
>>> -#endif
>>> + int i;
>>>
>>> -#ifdef CONFIG_DRM_EXYNOS_FIMD
>>> - platform_driver_unregister(&fimd_driver);
>>> -#endif
>>> + exynos_platform_device_ipp_unregister();
>>>
>>> -#ifdef CONFIG_DRM_EXYNOS_DSI
>>> - platform_driver_unregister(&dsi_driver);
>>> -#endif
>>> + for (i = ARRAY_SIZE(exynos_drm_drivers) - 1; i >= 0; --i)
>>> + platform_driver_unregister(exynos_drm_drivers[i]);
>>>
>>> -#ifdef CONFIG_DRM_EXYNOS_DP
>>> - platform_driver_unregister(&dp_driver);
>>> -#endif
>>> component_master_del(&pdev->dev, &exynos_drm_ops);
>>> return 0;
>>> }
>>> @@ -745,11 +653,9 @@ static int exynos_drm_init(void)
>>> if (IS_ERR(exynos_drm_pdev))
>>> return PTR_ERR(exynos_drm_pdev);
>>>
>>> -#ifdef CONFIG_DRM_EXYNOS_VIDI
>>> ret = exynos_drm_probe_vidi();
>>> if (ret < 0)
>>> goto err_unregister_pd;
>>> -#endif
>>>
>>> ret = platform_driver_register(&exynos_drm_platform_driver);
>>> if (ret)
>>> @@ -758,11 +664,9 @@ static int exynos_drm_init(void)
>>> return 0;
>>>
>>> err_remove_vidi:
>>> -#ifdef CONFIG_DRM_EXYNOS_VIDI
>>> exynos_drm_remove_vidi();
>>>
>>> err_unregister_pd:
>>> -#endif
>>> platform_device_unregister(exynos_drm_pdev);
>>>
>>> return ret;
>>> @@ -771,9 +675,9 @@ err_unregister_pd:
>>> static void exynos_drm_exit(void)
>>> {
>>> platform_driver_unregister(&exynos_drm_platform_driver);
>>> -#ifdef CONFIG_DRM_EXYNOS_VIDI
>>> +
>>> exynos_drm_remove_vidi();
>>> -#endif
>>> +
>>> platform_device_unregister(exynos_drm_pdev);
>>> }
>>>
>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>> index 69a6fa3..76d5d02 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>> @@ -324,15 +324,14 @@ int exynos_platform_device_hdmi_register(void);
>>> */
>>> void exynos_platform_device_hdmi_unregister(void);
>>>
>>> -/*
>>> - * this function registers exynos drm ipp platform device.
>>> - */
>>> +#ifdef CONFIG_DRM_EXYNOS_IPP
>>> int exynos_platform_device_ipp_register(void);
>>> -
>>> -/*
>>> - * this function unregisters exynos drm ipp platform device if it exists.
>>> - */
>>> void exynos_platform_device_ipp_unregister(void);
>>> +#else
>>> +static inline int exynos_platform_device_ipp_register(void) { return 0; }
>>> +static inline void exynos_platform_device_ipp_unregister(void) {}
>>> +#endif
>>> +
>>>
>>> #ifdef CONFIG_DRM_EXYNOS_DPI
>>> struct exynos_drm_display * exynos_dpi_probe(struct device *dev);
>>> @@ -343,15 +342,13 @@ exynos_dpi_probe(struct device *dev) { return NULL; }
>>> static inline int exynos_dpi_remove(struct device *dev) { return 0; }
>>> #endif
>>>
>>> -/*
>>> - * this function registers exynos drm vidi platform device/driver.
>>> - */
>>> +#ifdef CONFIG_DRM_EXYNOS_VIDI
>>> int exynos_drm_probe_vidi(void);
>>> -
>>> -/*
>>> - * this function unregister exynos drm vidi platform device/driver.
>>> - */
>>> void exynos_drm_remove_vidi(void);
>>> +#else
>>> +static inline int exynos_drm_probe_vidi(void) { return 0; }
>>> +static inline void exynos_drm_remove_vidi(void) {}
>>> +#endif
>>>
>>> /* This function creates a encoder and a connector, and initializes them. */
>>> int exynos_drm_create_enc_conn(struct drm_device *dev,
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
On Wed, Oct 1, 2014 at 11:18 AM, Inki Dae <[email protected]> wrote:
> On 2014년 09월 30일 20:29, Andrzej Hajda wrote:
>> Hi Inki,
>>
>> Gently ping.
>
> Hi Andrzej,
>
> I merged it to local repository to test. But now exynos drm doesn't work
> correctly since pulling drm-next of Dave regardless of your patch.
>
> Problems are,
> 1. error occurs when we try to test modetest with -v option from second
> times.
I face a similar issue. For me, modetest -v doesn't work for the first try also.
I tried to test on snow and peach_pit.
modetest returns with following error from drm_crtc.c:
if (crtc->primary->fb->pixel_format != fb->pixel_format) {
DRM_DEBUG_KMS("Page flip is not allowed to change
frame buffer format.\n");
ret = -EINVAL;
goto out;
}
This has started coming since 3.15 I think.
Ajay
> 2. error occurs when we try to test unbind.
>
> Now we are checking these problems. Can you try to also check it?
>
> Thanks,
> Inki Dae
>
>>
>> Andrzej
>>
>> On 09/10/2014 01:53 PM, Andrzej Hajda wrote:
>>> The patch replaces separate calls to driver (de)registration by
>>> loops over the array of drivers. As a result it significantly
>>> decreases number of ifdefs. Additionally it moves device registration
>>> related ifdefs to header file.
>>>
>>> Signed-off-by: Andrzej Hajda <[email protected]>
>>> ---
>>> Hi Inki,
>>>
>>> During testing your component match support patch [1] I have prepared patch
>>> removing most ifdefs from exynos_drm_drv.c. It is based on your patch, but
>>> I can rebase it if necessary.
>>>
>>> [1]: http://permalink.gmane.org/gmane.linux.kernel.samsung-soc/37031
>>>
>>> Regards
>>> Andrzej
>>> ---
>>> drivers/gpu/drm/exynos/exynos_drm_drv.c | 170 +++++++-------------------------
>>> drivers/gpu/drm/exynos/exynos_drm_drv.h | 25 +++--
>>> 2 files changed, 48 insertions(+), 147 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> index b2c710a..a660e46 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> @@ -553,74 +553,54 @@ static const struct component_master_ops exynos_drm_ops = {
>>> .unbind = exynos_drm_unbind,
>>> };
>>>
>>> -static int exynos_drm_platform_probe(struct platform_device *pdev)
>>> -{
>>> - struct component_match *match;
>>> - int ret;
>>> -
>>> - pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
>>> - exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls);
>>> -
>>> +static struct platform_driver * const exynos_drm_drivers[] = {
>>> #ifdef CONFIG_DRM_EXYNOS_FIMD
>>> - ret = platform_driver_register(&fimd_driver);
>>> - if (ret < 0)
>>> - return ret;
>>> + &fimd_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_DP
>>> - ret = platform_driver_register(&dp_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_fimd_drv;
>>> + &dp_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_DSI
>>> - ret = platform_driver_register(&dsi_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_dp_drv;
>>> + &dsi_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_HDMI
>>> - ret = platform_driver_register(&mixer_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_dsi_drv;
>>> - ret = platform_driver_register(&hdmi_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_mixer_drv;
>>> + &mixer_driver,
>>> + &hdmi_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_G2D
>>> - ret = platform_driver_register(&g2d_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_hdmi_drv;
>>> + &g2d_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_FIMC
>>> - ret = platform_driver_register(&fimc_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_g2d_drv;
>>> + &fimc_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>> - ret = platform_driver_register(&rotator_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_fimc_drv;
>>> + &rotator_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_GSC
>>> - ret = platform_driver_register(&gsc_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_rotator_drv;
>>> + &gsc_driver,
>>> #endif
>>> -
>>> #ifdef CONFIG_DRM_EXYNOS_IPP
>>> - ret = platform_driver_register(&ipp_driver);
>>> - if (ret < 0)
>>> - goto err_unregister_gsc_drv;
>>> + &ipp_driver,
>>> +#endif
>>> +};
>>> +
>>> +static int exynos_drm_platform_probe(struct platform_device *pdev)
>>> +{
>>> + struct component_match *match;
>>> + int ret, i;
>>> +
>>> + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
>>> + exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls);
>>> +
>>> + for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
>>> + ret = platform_driver_register(exynos_drm_drivers[i]);
>>> + if (ret < 0)
>>> + goto err_unregister_drivers;
>>> + }
>>>
>>> ret = exynos_platform_device_ipp_register();
>>> if (ret < 0)
>>> - goto err_unregister_ipp_drv;
>>> -#endif
>>> + goto err_unregister_drivers;
>>>
>>> match = exynos_drm_match_add(&pdev->dev);
>>> if (IS_ERR(match)) {
>>> @@ -632,96 +612,24 @@ static int exynos_drm_platform_probe(struct platform_device *pdev)
>>> match);
>>>
>>> err_unregister_ipp_dev:
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_IPP
>>> exynos_platform_device_ipp_unregister();
>>> -err_unregister_ipp_drv:
>>> - platform_driver_unregister(&ipp_driver);
>>> -err_unregister_gsc_drv:
>>> -#endif
>>>
>>> -#ifdef CONFIG_DRM_EXYNOS_GSC
>>> - platform_driver_unregister(&gsc_driver);
>>> -err_unregister_rotator_drv:
>>> -#endif
>>> +err_unregister_drivers:
>>> + while (--i >= 0)
>>> + platform_driver_unregister(exynos_drm_drivers[i]);
>>>
>>> -#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>> - platform_driver_unregister(&rotator_driver);
>>> -err_unregister_fimc_drv:
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_FIMC
>>> - platform_driver_unregister(&fimc_driver);
>>> -err_unregister_g2d_drv:
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_G2D
>>> - platform_driver_unregister(&g2d_driver);
>>> -err_unregister_hdmi_drv:
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_HDMI
>>> - platform_driver_unregister(&hdmi_driver);
>>> -err_unregister_mixer_drv:
>>> - platform_driver_unregister(&mixer_driver);
>>> -err_unregister_dsi_drv:
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_DSI
>>> - platform_driver_unregister(&dsi_driver);
>>> -err_unregister_dp_drv:
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_DP
>>> - platform_driver_unregister(&dp_driver);
>>> -err_unregister_fimd_drv:
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_FIMD
>>> - platform_driver_unregister(&fimd_driver);
>>> -#endif
>>> return ret;
>>> }
>>>
>>> static int exynos_drm_platform_remove(struct platform_device *pdev)
>>> {
>>> -#ifdef CONFIG_DRM_EXYNOS_IPP
>>> - exynos_platform_device_ipp_unregister();
>>> - platform_driver_unregister(&ipp_driver);
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_GSC
>>> - platform_driver_unregister(&gsc_driver);
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>> - platform_driver_unregister(&rotator_driver);
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_FIMC
>>> - platform_driver_unregister(&fimc_driver);
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_G2D
>>> - platform_driver_unregister(&g2d_driver);
>>> -#endif
>>> -
>>> -#ifdef CONFIG_DRM_EXYNOS_HDMI
>>> - platform_driver_unregister(&mixer_driver);
>>> - platform_driver_unregister(&hdmi_driver);
>>> -#endif
>>> + int i;
>>>
>>> -#ifdef CONFIG_DRM_EXYNOS_FIMD
>>> - platform_driver_unregister(&fimd_driver);
>>> -#endif
>>> + exynos_platform_device_ipp_unregister();
>>>
>>> -#ifdef CONFIG_DRM_EXYNOS_DSI
>>> - platform_driver_unregister(&dsi_driver);
>>> -#endif
>>> + for (i = ARRAY_SIZE(exynos_drm_drivers) - 1; i >= 0; --i)
>>> + platform_driver_unregister(exynos_drm_drivers[i]);
>>>
>>> -#ifdef CONFIG_DRM_EXYNOS_DP
>>> - platform_driver_unregister(&dp_driver);
>>> -#endif
>>> component_master_del(&pdev->dev, &exynos_drm_ops);
>>> return 0;
>>> }
>>> @@ -745,11 +653,9 @@ static int exynos_drm_init(void)
>>> if (IS_ERR(exynos_drm_pdev))
>>> return PTR_ERR(exynos_drm_pdev);
>>>
>>> -#ifdef CONFIG_DRM_EXYNOS_VIDI
>>> ret = exynos_drm_probe_vidi();
>>> if (ret < 0)
>>> goto err_unregister_pd;
>>> -#endif
>>>
>>> ret = platform_driver_register(&exynos_drm_platform_driver);
>>> if (ret)
>>> @@ -758,11 +664,9 @@ static int exynos_drm_init(void)
>>> return 0;
>>>
>>> err_remove_vidi:
>>> -#ifdef CONFIG_DRM_EXYNOS_VIDI
>>> exynos_drm_remove_vidi();
>>>
>>> err_unregister_pd:
>>> -#endif
>>> platform_device_unregister(exynos_drm_pdev);
>>>
>>> return ret;
>>> @@ -771,9 +675,9 @@ err_unregister_pd:
>>> static void exynos_drm_exit(void)
>>> {
>>> platform_driver_unregister(&exynos_drm_platform_driver);
>>> -#ifdef CONFIG_DRM_EXYNOS_VIDI
>>> +
>>> exynos_drm_remove_vidi();
>>> -#endif
>>> +
>>> platform_device_unregister(exynos_drm_pdev);
>>> }
>>>
>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>> index 69a6fa3..76d5d02 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>> @@ -324,15 +324,14 @@ int exynos_platform_device_hdmi_register(void);
>>> */
>>> void exynos_platform_device_hdmi_unregister(void);
>>>
>>> -/*
>>> - * this function registers exynos drm ipp platform device.
>>> - */
>>> +#ifdef CONFIG_DRM_EXYNOS_IPP
>>> int exynos_platform_device_ipp_register(void);
>>> -
>>> -/*
>>> - * this function unregisters exynos drm ipp platform device if it exists.
>>> - */
>>> void exynos_platform_device_ipp_unregister(void);
>>> +#else
>>> +static inline int exynos_platform_device_ipp_register(void) { return 0; }
>>> +static inline void exynos_platform_device_ipp_unregister(void) {}
>>> +#endif
>>> +
>>>
>>> #ifdef CONFIG_DRM_EXYNOS_DPI
>>> struct exynos_drm_display * exynos_dpi_probe(struct device *dev);
>>> @@ -343,15 +342,13 @@ exynos_dpi_probe(struct device *dev) { return NULL; }
>>> static inline int exynos_dpi_remove(struct device *dev) { return 0; }
>>> #endif
>>>
>>> -/*
>>> - * this function registers exynos drm vidi platform device/driver.
>>> - */
>>> +#ifdef CONFIG_DRM_EXYNOS_VIDI
>>> int exynos_drm_probe_vidi(void);
>>> -
>>> -/*
>>> - * this function unregister exynos drm vidi platform device/driver.
>>> - */
>>> void exynos_drm_remove_vidi(void);
>>> +#else
>>> +static inline int exynos_drm_probe_vidi(void) { return 0; }
>>> +static inline void exynos_drm_remove_vidi(void) {}
>>> +#endif
>>>
>>> /* This function creates a encoder and a connector, and initializes them. */
>>> int exynos_drm_create_enc_conn(struct drm_device *dev,
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
The patch disables vblanks during dpms off only if pagefilp has
not been finished. It also replaces drm_vblank_off with drm_crtc_vblank_put.
It fixes issue with page_flip ioctl not being able to acquire vblank counter.
Signed-off-by: Andrzej Hajda <[email protected]>
---
Hi Inki,
This is fix (or just workaround) of the problem you have reported.
Please carefully verify it, as I am not familiar with pageflip code.
Regards
Andrzej
---
drivers/gpu/drm/exynos/exynos_drm_crtc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 8e38e9f..57fa94d 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -69,9 +69,10 @@ static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
/* wait for the completion of page flip. */
if (!wait_event_timeout(exynos_crtc->pending_flip_queue,
!atomic_read(&exynos_crtc->pending_flip),
- HZ/20))
+ HZ/20)) {
atomic_set(&exynos_crtc->pending_flip, 0);
- drm_vblank_off(crtc->dev, exynos_crtc->pipe);
+ drm_crtc_vblank_put(crtc);
+ }
}
if (manager->ops->dpms)
--
1.9.1
Hi Andrzej,
On 10/01/2014 05:14 PM, Andrzej Hajda wrote:
> The patch disables vblanks during dpms off only if pagefilp has
> not been finished. It also replaces drm_vblank_off with drm_crtc_vblank_put.
> It fixes issue with page_flip ioctl not being able to acquire vblank counter.
This problem isn't related with pageflip, it just causes from
7ffd7a68511c710b84db3548a1997fd2625f580a commit (drm: Always reject
drm_vblank_get() after drm_vblank_off()).
We need to use drm_vblank_on() as a counterpart to drm_vblank_off()
after the commit .
How about below patch?
>From 6de01473746af225c688ee430123001d57d9af2a Mon Sep 17 00:00:00 2001
From: Joonyoung Shim <[email protected]>
Date: Thu, 2 Oct 2014 17:48:27 +0900
Subject: [PATCH] drm/exynos: use drm_vblank_on()
We need to use drm_vblank_on() as a counterpart to drm_vblank_off()
after the commit 7ffd7a68511c ("drm: Always reject drm_vblank_get()
after drm_vblank_off()"). If not, drm_vblank_get() will be failed
always after drm_vblank_off().
Signed-off-by: Joonyoung Shim <[email protected]>
---
drivers/gpu/drm/exynos/exynos_drm_crtc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 8e38e9f..dfa209a 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -71,7 +71,6 @@ static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
!atomic_read(&exynos_crtc->pending_flip),
HZ/20))
atomic_set(&exynos_crtc->pending_flip, 0);
- drm_vblank_off(crtc->dev, exynos_crtc->pipe);
}
if (manager->ops->dpms)
@@ -90,6 +89,7 @@ static void exynos_drm_crtc_commit(struct drm_crtc *crtc)
struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
struct exynos_drm_manager *manager = exynos_crtc->manager;
+ drm_vblank_on(crtc->dev, exynos_crtc->pipe);
exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
exynos_plane_commit(crtc->primary);
@@ -177,10 +177,12 @@ static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
static void exynos_drm_crtc_disable(struct drm_crtc *crtc)
{
+ struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
struct drm_plane *plane;
int ret;
exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
+ drm_vblank_off(crtc->dev, exynos_crtc->pipe);
drm_for_each_legacy_plane(plane, &crtc->dev->mode_config.plane_list) {
if (plane->crtc != crtc)
--
1.9.1
Thanks.
>
> Signed-off-by: Andrzej Hajda <[email protected]>
> ---
> Hi Inki,
>
> This is fix (or just workaround) of the problem you have reported.
> Please carefully verify it, as I am not familiar with pageflip code.
>
> Regards
> Andrzej
> ---
> drivers/gpu/drm/exynos/exynos_drm_crtc.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> index 8e38e9f..57fa94d 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> @@ -69,9 +69,10 @@ static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
> /* wait for the completion of page flip. */
> if (!wait_event_timeout(exynos_crtc->pending_flip_queue,
> !atomic_read(&exynos_crtc->pending_flip),
> - HZ/20))
> + HZ/20)) {
> atomic_set(&exynos_crtc->pending_flip, 0);
> - drm_vblank_off(crtc->dev, exynos_crtc->pipe);
> + drm_crtc_vblank_put(crtc);
> + }
> }
>
> if (manager->ops->dpms)
>
On 2014년 10월 02일 17:58, Joonyoung Shim wrote:
> Hi Andrzej,
>
> On 10/01/2014 05:14 PM, Andrzej Hajda wrote:
>> The patch disables vblanks during dpms off only if pagefilp has
>> not been finished. It also replaces drm_vblank_off with drm_crtc_vblank_put.
>> It fixes issue with page_flip ioctl not being able to acquire vblank counter.
>
> This problem isn't related with pageflip, it just causes from
> 7ffd7a68511c710b84db3548a1997fd2625f580a commit (drm: Always reject
> drm_vblank_get() after drm_vblank_off()).
>
> We need to use drm_vblank_on() as a counterpart to drm_vblank_off()
> after the commit .
>
> How about below patch?
Thanks you Joonyoung and Andrzej,
drm_vblank_on/off() are legacy api so it would be better to use
drm_vblank_crtc_on/off functions instead.
And drm_vblank_crtc_off() makes sure that the latest vblank frame count
is stored and restored by drm_vblank_crtc_on() again. So my opinion is,
static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
{
[snip]
if (mode > DRM_MODE_DPMS_ON) {
/* wait for the completion of page flip. */
if (!wait_event_timeout(exynos_crtc->pending_flip_queue,
!atomic_read(&exynos_crtc->pending_flip),
HZ/20))
atomic_set(&exynos_crtc->pending_flip, 0);
drm_crtc_vblank_off(crtc); //<- store the latest vblank frame count.
} else {
drm_crtc_vblank_on(crtc); //<- restore the vblank frame count.
}
[snip]
}
Tested and worked well with above patch. How about it?
Thanks,
Inki Dae
>
>>From 6de01473746af225c688ee430123001d57d9af2a Mon Sep 17 00:00:00 2001
> From: Joonyoung Shim <[email protected]>
> Date: Thu, 2 Oct 2014 17:48:27 +0900
> Subject: [PATCH] drm/exynos: use drm_vblank_on()
>
> We need to use drm_vblank_on() as a counterpart to drm_vblank_off()
> after the commit 7ffd7a68511c ("drm: Always reject drm_vblank_get()
> after drm_vblank_off()"). If not, drm_vblank_get() will be failed
> always after drm_vblank_off().
>
> Signed-off-by: Joonyoung Shim <[email protected]>
> ---
> drivers/gpu/drm/exynos/exynos_drm_crtc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> index 8e38e9f..dfa209a 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> @@ -71,7 +71,6 @@ static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
> !atomic_read(&exynos_crtc->pending_flip),
> HZ/20))
> atomic_set(&exynos_crtc->pending_flip, 0);
> - drm_vblank_off(crtc->dev, exynos_crtc->pipe);
> }
>
> if (manager->ops->dpms)
> @@ -90,6 +89,7 @@ static void exynos_drm_crtc_commit(struct drm_crtc *crtc)
> struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
> struct exynos_drm_manager *manager = exynos_crtc->manager;
>
> + drm_vblank_on(crtc->dev, exynos_crtc->pipe);
> exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
>
> exynos_plane_commit(crtc->primary);
> @@ -177,10 +177,12 @@ static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
>
> static void exynos_drm_crtc_disable(struct drm_crtc *crtc)
> {
> + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
> struct drm_plane *plane;
> int ret;
>
> exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
> + drm_vblank_off(crtc->dev, exynos_crtc->pipe);
>
> drm_for_each_legacy_plane(plane, &crtc->dev->mode_config.plane_list) {
> if (plane->crtc != crtc)
>
Hi,
+CC possible victims
On 10/02/2014 12:52 PM, Inki Dae wrote:
> On 2014년 10월 02일 17:58, Joonyoung Shim wrote:
>> Hi Andrzej,
>>
>> On 10/01/2014 05:14 PM, Andrzej Hajda wrote:
>>> The patch disables vblanks during dpms off only if pagefilp has
>>> not been finished. It also replaces drm_vblank_off with drm_crtc_vblank_put.
>>> It fixes issue with page_flip ioctl not being able to acquire vblank counter.
>> This problem isn't related with pageflip, it just causes from
>> 7ffd7a68511c710b84db3548a1997fd2625f580a commit (drm: Always reject
>> drm_vblank_get() after drm_vblank_off()).
>>
>> We need to use drm_vblank_on() as a counterpart to drm_vblank_off()
>> after the commit .
This patch should break also other drivers, it seems at least following
drms could be affected:
armada, sti, tegra.
I guess after disabling and re-enabling crtc vblanks should stop
working, unless there are other bugs.
Regards
Andrzej
On 10/02/2014 08:52 PM, Andrzej Hajda wrote:
> Hi,
>
> +CC possible victims
>
> On 10/02/2014 12:52 PM, Inki Dae wrote:
>> On 2014년 10월 02일 17:58, Joonyoung Shim wrote:
>>> Hi Andrzej,
>>>
>>> On 10/01/2014 05:14 PM, Andrzej Hajda wrote:
>>>> The patch disables vblanks during dpms off only if pagefilp has
>>>> not been finished. It also replaces drm_vblank_off with drm_crtc_vblank_put.
>>>> It fixes issue with page_flip ioctl not being able to acquire vblank counter.
>>> This problem isn't related with pageflip, it just causes from
>>> 7ffd7a68511c710b84db3548a1997fd2625f580a commit (drm: Always reject
>>> drm_vblank_get() after drm_vblank_off()).
>>>
>>> We need to use drm_vblank_on() as a counterpart to drm_vblank_off()
>>> after the commit .
>
> This patch should break also other drivers, it seems at least following
> drms could be affected:
> armada, sti, tegra.
Indeed we (tegra) have just been hit by this. The problem seems to come
from the fact that we have been using drm_vblank_pre_modeset,
drm_vblank_post_modeset and drm_vblank_off conjointly. All these
functions depend on the value of vblank->inmodeset, and 7ffd7a68511
increases the vblank reference counter only in drm_vblank_off, which can
result in the acquired reference never being released.
The following seems to fix this for Tegra, by stopping using
drm_vblank_pre/post_modeset and relying on drm_vblank_off/on instead:
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index b08df07cad47..3955d81236d0 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -739,7 +739,6 @@ static const struct drm_crtc_funcs tegra_crtc_funcs = {
static void tegra_crtc_disable(struct drm_crtc *crtc)
{
- struct tegra_dc *dc = to_tegra_dc(crtc);
struct drm_device *drm = crtc->dev;
struct drm_plane *plane;
@@ -755,7 +754,7 @@ static void tegra_crtc_disable(struct drm_crtc *crtc)
}
}
- drm_vblank_off(drm, dc->pipe);
+ drm_crtc_vblank_off(crtc);
}
static bool tegra_crtc_mode_fixup(struct drm_crtc *crtc,
@@ -844,7 +843,7 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc,
u32 value;
int err;
- drm_vblank_pre_modeset(crtc->dev, dc->pipe);
+ drm_crtc_vblank_off(crtc);
err = tegra_crtc_setup_clk(crtc, mode);
if (err) {
@@ -946,7 +945,7 @@ static void tegra_crtc_commit(struct drm_crtc *crtc)
value = GENERAL_ACT_REQ | WIN_A_ACT_REQ;
tegra_dc_writel(dc, value, DC_CMD_STATE_CONTROL);
- drm_vblank_post_modeset(crtc->dev, dc->pipe);
+ drm_crtc_vblank_on(crtc);
}
static void tegra_crtc_load_lut(struct drm_crtc *crtc)
Thierry, does this look ok to you?
But there might be another issue, which is that calls to
drm_vblank_get() will return -EINVAL if invoked between drm_blank_off
and drm_blank_on. Is this really the desired behavior? Can it at least
happen? If so, how are drivers supposed to react to this situation?
On Thu, Oct 09, 2014 at 02:43:02PM +0900, Alexandre Courbot wrote:
> But there might be another issue, which is that calls to
> drm_vblank_get() will return -EINVAL if invoked between drm_blank_off
> and drm_blank_on. Is this really the desired behavior? Can it at least
> happen? If so, how are drivers supposed to react to this situation?
I've not yet seen the commit which causes this problem, but I hope
that drm_wait_vblank() isn't affected by this. In current mainline,
drm_vblank_get() is used inside drm_wait_vblank(), which is called as
a result of userspace calling DRM_IOCTL_WAIT_VBLANK.
So, what is the effect of this change on user applications making use
of the vblank wait ioctl - and is that change intended?
--
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.
On Thu, Oct 09, 2014 at 09:52:58AM +0100, Russell King - ARM Linux wrote:
> On Thu, Oct 09, 2014 at 02:43:02PM +0900, Alexandre Courbot wrote:
> > But there might be another issue, which is that calls to
> > drm_vblank_get() will return -EINVAL if invoked between drm_blank_off
> > and drm_blank_on. Is this really the desired behavior? Can it at least
> > happen? If so, how are drivers supposed to react to this situation?
>
> I've not yet seen the commit which causes this problem, but I hope
> that drm_wait_vblank() isn't affected by this. In current mainline,
> drm_vblank_get() is used inside drm_wait_vblank(), which is called as
> a result of userspace calling DRM_IOCTL_WAIT_VBLANK.
>
> So, what is the effect of this change on user applications making use
> of the vblank wait ioctl - and is that change intended?
There's no effect on user applications if the driver behaves properly.
As far as I can tell, every driver that calls drm_vblank_off() but not
drm_vblank_on() will break. You can easily test this by running libdrm
modetest -s ... -v, which instead of toggling between the test pattern
and an all-gray framebuffer will switch to the gray one once and then
hang.
I guess that was probably not intended, but according to the new rules
all these drivers have now become buggy. So before merging this patch I
think we need to fix existing drivers to avoid regressions.
Thierry
On Thu, Oct 09, 2014 at 02:43:02PM +0900, Alexandre Courbot wrote:
> On 10/02/2014 08:52 PM, Andrzej Hajda wrote:
> >Hi,
> >
> >+CC possible victims
> >
> >On 10/02/2014 12:52 PM, Inki Dae wrote:
> >>On 2014년 10월 02일 17:58, Joonyoung Shim wrote:
> >>>Hi Andrzej,
> >>>
> >>>On 10/01/2014 05:14 PM, Andrzej Hajda wrote:
> >>>>The patch disables vblanks during dpms off only if pagefilp has
> >>>>not been finished. It also replaces drm_vblank_off with drm_crtc_vblank_put.
> >>>>It fixes issue with page_flip ioctl not being able to acquire vblank counter.
> >>>This problem isn't related with pageflip, it just causes from
> >>>7ffd7a68511c710b84db3548a1997fd2625f580a commit (drm: Always reject
> >>>drm_vblank_get() after drm_vblank_off()).
> >>>
> >>>We need to use drm_vblank_on() as a counterpart to drm_vblank_off()
> >>>after the commit .
> >
> >This patch should break also other drivers, it seems at least following
> >drms could be affected:
> >armada, sti, tegra.
>
> Indeed we (tegra) have just been hit by this. The problem seems to come from
> the fact that we have been using drm_vblank_pre_modeset,
> drm_vblank_post_modeset and drm_vblank_off conjointly. All these functions
> depend on the value of vblank->inmodeset, and 7ffd7a68511 increases the
> vblank reference counter only in drm_vblank_off, which can result in the
> acquired reference never being released.
>
> The following seems to fix this for Tegra, by stopping using
> drm_vblank_pre/post_modeset and relying on drm_vblank_off/on instead:
>
> diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
> index b08df07cad47..3955d81236d0 100644
> --- a/drivers/gpu/drm/tegra/dc.c
> +++ b/drivers/gpu/drm/tegra/dc.c
> @@ -739,7 +739,6 @@ static const struct drm_crtc_funcs tegra_crtc_funcs = {
>
> static void tegra_crtc_disable(struct drm_crtc *crtc)
> {
> - struct tegra_dc *dc = to_tegra_dc(crtc);
> struct drm_device *drm = crtc->dev;
> struct drm_plane *plane;
>
> @@ -755,7 +754,7 @@ static void tegra_crtc_disable(struct drm_crtc *crtc)
> }
> }
>
> - drm_vblank_off(drm, dc->pipe);
> + drm_crtc_vblank_off(crtc);
> }
>
> static bool tegra_crtc_mode_fixup(struct drm_crtc *crtc,
> @@ -844,7 +843,7 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc,
> u32 value;
> int err;
>
> - drm_vblank_pre_modeset(crtc->dev, dc->pipe);
> + drm_crtc_vblank_off(crtc);
>
> err = tegra_crtc_setup_clk(crtc, mode);
> if (err) {
> @@ -946,7 +945,7 @@ static void tegra_crtc_commit(struct drm_crtc *crtc)
> value = GENERAL_ACT_REQ | WIN_A_ACT_REQ;
> tegra_dc_writel(dc, value, DC_CMD_STATE_CONTROL);
>
> - drm_vblank_post_modeset(crtc->dev, dc->pipe);
> + drm_crtc_vblank_on(crtc);
> }
>
> static void tegra_crtc_load_lut(struct drm_crtc *crtc)
>
> Thierry, does this look ok to you?
Yes, that looks like almost the same patch that I sent out yesterday.
The difference is that I didn't replace the drm_vblank_pre_modeset()
call with drm_vblank_off() like you did, but rather just dropped the
former.
I /think/ your version is more correct in that regard.
Thierry
> But there might be another issue, which is that calls to drm_vblank_get()
> will return -EINVAL if invoked between drm_blank_off and drm_blank_on. Is
> this really the desired behavior? Can it at least happen? If so, how are
> drivers supposed to react to this situation?
It shouldn't happen. If drm_vblank_off() and drm_vblank_on() are called
around a modeset they should never conflict with drm_vblank_get(), at
least on Tegra, because the modeset and page-flip IOCTLs will be
serialized.
Thierry
On Thu, Oct 9, 2014 at 7:08 PM, Thierry Reding <[email protected]> wrote:
> On Thu, Oct 09, 2014 at 02:43:02PM +0900, Alexandre Courbot wrote:
>> On 10/02/2014 08:52 PM, Andrzej Hajda wrote:
>> >Hi,
>> >
>> >+CC possible victims
>> >
>> >On 10/02/2014 12:52 PM, Inki Dae wrote:
>> >>On 2014년 10월 02일 17:58, Joonyoung Shim wrote:
>> >>>Hi Andrzej,
>> >>>
>> >>>On 10/01/2014 05:14 PM, Andrzej Hajda wrote:
>> >>>>The patch disables vblanks during dpms off only if pagefilp has
>> >>>>not been finished. It also replaces drm_vblank_off with drm_crtc_vblank_put.
>> >>>>It fixes issue with page_flip ioctl not being able to acquire vblank counter.
>> >>>This problem isn't related with pageflip, it just causes from
>> >>>7ffd7a68511c710b84db3548a1997fd2625f580a commit (drm: Always reject
>> >>>drm_vblank_get() after drm_vblank_off()).
>> >>>
>> >>>We need to use drm_vblank_on() as a counterpart to drm_vblank_off()
>> >>>after the commit .
>> >
>> >This patch should break also other drivers, it seems at least following
>> >drms could be affected:
>> >armada, sti, tegra.
>>
>> Indeed we (tegra) have just been hit by this. The problem seems to come from
>> the fact that we have been using drm_vblank_pre_modeset,
>> drm_vblank_post_modeset and drm_vblank_off conjointly. All these functions
>> depend on the value of vblank->inmodeset, and 7ffd7a68511 increases the
>> vblank reference counter only in drm_vblank_off, which can result in the
>> acquired reference never being released.
>>
>> The following seems to fix this for Tegra, by stopping using
>> drm_vblank_pre/post_modeset and relying on drm_vblank_off/on instead:
>>
>> diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
>> index b08df07cad47..3955d81236d0 100644
>> --- a/drivers/gpu/drm/tegra/dc.c
>> +++ b/drivers/gpu/drm/tegra/dc.c
>> @@ -739,7 +739,6 @@ static const struct drm_crtc_funcs tegra_crtc_funcs = {
>>
>> static void tegra_crtc_disable(struct drm_crtc *crtc)
>> {
>> - struct tegra_dc *dc = to_tegra_dc(crtc);
>> struct drm_device *drm = crtc->dev;
>> struct drm_plane *plane;
>>
>> @@ -755,7 +754,7 @@ static void tegra_crtc_disable(struct drm_crtc *crtc)
>> }
>> }
>>
>> - drm_vblank_off(drm, dc->pipe);
>> + drm_crtc_vblank_off(crtc);
>> }
>>
>> static bool tegra_crtc_mode_fixup(struct drm_crtc *crtc,
>> @@ -844,7 +843,7 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc,
>> u32 value;
>> int err;
>>
>> - drm_vblank_pre_modeset(crtc->dev, dc->pipe);
>> + drm_crtc_vblank_off(crtc);
>>
>> err = tegra_crtc_setup_clk(crtc, mode);
>> if (err) {
>> @@ -946,7 +945,7 @@ static void tegra_crtc_commit(struct drm_crtc *crtc)
>> value = GENERAL_ACT_REQ | WIN_A_ACT_REQ;
>> tegra_dc_writel(dc, value, DC_CMD_STATE_CONTROL);
>>
>> - drm_vblank_post_modeset(crtc->dev, dc->pipe);
>> + drm_crtc_vblank_on(crtc);
>> }
>>
>> static void tegra_crtc_load_lut(struct drm_crtc *crtc)
>>
>> Thierry, does this look ok to you?
>
> Yes, that looks like almost the same patch that I sent out yesterday.
> The difference is that I didn't replace the drm_vblank_pre_modeset()
> call with drm_vblank_off() like you did, but rather just dropped the
> former.
>
> I /think/ your version is more correct in that regard.
Feel free to take that extra line in your patch then. ;)
>
> Thierry
>
>> But there might be another issue, which is that calls to drm_vblank_get()
>> will return -EINVAL if invoked between drm_blank_off and drm_blank_on. Is
>> this really the desired behavior? Can it at least happen? If so, how are
>> drivers supposed to react to this situation?
>
> It shouldn't happen. If drm_vblank_off() and drm_vblank_on() are called
> around a modeset they should never conflict with drm_vblank_get(), at
> least on Tegra, because the modeset and page-flip IOCTLs will be
> serialized.
Ok, that's good. I was just wondering whether this case has been thought of.
Actually, and seeing how drm_vblank_pre/post_modeset() have become
useless (if not harmful), maybe it would be a good idea to come with a
fixup patch that gets rid of them altogether and make their callers
invoke drm_vblank_off/on() instead?
On 10/02/2014 12:52 PM, Inki Dae wrote:
> On 2014년 10월 02일 17:58, Joonyoung Shim wrote:
>> Hi Andrzej,
>>
>> On 10/01/2014 05:14 PM, Andrzej Hajda wrote:
>>> The patch disables vblanks during dpms off only if pagefilp has
>>> not been finished. It also replaces drm_vblank_off with drm_crtc_vblank_put.
>>> It fixes issue with page_flip ioctl not being able to acquire vblank counter.
>> This problem isn't related with pageflip, it just causes from
>> 7ffd7a68511c710b84db3548a1997fd2625f580a commit (drm: Always reject
>> drm_vblank_get() after drm_vblank_off()).
>>
>> We need to use drm_vblank_on() as a counterpart to drm_vblank_off()
>> after the commit .
>>
>> How about below patch?
> Thanks you Joonyoung and Andrzej,
>
> drm_vblank_on/off() are legacy api so it would be better to use
> drm_vblank_crtc_on/off functions instead.
>
> And drm_vblank_crtc_off() makes sure that the latest vblank frame count
> is stored and restored by drm_vblank_crtc_on() again. So my opinion is,
>
> static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
> {
> [snip]
>
> if (mode > DRM_MODE_DPMS_ON) {
> /* wait for the completion of page flip. */
> if (!wait_event_timeout(exynos_crtc->pending_flip_queue,
> !atomic_read(&exynos_crtc->pending_flip),
> HZ/20))
> atomic_set(&exynos_crtc->pending_flip, 0);
> drm_crtc_vblank_off(crtc); //<- store the latest vblank frame count.
> } else {
> drm_crtc_vblank_on(crtc); //<- restore the vblank frame count.
> }
>
> [snip]
> }
>
>
> Tested and worked well with above patch. How about it?
>
>
drm_crtc_vblank_on should be called after dpms on, otherwise it can fail enabling vblank. I have provided
full explanation in my other email [1].
You can modify your patch or just use the one provided in [1].
[1]: http://permalink.gmane.org/gmane.comp.video.dri.devel/116152
Regards
Andrzej
On 2014년 10월 10일 21:39, Andrzej Hajda wrote:
> On 10/02/2014 12:52 PM, Inki Dae wrote:
>> On 2014년 10월 02일 17:58, Joonyoung Shim wrote:
>>> Hi Andrzej,
>>>
>>> On 10/01/2014 05:14 PM, Andrzej Hajda wrote:
>>>> The patch disables vblanks during dpms off only if pagefilp has
>>>> not been finished. It also replaces drm_vblank_off with drm_crtc_vblank_put.
>>>> It fixes issue with page_flip ioctl not being able to acquire vblank counter.
>>> This problem isn't related with pageflip, it just causes from
>>> 7ffd7a68511c710b84db3548a1997fd2625f580a commit (drm: Always reject
>>> drm_vblank_get() after drm_vblank_off()).
>>>
>>> We need to use drm_vblank_on() as a counterpart to drm_vblank_off()
>>> after the commit .
>>>
>>> How about below patch?
>> Thanks you Joonyoung and Andrzej,
>>
>> drm_vblank_on/off() are legacy api so it would be better to use
>> drm_vblank_crtc_on/off functions instead.
>>
>> And drm_vblank_crtc_off() makes sure that the latest vblank frame count
>> is stored and restored by drm_vblank_crtc_on() again. So my opinion is,
>>
>> static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
>> {
>> [snip]
>>
>> if (mode > DRM_MODE_DPMS_ON) {
>> /* wait for the completion of page flip. */
>> if (!wait_event_timeout(exynos_crtc->pending_flip_queue,
>> !atomic_read(&exynos_crtc->pending_flip),
>> HZ/20))
>> atomic_set(&exynos_crtc->pending_flip, 0);
>> drm_crtc_vblank_off(crtc); //<- store the latest vblank frame count.
>> } else {
>> drm_crtc_vblank_on(crtc); //<- restore the vblank frame count.
>> }
>>
>> [snip]
>> }
>>
>>
>> Tested and worked well with above patch. How about it?
>>
>>
>
> drm_crtc_vblank_on should be called after dpms on, otherwise it can fail enabling vblank. I have provided
> full explanation in my other email [1].
> You can modify your patch or just use the one provided in [1].
I will just merge your patch set after review and test. :)
Thanks,
Inki Dae
>
> [1]: http://permalink.gmane.org/gmane.comp.video.dri.devel/116152
>
> Regards
> Andrzej
>
>