Re: [PATCH v8 8/9] PCI: endpoint: pci-epf-test: Reuse pre-exposed doorbell targets

Niklas Cassel <[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 <aZQ_rEkzWnDeJrMe@ryzen>
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.


> +
> +	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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.