From patchwork Mon May 30 01:09:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 68816 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1159629qge; Sun, 29 May 2016 18:09:59 -0700 (PDT) X-Received: by 10.98.82.77 with SMTP id g74mr32244099pfb.113.1464570596930; Sun, 29 May 2016 18:09:56 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h192si32779846pfc.70.2016.05.29.18.09.56; Sun, 29 May 2016 18:09:56 -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; dkim=fail header.i=@gmail.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 S1161101AbcE3BJd (ORCPT + 30 others); Sun, 29 May 2016 21:09:33 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35067 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753417AbcE3BJS (ORCPT ); Sun, 29 May 2016 21:09:18 -0400 Received: by mail-pf0-f196.google.com with SMTP id f144so13510477pfa.2; Sun, 29 May 2016 18:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=X/6F2iCUJyAZA0pjl4R+lJPBlVk5zvrqb2QQw+vUtSw=; b=0bS2ZeD8cOZp6M1WfsPNCkFTijOcAX+eycjPjc+pl/miReSUSMdHccjeIImrqs6Ydz 4Ydf1PbS74bYn/F2Es1+gTDYBuPMw6YaLaHDXOfNZb8VnPk5CryvbGewkfy/Qv8PaXLp RxigUy9d+fmlLmIPeIitpJou2LajXe8k+6dcuHleO6i29s2rh5GNie5dNQ2tlTg45+al x5ZJHiK0FjmsGrOZAV4sRRcv5eVlUHMpASy1to4+RHcV8tewQIy3R2pEIno+bu2PeKeL UYsO2JLzc7OpUQvus0vwcHVYVFU0t4+v+5y86+6gadVfUM8eItTQvnhVJ90HDFrFEqud 65pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=X/6F2iCUJyAZA0pjl4R+lJPBlVk5zvrqb2QQw+vUtSw=; b=X+2riEsz9XPVlbusdhu6wv/3dVYahdpDbnQ3YpUp1eNXnq89zc+RFeLpQvSI8EayJV NTobvKiO3mMoBMtxC/sxU8Bg+xeQwF+eheZIklLvHXhKnNhMIvWWgAfvnngQIsDJrfsf svWlEJcOIKAbdSf/VS+IID4Y83gsmNJTstAgr4jeQerBshw04/yzv/t6peqTnUGtmpJs pHskdqj1Zm16F0lCDaUQ2i8g9yuqhIAkEI/c+5B1scyxFt+M2ooH/aPJlrg3X1irGH8I IDwKHj7rhFhYBdJOrFJoYt75EsI6o7wKODNgDu6EY8eg2A8ted6F9rEmDg2D+jCp1nZG hZMQ== X-Gm-Message-State: ALyK8tIPG1efce7CNakxHxdug6TYfR8VXJlO9/2xpvZQYamuEy9VxlzM8JCcxbqkcKg5FA== X-Received: by 10.98.35.93 with SMTP id j90mr42759936pfj.10.1464570557558; Sun, 29 May 2016 18:09:17 -0700 (PDT) Received: from serve.minyard.net ([108.19.215.157]) by smtp.gmail.com with ESMTPSA id t8sm42705097paw.16.2016.05.29.18.09.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 May 2016 18:09:16 -0700 (PDT) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:8881:3308:a7ea:195e]) by serve.minyard.net (Postfix) with ESMTPA id C0C62F4D; Sun, 29 May 2016 20:09:12 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 75D8430054E; Sun, 29 May 2016 20:09:08 -0500 (CDT) From: minyard@acm.org To: Jean Delvare , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, minyard@acm.org Cc: Corey Minyard Subject: [PATCH v2 08/10] i2c-i801: Handle a protocol error in byte-by-byte isr Date: Sun, 29 May 2016 20:09:02 -0500 Message-Id: <1464570544-975-9-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1464570544-975-1-git-send-email-minyard@acm.org> References: <1464570544-975-1-git-send-email-minyard@acm.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Corey Minyard If a bad number of bytes is read on a transaction, have it report an error and return -EPROTO for the transaction. Signed-off-by: Corey Minyard --- drivers/i2c/busses/i2c-i801.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index b415948..70da60a 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -230,7 +230,7 @@ struct i801_priv { /* isr processing */ wait_queue_head_t waitq; - u8 status; + int status; /* Command state used by isr for byte-by-byte block transactions */ u8 subcmd; @@ -472,16 +472,18 @@ static void i801_isr_byte_done(struct i801_priv *priv) (priv->count == 0)) { priv->len = inb_p(SMBHSTDAT0(priv)); if (priv->len < 1 || priv->len > I2C_SMBUS_BLOCK_MAX) { - dev_err(&priv->pci_dev->dev, - "Illegal SMBus block read size %d\n", - priv->len); - /* FIXME: Recover */ - priv->len = I2C_SMBUS_BLOCK_MAX; - } else { - dev_dbg(&priv->pci_dev->dev, - "SMBus block read size is %d\n", - priv->len); + /* + * Terminate the transaction here, to avoid + * getting any more interrupts that might + * hold us in an interrupt loop forever. + */ + outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL, + SMBHSTCNT(priv)); + priv->status = -EPROTO; + return; } + dev_dbg(&priv->pci_dev->dev, + "SMBus block read size is %d\n", priv->len); priv->data[-1] = priv->len; } @@ -541,7 +543,10 @@ static irqreturn_t i801_isr(int irq, void *dev_id) status &= SMBHSTSTS_INTR | STATUS_ERROR_FLAGS; if (status) { outb_p(status, SMBHSTSTS(priv)); - priv->status |= status; + if (status < 0) + priv->status = status; + else + priv->status |= status; wake_up(&priv->waitq); }