stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/dp_mst: Fix the DDC I2C device unregistration of an MST port
@ 2020-06-07 21:25 Imre Deak
  2020-06-07 21:25 ` [PATCH 2/3] drm/dp_mst: Fix the DDC I2C device registration " Imre Deak
  2020-06-09 20:45 ` [Intel-gfx] [PATCH 1/3] drm/dp_mst: Fix the DDC I2C device unregistration " Lisovskiy, Stanislav
  0 siblings, 2 replies; 6+ messages in thread
From: Imre Deak @ 2020-06-07 21:25 UTC (permalink / raw)
  To: intel-gfx; +Cc: dri-devel, stable

The WARN below triggers during the removal of an MST port. The problem
is that the parent device's (the connector's kdev) sysfs directory is
removed recursively when the connector is unregistered (even though the
I2C device holds a reference on the parent device). To fix this set
first the Peer Device Type to none which will remove the I2C device.

Note that atm, inconsistently, the parent of the I2C device is initially set to
the DRM kdev and after a Connection Status Notification the parent may be reset
to be the connector's kdev. This problem is addressed by the next patch.

[ 4462.989299] ------------[ cut here ]------------
[ 4463.014940] sysfs group 'power' not found for kobject 'i2c-24'
[ 4463.034664] WARNING: CPU: 0 PID: 970 at fs/sysfs/group.c:281 sysfs_remove_group+0x71/0x80
[ 4463.044357] Modules linked in: snd_hda_intel i915 drm_kms_helper(O) drm netconsole snd_hda_codec_hdmi mei_hdcp x86_pkg_temp_thermal coretemp crct10dif_pclmul snd_intel_dspcf
g crc32_pclmul snd_hda_codec snd_hwdep ghash_clmulni_intel snd_hda_core asix usbnet kvm_intel mii i2c_algo_bit snd_pcm syscopyarea sysfillrect e1000e sysimgblt fb_sys_fops prim
e_numbers ptp pps_core i2c_i801 r8169 mei_me realtek mei [last unloaded: drm]
[ 4463.044399] CPU: 0 PID: 970 Comm: kworker/0:2 Tainted: G           O      5.7.0+ #172
[ 4463.044402] Hardware name: Intel Corporation Tiger Lake Client Platform/TigerLake U DDR4 SODIMM RVP
[ 4463.044423] Workqueue: events drm_dp_delayed_destroy_work [drm_kms_helper]
[ 4463.044428] RIP: 0010:sysfs_remove_group+0x71/0x80
[ 4463.044431] Code: 48 89 df 5b 5d 41 5c e9 cd b6 ff ff 48 89 df e8 95 b4 ff ff eb cb 49 8b 14 24 48 8b 75 00 48 c7 c7 20 0f 3f 82 e8 9f c5 d7 ff <0f> 0b 5b 5d 41 5c c3 0f 1f
84 00 00 00 00 00 48 85 f6 74 31 41 54
[ 4463.044433] RSP: 0018:ffffc900018bfbf0 EFLAGS: 00010282
[ 4463.044436] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000001
[ 4463.044439] RDX: 0000000080000001 RSI: ffff88849e828f38 RDI: 00000000ffffffff
[ 4463.052970] [drm:drm_atomic_get_plane_state [drm]] Added [PLANE:100:plane 2B] 00000000c2160caa state to 00000000d172564a
[ 4463.070533] RBP: ffffffff820cea20 R08: ffff88847f4b8958 R09: 0000000000000000
[ 4463.070535] R10: 0000000000000000 R11: 0000000000000000 R12: ffff88848a725018
[ 4463.070537] R13: 0000000000000000 R14: ffffffff827090e0 R15: 0000000000000002
[ 4463.070539] FS:  0000000000000000(0000) GS:ffff88849e800000(0000) knlGS:0000000000000000
[ 4463.070541] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 4463.070543] CR2: 00007fdf8a756538 CR3: 0000000489684001 CR4: 0000000000760ef0
[ 4463.070545] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 4463.070547] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 4463.070549] PKRU: 55555554
[ 4463.070551] Call Trace:
[ 4463.070560]  device_del+0x84/0x400
[ 4463.070571]  cdev_device_del+0x10/0x30
[ 4463.070578]  put_i2c_dev+0x69/0x80
[ 4463.070584]  i2cdev_detach_adapter+0x2e/0x60
[ 4463.070591]  notifier_call_chain+0x34/0x90
[ 4463.070599]  blocking_notifier_call_chain+0x3f/0x60
[ 4463.070606]  device_del+0x7c/0x400
[ 4463.087817]  ? lockdep_init_map_waits+0x57/0x210
[ 4463.087825]  device_unregister+0x11/0x60
[ 4463.087829]  i2c_del_adapter+0x249/0x310
[ 4463.087846]  drm_dp_port_set_pdt+0x6b/0x2c0 [drm_kms_helper]
[ 4463.087862]  drm_dp_delayed_destroy_work+0x2af/0x350 [drm_kms_helper]
[ 4463.087876]  process_one_work+0x268/0x600
[ 4463.105438]  ? __schedule+0x30c/0x920
[ 4463.105451]  worker_thread+0x37/0x380
[ 4463.105457]  ? process_one_work+0x600/0x600
[ 4463.105462]  kthread+0x140/0x160
[ 4463.105466]  ? kthread_park+0x80/0x80
[ 4463.105474]  ret_from_fork+0x24/0x50

Cc: <stable@vger.kernel.org>
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 2a309fb2c4cc..02c800b8199f 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -4669,12 +4669,13 @@ static void drm_dp_tx_work(struct work_struct *work)
 static inline void
 drm_dp_delayed_destroy_port(struct drm_dp_mst_port *port)
 {
+	drm_dp_port_set_pdt(port, DP_PEER_DEVICE_NONE, port->mcs);
+
 	if (port->connector) {
 		drm_connector_unregister(port->connector);
 		drm_connector_put(port->connector);
 	}
 
-	drm_dp_port_set_pdt(port, DP_PEER_DEVICE_NONE, port->mcs);
 	drm_dp_mst_put_port_malloc(port);
 }
 
-- 
2.23.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] drm/dp_mst: Fix the DDC I2C device registration of an MST port
  2020-06-07 21:25 [PATCH 1/3] drm/dp_mst: Fix the DDC I2C device unregistration of an MST port Imre Deak
@ 2020-06-07 21:25 ` Imre Deak
  2020-06-10  8:03   ` Lisovskiy, Stanislav
  2020-06-09 20:45 ` [Intel-gfx] [PATCH 1/3] drm/dp_mst: Fix the DDC I2C device unregistration " Lisovskiy, Stanislav
  1 sibling, 1 reply; 6+ messages in thread
From: Imre Deak @ 2020-06-07 21:25 UTC (permalink / raw)
  To: intel-gfx; +Cc: dri-devel, stable

During the initial MST probing an MST port's I2C device will be
registered using the kdev of the DRM device as a parent. Later after MST
Connection Status Notifications this I2C device will be re-registered
with the kdev of the port's connector. This will also move
inconsistently the I2C device's sysfs entry from the DRM device's sysfs
dir to the connector's dir.

Fix the above by keeping the DRM kdev as the parent of the I2C device.

Ideally the connector's kdev would be used as a parent, similarly to
non-MST connectors, however that needs some more refactoring to ensure
the connector's kdev is already available early enough. So keep the
existing (initial) behavior for now.

Cc: <stable@vger.kernel.org>
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 28 +++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 02c800b8199f..083255c33ee0 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -88,8 +88,8 @@ static int drm_dp_send_enum_path_resources(struct drm_dp_mst_topology_mgr *mgr,
 static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr,
 				 u8 *guid);
 
-static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux);
-static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux);
+static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port);
+static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_mst_port *port);
 static void drm_dp_mst_kick_tx(struct drm_dp_mst_topology_mgr *mgr);
 
 #define DBG_PREFIX "[dp_mst]"
@@ -1993,7 +1993,7 @@ drm_dp_port_set_pdt(struct drm_dp_mst_port *port, u8 new_pdt,
 			}
 
 			/* remove i2c over sideband */
-			drm_dp_mst_unregister_i2c_bus(&port->aux);
+			drm_dp_mst_unregister_i2c_bus(port);
 		} else {
 			mutex_lock(&mgr->lock);
 			drm_dp_mst_topology_put_mstb(port->mstb);
@@ -2008,7 +2008,7 @@ drm_dp_port_set_pdt(struct drm_dp_mst_port *port, u8 new_pdt,
 	if (port->pdt != DP_PEER_DEVICE_NONE) {
 		if (drm_dp_mst_is_end_device(port->pdt, port->mcs)) {
 			/* add i2c over sideband */
-			ret = drm_dp_mst_register_i2c_bus(&port->aux);
+			ret = drm_dp_mst_register_i2c_bus(port);
 		} else {
 			lct = drm_dp_calculate_rad(port, rad);
 			mstb = drm_dp_add_mst_branch_device(lct, rad);
@@ -5375,22 +5375,26 @@ static const struct i2c_algorithm drm_dp_mst_i2c_algo = {
 
 /**
  * drm_dp_mst_register_i2c_bus() - register an I2C adapter for I2C-over-AUX
- * @aux: DisplayPort AUX channel
+ * @port: The port to add the I2C bus on
  *
  * Returns 0 on success or a negative error code on failure.
  */
-static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux)
+static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port)
 {
+	struct drm_dp_aux *aux = &port->aux;
+	struct device *parent_dev = port->mgr->dev->dev;
+
 	aux->ddc.algo = &drm_dp_mst_i2c_algo;
 	aux->ddc.algo_data = aux;
 	aux->ddc.retries = 3;
 
 	aux->ddc.class = I2C_CLASS_DDC;
 	aux->ddc.owner = THIS_MODULE;
-	aux->ddc.dev.parent = aux->dev;
-	aux->ddc.dev.of_node = aux->dev->of_node;
+	/* FIXME: set the kdev of the port's connector as parent */
+	aux->ddc.dev.parent = parent_dev;
+	aux->ddc.dev.of_node = parent_dev->of_node;
 
-	strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev),
+	strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(parent_dev),
 		sizeof(aux->ddc.name));
 
 	return i2c_add_adapter(&aux->ddc);
@@ -5398,11 +5402,11 @@ static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux)
 
 /**
  * drm_dp_mst_unregister_i2c_bus() - unregister an I2C-over-AUX adapter
- * @aux: DisplayPort AUX channel
+ * @port: The port to remove the I2C bus from
  */
-static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux)
+static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_mst_port *port)
 {
-	i2c_del_adapter(&aux->ddc);
+	i2c_del_adapter(&port->aux.ddc);
 }
 
 /**
-- 
2.23.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Intel-gfx] [PATCH 1/3] drm/dp_mst: Fix the DDC I2C device unregistration of an MST port
  2020-06-07 21:25 [PATCH 1/3] drm/dp_mst: Fix the DDC I2C device unregistration of an MST port Imre Deak
  2020-06-07 21:25 ` [PATCH 2/3] drm/dp_mst: Fix the DDC I2C device registration " Imre Deak
@ 2020-06-09 20:45 ` Lisovskiy, Stanislav
  1 sibling, 0 replies; 6+ messages in thread
From: Lisovskiy, Stanislav @ 2020-06-09 20:45 UTC (permalink / raw)
  To: Imre Deak; +Cc: intel-gfx, stable, dri-devel

On Mon, Jun 08, 2020 at 12:25:20AM +0300, Imre Deak wrote:
> The WARN below triggers during the removal of an MST port. The problem
> is that the parent device's (the connector's kdev) sysfs directory is
> removed recursively when the connector is unregistered (even though the
> I2C device holds a reference on the parent device). To fix this set
> first the Peer Device Type to none which will remove the I2C device.
> 
> Note that atm, inconsistently, the parent of the I2C device is initially set to
> the DRM kdev and after a Connection Status Notification the parent may be reset
> to be the connector's kdev. This problem is addressed by the next patch.

Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>

> 
> [ 4462.989299] ------------[ cut here ]------------
> [ 4463.014940] sysfs group 'power' not found for kobject 'i2c-24'
> [ 4463.034664] WARNING: CPU: 0 PID: 970 at fs/sysfs/group.c:281 sysfs_remove_group+0x71/0x80
> [ 4463.044357] Modules linked in: snd_hda_intel i915 drm_kms_helper(O) drm netconsole snd_hda_codec_hdmi mei_hdcp x86_pkg_temp_thermal coretemp crct10dif_pclmul snd_intel_dspcf
> g crc32_pclmul snd_hda_codec snd_hwdep ghash_clmulni_intel snd_hda_core asix usbnet kvm_intel mii i2c_algo_bit snd_pcm syscopyarea sysfillrect e1000e sysimgblt fb_sys_fops prim
> e_numbers ptp pps_core i2c_i801 r8169 mei_me realtek mei [last unloaded: drm]
> [ 4463.044399] CPU: 0 PID: 970 Comm: kworker/0:2 Tainted: G           O      5.7.0+ #172
> [ 4463.044402] Hardware name: Intel Corporation Tiger Lake Client Platform/TigerLake U DDR4 SODIMM RVP
> [ 4463.044423] Workqueue: events drm_dp_delayed_destroy_work [drm_kms_helper]
> [ 4463.044428] RIP: 0010:sysfs_remove_group+0x71/0x80
> [ 4463.044431] Code: 48 89 df 5b 5d 41 5c e9 cd b6 ff ff 48 89 df e8 95 b4 ff ff eb cb 49 8b 14 24 48 8b 75 00 48 c7 c7 20 0f 3f 82 e8 9f c5 d7 ff <0f> 0b 5b 5d 41 5c c3 0f 1f
> 84 00 00 00 00 00 48 85 f6 74 31 41 54
> [ 4463.044433] RSP: 0018:ffffc900018bfbf0 EFLAGS: 00010282
> [ 4463.044436] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000001
> [ 4463.044439] RDX: 0000000080000001 RSI: ffff88849e828f38 RDI: 00000000ffffffff
> [ 4463.052970] [drm:drm_atomic_get_plane_state [drm]] Added [PLANE:100:plane 2B] 00000000c2160caa state to 00000000d172564a
> [ 4463.070533] RBP: ffffffff820cea20 R08: ffff88847f4b8958 R09: 0000000000000000
> [ 4463.070535] R10: 0000000000000000 R11: 0000000000000000 R12: ffff88848a725018
> [ 4463.070537] R13: 0000000000000000 R14: ffffffff827090e0 R15: 0000000000000002
> [ 4463.070539] FS:  0000000000000000(0000) GS:ffff88849e800000(0000) knlGS:0000000000000000
> [ 4463.070541] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [ 4463.070543] CR2: 00007fdf8a756538 CR3: 0000000489684001 CR4: 0000000000760ef0
> [ 4463.070545] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> [ 4463.070547] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> [ 4463.070549] PKRU: 55555554
> [ 4463.070551] Call Trace:
> [ 4463.070560]  device_del+0x84/0x400
> [ 4463.070571]  cdev_device_del+0x10/0x30
> [ 4463.070578]  put_i2c_dev+0x69/0x80
> [ 4463.070584]  i2cdev_detach_adapter+0x2e/0x60
> [ 4463.070591]  notifier_call_chain+0x34/0x90
> [ 4463.070599]  blocking_notifier_call_chain+0x3f/0x60
> [ 4463.070606]  device_del+0x7c/0x400
> [ 4463.087817]  ? lockdep_init_map_waits+0x57/0x210
> [ 4463.087825]  device_unregister+0x11/0x60
> [ 4463.087829]  i2c_del_adapter+0x249/0x310
> [ 4463.087846]  drm_dp_port_set_pdt+0x6b/0x2c0 [drm_kms_helper]
> [ 4463.087862]  drm_dp_delayed_destroy_work+0x2af/0x350 [drm_kms_helper]
> [ 4463.087876]  process_one_work+0x268/0x600
> [ 4463.105438]  ? __schedule+0x30c/0x920
> [ 4463.105451]  worker_thread+0x37/0x380
> [ 4463.105457]  ? process_one_work+0x600/0x600
> [ 4463.105462]  kthread+0x140/0x160
> [ 4463.105466]  ? kthread_park+0x80/0x80
> [ 4463.105474]  ret_from_fork+0x24/0x50
> 
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 2a309fb2c4cc..02c800b8199f 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -4669,12 +4669,13 @@ static void drm_dp_tx_work(struct work_struct *work)
>  static inline void
>  drm_dp_delayed_destroy_port(struct drm_dp_mst_port *port)
>  {
> +	drm_dp_port_set_pdt(port, DP_PEER_DEVICE_NONE, port->mcs);
> +
>  	if (port->connector) {
>  		drm_connector_unregister(port->connector);
>  		drm_connector_put(port->connector);
>  	}
>  
> -	drm_dp_port_set_pdt(port, DP_PEER_DEVICE_NONE, port->mcs);
>  	drm_dp_mst_put_port_malloc(port);
>  }
>  
> -- 
> 2.23.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] drm/dp_mst: Fix the DDC I2C device registration of an MST port
  2020-06-07 21:25 ` [PATCH 2/3] drm/dp_mst: Fix the DDC I2C device registration " Imre Deak
@ 2020-06-10  8:03   ` Lisovskiy, Stanislav
  2020-06-10 10:09     ` Imre Deak
  0 siblings, 1 reply; 6+ messages in thread
From: Lisovskiy, Stanislav @ 2020-06-10  8:03 UTC (permalink / raw)
  To: Imre Deak; +Cc: intel-gfx, stable, dri-devel

On Mon, Jun 08, 2020 at 12:25:21AM +0300, Imre Deak wrote:
> During the initial MST probing an MST port's I2C device will be
> registered using the kdev of the DRM device as a parent. Later after MST
> Connection Status Notifications this I2C device will be re-registered
> with the kdev of the port's connector. This will also move
> inconsistently the I2C device's sysfs entry from the DRM device's sysfs
> dir to the connector's dir.
> 
> Fix the above by keeping the DRM kdev as the parent of the I2C device.
> 
> Ideally the connector's kdev would be used as a parent, similarly to
> non-MST connectors, however that needs some more refactoring to ensure
> the connector's kdev is already available early enough. So keep the
> existing (initial) behavior for now.
> 
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 28 +++++++++++++++------------
>  1 file changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 02c800b8199f..083255c33ee0 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -88,8 +88,8 @@ static int drm_dp_send_enum_path_resources(struct drm_dp_mst_topology_mgr *mgr,
>  static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr,
>  				 u8 *guid);
>  
> -static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux);
> -static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux);
> +static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port);
> +static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_mst_port *port);
>  static void drm_dp_mst_kick_tx(struct drm_dp_mst_topology_mgr *mgr);
>  
>  #define DBG_PREFIX "[dp_mst]"
> @@ -1993,7 +1993,7 @@ drm_dp_port_set_pdt(struct drm_dp_mst_port *port, u8 new_pdt,
>  			}
>  
>  			/* remove i2c over sideband */
> -			drm_dp_mst_unregister_i2c_bus(&port->aux);
> +			drm_dp_mst_unregister_i2c_bus(port);
>  		} else {
>  			mutex_lock(&mgr->lock);
>  			drm_dp_mst_topology_put_mstb(port->mstb);
> @@ -2008,7 +2008,7 @@ drm_dp_port_set_pdt(struct drm_dp_mst_port *port, u8 new_pdt,
>  	if (port->pdt != DP_PEER_DEVICE_NONE) {
>  		if (drm_dp_mst_is_end_device(port->pdt, port->mcs)) {
>  			/* add i2c over sideband */
> -			ret = drm_dp_mst_register_i2c_bus(&port->aux);
> +			ret = drm_dp_mst_register_i2c_bus(port);
>  		} else {
>  			lct = drm_dp_calculate_rad(port, rad);
>  			mstb = drm_dp_add_mst_branch_device(lct, rad);
> @@ -5375,22 +5375,26 @@ static const struct i2c_algorithm drm_dp_mst_i2c_algo = {
>  
>  /**
>   * drm_dp_mst_register_i2c_bus() - register an I2C adapter for I2C-over-AUX
> - * @aux: DisplayPort AUX channel
> + * @port: The port to add the I2C bus on
>   *
>   * Returns 0 on success or a negative error code on failure.
>   */
> -static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux)
> +static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port)
>  {
> +	struct drm_dp_aux *aux = &port->aux;
> +	struct device *parent_dev = port->mgr->dev->dev;
> +

So are we sure that this will always give us thr kdev of the drm device?
I mean could there be more complex hierarchy? Just wondering if there is 
a way to get drm device kdev in a more explicit way.
 
>  	aux->ddc.algo = &drm_dp_mst_i2c_algo;
>  	aux->ddc.algo_data = aux;
>  	aux->ddc.retries = 3;
>  
>  	aux->ddc.class = I2C_CLASS_DDC;
>  	aux->ddc.owner = THIS_MODULE;
> -	aux->ddc.dev.parent = aux->dev;
> -	aux->ddc.dev.of_node = aux->dev->of_node;
> +	/* FIXME: set the kdev of the port's connector as parent */
> +	aux->ddc.dev.parent = parent_dev;
> +	aux->ddc.dev.of_node = parent_dev->of_node;
>  
> -	strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev),
> +	strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(parent_dev),
>  		sizeof(aux->ddc.name));
>  
>  	return i2c_add_adapter(&aux->ddc);
> @@ -5398,11 +5402,11 @@ static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux)
>  
>  /**
>   * drm_dp_mst_unregister_i2c_bus() - unregister an I2C-over-AUX adapter
> - * @aux: DisplayPort AUX channel
> + * @port: The port to remove the I2C bus from
>   */
> -static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux)
> +static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_mst_port *port)
>  {
> -	i2c_del_adapter(&aux->ddc);
> +	i2c_del_adapter(&port->aux.ddc);
>  }
>  
>  /**
> -- 
> 2.23.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] drm/dp_mst: Fix the DDC I2C device registration of an MST port
  2020-06-10  8:03   ` Lisovskiy, Stanislav
@ 2020-06-10 10:09     ` Imre Deak
  2020-06-10 10:59       ` Lisovskiy, Stanislav
  0 siblings, 1 reply; 6+ messages in thread
From: Imre Deak @ 2020-06-10 10:09 UTC (permalink / raw)
  To: Lisovskiy, Stanislav; +Cc: intel-gfx, stable, dri-devel

On Wed, Jun 10, 2020 at 11:03:04AM +0300, Lisovskiy, Stanislav wrote:
> On Mon, Jun 08, 2020 at 12:25:21AM +0300, Imre Deak wrote:
> > During the initial MST probing an MST port's I2C device will be
> > registered using the kdev of the DRM device as a parent. Later after MST
> > Connection Status Notifications this I2C device will be re-registered
> > with the kdev of the port's connector. This will also move
> > inconsistently the I2C device's sysfs entry from the DRM device's sysfs
> > dir to the connector's dir.
> > 
> > Fix the above by keeping the DRM kdev as the parent of the I2C device.
> > 
> > Ideally the connector's kdev would be used as a parent, similarly to
> > non-MST connectors, however that needs some more refactoring to ensure
> > the connector's kdev is already available early enough. So keep the
> > existing (initial) behavior for now.
> > 
> > Cc: <stable@vger.kernel.org>
> > Signed-off-by: Imre Deak <imre.deak@intel.com>
> > ---
> >  drivers/gpu/drm/drm_dp_mst_topology.c | 28 +++++++++++++++------------
> >  1 file changed, 16 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> > index 02c800b8199f..083255c33ee0 100644
> > --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> > +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> > @@ -88,8 +88,8 @@ static int drm_dp_send_enum_path_resources(struct drm_dp_mst_topology_mgr *mgr,
> >  static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr,
> >  				 u8 *guid);
> >  
> > -static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux);
> > -static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux);
> > +static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port);
> > +static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_mst_port *port);
> >  static void drm_dp_mst_kick_tx(struct drm_dp_mst_topology_mgr *mgr);
> >  
> >  #define DBG_PREFIX "[dp_mst]"
> > @@ -1993,7 +1993,7 @@ drm_dp_port_set_pdt(struct drm_dp_mst_port *port, u8 new_pdt,
> >  			}
> >  
> >  			/* remove i2c over sideband */
> > -			drm_dp_mst_unregister_i2c_bus(&port->aux);
> > +			drm_dp_mst_unregister_i2c_bus(port);
> >  		} else {
> >  			mutex_lock(&mgr->lock);
> >  			drm_dp_mst_topology_put_mstb(port->mstb);
> > @@ -2008,7 +2008,7 @@ drm_dp_port_set_pdt(struct drm_dp_mst_port *port, u8 new_pdt,
> >  	if (port->pdt != DP_PEER_DEVICE_NONE) {
> >  		if (drm_dp_mst_is_end_device(port->pdt, port->mcs)) {
> >  			/* add i2c over sideband */
> > -			ret = drm_dp_mst_register_i2c_bus(&port->aux);
> > +			ret = drm_dp_mst_register_i2c_bus(port);
> >  		} else {
> >  			lct = drm_dp_calculate_rad(port, rad);
> >  			mstb = drm_dp_add_mst_branch_device(lct, rad);
> > @@ -5375,22 +5375,26 @@ static const struct i2c_algorithm drm_dp_mst_i2c_algo = {
> >  
> >  /**
> >   * drm_dp_mst_register_i2c_bus() - register an I2C adapter for I2C-over-AUX
> > - * @aux: DisplayPort AUX channel
> > + * @port: The port to add the I2C bus on
> >   *
> >   * Returns 0 on success or a negative error code on failure.
> >   */
> > -static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux)
> > +static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port)
> >  {
> > +	struct drm_dp_aux *aux = &port->aux;
> > +	struct device *parent_dev = port->mgr->dev->dev;
> > +
> 
> So are we sure that this will always give us thr kdev of the drm device?
> I mean could there be more complex hierarchy? Just wondering if there is 
> a way to get drm device kdev in a more explicit way.

There is a single mgr per DRM driver (kdev) and port objects created by
a given DRM driver will stay owned by the same DRM driver. So the
kdev->port association is static.

> >  	aux->ddc.algo = &drm_dp_mst_i2c_algo;
> >  	aux->ddc.algo_data = aux;
> >  	aux->ddc.retries = 3;
> >  
> >  	aux->ddc.class = I2C_CLASS_DDC;
> >  	aux->ddc.owner = THIS_MODULE;
> > -	aux->ddc.dev.parent = aux->dev;
> > -	aux->ddc.dev.of_node = aux->dev->of_node;
> > +	/* FIXME: set the kdev of the port's connector as parent */
> > +	aux->ddc.dev.parent = parent_dev;
> > +	aux->ddc.dev.of_node = parent_dev->of_node;
> >  
> > -	strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev),
> > +	strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(parent_dev),
> >  		sizeof(aux->ddc.name));
> >  
> >  	return i2c_add_adapter(&aux->ddc);
> > @@ -5398,11 +5402,11 @@ static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux)
> >  
> >  /**
> >   * drm_dp_mst_unregister_i2c_bus() - unregister an I2C-over-AUX adapter
> > - * @aux: DisplayPort AUX channel
> > + * @port: The port to remove the I2C bus from
> >   */
> > -static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux)
> > +static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_mst_port *port)
> >  {
> > -	i2c_del_adapter(&aux->ddc);
> > +	i2c_del_adapter(&port->aux.ddc);
> >  }
> >  
> >  /**
> > -- 
> > 2.23.1
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] drm/dp_mst: Fix the DDC I2C device registration of an MST port
  2020-06-10 10:09     ` Imre Deak
@ 2020-06-10 10:59       ` Lisovskiy, Stanislav
  0 siblings, 0 replies; 6+ messages in thread
From: Lisovskiy, Stanislav @ 2020-06-10 10:59 UTC (permalink / raw)
  To: Imre Deak; +Cc: intel-gfx, stable, dri-devel

On Wed, Jun 10, 2020 at 01:09:36PM +0300, Imre Deak wrote:
> On Wed, Jun 10, 2020 at 11:03:04AM +0300, Lisovskiy, Stanislav wrote:
> > On Mon, Jun 08, 2020 at 12:25:21AM +0300, Imre Deak wrote:
> > > During the initial MST probing an MST port's I2C device will be
> > > registered using the kdev of the DRM device as a parent. Later after MST
> > > Connection Status Notifications this I2C device will be re-registered
> > > with the kdev of the port's connector. This will also move
> > > inconsistently the I2C device's sysfs entry from the DRM device's sysfs
> > > dir to the connector's dir.
> > > 
> > > Fix the above by keeping the DRM kdev as the parent of the I2C device.
> > > 
> > > Ideally the connector's kdev would be used as a parent, similarly to
> > > non-MST connectors, however that needs some more refactoring to ensure
> > > the connector's kdev is already available early enough. So keep the
> > > existing (initial) behavior for now.
> > > 
> > > Cc: <stable@vger.kernel.org>
> > > Signed-off-by: Imre Deak <imre.deak@intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_dp_mst_topology.c | 28 +++++++++++++++------------
> > >  1 file changed, 16 insertions(+), 12 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> > > index 02c800b8199f..083255c33ee0 100644
> > > --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> > > +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> > > @@ -88,8 +88,8 @@ static int drm_dp_send_enum_path_resources(struct drm_dp_mst_topology_mgr *mgr,
> > >  static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr,
> > >  				 u8 *guid);
> > >  
> > > -static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux);
> > > -static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux);
> > > +static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port);
> > > +static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_mst_port *port);
> > >  static void drm_dp_mst_kick_tx(struct drm_dp_mst_topology_mgr *mgr);
> > >  
> > >  #define DBG_PREFIX "[dp_mst]"
> > > @@ -1993,7 +1993,7 @@ drm_dp_port_set_pdt(struct drm_dp_mst_port *port, u8 new_pdt,
> > >  			}
> > >  
> > >  			/* remove i2c over sideband */
> > > -			drm_dp_mst_unregister_i2c_bus(&port->aux);
> > > +			drm_dp_mst_unregister_i2c_bus(port);
> > >  		} else {
> > >  			mutex_lock(&mgr->lock);
> > >  			drm_dp_mst_topology_put_mstb(port->mstb);
> > > @@ -2008,7 +2008,7 @@ drm_dp_port_set_pdt(struct drm_dp_mst_port *port, u8 new_pdt,
> > >  	if (port->pdt != DP_PEER_DEVICE_NONE) {
> > >  		if (drm_dp_mst_is_end_device(port->pdt, port->mcs)) {
> > >  			/* add i2c over sideband */
> > > -			ret = drm_dp_mst_register_i2c_bus(&port->aux);
> > > +			ret = drm_dp_mst_register_i2c_bus(port);
> > >  		} else {
> > >  			lct = drm_dp_calculate_rad(port, rad);
> > >  			mstb = drm_dp_add_mst_branch_device(lct, rad);
> > > @@ -5375,22 +5375,26 @@ static const struct i2c_algorithm drm_dp_mst_i2c_algo = {
> > >  
> > >  /**
> > >   * drm_dp_mst_register_i2c_bus() - register an I2C adapter for I2C-over-AUX
> > > - * @aux: DisplayPort AUX channel
> > > + * @port: The port to add the I2C bus on
> > >   *
> > >   * Returns 0 on success or a negative error code on failure.
> > >   */
> > > -static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux)
> > > +static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port)
> > >  {
> > > +	struct drm_dp_aux *aux = &port->aux;
> > > +	struct device *parent_dev = port->mgr->dev->dev;
> > > +
> > 
> > So are we sure that this will always give us thr kdev of the drm device?
> > I mean could there be more complex hierarchy? Just wondering if there is 
> > a way to get drm device kdev in a more explicit way.
> 
> There is a single mgr per DRM driver (kdev) and port objects created by
> a given DRM driver will stay owned by the same DRM driver. So the
> kdev->port association is static.

Ok, thanks for clarification. lgtm then.

Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>

> 
> > >  	aux->ddc.algo = &drm_dp_mst_i2c_algo;
> > >  	aux->ddc.algo_data = aux;
> > >  	aux->ddc.retries = 3;
> > >  
> > >  	aux->ddc.class = I2C_CLASS_DDC;
> > >  	aux->ddc.owner = THIS_MODULE;
> > > -	aux->ddc.dev.parent = aux->dev;
> > > -	aux->ddc.dev.of_node = aux->dev->of_node;
> > > +	/* FIXME: set the kdev of the port's connector as parent */
> > > +	aux->ddc.dev.parent = parent_dev;
> > > +	aux->ddc.dev.of_node = parent_dev->of_node;
> > >  
> > > -	strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev),
> > > +	strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(parent_dev),
> > >  		sizeof(aux->ddc.name));
> > >  
> > >  	return i2c_add_adapter(&aux->ddc);
> > > @@ -5398,11 +5402,11 @@ static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux)
> > >  
> > >  /**
> > >   * drm_dp_mst_unregister_i2c_bus() - unregister an I2C-over-AUX adapter
> > > - * @aux: DisplayPort AUX channel
> > > + * @port: The port to remove the I2C bus from
> > >   */
> > > -static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux)
> > > +static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_mst_port *port)
> > >  {
> > > -	i2c_del_adapter(&aux->ddc);
> > > +	i2c_del_adapter(&port->aux.ddc);
> > >  }
> > >  
> > >  /**
> > > -- 
> > > 2.23.1
> > > 
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-10 11:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-07 21:25 [PATCH 1/3] drm/dp_mst: Fix the DDC I2C device unregistration of an MST port Imre Deak
2020-06-07 21:25 ` [PATCH 2/3] drm/dp_mst: Fix the DDC I2C device registration " Imre Deak
2020-06-10  8:03   ` Lisovskiy, Stanislav
2020-06-10 10:09     ` Imre Deak
2020-06-10 10:59       ` Lisovskiy, Stanislav
2020-06-09 20:45 ` [Intel-gfx] [PATCH 1/3] drm/dp_mst: Fix the DDC I2C device unregistration " Lisovskiy, Stanislav

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).