Re: [PATCH v8 8/9] PCI: endpoint: pci-epf-test: Reuse pre-exposed doorbell targets
From: Niklas Cassel <cassel@kernel.org>
Date: 2026-02-17 10:15:15
Also in:
linux-pci, linux-rockchip, lkml
Hello Koichiro, On Tue, Feb 17, 2026 at 05:06:00PM +0900, Koichiro Den wrote:
pci-epf-test advertises the doorbell target to the RC as a BAR number and an offset, and the RC rings the doorbell with a single DWORD MMIO write. Some doorbell backends may report that the doorbell target is already exposed via a platform-owned fixed BAR (db_msg[0].bar/offset). In that case, reuse the pre-exposed window and do not reprogram the BAR with pci_epc_set_bar(). Also honor db_msg[0].irq_flags when requesting the doorbell IRQ, and only restore the original BAR mapping on disable if pci-epf-test programmed it. Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Koichiro Den <redacted> ---
(snip)
quoted hunk ↗ jump to hunk
@@ -753,22 +771,33 @@ static void pci_epf_test_enable_doorbell(struct pci_epf_test *epf_test, reg->doorbell_data = cpu_to_le32(msg->data); reg->doorbell_bar = cpu_to_le32(bar); - msg = &epf->db_msg[0].msg; - ret = pci_epf_align_inbound_addr(epf, bar, ((u64)msg->address_hi << 32) | msg->address_lo, - &epf_test->db_bar.phys_addr, &offset); + if (db->bar == NO_BAR) { + ret = pci_epf_align_inbound_addr(epf, bar, + ((u64)msg->address_hi << 32) | + msg->address_lo, + &epf_test->db_bar.phys_addr, + &offset); - if (ret) - goto err_free_irq; + if (ret) + goto err_free_irq; + }
I tried this series on Rock5b (RK3588), and was surprised to see the doorbell test case still failing.
+ + if (size_add(offset, sizeof(u32)) > epf->bar[bar].size) + goto err_doorbell_cleanup;
It turns out that this check is the reason for it still failing. You see, for a BAR that is marked as BAR_RESERVED, pci-epf-test will not allocate backing memory, so epf->bar[bar].size will be 0. If I removed this check, I could get the test case to pass. As I suggested in my previous email, perhaps this check is better suited in pci_epf_alloc_doorbell(). (As a DWORD alignment check inside pci_epf_alloc_doorbell(). pci_epf_alloc_doorbell() could itself return error if the doorbell is not DWORD aligned.) That way, you could remove this check from pci_epf_test_enable_doorbell(), and we don't need to care about epf->bar[bar].size. Kind regards, Niklas