Return-Path: Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.intel.com (client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=jae.hyun.yoo@linux.intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45VC7x6CLKzDrJv for ; Fri, 21 Jun 2019 05:49:33 +1000 (AEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jun 2019 12:49:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,398,1557212400"; d="scan'208";a="154232478" Received: from maru.jf.intel.com ([10.54.51.75]) by orsmga008.jf.intel.com with ESMTP; 20 Jun 2019 12:49:31 -0700 From: Jae Hyun Yoo To: Brendan Higgins , Benjamin Herrenschmidt , C?ric Le Goater , Joel Stanley , Andrew Jeffery Cc: openbmc@lists.ozlabs.org, Jae Hyun Yoo Subject: [RFC PATCH dev-5.1 4/6] i2c: aspeed: fix master pending state handling Date: Thu, 20 Jun 2019 12:49:20 -0700 Message-Id: <20190620194922.15093-5-jae.hyun.yoo@linux.intel.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620194922.15093-1-jae.hyun.yoo@linux.intel.com> References: <20190620194922.15093-1-jae.hyun.yoo@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Jun 2019 19:49:34 -0000 In case of a master pending state, it should not trigger the master command because this H/W is sharing the same data buffer for slave and master operation, so this commit fixes the issue with making the master command triggering happens 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 6c8b38fd6e64..cde9dbac2d46 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -339,18 +339,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) { @@ -435,7 +436,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); } #endif /* CONFIG_I2C_SLAVE */ -- 2.22.0