From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C0C8C433E0 for ; Fri, 8 Jan 2021 01:02:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 719722076E for ; Fri, 8 Jan 2021 01:02:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729642AbhAHBC3 (ORCPT ); Thu, 7 Jan 2021 20:02:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:35756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729465AbhAHBC2 (ORCPT ); Thu, 7 Jan 2021 20:02:28 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 333DC2076E; Fri, 8 Jan 2021 01:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610067708; bh=NKUggXfpZoH7IqHHRR5QWltRsKDmLmNJObXFp2AwbFo=; h=Date:From:To:Subject:In-Reply-To:From; b=VuCwcsfw4hNEoFWpQvShhDEdJOP2jxhdhRXxpy+okQ8igZXRURzvPk7SOFL7A7//E DoBxvwAdQCRQJnaLkozQTHr9H0OiP5VD0DN69mPRGFCyJn0TqTaeKVZ4dBdvhIQTXF m8rF8geu//PDwVYhistGUA8bmxYpyX2piyyIHgG8AAbzgRmelSlCKPrQCpm2qqsbmv rBO0UwdUcsZ2e3rXwhc1cO4VzXFv0OK1D2aEFMck7aYJDlJigQxVPbn+MdzFJ4un6F 9+kOKQkSJ8yfsUJhrD3TmkwUQWbuUQvwqgVTS0z0iRnh1xTGPcQs0ShxkqSdyHFgLv uVA7SQjfnstEg== Date: Thu, 7 Jan 2021 19:01:47 -0600 From: Bjorn Helgaas To: nirmoy.das@amd.com, bhelgaas@google.com, ckoenig.leichtzumerken@gmail.com, linux-pci@vger.kernel.org, christian.koenig@amd.com, devspam@moreofthesa.me.uk, dri-devel@lists.freedesktop.org Subject: Re: [PATCH 2/4] PCI: Add pci_rebar_bytes_to_size() Message-ID: <20210108010147.GA1406822@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <58F0BFBCD0%devspam@moreofthesa.me.uk> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Thu, Jan 07, 2021 at 11:31:36PM +0000, Darren Salt wrote: > I demand that Bjorn Helgaas may or may not have written... ? > >> +static inline int pci_rebar_bytes_to_size(u64 bytes) > >> +{ > >> + bytes = roundup_pow_of_two(bytes); > >> + return max(ilog2(bytes), 20) - 20; > > > This isn't returning a "size", is it? It looks like it's returning the > > log2 of the number of MB the BAR will be, i.e., the encoding used by the > > Resizable BAR Control register "BAR Size" field. Needs a brief comment to > > that effect and/or a different function name. > > Given that, it seems to me that pci_rebar_size_to_bytes should be similarly > commented and/or renamed. Makes sense. Something like this is sufficient: return 1ULL << (size + 20); /* Convert PCI_REBAR_CTRL "BAR Size" */ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CF82C433E6 for ; Fri, 8 Jan 2021 01:01:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B65D236F9 for ; Fri, 8 Jan 2021 01:01:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B65D236F9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7EE886E5BF; Fri, 8 Jan 2021 01:01:50 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id B89AD6E5BF for ; Fri, 8 Jan 2021 01:01:48 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 333DC2076E; Fri, 8 Jan 2021 01:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610067708; bh=NKUggXfpZoH7IqHHRR5QWltRsKDmLmNJObXFp2AwbFo=; h=Date:From:To:Subject:In-Reply-To:From; b=VuCwcsfw4hNEoFWpQvShhDEdJOP2jxhdhRXxpy+okQ8igZXRURzvPk7SOFL7A7//E DoBxvwAdQCRQJnaLkozQTHr9H0OiP5VD0DN69mPRGFCyJn0TqTaeKVZ4dBdvhIQTXF m8rF8geu//PDwVYhistGUA8bmxYpyX2piyyIHgG8AAbzgRmelSlCKPrQCpm2qqsbmv rBO0UwdUcsZ2e3rXwhc1cO4VzXFv0OK1D2aEFMck7aYJDlJigQxVPbn+MdzFJ4un6F 9+kOKQkSJ8yfsUJhrD3TmkwUQWbuUQvwqgVTS0z0iRnh1xTGPcQs0ShxkqSdyHFgLv uVA7SQjfnstEg== Date: Thu, 7 Jan 2021 19:01:47 -0600 From: Bjorn Helgaas To: nirmoy.das@amd.com, bhelgaas@google.com, ckoenig.leichtzumerken@gmail.com, linux-pci@vger.kernel.org, christian.koenig@amd.com, devspam@moreofthesa.me.uk, dri-devel@lists.freedesktop.org Subject: Re: [PATCH 2/4] PCI: Add pci_rebar_bytes_to_size() Message-ID: <20210108010147.GA1406822@bjorn-Precision-5520> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <58F0BFBCD0%devspam@moreofthesa.me.uk> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Thu, Jan 07, 2021 at 11:31:36PM +0000, Darren Salt wrote: > I demand that Bjorn Helgaas may or may not have written... ? > >> +static inline int pci_rebar_bytes_to_size(u64 bytes) > >> +{ > >> + bytes = roundup_pow_of_two(bytes); > >> + return max(ilog2(bytes), 20) - 20; > > > This isn't returning a "size", is it? It looks like it's returning the > > log2 of the number of MB the BAR will be, i.e., the encoding used by the > > Resizable BAR Control register "BAR Size" field. Needs a brief comment to > > that effect and/or a different function name. > > Given that, it seems to me that pci_rebar_size_to_bytes should be similarly > commented and/or renamed. Makes sense. Something like this is sufficient: return 1ULL << (size + 20); /* Convert PCI_REBAR_CTRL "BAR Size" */ _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel