Received: by 10.223.185.116 with SMTP id b49csp3816992wrg; Mon, 26 Feb 2018 06:36:15 -0800 (PST) X-Google-Smtp-Source: AH8x227ArE5i7NCrFEinf5QchlpvHYhyiaFUqyytILT4rUToT/H7NVI/NCLvrx/nhg8etuLvTSM0 X-Received: by 2002:a17:902:b101:: with SMTP id q1-v6mr10901556plr.287.1519655775611; Mon, 26 Feb 2018 06:36:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519655775; cv=none; d=google.com; s=arc-20160816; b=Zh4lyqQWL230NZrRUrj9+gXJtEjvEc7MYxERrclvydZvfvV7MwBuTZIOk1y0o7L/Qt AbrIZA9lkIo7/RuVMzlx2lu6F85IOKdXkIE5hNgdLdnCV0U3JafZskN9jaxnI3MQwSXX u+H5j9AWKsInJdzFQMb4CiJn6VI2BKuD9QMsNHUeRQb9nrv0pgRwS4DfckY4B0MeIaMp 2uur/7xwTZa9eUkqnGNF7xMxCEwP/a29LlVsnId7XOsfdNsoKG6ntGlC3/nu2JgDrfUS VXcRt8bZG1utQs+RAVeqmkZVVqlNfmJLWe3Pm2p9YLSooxIB5VUYgN2thvIh8FQUgEHK YYmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=zeUC+6sd/lyRML+UU5XGs/neV0Dzfnk74yR/ipvqvjU=; b=1C19ueY15iySrwR2SSYMY5MNNu7cCjFXOg7BmQCtL6HppYSQLguZrwC3e5SEs1/cOT Ow/NhiGY+McJmKC3uHKBglh4X6OwbBrTDrw8UHz4zjplm84WkNOxX/yJBHLLeLzTXyMW zloQYkcpET8GCEby8rsS5u/wie8byo47XPmpASB6Hrw7LiEzA1Dh6FjSI2xvhOFnrZtE ltuSg3UbbAKeZvy1mhlNlKvEg8eYgDZ6QNO3GuzgJnUGM52kMRulig6rpqF6n7oospFg Ac8AB1Gft+anRSNqCt+q5IMUb5wOHAzF7jxHE6qrmCKxPVXllkqx7LuemGaHKiuBksdG Egdg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si5590506pgr.292.2018.02.26.06.36.00; Mon, 26 Feb 2018 06:36:15 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753931AbeBZOem (ORCPT + 99 others); Mon, 26 Feb 2018 09:34:42 -0500 Received: from us01smtprelay-2.synopsys.com ([198.182.60.111]:46905 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753866AbeBZOee (ORCPT ); Mon, 26 Feb 2018 09:34:34 -0500 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id C1FC110C1678; Mon, 26 Feb 2018 06:34:33 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id AC3F03BB4; Mon, 26 Feb 2018 06:34:33 -0800 (PST) Received: from ru20arcgnu1.internal.synopsys.com (ru20arcgnu1.internal.synopsys.com [10.121.9.48]) by mailhost.synopsys.com (Postfix) with ESMTP id 951203BAC; Mon, 26 Feb 2018 06:34:31 -0800 (PST) From: Evgeniy Didin To: linux-mmc@vger.kernel.org Cc: Alexey Brodkin , Eugeniy Paltsev , Douglas Anderson , Ulf Hansson , linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, stable@vger.kernel.org, Vineet Gupta Subject: [PATCH 2/2 v3] mmc: dw_mmc: Fix the CTO overflow calculation for 32-bit systems Date: Mon, 26 Feb 2018 17:34:13 +0300 Message-Id: <20180226143413.44134-3-Evgeniy.Didin@synopsys.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180226143413.44134-1-Evgeniy.Didin@synopsys.com> References: <20180226143413.44134-1-Evgeniy.Didin@synopsys.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In commit 4c2357f57dd5 ("mmc: dw_mmc: Fix the CTO timeout calculation") have been made changes which can cause multiply overflow for 32-bit systems. The value of cto_ms is lower the drto_ms, but nevertheless overflow can occur. Lets cast this multiply to u64 type which prevents overflow. Signed-off-by: Evgeniy Didin CC: Alexey Brodkin CC: Eugeniy Paltsev CC: Douglas Anderson CC: Ulf Hansson CC: linux-kernel@vger.kernel.org CC: linux-snps-arc@lists.infradead.org Cc: # 4c2357f57dd5 mmc: dw_mmc: Fix the CTO timeout calculation --- drivers/mmc/host/dw_mmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 194159219b32..775fb3ae1443 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -409,7 +409,8 @@ 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((u64)MSEC_PER_SEC * cto_clks * cto_div, host->bus_hz); /* add a bit spare time */ cto_ms += 10; -- 2.11.0