public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Niklas Cassel <cassel@kernel.org>,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: "Krzysztof Wilczyński" <kw@linux.com>,
	"Kishon Vijay Abraham I" <kishon@kernel.org>,
	linux-pci@vger.kernel.org, "Frank Li" <Frank.Li@nxp.com>
Subject: Re: [PATCH v2 0/2] PCI endpoint test: Add support for capabilities
Date: Wed, 27 Nov 2024 20:40:08 +0900	[thread overview]
Message-ID: <2633ef1d-8651-4f03-844f-7e8cf8099e30@kernel.org> (raw)
In-Reply-To: <Z0cBFjK1WgSmg6k5@ryzen>

On 11/27/24 20:23, Niklas Cassel wrote:

[...]

> IMO, an EPF driver should be able to write to any PCI address.
> (Especially since this can be solved trivially by EPF drivers simply using
> pci_epc_mem_map()/unmap())
> 
> E.g. the upcoming NVMe EPF driver uses the NVMe host side driver.
> This host side driver does no magic padding on host side for endpoints
> (NVMe controllers) that have an iATU with outbound address alignment
> restriction.

Not to mention that per NVMe specs, there should be no alignment constraints for
IO buffers. Anything is OK. And you can see it running this EPF driver while
going through a host boot sequence and using nvme-cli: the BIOS probing the NVMe
drive, GRUB looking at the NVMe drive and nvme-cli using on-stack buffers result
is high randomness of the buffer alignments. Trying to get that to work in all
cases led to the pci_epc_mem_map()/unmap() API :)

So having the test EPF driver allowing testing such unaligned pattern would
definitely help solidify the endpoint framework and its endpoint controller drivers.

> Imagine e.g. another EPF driver, for another existing protocol, e.g. AHCI.
> Modifying existing generic Linux drivers (e.g. the AHCI driver), simply because
> some random EPC driver has a specific outbound alignment requirement (that can
> simply be ignored by using pci_epc_mem_map/unmap()) does not make sense IMO.
> 
> 
>>
>> That being said, I really like to get rid of the hardcoded
>> 'pci_endpoint_test_data::alignment' field and make the driver learn about it
>> dynamically. I'm just thinking out loud here.
> 
> That would certainly be possible, by simply dedicating a new register to that
> in the test BAR (struct pci_epf_test_reg). However, I think that that would be
> a worse alternative compared to what this series is proposing.
> 
> The only ugliness in my opinion is that we are setting the CAP_UNALIGNED_ACCESS
> capability based on if an EPC driver has implemented the .align_addr callback.
> 
> If we could simply implement .align_addr() in the two missing EPC drivers:
> drivers/pci/controller/cadence/pcie-cadence-ep.c

At least for this one, it is likely exactly the same as for
drivers/pci/controller/pcie-rockchip-ep.c. The code for these 2 drivers is
suspiciously similar, which strongly hints at the fact that the HW is most
likely based on the same IP blocks.

> drivers/pci/controller/pcie-rcar-ep.c
> 
> pci-epf-test.c could set the CAP_UNALIGNED_ACCESS capability unconditionally.
> 
> However, I do not have the hardware for those two drivers, so I cannot
> implement .align_addr() for those myself.
> 
> So in order to be able to move forward, I think that simply letting
> pci-epf-test.c check if the EPC driver which is currently in use has
> implemented the .align_addr callback, is a tolerable ugliness.
> 
> Once all EPC drivers have implemented .align_addr(), we could change
> pci-epf-test.c to unconditionally set the CAP_UNALIGNED_ACCESS capability.
> 
> 
> Kind regards,
> Niklas


-- 
Damien Le Moal
Western Digital Research

  parent reply	other threads:[~2024-11-27 11:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-21 15:23 [PATCH v2 0/2] PCI endpoint test: Add support for capabilities Niklas Cassel
2024-11-21 15:23 ` [PATCH v2 1/2] PCI: endpoint: pci-epf-test: " Niklas Cassel
2024-11-21 19:38   ` Frank Li
2024-11-30  8:12   ` Manivannan Sadhasivam
2024-12-03  4:43     ` Niklas Cassel
2024-12-08 12:42       ` Manivannan Sadhasivam
2024-12-12  8:49         ` Niklas Cassel
2024-11-21 15:23 ` [PATCH v2 2/2] misc: pci_endpoint_test: " Niklas Cassel
2024-11-21 19:43   ` Frank Li
2024-11-25 15:17     ` Niklas Cassel
2024-11-30  8:21   ` Manivannan Sadhasivam
2024-12-03  4:48     ` Niklas Cassel
2024-11-26 13:20 ` [PATCH v2 0/2] PCI endpoint test: " Manivannan Sadhasivam
2024-11-27 11:23   ` Niklas Cassel
2024-11-27 11:32     ` Niklas Cassel
2024-11-27 11:55       ` Niklas Cassel
2024-11-27 11:40     ` Damien Le Moal [this message]
2024-11-30  8:05     ` Manivannan Sadhasivam

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=2633ef1d-8651-4f03-844f-7e8cf8099e30@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=Frank.Li@nxp.com \
    --cc=cassel@kernel.org \
    --cc=kishon@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.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