Received: by 10.213.65.68 with SMTP id h4csp3562513imn; Tue, 3 Apr 2018 07:08:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/v5ivrBJrxdcPDT7SciR2m7U7y3gMR7q3FYj9FmYhIxnNscBO/iZ8iV+LvO6ZS/i7vJXLq X-Received: by 10.101.101.136 with SMTP id u8mr1528964pgv.333.1522764531734; Tue, 03 Apr 2018 07:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522764531; cv=none; d=google.com; s=arc-20160816; b=C8wEXTu3TzGo1B2u8n3TQ/DCN78i9UrDRLq2QOqdz4dRcJRA0je1IgElVlJvWQDjON Rd/6Qsbgzm9LOEgs+tfOdvj4F3luNQdbMcRHkhUOyhRfRXaXhGBitqglGM+J5CxQuMsY KwxEkf/+ApImdUaUqSw/+p4Z3Zs3jUV2zMXwKOSZ9UYIxHMscJxeXzLg9qXAmD8mYIXD P7dENX8LZB3QNrnK38lFlrbvGI0oTLiZtBN9mzKyYHcVi7+OKrJ0g4UN5xeOzY+oSjcD g56hW978yXOpkkEW0ZE6FyWZ5im0xBb5CL7MLyU46J+hVetpyucSmOs0GFd7ICha+jAJ KaNw== 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=EXnhHQ3PKNwM+4+DU8y4oiA+ER976NI5/eNcddHtriY=; b=rdi8kkGrz9i89qkIQwaSGVXXH0k6EYZJXBAAq8ed+5om1G7eG55q8phsRg6ln8tw9m D8cirt/L37cxRIKhCgs27//jPgd3pXKTJxvLMZAr0zL/6Bw9o1PPBTcVOZN9aqBLBZLd FzRropHDhZ7TnM4dWj/G+4uKAAlNjfGo+DPckA1RvHeu9ddWfCCxVRtAioeZhGlUVx/5 F3iNkU4lGzNh/e2ZkDWedTzBt88/G7kNM3JAAfDNHyrEN7PoaPwX+WmH6KZFOkhzhBIQ 1fl8Gws04AlyOu23O+OJFzq5SV8RH2sS04+DUiGMe2mam6YVbdbauFYdSgyhaorXTryM 6m/g== 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 t18si2237839pfj.217.2018.04.03.07.08.37; Tue, 03 Apr 2018 07:08:51 -0700 (PDT) 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 S1751404AbeDCOF4 (ORCPT + 99 others); Tue, 3 Apr 2018 10:05:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:59626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750722AbeDCOFy (ORCPT ); Tue, 3 Apr 2018 10:05:54 -0400 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 86E8120CAA; Tue, 3 Apr 2018 14:05:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86E8120CAA 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, 3 Apr 2018 09:05:52 -0500 From: Bjorn Helgaas To: Jacob Keller Cc: Tal Gilboa , Tariq Toukan , Jacob Keller , Ariel Elior , Ganesh Goudar , Jeff Kirsher , everest-linux-l2@cavium.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH v5 03/14] PCI: Add pcie_bandwidth_capable() to compute max supported link bandwidth Message-ID: <20180403140552.GB60020@bhelgaas-glaptop.roam.corp.google.com> References: <152244269202.135666.3064353823697623332.stgit@bhelgaas-glaptop.roam.corp.google.com> <152244390359.135666.14890735614456271032.stgit@bhelgaas-glaptop.roam.corp.google.com> <31e66048-e8b8-47ba-baf5-023560b4c124@mellanox.com> <20180402004049.GA131023@bhelgaas-glaptop.roam.corp.google.com> <50346f44-de3f-b226-69ad-6de45e94e261@mellanox.com> <20180402140501.GA244675@bhelgaas-glaptop.roam.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Mon, Apr 02, 2018 at 05:30:54PM -0700, Jacob Keller wrote: > On Mon, Apr 2, 2018 at 7:05 AM, Bjorn Helgaas wrote: > > +/* PCIe speed to Mb/s reduced by encoding overhead */ > > +#define PCIE_SPEED2MBS_ENC(speed) \ > > + ((speed) == PCIE_SPEED_16_0GT ? (16000*(128/130)) : \ > > + (speed) == PCIE_SPEED_8_0GT ? (8000*(128/130)) : \ > > + (speed) == PCIE_SPEED_5_0GT ? (5000*(8/10)) : \ > > + (speed) == PCIE_SPEED_2_5GT ? (2500*(8/10)) : \ > > + 0) > > + > > Should this be "(speed * x ) / y" instead? wouldn't they calculate > 128/130 and truncate that to zero before multiplying by the speed? Or > are compilers smart enough to do this the other way to avoid the > losses? Yep, thanks for saving me yet more embarrassment.