From: Bjorn Helgaas <helgaas@kernel•org>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse•de>
Cc: Heiko Stuebner <heiko@sntech•de>,
linux-pci@vger•kernel.org, Shawn Lin <shawn.lin@rock-chips•com>,
Eric Anholt <eric@anholt•net>, Hanjun Guo <guohanjun@huawei•com>,
Frank Rowand <frowand.list@gmail•com>,
Christoph Hellwig <hch@lst•de>,
Marek Szyprowski <m.szyprowski@samsung•com>,
Florian Fainelli <f.fainelli@gmail•com>,
linux-rockchip@lists•infradead.org, linux-rdma@vger•kernel.org,
maz@kernel•org, phil@raspberrypi•org, linux-acpi@vger•kernel.org,
bcm-kernel-feedback-list@broadcom•com,
Len Brown <lenb@kernel•org>,
devicetree@vger•kernel.org,
Lorenzo Pieralisi <lorenzo.pieralisi@arm•com>,
linux-rpi-kernel@lists•infradead.org,
linux-arm-kernel@lists•infradead.org, mbrugger@suse•com,
netdev@vger•kernel.org, "Rafael J. Wysocki" <rjw@rjwysocki•net>,
linux-kernel@vger•kernel.org, jeremy.linton@arm•com,
iommu@lists•linux-foundation.org,
Rob Herring <robh+dt@kernel•org>,
Stefan Wahren <wahrenst@gmx•net>,
james.quinlan@broadcom•com, Sudeep Holla <sudeep.holla@arm•com>,
andrew.murray@arm•com, Robin Murphy <robin.murphy@arm•com>,
"David S. Miller" <davem@davemloft•net>,
Tariq Toukan <tariqt@mellanox•com>
Subject: Re: [PATCH v4 8/8] linux/log2.h: Use roundup/dow_pow_two() on 64bit calculations
Date: Thu, 5 Dec 2019 14:38:45 -0600 [thread overview]
Message-ID: <20191205203845.GA243596@google.com> (raw)
In-Reply-To: <20191203114743.1294-9-nsaenzjulienne@suse.de>
The subject contains a couple typos: it's missing "of" and it's
missing the "n" on "down".
On Tue, Dec 03, 2019 at 12:47:41PM +0100, Nicolas Saenz Julienne wrote:
> The function now is safe to use while expecting a 64bit value. Use it
> where relevant.
Please include the function names ("roundup_pow_of_two()",
"rounddown_pow_of_two()") in the changelog so it is self-contained and
doesn't depend on the subject.
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse•de>
With the nits above and below addressed,
Acked-by: Bjorn Helgaas <bhelgaas@google•com> # drivers/pci
> ---
> drivers/acpi/arm64/iort.c | 2 +-
> drivers/net/ethernet/mellanox/mlx4/en_clock.c | 3 ++-
> drivers/of/device.c | 3 ++-
> drivers/pci/controller/cadence/pcie-cadence-ep.c | 3 ++-
> drivers/pci/controller/cadence/pcie-cadence.c | 3 ++-
> drivers/pci/controller/pcie-brcmstb.c | 3 ++-
> drivers/pci/controller/pcie-rockchip-ep.c | 5 +++--
> kernel/dma/direct.c | 2 +-
> 8 files changed, 15 insertions(+), 9 deletions(-)
> --- a/drivers/pci/controller/cadence/pcie-cadence-ep.c
> +++ b/drivers/pci/controller/cadence/pcie-cadence-ep.c
> @@ -10,6 +10,7 @@
> #include <linux/platform_device.h>
> #include <linux/pm_runtime.h>
> #include <linux/sizes.h>
> +#include <linux/log2.h>
>
> #include "pcie-cadence.h"
>
> @@ -65,7 +66,7 @@ static int cdns_pcie_ep_set_bar(struct pci_epc *epc, u8 fn,
> * roundup_pow_of_two() returns an unsigned long, which is not suited
> * for 64bit values.
> */
Please remove the comment above since it no longer applies.
> - sz = 1ULL << fls64(sz - 1);
> + sz = roundup_pow_of_two(sz);
> aperture = ilog2(sz) - 7; /* 128B -> 0, 256B -> 1, 512B -> 2, ... */
>
> if ((flags & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) {
> diff --git a/drivers/pci/controller/cadence/pcie-cadence.c b/drivers/pci/controller/cadence/pcie-cadence.c
> index cd795f6fc1e2..b1689f725b41 100644
> --- a/drivers/pci/controller/cadence/pcie-cadence.c
> +++ b/drivers/pci/controller/cadence/pcie-cadence.c
> @@ -4,6 +4,7 @@
> // Author: Cyrille Pitchen <cyrille.pitchen@free-electrons•com>
>
> #include <linux/kernel.h>
> +#include <linux/log2.h>
>
> #include "pcie-cadence.h"
>
> @@ -15,7 +16,7 @@ void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 fn,
> * roundup_pow_of_two() returns an unsigned long, which is not suited
> * for 64bit values.
> */
Same here.
> - u64 sz = 1ULL << fls64(size - 1);
> + u64 sz = roundup_pow_of_two(size);
> int nbits = ilog2(sz);
> u32 addr0, addr1, desc0, desc1;
>
> --- a/drivers/pci/controller/pcie-rockchip-ep.c
> +++ b/drivers/pci/controller/pcie-rockchip-ep.c
> @@ -16,6 +16,7 @@
> #include <linux/platform_device.h>
> #include <linux/pci-epf.h>
> #include <linux/sizes.h>
> +#include <linux/log2.h>
>
> #include "pcie-rockchip.h"
>
> @@ -70,7 +71,7 @@ static void rockchip_pcie_prog_ep_ob_atu(struct rockchip_pcie *rockchip, u8 fn,
> u32 r, u32 type, u64 cpu_addr,
> u64 pci_addr, size_t size)
> {
> - u64 sz = 1ULL << fls64(size - 1);
> + u64 sz = roundup_pow_of_two(size);
> int num_pass_bits = ilog2(sz);
> u32 addr0, addr1, desc0, desc1;
> bool is_nor_msg = (type == AXI_WRAPPER_NOR_MSG);
> @@ -176,7 +177,7 @@ static int rockchip_pcie_ep_set_bar(struct pci_epc *epc, u8 fn,
> * roundup_pow_of_two() returns an unsigned long, which is not suited
> * for 64bit values.
> */
And here.
> - sz = 1ULL << fls64(sz - 1);
> + sz = roundup_pow_of_two(sz);
> aperture = ilog2(sz) - 7; /* 128B -> 0, 256B -> 1, 512B -> 2, ... */
>
> if ((flags & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) {
> diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
> index 6af7ae83c4ad..056886c4efec 100644
> --- a/kernel/dma/direct.c
> +++ b/kernel/dma/direct.c
> @@ -53,7 +53,7 @@ u64 dma_direct_get_required_mask(struct device *dev)
> {
> u64 max_dma = phys_to_dma_direct(dev, (max_pfn - 1) << PAGE_SHIFT);
>
> - return (1ULL << (fls64(max_dma) - 1)) * 2 - 1;
> + return rounddown_pow_of_two(max_dma) * 2 - 1;
Personally I would probably make this one a separate patch since it's
qualitatively different than the others and it would avoid the slight
awkwardness of the non-greppable "roundup/down_pow_of_two()"
construction in the commit subject.
But it's fine either way.
> }
>
> static gfp_t __dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
> --
> 2.24.0
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-12-05 20:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-03 11:47 [PATCH v4 0/8] Raspberry Pi 4 PCIe support Nicolas Saenz Julienne
2019-12-03 11:47 ` [PATCH v4 1/8] dt-bindings: PCI: Add bindings for brcmstb's PCIe device Nicolas Saenz Julienne
2019-12-03 15:03 ` Andrew Murray
2019-12-03 11:47 ` [PATCH v4 2/8] ARM: dts: bcm2711: Enable PCIe controller Nicolas Saenz Julienne
2019-12-16 6:46 ` Jian-Hong Pan
2019-12-16 9:49 ` Nicolas Saenz Julienne
2019-12-03 11:47 ` [PATCH v4 3/8] PCI: brcmstb: Add Broadcom STB PCIe host controller driver Nicolas Saenz Julienne
2019-12-03 11:47 ` [PATCH v4 4/8] PCI: brcmstb: Add MSI support Nicolas Saenz Julienne
2019-12-03 11:47 ` [PATCH v4 6/8] arm64: defconfig: Enable Broadcom's STB PCIe controller Nicolas Saenz Julienne
2019-12-03 11:47 ` [PATCH v4 8/8] linux/log2.h: Use roundup/dow_pow_two() on 64bit calculations Nicolas Saenz Julienne
2019-12-03 15:53 ` Rob Herring
2019-12-03 16:06 ` Nicolas Saenz Julienne
2019-12-05 20:38 ` Bjorn Helgaas [this message]
2019-12-12 13:21 ` Nicolas Saenz Julienne
[not found] ` <20191203114743.1294-8-nsaenzjulienne@suse.de>
2019-12-03 16:39 ` [PATCH v4 7/8] linux/log2.h: Fix 64bit calculations in roundup/down_pow_two() Chuck Lever
2019-12-04 10:56 ` Martin Habets
2019-12-05 22:30 ` Bjorn Helgaas
2019-12-12 13:16 ` Nicolas Saenz Julienne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191205203845.GA243596@google.com \
--to=helgaas@kernel$(echo .)org \
--cc=andrew.murray@arm$(echo .)com \
--cc=bcm-kernel-feedback-list@broadcom$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=devicetree@vger$(echo .)kernel.org \
--cc=eric@anholt$(echo .)net \
--cc=f.fainelli@gmail$(echo .)com \
--cc=frowand.list@gmail$(echo .)com \
--cc=guohanjun@huawei$(echo .)com \
--cc=hch@lst$(echo .)de \
--cc=heiko@sntech$(echo .)de \
--cc=iommu@lists$(echo .)linux-foundation.org \
--cc=james.quinlan@broadcom$(echo .)com \
--cc=jeremy.linton@arm$(echo .)com \
--cc=lenb@kernel$(echo .)org \
--cc=linux-acpi@vger$(echo .)kernel.org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-pci@vger$(echo .)kernel.org \
--cc=linux-rdma@vger$(echo .)kernel.org \
--cc=linux-rockchip@lists$(echo .)infradead.org \
--cc=linux-rpi-kernel@lists$(echo .)infradead.org \
--cc=lorenzo.pieralisi@arm$(echo .)com \
--cc=m.szyprowski@samsung$(echo .)com \
--cc=maz@kernel$(echo .)org \
--cc=mbrugger@suse$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nsaenzjulienne@suse$(echo .)de \
--cc=phil@raspberrypi$(echo .)org \
--cc=rjw@rjwysocki$(echo .)net \
--cc=robh+dt@kernel$(echo .)org \
--cc=robin.murphy@arm$(echo .)com \
--cc=shawn.lin@rock-chips$(echo .)com \
--cc=sudeep.holla@arm$(echo .)com \
--cc=tariqt@mellanox$(echo .)com \
--cc=wahrenst@gmx$(echo .)net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox