Commit 292ec6c
loongarch: fix DMA address offset
Loongarch CPUs are using HT bus interface, which is only 40-bit wide,
to communicate with the bridge chipset. However, the actual memory
bus of the CPUs is 48-bit wide, and the available address space of DMA
requests of PCI devices is also larger than the 40-bit address space.
The address space of loongarch systems is not continuous, the bits
[47:44] of which are used to denote the belonging node id, which is
far beyond the space provided by the 40-bit wide HT bus. As a result,
a translation on the both LS7A and CPU sides is needed.
The translation happens on the LS7A side is controlled by the higher
half of the register, HT_ROUTE. Bits [12:8] denotes dma_node_id_offset
and bits[15:13] denotes dma_node_id_offset_mapped. The behavior of the
translation is that the chip extracts the node id from bit
dma_node_id_offset + 36 of a DMA address, places it at bit
dma_node_id_offset_mapped + 32, and generates the address on the HT bus.
On the CPU side, an alike translation happens, to convert the address on
the HT bus back to a proper memory address.
On machines with legacy firmware with BPI01000 version,
dma_node_id_offset is configured with 0, resulting the address which
should be used by the DMA engine of a PCI device differs from the
actural physical memeory address, which requires a pair of arch-specific
phys_to_dma and dma_to_phys functions or setting up the whole mapping
in the _DMA method of the PCI root device in the DSDT table.
The former method requires we add back the prevoiusly removed functions,
and the latter method degrades the performance since when the
translation happens, the mapping table is scanned linearly.
This patch addresses this issue by directly setting dma_node_id_offset
to 8, like what is done by modern firmwares, making the address used by
the DMA engine just the same as the actual physical memory address, and
eliminating the need of DMA address translation on the kernel side.1 parent 797c053 commit 292ec6c
1 file changed
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
49 | 62 | | |
50 | 63 | | |
51 | 64 | | |
| |||
588 | 601 | | |
589 | 602 | | |
590 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
591 | 618 | | |
592 | 619 | | |
593 | 620 | | |
| |||
0 commit comments