All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: "Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Kishon Vijay Abraham I" <kishon@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Jingoo Han" <jingoohan1@gmail.com>,
	linux-pci@vger.kernel.org,
	"Rick Wertenbroek" <rick.wertenbroek@gmail.com>
Subject: Re: [PATCH v3 6/7] PCI: endpoint: test: Use pci_epc_mem_map/unmap()
Date: Sun, 6 Oct 2024 13:48:04 +0200	[thread overview]
Message-ID: <ZwJ49NkwhKpeuwKa@ryzen.lan> (raw)
In-Reply-To: <a3c93ede-adc8-4f4d-9da1-da8241ddeffc@kernel.org>

On Fri, Oct 04, 2024 at 10:47:01PM +0900, Damien Le Moal wrote:
> On 10/4/24 21:11, Niklas Cassel wrote:

(snip)

> > I think that you need to also include the patch that implements map_align()
> > for rk3399 in this series (without any other rk3399 patches), such that the
> > API actually makes sense.
> 
> This is coming in a followup series. Note that the Cadence controller also look
> suspiciously similar to the rk3399, so it may need the same treatment.

I strongly think that you should continue to include patch:
"PCI: rockchip-ep: Implement the map_align endpoint controller operation"
(that was part of your V2) in this series.

(Just do not include any of the other random fixes for rockchip-ep that
were part of your V2.)

Because without an implementer of the API that can actually return a size
smaller than requested, the current API makes no sense.

We do send out a series that provides a complex API if there is no implementer
(in that same series) which require the complexity. The single implementer in
this series (DWC PCIe EP), does not require the complexity of the API.

(The reason for this is that it is possible (for whatever reason) that the
intended follow up series which adds an implementer which actually requires
this complex API, may never materialize/land, and in that case we are left
with technical debt/an overcomplicated API for no reason.)


> As for the need for the loop, let's not kid ourselves here: it was already
> needed because some controllers have limited window sizes and do not allow
> allocating large chunks of memory to map. That was never handled...

I agree.

For controllers which have a window size that is very small, the pci-epf-test
driver will currently not handle buffer sizes larger than the window size.
Adding a loop would solve that limitation.

But this information is currently completely missing for the commit log.

May I suggest that you:
1) Include a preparatory patch in this series, which adds the loop using the
   existing map functions. With the proper motivation in the commit log.
2) Add this patch which converts the pci-epf-test driver to use the new map
   API. The number of changed lines in this patch will thus be much smaller
   than it currently is, and it will be easier to review.


> > I understand that certain EPF drivers will need to map buffers larger
> > than that. But perhaps we can keep pci-epf-test.c simple, and introduce
> > the more complex logic in EPF drivers that actually need it?
> 
> But then it would not be much of test driver... We need to exercise corner cases
> as well.

Yes, your argument does make a lot of sense.


> > More complicated EPF drivers can then choose if they want to support only
> > the simple case (no looping case), but can also choose to support buffers
> > larger than pci_epc_max_mapping_for_address(), using looping (I assume that
> > each loop iteration will be able to map (at least) the same amount as the
> > first loop iteration).
> 
> How can they "choose" if the controller being used gives you a max mapping size
> that completely depend on the PCI address used by the RC ? Unless the protocol
> used by that function driver imposes constraint on the host on buffer alignment,
> the epf cannot choose anything here. E.g. NVMe epf needs to be able to handle
> anything.

What I meant was that PCI EPF drivers could simply (continue) to return error
if the buffer size was larger than the window size. But you have successfully
changed my mind, let's just add the loop.

(As my previous suggestion of letting an EPF driver call
pci_epc_max_mapping_for_address()/pci_epc_map_align(), and then based on if
the returned size being either smaller or larger than the window size, call
either a function that does no looping, or a function that does looping, might
actually be more error prone and more confusing compared to just having a
single transfer function which includes a loop.)


Kind regards,
Niklas

  reply	other threads:[~2024-10-06 11:48 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-04  5:07 [PATCH v3 0/7] Improve PCI memory mapping API Damien Le Moal
2024-10-04  5:07 ` [PATCH v3 1/7] PCI: endpoint: Introduce pci_epc_function_is_valid() Damien Le Moal
2024-10-04  5:07 ` [PATCH v3 2/7] PCI: endpoint: Improve pci_epc_mem_alloc_addr() Damien Le Moal
2024-10-04 11:45   ` Niklas Cassel
2024-10-04  5:07 ` [PATCH v3 3/7] PCI: endpoint: Introduce pci_epc_map_align() Damien Le Moal
2024-10-04 11:45   ` Niklas Cassel
2024-10-04  5:07 ` [PATCH v3 4/7] PCI: endpoint: Introduce pci_epc_mem_map()/unmap() Damien Le Moal
2024-10-04 11:47   ` Niklas Cassel
2024-10-04 13:29     ` Damien Le Moal
2024-10-07  2:01   ` kernel test robot
2024-10-04  5:07 ` [PATCH v3 5/7] PCI: endpoint: Update documentation Damien Le Moal
2024-10-04 11:51   ` Niklas Cassel
2024-10-04  5:07 ` [PATCH v3 6/7] PCI: endpoint: test: Use pci_epc_mem_map/unmap() Damien Le Moal
2024-10-04 12:11   ` Niklas Cassel
2024-10-04 13:47     ` Damien Le Moal
2024-10-06 11:48       ` Niklas Cassel [this message]
2024-10-06 22:15         ` Damien Le Moal
2024-10-04  5:07 ` [PATCH v3 7/7] PCI: dwc: endpoint: Define the .map_align() controller operation Damien Le Moal
2024-10-04 12:12   ` Niklas Cassel
2024-10-04 11:45 ` [PATCH v3 0/7] Improve PCI memory mapping API Niklas Cassel
2024-10-04 13:13 ` Niklas Cassel
2024-10-04 13:25   ` Damien Le Moal
2024-10-06 11:46     ` 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=ZwJ49NkwhKpeuwKa@ryzen.lan \
    --to=cassel@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=corbet@lwn.net \
    --cc=dlemoal@kernel.org \
    --cc=jingoohan1@gmail.com \
    --cc=kishon@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=rick.wertenbroek@gmail.com \
    --cc=robh@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.