Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information