Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4786128pxy; Tue, 27 Apr 2021 12:35:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyoorQMqEzlvbcAB2rSzREt5oVe4hM++6IcJ2/SbWrrM+zPDlJlSrYVxKaVZbQL0IkwJOj X-Received: by 2002:a63:e007:: with SMTP id e7mr24568746pgh.260.1619552106500; Tue, 27 Apr 2021 12:35:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619552106; cv=none; d=google.com; s=arc-20160816; b=BCO+FJRfEdK4vVJ20UICXDmcB72mG9mtMuJWNFAkMRhCujOLP2wRa0XUUj6ENjJFK9 6SpGrpf4kr2FT/upY5wS9v+EexMTuykKPgQoOIqcY3OoxQTeQT7jcSAVxnPSv0YitUIE 7JBsi7OTPblfgh1US6xzuoyogbmzvnKJ34VRTh+KfqjsmmYTavV8l0MLEFsUdLHmxoAV F/NukeINEvRI47X8e4OYBKnUHGnHmA7Q6fGlIVplcuzgOr8trLiSd+UQtXaMI8QtVG7n S+QfcfhyQXl0waLNlTqJI3AvXS/uilE2QVt41sbPaRDWKcl/l8mrOqPB0dc4/QUuX5X9 o3Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=R+F2zOJdoXavuDhUMY1QiZp/NrhfLweB0na9Qyx1V6M=; b=r+xLIptqyqjdCaHQ5lCj0tvoC3E8UdYHRTpL5mlfyyXgysEx0nT3NjO/2t8hukelGb lCZvtuFcAA2n1rZsqlwtZ3x8cgnrrdUwuyQhnh9HliOicTx2rYm7vT5ztbGWzke9rz1R e/OQEbmQr6DNyFSK4pLMhZnK3xNjKLnP72+mN+ow1PD698dA2gOZX0SHsKFQ/3YRQMd/ z/ECNFOu+F1YumBRdoxfFA46prh1jS9TjMooHxDOfax1xVtVmBVrtx3MXYCzOl3hP8Wa FaL6Swo3+CJZVLx9iOMcMgmxVKHqPJCYJeSd3bIYuE/K9gIadc2Ff4m8GNz4fzPFPQNt G7nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=TJz59G9w; 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 x9si4758604pfu.201.2021.04.27.12.34.53; Tue, 27 Apr 2021 12:35:06 -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; dkim=pass header.i=@ziepe.ca header.s=google header.b=TJz59G9w; 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 S238668AbhD0Tek (ORCPT + 99 others); Tue, 27 Apr 2021 15:34:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235686AbhD0Tej (ORCPT ); Tue, 27 Apr 2021 15:34:39 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90C4DC061760 for ; Tue, 27 Apr 2021 12:33:54 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id a11so570157plh.3 for ; Tue, 27 Apr 2021 12:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=R+F2zOJdoXavuDhUMY1QiZp/NrhfLweB0na9Qyx1V6M=; b=TJz59G9wTmQQcbNbRY6OLyN78TksPOrBEHchyw0NBoPqX7sH+F3GGV9C/CfZW1h60M za+EgCvhm5j94fG3EFrSszh3F9AtXSEv6o4v4pzjNzSIPeAEJTXAJgDlK3w7dIOwvVl3 GDz/9VRq+nxGIFibJgIM4ZDwttw1bZanScMikT8vBhr3hHdh3+D1AMW+87r/3r/WeSeL mFN1NYGu0fU/BHLpJfQ111ayxh2eOXs3wIHf4Gc1C7LSKzpmBZACVlSiQZcSoeU7Fukr d9IJK8EwTF9bbg0KdJNjSvCfq8EatvIhTdt5V794cL+MA6LlTikeW2O5j+OCr1c9eKX8 S8Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=R+F2zOJdoXavuDhUMY1QiZp/NrhfLweB0na9Qyx1V6M=; b=hYzCdCcg83GGNpyzZStBp8hk1hMlL3HYidLT72X7+6bOgbqIWAuf9OhQY9bN05nUwr b8FyvBvtPm6jb69ECeNyJjRfSoxXJmlh9b5aBm49zI1hWVmOLrzF3NTo3noEL7KM8BB8 lQp1udA/gYhxYOrcNlneH/1LoDa6io7Gt0GxxvcKzaQty6lnHz+8LOjSC0Jb3lt9sKpC xpRE6S831wiboyXoCnj/fIl9ajyVsP23i1xUIZfTHyvbcsiTPmVshEK4wOUTrXveGMNs I9uJewEiGQ1qUapRINeixh0IEE/Bq9A1o37bh0WbxFGIgsNxxl0ZzRqMk1te84TQEcXo 14iw== X-Gm-Message-State: AOAM531UpFK3ISwVU/DAhCgJXVEEmsK/UTAuxPKnnN5exkWT69gKOMWf OLM1FaPvagky4DVU9HturJH1EA== X-Received: by 2002:a17:902:8a8a:b029:ec:857a:4d51 with SMTP id p10-20020a1709028a8ab02900ec857a4d51mr25612392plo.68.1619552034009; Tue, 27 Apr 2021 12:33:54 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id o5sm460461pgq.58.2021.04.27.12.33.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 12:33:53 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lbTSx-00Dgwh-Mo; Tue, 27 Apr 2021 16:33:51 -0300 Date: Tue, 27 Apr 2021 16:33:51 -0300 From: Jason Gunthorpe To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Stephen Bates , Christoph Hellwig , Dan Williams , Christian =?utf-8?B?S8O2bmln?= , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy Subject: Re: [PATCH 09/16] dma-direct: Support PCI P2PDMA pages in dma-direct map_sg Message-ID: <20210427193351.GR2047089@ziepe.ca> References: <20210408170123.8788-1-logang@deltatee.com> <20210408170123.8788-10-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210408170123.8788-10-logang@deltatee.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 08, 2021 at 11:01:16AM -0600, Logan Gunthorpe wrote: > Add PCI P2PDMA support for dma_direct_map_sg() so that it can map > PCI P2PDMA pages directly without a hack in the callers. This allows > for heterogeneous SGLs that contain both P2PDMA and regular pages. > > SGL segments that contain PCI bus addresses are marked with > sg_mark_pci_p2pdma() and are ignored when unmapped. > > Signed-off-by: Logan Gunthorpe > kernel/dma/direct.c | 25 ++++++++++++++++++++++--- > 1 file changed, 22 insertions(+), 3 deletions(-) > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > index 002268262c9a..108dfb4ecbd5 100644 > +++ b/kernel/dma/direct.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > #include "direct.h" > > /* > @@ -387,19 +388,37 @@ void dma_direct_unmap_sg(struct device *dev, struct scatterlist *sgl, > struct scatterlist *sg; > int i; > > - for_each_sg(sgl, sg, nents, i) > + for_each_sg(sgl, sg, nents, i) { > + if (sg_is_pci_p2pdma(sg)) { > + sg_unmark_pci_p2pdma(sg); This doesn't seem nice, the DMA layer should only alter the DMA portion of the SG, not the other portions. Is it necessary? Jason