diff mbox

[v8,2/2] drm/dp: Set aux.dev to the drm_connector device, instead of drm_device.

Message ID 1446496428-12135-3-git-send-email-rafael.antognolli@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rafael Antognolli Nov. 2, 2015, 8:33 p.m. UTC
So far, the i915 driver and some other drivers set it to the drm_device,
which doesn't allow one to know which DP a given aux channel is related
to. Changing this to be the drm_connector provides proper nesting, still
allowing one to get the drm_device from it. Some drivers already set it
to the drm_connector.

This also removes the need to add a sysfs link for the i2c device under
the connector, as it will already be there.

Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com>
---
 drivers/gpu/drm/i915/intel_dp.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

Comments

Ville Syrjälä Nov. 24, 2015, 8:31 p.m. UTC | #1
On Mon, Nov 02, 2015 at 12:33:48PM -0800, Rafael Antognolli wrote:
> So far, the i915 driver and some other drivers set it to the drm_device,
> which doesn't allow one to know which DP a given aux channel is related
> to. Changing this to be the drm_connector provides proper nesting, still
> allowing one to get the drm_device from it. Some drivers already set it
> to the drm_connector.
> 
> This also removes the need to add a sysfs link for the i2c device under
> the connector, as it will already be there.
> 
> Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com>

I gave aux_dev a bit of a testing here, and it appaers to work quite
splendidly.

This patch however causes lots of WARN spew if I unload the driver
while in middle of dumping the DPCD via the aux_dev. It appears we
we clean up things the wrong order now.

> ---
>  drivers/gpu/drm/i915/intel_dp.c | 19 ++-----------------
>  1 file changed, 2 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index 8287df4..7aacc08 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -1078,36 +1078,21 @@ intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector *connector)
>  		intel_dp->aux_ch_ctl_reg = intel_dp->output_reg + 0x10;
>  
>  	intel_dp->aux.name = name;
> -	intel_dp->aux.dev = dev->dev;
> +	intel_dp->aux.dev = connector->base.kdev;
>  	intel_dp->aux.transfer = intel_dp_aux_transfer;
>  
>  	DRM_DEBUG_KMS("registering %s bus for %s\n", name,
>  		      connector->base.kdev->kobj.name);
>  
>  	ret = drm_dp_aux_register(&intel_dp->aux);
> -	if (ret < 0) {
> +	if (ret < 0)
>  		DRM_ERROR("drm_dp_aux_register() for %s failed (%d)\n",
>  			  name, ret);
> -		return;
> -	}
> -
> -	ret = sysfs_create_link(&connector->base.kdev->kobj,
> -				&intel_dp->aux.ddc.dev.kobj,
> -				intel_dp->aux.ddc.dev.kobj.name);
> -	if (ret < 0) {
> -		DRM_ERROR("sysfs_create_link() for %s failed (%d)\n", name, ret);
> -		drm_dp_aux_unregister(&intel_dp->aux);
> -	}
>  }
>  
>  static void
>  intel_dp_connector_unregister(struct intel_connector *intel_connector)
>  {
> -	struct intel_dp *intel_dp = intel_attached_dp(&intel_connector->base);
> -
> -	if (!intel_connector->mst_port)
> -		sysfs_remove_link(&intel_connector->base.kdev->kobj,
> -				  intel_dp->aux.ddc.dev.kobj.name);
>  	intel_connector_unregister(intel_connector);
>  }
>  
> -- 
> 2.4.3
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Rafael Antognolli Dec. 2, 2015, 12:37 a.m. UTC | #2
On Tue, Nov 24, 2015 at 10:31:41PM +0200, Ville Syrjälä wrote:
> On Mon, Nov 02, 2015 at 12:33:48PM -0800, Rafael Antognolli wrote:
> > So far, the i915 driver and some other drivers set it to the drm_device,
> > which doesn't allow one to know which DP a given aux channel is related
> > to. Changing this to be the drm_connector provides proper nesting, still
> > allowing one to get the drm_device from it. Some drivers already set it
> > to the drm_connector.
> > 
> > This also removes the need to add a sysfs link for the i2c device under
> > the connector, as it will already be there.
> > 
> > Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com>
> 
> I gave aux_dev a bit of a testing here, and it appaers to work quite
> splendidly.
> 
> This patch however causes lots of WARN spew if I unload the driver
> while in middle of dumping the DPCD via the aux_dev. It appears we
> we clean up things the wrong order now.

It looks like device_destroy is being called twice on the drm_aux_dev
and i2c adapter devices.

If I understood correctly, this is happening because I changed the
parent device, from the drm_device to the drm_connector, but the
drm_connector is being destroyed before the drm_aux_dev and i2c adapter
devices, which already causes them to be destroyed too.

Changing the drm_dp_aux_unregister() from inside intel_dp_aux_fini() to
intel_dp_connector_unregister(), right before
intel_connector_unregister(), seems to fix everything, and it still
makes sense in my opinion, since the auxdev is going to be unregistered
before we destroy the drm_connector. Do you think that would be ok?

> > ---
> >  drivers/gpu/drm/i915/intel_dp.c | 19 ++-----------------
> >  1 file changed, 2 insertions(+), 17 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> > index 8287df4..7aacc08 100644
> > --- a/drivers/gpu/drm/i915/intel_dp.c
> > +++ b/drivers/gpu/drm/i915/intel_dp.c
> > @@ -1078,36 +1078,21 @@ intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector *connector)
> >  		intel_dp->aux_ch_ctl_reg = intel_dp->output_reg + 0x10;
> >  
> >  	intel_dp->aux.name = name;
> > -	intel_dp->aux.dev = dev->dev;
> > +	intel_dp->aux.dev = connector->base.kdev;
> >  	intel_dp->aux.transfer = intel_dp_aux_transfer;
> >  
> >  	DRM_DEBUG_KMS("registering %s bus for %s\n", name,
> >  		      connector->base.kdev->kobj.name);
> >  
> >  	ret = drm_dp_aux_register(&intel_dp->aux);
> > -	if (ret < 0) {
> > +	if (ret < 0)
> >  		DRM_ERROR("drm_dp_aux_register() for %s failed (%d)\n",
> >  			  name, ret);
> > -		return;
> > -	}
> > -
> > -	ret = sysfs_create_link(&connector->base.kdev->kobj,
> > -				&intel_dp->aux.ddc.dev.kobj,
> > -				intel_dp->aux.ddc.dev.kobj.name);
> > -	if (ret < 0) {
> > -		DRM_ERROR("sysfs_create_link() for %s failed (%d)\n", name, ret);
> > -		drm_dp_aux_unregister(&intel_dp->aux);
> > -	}
> >  }
> >  
> >  static void
> >  intel_dp_connector_unregister(struct intel_connector *intel_connector)
> >  {
> > -	struct intel_dp *intel_dp = intel_attached_dp(&intel_connector->base);
> > -
> > -	if (!intel_connector->mst_port)
> > -		sysfs_remove_link(&intel_connector->base.kdev->kobj,
> > -				  intel_dp->aux.ddc.dev.kobj.name);
> >  	intel_connector_unregister(intel_connector);
> >  }
> >  
> > -- 
> > 2.4.3
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Ville Syrjälä
> Intel OTC
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 8287df4..7aacc08 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1078,36 +1078,21 @@  intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector *connector)
 		intel_dp->aux_ch_ctl_reg = intel_dp->output_reg + 0x10;
 
 	intel_dp->aux.name = name;
-	intel_dp->aux.dev = dev->dev;
+	intel_dp->aux.dev = connector->base.kdev;
 	intel_dp->aux.transfer = intel_dp_aux_transfer;
 
 	DRM_DEBUG_KMS("registering %s bus for %s\n", name,
 		      connector->base.kdev->kobj.name);
 
 	ret = drm_dp_aux_register(&intel_dp->aux);
-	if (ret < 0) {
+	if (ret < 0)
 		DRM_ERROR("drm_dp_aux_register() for %s failed (%d)\n",
 			  name, ret);
-		return;
-	}
-
-	ret = sysfs_create_link(&connector->base.kdev->kobj,
-				&intel_dp->aux.ddc.dev.kobj,
-				intel_dp->aux.ddc.dev.kobj.name);
-	if (ret < 0) {
-		DRM_ERROR("sysfs_create_link() for %s failed (%d)\n", name, ret);
-		drm_dp_aux_unregister(&intel_dp->aux);
-	}
 }
 
 static void
 intel_dp_connector_unregister(struct intel_connector *intel_connector)
 {
-	struct intel_dp *intel_dp = intel_attached_dp(&intel_connector->base);
-
-	if (!intel_connector->mst_port)
-		sysfs_remove_link(&intel_connector->base.kdev->kobj,
-				  intel_dp->aux.ddc.dev.kobj.name);
 	intel_connector_unregister(intel_connector);
 }