Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp176238pxb; Wed, 8 Sep 2021 21:09:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxy0FKwOjPnHSXOL156+n4V4H07FAHUALAioPyleSlekpDoDTx0d7Wr2PVGz7ueBBUt0K9E X-Received: by 2002:a17:906:3759:: with SMTP id e25mr1152237ejc.464.1631160594886; Wed, 08 Sep 2021 21:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631160594; cv=none; d=google.com; s=arc-20160816; b=JnX4MkZa096qLE5+F/LWGrpP8FZf574abGsew8Zf8TzJ+iCyd7OehQY6SPcwh1Tvsp 9yf23/yN5HI61SoVuilqr/+NATo9fgclPG6+S+YxzDTf6Fm+4crVuhLurmwL9SKkuKke qWHnFl+IYOqSf3zKzvNIwzLh2pyF8FmyfkNahCeYTJil/0ZxZKmIWiEGIRp3I9OVpY3J kuuNh3LZARDRmZe9tlmjWilziNUPBpoiDxBtgEhFvn82FJR57B8hJigwZPCqjuoEQXCx i3Pr6jGXkNjDghpXp2ZjCrskM3VdMl64AuXagQRQj8T9dgJt4zGqm1OmppN7EyySb7V2 YsYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:message-id:date:subject:cc:to:from; bh=vgOX02Bzs+x5mgelbkx8+Rv3eJDLNpF26ziUwWQIlfc=; b=iorBWIjnqBq3doKtttylSnKsZTTi9Q5/sQT5DzIghOzEeJNSIdCwUxL/Ryi5R9QAox 1dfsU6aKhzxyQMDfE+0VTk+BZUQo6lFrUz1X/fG0Gb44OD2ng+qGdItsE8/WFv1ZALu6 htgT7UHoqCFhSebmdRdQxvCK6yiXDVVFP9P26CD4tB+KXpWQR712O/YWoa58myjhvYpn imc16ZXVaxq0dHPQU8gJ0Bwn9Dx+DNxs8Hh5qkCLH+z4bLrEtbKr8G6XSnpVDDRTd1kM R6eHEpxqLgtOs+YJcXoTjVLa12dSL4qqZfNCa+MH36UPleygeugO1EZ6/M0E9G9+i7aJ ikRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c17si711620edv.438.2021.09.08.21.09.31; Wed, 08 Sep 2021 21:09:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349199AbhIID23 (ORCPT + 99 others); Wed, 8 Sep 2021 23:28:29 -0400 Received: from smtpbg704.qq.com ([203.205.195.105]:42014 "EHLO smtpproxy21.qq.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1350036AbhIID17 (ORCPT ); Wed, 8 Sep 2021 23:27:59 -0400 X-QQ-mid: bizesmtp31t1631157944tj67lzfz Received: from localhost.localdomain (unknown [121.228.85.104]) by esmtp6.qq.com (ESMTP) with id ; Thu, 09 Sep 2021 11:25:29 +0800 (CST) X-QQ-SSF: 01400000002000E0K000B00A0000000 X-QQ-FEAT: LE7C6P2vL8QdlG8W6D6RCL8Ec8cTgXKmpKclyKe1pLXCGz+7XNwPR8eZ8au5H 16qVc8hW6IQotYPtAZeH1zSmcNA4W1+YwTHWn5kn2wh4jwCBuDVKlc2t/wpA6LNPeIQEjS1 i5LPEqxu6YY30hbmVr4qvniOY/6MgsW2Fb1/RofqT2Iusb8izJznCHDURyv1tviUo0Etuxl Bqw6aduAsPmdD2iORFdwF5/UC1qnFFL6YxPreT1ib1FDPQhtEjnnbvre2ni9neFlZZK5DZs 2NUo04riinuLSneGM3WJvuoTAD+0MuTv+MBn4kg/Yb6jjSP30Lz5us/53tkJ+p85dVFBekm Nfs6F82uImaKucOUaI= X-QQ-GoodBg: 2 From: Wang Lu To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Wang Lu Subject: [PATCH] PCI/P2PDMA: fix the wrong dma address calculation when map sg Date: Thu, 9 Sep 2021 11:25:28 +0800 Message-Id: <20210909032528.24517-1-wanglu@dapustor.com> X-Mailer: git-send-email 2.17.1 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:dapustor.com:qybgforeign:qybgforeign5 X-QQ-Bgrelay: 1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The bus offset is bus address - physical address, so the calculation in __pci_p2pdma_map_sg should be: bus address = physical address + bus offset. Signed-off-by: Wang Lu --- drivers/pci/p2pdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 50cdde3e9a8b..327882638b30 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -874,7 +874,7 @@ static int __pci_p2pdma_map_sg(struct pci_p2pdma_pagemap *p2p_pgmap, int i; for_each_sg(sg, s, nents, i) { - s->dma_address = sg_phys(s) - p2p_pgmap->bus_offset; + s->dma_address = sg_phys(s) + p2p_pgmap->bus_offset; sg_dma_len(s) = s->length; } -- 2.17.1