mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <mani@kernel.org>
To: Niklas Cassel <cassel@kernel.org>
Cc: "Manivannan Sadhasivam" <mani@kernel.org>,
	"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 22:48:37 +0530	[thread overview]
Message-ID: <179191191767.12828.2752703637384946037.b4-reply@b4> (raw)
In-Reply-To: <aqbahGslz11TWIRo@fedora>

On 2026-09-13 19:16 +0200, Niklas Cassel wrote:
> On Sun, Sep 13, 2026 at 11:35:59AM +0200, Manivannan Sadhasivam wrote:
> > 
> > pci_epc_mem_map() is already useless in the eDMA path today. So this patch
> > doesn't change that.
> 
> I'm not sure if useless is the proper word here.
> Redundant is perhaps a better word.
> 

No, it is useless indeed. See below.

> 
> Let me explain using pci-epf-test.c:pci_epf_test_read() as an example:
> 
> 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.

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.

> So the iATU entry is actually being used.
> 
> 
> After the patch in $subject, on a DWC based platform:
> 
> pci_epc_mem_map() will setup an iATU entry, however, because of the DMA_BYPASS
> bit, that iATU entry will not be used, and the transaction will be send out on
> the PCIe bus untranslated.
> 

This is the current behaviour as well.

> 
> So I would argue that it is only after this patch that pci_epc_mem_map() will
> setup an iATU entry that will then never be used.
> 
> Yes, I think I understand that you are trying to say that, for DWC based
> drivers, we could theoretically skip the pci_epc_mem_map() call, and send the
> transaction untranslated.
> 
> My point is that it feels silly to set the DMA_BYPASS bit without also making
> sure that the pci_epc_mem_map() calls are either removed or (at least for DWC
> based platforms) modified to not set up an iATU entry in the DMA path in the
> first place.
> 

This I agree. But this also needs some careful analysis as other DMA controllers
other than eDMA might need the mapping. For eDMA, it is also not straightforward
as we do not pass any 'I'm using DMA' flag to map_addr() callback.

> 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.

- Mani


  reply	other threads:[~2026-10-13 17:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08  6:18 Sumit Kumar
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 [this message]
2026-10-13 19:00         ` Niklas Cassel
2026-10-14  6:18 ` Manivannan Sadhasivam
2026-10-14 19:20 ` Bjorn Helgaas
2026-10-15  5:40   ` Manivannan Sadhasivam
2026-10-19 21:55     ` Bjorn Helgaas
2026-10-19 21:56       ` Bjorn Helgaas

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=179191191767.12828.2752703637384946037.b4-reply@b4 \
    --to=mani@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=cassel@kernel.org \
    --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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®