Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5194621ybv; Tue, 11 Feb 2020 10:58:30 -0800 (PST) X-Google-Smtp-Source: APXvYqys6f6YnLpkmp/s5A79lwZEqE6X2289yH1AEOZLDkXm93Fz4Y9HtEKTSTBqHpGyI1Amnodt X-Received: by 2002:aca:4ace:: with SMTP id x197mr3865043oia.23.1581447509937; Tue, 11 Feb 2020 10:58:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581447509; cv=none; d=google.com; s=arc-20160816; b=bWRQTMXTQ1GM9i86tgf+vihZzIaEDWk1B5TpDfAiyl1N2rejNvjVudla+eTStzsTQA tRT7IxYUDZuGRwcrn+RdyxTJrA3n8bXTZdm7aoIkMcdLB+yqlbcIa3epMvbKXBACUdw1 tdcHTyS3L87D4WaRKoNXEfw2yxilmeh+XexWNs1Kl6W9pwKL+j2UmVBagRRrgJn7fc8U Jr04w32sP9LbiwZxn/+zjPSl73HiIUodvd6n+rUFf1OQmOygqqlrykrBswMPR13Tk8gc 21as87+nK9ZyrCa5s+DajcfV5YvV+JgeSG2maUy1hiBf1wrJiFgJs5Ux7k/0ln0Qrx0B p/Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=jtO/u1jcpDpVpf2gT7hVN7TAjhkazF7mlT7c8VtZtc8=; b=c73RcP66O1X5bajYdSCFTr/EohQjCYE8ptFHuZI/LEasVe32jiO/c/0l0sRRy7l0X4 imrA6m+TTTFriJPQGqFs1P6qYV9Es0I86bOCzRJKepKddGBsqWKhxZuPvddC4kquHXdT JU5a48RZJiLeXAK7nRtNDhR04iJ8Uk4/kCch7JRI4A7j6PeYsV4EqzfDB8eaUNn1nEYp O73/0zRb8q99ZkqJ8aFcFnN0N99V/RH93hFfgWiK98ImR6+bjCJH/g8fbQKPS46f3oEV eNY6veEHqkcCk+8RBi7s9ly+5swawIq1GhQ7ujSC0yrb7n9wS7SGqhmv/C6WXRWzE8g6 6jag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-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 f23si2454963oti.283.2020.02.11.10.58.07; Tue, 11 Feb 2020 10:58:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-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-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729658AbgBKQgj (ORCPT + 99 others); Tue, 11 Feb 2020 11:36:39 -0500 Received: from foss.arm.com ([217.140.110.172]:49518 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728295AbgBKQgj (ORCPT ); Tue, 11 Feb 2020 11:36:39 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D9A6030E; Tue, 11 Feb 2020 08:36:38 -0800 (PST) Received: from [10.1.196.37] (e121345-lin.cambridge.arm.com [10.1.196.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 14FF13F68E; Tue, 11 Feb 2020 08:36:37 -0800 (PST) Subject: Re: AMD IOMMU stops RDMA NFS from working since kernel 5.5 (bisected) To: Chuck Lever , Andre Tomt Cc: Tom Murphy , Linux NFS Mailing List , Joerg Roedel , iommu@lists.linux-foundation.org References: <7ee099af-e6bb-18fe-eb93-2a8abd401570@tomt.net> <20200211072537.GD23114@suse.de> <2CE039F4-3519-4481-B0E2-840D24EE4428@oracle.com> <3507674A-F860-4B65-BD46-93431DD268AC@oracle.com> <21c801a6-9a8b-1ebb-7e41-76e8385116ea@arm.com> From: Robin Murphy Message-ID: <35961bac-2f1e-3fbc-9661-031b9d5acee3@arm.com> Date: Tue, 11 Feb 2020 16:36:36 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On 11/02/2020 4:03 pm, Chuck Lever wrote: > > >> On Feb 11, 2020, at 10:32 AM, Robin Murphy wrote: >> >> On 11/02/2020 3:24 pm, Chuck Lever wrote: >>>> On Feb 11, 2020, at 10:12 AM, Robin Murphy wrote: >>>> >>>> On 11/02/2020 1:48 pm, Chuck Lever wrote: >>>>> Andre- >>>>> Thank you for the detailed report! >>>>> Tom- >>>>> There is a rich set of trace points available in the RPC/RDMA implementation in 5.4/5.5, fwiw. >>>>> Please keep me in the loop, let me know if there is anything I can do to help. >>>> >>>> One aspect that may be worth checking is whether there's anywhere that assumes a successful return value from dma_map_sg() is always the same as the number of entries passed in - that's the most obvious way the iommu-dma code differs (legitimately) from the previous amd-iommu implementation. >>> net/sunrpc/xprtrdma/frwr_ops.c: frwr_map() >>> 317 mr->mr_nents = >>> 318 ib_dma_map_sg(ia->ri_id->device, mr->mr_sg, i, mr->mr_dir); >>> 319 if (!mr->mr_nents) >>> 320 goto out_dmamap_err; >>> Should that rather be "if (mr->mr_nents != i)" ? >> >> No, that much is OK - the point is that dma_map_sg() may pack the DMA addresses such that sg_dma_len(sg) > sg->length - however, subsequently passing that mr->nents to dma_unmap_sg() in frwr_mr_recycle() (rather than the original value of i) looks at a glance like an example of how things may start to get out-of-whack. > > Robin, your explanation makes sense to me. I can post a fix for this imbalance later today for Andre to try. FWIW here's a quick hack which *should* suppress the concatenation behaviour - if it makes Andre's system any happier then that would indeed point towards dma_map_sg() handling being the culprit. Robin. ----->8----- diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index a2e96a5fd9a7..a6b71bad518e 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -779,7 +779,7 @@ static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents, * - but doesn't fall at a segment boundary * - and wouldn't make the resulting output segment too long */ - if (cur_len && !s_iova_off && (dma_addr & seg_mask) && + if (0 && cur_len && !s_iova_off && (dma_addr & seg_mask) && (max_len - cur_len >= s_length)) { /* ...then concatenate it with the previous one */ cur_len += s_length; @@ -799,6 +799,7 @@ static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents, if (s_length + s_iova_off < s_iova_len) cur_len = 0; } + WARN_ON(count < nents); return count; }