]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
PCI: mediatek-gen3: Fix translation window size calculation
authorJianjun Wang <jianjun.wang@mediatek.com>
Mon, 23 Oct 2023 08:14:23 +0000 (16:14 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:27:48 +0000 (15:27 -0800)
commit69f0bebe9166f389ac508b3d5536d6dff93273e2
tree16bc1fc8b2bc354e6d78ebb717e4dc1d9955a180
parent94667790e5e316201d4b9a5072af00e14ad492f0
PCI: mediatek-gen3: Fix translation window size calculation

[ Upstream commit 9ccc1318cf4bd90601f221268e42c3374703d681 ]

When using the fls() helper, the translation table should be a power of
two; otherwise, the resulting value will not be correct.

For example, given fls(0x3e00000) - 1 = 25, the PCIe translation window
size will be set to 0x2000000 instead of the expected size 0x3e00000.

Fix the translation window by splitting the MMIO space into multiple tables
if its size is not a power of two.

[kwilczynski: commit log]
Link: https://lore.kernel.org/linux-pci/20231023081423.18559-1-jianjun.wang@mediatek.com
Fixes: d3bf75b579b9 ("PCI: mediatek-gen3: Add MediaTek Gen3 driver for MT8192")
Signed-off-by: Jianjun Wang <jianjun.wang@mediatek.com>
Signed-off-by: Krzysztof WilczyƄski <kwilczynski@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pci/controller/pcie-mediatek-gen3.c