From: Dave Jiang <dave.jiang@intel.com>
To: Koichiro Den <den@valinux.co.jp>,
Frank.Li@nxp.com, kishon@kernel.org, jdmason@kudzu.us,
mani@kernel.org, allenbh@gmail.com, kwilczynski@kernel.org,
bhelgaas@google.com, jbrunet@baylibre.com, lpieralisi@kernel.org
Cc: linux-pci@vger.kernel.org, ntb@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 06/10] NTB: epf: Document legacy doorbell slot offset in ntb_epf_peer_db_set()
Date: Wed, 25 Feb 2026 09:46:33 -0700 [thread overview]
Message-ID: <38d9206d-08a3-4b69-a97f-902160bd9e31@intel.com> (raw)
In-Reply-To: <20260224133459.1741537-7-den@valinux.co.jp>
On 2/24/26 6:34 AM, Koichiro Den wrote:
> ntb_epf_peer_db_set() uses ffs(db_bits) to select a doorbell to ring.
> ffs() returns a 1-based bit index (bit 0 -> 1).
>
> Entry 0 is reserved for link events, so doorbell bit 0 must map to entry
> 1. However, since the initial commit 812ce2f8d14e ("NTB: Add support for
> EPF PCI Non-Transparent Bridge"), the implementation has been adding an
> extra +1, ending up using entry 2 for bit 0. Fixing the extra increment
> would break interoperability with peers running older kernels.
>
> Keep the legacy behavior and document the offset and the resulting slot
> layout to avoid confusion when enabling per-db-vector handling.
>
> Signed-off-by: Koichiro Den <den@valinux.co.jp>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/ntb/hw/epf/ntb_hw_epf.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/ntb/hw/epf/ntb_hw_epf.c b/drivers/ntb/hw/epf/ntb_hw_epf.c
> index d3ecf25a5162..bce7130fec39 100644
> --- a/drivers/ntb/hw/epf/ntb_hw_epf.c
> +++ b/drivers/ntb/hw/epf/ntb_hw_epf.c
> @@ -43,6 +43,18 @@
> #define NTB_EPF_DB_DATA(n) (0x34 + (n) * 4)
> #define NTB_EPF_DB_OFFSET(n) (0xB4 + (n) * 4)
>
> +/*
> + * Legacy doorbell slot layout when paired with pci-epf-*ntb:
> + *
> + * slot 0 : reserved for link events
> + * slot 1 : unused (historical extra offset)
> + * slot 2 : DB#0
> + * slot 3 : DB#1
> + * ...
> + *
> + * Thus, NTB_EPF_MIN_DB_COUNT=3 means that we at least create vectors for
> + * doorbells DB#0 and DB#1.
> + */
> #define NTB_EPF_MIN_DB_COUNT 3
> #define NTB_EPF_MAX_DB_COUNT 31
>
> @@ -473,6 +485,14 @@ static int ntb_epf_peer_mw_get_addr(struct ntb_dev *ntb, int idx,
> static int ntb_epf_peer_db_set(struct ntb_dev *ntb, u64 db_bits)
> {
> struct ntb_epf_dev *ndev = ntb_ndev(ntb);
> + /*
> + * ffs() returns a 1-based bit index (bit 0 -> 1).
> + *
> + * With slot 0 reserved for link events, DB#0 would naturally map to
> + * slot 1. Historically an extra +1 offset was added, so DB#0 maps to
> + * slot 2 and slot 1 remains unused. Keep this mapping for
> + * backward-compatibility.
> + */
> u32 interrupt_num = ffs(db_bits) + 1;
> struct device *dev = ndev->dev;
> u32 db_entry_size;
next prev parent reply other threads:[~2026-02-25 16:46 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 13:34 [PATCH 00/10] NTB: epf: Enable per-doorbell bit handling while keeping legacy offset Koichiro Den
2026-02-24 13:34 ` [PATCH 01/10] PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset Koichiro Den
2026-02-25 20:34 ` Frank Li
2026-02-24 13:34 ` [PATCH 02/10] PCI: endpoint: pci-epf-vntb: Defer pci_epc_raise_irq() out of atomic context Koichiro Den
2026-02-25 20:36 ` Frank Li
2026-02-26 1:02 ` Koichiro Den
2026-02-27 7:32 ` Koichiro Den
2026-02-24 13:34 ` [PATCH 03/10] PCI: endpoint: pci-epf-vntb: Report 0-based doorbell vector via ntb_db_event() Koichiro Den
2026-02-25 20:54 ` Frank Li
2026-02-24 13:34 ` [PATCH 04/10] PCI: endpoint: pci-epf-vntb: Exclude reserved slots from db_valid_mask Koichiro Den
2026-02-25 20:55 ` Frank Li
2026-02-24 13:34 ` [PATCH 05/10] PCI: endpoint: pci-epf-vntb: Implement db_vector_count/mask for doorbells Koichiro Den
2026-02-25 21:02 ` Frank Li
2026-02-27 6:23 ` Koichiro Den
2026-02-24 13:34 ` [PATCH 06/10] NTB: epf: Document legacy doorbell slot offset in ntb_epf_peer_db_set() Koichiro Den
2026-02-25 16:46 ` Dave Jiang [this message]
2026-02-25 21:03 ` Frank Li
2026-02-24 13:34 ` [PATCH 07/10] NTB: epf: Make db_valid_mask cover only real doorbell bits Koichiro Den
2026-02-25 16:47 ` Dave Jiang
2026-02-26 3:24 ` Koichiro Den
2026-02-25 21:07 ` Frank Li
2026-02-26 1:25 ` Koichiro Den
2026-02-24 13:34 ` [PATCH 08/10] NTB: epf: Report 0-based doorbell vector via ntb_db_event() Koichiro Den
2026-02-25 16:59 ` Dave Jiang
2026-02-26 3:17 ` Koichiro Den
2026-02-25 21:09 ` Frank Li
2026-02-24 13:34 ` [PATCH 09/10] NTB: epf: Fix doorbell bitmask handling in db_read/db_clear Koichiro Den
2026-02-25 17:04 ` Dave Jiang
2026-02-25 21:11 ` Frank Li
2026-02-24 13:34 ` [PATCH 10/10] NTB: epf: Implement db_vector_count/mask for doorbells Koichiro Den
2026-02-25 17:09 ` Dave Jiang
2026-02-25 21:13 ` Frank Li
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=38d9206d-08a3-4b69-a97f-902160bd9e31@intel.com \
--to=dave.jiang@intel.com \
--cc=Frank.Li@nxp.com \
--cc=allenbh@gmail.com \
--cc=bhelgaas@google.com \
--cc=den@valinux.co.jp \
--cc=jbrunet@baylibre.com \
--cc=jdmason@kudzu.us \
--cc=kishon@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=ntb@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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