2

I am a bit confused regarding DMA transfers with a PCIe device.

Say, for example, I have a slave PCIe device, and I want to transfer a block of data from the device to the RAM, using a DMA transaction. Note that the device is slave, and does not have a DMA "machine" on it.

I know I need to obtain a DMA-able buffer in RAM (either by allocating a coherent one, or by mapping a page) first.

But what's next? what's the API to start a DMA transfer of N bytes from address S to address D?

Can modern systems issue a DMA transfer to/from a slave pci device? if so, what is the Linux API for that?


As explained here:

[ISA] In the original IBM PC, there was only one Intel 8237 DMA controller [...] A PCI architecture has no central DMA controller, unlike ISA. Instead, any PCI component can request control of the bus ("become the bus master") and request to read from and write to system memory

The PCI bus does not have a "central" DMA controller - instead, each device can be a DMA "controller".

4

1 に答える 1

1

まず第一に、現代のPCの中にはスレーブとスレーブホルダーはありません。サウスブリッジ(PCI内)またはルートコンプレックス(PCI-expressデバイスツリーのルート)があり、ブリッジ、はんだ付けチップ、プラグカード、ハードウェアデバッガーなどの他のPCI/PCIeアクターがあります。プラグが差し込まれたカード、またははんだ付けされたサウンドカードやイーサネットチップなどの他の周辺機器について質問する。

この「トランザクションレイヤーパケット」(TLP、「PCIeの最上位レイヤー」)の詳細な説明によると、「バスマスターシップ(DMA)」があります。

PCIeでは、それほどエキゾチックではありません。...バス上の誰でも、ルートコンプレックスとまったく同じように、バス上で読み取りおよび書き込みTLPを送信できます。これにより、ペリフェラルはCPUのメモリに直接アクセス(DMA)したり、TLPをピアペリフェラルと交換したりできます(スイッチングエンティティがサポートしている場合)。

また、プラグインされたデバイスからのDMA機能にはいくつかの利点があります。DMA攻撃。また、PCIeはDMA転送を開始できるものとしてリストされています。

システムは、FireWire、ExpressCard、Thunderbolt、または一般的なPCIやPCI-Expressのように、接続されたデバイスを物理アドレス空間に直接接続するその他の拡張ポートを備えている場合、外部デバイスによるDMA攻撃に対して脆弱である可能性があります。

周辺機器自体から開始されるDMA転送をプログラミングするためのユニバーサルAPIはないと思います。これは、デバイスが何であるか、DMAをいつ開始する必要があるか、および何を送信するかによって異なります。

于 2012-06-08T22:18:45.570 に答える