Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5234420imd; Tue, 30 Oct 2018 14:10:59 -0700 (PDT) X-Google-Smtp-Source: AJdET5fZ7WhXUTE2U/oDHtTj3EOtbEqa7DnYRiGoNGXOGQgWVbmfOyUXgDm9AdnTvkJbquuEMyIo X-Received: by 2002:a63:6c4a:: with SMTP id h71-v6mr332804pgc.326.1540933859277; Tue, 30 Oct 2018 14:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540933859; cv=none; d=google.com; s=arc-20160816; b=hXoXB5N+3bosuPs3/0AnWlbEc8SCnIw1G//ztI480YSBJjIEGMAJvLvtmZcFcu66va XH6kdk4yXx8WFOU+5WzcZ6xouN0I1rKBrmZbOaYekqC9A2BpOt9af1PzmWSRnIu/NAmF 2XTaJmADiXoDnKDfELwUqGa5TqLCRtgAdx9L3WAr1zLozcEzhyNq2w97uguLiRmbT9PR C9vv5E8xKqgZhwd/+/4ja0lwzCZdxpD0H5llhwLwNI08nBYVILT1YMYIDcCoLZ24zY0w tvKQRFqu+SFJeTSBVWtmrtm8TQTcnd3b9dGdXUQHFxIlAUl4veJ4HbgEsSubCLAuITmS KbvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=VEzVsIB5ihUuj0uf9fjclwkP4dzs8tVesqHaPHVi4YE=; b=xByOfnP8gTdTUG1m5kNZc1O9FiEqcnq1+GhYhuXrjxawRd0O+FpGIdz9vAj848ak88 6fwikrkykLDPWWfJ3ZdQxdo1eQMbZQ7spnIMZZAR2Y9M5PehT0hIC6af9kAfDdhh/G4V 4PTrPzoWk/VIgGK3JqFZ1yZFMbI82VC06eM3cIy/S80MNM027MTGDbCx8+31GjAGbgNs KVR6BGef+fdYjERCg26IdjuXQ+iBkWxE2Eh7CeP3vvZvzVKCub848WV+Xrc8BpMaiOiH kOUGQheu1LkmURZRn6a4bfII3AI0KvAytlQrGGB4ew6dDx+FhhkNicKe0wsCkffyXM3z aXDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4-v6si25589556pff.140.2018.10.30.14.10.43; Tue, 30 Oct 2018 14:10:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727465AbeJaGEZ (ORCPT + 99 others); Wed, 31 Oct 2018 02:04:25 -0400 Received: from mga09.intel.com ([134.134.136.24]:28959 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725921AbeJaGEZ (ORCPT ); Wed, 31 Oct 2018 02:04:25 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2018 14:09:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,446,1534834800"; d="scan'208";a="100110045" Received: from maru.jf.intel.com ([10.54.51.77]) by fmsmga002.fm.intel.com with ESMTP; 30 Oct 2018 14:09:19 -0700 From: Jae Hyun Yoo To: Wolfram Sang , Brendan Higgins , Rob Herring , Joel Stanley , Benjamin Herrenschmidt , Mark Rutland , Andrew Jeffery , linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: Jarkko Nikula , James Feist , Vernon Mauery , Jae Hyun Yoo Subject: [PATCH i2c-next v9 0/5] i2c: aspeed: Add bus idle waiting logic for multi-master use cases Date: Tue, 30 Oct 2018 14:09:11 -0700 Message-Id: <20181030210917.32711-1-jae.hyun.yoo@linux.intel.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In multi-master environment, this driver's master cannot know exactly when a peer master sends data to this driver's slave so a case can be happened that this master tries to send data through the master_xfer function but slave data from peer master is still being processed by this driver. To prevent state corruption in the case, this patch adds checking code if any slave operation is ongoing and it waits up to the bus timeout duration before starting a master_xfer operation. To support this change, it introduces changes on i2c-core-base to make that able to read the bus timeout and master transfer retries count values from device tree properties. Please review this patch set. Thanks, -Jae Changes since v8: - Fixed a build break when CONFIG_I2C_SLAVE is not set. Changes since v7: - Simplified the bus idle waiting logic using jiffy based timer APIs. Changes since v6: - Changed the 'timeout-ms' property name to 'bus-timeout-ms'. Changes since v5: - Changed using of property reading API to device_property_read_u32. Changes since v4: - Moved the property reading code into i2c-base-core and changed the property name to 'timeout-ms'. Also, added '#retries' property reading code. - Changed bus busy checking logic to make that check slave_state instead of 'Transfer Mode State Machine' reg value. Changes since v3: - Changed the property name to 'timeout' and made it use the default setting in i2c-core when not specified. Changes since v2: - Changed the property name to 'aspeed,timeout' and made it to update the adapter's timeout configuration. Changes since v1: - Changed define names of timeout related. Jae Hyun Yoo (5): dt-bindings: i2c: Add 'bus-timeout-ms' and '#retries' properties as common optional i2c: core: Add support reading of 'bus-timeout-ms' and '#retries' properties dt-bindings: i2c: aspeed: Add 'bus-timeout-ms' property as an optional property i2c: aspeed: Remove hard-coded bus timeout value setting i2c: aspeed: Add bus idle waiting logic for multi-master use cases .../devicetree/bindings/i2c/i2c-aspeed.txt | 3 + Documentation/devicetree/bindings/i2c/i2c.txt | 6 ++ drivers/i2c/busses/i2c-aspeed.c | 56 +++++++++++++------ drivers/i2c/i2c-core-base.c | 12 +++- 4 files changed, 59 insertions(+), 18 deletions(-) -- 2.19.1