Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6428561ybx; Mon, 11 Nov 2019 09:00:34 -0800 (PST) X-Google-Smtp-Source: APXvYqyEkA1PhTUNfrNP0+0thYReHFNWdAesCwxl9wKqjauJhSa764lOPkannyktnCEZtwntqy8I X-Received: by 2002:a17:906:1982:: with SMTP id g2mr23907519ejd.254.1573491633981; Mon, 11 Nov 2019 09:00:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573491633; cv=none; d=google.com; s=arc-20160816; b=LK24KcCNoXYYutdOT+v4mBBtCreirp8tNzcxO+PSp8/hhKD5hAC4lVvvLcRBbgPWau hnpKj0Bndyr7gijsiKACvOvWW1gt23Xjtqj2M3z/kkAzecYWiuxHNEi9dItCq/mnZZIN 16qhOK3to1tCDWa3z8iXPB1CyiTG+Fu+fvAZBnyh0jVG5/Iqq/UTCZB81gxX9m8zz/JJ kdrEN92ksAEGdA2hHQd/kWR6QVVHLHq0aDhmTUXcQ/tYowZFGuchu8Otcm6nzWrIbTco diwmW3IVKS4HgYHQwpBxQbSoT//n/o3lJvnzacUGgYGjxEEmiVzqT+2Kv+Q0vqUMBjcU tGCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to; bh=J75fXgf9Z1PHvRL2II1tfxI6L4R5aVW9pNgIcKmjI9U=; b=hqhGoaMrnN1bLGVqud0FN4RgLDqOmYAoQ8o6SQJ2LtGG2hnOq6CSW120vM/rRlRmi6 imyw9IVXK6HbFVfGQEEzABbhLjR8VJsfX/+JFw7qwK06MIhRZiNE644l429UxyFiwOnZ pipdCDIzlIpqNTpFHEWa/uLS7fJbgz2rC64AtczMZl3a66J6ZCJquRJKN+83fmdMYioS 5KuJviG7EAgRrKunIqIxwKtxbIxZzOVPUJWmTBlkTSg0+bva5ZgIan4QViUX5ec+GxGX Ls1x88jnICQH5XMnMk58b5FglRd5AmlBlLltmI/7G41jqtfT8W7mDGWwiNuNOP+KwDIl DOww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o5si9695514ejn.123.2019.11.11.09.00.09; Mon, 11 Nov 2019 09:00:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726928AbfKKQ7J (ORCPT + 99 others); Mon, 11 Nov 2019 11:59:09 -0500 Received: from ale.deltatee.com ([207.54.116.67]:41668 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbfKKQ7J (ORCPT ); Mon, 11 Nov 2019 11:59:09 -0500 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.89) (envelope-from ) id 1iUD1s-00083M-Nn; Mon, 11 Nov 2019 09:59:05 -0700 To: Jiasen Lin , linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com, jdmason@kudzu.us Cc: allenbh@gmail.com, dave.jiang@intel.com References: <1573097913-104555-1-git-send-email-linjiasen@hygon.cn> <7ea7ef5d-7e46-396a-8d70-2c6c333a4508@deltatee.com> <8973e56c-ccce-2884-f4dc-4d0f8072a948@hygon.cn> From: Logan Gunthorpe Message-ID: Date: Mon, 11 Nov 2019 09:59:00 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <8973e56c-ccce-2884-f4dc-4d0f8072a948@hygon.cn> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: dave.jiang@intel.com, allenbh@gmail.com, jdmason@kudzu.us, linux-ntb@googlegroups.com, linux-kernel@vger.kernel.org, linjiasen@hygon.cn X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [PATCH] NTB: ntb_perf: Fix address err in perf_copy_chunk X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-11-11 12:51 a.m., Jiasen Lin wrote: > > > On 2019/11/9 1:04, Logan Gunthorpe wrote: >> >> >> On 2019-11-06 8:38 p.m., Jiasen Lin wrote: >>> peer->outbuf is a virtual address which is get by ioremap, it can not >>> be converted to a physical address by virt_to_page and page_to_phys. >>> This conversion will result in DMA error, because the destination address >>> which is converted by page_to_phys is invalid. >> >> Hmm, yes, ntb_perf is obviously wrong. I never noticed this, how did >> this ever work? >> > > The default value of use_dma which is used to enable DMA engine to > measure NTB performance is zero, in other words, DMA engine is not used > by default. Thus, olny memcpy_toio is called in perf_copy_chunk and not > trigger this bug. > > If we install driver with specified dma-enabled flag like this: > insmod ntb_perf.ko use_dma=1, this issue will be triggered. I've definitely tested with use_dma=1 in the past. But it looks like it was broken by this problematic commit and I must have never personally run the DMA tests after it: 5648e56d03fa ("NTB: ntb_perf: Add full multi-port NTB API support") So it's probably worth adding a fixes tag to your patch. >>> We Save the physical address in perf_setup_peer_mw, it is MMIO address >>> of NTB BARx. Then fill the destination address of DMA descriptor with >>> this physical address to guarantee that the address of memory write >>> requests fall in memory window of NBT BARx. >> >> Using the physical address directly is also wrong and will not work in >> the presence of an IOMMU. You should use dma_map_resource() for this. >> See what was done in ntb_transport[1]. >> > > Yes, my mistake. I will modify the code according to your suggestion and > test it on AMD and HYGON platforms with the IOMMU enabled. Maybe the > following patches are relied on, when IOMMU is enabled on AMD and HYGON > plartforms. > > https://lore.kernel.org/patchwork/cover/1143155/ > https://lore.kernel.org/patchwork/patch/1143156/ > https://lore.kernel.org/patchwork/patch/1143157/ Thanks! Logan