[PATCH] dt-bindings: PCI: mediatek-gen3: Allow memory-region for restricted DMA buffer

Manivannan Sadhasivam mani at kernel.org
Fri May 15 05:34:29 PDT 2026


On Fri, May 15, 2026 at 05:16:19PM +0800, Chen-Yu Tsai wrote:
> On Thu, May 14, 2026 at 7:48 PM Manivannan Sadhasivam <mani at kernel.org> wrote:
> >
> > On Thu, May 14, 2026 at 03:54:29PM +0800, Chen-Yu Tsai wrote:
> > > On Thu, May 14, 2026 at 1:23 PM Manivannan Sadhasivam <mani at kernel.org> wrote:
> > > >
> > > > On Fri, May 08, 2026 at 02:36:32PM +0800, Chen-Yu Tsai wrote:
> > > > > On some SoCs without an IOMMU behind the PCIe controller, the PCIe
> > > > > controller memory access could be limited to a small region by the
> > > > > firmware configuring a memory protection unit. This memory region
> > > > > must be assigned to the PCIe controller so that the OS knows to
> > > > > use that region. Otherwise PCIe devices would not work properly.
> > > > >
> > > >
> > > > So this means, the PCIe devices can only access a specific carveout memory
> > > > configured by MPU for DMA? If so, you should use 'dma-ranges' as suggested by
> > > > Rob.
> > > >
> > > > 'memory-region' also serves the purpose, but for PCI, we have the dedicated
> > > > 'dma-ranges' property.
> > >
> > > I think I need some sort of guide on writing the 'dma-ranges' property,
> > > because it is not working for me.
> > >
> > > I'm adding
> > >
> > >     dma-ranges = <0x42000000 0 0x00000000 0 0xc0000000 0 0x4000000>;
> > >
> >
> > So the device DMA address start from 0x0? Isn't it a 1:1 mapping?
> 
> I actually don't know. But
> 
> >         dma-ranges = <0x42000000 0 0xc0000000 0 0xc0000000 0 0x4000000>;
> 
> this didn't work either.


Hmm. Can you print the DMA address programmed to the device? i.e., the address
returned by dma_map_single() in the driver.

Also, using prefetchable flag is not correct for DMA memory. You should use:

	dma-ranges = <0x02000000 0 0xc0000000 0 0xc0000000 0 0x4000000>;

- Mani

-- 
மணிவண்ணன் சதாசிவம்



More information about the Linux-mediatek mailing list