Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161568AbbKENze (ORCPT ); Thu, 5 Nov 2015 08:55:34 -0500 Received: from mga01.intel.com ([192.55.52.88]:14354 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161530AbbKENzc (ORCPT ); Thu, 5 Nov 2015 08:55:32 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,247,1444719600"; d="scan'208";a="843274982" Date: Thu, 5 Nov 2015 15:52:16 +0200 From: Mika Westerberg To: Xiangliang Yu Cc: andriy.shevchenko@linux.intel.com, jarkko.nikula@linux.intel.com, wsa@the-dreams.de, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Ken.Xue@amd.com, Vincent.Wan@amd.com, Ray.Huang@amd.com, Annie.Wang@amd.com, Tony.Li@amd.com Subject: Re: [PATCH 1/1] I2C: designware: fix IO timeout issue for AMD controller Message-ID: <20151105135216.GN1509@lahna.fi.intel.com> References: <1446726884-30558-1-git-send-email-Xiangliang.Yu@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1446726884-30558-1-git-send-email-Xiangliang.Yu@amd.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3463 Lines: 91 On Thu, Nov 05, 2015 at 08:34:44PM +0800, Xiangliang Yu wrote: > Because of some hardware limitation, AMD I2C controller can't > trigger next interrupt if interrupt status has been changed > after clearing interrupt status bits. Then, I2C will lost > interrupt and IO timeout. > > According to hardware design, this patch implements a workaround > to disable i2c controller interrupt after clearing interrupt bits > when entering ISR and to enable i2c interrupt before exiting ISR. > > To reduce the performance impacts on other vendors, use unlikely > function to check flag in ISR. > > Signed-off-by: Xiangliang Yu > --- > drivers/i2c/busses/i2c-designware-core.c | 6 ++++++ > drivers/i2c/busses/i2c-designware-core.h | 1 + > drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++++ > 3 files changed, 11 insertions(+) > > diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c > index 7441cdc..04e7b65 100644 > --- a/drivers/i2c/busses/i2c-designware-core.c > +++ b/drivers/i2c/busses/i2c-designware-core.c > @@ -783,6 +783,9 @@ irqreturn_t i2c_dw_isr(int this_irq, void *dev_id) > > stat = i2c_dw_read_clear_intrbits(dev); What if the status changes right here, before you go and mask the interrupt? > > + if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK)) > + i2c_dw_disable_int(dev); > + > if (stat & DW_IC_INTR_TX_ABRT) { > dev->cmd_err |= DW_IC_ERR_TX_ABRT; > dev->status = STATUS_IDLE; > @@ -811,6 +814,9 @@ tx_aborted: > if ((stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET)) || dev->msg_err) > complete(&dev->cmd_complete); > > + if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK)) > + dw_writel(dev, DW_IC_INTR_DEFAULT_MASK, DW_IC_INTR_MASK); The driver disables TX interrupt when it is not needed anymore or when TX gets aborted but the above will re-enable all interrupts regardless. Is that the intention? > + > return IRQ_HANDLED; > } > EXPORT_SYMBOL_GPL(i2c_dw_isr); > diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h > index 9630222..808ef6a 100644 > --- a/drivers/i2c/busses/i2c-designware-core.h > +++ b/drivers/i2c/busses/i2c-designware-core.h > @@ -111,6 +111,7 @@ struct dw_i2c_dev { > > #define ACCESS_SWAP 0x00000001 > #define ACCESS_16BIT 0x00000002 > +#define ACCESS_INTR_MASK 0x00000004 > > extern u32 dw_readl(struct dw_i2c_dev *dev, int offset); > extern void dw_writel(struct dw_i2c_dev *dev, u32 b, int offset); > diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c > index 472b882..0c59357 100644 > --- a/drivers/i2c/busses/i2c-designware-platdrv.c > +++ b/drivers/i2c/busses/i2c-designware-platdrv.c > @@ -251,6 +251,10 @@ static int dw_i2c_probe(struct platform_device *pdev) > dev->rx_fifo_depth = ((param1 >> 8) & 0xff) + 1; > dev->adapter.nr = pdev->id; > } > + > + if (!strncmp(pdev->name, "AMD0010", 7)) > + dev->accessor_flags |= ACCESS_INTR_MASK; > + Can't you put this to ->driver_data? For example it could refer to a configuration structure that then contains quirk flags. > r = i2c_dw_init(dev); > if (r) > return r; > -- > 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/