Skip to content

Commit f1b785f

Browse files
committed
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fix from Michael Tsirkin: "A last minute mlx5 bugfix" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: vdpa/mlx5: Fix PA offset with unaligned starting iotlb map
2 parents 14b6320 + 29ce8b8 commit f1b785f

File tree

1 file changed

+5
-3
lines changed
  • drivers/vdpa/mlx5/core

1 file changed

+5
-3
lines changed

drivers/vdpa/mlx5/core/mr.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
373373
struct page *pg;
374374
unsigned int nsg;
375375
int sglen;
376-
u64 pa;
376+
u64 pa, offset;
377377
u64 paend;
378378
struct scatterlist *sg;
379379
struct device *dma = mvdev->vdev.dma_dev;
@@ -396,8 +396,10 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
396396
sg = mr->sg_head.sgl;
397397
for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1);
398398
map; map = vhost_iotlb_itree_next(map, mr->start, mr->end - 1)) {
399-
paend = map->addr + maplen(map, mr);
400-
for (pa = map->addr; pa < paend; pa += sglen) {
399+
offset = mr->start > map->start ? mr->start - map->start : 0;
400+
pa = map->addr + offset;
401+
paend = map->addr + offset + maplen(map, mr);
402+
for (; pa < paend; pa += sglen) {
401403
pg = pfn_to_page(__phys_to_pfn(pa));
402404
if (!sg) {
403405
mlx5_vdpa_warn(mvdev, "sg null. start 0x%llx, end 0x%llx\n",

0 commit comments

Comments
 (0)