From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B040AC433EF for ; Mon, 6 Dec 2021 21:14:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350528AbhLFVRu (ORCPT ); Mon, 6 Dec 2021 16:17:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350631AbhLFVRo (ORCPT ); Mon, 6 Dec 2021 16:17:44 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 078D6C061746; Mon, 6 Dec 2021 13:14:15 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 5409ECE1864; Mon, 6 Dec 2021 21:14:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B4B1C341C6; Mon, 6 Dec 2021 21:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638825251; bh=hPhWCMSayHBcfhH1bYNvUK2TzdlMPbkcPiari3gUW8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HifX9u3b7ByiKL041rOqp4WLYpVinxYj+QzNtIHh3oobvMl8lQDwy4HjbWdaf6kdb 3Pv2se0ZZU+9nEUW8Xt8+T6YjFySKHNrQ6qfpF7h4rJ6jpHvBR5v+zgxYd7at8aVLH pNGgpf/7eRSceGUaYnhOpy26z/F4HWuBbzG9CV4/qNGpDPToRP3nA0PEcPrBYyAG7t geARE2AeNTk39DwORIAKQB12ExmmTixo+p2KT3oVY2NSRrKIBYfGwfo4D5HyDIyxAb InFokQ2UhEv34+bHeMvTsnw8eJQF5prBIRf1RkkSExkg1V9NOe8B5m2QGi+8ftXRZr Ao43p4apd24FQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ondrej Jirman , John Keeping , Wolfram Sang , Sasha Levin , heiko@sntech.de, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-i2c@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 15/24] i2c: rk3x: Handle a spurious start completion interrupt flag Date: Mon, 6 Dec 2021 16:12:20 -0500 Message-Id: <20211206211230.1660072-15-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211206211230.1660072-1-sashal@kernel.org> References: <20211206211230.1660072-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Ondrej Jirman [ Upstream commit 02fe0fbd8a21e183687925c3a266ae27dda9840f ] In a typical read transfer, start completion flag is being set after read finishes (notice ipd bit 4 being set): trasnfer poll=0 i2c start rk3x-i2c fdd40000.i2c: IRQ: state 1, ipd: 10 i2c read rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 1b i2c stop rk3x-i2c fdd40000.i2c: IRQ: state 4, ipd: 33 This causes I2C transfer being aborted in polled mode from a stop completion handler: trasnfer poll=1 i2c start rk3x-i2c fdd40000.i2c: IRQ: state 1, ipd: 10 i2c read rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 0 rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 1b i2c stop rk3x-i2c fdd40000.i2c: IRQ: state 4, ipd: 13 i2c stop rk3x-i2c fdd40000.i2c: unexpected irq in STOP: 0x10 Clearing the START flag after read fixes the issue without any obvious side effects. This issue was dicovered on RK3566 when adding support for powering off the RK817 PMIC. Signed-off-by: Ondrej Jirman Reviewed-by: John Keeping Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-rk3x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index 819ab4ee517e1..02ddb237f69af 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c @@ -423,8 +423,8 @@ static void rk3x_i2c_handle_read(struct rk3x_i2c *i2c, unsigned int ipd) if (!(ipd & REG_INT_MBRF)) return; - /* ack interrupt */ - i2c_writel(i2c, REG_INT_MBRF, REG_IPD); + /* ack interrupt (read also produces a spurious START flag, clear it too) */ + i2c_writel(i2c, REG_INT_MBRF | REG_INT_START, REG_IPD); /* Can only handle a maximum of 32 bytes at a time */ if (len > 32) -- 2.33.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4FFF8C433F5 for ; Mon, 6 Dec 2021 21:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vljByr74vNXk7eyIst0CxILVrdGV6JrhLhe4ghzQogs=; b=gV1B8X2SnULBm3 hhvdvxzkom9TuHZ+M1yYqjcTJB4iAKc1JBSdzydvhpLGrnYOwLEH28YaUTn/PWkQAQXbLRQT88yz7 jwvXYgkw1hU64HmQX/U/B99V//TmNEScyi/1MT7Izp3SHhWGMlJyxET5bDgwpJoWZQiUCEtef8eaj Om6X40Ignipc6CDFLCed2yoJPhhkNzb3gWuc+WkwHOwjNuTpY74Nz9EsIAb7hL+7DpfIUw8ngvJb1 7YzwroJdcOQ9+eclV4L3zdGLRO7YDf4gEjz818X+1rWJcBbfwM7UzJxfT+wnqGVpv5wbLl3x3nCDv WfLD3IWQ1MsDqRB4Jt9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1muLN8-005oUb-R4; Mon, 06 Dec 2021 21:18:06 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1muLJO-005mfN-AN; Mon, 06 Dec 2021 21:14:16 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EEAF2B812A4; Mon, 6 Dec 2021 21:14:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B4B1C341C6; Mon, 6 Dec 2021 21:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638825251; bh=hPhWCMSayHBcfhH1bYNvUK2TzdlMPbkcPiari3gUW8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HifX9u3b7ByiKL041rOqp4WLYpVinxYj+QzNtIHh3oobvMl8lQDwy4HjbWdaf6kdb 3Pv2se0ZZU+9nEUW8Xt8+T6YjFySKHNrQ6qfpF7h4rJ6jpHvBR5v+zgxYd7at8aVLH pNGgpf/7eRSceGUaYnhOpy26z/F4HWuBbzG9CV4/qNGpDPToRP3nA0PEcPrBYyAG7t geARE2AeNTk39DwORIAKQB12ExmmTixo+p2KT3oVY2NSRrKIBYfGwfo4D5HyDIyxAb InFokQ2UhEv34+bHeMvTsnw8eJQF5prBIRf1RkkSExkg1V9NOe8B5m2QGi+8ftXRZr Ao43p4apd24FQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ondrej Jirman , John Keeping , Wolfram Sang , Sasha Levin , heiko@sntech.de, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-i2c@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 15/24] i2c: rk3x: Handle a spurious start completion interrupt flag Date: Mon, 6 Dec 2021 16:12:20 -0500 Message-Id: <20211206211230.1660072-15-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211206211230.1660072-1-sashal@kernel.org> References: <20211206211230.1660072-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211206_131414_552426_B6AFFC0D X-CRM114-Status: GOOD ( 12.97 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org From: Ondrej Jirman [ Upstream commit 02fe0fbd8a21e183687925c3a266ae27dda9840f ] In a typical read transfer, start completion flag is being set after read finishes (notice ipd bit 4 being set): trasnfer poll=0 i2c start rk3x-i2c fdd40000.i2c: IRQ: state 1, ipd: 10 i2c read rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 1b i2c stop rk3x-i2c fdd40000.i2c: IRQ: state 4, ipd: 33 This causes I2C transfer being aborted in polled mode from a stop completion handler: trasnfer poll=1 i2c start rk3x-i2c fdd40000.i2c: IRQ: state 1, ipd: 10 i2c read rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 0 rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 1b i2c stop rk3x-i2c fdd40000.i2c: IRQ: state 4, ipd: 13 i2c stop rk3x-i2c fdd40000.i2c: unexpected irq in STOP: 0x10 Clearing the START flag after read fixes the issue without any obvious side effects. This issue was dicovered on RK3566 when adding support for powering off the RK817 PMIC. Signed-off-by: Ondrej Jirman Reviewed-by: John Keeping Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-rk3x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index 819ab4ee517e1..02ddb237f69af 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c @@ -423,8 +423,8 @@ static void rk3x_i2c_handle_read(struct rk3x_i2c *i2c, unsigned int ipd) if (!(ipd & REG_INT_MBRF)) return; - /* ack interrupt */ - i2c_writel(i2c, REG_INT_MBRF, REG_IPD); + /* ack interrupt (read also produces a spurious START flag, clear it too) */ + i2c_writel(i2c, REG_INT_MBRF | REG_INT_START, REG_IPD); /* Can only handle a maximum of 32 bytes at a time */ if (len > 32) -- 2.33.0 _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D3713C433F5 for ; Mon, 6 Dec 2021 21:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5D2WoUCy1gpLvE/cd3IqF7/MVwAkVn1cP/fFihrWNp8=; b=qbqBzUlHJuNwfn Y6ayjJgcfMxEhtpYGSKKXkqOoPI/6HqEoAzdIvPY+D0uFWh/lsgCN154akQ/MC8vMt5C2z4M9lefm BIcj8g35RwrNg3AxQOQ2HTgWetkbd3eIP0wRTGiaqxUCAvsjDeNOwGQsUmFfpAAmrNI7aSCKFO1CZ tGr1P3GGQiRZv6rgeQPIT1q3yltdTaK5qHx5y2FcHUPnHYJwVR6jftiyNsO49POMw/Ev2GA89HrpA jPOPqXYzC+9gRKjAzDfE7G3yxEM+oyY3sYXcnVPtZb6Dz5Y61Qi2F+2gVtmT6QBP58qVzqOrEofrv fB+eDeDy9dIBr4CPSSzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1muLM4-005nuy-C6; Mon, 06 Dec 2021 21:17:01 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1muLJO-005mfN-AN; Mon, 06 Dec 2021 21:14:16 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EEAF2B812A4; Mon, 6 Dec 2021 21:14:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B4B1C341C6; Mon, 6 Dec 2021 21:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638825251; bh=hPhWCMSayHBcfhH1bYNvUK2TzdlMPbkcPiari3gUW8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HifX9u3b7ByiKL041rOqp4WLYpVinxYj+QzNtIHh3oobvMl8lQDwy4HjbWdaf6kdb 3Pv2se0ZZU+9nEUW8Xt8+T6YjFySKHNrQ6qfpF7h4rJ6jpHvBR5v+zgxYd7at8aVLH pNGgpf/7eRSceGUaYnhOpy26z/F4HWuBbzG9CV4/qNGpDPToRP3nA0PEcPrBYyAG7t geARE2AeNTk39DwORIAKQB12ExmmTixo+p2KT3oVY2NSRrKIBYfGwfo4D5HyDIyxAb InFokQ2UhEv34+bHeMvTsnw8eJQF5prBIRf1RkkSExkg1V9NOe8B5m2QGi+8ftXRZr Ao43p4apd24FQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ondrej Jirman , John Keeping , Wolfram Sang , Sasha Levin , heiko@sntech.de, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-i2c@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 15/24] i2c: rk3x: Handle a spurious start completion interrupt flag Date: Mon, 6 Dec 2021 16:12:20 -0500 Message-Id: <20211206211230.1660072-15-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211206211230.1660072-1-sashal@kernel.org> References: <20211206211230.1660072-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211206_131414_552426_B6AFFC0D X-CRM114-Status: GOOD ( 12.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Ondrej Jirman [ Upstream commit 02fe0fbd8a21e183687925c3a266ae27dda9840f ] In a typical read transfer, start completion flag is being set after read finishes (notice ipd bit 4 being set): trasnfer poll=0 i2c start rk3x-i2c fdd40000.i2c: IRQ: state 1, ipd: 10 i2c read rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 1b i2c stop rk3x-i2c fdd40000.i2c: IRQ: state 4, ipd: 33 This causes I2C transfer being aborted in polled mode from a stop completion handler: trasnfer poll=1 i2c start rk3x-i2c fdd40000.i2c: IRQ: state 1, ipd: 10 i2c read rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 0 rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 1b i2c stop rk3x-i2c fdd40000.i2c: IRQ: state 4, ipd: 13 i2c stop rk3x-i2c fdd40000.i2c: unexpected irq in STOP: 0x10 Clearing the START flag after read fixes the issue without any obvious side effects. This issue was dicovered on RK3566 when adding support for powering off the RK817 PMIC. Signed-off-by: Ondrej Jirman Reviewed-by: John Keeping Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-rk3x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index 819ab4ee517e1..02ddb237f69af 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c @@ -423,8 +423,8 @@ static void rk3x_i2c_handle_read(struct rk3x_i2c *i2c, unsigned int ipd) if (!(ipd & REG_INT_MBRF)) return; - /* ack interrupt */ - i2c_writel(i2c, REG_INT_MBRF, REG_IPD); + /* ack interrupt (read also produces a spurious START flag, clear it too) */ + i2c_writel(i2c, REG_INT_MBRF | REG_INT_START, REG_IPD); /* Can only handle a maximum of 32 bytes at a time */ if (len > 32) -- 2.33.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel