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 1454217A93F; Tue, 16 Jul 2024 15:53:32 +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=1721145212; cv=none; b=M0D/8+y0CMIkGOoAZOCMJDQ9B6fy7XBbC6zCTZiI6vYFB3HSOZ3OZYzV4N47UI1f5blpC5j9u/V0Jz9Q9nLBk1AkrvPqDCpn+gvFqXi/dm51i2FielRey7SPdkLnQ81U6aZf0l4l9eeb4d67liNxUf+W4SuktWnkizZditjvU/w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721145212; c=relaxed/simple; bh=IiWJyf/9/uDPgV5Oe3Bx2xBH1pd53qqPrTXmT4Dri4c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P+FBEkP7MSv3W8FQaQVBDeKzjpulq1W7JhGEY4eSv1CQUw9g9GcWDYUinjLN5Zk40PvCO9QVmbRJWhen4x2wvcpD+F5zmWEhK+YGiH2czoZXFqUz2GMyyvBmlRkp8eajOwgF/kcmcrlj53YnkG8NjPxUtAQE6qf/pm4gOGnvnEo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=op9t6ozI; 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="op9t6ozI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E27DC116B1; Tue, 16 Jul 2024 15:53:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1721145212; bh=IiWJyf/9/uDPgV5Oe3Bx2xBH1pd53qqPrTXmT4Dri4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=op9t6ozIzQLBWz70bu8Tcfvg4dsQX7CrE898NTyXWK/S8lBXvzPWXvc8px8q9d/GK pvSam29tHbXV13DtK8cF/mNzEr4ivDHqwvuRtRecTdBBjsIg9474jBkbM4rULvIUra TTR7WmLtaCqJnAZYI3mjxDcgDKF+FDyzszn73ik4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dirk Behme , Geert Uytterhoeven , Wolfram Sang , Andi Shyti , Sasha Levin Subject: [PATCH 6.9 135/143] i2c: rcar: bring hardware to known state when probing Date: Tue, 16 Jul 2024 17:32:11 +0200 Message-ID: <20240716152801.189186289@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716152755.980289992@linuxfoundation.org> References: <20240716152755.980289992@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 6.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wolfram Sang [ Upstream commit 4e36c0f20cb1c74c7bd7ea31ba432c1c4a989031 ] When probing, the hardware is not brought into a known state. This may be a problem when a hypervisor restarts Linux without resetting the hardware, leaving an old state running. Make sure the hardware gets initialized, especially interrupts should be cleared and disabled. Reported-by: Dirk Behme Reported-by: Geert Uytterhoeven Closes: https://lore.kernel.org/r/20240702045535.2000393-1-dirk.behme@de.bosch.com Fixes: 6ccbe607132b ("i2c: add Renesas R-Car I2C driver") Signed-off-by: Wolfram Sang Signed-off-by: Andi Shyti Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-rcar.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 828aa2ea0fe4c..ec73463ea9b5e 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -257,6 +257,14 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv) } } +static void rcar_i2c_reset_slave(struct rcar_i2c_priv *priv) +{ + rcar_i2c_write(priv, ICSIER, 0); + rcar_i2c_write(priv, ICSSR, 0); + rcar_i2c_write(priv, ICSCR, SDBS); + rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */ +} + static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv) { int ret; @@ -1033,11 +1041,8 @@ static int rcar_unreg_slave(struct i2c_client *slave) /* ensure no irq is running before clearing ptr */ disable_irq(priv->irq); - rcar_i2c_write(priv, ICSIER, 0); - rcar_i2c_write(priv, ICSSR, 0); + rcar_i2c_reset_slave(priv); enable_irq(priv->irq); - rcar_i2c_write(priv, ICSCR, SDBS); - rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */ priv->slave = NULL; @@ -1152,7 +1157,9 @@ static int rcar_i2c_probe(struct platform_device *pdev) goto out_pm_disable; } - rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */ + /* Bring hardware to known state */ + rcar_i2c_init(priv); + rcar_i2c_reset_slave(priv); if (priv->devtype < I2C_RCAR_GEN3) { irqflags |= IRQF_NO_THREAD; -- 2.43.0