Solaris 2.x supports two types of memory access: Direct Memory Access (DMA) and Direct Virtual Memory Access (DVMA). The difference between the two types of memory access is the type of memory address provided by the system to PCI devices. See the Chapter on DMA in Writing Device Drivers for a general discussion of DDI functions for DVMA.
DMA Objects
- Handles device access attributes
- Allows a device driver to specify address alignment
- Checks for allocation size within the device's DMA capability
The kernel virtual address returned by ddi_dma_mem_alloc(9F) is allocated from the kernel resource map (kernelmap in the diagram on the Device Addressing Map page), which is a scarce resource and sometimes is more scarce than the physical memory in high-end configurations. In Sun4U platforms, the size of kernelmap is 2.5 Gbytes.
DVMA Resources and IOMMU Translations
The DVMA resource is a contiguous virtual page region in the kernel virtual address space dedicated for DVMA (dvmamap in the diagram on the Device Addressing Map page). DVMA pages occupy the top end of the kernel virtual address space. There is a one-to-one correspondence between a DVMA page and a TSB entry. The size of DVMA address space is the number of entries in the TSB multiplying IOMMU_PAGESIZE (8 Kbytes). When the system has no resources to allocate, the system (depending upon the driver's option):
- Sleeps until resources become available
- Returns
DDI_DMA_NORESOURCES - Returns available resources if
DDI_DMA_PARTIALis specified
Consistent vs. Streaming DMA
ddi_dma_attr(9S)
dma_attr_versionThis field must be set toDMA_ATTR_V0.dma_attr_addr_lo, dma_attr_addr_hiDevice drivers use these two fields to specify the lower and upper bound of the DVMA resource to be allocated. The system usesMAX(dma_attr_addr_lo,DVMA_MAP_LO)andMIN(dma_attr_addr_hi,DVMAP_MAP_HI) to determine the boundary for resource allocation.dma_attr_count_maxThis field specifies the maximum transfer count that the DMA engine can handle in one cookie. Ifdma_attr_segis also specified, the maximum effective transfer size isMIN(dma_attr_count_max, dma_attr_seg). The driver should set this field to 0xffffffff if the device's DMA engine can handle 32-bit addressing.dma_attr_alignDevice drivers use this field to force a more restrictive alignment requirement for DVMA resource allocation. The system converts the value to number of pages for alignment. Values less thanIOMMU_PAGE_SIZEmean no alignment.dma_attr_burstsizesThis field is used to specify the burst transfer alignment restrictions and to determine the minimum transfer size. The minimum transfer size isMAX(dma_attr_burstsizes, dma_attr_minxfer). In the ddi_dma_mem_alloc(9F) call, this field is also used to round up size in allocating driver private memory for DVMA transfers. Since the PCI specification is byte alignment, this field should be set to 1 for PCI devices.dma_attr_minxferThe system uses this field anddma_attr_burstsizesto determine the minimum transfer size. Unless the device has its own restrictions, this field is typically set to 1.dma_attr_maxxferThis value indicates the maximum number of bytes that the device can transmit/receive for one I/O command. This limitation is significant only if it is less thandma_attr_count_max * dma_attr_sgllen.dma_attr_segThis field specifies the upper bound of the DMA engine's address register of a segment. For devices that have only one segment, this field should be the same asdma_attr_count_max. If this field is not 0, the maximum effective transfer size isMIN(dma_attr_count_max, dma_attr_seg). The system returnsDDI_DMA_TOOBIGif the DVMA size is larger than this field. The driver should set this field to 0xffffffff if the device's DMA engine can handle 32-bit addressing.dma_attr_sgllenThis field specifies the maximum number of entries in the scatter/gather list. It is the number of segments that the DMA engine can consume in one I/O request to the device. The system crosses a segment boundary when it encounters a discontinuous physical address or thedma_attr_count_maxis exceeded. This field should be set to 1 if the DMA engine has no scatter/gather list. Since Sun SPARC platforms support DVMA, the device does not need scatter/gather capability. This field should be set to 1.dma_attr_granularThis field should be set to 512.dma_attr_flagsThis field must be set to 0.
本文详细介绍了Solaris系统中Direct Virtual Memory Access (DVMA) 和 Direct Memory Access (DMA) 的工作原理和技术细节,包括如何设置DVMA资源、使用IOMMU进行地址转换以及一致性和流式DMA的区别。
7269

被折叠的 条评论
为什么被折叠?



