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_PARTIAL
is specified
Consistent vs. Streaming DMA
ddi_dma_attr(9S)
dma_attr_version
This field must be set toDMA_ATTR_V0
.dma_attr_addr_lo, dma_attr_addr_hi
Device 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_max
This field specifies the maximum transfer count that the DMA engine can handle in one cookie. Ifdma_attr_seg
is 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_align
Device 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_SIZE
mean no alignment.dma_attr_burstsizes
This 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_minxfer
The system uses this field anddma_attr_burstsizes
to determine the minimum transfer size. Unless the device has its own restrictions, this field is typically set to 1.dma_attr_maxxfer
This 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_seg
This 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_TOOBIG
if 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_sgllen
This 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_max
is 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_granular
This field should be set to 512.dma_attr_flags
This field must be set to 0.