Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032964AbbKEHux (ORCPT ); Thu, 5 Nov 2015 02:50:53 -0500 Received: from mail-bn1on0094.outbound.protection.outlook.com ([157.56.110.94]:42030 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1031161AbbKEHuv (ORCPT ); Thu, 5 Nov 2015 02:50:51 -0500 X-Greylist: delayed 895 seconds by postgrey-1.27 at vger.kernel.org; Thu, 05 Nov 2015 02:50:51 EST Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; linux.intel.com; dkim=none (message not signed) header.d=none;linux.intel.com; dmarc=permerror action=none header.from=amd.com; X-WSS-ID: 0NXBZRS-08-1F8-02 X-M-MSG: From: Xiangliang Yu To: , , , , , CC: , , , , , Xiangliang Yu Subject: [PATCH 1/1] I2C: designware: fix IO timeout issue for AMD controller Date: Thu, 5 Nov 2015 20:34:44 +0800 Message-ID: <1446726884-30558-1-git-send-email-Xiangliang.Yu@amd.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(428002)(199003)(189002)(86362001)(19580395003)(106466001)(19580405001)(50226001)(87936001)(53416004)(5007970100001)(101416001)(105586002)(47776003)(50986999)(2201001)(48376002)(92566002)(5003940100001)(11100500001)(189998001)(36756003)(77096005)(229853001)(50466002)(5003600100002)(97736004)(5001770100001)(5008740100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN4PR12MB0850;H:atltwp02.amd.com;FPR:;SPF:None;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN4PR12MB0850;2:+1efW9q/dui8QAh8DCWmerw58I5zSyxJ7ut+qqRhXfTxkxB3m4n6R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lrb41lyO3M2Z5HP/GMGNVHMv9g60VO4gDTY+UMOkcP4io9WX27u764175CHEcr8SPLA5p/4196plCyssVIVJK/M4Z9GKcKvWji6hH7dMSevuNOlYF1FLgjg7pK7LxS0WUJmbY3/QXHq+6q4Mo229YI5QReCfKN1oHA/TetSPfASN24yY9BJfyP0qSiVY0+2;4:abnvPYDny2b0soAJRGMmx/dg7mmlw6QaG3uiqw1cRDDBDRg3lIrcSFqGhw24fPPCOFWh++rhCPkA3fZb0s031b86y8/iswSc0R9cMzVOBMtKdztraTl0NmVso8pGNvxgPObl/gACbI574vAU8eF6jUBRG6Ize3P7u6CECIkR4FGfnwe2DowK0yB8dCqPyf5XDgQBWRQYA4FzNq3RpEFdSi9jGxVostti7cDH68K+tfsDETJ3lNc4EwB3el7H13X3s7VRlllCCGOEsoiR4ECdZaU9Aqx77XOyyHYL1hKvWQzRkm1B2qFAEwbI9No1jGRRYXbV6Z0j8K59RZzsREn1DdUXvH0VoLuc8hdLSK23GI/XjOKzmFv0i3OnabZEfiRe X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001);SRVR:BN4PR12MB0850;BCL:0;PCL:0;RULEID:;SRVR:BN4PR12MB0850; X-Forefront-PRVS: 0751474A44 X-Microsoft-Exchange-Diagnostics: 1;BN4PR12MB0850;23:4yBDD5UaHjG9qkb0U+g70uTkH7wZ9jLPlCz6W0lS9tU3S0JA5aEtwav1CoTzhLHiPHtQtQqdpZ5Vc3inBVyd6ZPjcAFlda0VpRXkK+puCSUmpDqz3edrPohJqItp6m1cnPDMqdXf3bwriXFgZjXBfS4dEfDctiLnYlfHHr7k26g27JQL+Z2QqtAhllEtd84NyBG9ZUho/Ti2IbgUoUubi3PvTXakRH8v0fToyO9nk+JD2PJNf0SBMpsFSCbAPwHaMaUJ50qPDZDdyaWTmEd/ir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LGHLOEGT9kfaFhAvSnXb1ULYAVLajBPk/m6iSgX6uXpbvbK88JiEvRyrBQoz9/vEb5rQZWoMwxM/xjk7HGO8V55 SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2015 07:35:53.5897 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.222];Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN4PR12MB0850 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2883 Lines: 78 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); + 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); + 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; + 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/