Received: by 10.223.185.116 with SMTP id b49csp5390075wrg; Tue, 27 Feb 2018 12:27:59 -0800 (PST) X-Google-Smtp-Source: AH8x225z2+3l0A63T4UciVY6ZkfTegtlT5nDtB0+qwqhdEc0fEQyiz9rSD5swxq4IihjpMFvwyF6 X-Received: by 2002:a17:902:22e:: with SMTP id 43-v6mr15524176plc.384.1519763279832; Tue, 27 Feb 2018 12:27:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519763279; cv=none; d=google.com; s=arc-20160816; b=NWPUJeRmtv5eJ4GuE55s32XCspc+eKfS3/VA9YEASRrq6JdsJmax0OR/so49w6K+c6 U+c1WQmWewaBh/B/bcUjcT5r8QYI3VxVN/R9eQ9W6OkyDhcae3M6rkOFUJZVpasPHOdI hjvJpZ7AizTkR7nUL3KQDhiwzZQAylo034yYiwNebjCxrq7H8/qq1Tfp2t0zDyBm7ZB1 8qhIlfLpXs+frlUe2vg29QBJck0oc3Izm9L9u4Q5R3HS7fwl3l9HugqOGcqd3gUVScjv qKyNK6K1IaNrmmK/+WACZZtjapa0+tvlcs98tPSof78QC0Hy8iFsxPex9QWJVMBOu1Js pHFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:arc-authentication-results; bh=zLnWVrL19UnwJ0PGTKT+8c5b0D4b1n0+B8nkH3ck+fI=; b=YNk6LNel5PtN+14OPu6iF212MGq90AKjUL4TO2WmPvdVhPQnZ7BkY1JXA1Hij49bLy tx+EEep9Iu4Bn81UTP6Bvu07f8Wty2YsjsUUrx4JepSNun2l2NzWjhV8CnnNC7eKl8SL He1ByHiHoduoQP33IkOVV2AU946VQ04NCycNgi0eblmhbC9EpvCyonHqKwiMWGA+SopW Gh+pT4+OBLBWvo4dk/AX9s2TpAMupcE2MmS0vnaF9fGZ2yCpAdf+pm2hd7aUBBweFJv4 fdqNEJVqoBCk3tFG5Uvg6es1B6Ere1jVy8/r72NLdHd6IY3zbLkGXxfByVyWGqOjg7/M RSeA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b2si955pfc.97.2018.02.27.12.27.44; Tue, 27 Feb 2018 12:27:59 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751962AbeB0U0Z (ORCPT + 99 others); Tue, 27 Feb 2018 15:26:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:34394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751628AbeB0U0X (ORCPT ); Tue, 27 Feb 2018 15:26:23 -0500 Received: from localhost (unknown [69.55.156.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 075CD21748; Tue, 27 Feb 2018 20:26:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 075CD21748 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=helgaas@kernel.org Date: Tue, 27 Feb 2018 14:26:22 -0600 From: Bjorn Helgaas To: "Gustavo A. R. Silva" Cc: Andy Shevchenko , Bjorn Helgaas , linux-pci@vger.kernel.org, Linux Kernel Mailing List Subject: Re: [PATCH] PCI/ASPM: Use 64-bit arithmetic instead of 32-bit Message-ID: <20180227202621.GC127842@bhelgaas-glaptop.roam.corp.google.com> References: <20180213165948.GA14035@embeddedor.com> <20180213130550.Horde.JMezTfF5lIykmPMB49PKEwG@gator4166.hostgator.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180213130550.Horde.JMezTfF5lIykmPMB49PKEwG@gator4166.hostgator.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 13, 2018 at 01:05:50PM -0600, Gustavo A. R. Silva wrote: > Hi Andy, > > Quoting Andy Shevchenko : > > > On Tue, Feb 13, 2018 at 6:59 PM, Gustavo A. R. Silva > > wrote: > > > Add suffix ULL to constant 1000 in order to give the compiler complete > > > information about the proper arithmetic to use. Notice that this > > > constant is used in a context that expects an expression of type > > > u64 (64 bits, unsigned). > > > > > > The expression threshold_us * 1000 is currently being evaluated > > > using 32-bit arithmetic. > > > > > - u64 threshold_ns = threshold_us * 1000; > > > + u64 threshold_ns = threshold_us * 1000ULL; > > > > Shouldn't be other way around, i.e. > > > > (u64)threshold_us ? > > > > Either way works. The thing is that casting threshold_us to u64 may imply > that there is something wrong with threshold_us, which does not seem to be > the case. So adding the suffix ULL to the constant 1000 is good enough to > make the expression be evaluated using 64-bit arithmetic instead of 32-bit. > > But, again, either way works. > > > But still the question. have you checked all callers? Does it even makes > > sense? > > > > The proposed patch was due to fact that currently threshold_ns is of type > u64. But based on the following piece of code (which is the only piece of > code from where encode_l12_threshold is being called): > > * Based on PCIe r3.1, sec 5.5.3.3.1, Figures 5-16 and 5-17, and > * Table 5-11. T(POWER_OFF) is at most 2us and T(L1.2) is at > * least 4us. > */ > l1_2_threshold = 2 + 4 + t_common_mode + t_power_on; > encode_l12_threshold(l1_2_threshold, &scale, &value); > > It seems to me that it makes no sense for threshold_ns to be of type u64, > because the expression threshold_us * 1000 will never exceed the 32-bit > limits. So if you agree I can send a patch to change its type to u32 > instead. Changing it to u32 sounds good to me. I can't remember why I chose u64 to begin with, but it doesn't look necessary. Thanks for cleaning this up!