Received: by 10.223.185.116 with SMTP id b49csp3962332wrg; Mon, 26 Feb 2018 08:55:11 -0800 (PST) X-Google-Smtp-Source: AH8x226tG+8nFoiL8WeRRcQ9oHsSpkdEDhfxyPnIqsFN/DDCzt3wlyWLYdOjPlwXrF9ZfPMYHNHa X-Received: by 10.101.70.10 with SMTP id v10mr8931340pgq.327.1519664110906; Mon, 26 Feb 2018 08:55:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519664110; cv=none; d=google.com; s=arc-20160816; b=a28HqC+SS3BgiTIeQIVGD+RAwDabvLlHObfRrWtKfac3aohKyf99g92avAcOwVQAX2 DlieNIbZ1x0Z+4jPkXo7MjXsuT6EkHpq1baZXXNDQlFNBuZ3zfAU64pQgBpFexgB5305 jmd3MipRp10TXOzdmg7tqEt7E6/QDJv1bzAU43xy6aS5DcsvLO8goVkdd2XZAD1+Gw5S VNMI10jRi41lev90f+NfNoq2m7DWQ5WJAlyzjGjYHr9RvKqiE3LmAB1Zc4QTolRvTioj Zu0wX+cdg3POZIzRaR1Rzpb3aTXZ7gDL1aHG3e32puizVCW0nZYcvjS1d9FurUL964RL 0O6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=XSg7LuFoO/nDGWQMRIa1Uh51KSyjSF5vv6AoetzdT08=; b=nX7zBClYaeGIs5xpL/4BwOHMbhscK8CGH+k/4V/H3xZ7bz3OJcBWSnZ5g7UmNTvwog jWm47K1BTAcUC9WX45nVZvtSBo1FFKKY0/CZY4h17G4noytnaO05YmNEPaIKJbODWN8E RwLtamSDP/6oVwf7BliDpgF9V7U/g2SOanmefIOsr9Lr4TOexNMYsgPrAPj6gaL9XJ08 fyC7dteSomoESywToOWDmWDtCs6UJd/0N+/TyewyTxdHfO5mrGyC/V4V2b+gU+vXpLfL RPF4+M/NmkTr5y19+WH3DLTKotU19FyxccydGZhcv8Q6I/B//+6yMMTSZOJM1hSGMNSt zdIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nEWeisMN; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g21si5131022pfh.379.2018.02.26.08.54.55; Mon, 26 Feb 2018 08:55:10 -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=@gmail.com header.s=20161025 header.b=nEWeisMN; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751455AbeBZQxv (ORCPT + 99 others); Mon, 26 Feb 2018 11:53:51 -0500 Received: from mail-qk0-f173.google.com ([209.85.220.173]:46236 "EHLO mail-qk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751018AbeBZQxt (ORCPT ); Mon, 26 Feb 2018 11:53:49 -0500 Received: by mail-qk0-f173.google.com with SMTP id 130so15040490qkd.13; Mon, 26 Feb 2018 08:53:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=XSg7LuFoO/nDGWQMRIa1Uh51KSyjSF5vv6AoetzdT08=; b=nEWeisMN40Etw3Wc5+YqEy9woVwIFDHCs+9LjFAqnEvKCxqtiXRSOllLDDmMpuZwDJ TtxGfpPO9EIQXMRUTEpVgERjczUtPaYr3vGGYyO6YkXV5oa5FPBhSeoa+C/jCXwVOgLt 2w9xI3oP7TQq3bZpqsZjCQwMq7qE80jQZypyNfypbAeh3uarTsF6RFq8El0+3VRvCs1y c2UjQpWAUqTk5eDI2U6Er+ZLlgjEypA6W+8aZWbZ3jd1pnJAVe7+eUtBZcyNtMrRigwR PfMaN0lqeqY654akTJFfaCF/SKPI6u8ukwo9UvYbTz+e5tjcMexgTsCBlTSl82BbsP4+ m7WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=XSg7LuFoO/nDGWQMRIa1Uh51KSyjSF5vv6AoetzdT08=; b=hvC5HvMv7IqNrvDn9STv/sfNXkF2+bOcRcedrfxtPSS9j3WyH61kGswHAne8nyOoIb wC2m/x9dF/7UJ01OT+iKhXbcB4QpuyGMLzxrOOtA/ECGJ9ZxusMT9njhjtFZYboomOZf 5pmSpkTHi1Xzg0KfVb3oalr90yoFV0M/F5wlTKakGs5z9xMxEVmQzBVHDlX27ufnK/y0 fi+kW83tiVsxuyoyHkScyjnRJgZIKjYm0p2poBCdNGTI/nCxy1Q+UVMJ0nLS5gPfaI9Q dOLSVDBWHUG3p6fDYebw1Ej3c/wgNwZfJn9yG6bS2tSnwH8fglIfHvlkYDlaIQNC6jKk zXVQ== X-Gm-Message-State: APf1xPD8upmCu8duIs9djrioy9y2lsM99sDgVN5oMR4hiuiU49IXmAjt a03/oeCO98KENcSGaqQ8/ofHiOnqAxBrKX7cj7m+vpiP X-Received: by 10.55.124.67 with SMTP id x64mr1140695qkc.137.1519664028649; Mon, 26 Feb 2018 08:53:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.195.80 with HTTP; Mon, 26 Feb 2018 08:53:48 -0800 (PST) In-Reply-To: <1519658060.31245.4.camel@synopsys.com> References: <20180226143413.44134-1-Evgeniy.Didin@synopsys.com> <20180226143413.44134-3-Evgeniy.Didin@synopsys.com> <1519658060.31245.4.camel@synopsys.com> From: Andy Shevchenko Date: Mon, 26 Feb 2018 18:53:48 +0200 Message-ID: Subject: Re: [PATCH 2/2 v3] mmc: dw_mmc: Fix the CTO overflow calculation for 32-bit systems To: Evgeniy Didin Cc: "linux-kernel@vger.kernel.org" , "Alexey.Brodkin@synopsys.com" , "linux-mmc@vger.kernel.org" , "dianders@chromium.org" , "Vineet.Gupta1@synopsys.com" , "Eugeniy.Paltsev@synopsys.com" , "linux-snps-arc@lists.infradead.org" , "stable@vger.kernel.org" , "ulf.hansson@linaro.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 26, 2018 at 5:14 PM, Evgeniy Didin wrote: > On Mon, 2018-02-26 at 16:39 +0200, Andy Shevchenko wrote: >> On Mon, Feb 26, 2018 at 4:34 PM, Evgeniy Didin >> wrote: >> > 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. >> > - 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); >> >> IIRC, someone commented on this or similar, i.e. >> >> DIV_ROUND_UP_ULL() ? > Switch DIV_ROUND_UP macro to DIV_ROUND_UP_ULL is not reasonable > because overflow happens on multiply and DIV_ROUND_UP_ULL helps > with sum overflow. Did you try to compile your code for 32-bit target? -- With Best Regards, Andy Shevchenko