Hi Elliott,
On 26/10/2020 16:03, Elliott Mitchell wrote:
On Mon, Oct 26, 2020 at 01:31:42PM +0000, Julien Grall wrote:
On 24/10/2020 06:35, Elliott Mitchell wrote:
ACPI has a distinct
means of specifying a limited DMA-width; the above fails, because it
assumes a *device-tree*.
Do you know if it would be possible to infer from the ACPI static table
the DMA-width?
Yes, and it is. Due to not knowing much about ACPI tables I don't know
what the C code would look like though (problem is which documentation
should I be looking at first?).
What you provided below is an excerpt of the DSDT. AFAIK, DSDT content
is written in AML. So far the shortest implementation I have seen for
the AML parser is around 5000 lines (see [1]). It might be possible to
strip some the code, although I think this will still probably too big
for a single workaround.
What I meant by "static table" is a table that looks like a structure
and can be parsed in a few lines. If we can't find on contain the DMA
window, then the next best solution is to find a way to identity the
platform.
I don't know enough ACPI to know if this solution is possible. A good
starter would probably be the ACPI spec [2].
Handy bit of information is in the RP4 Tianocore table source:
https://github.com/tianocore/edk2-platforms/blob/d492639638eee331ac3389e6cf53ea266c3c84b3/Platform/RaspberryPi/AcpiTables/Dsdt.asl
Name (_DMA, ResourceTemplate() {
//
// Only the first GB is available.
// Bus 0xC0000000 -> CPU 0x00000000.
//
QWordMemory (ResourceConsumer,
,
MinFixed,
MaxFixed,
NonCacheable,
ReadWrite,
0x0,
0x00000000C0000000, // MIN
0x00000000FFFFFFFF, // MAX
0xFFFFFFFF40000000, // TRA
0x0000000040000000, // LEN
,
,
)
})
There should be some corresponding code in the Linux 5.9 kernels. From
the look of that, it might even be possible to specify a memory range
which didn't start at address 0.
Cheers,
[1] https://github.com/openbsd/src/blob/master/sys/dev/acpi/dsdt.c
[2] https://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf
--
Julien Grall