{"id":2215966,"url":"http://patchwork.ozlabs.org/api/patches/2215966/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/patch/20260325143555.451852-17-herve.codina@bootlin.com/","project":{"id":28,"url":"http://patchwork.ozlabs.org/api/projects/28/?format=json","name":"Linux PCI development","link_name":"linux-pci","list_id":"linux-pci.vger.kernel.org","list_email":"linux-pci@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260325143555.451852-17-herve.codina@bootlin.com>","list_archive_url":null,"date":"2026-03-25T14:35:43","name":"[v6,16/27] i2c: mux: Create missing devlink between mux and adapter physical device","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"8044c7f42b529912a22bd71a8138a9b8d198d354","submitter":{"id":81983,"url":"http://patchwork.ozlabs.org/api/people/81983/?format=json","name":"Herve Codina","email":"herve.codina@bootlin.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-pci/patch/20260325143555.451852-17-herve.codina@bootlin.com/mbox/","series":[{"id":497453,"url":"http://patchwork.ozlabs.org/api/series/497453/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/list/?series=497453","date":"2026-03-25T14:35:27","name":"lan966x pci device: Add support for SFPs","version":6,"mbox":"http://patchwork.ozlabs.org/series/497453/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2215966/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2215966/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-pci+bounces-51087-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256\n header.s=dkim header.b=x9aXYJt2;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-51087-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com\n header.b=\"x9aXYJt2\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=185.246.84.56","smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=bootlin.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=bootlin.com"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fgrLF6bRsz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 02:24:37 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 1E1FC320E6AD\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 14:44:54 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id AB5513F9F4E;\n\tWed, 25 Mar 2026 14:41:09 +0000 (UTC)","from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C6853F880D;\n\tWed, 25 Mar 2026 14:41:06 +0000 (UTC)","from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233])\n\tby smtpout-02.galae.net (Postfix) with ESMTPS id 371411A2FE8;\n\tWed, 25 Mar 2026 14:41:05 +0000 (UTC)","from mail.galae.net (mail.galae.net [212.83.136.155])\n\tby smtpout-01.galae.net (Postfix) with ESMTPS id 05245601FA;\n\tWed, 25 Mar 2026 14:41:05 +0000 (UTC)","from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon)\n with ESMTPSA id 5F96E104513C1;\n\tWed, 25 Mar 2026 15:40:44 +0100 (CET)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1774449669; cv=none;\n b=TuX0341W1v9wC1/A5xtxpiKIvjB4we4hpYJUD18qevouA886U+iblQG/VSjPxk/gAExYDpWJ6OVDvnQxd7sJiaO613QLBE7F20jNbJ0HxTXFNc27YoC3gBY8hvUThvN8sk3V3zIVLem7AiLSnaP2Ym9NOrJGqoSA66aOebnKMvo=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1774449669; c=relaxed/simple;\n\tbh=uDuPgt2o/9oBQHh+Cpy7Gf83um6TASnvbhCiTbvCQdY=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=vC5dYS6C44c08CXHiVn4h8xI68VPk4hJ/Kv7LSNTO7Ax/dpPQKAILKhwUo1gAanYIPO6k6P7mCUR9z0hw11NWS3Qy1HhUaTlLY6hIhDxdDofdIJ4bCcR0n9ZKExm9n8wQ9So+L/STUaAGyV+w2aRaukML9h+08yZPnXqXJBgGtY=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=bootlin.com;\n spf=pass smtp.mailfrom=bootlin.com;\n dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com\n header.b=x9aXYJt2; arc=none smtp.client-ip=185.246.84.56","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim;\n\tt=1774449661; h=from:subject:date:message-id:to:cc:mime-version:\n\t content-transfer-encoding:in-reply-to:references;\n\tbh=EB2C+jRFMxDkKtJvrc3FzQhnrQCg9ZYzY6GBMb2A8G4=;\n\tb=x9aXYJt2Xgv4kB01GyPszWYFEN17VsPTuRWho3EM5oIObrs0bojHjDhISOKnG44m1DMxNq\n\tcKQJDZLmCapQChTQoa3OODYY+pV9TVmx+9r2a1wgUgaAXGCgOsYXiXVRNoih0o25MH/3Fc\n\tMGwNg9BPQmrmMvUjiRSJxCoactYMhwFr7lQUqyE9QjOGv6YC/kIA9QXZRIxrN+qsbAaGeQ\n\taKwIxzVON7u5qPOVEvBm8Em5pWnL1+NdeOnjZHFydwFiUarG2Xc/wCG2XUwBwISErwUn2f\n\tysLd8Zbxa66++hAPrjNqzamzw69xul/RiuxCwgrNipfI3j+0AvjiRJ2e4Ea7CQ==","From":"Herve Codina <herve.codina@bootlin.com>","To":"Andrew Lunn <andrew@lunn.ch>,\n\tRob Herring <robh@kernel.org>,\n\tKrzysztof Kozlowski <krzk+dt@kernel.org>,\n\tConor Dooley <conor+dt@kernel.org>,\n\tGeert Uytterhoeven <geert+renesas@glider.be>,\n\tKalle Niemi <kaleposti@gmail.com>,\n\tMatti Vaittinen <mazziesaccount@gmail.com>,\n\tGreg Kroah-Hartman <gregkh@linuxfoundation.org>,\n\t\"Rafael J. Wysocki\" <rafael@kernel.org>,\n\tDanilo Krummrich <dakr@kernel.org>,\n\tFrank Li <Frank.Li@nxp.com>,\n\tSascha Hauer <s.hauer@pengutronix.de>,\n\tPengutronix Kernel Team <kernel@pengutronix.de>,\n\tFabio Estevam <festevam@gmail.com>,\n\tMichael Turquette <mturquette@baylibre.com>,\n\tStephen Boyd <sboyd@kernel.org>,\n\tAndi Shyti <andi.shyti@kernel.org>,\n\tWolfram Sang <wsa+renesas@sang-engineering.com>,\n\tPeter Rosin <peda@axentia.se>,\n\tArnd Bergmann <arnd@arndb.de>,\n\tHerve Codina <herve.codina@bootlin.com>,\n\tSaravana Kannan <saravanak@kernel.org>,\n\tBjorn Helgaas <bhelgaas@google.com>,\n\tCharles Keepax <ckeepax@opensource.cirrus.com>,\n\tRichard Fitzgerald <rf@opensource.cirrus.com>,\n\tDavid Rhodes <david.rhodes@cirrus.com>,\n\tLinus Walleij <linusw@kernel.org>,\n\tUlf Hansson <ulf.hansson@linaro.org>,\n\tMark Brown <broonie@kernel.org>,\n\tLen Brown <lenb@kernel.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tDaniel Scally <djrscally@gmail.com>,\n\tHeikki Krogerus <heikki.krogerus@linux.intel.com>,\n\tSakari Ailus <sakari.ailus@linux.intel.com>,\n\tDavidlohr Bueso <dave@stgolabs.net>,\n\tJonathan Cameron <jonathan.cameron@huawei.com>,\n\tDave Jiang <dave.jiang@intel.com>,\n\tAlison Schofield <alison.schofield@intel.com>,\n\tVishal Verma <vishal.l.verma@intel.com>,\n\tIra Weiny <ira.weiny@intel.com>,\n\tDan Williams <dan.j.williams@intel.com>,\n\tShawn Guo <shawnguo@kernel.org>","Cc":"Wolfram Sang <wsa@kernel.org>,\n\tlinux-kernel@vger.kernel.org,\n\tdriver-core@lists.linux.dev,\n\timx@lists.linux.dev,\n\tlinux-arm-kernel@lists.infradead.org,\n\tlinux-clk@vger.kernel.org,\n\tlinux-i2c@vger.kernel.org,\n\tdevicetree@vger.kernel.org,\n\tlinux-pci@vger.kernel.org,\n\tlinux-sound@vger.kernel.org,\n\tpatches@opensource.cirrus.com,\n\tlinux-gpio@vger.kernel.org,\n\tlinux-pm@vger.kernel.org,\n\tlinux-spi@vger.kernel.org,\n\tlinux-acpi@vger.kernel.org,\n\tlinux-cxl@vger.kernel.org,\n\tAllan Nielsen <allan.nielsen@microchip.com>,\n\tHoratiu Vultur <horatiu.vultur@microchip.com>,\n\tSteen Hegelund <steen.hegelund@microchip.com>,\n\tLuca Ceresoli <luca.ceresoli@bootlin.com>,\n\tThomas Petazzoni <thomas.petazzoni@bootlin.com>","Subject":"[PATCH v6 16/27] i2c: mux: Create missing devlink between mux and\n adapter physical device","Date":"Wed, 25 Mar 2026 15:35:43 +0100","Message-ID":"<20260325143555.451852-17-herve.codina@bootlin.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260325143555.451852-1-herve.codina@bootlin.com>","References":"<20260325143555.451852-1-herve.codina@bootlin.com>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Last-TLS-Session-Version":"TLSv1.3"},"content":"When removing an i2c controller device handling an i2c bus where an i2c\nmux is connected to, the removal process hangs and is stuck in the\nwait_completion() call done in i2c_del_adapter().\n\nThe i2c_del_adapter() tries to removed the i2c adapter related to the\ni2c controller device and the wait_completion() is waiting for the i2c\nadapter device release. This release is performed when the device is no\nmore used (i.e. refcount reaches zero).\n\nWhen an i2c mux is involved in an i2c path, the struct dev topology is\nthe following:\n\n    +----------------+                +-------------------+\n    | i2c controller |                |      i2c mux      |\n    |     device     |                |      device       |\n    |       ^        |                |                   |\n    |       |        |                |                   |\n    |  dev's parent  |                |                   |\n    |       |        |                |                   |\n    |   i2c adapter  |                | i2c adapter chanX |\n    |     device  <---- dev's parent ------  device       |\n    |   (no driver)  |                |    (no driver)    |\n    +----------------+                +-------------------+\n\nWhen an i2c mux device creates an i2c adapter for its downstream\nchannel, a reference is taken to its adapter dev's parent. This parent\nis the i2c mux upstream adapter device.\n\nNo relationship exists between the i2c mux device itself and the i2c\ncontroller device (physical device) in order to have the i2c mux device\ncalling i2c_del_adapter() to remove its downstream adapters and so,\nrelease references taken to the upstream adapter.\n\nThis consumer/supplier relationship is typically a devlink relationship.\n\nAlso, i2c muxes can be chained and so, the upstream adapter can be\nsupplied by either an i2c controller device or an other i2c mux device.\n\nIn order to get the physical device of the adapter a mux is connected\nto, rely on the newly introduced i2c_adapter_get_physdev() and create\nthe missing devlink between the i2c mux device and the physical\ndevice of the adapter the mux is connected to.\n\nWith that done, the i2c mux device is removed before the device\nhandling the upstream i2c adapter (i2c controller device or i2c mux\ndevice). All references are released and the i2c_del_adapter() call\nperformed by driver handling the upstream adapter device is not blocking\nanymore.\n\nSigned-off-by: Herve Codina <herve.codina@bootlin.com>\n---\n drivers/i2c/i2c-mux.c | 25 +++++++++++++++++++++++++\n 1 file changed, 25 insertions(+)","diff":"diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c\nindex f4e73e7a0e33..26470a7c2eea 100644\n--- a/drivers/i2c/i2c-mux.c\n+++ b/drivers/i2c/i2c-mux.c\n@@ -268,7 +268,9 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc,\n \t\t\tu32 force_nr, u32 chan_id)\n {\n \tstruct i2c_adapter *parent = muxc->parent;\n+\tstruct device *parent_physdev;\n \tstruct i2c_mux_priv *priv;\n+\tstruct device_link *dl;\n \tchar symlink_name[20];\n \tint ret;\n \n@@ -375,6 +377,29 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc,\n \t\t\t\t      ACPI_COMPANION(muxc->dev),\n \t\t\t\t      chan_id);\n \n+\t/*\n+\t * There is no relationship set between the mux device and the physical\n+\t * device handling the parent adapter. Create this missing relationship\n+\t * in order to remove the i2c mux device (consumer) and so the dowstream\n+\t * channel adapters before removing the physical device (supplier) which\n+\t * handles the i2c mux upstream adapter.\n+\t */\n+\tparent_physdev = i2c_get_adapter_physdev(parent);\n+\tif (!parent_physdev) {\n+\t\tdev_err(muxc->dev, \"failed to get the parent physical device\\n\");\n+\t\tret = -ENODEV;\n+\t\tgoto err_free_priv;\n+\t}\n+\tdl = device_link_add(muxc->dev, parent_physdev, DL_FLAG_AUTOREMOVE_CONSUMER);\n+\tif (!dl) {\n+\t\tdev_err(muxc->dev, \"failed to create device link to %s\\n\",\n+\t\t\tdev_name(parent_physdev));\n+\t\tput_device(parent_physdev);\n+\t\tret = -EINVAL;\n+\t\tgoto err_free_priv;\n+\t}\n+\tput_device(parent_physdev);\n+\n \tif (force_nr) {\n \t\tpriv->adap.nr = force_nr;\n \t\tret = i2c_add_numbered_adapter(&priv->adap);\n","prefixes":["v6","16/27"]}