芯片无法正常启动,系统日志出现如下打印信息:dev id 0, The address dont comply with the NVME protocol(must be aligned with 4KB).
问题描述
芯片无法正常启动时,系统日志有如下打印信息:dev id 0, The address dont comply with the NVME protocol(must be aligned with 4KB)。
可能原因
Host内核接口dma_alloc_coherent申请用于Nvme协议的地址不满足4K对齐要求。
根据内核DMA接口文档中相关描述,多数平台由于使用一致性内存代价很高,通常最小的分配长度为一个页。
Using Consistent DMA mappings ============================= To allocate and map large (PAGE_SIZE or so) consistent DMA regions, you should do:: dma_addr_t dma_handle; cpu_addr = dma_alloc_coherent(dev, size, &dma_handle, gfp); where device is a ``struct device *``. This may be called in interrupt context with the GFP_ATOMIC flag. Size is the length of the region you want to allocate, in bytes. This routine will allocate RAM for that region, so it acts similarly to __get_free_pages() (but takes size instead of a page order). If your driver needs regions sized smaller than a page, you may prefer using the dma_pool interface, described below. The consistent DMA mapping interfaces, will by default return a DMA address which is 32-bit addressable. Even if the device indicates (via the DMA mask) that it may address the upper 32-bits, consistent allocation will only return > 32-bit addresses for DMA if the consistent DMA mask has been explicitly changed via dma_set_coherent_mask(). This is true of the dma_pool interface as well. dma_alloc_coherent() returns two values: the virtual address which you can use to access it from the CPU and dma_handle which you pass to the card. The CPU virtual address and the DMA address are both guaranteed to be aligned to the smallest PAGE_SIZE order which is greater than or equal to the requested size. This invariant exists (for example) to guarantee that if you allocate a chunk which is smaller than or equal to 64 kilobytes, the extent of the buffer you receive will not cross a 64K boundary.
可能造成不满足4K对齐的原因如下:
- 用户内核PAGESIZE小于4096字节
- dma_alloc_coherent实现方式与Linux社区不一致
解决方案
- 执行如下命令,查询该环境PAGESIZE。getconf PAGESIZE
4096
- 若PAGESIZE小于4096字节,请修改Host内核或修改PAGESIZE。
- 若PAGESIZE大于4096字节,请排查Host内核接口dma_alloc_coherent申请一致性内存方式,确保申请的地址满足4K对齐。
父主题: FAQ