Re: [PATCH v8 8/9] PCI: endpoint: pci-epf-test: Reuse pre-exposed doorbell targets
Koichiro Den <[email protected]>
| Newsgroups | dev.linux.lists.ntb,org.infradead.lists.linux-arm-kernel,org.infradead.lists.linux-rockchip,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <2ltjmhbw5s6t3emem5jron6v6frmfi46k6mmooukqaviyi3ktk@wpsuu5h6fqag> |
On Tue, Feb 17, 2026 at 11:15:08AM +0100, Niklas Cassel wrote: > 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 <[email protected]> > > Signed-off-by: Koichiro Den <[email protected]> > > --- > > (snip) > > > @@ -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. Thank you very much for testing, and apologies for not being able to test on RK3588 on my side right now. > > > > + > > + 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.) Yes, and I mentioned there I would reconsider this when respinning this feature series. For reference: https://lore.kernel.org/linux-pci/jcjson6zedvhkpctwzfao2wfaaujtdfqsnnm3k25e2vpz2evf4@hbsegnyevisu/ I hadn't noticed the bar.size==0 possibility at that time. I agree that this check is better placed in pci_epf_alloc_doorbell(). I'll respin accordingly. Thanks again for the testing and review, Koichiro > > 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