From patchwork Mon Nov 10 21:31:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 409088 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C7AF614011B for ; Tue, 11 Nov 2014 08:31:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751527AbaKJVbm (ORCPT ); Mon, 10 Nov 2014 16:31:42 -0500 Received: from cantor2.suse.de ([195.135.220.15]:52080 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751218AbaKJVbm (ORCPT ); Mon, 10 Nov 2014 16:31:42 -0500 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2D0EBAAC3; Mon, 10 Nov 2014 21:31:41 +0000 (UTC) Date: Mon, 10 Nov 2014 22:31:39 +0100 From: Jean Delvare To: Linux I2C Cc: Wolfram Sang Subject: [PATCH 3/4] i2c-i801: Check if interrupts are disabled Message-ID: <20141110223139.02aafde4@endymion.delvare> In-Reply-To: <20141110222655.13660613@endymion.delvare> References: <20141110222655.13660613@endymion.delvare> Organization: SUSE Linux X-Mailer: Claws Mail 3.10.1 (GTK+ 2.24.23; x86_64-suse-linux-gnu) MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org There is a control bit in the PCI configuration space which disables interrupts. If this bit is set, the driver should not try to make use of interrupts, it won't receive any. Signed-off-by: Jean Delvare Cc: Wolfram Sang --- drivers/i2c/busses/i2c-i801.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) --- linux-3.18-rc4.orig/drivers/i2c/busses/i2c-i801.c 2014-11-10 22:29:44.416991298 +0100 +++ linux-3.18-rc4/drivers/i2c/busses/i2c-i801.c 2014-11-10 22:29:46.915045662 +0100 @@ -110,12 +110,16 @@ /* PCI Address Constants */ #define SMBBAR 4 +#define SMBPCICTL 0x004 #define SMBPCISTS 0x006 #define SMBHSTCFG 0x040 /* Host status bits for SMBPCISTS */ #define SMBPCISTS_INTS 0x08 +/* Control bits for SMBPCICTL */ +#define SMBPCICTL_INTDIS 0x0400 + /* Host configuration bits for SMBHSTCFG */ #define SMBHSTCFG_HST_EN 1 #define SMBHSTCFG_SMB_SMI_EN 2 @@ -1235,6 +1239,23 @@ static int i801_probe(struct pci_dev *de priv->adapter.timeout = HZ / 5; if (priv->features & FEATURE_IRQ) { + u16 pcictl, pcists; + + /* Complain if an interrupt is already pending */ + pci_read_config_word(priv->pci_dev, SMBPCISTS, &pcists); + if (pcists & SMBPCISTS_INTS) + dev_warn(&dev->dev, "An interrupt is pending!\n"); + + /* Check if interrupts have been disabled */ + pci_read_config_word(priv->pci_dev, SMBPCICTL, &pcictl); + if (pcictl & SMBPCICTL_INTDIS) { + dev_warn(&dev->dev, + "Interrupts are disabled, will use polling\n"); + priv->features &= ~FEATURE_IRQ; + } + } + + if (priv->features & FEATURE_IRQ) { init_waitqueue_head(&priv->waitq); err = request_irq(dev->irq, i801_isr, IRQF_SHARED,