]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PCI: endpoint: pci-epf-vntb: Exclude reserved slots from db_valid_mask
authorKoichiro Den <den@valinux.co.jp>
Wed, 13 May 2026 02:49:17 +0000 (11:49 +0900)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 23 Jun 2026 15:41:47 +0000 (10:41 -0500)
In pci-epf-vntb, db_count represents the total number of doorbell slots
exposed to the peer, including:

  - slot #0 reserved for link events, and

  - slot #1 historically unused (kept for compatibility).

Only the remaining slots correspond to actual doorbell bits. The current
db_valid_mask() exposes all slots as valid doorbells.

Limit db_valid_mask() to the real doorbell bits by returning
BIT_ULL(db_count - 2) - 1, and guard against db_count < 2.

Fixes: e35f56bb0330 ("PCI: endpoint: Support NTB transfer between RC and EP")
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>
Link: https://patch.msgid.link/20260513024923.451765-7-den@valinux.co.jp
drivers/pci/endpoint/functions/pci-epf-vntb.c

index 524355a8b4bedab4dee6309a20ff550609437ce6..58e41d95d029c02a31dceadb6407d9309a26adc2 100644 (file)
@@ -1364,7 +1364,10 @@ static int vntb_epf_peer_mw_count(struct ntb_dev *ntb)
 
 static u64 vntb_epf_db_valid_mask(struct ntb_dev *ntb)
 {
-       return BIT_ULL(ntb_ndev(ntb)->db_count) - 1;
+       if (ntb_ndev(ntb)->db_count < EPF_IRQ_DB_START)
+               return 0;
+
+       return BIT_ULL(ntb_ndev(ntb)->db_count - EPF_IRQ_DB_START) - 1;
 }
 
 static int vntb_epf_db_set_mask(struct ntb_dev *ntb, u64 db_bits)