Received: by 10.223.185.116 with SMTP id b49csp8553285wrg; Fri, 2 Mar 2018 04:01:12 -0800 (PST) X-Google-Smtp-Source: AG47ELsRDgE/mZ5/iAPayLvgnjHH6YhQyuWH97Dlr/xSUuWHtNxI7RG1EomSWpoCimAIvX1tLFCH X-Received: by 2002:a17:902:7789:: with SMTP id o9-v6mr5189578pll.422.1519992071963; Fri, 02 Mar 2018 04:01:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519992071; cv=none; d=google.com; s=arc-20160816; b=v91LMxu9dqNQFaiSvcer5HGAsI7IRZd+COv36dO7YG01aAPTYbuJIGy8adUyJFGSkW kvfHyl8gewfan+Aukh6bipgc1jueBhnvDI11mXskSJpFu2LuORDXDRq6SK/z3NKs37j7 c97LIgLfkFBwGtuXx+Fs4MIX9VOeViZ2KwM/lfnM8Gx4Vm+BrlRTrhnwWsYN+cagGqtp pR8uyN4Vnp3jkYze1Um4hxKDF6HnO7DWUXXKTbRfFHLCXk7dE//wR7pDMcZpvlwLE1Z7 sGPMA/bXiOG4F32y77cSD4wU8IK0p2UBc5MkTiryO8zZvcbFMC31cAo3z6t/a51n/954 eniw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type :content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:cc:to:subject:dkim-signature :dkim-filter:arc-authentication-results; bh=yaK5h89K9BY+pwa2J8R5taymXhEMi3INND0bHj3Ajx0=; b=IsOw+Kl0eYkO/smOE8tiN/3WlvJMc3hzh4FPG5ssysjgPqYHRe7Ly5DOh1WZHyx2md vmW/kAM0ftpgNFfiGqqV3PVFAHvqGTi2A5XP0taIZ9Y2SRZeiOcN1U/TPLCBtGH7WzrS MFRGdEO24+col/LNxwd1Q5QzMsV3sujZ+wqIrPIumh7R4LkeQ1WlyAdEqXzmJrOvi3qm h1DdGiUOAMZ1sRa7Zs6zdJyjoePaluaIm2xzH/bjoN8mIfGO0LL8L/U8FzuXUYZ6pG+S RM9pT48GJKe2kbFI8DInZTQRa2QhzWCW2oERABv/wz0nKVxHbo1hlqBnRqIO7inv7dUf 6tzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=TZFklF/0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u91-v6si1826638plb.341.2018.03.02.04.00.56; Fri, 02 Mar 2018 04:01:11 -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=@samsung.com header.s=mail20170921 header.b=TZFklF/0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034340AbeCBIFu (ORCPT + 99 others); Fri, 2 Mar 2018 03:05:50 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:10391 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936005AbeCBIFr (ORCPT ); Fri, 2 Mar 2018 03:05:47 -0500 Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20180302080544epoutp02be57671867b7585c864729350e5e7b86~YC_MhKUvP1468814688epoutp02h; Fri, 2 Mar 2018 08:05:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20180302080544epoutp02be57671867b7585c864729350e5e7b86~YC_MhKUvP1468814688epoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1519977944; bh=yaK5h89K9BY+pwa2J8R5taymXhEMi3INND0bHj3Ajx0=; h=Subject:To:Cc:From:Date:In-reply-to:References:From; b=TZFklF/0RrvSgHA5Z/eGjp526rCbNnk9EZJfwM7SMrT3415Zbgx91/cKbFq2zspnH JbFu6J56Zy2j7iPFgIycziB0xRh2jNATM2VcUpKtAIm3///ns8YjncZ5KHDm+5ho6g 7wglFkt0hXJtEUwhtObDxsd2ITNodi2iDWNbOE50= Received: from epsmges1p5.samsung.com (unknown [182.195.40.64]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20180302080544epcas1p408024ee6fd394326ac0ba6208e2ce910~YC_MOm9fb0887708877epcas1p4-; Fri, 2 Mar 2018 08:05:44 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id B4.F9.04037.7D5099A5; Fri, 2 Mar 2018 17:05:43 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20180302080543epcas1p4304bba2730ee0c10e944ed32ead62f73~YC_LiFmuq1185111851epcas1p4s; Fri, 2 Mar 2018 08:05:43 +0000 (GMT) X-AuditID: b6c32a39-467ff70000000fc5-0d-5a9905d78356 Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 15.7F.03826.7D5099A5; Fri, 2 Mar 2018 17:05:43 +0900 (KST) Received: from [10.113.77.174] by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P4Y009FIEHITH90@mmp1.samsung.com>; Fri, 02 Mar 2018 17:05:43 +0900 (KST) Subject: Re: [PATCH v4] mmc: dw_mmc: Fix the DTO/CTO timeout overflow calculation for 32-bit systems To: Jisheng Zhang , Evgeniy Didin Cc: linux-mmc@vger.kernel.org, Alexey Brodkin , Eugeniy Paltsev , Douglas Anderson , Ulf Hansson , Andy Shevchenko , Shawn Lin , Vineet Gupta , linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, stable@vger.kernel.org From: Jaehoon Chung Message-id: <1112b6b6-4bb9-6cbf-24e5-e082f7ce04df@samsung.com> Date: Fri, 02 Mar 2018 17:05:42 +0900 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-version: 1.0 In-reply-to: <20180301135755.7e26f12e@xhacker.debian> Content-type: text/plain; charset="utf-8" Content-language: en-US Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA02Se0hTcRTH+e3ebXfS6jpNDxZmF/oj07W7trxmRpHUpfxjJWQYZjd3U8s9 2N2id+thiRktK9Fly1IyLCszTE2UTLMHGvZEMyUJK8UQe9KD2vUa+N+Xcz7fw/keDoFpbijC iCyrk3dYuWxKEYDX3psbHf1KXpyie1QRx1z7+lrGfPTcQ0zHpbsKJreiRM48L3MjprC7Amee NZQomNa/JxCT01slY3rfXZczpdUDiGmvSmYODFVhS9XsWXcXztZ73yjZ3peNCramfD/7x9uM swXPOzH2VvNnxH6+GW4iUvjFmTxn5h0RvDXdZs6yZsRTq5PSlqcZF+roaDqWiaEirJyFj6cS Ek3RK7Ky/RtTEdu5bJe/ZOIEgZq/ZLHD5nLyEZk2wRlPbaBpvZbWxWj1er3WsCB1kd7oRzbx mSM1jZi9fsaO6vxBzI2qQ/KQigDSAO6mhygPBRAasg6B75tHITY05HcEPZ5deYgYh362zJaY OwiqupomDH0IyrzfFSIURG6Bhg8y0RtMpsLI+TG5yGDkdQwK+w+OD1WQUXD7W/s4pCaXgGfM i4tenJwDDbVJYnk6uQ7aiseQhATCj1N9uKhVpBFuNA5josbIufDhSwEu6VA4lNM9oWdBzdUR TAp2Qgmv7zCSToCO2jN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uXHF5XmpBYfYpTmYFES572ddyxSSCA9sSQ1OzW1ILUIJsvEwSnV wOh2RW15v8Fh+5YN5ZGn277b1l3jmOhv9/pz4vYy7kC5aNVtZ+rumRfdun3uq/T9n1dqXOqM DjqURq+Ok5od23dKvWXq/vR/1mprzQ6s/V2smhfwJEZazPZ9Ve8t7hNc33U61AyTYtPlOZtt lpso+zKkBHT9mSZ+KCsv6JXZhqpnHiLKFrYLlFiKMxINtZiLihMBcwRnA6YCAAA= X-CMS-MailID: 20180302080543epcas1p4304bba2730ee0c10e944ed32ead62f73 X-Msg-Generator: CA CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180301055819epcas1p4de351fc93e2226e0b0ae5c9647610fc4 X-RootMTR: 20180301055819epcas1p4de351fc93e2226e0b0ae5c9647610fc4 References: <20180228115318.20154-1-Evgeniy.Didin@synopsys.com> <20180301135755.7e26f12e@xhacker.debian> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/01/2018 02:57 PM, Jisheng Zhang wrote: > 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 Acked-by: Jaehoon Chung Best Regards, Jaehoon Chung > >> >> 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; > > > >