linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	"Bryan O'Donoghue" <bryan.odonoghue@linaro.org>,
	Guenter Roeck <linux@roeck-us.net>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Janne Grunau <j@jannau.net>, Simon Ser <contact@emersion.fr>,
	Andy Gross <agross@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	freedreno@lists.freedesktop.org, Won Chung <wonchung@google.com>
Subject: [RFC PATCH v1 01/12] Revert "drm/sysfs: Link DRM connectors to corresponding Type-C connectors"
Date: Mon,  4 Sep 2023 00:41:39 +0300	[thread overview]
Message-ID: <20230903214150.2877023-2-dmitry.baryshkov@linaro.org> (raw)
In-Reply-To: <20230903214150.2877023-1-dmitry.baryshkov@linaro.org>

The kdev->fwnode pointer is never set in drm_sysfs_connector_add(), so
dev_fwnode() checks never succeed, making the respective commit NOP.

And if drm_sysfs_connector_add() is modified to set kdev->fwnode, it
breaks drivers already using components (as it was pointed at [1]),
resulting in a deadlock. Lockdep trace is provided below.

Granted these two issues, it seems impractical to fix this commit in any
sane way. Revert it instead.

[1] https://lore.kernel.org/dri-devel/Y24bcYJKGy%2Fgd5fV@phenom.ffwll.local/

============================================
WARNING: possible recursive locking detected
6.5.0-rc6-next-20230816-10542-g090e2ca9feae-dirty #713 Tainted: G        W
--------------------------------------------
kworker/u16:0/11 is trying to acquire lock:
ffffce0f54bea490 (component_mutex){+.+.}-{3:3}, at: __component_add+0x64/0x170

but task is already holding lock:
ffffce0f54bea490 (component_mutex){+.+.}-{3:3}, at: __component_add+0x64/0x170

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(component_mutex);
  lock(component_mutex);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

6 locks held by kworker/u16:0/11:
 #0: ffff5b7680008d38 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work+0x14c/0x51c
 #1: ffff8000800abde0 (deferred_probe_work){+.+.}-{0:0}, at: process_one_work+0x14c/0x51c
 #2: ffff5b76837a2908 (&dev->mutex){....}-{3:3}, at: __device_attach+0x38/0x188
 #3: ffffce0f54bea490 (component_mutex){+.+.}-{3:3}, at: __component_add+0x64/0x170
 #4: ffffce0f54bdeb40 (drm_connector_list_iter){.+.+}-{0:0}, at: drm_modeset_register_all+0x80/0x9c
 #5: ffff5b76866ad0d0 (&connector->mutex){+.+.}-{3:3}, at: drm_connector_register.part.0+0x28/0x104

stack backtrace:
CPU: 6 PID: 11 Comm: kworker/u16:0 Tainted: G        W          6.5.0-rc6-next-20230816-10542-g090e2ca9feae-dirty #713
Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
Workqueue: events_unbound deferred_probe_work_func
Call trace:
 dump_backtrace+0x98/0xf0
 show_stack+0x18/0x24
 dump_stack_lvl+0x60/0xac
 dump_stack+0x18/0x24
 print_deadlock_bug+0x254/0x340
 __lock_acquire+0x105c/0x1ebc
 lock_acquire+0x1ec/0x314
 __lock_acquire+0x105c/0x1ebc
 lock_acquire+0x1ec/0x314
 __mutex_lock+0xa0/0x77c
 mutex_lock_nested+0x24/0x30
 __component_add+0x64/0x170
 component_add+0x14/0x20
 drm_sysfs_connector_add+0x144/0x1a0
 drm_connector_register.part.0+0x5c/0x104
 drm_connector_register_all+0x84/0x160
 drm_modeset_register_all+0x80/0x9c
 drm_dev_register+0x120/0x238
 msm_drm_bind+0x550/0x6e0
 try_to_bring_up_aggregate_device+0x164/0x1d0
 __component_add+0xa8/0x170
 component_add+0x14/0x20
 dsi_dev_attach+0x20/0x2c
 dsi_host_attach+0x9c/0x144
 devm_mipi_dsi_attach+0x34/0xb4
 lt9611uxc_attach_dsi.isra.0+0x84/0xfc
 lt9611uxc_probe+0x5ac/0x66c
 i2c_device_probe+0x148/0x290
 really_probe+0x148/0x2ac
 __driver_probe_device+0x78/0x12c
 driver_probe_device+0x3c/0x160
 __device_attach_driver+0xb8/0x138
 bus_for_each_drv+0x80/0xdc
 __device_attach+0x9c/0x188
 device_initial_probe+0x14/0x20
 bus_probe_device+0xac/0xb0
 deferred_probe_work_func+0x8c/0xc8
 process_one_work+0x1ec/0x51c
 worker_thread+0x1ec/0x3e4
 kthread+0x120/0x124
 ret_from_fork+0x10/0x20

Fixes: c5c51b242062 ("drm/sysfs: Link DRM connectors to corresponding Type-C connectors")
Cc: Won Chung <wonchung@google.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/gpu/drm/drm_sysfs.c | 40 -------------------------------------
 1 file changed, 40 deletions(-)

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index b169b3e44a92..06662cc8d3f4 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -11,14 +11,12 @@
  */
 
 #include <linux/acpi.h>
-#include <linux/component.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/export.h>
 #include <linux/gfp.h>
 #include <linux/i2c.h>
 #include <linux/kdev_t.h>
-#include <linux/property.h>
 #include <linux/slab.h>
 
 #include <drm/drm_accel.h>
@@ -98,34 +96,6 @@ static char *drm_devnode(const struct device *dev, umode_t *mode)
 	return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev));
 }
 
-static int typec_connector_bind(struct device *dev,
-				struct device *typec_connector, void *data)
-{
-	int ret;
-
-	ret = sysfs_create_link(&dev->kobj, &typec_connector->kobj, "typec_connector");
-	if (ret)
-		return ret;
-
-	ret = sysfs_create_link(&typec_connector->kobj, &dev->kobj, "drm_connector");
-	if (ret)
-		sysfs_remove_link(&dev->kobj, "typec_connector");
-
-	return ret;
-}
-
-static void typec_connector_unbind(struct device *dev,
-				   struct device *typec_connector, void *data)
-{
-	sysfs_remove_link(&typec_connector->kobj, "drm_connector");
-	sysfs_remove_link(&dev->kobj, "typec_connector");
-}
-
-static const struct component_ops typec_connector_ops = {
-	.bind = typec_connector_bind,
-	.unbind = typec_connector_unbind,
-};
-
 static CLASS_ATTR_STRING(version, S_IRUGO, "drm 1.1.0 20060810");
 
 /**
@@ -394,16 +364,9 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
 
 	connector->kdev = kdev;
 
-	if (dev_fwnode(kdev)) {
-		r = component_add(kdev, &typec_connector_ops);
-		if (r)
-			drm_err(dev, "failed to add component to create link to typec connector\n");
-	}
-
 	if (connector->ddc)
 		return sysfs_create_link(&connector->kdev->kobj,
 				 &connector->ddc->dev.kobj, "ddc");
-
 	return 0;
 
 err_free:
@@ -419,9 +382,6 @@ void drm_sysfs_connector_remove(struct drm_connector *connector)
 	if (connector->ddc)
 		sysfs_remove_link(&connector->kdev->kobj, "ddc");
 
-	if (dev_fwnode(connector->kdev))
-		component_del(connector->kdev, &typec_connector_ops);
-
 	DRM_DEBUG("removing \"%s\" from sysfs\n",
 		  connector->name);
 
-- 
2.39.2


  reply	other threads:[~2023-09-03 21:41 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-03 21:41 [RFC PATCH v1 00/12] drm,usb/typec: uABI for USB-C DisplayPort connectors Dmitry Baryshkov
2023-09-03 21:41 ` Dmitry Baryshkov [this message]
2023-09-05  8:49   ` [RFC PATCH v1 01/12] Revert "drm/sysfs: Link DRM connectors to corresponding Type-C connectors" Heikki Krogerus
2023-09-05 10:56     ` Dmitry Baryshkov
2023-09-06 12:44       ` Heikki Krogerus
2023-09-06 12:48         ` Dmitry Baryshkov
2023-09-06 12:53           ` Laurent Pinchart
2023-09-06 14:32             ` Maxime Ripard
2023-09-06 13:38           ` Heikki Krogerus
2023-09-11 21:15             ` Dmitry Baryshkov
2023-09-12 11:05               ` Heikki Krogerus
2023-09-12 17:39                 ` Dmitry Baryshkov
2023-09-13  9:27                   ` Heikki Krogerus
2023-09-13 10:26                     ` Dmitry Baryshkov
2023-09-13 13:14                       ` Heikki Krogerus
2023-09-13 13:47                         ` Dmitry Baryshkov
2023-09-14  9:26                           ` Heikki Krogerus
2023-09-14  9:35                             ` Neil Armstrong
2023-09-14 10:16                               ` Dmitry Baryshkov
2023-09-14 10:40                             ` Dmitry Baryshkov
2023-09-14 14:55                               ` Heikki Krogerus
2023-09-13  9:38                   ` Neil Armstrong
2023-09-13 10:34                     ` Heikki Krogerus
2023-09-13  3:00               ` [Freedreno] " Rob Clark
2023-09-03 21:41 ` [RFC PATCH v1 02/12] drm/sysfs: link DRM connector device to the connector's fw nodes Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 03/12] drm/connector: extend PATH property to covert Type-C case Dmitry Baryshkov
2023-10-03  9:15   ` Simon Ser
2023-09-03 21:41 ` [RFC PATCH v1 04/12] drm/bridge-connector: set the PATH property for the connector Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 05/12] drm/bridge: remove conditionals around devicetree pointers Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 06/12] soc: qcom: pmic_glink_altmode: fix DRM connector type Dmitry Baryshkov
2023-09-04 15:42   ` Bjorn Andersson
2023-09-03 21:41 ` [RFC PATCH v1 07/12] soc: qcom: pmic_glink_altmode: report that this is a Type-C connector Dmitry Baryshkov
2023-09-04 15:43   ` Bjorn Andersson
2023-09-04 15:45     ` Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 08/12] usb: typec: support generating Type-C port names for userspace Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 09/12] usb: typec: tcpm: " Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 10/12] usb: typec: qcom: implement proper error path in probe() Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 11/12] usb: typec: qcom: extract DRM bridge functionality to separate file Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 12/12] usb: typec: qcom: define the bridge's path Dmitry Baryshkov
2023-09-15 12:14   ` Heikki Krogerus
2023-10-23 18:24     ` Dmitry Baryshkov
2023-10-30  8:19       ` Heikki Krogerus
2023-10-30  9:47         ` Dmitry Baryshkov
2023-10-30 10:13           ` Simon Ser
2023-10-30 10:22             ` Dmitry Baryshkov
2023-10-30 10:26               ` Simon Ser
2023-10-30 12:12                 ` Dmitry Baryshkov
2023-09-04 15:46 ` [RFC PATCH v1 00/12] drm,usb/typec: uABI for USB-C DisplayPort connectors Bjorn Andersson
2023-09-04 15:49   ` Dmitry Baryshkov

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=20230903214150.2877023-2-dmitry.baryshkov@linaro.org \
    --to=dmitry.baryshkov@linaro.org \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=agross@kernel.org \
    --cc=airlied@gmail.com \
    --cc=andersson@kernel.org \
    --cc=andrzej.hajda@intel.com \
    --cc=bryan.odonoghue@linaro.org \
    --cc=contact@emersion.fr \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=j@jannau.net \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=konrad.dybcio@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --cc=tzimmermann@suse.de \
    --cc=wonchung@google.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 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).