Skip to contentSkip to conversation

Strange dma map/unmap/memcpy dance in ipoib_cm_handle_rx_wc

DISCUSSION Nikolay Borisov 2 participants 2 messages Apr 27, 2016 – Apr 28, 2016 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

Hello,

I need a bit of help in understanding the logic behind the following code sequence in ipoib_cm_handle_rx_wc:

newskb = ipoib_cm_alloc_rx_skb(dev, rx_ring, wr_id, frags,

                                       mapping, GFP_ATOMIC);

so Here a new skb is being allocated and pages constituting its fragments are being dma mapped.

ipoib_cm_dma_unmap_rx(priv, frags, rx_ring[wr_id].mapping);

immediately after that the very same mappings are being unmapped. And finally the resulting dma addresses from ipoib_cm_alloc_rx_skb are being copied via this call to memcpy:

memcpy(rx_ring[wr_id].mapping, mapping, (frags + 1) * sizeof *mapping);

Can someone explain what's the logic of doing the memcpy after the mappings have been destroyed, doesn't that mean the dma addresses stored in rx_ring[wr_id].mapping are invalid?

Regards,
Nikolay
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 10 lines · Nikolay Borisov

Hello,

I need a bit of help in understanding the logic behind the following code sequence in ipoib_cm_handle_rx_wc:

newskb = ipoib_cm_alloc_rx_skb(dev, rx_ring, wr_id, frags,

                                       mapping, GFP_ATOMIC);

so Here a new skb is being allocated and pages constituting its fragments are being dma mapped.

Into the local variable mapping.

Quoted 3 lines

ipoib_cm_dma_unmap_rx(priv, frags, rx_ring[wr_id].mapping);

immediately after that the very same mappings are being unmapped.

No, these are the saved mappings of the skb that has the same ring slot as the one we are going to take.

Quoted 5 lines

And
finally the resulting dma addresses from ipoib_cm_alloc_rx_skb are being copied via this call to memcpy:

memcpy(rx_ring[wr_id].mapping, mapping, (frags + 1) * sizeof *mapping);

From our local variable to the saved mapping slot for this ring index.

Quoted 11 lines

Can someone explain what's the logic of doing the memcpy after the mappings have been destroyed, doesn't that mean the dma addresses stored in rx_ring[wr_id].mapping are invalid?

Regards,
Nikolay
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Doug Ledford <[email protected]>
              GPG KeyID: 0E572FDD