Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp902357ybl; Wed, 28 Aug 2019 07:01:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDTjr3RxFA/s8cccz+icBtwEXLlNIQKzrQTJL2kIESwHrkPGNwMf1R/1HeRvaEM8Ms6SQ6 X-Received: by 2002:a65:430b:: with SMTP id j11mr3517791pgq.383.1567000870968; Wed, 28 Aug 2019 07:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567000870; cv=none; d=google.com; s=arc-20160816; b=SCsVK+C/rQ9ipRovL0AHTv6dQsbOhDr8y6uNKBtbaYlO3/UJB7NZgFt9zz2D4hkAay pTw9crE9XTseP2yk9OEVNPIZnxk3Smwtie29TkEpuqxupLV7WaEA9f6mWdanHCjIqxCn onnWEA+ig8M+Y7BTMT0JXWlU9TovdzaBqQ5wUnjt/QK3wlHZgLOJX5SL7mC+hdT4G0gh 0FbTmCxmOVEH9R9jdUpHIg1v8YaSHyzGPU76CDhkE7RICYA7tlLNCP4d2V9elRA/kJY3 lKdxMrWPebx/mSkIWk/mE1XI9pPYtgXVmi9S5isUdYXQyu/x5gRZ1DfUzEx3Cdxrl9W9 ddoA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=RjRQhl9R0+eOywU9B6taa17TMxrlTikyxVAA0HBkID8=; b=ZH7B0rkpKuYYNjmtpGkvOgMBlzG0XUcFsMVQnBZwdabQ4PDOdeuLHDU4m73eh6LqWY GVuN2zYHiPx2wzeiuhrpdvoJLo5UWY5Y8GjeLIjuoUvBx8MEx2C0Ho7CpwoHdGtoEPNa VQX0AIE3mfMW4cuSOWgJPpg2NHAuSN2UY21sid9MJtJUG3qPinyPdGzGcM2Rplgc0j9m HS4ZiG+nHL3OpxpvvXtMJ1m3Od9BaWiSdXpaCTLEM8FI51YprOlteD31iULKS1w/gGfK Ha0Mgz5YL4zJ9IpaRRaqLzHzMkqPWtbTVpeVOfVSUJ77Me42BPje+9apNi1hOk9TrE5i 0Khw== 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 143si2152328pgc.479.2019.08.28.07.00.53; Wed, 28 Aug 2019 07:01:10 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726575AbfH1N6T (ORCPT + 99 others); Wed, 28 Aug 2019 09:58:19 -0400 Received: from mx2.suse.de ([195.135.220.15]:37206 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726506AbfH1N6R (ORCPT ); Wed, 28 Aug 2019 09:58:17 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7ED8EAC7D; Wed, 28 Aug 2019 13:58:15 +0000 (UTC) Date: Wed, 28 Aug 2019 15:58:22 +0200 From: Jean Delvare To: lingyxu Cc: Krzysztof Adamski , WladislavWiebe , , Subject: Re: [PATCH] i801_smbus: clear SMBALERT status bit and disable SMBALERT interrupt Message-ID: <20190828155822.7cb13a7b@endymion> In-Reply-To: <1565577634-18264-1-git-send-email-lingyan.xu@nokia-sbell.com> References: <1565577634-18264-1-git-send-email-lingyan.xu@nokia-sbell.com> Organization: SUSE Linux X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lingyan, On Mon, 12 Aug 2019 10:40:34 +0800, lingyxu wrote: > From: Lingyan Xu > > In current i801 driver, SMBALERT interrupt is allowed > (Slave Command Register bit2 is 0). > But these is no handler for SMBALERT interrupt in i801_isr, > if there is SMBALERT interrupt asserted and deasserted, > i801 will have an irq flood for the related status bit is setted. > > So SMBALERT interrupt handler is needed, and also, SMBALERT interrupt > will be generated from time to time if slave chip have some fault. > So disable SMBALERT interrupt is also needed. > > About the solution, > please see http://www.farnell.com/datasheets/1581967.pdf > Page632 P640 for more. > > Signed-off-by: Lingyan Xu > --- > drivers/i2c/busses/i2c-i801.c | 7 ++++++- > 1 files changed, 6 insertions(+), 1 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c > index f295693..033bafe 100644 > --- a/drivers/i2c/busses/i2c-i801.c > +++ b/drivers/i2c/busses/i2c-i801.c > @@ -661,9 +661,11 @@ static irqreturn_t i801_isr(int irq, void *dev_id) > * Clear irq sources and report transaction result. > * ->status must be cleared before the next transaction is started. > */ > + > + outb_p(status, SMBHSTSTS(priv)); > + > status &= SMBHSTSTS_INTR | STATUS_ERROR_FLAGS; > if (status) { > - outb_p(status, SMBHSTSTS(priv)); > priv->status = status; > wake_up(&priv->waitq); > } Looks scary. Writing the whole value of SMBHSTSTS back to itself without selecting which bits you write is dangerous. Specifically, writing back SMBHSTSTS_BYTE_DONE, SMBHSTSTS_INUSE_STS and SMBHSTSTS_HOST_BUSY could have unexpected consequences. I would feel much better if you would just explicitly add SMBHSTSTS_SMBALERT_STS to the list. > @@ -1810,6 +1812,9 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) > /* Default timeout in interrupt mode: 200 ms */ > priv->adapter.timeout = HZ / 5; > > + /* Disable SMBALERT interrupt */ > + outb_p(inb_p(SMBSLVCMD(priv)) | BIT(2), SMBSLVCMD(priv)); Please give SMBSLVCMD's BIT(2) a name and define it after SMBSLVCMD_HST_NTFY_INTREN. Also it is mandatory to restore the value of SMBSLVCMD before returning the control back to the BIOS. Currently this is only being done when the FEATURE_HOST_NOTIFY bit is set because that's the only case where we change the value of that register, but if we change it unconditionally then it must be saved and restored unconditionally too. > + > if (dev->irq == IRQ_NOTCONNECTED) > priv->features &= ~FEATURE_IRQ; > That being said, if you see this interrupt flood, it means that at least one device on your SMBus would benefit from SMBus Alert being supported. The infrastructure is already there as we added support in a few I2C bus drivers already. So maybe instead of silencing the interrupts, we could add proper SMBus Alert support to the i2c-i801 driver? Did you figure out which device is raising the SMBus Alert and why? -- Jean Delvare SUSE L3 Support