public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: Koichiro Den <den@valinux.co.jp>
Cc: Manivannan Sadhasivam <mani@kernel.org>,
	bhelgaas@google.com, kwilczynski@kernel.org, frank.li@nxp.com,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 0/5] PCI: endpoint: BAR subrange mapping support
Date: Fri, 23 Jan 2026 09:35:01 +0100	[thread overview]
Message-ID: <aXMytcJTIeBHatIF@ryzen> (raw)
In-Reply-To: <nrvamhbpi4372c4qmb2q3h74irrqkntlb2rwfasiorgavylp25@rx2lp6ldk64j>

On Fri, Jan 23, 2026 at 04:11:08PM +0900, Koichiro Den wrote:
> 
> One additional concern if we were to add a subrange mapping test is that
> the EP-side pci-epf-test.c currently defines bar_size as follows:
> 
>   static size_t bar_size[] = { 512, 512, 1024, 16384, 131072, 1048576 };
>   (see https://github.com/torvalds/linux/blob/v6.19-rc6/drivers/pci/endpoint/functions/pci-epf-test.c#L105)
> 
> The values 512 (BAR0/1) and 1024 (BAR2) are even smaller than the minimam
> CX_ATU_MIN_REGION_SIZE (=4KB). This means that introducing
> BAR_SUBRANGE_TEST would likely require one of the following:
> 
>   (a). raising these hard-coded values
>   (b). reserving a dedicated BAR for the subrange mapping test
>   (c). limiting the testing to BAR3/4/5 if available (though, for
>        example, no BAR would pass the test on R-Car Spider which I'm
>        testing on, where BAR4 is fixed 256B).
> 
> I'm wondering whether there is a clean way to add a subrange mapping test
> without significantly reshaping pci-epf-test.

If you really want to implement a test, I suggest to look at:

pci_epf_test_enable_doorbell()
Which changes the address translation of a BAR dynamically.

pci_epf_test_disable_doorbell()
Which reverts back to the original translation.

pci_epf_test_enable_doorbell() simply does:
pci_epc_get_next_free_bar() to get a BAR, then writes the BAR
number in the in the pci-epf-test command registers, offset:
PCI_ENDPOINT_TEST_DB_BAR                0x34

(Which represent the offset in struct pci_epf_test, for
struct member db_bar)


However, the doorbells are most likely very small, so the chances
that reg->doorbell_offset will have a value that is smaller than
BAR size seems likely... but not guaranteed... and there is no

if (reg->doorbell_offset > epf->bar[bar].size)
    goto err_doorbell_cleanup;

So it seems that this doorbell test just ignores the problem...

Frank, could you perhaps send a patch to add something like the above?


For your case... I guess we could bump the default sizes in pci-epf-test
if we want to. pci-epf-test already does:

                if (epc_features->bar[bar].type == BAR_FIXED)
                        test_reg_size = epc_features->bar[bar].fixed_size;
                else
                        test_reg_size = bar_size[bar];

So if there are fixed size BARs, that size will be respected, so I don't
think there should be any problem to increase the default sizes, if we
wanted to.

E.g. RK3588 has CX_ATU_MIN_REGION_SIZE 64k

So if we wanted to, a good number would be to have at least a few BARs of size
128k or larger (so there could be two submaps), since I assume that some other
DWC controllers might also have have 64k min alignment.


Having a test for this feature in pci-epf-test sounds really nice.
You could have even add a capability for this, see
pci_epf_test_set_capabilities().

if (epf_test->epc_features->subrange_mapping)
	caps |= CAP_SUBRANGE_MAPPING;


Such that the host side driver (drivers/misc/pci_endpoint_test.c) could return
a distinct error code when this feature is not supported, such that
tools/testing/selftests/pci_endpoint/pci_endpoint_test.c could return SKIP when
that distinct error code is detected.


Kind regards,
Niklas

  reply	other threads:[~2026-01-23  8:35 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-15  8:49 [PATCH v8 0/5] PCI: endpoint: BAR subrange mapping support Koichiro Den
2026-01-15  8:49 ` [PATCH v8 1/5] PCI: endpoint: Add dynamic_inbound_mapping EPC feature Koichiro Den
2026-01-15  8:49 ` [PATCH v8 2/5] PCI: endpoint: Add BAR subrange mapping support Koichiro Den
2026-01-15 14:52   ` Frank Li
2026-01-15 15:21     ` Niklas Cassel
2026-01-15 19:44       ` Frank Li
2026-01-19  8:42     ` Koichiro Den
2026-01-15  8:49 ` [PATCH v8 3/5] PCI: dwc: Advertise dynamic inbound " Koichiro Den
2026-01-15 14:54   ` Frank Li
2026-01-15  8:49 ` [PATCH v8 4/5] PCI: dwc: ep: Support BAR subrange inbound mapping via Address Match Mode iATU Koichiro Den
2026-01-15 15:22   ` Frank Li
2026-01-15  8:49 ` [PATCH v8 5/5] Documentation: PCI: endpoint: Clarify pci_epc_set_bar() usage Koichiro Den
2026-01-15 15:23   ` Frank Li
2026-01-19 13:00 ` [PATCH v8 0/5] PCI: endpoint: BAR subrange mapping support Koichiro Den
2026-01-21 15:38   ` Manivannan Sadhasivam
2026-01-22  1:52     ` Koichiro Den
2026-01-22  6:46       ` Manivannan Sadhasivam
2026-01-22  8:45       ` Niklas Cassel
2026-01-22 14:02         ` Koichiro Den
2026-01-22 15:17           ` Niklas Cassel
2026-01-23  0:36             ` Koichiro Den
2026-01-23  7:11               ` Koichiro Den
2026-01-23  8:35                 ` Niklas Cassel [this message]
2026-01-23 10:16                   ` Niklas Cassel
2026-01-23 14:08                   ` Koichiro Den
2026-01-23 14:57                     ` Niklas Cassel
2026-01-26 14:26                       ` Koichiro Den
2026-01-26 19:08                         ` Niklas Cassel
2026-01-23 15:26                   ` Niklas Cassel

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=aXMytcJTIeBHatIF@ryzen \
    --to=cassel@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=den@valinux.co.jp \
    --cc=frank.li@nxp.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mani@kernel.org \
    /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