From: Niklas Cassel <cassel@kernel.org>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: "Sumit Kumar" <sumit.kumar@oss.qualcomm.com>,
"Jingoo Han" <jingoohan1@gmail.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] pci: designware: Set DMA_BYPASS bit in outbound IATU CTRL2 register
Date: Tue, 13 Oct 2026 21:00:46 +0200 [thread overview]
Message-ID: <as5_1qSjdTfwcTD6@ryzen> (raw)
In-Reply-To: <179191191767.12828.2752703637384946037.b4-reply@b4>
On Tue, Oct 13, 2026 at 10:48:37PM +0530, Manivannan Sadhasivam wrote:
> On 2026-09-13 19:16 +0200, Niklas Cassel wrote:
> >
> > Without the patch in $subject, on a DWC based platform:
> >
> > pci_epc_mem_map() will setup an iATU entry, and the eDMA transaction will then
> > be translated using that iATU entry, before being sent out on the PCIe bus.
> >
>
> No, that's not true. While the pci_epc_mem_map() does setup an iATU entry, eDMA
> transaction doesn't use the mapped address.
>
> If you look into the eDMA read path:
> pci_epc_mem_map()
> -> Allocates map.phys_addr and sets up an iATU entry
> pci_epf_test_data_transfer()
> -> dma_local points to address allocated by dma_map_single()
> (dma_dst)
> -> dma_remote points to RC address referenced in src_addr
> -> These two were passed to dmaengine_prep_config_single()
> ignoring the map.phys_addr passed through dma_src parameter.
>
> For eDMA write:
> pci_epc_mem_map()
> -> Allocates map.phys_addr and sets up an iATU entry
> pci_epf_test_data_transfer()
> -> dma_local points to address allocated by dma_map_single()
> (dma_src)
> -> dma_remote points to RC address referenced in dst_addr
> -> These two were passed to dmaengine_prep_config_single()
> ignoring the map.phys_addr passed through dma_dst parameter.
>
> So essentially, the address used by the eDMA is the raw RC PCIe address, not
> translated by the iATU. In fact, the Designware Databook also doesn't recommend
> setting up the iATU entry for the eDMA path. So the allocated iATU entry is
> useless.
I see, you are correct.
The pci-epf-test.c driver is very misleading, because if does:
...
pci_epc_mem_map();
if (flags & FLAG_USE_DMA) {
dma_map_single();
pci_epf_test_data_transfer();
} else {
memcpy_fromio();
}
pci_epc_mem_unmap();
This suggests to the reader that the mapping is used in both cases...
Why else would the mapping be done unconditionally?
I strongly suggest that the pci_epc_mem_map() and pci_epc_mem_unmap()
calls are moved into the "else" clause then.
Since this patch is already touching behavior related to this, it would be
nice if the patch author could also write a patch that cleans up this mess.
>
> But the issue this patch is trying to address is, if the raw PCI address or the
> dma_map_single address used by the eDMA happens to be present in one of the
> existing iATU mappings, then at that point, the address can get translated
> causing wrong address to be sent over the bus.
I do understand the problem that this patch is trying to solve.
> > I am happy that this is getting cleaned up, I just don't like a half cleanup
> > where we, after this commit, will setup+teardown iATU entries that will then
> > never be used for the actual transaction.
> >
>
> This should be done as a follow-up, not blocking this patch.
Fine with me.
Kind regards,
Niklas
prev parent reply other threads:[~2026-10-13 19:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 6:18 [PATCH v2] pci: designware: Set DMA_BYPASS bit in outbound IATU CTRL2 register Sumit Kumar
2026-09-08 6:25 ` sashiko-bot
2026-09-08 15:08 ` Niklas Cassel
2026-09-13 9:35 ` Manivannan Sadhasivam
2026-09-13 17:16 ` Niklas Cassel
2026-10-13 17:18 ` Manivannan Sadhasivam
2026-10-13 19:00 ` Niklas Cassel [this message]
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=as5_1qSjdTfwcTD6@ryzen \
--to=cassel@kernel.org \
--cc=bhelgaas@google.com \
--cc=jingoohan1@gmail.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
--cc=sumit.kumar@oss.qualcomm.com \
/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.