]> git.baikalelectronics.ru Git - kernel.git/commit
vdpa/mlx5: Fix memory key MTT population
authorEli Cohen <elic@nvidia.com>
Thu, 7 Jan 2021 07:18:45 +0000 (09:18 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 20 Jan 2021 08:47:04 +0000 (03:47 -0500)
commita7f1b4145675b0e252261fb17f6ba0198c8541ae
tree222ab8b551565baa7b816613835869c3170fccc6
parent9fb686b91f85f6106279ccd602ad0555eb2734b1
vdpa/mlx5: Fix memory key MTT population

map_direct_mr() assumed that the number of scatter/gather entries
returned by dma_map_sg_attrs() was equal to the number of segments in
the sgl list. This led to wrong population of the mkey object. Fix this
by properly referring to the returned value.

The hardware expects each MTT entry to contain the DMA address of a
contiguous block of memory of size (1 << mr->log_size) bytes.
dma_map_sg_attrs() can coalesce several sg entries into a single
scatter/gather entry of contiguous DMA range so we need to scan the list
and refer to the size of each s/g entry.

In addition, get rid of fill_sg() which effect is overwritten by
populate_mtts().

Fixes: eb3156f4b78f ("vdpa/mlx5: Add shared memory registration code")
Signed-off-by: Eli Cohen <elic@nvidia.com>
Link: https://lore.kernel.org/r/20210107071845.GA224876@mtl-vdi-166.wap.labs.mlnx
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
drivers/vdpa/mlx5/core/mlx5_vdpa.h
drivers/vdpa/mlx5/core/mr.c