Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2972651imu; Sun, 9 Dec 2018 14:01:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/X0sdTBk+6Lkd1SceYnccmhfEeK1ni5BUePwb/7AM2TXuKFQVf/LMZ0SmwO+NCulRYOf8wJ X-Received: by 2002:a17:902:20c6:: with SMTP id v6mr10018856plg.156.1544392908117; Sun, 09 Dec 2018 14:01:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544392908; cv=none; d=google.com; s=arc-20160816; b=nWbXmZHA73A7p9/fc7CvmFAoTutRLdNRIgEKqiY34lmBKsRtZ481DInW2p+Ryq/2Jo /7cXcun0PivK4SenM9R+7cJiUYyApqTjdRVKiEUcApFHsWAqqWP7c0Y9ILiazxLm/wgB qSd2sBngYVQQ8T11Xy85S4utwmraY6nOD0xEpGQlyrX4y7OR6wU8Q7qiCebmo/rI2mZT deeMIjYFnalFZ3Tt6zockVdM3p8O50ZmCH0LPqcx58dNQTWkSHmH0m2G759rgY7BssnQ Ys7fyGFLfFi96spI8BXt8UHoV72QRfWktwPEEjswFruHTiXMk3HbJgrsD8uQcrgj0nhH jPOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=MgeVuDL5gN7UcWyGZp9rzuG50ENli+7/mkH7qHNRYd8=; b=zfCpeeb2YsbHA8fPW/5TNkpn3OJdGOHM5nwsYQE+FkGzZn6EoNp4e6oWom7l73GYl2 IXHy17yhErIJfzL8kT9+hP1P2Xqbnsu9vKtNdG+PpwtUekkyoJmX3mUC4YnNT1xGsP3l vjZb6llRz1ipUQvEt9LQYFKgm51FmiVzA0zQTnOQs4RZlt62EEE+NGyYWX1J3Q2CwJMI BMeNmQa5TT2jRHrX5qq5+igCFbZVmRr20x6ixC3ZVVjkanZF/2l1MHDtqkU0GVejKgty ImYv8eV2B/Y7Vc0QDREPQII7BiU5THF5P+XmVncSLpLrzmF/RMbYXayVHTgSLomUR4p3 xHKQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si7561828pgv.123.2018.12.09.14.01.32; Sun, 09 Dec 2018 14:01:48 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727148AbeLIV66 (ORCPT + 99 others); Sun, 9 Dec 2018 16:58:58 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:36232 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726753AbeLIVzj (ORCPT ); Sun, 9 Dec 2018 16:55:39 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW730-0002iZ-Qs; Sun, 09 Dec 2018 21:55:35 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72h-0003Xp-5b; Sun, 09 Dec 2018 21:55:15 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Shubhrajyoti Datta" , "Wolfram Sang" , "Michal Simek" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 222/328] i2c: xiic: Make the start and the byte count write atomic In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Shubhrajyoti Datta commit ae7304c3ea28a3ba47a7a8312c76c654ef24967e upstream. Disable interrupts while configuring the transfer and enable them back. We have below as the programming sequence 1. start and slave address 2. byte count and stop In some customer platform there was a lot of interrupts between 1 and 2 and after slave address (around 7 clock cyles) if 2 is not executed then the transaction is nacked. To fix this case make the 2 writes atomic. Signed-off-by: Shubhrajyoti Datta Signed-off-by: Michal Simek [wsa: added a newline for better readability] Signed-off-by: Wolfram Sang Signed-off-by: Ben Hutchings --- drivers/i2c/busses/i2c-xiic.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -504,6 +504,7 @@ static void xiic_start_recv(struct xiic_ { u8 rx_watermark; struct i2c_msg *msg = i2c->rx_msg = i2c->tx_msg; + unsigned long flags; /* Clear and enable Rx full interrupt. */ xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK | XIIC_INTR_TX_ERROR_MASK); @@ -519,6 +520,7 @@ static void xiic_start_recv(struct xiic_ rx_watermark = IIC_RX_FIFO_DEPTH; xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rx_watermark - 1); + local_irq_save(flags); if (!(msg->flags & I2C_M_NOSTART)) /* write the address */ xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, @@ -529,6 +531,8 @@ static void xiic_start_recv(struct xiic_ xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, msg->len | ((i2c->nmsgs == 1) ? XIIC_TX_DYN_STOP_MASK : 0)); + local_irq_restore(flags); + if (i2c->nmsgs == 1) /* very last, enable bus not busy as well */ xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK);