From patchwork Tue May 31 09:31:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Chen X-Patchwork-Id: 12866022 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 99E58C433EF for ; Tue, 31 May 2022 18:42:25 +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:Message-ID:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=YBBgFNpFQlU2BCT0cvLY27KJ/YCiTXV8LhSrxb41xB4=; b=JAeQWh/XUm5hgy eTJMMdV713jG17TcyczWZbh4Ps5YgZjcolt/A11eyAhJSixZS/0FizX10giQFZ3c7SVUlkD7B+3mJ TDVFP2x9MIV7KGnkQZZHs1vYIuS8gbjK9o66Z0ktV5Uiitmo+hIg4JfDANrWFEeg8zbuLCMcxNooe pHEr2zY/PmQGMmt3La3ochrYboq/iUwJvX8CTzOGtRuYEZ2oCrJxX1CsYyo7e+GOwAcVNi7nkm2kB hrTNNPMrU59WQnO773cPULJAHdMKPwfr4mfFw/Ei3vVGTfTqHmjzby+BnYCk9FnmlWwUZMfeFfxfb K/Wd5q2ZCLfg3tYe9BjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nw6nP-00CBsz-9v; Tue, 31 May 2022 18:40:47 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nw6nN-00CBss-Ai for linux-arm-kernel@bombadil.infradead.org; Tue, 31 May 2022 18:40:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:In-Reply-To:References; bh=gqwpWiuGU6dBjOJrGZDnPzcq8muo17DwBLompy8oTQk=; b=VH8fqcsJ0k7tG1T8Aa3+v/WwVz J5w1KtuaONJalYSk0H66EUBKH8hQ7eba/cLtLqVwENTpYDG6FZWT2k4XLaBemapsjXzv2258Yfpzq 9IMuM5Yi6AQQ8CspR4alC05ygM42W1H5PBFqZj1dX+l5HFqWbVuK1Rc7kMkmVdgcL+SlyqIIkeYA0 uVPH91cyEXOOWlVMAjFBZCabB3HkmdOf7G2HAV1xrScmj5BnE2HiQ5QxxdFrgyxuXMKAzw1Ed+wdu C4980zhFXBxLWxRQrft7+2/KWMlSjsw+zQK6tZp8PzGLJqSTUdIuH1/rXkkUlbK4Ig0IUFAvPFFV+ i4sbWd6g==; Received: from twspam01.aspeedtech.com ([211.20.114.71]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nvyEj-003LRS-TL for linux-arm-kernel@lists.infradead.org; Tue, 31 May 2022 09:32:28 +0000 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 24V9HLNb095917; Tue, 31 May 2022 17:17:21 +0800 (GMT-8) (envelope-from ryan_chen@aspeedtech.com) Received: from localhost.localdomain (192.168.10.9) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 31 May 2022 17:31:46 +0800 From: ryan_chen To: , , , , , , , , Subject: [PATCH] i2c: aspeed: Fix slave mode unexpected irq handler Date: Tue, 31 May 2022 17:31:40 +0800 Message-ID: <20220531093140.28770-1-ryan_chen@aspeedtech.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [192.168.10.9] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 24V9HLNb095917 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220531_103227_052872_8AD4F8E8 X-CRM114-Status: UNSURE ( 8.27 ) X-CRM114-Notice: Please train this message. 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When i2c master send the new i2c transfer immediately after stop. the i2c slave will see the stop and new address match stage together. And it needs handle the stop first. otherwise will occur unexpected handle isr. Fixes: f327c686d3ba ("i2c: aspeed: added drover for Aspeed I2C) Signed-off-by: ryan_chen --- drivers/i2c/busses/i2c-aspeed.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 771e53d3d197..9f21e090ce47 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -252,6 +252,12 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) /* Slave was requested, restart state machine. */ if (irq_status & ASPEED_I2CD_INTR_SLAVE_MATCH) { + if (irq_status & ASPEED_I2CD_INTR_NORMAL_STOP && + bus->slave_state == ASPEED_I2C_SLAVE_WRITE_RECEIVED) { + irq_handled |= ASPEED_I2CD_INTR_NORMAL_STOP; + irq_status &= ~ASPEED_I2CD_INTR_NORMAL_STOP; + i2c_slave_event(slave, I2C_SLAVE_STOP, &value); + } irq_handled |= ASPEED_I2CD_INTR_SLAVE_MATCH; bus->slave_state = ASPEED_I2C_SLAVE_START; }