{"id":2232092,"url":"http://patchwork.ozlabs.org/api/patches/2232092/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20260502153218.56142-1-marex@nabladev.com/","project":{"id":35,"url":"http://patchwork.ozlabs.org/api/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":"<20260502153218.56142-1-marex@nabladev.com>","list_archive_url":null,"date":"2026-05-02T15:31:54","name":"i2c: stm32f7: Move reinit_completion() to stm32f7_i2c_xfer_core()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"cc834b67d8e94abdf690abb4678ff2c775327c12","submitter":{"id":91452,"url":"http://patchwork.ozlabs.org/api/people/91452/?format=json","name":"Marek Vasut","email":"marex@nabladev.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20260502153218.56142-1-marex@nabladev.com/mbox/","series":[{"id":502539,"url":"http://patchwork.ozlabs.org/api/series/502539/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/list/?series=502539","date":"2026-05-02T15:31:54","name":"i2c: stm32f7: Move reinit_completion() to stm32f7_i2c_xfer_core()","version":1,"mbox":"http://patchwork.ozlabs.org/series/502539/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2232092/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2232092/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-i2c+bounces-17206-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=nabladev.com header.i=@nabladev.com header.a=rsa-sha256\n header.s=dkim header.b=Hq2oZqmf;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-i2c+bounces-17206-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=nabladev.com header.i=@nabladev.com\n header.b=\"Hq2oZqmf\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=178.251.229.89","smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=nabladev.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=nabladev.com"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g7Bk32pQfz1y04\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 03 May 2026 01:32:43 +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 EA63A300FC66\n\tfor <incoming@patchwork.ozlabs.org>; Sat,  2 May 2026 15:32:35 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 30419366DB6;\n\tSat,  2 May 2026 15:32:35 +0000 (UTC)","from mx.nabladev.com (mx.nabladev.com [178.251.229.89])\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 0898D2C21F2;\n\tSat,  2 May 2026 15:32:32 +0000 (UTC)","from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon)\n with ESMTPSA id D205D112877;\n\tSat,  2 May 2026 17:32:20 +0200 (CEST)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777735954; cv=none;\n b=A60knHPQmXjTazw4rnR3Dy1wGbxidRGRaL2zBQ4rF9BLvsM4oUYgS4LSb+Wzgfha9TOKgCwzNeW+SpWIIxg2w/k9OcKFqDfKp05ZsjVViTyZhF8d84sHsfxGas8dAM31i3rvt6gmDcVhkqjZOmYuMSXVXcUnh3E/rHUVI4QR+G0=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777735954; c=relaxed/simple;\n\tbh=5N4j7dqp3wXHijrMRaccB7RFI8HYwGLQKs9hGzmNDcw=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=H7hiZeJ8mjddY7qVN8mvUKlMql7ePrgU3sx45ApkGAl0wzwJiYuzYT0nWFyviXmpK23MfrNqcqRzQ1AxUcoK0eoe7VtIWlUWabNlfmI4p+IRNEJ9deTkkmFVdNtWElYSquTNOTPgPkb26TSZ/fqYcSBWmSAv/MTV4A68/YyNegI=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=nabladev.com;\n spf=pass smtp.mailfrom=nabladev.com;\n dkim=pass (2048-bit key) header.d=nabladev.com header.i=@nabladev.com\n header.b=Hq2oZqmf; arc=none smtp.client-ip=178.251.229.89","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=nabladev.com;\n\ts=dkim; t=1777735944; h=from:subject:date:message-id:to:cc:mime-version:\n\t content-transfer-encoding; bh=1Ji4o/UKh5s3iYAgum24fW1ttfWjMxe2zCp2y0o6sCg=;\n\tb=Hq2oZqmfzGYQ/21alyh41Hi/ZBlWkeDrmW6/VbJiHP8dLV0mska06rVLmpVN9VEtln9Jmh\n\t6EdvO9PtCahkjrCKRB2AOicrdvK9Lcxf0kBCoXeapjzM38empUchYBlqx4/X+gQ15aed6i\n\tep8GvpYJMHENQuOGrPjh2OFUj4DE5gtghEF7nlztujBGVJJERJBQbp/d2kYk9elanswqC8\n\thY38US03Y94gHVOgP4S7nfzKrKVTWRRGhDfM0MUkI+DQ0PPH54zDgEkPo5e4byXIgSgaP1\n\tw4jz7e7sirOQNlQmpMwqACaIggv1ELxVFr6kflPJloNbHohmF9MMl9byOw8dFQ==","From":"Marek Vasut <marex@nabladev.com>","To":"linux-i2c@vger.kernel.org","Cc":"Marek Vasut <marex@nabladev.com>,\n\tAlain Volmat <alain.volmat@foss.st.com>,\n\tAlexandre Torgue <alexandre.torgue@foss.st.com>,\n\tAndi Shyti <andi.shyti@kernel.org>,\n\tMaxime Coquelin <mcoquelin.stm32@gmail.com>,\n\tPierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>,\n\tlinux-arm-kernel@lists.infradead.org,\n\tlinux-kernel@vger.kernel.org,\n\tlinux-stm32@st-md-mailman.stormreply.com","Subject":"[PATCH] i2c: stm32f7: Move reinit_completion() to\n stm32f7_i2c_xfer_core()","Date":"Sat,  2 May 2026 17:31:54 +0200","Message-ID":"<20260502153218.56142-1-marex@nabladev.com>","X-Mailer":"git-send-email 2.53.0","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","X-Last-TLS-Session-Version":"TLSv1.3"},"content":"Currently, the driver may repeatedly call reinit_completion() during\ntransfer which contains multiple messages, while another thread is\nwaiting for the completion.\n\nThis happens during transfer with more than 1 message, invoked via\nstm32f7_i2c_xfer_core() -> stm32f7_i2c_xfer_msg(). After invoking the\nstm32f7_i2c_xfer_msg() to start transfer, stm32f7_i2c_xfer_core()\ncalls wait_for_completion_timeout() to wait for completion of the\ntransfer of all messages. When the first message transfer completes,\nthe hard IRQ handler triggers, and detects transfer completion, which\nleads to stm32f7_i2c_isr_event_thread() IRQ thread being started. The\nstm32f7_i2c_isr_event_thread() calls stm32f7_i2c_xfer_msg() in case\nthere are more messages.\n\nWithout this change, the second and later stm32f7_i2c_xfer_msg() would\ncall reinit_completion() on the completion which is still being waited\nfor in stm32f7_i2c_xfer_core(). Fix this by moving the reinit_completion()\ninto stm32f7_i2c_xfer_core(), together with wait_for_completion_timeout().\n\nSince stm32f7_i2c_xfer_core() now waits for completion of the entire\ntransfer, increase the default timeout. This fixes sporadic transfer\ntimeouts on STM32MP25xx during kernel boot.\n\nFixes: aeb068c57214 (\"i2c: i2c-stm32f7: add driver\")\nSigned-off-by: Marek Vasut <marex@nabladev.com>\n---\nCc: Alain Volmat <alain.volmat@foss.st.com>\nCc: Alexandre Torgue <alexandre.torgue@foss.st.com>\nCc: Andi Shyti <andi.shyti@kernel.org>\nCc: Maxime Coquelin <mcoquelin.stm32@gmail.com>\nCc: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>\nCc: linux-arm-kernel@lists.infradead.org\nCc: linux-i2c@vger.kernel.org\nCc: linux-kernel@vger.kernel.org\nCc: linux-stm32@st-md-mailman.stormreply.com\n---\n drivers/i2c/busses/i2c-stm32f7.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)","diff":"diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c\nindex 70cb5822bf17b..53d9df70ebe4d 100644\n--- a/drivers/i2c/busses/i2c-stm32f7.c\n+++ b/drivers/i2c/busses/i2c-stm32f7.c\n@@ -895,8 +895,6 @@ static void stm32f7_i2c_xfer_msg(struct stm32f7_i2c_dev *i2c_dev,\n \tf7_msg->result = 0;\n \tf7_msg->stop = (i2c_dev->msg_id >= i2c_dev->msg_num - 1);\n \n-\treinit_completion(&i2c_dev->complete);\n-\n \tcr1 = readl_relaxed(base + STM32F7_I2C_CR1);\n \tcr2 = readl_relaxed(base + STM32F7_I2C_CR2);\n \n@@ -1728,6 +1726,8 @@ static int stm32f7_i2c_xfer_core(struct i2c_adapter *i2c_adap,\n \tif (ret)\n \t\tgoto pm_free;\n \n+\treinit_completion(&i2c_dev->complete);\n+\n \tstm32f7_i2c_xfer_msg(i2c_dev, msgs);\n \n \tif (!i2c_dev->atomic)\n@@ -2253,7 +2253,7 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)\n \tsnprintf(adap->name, sizeof(adap->name), \"STM32F7 I2C(%pa)\",\n \t\t &res->start);\n \tadap->owner = THIS_MODULE;\n-\tadap->timeout = 2 * HZ;\n+\tadap->timeout = 8 * HZ;\n \tadap->retries = 3;\n \tadap->algo = &stm32f7_i2c_algo;\n \tadap->dev.parent = &pdev->dev;\n","prefixes":[]}