]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
NTB: epf: Make db_valid_mask cover only real doorbell bits
authorKoichiro Den <den@valinux.co.jp>
Wed, 13 May 2026 02:49:20 +0000 (11:49 +0900)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 23 Jun 2026 16:37:44 +0000 (11:37 -0500)
ndev->db_count includes an unused doorbell slot due to the legacy extra
offset in the peer doorbell path. db_valid_mask must cover only the real
doorbell bits and exclude the unused slot.

Set db_valid_mask to BIT_ULL(db_count - 1) - 1.

Fixes: 812ce2f8d14e ("NTB: Add support for EPF PCI Non-Transparent Bridge")
Signed-off-by: Koichiro Den <den@valinux.co.jp>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://patch.msgid.link/20260513024923.451765-10-den@valinux.co.jp
drivers/ntb/hw/epf/ntb_hw_epf.c

index 21d9428249835a381b8486c1cbb25c42ad5406bd..c0bab3292075ce40bf624ce61eb0a491f3d41a3c 100644 (file)
@@ -580,7 +580,11 @@ static int ntb_epf_init_dev(struct ntb_epf_dev *ndev)
                return ret;
        }
 
-       ndev->db_valid_mask = BIT_ULL(ndev->db_count) - 1;
+       /*
+        * ndev->db_count includes an extra skipped slot due to the legacy
+        * doorbell layout, hence -1.
+        */
+       ndev->db_valid_mask = BIT_ULL(ndev->db_count - 1) - 1;
        ndev->mw_count = readl(ndev->ctrl_reg + NTB_EPF_MW_COUNT);
        ndev->spad_count = readl(ndev->ctrl_reg + NTB_EPF_SPAD_COUNT);