From: Frank Li <Frank.li@nxp.com>
To: Koichiro Den <den@valinux.co.jp>
Cc: kishon@kernel.org, jdmason@kudzu.us, mani@kernel.org,
dave.jiang@intel.com, allenbh@gmail.com, kwilczynski@kernel.org,
bhelgaas@google.com, jbrunet@baylibre.com, lpieralisi@kernel.org,
linux-pci@vger.kernel.org, ntb@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 05/10] PCI: endpoint: pci-epf-vntb: Implement db_vector_count/mask for doorbells
Date: Wed, 25 Feb 2026 16:02:01 -0500 [thread overview]
Message-ID: <aZ9jSS_sWVGnZwb6@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20260224133459.1741537-6-den@valinux.co.jp>
On Tue, Feb 24, 2026 at 10:34:54PM +0900, Koichiro Den wrote:
> Implement .db_vector_count and .db_vector_mask so ntb core/clients can map
> doorbell events to per-vector work and avoid the thundering-herd behavior.
>
> pci-epf-vntb reserves two slots in db_count: slot 0 for link events and
> slot 1 which is historically unused. Therefore the number of doorbell
> vectors is (db_count - 2).
>
> Report vectors as 0..N-1 and return BIT_ULL(db_vector) for the
> corresponding doorbell bit. While at it, use vntb_epf_db_vector_mask()
> to simplify vntb_epf_db_valid_mask().
>
> Signed-off-by: Koichiro Den <den@valinux.co.jp>
> ---
> drivers/pci/endpoint/functions/pci-epf-vntb.c | 36 +++++++++++++++++--
> 1 file changed, 34 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> index 2eb3db035644..b651c54d6bef 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> @@ -1267,12 +1267,42 @@ static int vntb_epf_peer_mw_count(struct ntb_dev *ntb)
> return ntb_ndev(ntb)->num_mws;
> }
>
> +static int vntb_epf_db_vector_count(struct ntb_dev *ntb)
> +{
> + struct epf_ntb *ndev = ntb_ndev(ntb);
> +
> + /*
> + * ndev->db_count is the total number of doorbell slots exposed to
> + * the peer, including:
> + * - slot #0 reserved for link events
> + * - slot #1 historically unused (kept for protocol compatibility)
> + *
> + * Report only usable per-vector doorbell interrupts.
> + */
> + if (ndev->db_count < 2)
> + return 0;
> +
> + return ndev->db_count - 2;
return max(ndev->db_count - 2, 0);
Frank
> +}
> +
> static u64 vntb_epf_db_valid_mask(struct ntb_dev *ntb)
> {
> - if (ntb_ndev(ntb)->db_count < 2)
> + return BIT_ULL(vntb_epf_db_vector_count(ntb)) - 1;
> +}
> +
> +static u64 vntb_epf_db_vector_mask(struct ntb_dev *ntb, int db_vector)
> +{
> + int nr_vec;
> +
> + /*
> + * Doorbell vectors are numbered [0 .. nr_vec - 1], where nr_vec
> + * excludes the two reserved slots described above.
> + */
> + nr_vec = vntb_epf_db_vector_count(ntb);
> + if (db_vector < 0 || db_vector >= nr_vec)
> return 0;
>
> - return BIT_ULL(ntb_ndev(ntb)->db_count - 2) - 1;
> + return BIT_ULL(db_vector);
> }
>
> static int vntb_epf_db_set_mask(struct ntb_dev *ntb, u64 db_bits)
> @@ -1512,6 +1542,8 @@ static const struct ntb_dev_ops vntb_epf_ops = {
> .spad_count = vntb_epf_spad_count,
> .peer_mw_count = vntb_epf_peer_mw_count,
> .db_valid_mask = vntb_epf_db_valid_mask,
> + .db_vector_count = vntb_epf_db_vector_count,
> + .db_vector_mask = vntb_epf_db_vector_mask,
> .db_set_mask = vntb_epf_db_set_mask,
> .mw_set_trans = vntb_epf_mw_set_trans,
> .mw_clear_trans = vntb_epf_mw_clear_trans,
> --
> 2.51.0
>
next prev parent reply other threads:[~2026-02-25 21:02 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 [this message]
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
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=aZ9jSS_sWVGnZwb6@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=allenbh@gmail.com \
--cc=bhelgaas@google.com \
--cc=dave.jiang@intel.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
all inboxes | Powered by JetHome®