PCIe 調(diào)試執(zhí)行retrain
掃描二維碼
隨時(shí)隨地手機(jī)看文章
在進(jìn)行PCIe調(diào)試過(guò)程中我們時(shí)常需要執(zhí)行retrain操作。retrain命令是讓PCIe 鏈路先退出Link狀態(tài)(ltssm==L0),ltssm會(huì)進(jìn)入recovery狀態(tài),然后再次進(jìn)入L0狀態(tài)。
retrain操作使用的setpci命令,操作對(duì)象是downstream port而非endpoint。
1.retrain操作步驟????
1.將Secondary PCI Express Extended Capability中的Link Control 3 Register中Perform Equalization字段寫1,此操作是為了保證重新建鏈過(guò)程中執(zhí)行Equalization操作,Perform Equalization字段默認(rèn)值為0,且每次重新建鏈后此字段會(huì)被清零。
? ??

2.設(shè)置目標(biāo)速率:將PCI Express Capability Structure中的Link Control 2 Register的target Link Speed設(shè)置成目標(biāo)速率,字段表示設(shè)備支持的最大速率
? ??

3.將PCI Express Capability Structure中的Link Control Register的Retrain Link字段寫1,pcie鏈路將進(jìn)行retrain操作。
? ??



2.案例說(shuō)明????
案例中14:02.0表示downstream port的bus number、device number和function number,在不同設(shè)備中數(shù)值不同。如下案例中“.B”表示按訪問(wèn)數(shù)據(jù)位寬是1字節(jié)。
(1)setpci -s 14:02.0 204.B=0x01
本案例中Secondary PCI Express Extended Capability的偏移地址是0x200,Link Control 3 Register的地址是0x204,將Perform Equalization設(shè)置成1
(2)setpci -s 14:02.0??cap_exp+0x30.B=0x44?
將PCI Express Capability Structure地址采用縮寫cap_exp來(lái)表示,Link Control 2 Register在PCI Express Capability Structure內(nèi)部的地址偏移是0x30,因此Link Control Register的地址就是cap_exp+0x30,寫數(shù)據(jù)0x44中的[3:0]為0x4對(duì)應(yīng)target link speed,即16G速率。
(3)setpci -s 14:02.0 cap_exp+0x10.B=0x60
將PCI Express Capability Structure地址采用縮寫cap_exp來(lái)表示,Link Control Register在PCI Express Capability Structure內(nèi)部的地址偏移是0x10,因此Link Control Register的地址就是cap_exp+0x10,寫數(shù)據(jù)0x60表示將Retrain Link置1。
NOTE:在改寫字段時(shí),首先需要先讀字段地址的字節(jié)數(shù)據(jù),然后改寫對(duì)應(yīng)字段,最終將改寫后的數(shù)據(jù)使用setpci寫入。? ??
? ? ? ? ??





