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 X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50AF6C10F14 for ; Tue, 8 Oct 2019 22:45:41 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 204ED206BB for ; Tue, 8 Oct 2019 22:45:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JevblMKG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 204ED206BB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fnmY1PR/fLnxmrffSZedzvqYtXRN1hlS5QsZwxFNsyM=; b=JevblMKGgMSRLcQsS4lgHGee8 ToOjHrUw20OTNPOi8MWNIzfQcJ5jAog0460uV2A7GcNdvqiwqOBjeHRm7Ju0zeLhHhu2A5TnVBwXj Hc0hzv5v1IS6O3Y6Wgw0GrOt7h4aNllwjsYYqy0ZjPaskx9Q4aQPInbbuu/TalNnECpBWyPEWs2kw ahEIqhZ8lAMGcmy07TndohFvELHGLLzwCQDH7auj5MD6rSUR2Tegj5GXv3y5zo+Otzt3uvhD8lrP/ k53lVByN2oqinerQ3w0PP6YIr6yA86Gvl/1VrHl2nmHHQF+FaDv7FJDqSGPLCXZVDPx2vM/5kPMET W/o8rZcrw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iHyEe-0005oS-KO; Tue, 08 Oct 2019 22:45:40 +0000 Received: from mga03.intel.com ([134.134.136.65]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iHyEY-0005nx-CG for linux-arm-kernel@lists.infradead.org; Tue, 08 Oct 2019 22:45:39 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Oct 2019 15:45:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,272,1566889200"; d="scan'208";a="187447543" Received: from yoojae-mobl1.amr.corp.intel.com (HELO [10.7.153.148]) ([10.7.153.148]) by orsmga008.jf.intel.com with ESMTP; 08 Oct 2019 15:45:33 -0700 Subject: Re: [PATCH 3/5] i2c: aspeed: fix master pending state handling To: Tao Ren , Brendan Higgins , Benjamin Herrenschmidt , Joel Stanley , Rob Herring , Mark Rutland , Andrew Jeffery References: <20191007231313.4700-1-jae.hyun.yoo@linux.intel.com> <20191007231313.4700-4-jae.hyun.yoo@linux.intel.com> <422eea61-7cb9-e471-83fb-3f554ff5e079@fb.com> From: Jae Hyun Yoo Message-ID: <6f280195-eef7-1fe7-ac42-ad6879ca9838@linux.intel.com> Date: Tue, 8 Oct 2019 15:45:33 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <422eea61-7cb9-e471-83fb-3f554ff5e079@fb.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191008_154537_327694_03C5D5C6 X-CRM114-Status: GOOD ( 18.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "devicetree@vger.kernel.org" , "linux-aspeed@lists.ozlabs.org" , "linux-i2c@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "openbmc@lists.ozlabs.org" Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Tao, On 10/8/2019 3:00 PM, Tao Ren wrote: > On 10/7/19 4:13 PM, Jae Hyun Yoo wrote: >> In case of master pending state, it should not trigger the master >> command because this H/W is sharing the same data buffer for slave >> and master operations, so this commit fixes the issue with making >> the master command triggering happen when the state goes to active >> state. >> >> Signed-off-by: Jae Hyun Yoo >> --- >> drivers/i2c/busses/i2c-aspeed.c | 9 +++++---- >> 1 file changed, 5 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c >> index fa66951b05d0..40f6cf98d32e 100644 >> --- a/drivers/i2c/busses/i2c-aspeed.c >> +++ b/drivers/i2c/busses/i2c-aspeed.c >> @@ -336,18 +336,19 @@ static void aspeed_i2c_do_start(struct aspeed_i2c_bus *bus) >> struct i2c_msg *msg = &bus->msgs[bus->msgs_index]; >> u8 slave_addr = i2c_8bit_addr_from_msg(msg); >> >> - bus->master_state = ASPEED_I2C_MASTER_START; >> - >> #if IS_ENABLED(CONFIG_I2C_SLAVE) >> /* >> * If it's requested in the middle of a slave session, set the master >> * state to 'pending' then H/W will continue handling this master >> * command when the bus comes back to the idle state. >> */ >> - if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) >> + if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) { >> bus->master_state = ASPEED_I2C_MASTER_PENDING; >> + return; >> + } >> #endif /* CONFIG_I2C_SLAVE */ >> >> + bus->master_state = ASPEED_I2C_MASTER_START; >> bus->buf_index = 0; >> >> if (msg->flags & I2C_M_RD) { >> @@ -432,7 +433,7 @@ static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status) >> if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) >> goto out_no_complete; >> >> - bus->master_state = ASPEED_I2C_MASTER_START; >> + aspeed_i2c_do_start(bus); >> } > > Shall we move the restart-master logic from master_irq to bus_irq? The reason being: > master transaction cannot be restarted when aspeed-i2c is running in slave state and > receives STOP interrupt, because aspeed_i2c_master_irq won't be called in this case. Even in that case, master can be restarted properly because slave_irq will be called first because master is in MASTER_PENDING state, so the slave_irq handles the STOP interrupt as well, and then master_irq will be called with SLAVE_INACTIVE state so the aspeed_i2c_do_start can be called eventually. Also, this is right point to call the aspeed_i2c_do_start because master state will be changed to MASTER_START by the aspeed_i2c_do_start and we have to do remaining handling for the MASTER_START in the master_irq by falling through after the call. Thanks, Jae _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel