From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2CDC227B80; Tue, 15 Oct 2024 13:13:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728998032; cv=none; b=u4V5fuHU8C+H+f3BkQ2Dy7AiAvumdJ9lp0aYA3Otq0Hr/QW23Ia0d44CIWrY0y8TZlG3jILRbGDqjOsLiWInqT7Y6Dxw+ZEAXLNgAHsqMHhNBMGw/jnkaqp6fUGc4I+cj4EWd1d47M1/zbkPuLkf3eohvIE4pNZnwgMW8vUo2uU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728998032; c=relaxed/simple; bh=AEG54ASg5ujHqp/8FGmAofxeHqL9r5U50+CssB+9/Qk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XQdV5IGxHlcPb6OmKFko29JaL4DO5w2ACynuAze0mm2yEqLBSwtJAb6OYdZRHWBL97x1fWMM9+JFIO4GcktVoMbWJAfal/LuJuNJ1xRk84CdwV5BV6iLvVt4Gh12LsFs+jZck3UStooIolh13XqDSzmar0pTCgLn0y7IC3vVAGc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eKw3KbBV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="eKw3KbBV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32371C4CEC6; Tue, 15 Oct 2024 13:13:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728998032; bh=AEG54ASg5ujHqp/8FGmAofxeHqL9r5U50+CssB+9/Qk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eKw3KbBVicGjIRxTcOGTGbNeToSo+3mypmsDsax/QkKyx0zfwvzH1Ecxoj9/LVXxj EhEtUXDuIVjtPvYYOVsMlm74hf6VWLReNNmf4N20+XgiXCLzkgTunLlKGnM44qMYV3 yqHV8ui/daxpOtroMG1oScuq+HrEr46taTgCO3YU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alain Volmat , Marek Vasut , Andi Shyti Subject: [PATCH 5.10 359/518] i2c: stm32f7: Do not prepare/unprepare clock during runtime suspend/resume Date: Tue, 15 Oct 2024 14:44:23 +0200 Message-ID: <20241015123930.824656231@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015123916.821186887@linuxfoundation.org> References: <20241015123916.821186887@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marek Vasut commit 048bbbdbf85e5e00258dfb12f5e368f908801d7b upstream. In case there is any sort of clock controller attached to this I2C bus controller, for example Versaclock or even an AIC32x4 I2C codec, then an I2C transfer triggered from the clock controller clk_ops .prepare callback may trigger a deadlock on drivers/clk/clk.c prepare_lock mutex. This is because the clock controller first grabs the prepare_lock mutex and then performs the prepare operation, including its I2C access. The I2C access resumes this I2C bus controller via .runtime_resume callback, which calls clk_prepare_enable(), which attempts to grab the prepare_lock mutex again and deadlocks. Since the clock are already prepared since probe() and unprepared in remove(), use simple clk_enable()/clk_disable() calls to enable and disable the clock on runtime suspend and resume, to avoid hitting the prepare_lock mutex. Acked-by: Alain Volmat Signed-off-by: Marek Vasut Fixes: 4e7bca6fc07b ("i2c: i2c-stm32f7: add PM Runtime support") Cc: # v5.0+ Signed-off-by: Andi Shyti Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-stm32f7.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/i2c/busses/i2c-stm32f7.c +++ b/drivers/i2c/busses/i2c-stm32f7.c @@ -2278,7 +2278,7 @@ static int __maybe_unused stm32f7_i2c_ru struct stm32f7_i2c_dev *i2c_dev = dev_get_drvdata(dev); if (!stm32f7_i2c_is_slave_registered(i2c_dev)) - clk_disable_unprepare(i2c_dev->clk); + clk_disable(i2c_dev->clk); return 0; } @@ -2289,9 +2289,9 @@ static int __maybe_unused stm32f7_i2c_ru int ret; if (!stm32f7_i2c_is_slave_registered(i2c_dev)) { - ret = clk_prepare_enable(i2c_dev->clk); + ret = clk_enable(i2c_dev->clk); if (ret) { - dev_err(dev, "failed to prepare_enable clock\n"); + dev_err(dev, "failed to enable clock\n"); return ret; } }