From patchwork Fri Apr 15 17:29:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 8854161 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1D0239F3A0 for ; Fri, 15 Apr 2016 17:52:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 05FD520256 for ; Fri, 15 Apr 2016 17:51:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9AEA20218 for ; Fri, 15 Apr 2016 17:51:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750768AbcDORv5 (ORCPT ); Fri, 15 Apr 2016 13:51:57 -0400 Received: from mail-by2on0091.outbound.protection.outlook.com ([207.46.100.91]:43061 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750709AbcDORv4 (ORCPT ); Fri, 15 Apr 2016 13:51:56 -0400 Received: from CH1PR03CA002.namprd03.prod.outlook.com (10.255.156.147) by BN1PR0301MB0705.namprd03.prod.outlook.com (10.160.78.12) with Microsoft SMTP Server (TLS) id 15.1.453.26; Fri, 15 Apr 2016 17:37:35 +0000 Received: from BN1BFFO11FD015.protection.gbl (10.255.156.132) by CH1PR03CA002.outlook.office365.com (10.255.156.147) with Microsoft SMTP Server (TLS) id 15.1.466.19 via Frontend Transport; Fri, 15 Apr 2016 17:37:35 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; gmail.com; dkim=none (message not signed) header.d=none; gmail.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD015.mail.protection.outlook.com (10.58.144.78) with Microsoft SMTP Server (TLS) id 15.1.472.8 via Frontend Transport; Fri, 15 Apr 2016 17:37:34 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u3FHb2HK019919; Fri, 15 Apr 2016 10:37:30 -0700 From: Dong Aisheng To: CC: , , , , , , , Subject: [PATCH 09/23] mmc: sdhci: fix incorrect get data interrupt during no data transfer Date: Sat, 16 Apr 2016 01:29:33 +0800 Message-ID: <1460741387-23815-10-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460741387-23815-1-git-send-email-aisheng.dong@nxp.com> References: <1460741387-23815-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131052154553979071; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(586003)(33646002)(47776003)(19580395003)(19580405001)(229853001)(106466001)(85426001)(77096005)(217423001)(5008740100001)(6806005)(81166005)(87936001)(2351001)(4326007)(48376002)(104016004)(189998001)(92566002)(50466002)(36756003)(5003940100001)(2906002)(1096002)(1220700001)(11100500001)(76176999)(50986999)(50226001)(86362001)(575784001)(105606002)(110136002)(2950100001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0301MB0705; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD015; 1:iodQ1rh3syj+OUJZJ9326eTDqhyj6TYr1WwE0B0yKGU35ZGJ7n6B+0YVxtwoZcRUGUhVCpnUuJDeiW9EtOWvapNFGH2KxgJHaEAYA09trlCiD0mi9qBtTze5s954KMFYxxCGItWOJlB3y84AlrffF3hv+GP06zPCy91P77FPoCvXmohO8io6cagF+daNWXH1drVUquqswRBtfXMvpeK0htnVnHqwwu+BqD4snxLQH/ajca8XPAB+oNyBiTdsZz28S9Irj8XuLX6YSrnDaQjjM1+2uCI6f1kCy0I1TayWBT1sHGxfOCFOAyut6CSVi1sZ49NG0VuZk7tg2cvdCnj7kDuqxEryBvV9Qh4WC99ZuhZtc2rZcDb/v/KJDHU4qd9kO++PdTQ5ES//SiDzl9tfNCvY3MJM2YXDfepD07ggSIxVFvACAR3IAiUUc9l8xBqBpKBubInieTcxSStzvEtlGCW7BC3gZav6Rl8ZiuVnG+M024Zq04lN8pIRpEAEkBrBPvdctwFn1sQPFDTFPWa6HWrrFHLKESElYsovFE/RjdfaDu5oFdDs84buZX9RyMuKhY6EbmMpQA9dWazHDrLAZut7IsNlyxTZddwU8PRStTpT/wS96fMZmOhGFuK33kXy MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 1d001ad6-ad60-4c8d-45c7-08d36554a1a1 X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0705; 2:2Ch7RPQ1x+ImnXUcO8ACcOzZvFs4ZcG8bCBoO1GTsN4MVIXzEmRxxhN7kRGxY6Hb2sCHij4T0+5OFtyylQACukFH7e6/ZpDZDI2wlX1s4695s2dzC/WdMniOMxHZy+xhLTdJTkZAlJR79vDcztPYGDkVeTsUghjtUXsoN8grg3RnyAf4XM9mOBr480g2gw6/; 3:BFYooPbey0RD36i4TnRotYTl0C1PB009SDrcjxuaEtZq8dwCtKyg8c4PEvhX/KAVG5a+wzm9/bLWTY37YbQAjWUNY8KFrNC3HLA7Ol+/ZJMJRK78/g8n+gTTd6rVufVvz9OxLbk8dvJDp55DBM4EqNx57IRqg0ILp3TkKrxeLf2g6AddxCrdCb+rkm578AotkncxwDE6/7P0HRnNeQMZcDsyXo0smjjhjPm0M0CBpLs= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR0301MB0705; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0705; 25:Js/PnEBet70NkVCUKfnlvjU+Uf9o/rxm7w7KJs7MHqz2e1t7u5okGeX8h30vdvaUC5Kp0dzSUezMtXg+VSMkxNGo2gp1Ojdb9IeIL6GazrE/tXS3TGsG+OJT3c/P9M1YeqBBTgqa3B8/gy0mp5dIkCgYZXdJaAU1Q/zLLU3smKTB0vFjZz7Izx/ZjevvU7eQTuVVcrpdEKJS1sTsmauUnJDwWUp1SWtAyRxA7dBrkN/BW22FCOHP4mWIn6FzNf640gaGhWTbcMzehSKI19u4/4joY35KepWd04Zsy+8o/G//N2wnzMhkvtCbStbOvhc2/PQfh7E8gliD3eEs/mcr5V+WRHlo0EpUd3Vz6QIOyFLbdDfaMtjQXUTcCfQ8w26gCJ3ZP279UKbkgIT8JTWxTcNq6UE1LwriYEKWmc0JvvZhWMVeUwBOFatIgAD+BVqi2WVW23Xx+5I+bfHVilQTb1Y8JELCdYzCxNpmo1D9BeRxxyaFmcHpb0cGIrzkWKYdvOXLgSUaKfzRF2QjnGuCB84U+qCSRBAVB8MWqbBaruHmaQQypv109gD/KFTdcTqI8aT1II+cAs38zbRvIU5CDgrK53/xrymNwoWkIVPaG3CgrRWSCd6XaPTtimNWyyXIb40d+WOKHZ3+3rZBF+eBDnRRKIajr7eFsd77EL5hCC9AtxH1mlcDjKt3IGYqmXQbhldXA+PHjQ6T68ZRT7zL0w== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(13018025)(13024025)(5005006)(13015025)(13017025)(13023025)(3002001)(10201501046)(6055026); SRVR:BN1PR0301MB0705; BCL:0; PCL:0; RULEID:(400006); SRVR:BN1PR0301MB0705; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0705; 4:Iwk4nUoe1+ajigBi8U7PvzwEZNNznGJCYFBITZXZmzIud6nCTc3Pwg/LnkGLe24GoJuNOzYUoJg57HViQ1dULvBD/4puCVxqvd1bnjaruAYHEsfHMuSMTc45QnZ8xdaBXeEAvIG7SNpAPeDKk5sOlrHzJPpNtKhMLBiBAv4ePPgGtkCfTvWim3SP2zVu5vb7wwKnFs72gbKKrUlxlj5e663YrJ3VBPgXAs9Ad7RyfLZtb6emMZFOYkankxvUvy6rfveyc6DYMFaEPYqoab8stjEghywR7rj7B5taZLRgHZK52A3zdI/C89FCG3WAiJs53+3H+vUBZ2wfyO3C0b989azP/TtMStWk0FgnRmscELgATIC0cplgXTkhZ9IvOXcw9GA33bZTCpF4hZ3pxhJF5K/PcYjofEeu+EeSJks+ewPLEZQEt7bxegQ7w2k7+fNAKcHr0hb7Ko4KbG/EcTO3jF9RwhPi31uRthBWp8Pk+zc= X-Forefront-PRVS: 0913EA1D60 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR0301MB0705; 23:6ZXdbgMF2VF1JUXV048MDhzblcrRmpBmZ489ZBB?= =?us-ascii?Q?dHFST4ZMqb7g9devnBzrCv8uLCAK02N0IbD3DdCMt/bXbc3dcbPcd7TQWm5r?= =?us-ascii?Q?GAmlVXHiyadVUcAoCW9AB1ZLQA+3hA3ky/wcRFnyrkcEGrONjyHR8w1FK9MT?= =?us-ascii?Q?vWSkytMYTUaj+tflBgZwkluubqYP6kcJ1kksLcKDdxz2yPh/tp30KRvR2OO5?= =?us-ascii?Q?bIKVAX+YITP9dw7gD+Nm6HumT6wvI6EtMXHRcKzof7VrjvrIL7MOim0P0ip1?= =?us-ascii?Q?0DpQKvCEbZ3lH8QlA8sp9+0WEJ0lZo0tD8YHgY1ajEUdjpTUXqYLPjli0Kux?= =?us-ascii?Q?GGg8LYAO8PZeuf7eJrrSAOqZa1Y6FNReoMaftCRnFFfWYErTDSJURjVZtFWW?= =?us-ascii?Q?mRXfDOFwVJaB8mXJXGKtvm3DyGbxtTM/M7fcUeJEt5pM4ME4TM15SGMZfPFY?= =?us-ascii?Q?3JpayuW+38BsyHrZZG/gohw6+0x/owfYj7yDEYpRUykrH18vQmPKfRetbMFa?= =?us-ascii?Q?qj9JrqlSlP7TYBCimX8zxdP0LR5BxRIUVlwqGFQwB48j1PiNIqLPsjZE4IDI?= =?us-ascii?Q?vgH4w5EH/Qmap/9XI/DLS2YZW0XDemwAOzqP2Cprx+CbZWrgYz1TpZx87HWb?= =?us-ascii?Q?O4dYvilmpT/KLGdp4obw/4W3JDHUItjNSL8dneI9BHFzqnven0/OwyqgNOx1?= =?us-ascii?Q?mvD/JjrAose4X46UqxM6O9/sGt9KOuaerEs697h5keY91q4FrBL4p7/hj1QK?= =?us-ascii?Q?IJro6x/3mNRxX+hKLsaEArBxKjZS+P6yaBDkI3vUIOaNn9z1X299w5ALI/WX?= =?us-ascii?Q?y3/GEG6T9Uh4oI3vluBX4TvZOzEpMG6K2r4S5QU2w++EitxD8aoWgrd0eJZp?= =?us-ascii?Q?MfQmJveZCiNKqHl9H17detat4qQ2DpMNqW4sLPYv1cKaBz+WQBw5PYKPwVPm?= =?us-ascii?Q?+HZAE5lyU2toIgCSENmmpBHJ0tSm3Xf+ZF02xlyXhKx4vRCnRkybKqzJ4K9i?= =?us-ascii?Q?+xLjLTRXLjKChNK/3tLH/MCO7BxRiF7K4XrD5FynQU7COWcz5SLg2W2WYtHr?= =?us-ascii?Q?weEi51kudB7OBMCosrNItmLBSHrQf0Up3PwEmI+gcHzR4xmAhQNtJGNpLyNd?= =?us-ascii?Q?xWPUuKgrrm2k=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0705; 5:QwSNnQvkLy8kC4xFNr98Q8ewY1v3KN1TIQZHOOAHz7s1Fx2FenUeMstcqe3RLNYHdTmSXz62qbEav76HdVCfAPtbNBWaidwTkk+BxGMDBWL1gVAzA7ApuNlhLNnKuEQg2xemyAngWFN9eIINjPzk2H04ngp8qJX6p/9fqS3bzD0=; 24:qpXFLHt4dKQ0FTWu3Ah4MHANJWP+8qk/wXQmHexwXAnlVsUKJxGKEgB+cdHCVGvIB6svT6hNDFCycHsyeZAFxxq6can69mjo5Dly/6nx61c= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2016 17:37:34.5867 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0301MB0705 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Current code will report the wrong data interrupt got when no data operation in progress assumed by getting !host->data in sdhci_data_irq(). For a data command handling process, the driver will call sdhci_finish_data() and clear host->data in case any data error, then card finish_tasklet will do the rest controller reset work. Before the tasklet got run, however, controllers may report the TC(Transfer Complete) interrupt (SDHCI_INT_DATA_END) a bit later than data CRC error and data end bit error interrupts for single block transfer or the last block of multiblock transfer. Controller usually detects and generates data CRC/end bit error interrupts once one block on the bus is transferred completely. For single block transfer, since there's only one bock to transfer, the controller will report transfer complete interrupt as well, but until the data in controller FIFO has been successfully transferred to memory. The time gap of TC and CRC interrupt depends on the system busy state at that point and memory bus access speed. So it is possible when TC interrupt generated, host->data is already equal to NULL due to cleared by former CRC/Data End Bit error which is reasonable. Thus we DO NOT report the weird data interrupt event for this case. Else we may easily see warning below during SD3.0 card manually tuning process (calling mmc_send_tuning() which is a single block transfer) mmc0: Got data interrupt 0x00000002 even though no data operation was in progress The detailed command log is as follows: [ 1657.920983] mmc0: starting CMD19 arg 00000000 flags 00000035 [ 1657.921009] mmc0: blksz 64 blocks 1 flags 00000200 tsac 150 ms nsac 0 [ 1657.921085] sdhci [sdhci_irq()]: *** mmc0 got interrupt: 0x00200001 [ 1657.921112] sdhci [sdhci_irq()]: *** mmc0 got interrupt: 0x00000002 [ 1657.921131] mmc0: Got data interrupt 0x00000002 even though no data operation was in progress. [ 1657.929761] sdhci: =========== REGISTER DUMP (mmc0)=========== [ 1657.929780] sdhci: Sys addr: 0x3d5d6380 | Version: 0x00000002 [ 1657.929796] sdhci: Blk size: 0x00000040 | Blk cnt: 0x00000001 [ 1657.929814] sdhci: Argument: 0x00000000 | Trn mode: 0x00000013 [ 1657.929831] sdhci: Present: 0x01fd8008 | Host ctl: 0x00000023 [ 1657.929847] sdhci: Power: 0x00000002 | Blk gap: 0x00000080 [ 1657.929863] sdhci: Wake-up: 0x00000008 | Clock: 0x0000000f [ 1657.929879] sdhci: Timeout: 0x0000000f | Int stat: 0x00000000 [ 1657.929896] sdhci: Int enab: 0x107f008b | Sig enab: 0x107f008b [ 1657.929914] sdhci: AC12 err: 0x00000000 | Slot int: 0x00000003 [ 1657.929932] sdhci: Caps: 0x07eb0000 | Caps_1: 0x00002007 [ 1657.929949] sdhci: Cmd: 0x0000133a | Max curr: 0x00ffffff [ 1657.929965] sdhci: Host ctl2: 0x000000c8 [ 1657.929981] sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x8f042208 [ 1657.929995] sdhci: =========================================== [ 1657.930156] mmc0: req done (CMD19): 0: 00000900 00000000 00000000 00000000 [ 1657.930179] mmc0: 0 bytes transferred: -84 It shows we first have a data CRC error interrupt then a data transfer complete interrupt. Then we got the !host->data case in sdhci_data_irq(). CC: stable Signed-off-by: Dong Aisheng --- drivers/mmc/host/sdhci.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 40e3551..2eb0e34 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2325,6 +2325,17 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask) } } + /* + * The "data complete" interrupt is possible to happen a bit + * later than CRC error and data end bit error interrupts + * separately for single block transfer or the last block of + * multiblock transfer. For this case, we DO NOT report the + * weird data interrupt event. + */ + if ((intmask & SDHCI_INT_DATA_END) && + (host->mrq && host->mrq->data && host->mrq->data->error)) + return; + pr_err("%s: Got data interrupt 0x%08x even though no data operation was in progress.\n", mmc_hostname(host->mmc), (unsigned)intmask); sdhci_dumpregs(host);