* [PATCH] drm: platform: Don't initialize driver-private data
@ 2012-10-15 18:03 Thierry Reding
2012-10-26 14:06 ` Laurent Pinchart
0 siblings, 1 reply; 5+ messages in thread
From: Thierry Reding @ 2012-10-15 18:03 UTC (permalink / raw)
To: David Airlie; +Cc: Laurent Pinchart, dri-devel, linux-kernel
Platform device drivers usually use the driver-private data for their
own purposes. Having it overwritten by drm_platform_init() is confusing
and error-prone.
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
---
Note that I don't have any hardware to test the shmobile changes on so
it would be good to get a Tested-by for that.
drivers/gpu/drm/drm_platform.c | 1 -
drivers/gpu/drm/shmobile/shmob_drm_drv.c | 12 +++++-------
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index aaeb6f8..b8a282e 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -64,7 +64,6 @@ int drm_get_platform_dev(struct platform_device *platdev,
}
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
- dev_set_drvdata(&platdev->dev, dev);
ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
if (ret)
goto err_g1;
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index c71d493..1c350fc 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -201,6 +201,8 @@ static int shmob_drm_load(struct drm_device *dev, unsigned long flags)
goto done;
}
+ platform_set_drvdata(pdev, sdev);
+
done:
if (ret)
shmob_drm_unload(dev);
@@ -299,11 +301,9 @@ static struct drm_driver shmob_drm_driver = {
#if CONFIG_PM_SLEEP
static int shmob_drm_pm_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct drm_device *ddev = platform_get_drvdata(pdev);
- struct shmob_drm_device *sdev = ddev->dev_private;
+ struct shmob_drm_device *sdev = dev_get_drvdata(dev);
- drm_kms_helper_poll_disable(ddev);
+ drm_kms_helper_poll_disable(sdev->ddev);
shmob_drm_crtc_suspend(&sdev->crtc);
return 0;
@@ -311,9 +311,7 @@ static int shmob_drm_pm_suspend(struct device *dev)
static int shmob_drm_pm_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct drm_device *ddev = platform_get_drvdata(pdev);
- struct shmob_drm_device *sdev = ddev->dev_private;
+ struct shmob_drm_device *sdev = dev_get_drvdata(dev);
mutex_lock(&sdev->ddev->mode_config.mutex);
shmob_drm_crtc_resume(&sdev->crtc);
--
1.7.12.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm: platform: Don't initialize driver-private data
2012-10-15 18:03 [PATCH] drm: platform: Don't initialize driver-private data Thierry Reding
@ 2012-10-26 14:06 ` Laurent Pinchart
2012-10-31 8:26 ` Thierry Reding
0 siblings, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2012-10-26 14:06 UTC (permalink / raw)
To: Thierry Reding; +Cc: David Airlie, dri-devel, linux-kernel
Hi Thierry,
Thank you for the patch, and sorry for the late reply.
On Monday 15 October 2012 20:03:42 Thierry Reding wrote:
> Platform device drivers usually use the driver-private data for their
> own purposes. Having it overwritten by drm_platform_init() is confusing
> and error-prone.
If you want to push drivers that way, you should get rid of the
pci_set_drvdata() call in core DRM as well. This would push device driver data
handling down to all drivers, so I'm not convinced it would actually make
things simpler.
> Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
But I'm not convinced by the patch, as explained above.
> ---
> Note that I don't have any hardware to test the shmobile changes on so
> it would be good to get a Tested-by for that.
>
> drivers/gpu/drm/drm_platform.c | 1 -
> drivers/gpu/drm/shmobile/shmob_drm_drv.c | 12 +++++-------
> 2 files changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
> index aaeb6f8..b8a282e 100644
> --- a/drivers/gpu/drm/drm_platform.c
> +++ b/drivers/gpu/drm/drm_platform.c
> @@ -64,7 +64,6 @@ int drm_get_platform_dev(struct platform_device *platdev,
> }
>
> if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> - dev_set_drvdata(&platdev->dev, dev);
> ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
> if (ret)
> goto err_g1;
> diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> b/drivers/gpu/drm/shmobile/shmob_drm_drv.c index c71d493..1c350fc 100644
> --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> @@ -201,6 +201,8 @@ static int shmob_drm_load(struct drm_device *dev,
> unsigned long flags) goto done;
> }
>
> + platform_set_drvdata(pdev, sdev);
> +
> done:
> if (ret)
> shmob_drm_unload(dev);
> @@ -299,11 +301,9 @@ static struct drm_driver shmob_drm_driver = {
> #if CONFIG_PM_SLEEP
> static int shmob_drm_pm_suspend(struct device *dev)
> {
> - struct platform_device *pdev = to_platform_device(dev);
> - struct drm_device *ddev = platform_get_drvdata(pdev);
> - struct shmob_drm_device *sdev = ddev->dev_private;
> + struct shmob_drm_device *sdev = dev_get_drvdata(dev);
>
> - drm_kms_helper_poll_disable(ddev);
> + drm_kms_helper_poll_disable(sdev->ddev);
> shmob_drm_crtc_suspend(&sdev->crtc);
>
> return 0;
> @@ -311,9 +311,7 @@ static int shmob_drm_pm_suspend(struct device *dev)
>
> static int shmob_drm_pm_resume(struct device *dev)
> {
> - struct platform_device *pdev = to_platform_device(dev);
> - struct drm_device *ddev = platform_get_drvdata(pdev);
> - struct shmob_drm_device *sdev = ddev->dev_private;
> + struct shmob_drm_device *sdev = dev_get_drvdata(dev);
>
> mutex_lock(&sdev->ddev->mode_config.mutex);
> shmob_drm_crtc_resume(&sdev->crtc);
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm: platform: Don't initialize driver-private data
2012-10-26 14:06 ` Laurent Pinchart
@ 2012-10-31 8:26 ` Thierry Reding
2012-10-31 8:31 ` Laurent Pinchart
0 siblings, 1 reply; 5+ messages in thread
From: Thierry Reding @ 2012-10-31 8:26 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: David Airlie, dri-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1486 bytes --]
On Fri, Oct 26, 2012 at 04:06:27PM +0200, Laurent Pinchart wrote:
> Hi Thierry,
>
> Thank you for the patch, and sorry for the late reply.
>
> On Monday 15 October 2012 20:03:42 Thierry Reding wrote:
> > Platform device drivers usually use the driver-private data for their
> > own purposes. Having it overwritten by drm_platform_init() is confusing
> > and error-prone.
>
> If you want to push drivers that way, you should get rid of the
> pci_set_drvdata() call in core DRM as well. This would push device driver data
> handling down to all drivers, so I'm not convinced it would actually make
> things simpler.
I think the problem doesn't exist for PCI-based DRM drivers, so I didn't
look at it. The issue only arises once the DRM needs to glue together
multiple devices, as is usual with the drivers for embedded devices,
where the drivers are based on platform devices.
I agree, though, that for consistency it would be nicer not to do this
for the PCI-based DRM drivers either. If David agrees I can take a look
at converting the other drivers along with the change to the DRM core.
Pushing the handling of the driver-private data down to the drivers may
not make things easier, but at least it would be consistent with other
drivers. I didn't mention this in the patch description but it actually
took me a day to track down why the driver kept crashing until I figured
out that drm_platform_init() actually modified the pointer.
Thierry
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm: platform: Don't initialize driver-private data
2012-10-31 8:26 ` Thierry Reding
@ 2012-10-31 8:31 ` Laurent Pinchart
2012-10-31 8:50 ` Thierry Reding
0 siblings, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2012-10-31 8:31 UTC (permalink / raw)
To: Thierry Reding; +Cc: David Airlie, dri-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1650 bytes --]
Hi Thierry,
On Wednesday 31 October 2012 09:26:07 Thierry Reding wrote:
> On Fri, Oct 26, 2012 at 04:06:27PM +0200, Laurent Pinchart wrote:
> > On Monday 15 October 2012 20:03:42 Thierry Reding wrote:
> > > Platform device drivers usually use the driver-private data for their
> > > own purposes. Having it overwritten by drm_platform_init() is confusing
> > > and error-prone.
> >
> > If you want to push drivers that way, you should get rid of the
> > pci_set_drvdata() call in core DRM as well. This would push device driver
> > data handling down to all drivers, so I'm not convinced it would actually
> > make things simpler.
>
> I think the problem doesn't exist for PCI-based DRM drivers, so I didn't
> look at it. The issue only arises once the DRM needs to glue together
> multiple devices, as is usual with the drivers for embedded devices,
> where the drivers are based on platform devices.
>
> I agree, though, that for consistency it would be nicer not to do this
> for the PCI-based DRM drivers either. If David agrees I can take a look
> at converting the other drivers along with the change to the DRM core.
>
> Pushing the handling of the driver-private data down to the drivers may
> not make things easier, but at least it would be consistent with other
> drivers. I didn't mention this in the patch description but it actually
> took me a day to track down why the driver kept crashing until I figured
> out that drm_platform_init() actually modified the pointer.
So we either need your patch, or a documentation update :-)
The patch itself is fine, I'll let others comment on the approach.
--
Regards,
Laurent Pinchart
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm: platform: Don't initialize driver-private data
2012-10-31 8:31 ` Laurent Pinchart
@ 2012-10-31 8:50 ` Thierry Reding
0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2012-10-31 8:50 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: David Airlie, dri-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2045 bytes --]
On Wed, Oct 31, 2012 at 09:31:27AM +0100, Laurent Pinchart wrote:
> Hi Thierry,
>
> On Wednesday 31 October 2012 09:26:07 Thierry Reding wrote:
> > On Fri, Oct 26, 2012 at 04:06:27PM +0200, Laurent Pinchart wrote:
> > > On Monday 15 October 2012 20:03:42 Thierry Reding wrote:
> > > > Platform device drivers usually use the driver-private data for their
> > > > own purposes. Having it overwritten by drm_platform_init() is confusing
> > > > and error-prone.
> > >
> > > If you want to push drivers that way, you should get rid of the
> > > pci_set_drvdata() call in core DRM as well. This would push device driver
> > > data handling down to all drivers, so I'm not convinced it would actually
> > > make things simpler.
> >
> > I think the problem doesn't exist for PCI-based DRM drivers, so I didn't
> > look at it. The issue only arises once the DRM needs to glue together
> > multiple devices, as is usual with the drivers for embedded devices,
> > where the drivers are based on platform devices.
> >
> > I agree, though, that for consistency it would be nicer not to do this
> > for the PCI-based DRM drivers either. If David agrees I can take a look
> > at converting the other drivers along with the change to the DRM core.
> >
> > Pushing the handling of the driver-private data down to the drivers may
> > not make things easier, but at least it would be consistent with other
> > drivers. I didn't mention this in the patch description but it actually
> > took me a day to track down why the driver kept crashing until I figured
> > out that drm_platform_init() actually modified the pointer.
>
> So we either need your patch, or a documentation update :-)
>
> The patch itself is fine, I'll let others comment on the approach.
The patch already went in through David's tree, so I guess that says
much about his opinion on the matter. =) Still I think there's some
value in making this consistent across all drivers and if everybody
agrees I'll volunteer to write the patch.
Thierry
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-10-31 8:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-15 18:03 [PATCH] drm: platform: Don't initialize driver-private data Thierry Reding
2012-10-26 14:06 ` Laurent Pinchart
2012-10-31 8:26 ` Thierry Reding
2012-10-31 8:31 ` Laurent Pinchart
2012-10-31 8:50 ` Thierry Reding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).