Re: [PATCH v9 1/5] dt-bindings: reserved-memory: Document iommu-addresses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2022-10-07 16:22, Thierry Reding wrote:
On Fri, Oct 07, 2022 at 03:21:46PM +0100, Robin Murphy wrote:
On 2022-10-07 14:54, Thierry Reding wrote:
On Fri, Oct 07, 2022 at 02:45:31PM +0100, Robin Murphy wrote:
On 2022-09-23 13:35, Thierry Reding wrote:
From: Thierry Reding <treding@xxxxxxxxxx>

This adds the "iommu-addresses" property to reserved-memory nodes, which
allow describing the interaction of memory regions with IOMMUs. Two use-
cases are supported:

     1. Static mappings can be described by pairing the "iommu-addresses"
        property with a "reg" property. This is mostly useful for adopting
        firmware-allocated buffers via identity mappings. One common use-
        case where this is required is if early firmware or bootloaders
        have set up a bootsplash framebuffer that a display controller is
        actively scanning out from during the operating system boot
        process.

     2. If an "iommu-addresses" property exists without a "reg" property,
        the reserved-memory node describes an IOVA reservation. Such memory
        regions are excluded from the IOVA space available to operating
        system drivers and can be used for regions that must not be used to
        map arbitrary buffers.

Bah, I've only just realised: don't we also need to change the "oneOf:
required: ..." schema to permit "iommu-addresses" without "reg" or "size"?

Hm... good point. I think at least we'll want another:

       - required:
           - iommu-addresses

in there. I wonder if we also need to avoid the combination of "size"
and "iommu-addresses". When "size" is specified, is it guaranteed that
those regions will be allocated before the direct mapping needs to be
created?

Well, it couldn't really be a direct mapping anyway. In general I don't
think that combination makes any sense, since the presence of
"iommu-addresses" means one of two things; either it says the IOVA range is
carved out for some special purpose or just unusable, in which case
allocating any memory to back it would surely be pointless, or it's saying
don't touch these addresses because the device is already accessing them,
thus the underlying physical memory must be allocated somewhere already.

I thought perhaps there could be cases where it is known that a
controller needs to access memory in a certain I/O virtual region but
doesn't actually care where that lives in physical memory and also does
not rely on that memory have been previously set up (pre-filled, or
whatever). Say you've got a micro-controller in a system that needs its
firmware in a given region, but the OS can set up that region without
any other limitations. One could use "size" and "iommu-addresses" to
make sure the region is allocated with a specific size and located in a
specific I/O virtual region. Not sure if that's perhaps a bit exotic,
though.

Yeah, that was the closest case I could think of as well, but I'd really rather not encourage people to abuse DT that way. If a kernel driver is loading firmware and initialising the device from scratch then it should be able to sort everything out at runtime without DT involvement. Even if the firmware is somehow massive enough to warrant an early dynamic carveout rather than a regular page/CMA allocation, there's still no good excuse for the driver not to manage its own address space constraints.

On the other hand if the device really does need its firmware at a specific hard-coded address than that would need a fixed physical reservation anyway, since the DT can't assume that the OS is definitely going to use IOMMU translation.

Thanks,
Robin.



[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux