Received: by 10.223.185.116 with SMTP id b49csp4029437wrg; Tue, 13 Feb 2018 11:32:08 -0800 (PST) X-Google-Smtp-Source: AH8x2240fO1qNspZeTosN18N2wcx4p9zQZdORybBS+7Msc4i50050mkZlI4aFZ/8BvuO7D5gRLOQ X-Received: by 2002:a17:902:3225:: with SMTP id y34-v6mr2041151plb.399.1518550328266; Tue, 13 Feb 2018 11:32:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518550328; cv=none; d=google.com; s=arc-20160816; b=UXcCyMFvZoS2TSkT+Pyi4pEJU59UN2DpdGGB6AE9Mv3lPSMI57QV//pPGzW/1L2+/Q nY+N2590PwH26BAWwA1zgHyjffFRVigEfDwMKexr1ThR9QeVG9N5Gb3zKylGyK8nmqIR 6vY5zMGd0VIRjrTMxKDrwSPPZ53GicQVvJNogJD+FUhpKTGqTWISN+X9UBDMXjb4oGXa 4yrDCyxL8Ndfg6z6kImn/YAFRLpY4aFe+s2OYYMV/farGFiRRA2cNNozniRwEZOsknYy C2+/jZYAqzz3qm1eywaLP7BYJQrq+eGFGTxlOxvxb5ww0w3I0gkNhlpPg4k40dn/uRdm jiFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :user-agent:in-reply-to:references:subject:cc:to:from:message-id :date:arc-authentication-results; bh=r5FkTgkzCgYmhN6k5t1Rygyrowh/BliG/4FTB5tYZNU=; b=DO6sN3XqLmLbZFfPs4u06y6aD+nqnC+jrw+xTaMVW65QVBjdA4WKL/CRcD6cJiF2ZH qvoDYFAhB9G7J+rnizHm/Cq3JUesW1Etyf9fH98URiw0kBjx8cOR7zFLdgFIk/FoJkAd B8Tx79bZS03EsN8fvvCH14kvuEBrg7/rsCJYtxW3Vj5FS3peHaeMqrwx4vFOElL+Sa+f xdVAJm7IcPq6JNMzVCo87LNltKDQkq5mAVkEOp8k+kE6d2oTCJcp2UFoUfBIiT0ds1LB tlCL+NRIS1nupQhKSQWMtgmJlXlKRKFbOhMgSpfxiuE5QcTeCfwsK2G9qHH0v/lFMGV5 C5VA== 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 k33-v6si60483pld.303.2018.02.13.11.31.53; Tue, 13 Feb 2018 11:32:08 -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 S965530AbeBMTaH (ORCPT + 99 others); Tue, 13 Feb 2018 14:30:07 -0500 Received: from gateway22.websitewelcome.com ([192.185.46.131]:32759 "EHLO gateway22.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965313AbeBMTaG (ORCPT ); Tue, 13 Feb 2018 14:30:06 -0500 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 4908D38999 for ; Tue, 13 Feb 2018 13:05:51 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id lftneKXW8mzEzlftneM4vQ; Tue, 13 Feb 2018 13:05:51 -0600 Received: from gator4166.hostgator.com ([108.167.133.22]:48297) by gator4166.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1elftm-003Iwq-VO; Tue, 13 Feb 2018 13:05:50 -0600 Received: from 189.175.4.238 ([189.175.4.238]) by gator4166.hostgator.com (Horde Framework) with HTTPS; Tue, 13 Feb 2018 13:05:50 -0600 Date: Tue, 13 Feb 2018 13:05:50 -0600 Message-ID: <20180213130550.Horde.JMezTfF5lIykmPMB49PKEwG@gator4166.hostgator.com> From: "Gustavo A. R. Silva" To: Andy Shevchenko Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, Linux Kernel Mailing List Subject: Re: [PATCH] PCI/ASPM: Use 64-bit arithmetic instead of 32-bit References: <20180213165948.GA14035@embeddedor.com> In-Reply-To: User-Agent: Horde Application Framework 5 Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 108.167.133.22 X-Source-L: Yes X-Exim-ID: 1elftm-003Iwq-VO X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: gator4166.hostgator.com [108.167.133.22]:48297 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 1 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks -- Gustavo