Received: by 10.223.185.116 with SMTP id b49csp7050774wrg; Wed, 28 Feb 2018 21:59:18 -0800 (PST) X-Google-Smtp-Source: AG47ELsVcgTMXzLgXinhjFnTdxS02zDz3GUteT+nFLscWAoJlcDIUTfjjZGqJS1F31Ejql7D5HCp X-Received: by 10.101.88.76 with SMTP id s12mr597937pgr.385.1519883958715; Wed, 28 Feb 2018 21:59:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519883958; cv=none; d=google.com; s=arc-20160816; b=ayf1Ismj4amyrghG7dHxhnI08+MGei/lCs1IUs0Bmm9c80oa0xbOut5DBNFUd/ufcb i+wpqV0EwCy4yiDQWVjL5ATKv/S8h+0luFaY9xzZimb7RJ+j8J/3PtL8l0Gu1qyr5cnL rWccKd54Vc3CpsTGrFn65jJktUZGje+hPkKVlnsj7RC2c133mWZWdkffx6u4bmbiLhAH wZxmSF4Rxs9MfK4o5OLevMisaHowrtHwlN6UucveiOdXYbsQ/W4wetIeo0BZ8p1M/BG/ o0kAzHMTCAM7s5N+jQoyUYqkxYz8CbGUCjsm+r+EOAHPNABuJBeLdz1CKqVTemsk6P/o JjZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=pNMrRT0bqp3gY/6Umtd/FQGgcOi5idU0mTcaklavr2Y=; b=aqxcWIEc5OAvjJWTAQG/ZzqGKxFLKseyK+IU1rlpyjUk5cc+HyFDQyLzcN8aET9lqC WtQnzgUg8A+pxpNdlZZl8MrwQCApqViSYFt1LlFxVtfGOCt0gXJ3bQb+vwo3E3Rxf465 Gt4z9meMLLZPhLK8ke3qJMGKdH7LWJ658B2/2GjK9Uq5nmslKg7m6gGtKBc7p3lJTeCc Og2VhC7hgQUkROrEZZHOwKq1d2Q4jDmyKx6OMz/C0wRolPBj0iRpfUhL9aeMyMLvMurZ iSr0MO2dv32igRipvDkPl5vOWrW5U+0+mqYgVVmXTFj7StPS6YJjF9r7nIHVRlfx6fXV I6VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector1-synaptics-com header.b=Vv4ey5Gt; 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 e28si2051757pgn.311.2018.02.28.21.59.02; Wed, 28 Feb 2018 21:59:18 -0800 (PST) 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; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector1-synaptics-com header.b=Vv4ey5Gt; 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 S966221AbeCAF6U (ORCPT + 99 others); Thu, 1 Mar 2018 00:58:20 -0500 Received: from mail-by2nam03on0055.outbound.protection.outlook.com ([104.47.42.55]:26517 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966089AbeCAF6Q (ORCPT ); Thu, 1 Mar 2018 00:58:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector1-synaptics-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=pNMrRT0bqp3gY/6Umtd/FQGgcOi5idU0mTcaklavr2Y=; b=Vv4ey5GtY1ii0ZxxGlyvp8BFap4eRwf4MUieLLoIxkaAGucUNa57fac4tuE1CuPlt68ADmZ1QQ+5IqTE8EzoaUhaSO1Y+1jsmV+xjFi0FD6rjr909kGuHmYOXQPdea1JO3g55AnEszvgOLzBFhB7RpcQEgPbEV7lMpJ+71HWHO4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by BN6PR03MB2627.namprd03.prod.outlook.com (10.173.143.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Thu, 1 Mar 2018 05:58:11 +0000 Date: Thu, 1 Mar 2018 13:57:55 +0800 From: Jisheng Zhang To: Evgeniy Didin , Jaehoon Chung Cc: , Alexey Brodkin , Eugeniy Paltsev , Douglas Anderson , "Ulf Hansson" , Andy Shevchenko , Shawn Lin , Vineet Gupta , , , Subject: Re: [PATCH v4] mmc: dw_mmc: Fix the DTO/CTO timeout overflow calculation for 32-bit systems Message-ID: <20180301135755.7e26f12e@xhacker.debian> In-Reply-To: <20180228115318.20154-1-Evgeniy.Didin@synopsys.com> References: <20180228115318.20154-1-Evgeniy.Didin@synopsys.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: HK2PR04CA0074.apcprd04.prod.outlook.com (10.170.154.146) To BN6PR03MB2627.namprd03.prod.outlook.com (10.173.143.138) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f5002b53-0301-4e35-6b7c-08d57f396c1b X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:BN6PR03MB2627; X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2627;3:vmLR1djOxtcHXYKW8mE6ld4gan0MpkE623EFa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gxx6e/mEhKf7cCWFyXwiGUuTNV7ZXo2yZp9RqDtI3ym2RZZPnt/pj3kYpTRxnx+xM0KedRAZWrP+Z/5yEpKQLExjgLqPYb1YE8HnsA+JipzHaWu6KkhS9Oxe6uOq0L1L8lCxk/HEV0c2LUaHNE0KdoMzMmyMjXp7q1u8j6qhRz24fMONz6Q9tqtTLtU8GH/Aw/u5Dj7C3GR6YhptZZmnsMpw6Rymxx+f5L/daQ2Z6v4Ycsmg=;4:NjBKVAHiDF8j36Kroaf+WtKF1pblI60tk71iW4ThhxjnKlh65GvCNK7dLOWKCL4fFipP4RjJJVbgZ9mnDZWSIglUtwdKQEVnvGdeVu1YKQNYDeHDhlyjOOuoSrgTS47lb/EDnjbJ9VuzRhLwLfDGXfZCjLMo6SrUg6I2rjq0BsRzleyDfV2SCh1201+s28OFD+z12fIIkk7i4URxPkZKW1yeJcJIqODfmDF3ZiIuVXdl2zYwXsZWRqwTxpbvTKYetzf17vPlPBMUNw8pnrxUNuMFFSSrdyqbaQwp40+TF+WUDvziw0v1gIXJrI/eoJLdxb2J9BRPVGTqzxUYsvGDWdV2lFJTKbTuzuD2xmtqjs41gbZDZr2gtJbJX1Y1zl/w X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(85827821059158)(258649278758335); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231220)(944501161)(52105095)(6041288)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:BN6PR03MB2627;BCL:0;PCL:0;RULEID:;SRVR:BN6PR03MB2627; X-Forefront-PRVS: 05986C03E0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(366004)(396003)(39860400002)(39380400002)(346002)(376002)(199004)(189003)(1076002)(81156014)(72206003)(478600001)(2950100002)(229853002)(81166006)(16526019)(39060400002)(6506007)(2906002)(26005)(50466002)(186003)(386003)(9686003)(6246003)(55016002)(316002)(54906003)(110136005)(6666003)(68736007)(230700001)(33896004)(50226002)(53936002)(8676002)(8936002)(66066001)(105586002)(47776003)(4326008)(25786009)(5660300001)(305945005)(52116002)(7736002)(7696005)(3846002)(97736004)(6116002)(23726003)(76176011)(106356001)(7416002)(86362001)(39210200001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR03MB2627;H:xhacker.debian;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR03MB2627;23:jsuyTORtcK9HSNn4nJFfrKorVpQ8BhJxYLzTQvSkm?= =?us-ascii?Q?Xy2YvtjBv6WCppNUhRAm6ur8ifQJlCoKZ31cnmEVb12XNaXZYk5rM5qZBFZp?= =?us-ascii?Q?o03iapgUsVvKnWjgGWR5MWY7C5JnF5EYsLG19e5Uc6PIaV59LmtQf4L/ESQr?= =?us-ascii?Q?C5LBwYFhQvigUgFSRv0w4oanwG79tQzx7VAoRYYTyvIaj7S75PWBDn26uO2T?= =?us-ascii?Q?zB15nAtTgSI3kGjX+I0Ao6IyRlssahpM3xzhtAxZNQQUE1mOUeu0wme+gz6C?= =?us-ascii?Q?Xlot6MaqAAo+zIVl1Jz87KNuTbCPAw6BxVBB/ENN+ya6WwLVLI8Y7pvpSjnt?= =?us-ascii?Q?GyjL9CIEHRxWVam/viWKsUluyj0uh7mvl3FHaS3gYD7X60013wyVl0g+ubQz?= =?us-ascii?Q?XKkACT5FgDy5i8Z22nY9ZAog2tZJvK2YzTAVX6G9vVEudpEqqlYPrsuV+Zgj?= =?us-ascii?Q?NdFIX2rf+puBh7yyRaL5V54tIb8qKoFn9pHZolZaI1wonsT/T3qorG81cBK3?= =?us-ascii?Q?u5DalmdtSTpqHdlPb+h4LBv4Axv15iA+awLVR/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b7bQ3V1A+HM0Ph3NagRG/tep4RKuif6GqV/XJsR/iESLUMpK5V1ibkP0OK9GY7N/Fi8ZV2jwTq3YgJ0+4HGH7T4ng/xE49QYhdL0YlMOmP603rVe733C1gfKlR4PT4+t9RCSGy443/1nHtxzOSfEAJOzQHLBVxMcAIgbPm5t3HSB9JWTC5KFzhPxK324bVD/qPDI4z0y7YBdtSQ=;5:7zhQiUi85DtPOlwBJm/pzpysGlPgwtlqfNoBA6ALZc5o35qDFynDAnhATgzxuFvqzEseuLKLxa9ALUtXWj/WYkHAPSELeisUQG7mmXNG9AEaCmgD6T2LKsXEyqq4psP+HtE6TVGzoO243AKCJM56OQn8198rmHiiyYlxnIbGhJk=;24:3miZ8KS6SIyPk0+4oct3XelmPw7VihB90YaKlSI10Fs+OLPMFFcUP/RTajtqAV9iYhO4/94doyxhyu7isIE8XtZO8mCgzUO6m6Brqz1ZK8M=;7:Us6pGGTfWVj7U7xpmUhjKiiQ+cIsBoSmy8Hc+sJK28OlHJZisdpblBEiNxEpqBRfSqD/Jyh3XXNoDBwxheh/fFD1T+I46zNMFNVI/VcscspsZgSQYgkBuA3ixiDnRJu/bNQhRM/D7WW+6GbYiNfqNXkcISJZkyXQrkbH4e+z6ogm3B27KMu/N9nGJzi0raludi7ks4VGQBg8bxunlyVeoWUoU3x6GFIZhfktYs3bpcJ9DR2ySs6rnFklqGWbElOu SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2018 05:58:11.2017 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f5002b53-0301-4e35-6b7c-08d57f396c1b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2627 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 28 Feb 2018 14:53:18 +0300 Evgeniy Didin wrote: > In commit 9d9491a7da2a ("mmc: dw_mmc: Fix the DTO timeout calculation") and > commit 4c2357f57dd5 ("mmc: dw_mmc: Fix the CTO timeout calculation") > have been made changes which cause multiply overflow for 32-bit systems. > The broken timeout calculations leads to unexpected ETIMEDOUT errors and > causes stacktrace splat (such as below) during normal data exchange > with SD-card. > > | Running : 4M-check-reassembly-tcp-cmykw2-rotatew2.out -v0 -w1 > | - Info: Finished target initialization. > | mmcblk0: error -110 transferring data, sector 320544, nr 2048, cmd response > | 0x900, card status 0x0 > > DIV_ROUND_UP_ULL helps to escape usage of __udivdi3() from libgcc and so > code gets compiled on all 32-bit platforms as opposed to usage > of DIV_ROUND_UP when we may only compile stuff on a very few arches. > > Lets cast this multiply to u64 type which prevents overflow. Reviewed-by: Jisheng Zhang > > Tested-by: Vineet Gupta > Reported-by: Vineet Gupta # ARC STAR 9001306872 HSDK, sdio: board crashes when copying big files > Fixes: 9d9491a7da2a ("mmc: dw_mmc: Fix the DTO timeout calculation") > Fixes: 4c2357f57dd5 ("mmc: dw_mmc: Fix the CTO timeout calculation") > > Signed-off-by: Evgeniy Didin > > CC: Alexey Brodkin > CC: Eugeniy Paltsev > CC: Douglas Anderson > CC: Ulf Hansson > CC: Andy Shevchenko > CC: Jisheng Zhang > CC: Shawn Lin > CC: Vineet Gupta > CC: linux-kernel@vger.kernel.org > CC: linux-snps-arc@lists.infradead.org > Cc: > --- > Changes since v3: > -Switch DIV_ROUND_UP macro to DIV_ROUND_UP_ULL > -Make one patch from two patches > -Modify commit message > > Changes sinve v2: > -add fix for cto_ms > > Changes since v1: > -uint64_t switched to u64 > > drivers/mmc/host/dw_mmc.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c > index 0aa39975f33b..cba534d4c81b 100644 > --- a/drivers/mmc/host/dw_mmc.c > +++ b/drivers/mmc/host/dw_mmc.c > @@ -409,7 +409,9 @@ static inline void dw_mci_set_cto(struct dw_mci *host) > cto_div = (mci_readl(host, CLKDIV) & 0xff) * 2; > if (cto_div == 0) > cto_div = 1; > - cto_ms = DIV_ROUND_UP(MSEC_PER_SEC * cto_clks * cto_div, host->bus_hz); > + > + cto_ms = DIV_ROUND_UP_ULL((u64)MSEC_PER_SEC * cto_clks * cto_div, > + host->bus_hz); > > /* add a bit spare time */ > cto_ms += 10; > @@ -1944,8 +1946,9 @@ static void dw_mci_set_drto(struct dw_mci *host) > drto_div = (mci_readl(host, CLKDIV) & 0xff) * 2; > if (drto_div == 0) > drto_div = 1; > - drto_ms = DIV_ROUND_UP(MSEC_PER_SEC * drto_clks * drto_div, > - host->bus_hz); > + > + drto_ms = DIV_ROUND_UP_ULL((u64)MSEC_PER_SEC * drto_clks * drto_div, > + host->bus_hz); > > /* add a bit spare time */ > drto_ms += 10;