kernel是如何選擇iommu的呢?

2021-07-27 06:42:09 字數 1252 閱讀 8462

如果acpi表中定義了iort 子表的話,flow如下:

acpi_iort_init->iort_init_platform_devices

static void __init iort_init_platform_devices(void)}}

從iort_init_platform_devices 中可以知道當前kernel同時support smmu 和smmuv3

iort_add_smmu_platform_device->acpi_dma_configure->arch_setup_dma_ops->acpi_dma_configure

在acpi_dma_configure 中會呼叫arch_setup_dma_ops 這裡需要注意attr == dev_dma_coherent

arch_setup_dma_ops(dev, 0, dev->coherent_dma_mask + 1, iommu,

attr == dev_dma_coherent);

在arch_setup_dma_ops 函式中dev->archdata.dma_ops == null

void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,

const struct iommu_ops *iommu, bool coherent)

我們這邊暫時給dev->archdata.dma_ops = &swiotlb_dma_ops 以防後面iommu賦值失敗。這裡繼續呼叫__iommu_setup_dma_ops

static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,

const struct iommu_ops *ops)

else

}在__iommu_setup_dma_ops 中ops顯然部位null,且group也不為null,因此呼叫do_iommu_attach

static bool do_iommu_attach(struct device *dev, const struct iommu_ops *ops,

u64 dma_base, u64 size)

dev->archdata.dma_ops = &iommu_dma_ops;

return true;

}哈哈哈,在do_iommu_attach 中終於賦值了dev->archdata.dma_ops = &iommu_dma_ops;

如何記錄kernel啟動時間

sdkstarttimer timer cudaeventrecord start,0 cudamemcpyasync d a,a,nbytes,cudamemcpyhosttodevice,0 increment kernel d a,value cudamemcpyasync a,d a,nby...

Go語言選擇器是如何選擇的

我們都知道選擇器其實就是型別裡面的乙個個方法,型別之間可以互相內嵌,經過 證明,選擇器會優先選擇自身定義的方法,然後如果沒有,就會去解析內嵌的型別的方法,例如定義型別t,同時內嵌了t1,t2兩個型別,裡面都有方法f,這是直接呼叫t.f,就會產生二義性,因為t1和t2在解析器看來都算是同一層,如果t1...

機器學習裡的kernel是指什麼?

先給個定義 核函式k kernel function 就是指k x,y 其中x和y是n維的輸入值,f 是從n維到m維的對映 通常而言,m n 是x和y的內積 inner product 嚴格來說應該叫歐式空間的標準內積,也就是很多人常說的點積 dot product 光看這一段還是不明白kernel...