All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jyri Sarha <jsarha@ti.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: khilman@baylibre.com, dri-devel@lists.freedesktop.org,
	bgolaszewski@baylibre.com, tomi.valkeinen@ti.com
Subject: Re: [PATCHv3 2/4] drm/tilcdc: Stop using struct drm_driver load() callback
Date: Thu, 3 Nov 2016 22:11:26 +0200	[thread overview]
Message-ID: <a6e6e6f8-92af-c38f-2de1-ec28ea66c085@ti.com> (raw)
In-Reply-To: <14637959.KONjiNb2SJ@avalon>

On 11/03/16 20:15, Laurent Pinchart wrote:
> Hi Jyri,
> 
> Thank you for the patch.
> 
> On Wednesday 02 Nov 2016 17:57:50 Jyri Sarha wrote:
>> Stop using struct drm_driver load() and unload() callbacks. The
>> callbacks should not be used anymore. Instead of using load the
>> drm_device is allocated with drm_dev_alloc() and registered with
>> drm_dev_register() only after the driver is completely initialized.
>> The deinitialization is done directly either in component unbind
>> callback or in platform driver demove callback.
>>
>> Signed-off-by: Jyri Sarha <jsarha@ti.com>
>> ---
>>  drivers/gpu/drm/tilcdc/tilcdc_drv.c | 124 ++++++++++++++++++--------------
>>  1 file changed, 70 insertions(+), 54 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
>> b/drivers/gpu/drm/tilcdc/tilcdc_drv.c index 5cf534c..11f3262 100644
>> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
>> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
>> @@ -194,18 +194,22 @@ static int cpufreq_transition(struct notifier_block
>> *nb, * DRM operations:
>>   */
>>
>> -static int tilcdc_unload(struct drm_device *dev)
>> +static void tilcdc_fini(struct drm_device *dev)
>>  {
>>  	struct tilcdc_drm_private *priv = dev->dev_private;
>>
>> -	tilcdc_remove_external_encoders(dev);
>> +	drm_modeset_lock_crtc(priv->crtc, NULL);
>> +	tilcdc_crtc_disable(priv->crtc);
>> +	drm_modeset_unlock_crtc(priv->crtc);
>> +
>> +	drm_dev_unregister(dev);
>>
>> -	drm_fbdev_cma_fini(priv->fbdev);
>>  	drm_kms_helper_poll_fini(dev);
>> +	drm_fbdev_cma_fini(priv->fbdev);
> 
> Is there a need to reorder these ?

I am not sure actually. When the things did not work properly in the
beginning I just ordered unloading to happen strictly in the reverse
order compared to loading. I did not go back to check what changes were
actually needed when I got things working.

> 
>> +	drm_irq_uninstall(dev);
>>  	drm_mode_config_cleanup(dev);
>> -	drm_vblank_cleanup(dev);
>>
>> -	drm_irq_uninstall(dev);
>> +	tilcdc_remove_external_encoders(dev);
>>
>>  #ifdef CONFIG_CPU_FREQ
>>  	cpufreq_unregister_notifier(&priv->freq_transition,
>> @@ -225,28 +229,34 @@ static int tilcdc_unload(struct drm_device *dev)
>>
>>  	pm_runtime_disable(dev->dev);
>>
>> -	return 0;
>> +	drm_dev_unref(dev);
>>  }
>>
>> -static int tilcdc_load(struct drm_device *dev, unsigned long flags)
>> +static int tilcdc_init(struct drm_driver *ddrv, struct device *dev)
>>  {
>> -	struct platform_device *pdev = dev->platformdev;
>> -	struct device_node *node = pdev->dev.of_node;
>> +	struct drm_device *ddev;
>> +	struct platform_device *pdev = to_platform_device(dev);
>> +	struct device_node *node = dev->of_node;
>>  	struct tilcdc_drm_private *priv;
>>  	struct resource *res;
>>  	u32 bpp = 0;
>>  	int ret;
>>
>> -	priv = devm_kzalloc(dev->dev, sizeof(*priv), GFP_KERNEL);
>> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>>  	if (!priv) {
>> -		dev_err(dev->dev, "failed to allocate private data\n");
>> +		dev_err(dev, "failed to allocate private data\n");
>>  		return -ENOMEM;
>>  	}
>>
>> -	dev->dev_private = priv;
>> +	ddev = drm_dev_alloc(ddrv, dev);
> 
> As a follow-up patch you might want to move tilcdc_driver above this function 
> and use it directly to remove the ddrv argument.
> 

Ok, thanks.

> Apart from that,
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
>> +	if (IS_ERR(ddev))
>> +		return PTR_ERR(ddev);
>> +
>> +	ddev->platformdev = pdev;
>> +	ddev->dev_private = priv;
> 
> [snip]
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2016-11-03 20:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-02 15:57 [PATCHv3 0/4] drm/tilcdc: Cleanup tilcdc init sequence Jyri Sarha
2016-11-02 15:57 ` [PATCHv3 1/4] drm/tilcdc: Remove obsolete drm_connector_register() calls Jyri Sarha
2016-11-02 15:57 ` [PATCHv3 2/4] drm/tilcdc: Stop using struct drm_driver load() callback Jyri Sarha
2016-11-03 18:15   ` Laurent Pinchart
2016-11-03 20:11     ` Jyri Sarha [this message]
2016-11-02 15:57 ` [PATCHv3 3/4] drm/tilcdc: Use unload to handle initialization failures Jyri Sarha
2016-11-18 16:57   ` Bartosz Golaszewski
2016-11-21 10:24     ` Jyri Sarha
2016-11-21 10:44       ` Bartosz Golaszewski
2016-11-02 15:57 ` [PATCHv3 4/4] drm/tilcdc: Fix race from forced shutdown of crtc in unload Jyri Sarha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a6e6e6f8-92af-c38f-2de1-ec28ea66c085@ti.com \
    --to=jsarha@ti.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=khilman@baylibre.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.