Received: by 10.223.185.116 with SMTP id b49csp4068717wrg; Mon, 26 Feb 2018 10:32:36 -0800 (PST) X-Google-Smtp-Source: AH8x224xT/UIxeSM17FuCBxtuCliBP8I/3Y5IyL3u1F6OwMGDu59kWQelAQdGv4n4+P6H0nRSPod X-Received: by 2002:a17:902:42e:: with SMTP id 43-v6mr11796493ple.186.1519669956238; Mon, 26 Feb 2018 10:32:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519669956; cv=none; d=google.com; s=arc-20160816; b=y8vyDpzg9Dzq5zMv737NX6yjZMzRUBKw4rzXeUopqFwT8VkXKS86xHIoWOEqZgN9/g Gnv6kfnT7K1wSgaWlU0eTCB1Spj3jRDqohRljcN7VGSpuL0uGWqFsC78/BMiVDcu7Quo yvqsMbDNbDD4uVkUMQBdzYmwLzOkG/xML8lQsFRvxvDINGj7p0nO5ElrPtkIEsXNElhQ DHdSYQ9bvulZIdL+4/Vlpjy3qYylPXth9+f+XWdCoEJSHwIzQxTCDy/h5Np8zTSrOW4b LiaAYS/mfWgTEmoNjEEBacSP4u29hICHu7z0gUXaX+3Ce6QkDaxwRMKVdEXmx5xTDY3T fAdg== 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=W37gUqsawhpChAO80m00VsfPzJQd8k2HPD6o9kxCHK0=; b=htIxsM4HoQU9g0CpVZZbAC/z4cUCmo6xrAN3iMZX8uLdB/ipwme+Zmq3fUNTSP/JF3 orc4CqFyPnfdPD8pEzdEk8TqVlvkg+7y3N2C04yoMgC7feM4lD7whIy45Aeo03I7/L6j 3COe0sPDX5yRGgxDnAUjpliLUkbwcbSdwZ6wmX0zvtA8TDj8kOF3juPQHSIXALgBZA2c OABfxdRxPaAKSzWewUrt/0bFO5G+lKSRrCbuYf8XypsZug7lXgcVhYGrbEVdw5O8heov K1lhYyegkbtqI0gyHW7JBE535WErGSUIYtqkiZqfidZMd95OqXBBry+4hLMWpve6FNLQ bwpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bbBkdCLC; 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 c22si7131147pfl.371.2018.02.26.10.32.19; Mon, 26 Feb 2018 10:32:36 -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=bbBkdCLC; 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 S1751661AbeBZSap (ORCPT + 99 others); Mon, 26 Feb 2018 13:30:45 -0500 Received: from mail-qk0-f194.google.com ([209.85.220.194]:38082 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751165AbeBZSan (ORCPT ); Mon, 26 Feb 2018 13:30:43 -0500 Received: by mail-qk0-f194.google.com with SMTP id s198so20233792qke.5; Mon, 26 Feb 2018 10:30:42 -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=W37gUqsawhpChAO80m00VsfPzJQd8k2HPD6o9kxCHK0=; b=bbBkdCLCeDc4Yxc8d7RMhViASIZj7PlrIAc4Q7SHKOGhiB74aJ5+vrfc/3WuHwK9UH NJTdosxZSAKLAau2hVjvIQVDjCm7gsWSc18gYar8QjeSfvjp/m8T7zpcUZsADV0vkpXA UItra6MHHzjeY/AwZzIzDHod2AK2eS3p3o+D/4lg8vE8Zt1jKXw1JL+7mjJUPfHtxO2Y Pf2WbLe0364q8smUBIEJvy8VTCQ0pT5SagQ0r7zUM0Xu1dSTE2El4erBYANka4odVtqc HvKNbFllN3kpQsXoN+y64KUpuJ0joFVxq9FQxwJxJVzlcuHEJ/cG1Ad6JSZK9FvNIlqx Xtiw== 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=W37gUqsawhpChAO80m00VsfPzJQd8k2HPD6o9kxCHK0=; b=QM3nHE0h3oL+E++fDqNM1ZVSJizZAshiy0l1kQJITLMiABBu4Rjr/HvuSeEJSw2Ahp sji7XS79nFPD/XXNiwCP0Ij4pH09uT21TNHdDF4q5sLlKtJ/E0yVgVqr9kFewvYBx/FE 8NIsuQrt8Mg6ktz4Yu7VJeRSmWzaCVgHI/wakJnNf1AZ+ZhxUFfo7DfU1bmTAcBCQrlj Ta0PzxakwYaAgMewMMwSnFGhdOmsBx3QmTfBazecw5eh9MhXe7JcGe7mOdrYmz3B92ew bjBL3eUFHj4bURLU8fGQ+YG4Fqxj9pLRvGVk/E46v54asua/VoPP3WIDAWhG284d6DkN 2A+A== X-Gm-Message-State: APf1xPCLxqq3jIXGqqlP7RqmMyy5gzk2Yq6pFUEMx5q+JFQKKsV8JJy6 ueFm6Odewbz3E3iMxDzkW43O4BRoRGdL05zaIJl3Nyq4sws= X-Received: by 10.55.15.147 with SMTP id 19mr16049101qkp.301.1519669842364; Mon, 26 Feb 2018 10:30:42 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.195.80 with HTTP; Mon, 26 Feb 2018 10:30:41 -0800 (PST) In-Reply-To: <1519665265.31245.6.camel@synopsys.com> References: <20180226143413.44134-1-Evgeniy.Didin@synopsys.com> <20180226143413.44134-3-Evgeniy.Didin@synopsys.com> <1519658060.31245.4.camel@synopsys.com> <1519665265.31245.6.camel@synopsys.com> From: Andy Shevchenko Date: Mon, 26 Feb 2018 20:30:41 +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 7:14 PM, Evgeniy Didin wrote: > On Mon, 2018-02-26 at 18:53 +0200, Andy Shevchenko wrote: >> 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? > Yes, we have compiled code for 32-bit system. > I am wondering why are you asking that? Because I simple didn't believe you. ERROR: "__udivdi3" [drivers/mmc/host/dw_mmc.ko] undefined! ...scripts/Makefile.modpost:92: recipe for target '__modpost' failed make[2]: *** [__modpost] Error 1 +++ b/drivers/mmc/host/dw_mmc.c @@ -409,7 +409,7 @@ static inline void dw_mci_set_cto(struct dw_mci *host) - 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); -- With Best Regards, Andy Shevchenko