{"id":2234907,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2234907/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20260508090311.379333-4-johan@kernel.org/","project":{"id":35,"url":"http://patchwork.ozlabs.org/api/1.2/projects/35/?format=json","name":"Linux I2C development","link_name":"linux-i2c","list_id":"linux-i2c.vger.kernel.org","list_email":"linux-i2c@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260508090311.379333-4-johan@kernel.org>","list_archive_url":null,"date":"2026-05-08T09:03:05","name":"[v2,3/9] i2c: core: fix adapter probe deferral loop","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"ff1f00b9cd98c9a7d01731e8393344819432685b","submitter":{"id":64666,"url":"http://patchwork.ozlabs.org/api/1.2/people/64666/?format=json","name":"Johan Hovold","email":"johan@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20260508090311.379333-4-johan@kernel.org/mbox/","series":[{"id":503352,"url":"http://patchwork.ozlabs.org/api/1.2/series/503352/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/list/?series=503352","date":"2026-05-08T09:03:09","name":"i2c: core: adapter registration fixes","version":2,"mbox":"http://patchwork.ozlabs.org/series/503352/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2234907/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2234907/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-i2c+bounces-17326-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-i2c@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=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=NvGBQGJz;\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-i2c+bounces-17326-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"NvGBQGJz\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"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 4gBjt43Qhxz1yJq\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 08 May 2026 19:06:52 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 10C293068EF5\n\tfor <incoming@patchwork.ozlabs.org>; Fri,  8 May 2026 09:03:39 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 3705638945C;\n\tFri,  8 May 2026 09:03:33 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\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 8F559382F26;\n\tFri,  8 May 2026 09:03:32 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 2BB02C2BCF4;\n\tFri,  8 May 2026 09:03:32 +0000 (UTC)","from johan by xi.lan with local (Exim 4.98.2)\n\t(envelope-from <johan@kernel.org>)\n\tid 1wLH7J-00000001ah4-48g6;\n\tFri, 08 May 2026 11:03:29 +0200"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778231012; cv=none;\n b=SMlzjyD9Dm/onkCaLy9G+7UOqFQESHo2grLjbssV/eRcXhmnP1nkNAoIXagE6i++s9ZQxoRGhyuAvwo3mIdfU4cl53nrXiljRYj2Qs/gNarLyWVOYYHkK/zy8OWzP1kwm1VuBJfdIVnDIXdypT6mN+2dtegfCM43GvdYcsCSUYA=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778231012; c=relaxed/simple;\n\tbh=N46uGMjt3fV1Z3PaiSqd3/q7oyJsZAsXz0u+Q9Byvuk=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=Np+kTErop+8Yga6DZ38NCMzNKHe5Bh3Ri5ViJDTY4ilmvEgoytJkSkcJ7IQsKCA9Jj9K0KQGRRBg/feiSfsNwW1TqgZuwWuVbna7XdeNYEU5BivQR3hNMzWAeUXdFTwKE85qu7wczECzIFqgL/WqV++dSiIHlijujhvUJL+lmHg=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=NvGBQGJz; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1778231012;\n\tbh=N46uGMjt3fV1Z3PaiSqd3/q7oyJsZAsXz0u+Q9Byvuk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=NvGBQGJz0hGMPHiCu9Trw0Fvy5atrFdFSZyWy4UUcp1vBxTMv6I6C8QZa1FwTRmTY\n\t ISXYcL/blEL8VGoL0w6yzr2gcYkZAikdF+ErO448HZVzUeLEFHXGL20272S4LOuGiz\n\t 8jOD7HoElIEDhJsbxgjMHoXjqqBaB2xarAW+edfgOPgxOfup5puKapr6yTkSY0df4F\n\t X7B0as3ANodLYZW9cBGzfFVIxvtKT4EhjWcM3Tqp0RRsgKWREALtG0jTWdwhXWc3EZ\n\t YZVt16tgrXNl18xh7W8HvV6HDNp+BsWszE85nWPB7uTrP00ZEyeVWVfijC5kFBdzGq\n\t TBiuUGMtxrh+g==","From":"Johan Hovold <johan@kernel.org>","To":"Wolfram Sang <wsa+renesas@sang-engineering.com>","Cc":"Andi Shyti <andi.shyti@kernel.org>,\n\tlinux-i2c@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tJohan Hovold <johan@kernel.org>,\n\tstable@vger.kernel.org,\n\tCodrin Ciubotariu <codrin.ciubotariu@microchip.com>","Subject":"[PATCH v2 3/9] i2c: core: fix adapter probe deferral loop","Date":"Fri,  8 May 2026 11:03:05 +0200","Message-ID":"<20260508090311.379333-4-johan@kernel.org>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260508090311.379333-1-johan@kernel.org>","References":"<20260508090311.379333-1-johan@kernel.org>","Precedence":"bulk","X-Mailing-List":"linux-i2c@vger.kernel.org","List-Id":"<linux-i2c.vger.kernel.org>","List-Subscribe":"<mailto:linux-i2c+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-i2c+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"Drivers must not probe defer after having registered devices as that\nwill trigger a probe loop if the devices bind to a driver (cf. commit\nfbc35b45f9f6 (\"Add documentation on meaning of -EPROBE_DEFER\")).\n\nMove the recovery initialisation, where the GPIO lookup may fail, before\nregistering the adapter to prevent this.\n\nFixes: 75820314de26 (\"i2c: core: add generic I2C GPIO recovery\")\nCc: stable@vger.kernel.org\t# 5.9\nCc: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>\nSigned-off-by: Johan Hovold <johan@kernel.org>\n---\n drivers/i2c/i2c-core-base.c | 17 +++++++++--------\n 1 file changed, 9 insertions(+), 8 deletions(-)","diff":"diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c\nindex e42851a10098..1caaa3b3ee10 100644\n--- a/drivers/i2c/i2c-core-base.c\n+++ b/drivers/i2c/i2c-core-base.c\n@@ -1562,6 +1562,10 @@ static int i2c_register_adapter(struct i2c_adapter *adap)\n \tadap->dev.type = &i2c_adapter_type;\n \tdevice_initialize(&adap->dev);\n \n+\tres = i2c_init_recovery(adap);\n+\tif (res == -EPROBE_DEFER)\n+\t\tgoto err_put_adap;\n+\n \t/*\n \t * This adapter can be used as a parent immediately after device_add(),\n \t * setup runtime-pm (especially ignore-children) before hand.\n@@ -1574,8 +1578,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap)\n \tres = device_add(&adap->dev);\n \tif (res) {\n \t\tpr_err(\"adapter '%s': can't register device (%d)\\n\", adap->name, res);\n-\t\tput_device(&adap->dev);\n-\t\tgoto err_remove_irq_domain;\n+\t\tgoto err_put_adap;\n \t}\n \n \tadap->debugfs = debugfs_create_dir(dev_name(&adap->dev), i2c_debugfs_root);\n@@ -1584,10 +1587,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap)\n \tif (res)\n \t\tgoto out_reg;\n \n-\tres = i2c_init_recovery(adap);\n-\tif (res == -EPROBE_DEFER)\n-\t\tgoto out_reg;\n-\n \tdev_dbg(&adap->dev, \"adapter [%s] registered\\n\", adap->name);\n \n \t/* create pre-declared device nodes */\n@@ -1608,10 +1607,12 @@ static int i2c_register_adapter(struct i2c_adapter *adap)\n out_reg:\n \ti2c_deregister_clients(adap);\n \tdebugfs_remove_recursive(adap->debugfs);\n+\tdevice_del(&adap->dev);\n+err_put_adap:\n \tinit_completion(&adap->dev_released);\n-\tdevice_unregister(&adap->dev);\n+\tput_device(&adap->dev);\n \twait_for_completion(&adap->dev_released);\n-err_remove_irq_domain:\n+\n \ti2c_host_notify_irq_teardown(adap);\n out_list:\n \tmutex_lock(&core_lock);\n","prefixes":["v2","3/9"]}