Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp5183352pxb; Tue, 28 Sep 2021 12:20:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3aLGFNCiGsUWuzxJo//UG9/aBMYDtb831t9MWsJFkUE+FX1j4oybEVLvRTRgbEB39z1yG X-Received: by 2002:a05:6402:51d2:: with SMTP id r18mr9763073edd.108.1632856799755; Tue, 28 Sep 2021 12:19:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632856799; cv=none; d=google.com; s=arc-20160816; b=tA+GeIBWRC5uqPNENYpfpuFd8yc8Cok2o1N6F6oui66dI/qWvZvVmaGLZjWZv+xj+K 6us2fARHxPhRol8Ra1KOL2UB+4aNageg+cbIK513FPA6BbWUlMrhapcvUvWbitwGzY4H teEfgFFXGwn0cixHdSnevEPnbLnonyuvkWtKl17I5rtwK72DeSvos4CmjXoH2xtOtSh7 s0EOuW4s6FWv4/Js+bWhfhqwLEsOaGE0GuPBKKPopf9X6QM+Ry2WO2Us6Vka5rj95zeW DeB7QcfjUjpS1lHzY0tXxz2ZOloRSOmPpMkEL5UM+emcS+OOmtCG+FGVGKFgTDSnTUJr YJCQ== 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=tcyMivDSSj98xjcYfl0Ss83FFw70+B/UboxWuutjjDI=; b=IUSLqg4II0fDybLqyKIhD8EXxeF/lGh9zi357Dc0smIWqndkeBvW8Cx1E5ej3omZa9 6oxYTjEeZN0wXsqA7pKFP/JjkUFZFh64TrDmLioluRw+hZYavOlTs7m+aBEK1LMkDJGn baeD3uD7G2pmMN3qEVv4JeEFjZcn6Pa5vAUnbrSKCp+s7ApcQw2SB2aIq783V5LbIDXo P4lPEVv7ESOIR9SZVNZYc6fWYonsBjs25kptX8WSoS0fY1y1luVX8p1yokqIma1nYRRM 2aqY8wWE0c4FNjVkpy5uhusFvi35EDopWqSWlLXpGD6DaxLo+WGKFxWFP16CdKhRpk6C TVcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=ZXqOBoW2; 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 f20si572950edf.614.2021.09.28.12.19.35; Tue, 28 Sep 2021 12:19:59 -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=ZXqOBoW2; 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 S242385AbhI1TR3 (ORCPT + 99 others); Tue, 28 Sep 2021 15:17:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242262AbhI1TR3 (ORCPT ); Tue, 28 Sep 2021 15:17:29 -0400 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FE78C061746 for ; Tue, 28 Sep 2021 12:15:49 -0700 (PDT) Received: by mail-qv1-xf36.google.com with SMTP id dk4so421qvb.2 for ; Tue, 28 Sep 2021 12:15:49 -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=tcyMivDSSj98xjcYfl0Ss83FFw70+B/UboxWuutjjDI=; b=ZXqOBoW2zcRY/XCsYnDKUJm0jeVb6g6QynSlK5Ml/gYsHIPYVyWznW28IH/m39nrRs rG+j+z/VkkqSaLLAsjs0lqXyt+KgS2pwIFFxGvKOTpp6OskwVnUll7c0SZ88LW5r3udd 0x2by8/0zgW10HXmR0atwW5ZveJ3LbAJ7dsEEUr2Gu8vBnEg7aKaIp30t+n3dbCJEhXZ 2aFI7yDiqqERTNEfaySqTNHIuhyRB286ED8KYrDS7lbzOda3vmUboyfsyK3esMfGV4a8 lPty5Chcgd6dyRXlzNl6IVGzK8Mh2KFiv4dYejeXY92N3QfzHRKzIOavZpEbU+UISfzK CNNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tcyMivDSSj98xjcYfl0Ss83FFw70+B/UboxWuutjjDI=; b=tcQI4/02kRnifKBzm7Y2uUIT1G9Zq5PgmP578mFvFLDYrA3oIgjIXo/lX3cXOdy82D fOdpuYxeubQcKWOKHqP2ek327/b4yjQCDZnvr5rejWPrGKPUNTmKNDngbgbmeSgzELOa sxU//IWo4pnO0g3CuGZrTkFioKbW29+ZqguFtft58MBp0vibBLAPlcGm4R4C5QrTPSIz 37TymM7TiUh6tXYttkwzwU2G3NjaGwlnVfHocN5I07lWAvm1baWuwxyUBqYjR9AuzYGR e0fRp4GKG5ogAqTOmFhxWBc9qT2hZprC1u0DmrFnkCAgClE1yZnIFn/mN8ltO+zB6WPn 3MwA== X-Gm-Message-State: AOAM532s3Btxk0iqt8vB0Iw0MdlI02PLvS0LDgLQcLX+YMimpajH/qdA qgi6S8TXPhAomRO1mZCmZyuwjw== X-Received: by 2002:a0c:dd92:: with SMTP id v18mr7551030qvk.41.1632856548504; Tue, 28 Sep 2021 12:15:48 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id p9sm6469qkm.23.2021.09.28.12.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 12:15:48 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1mVIZv-007G30-3V; Tue, 28 Sep 2021 16:15:47 -0300 Date: Tue, 28 Sep 2021 16:15:47 -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 , Martin Oliveira , Chaitanya Kulkarni Subject: Re: [PATCH v3 08/20] iommu/dma: support PCI P2PDMA pages in dma-iommu map_sg Message-ID: <20210928191547.GP3544071@ziepe.ca> References: <20210916234100.122368-1-logang@deltatee.com> <20210916234100.122368-9-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210916234100.122368-9-logang@deltatee.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 16, 2021 at 05:40:48PM -0600, Logan Gunthorpe wrote: > When a PCI P2PDMA page is seen, set the IOVA length of the segment > to zero so that it is not mapped into the IOVA. Then, in finalise_sg(), > apply the appropriate bus address to the segment. The IOVA is not > created if the scatterlist only consists of P2PDMA pages. > > A P2PDMA page may have three possible outcomes when being mapped: > 1) If the data path between the two devices doesn't go through > the root port, then it should be mapped with a PCI bus address > 2) If the data path goes through the host bridge, it should be mapped > normally with an IOMMU IOVA. > 3) It is not possible for the two devices to communicate and thus > the mapping operation should fail (and it will return -EREMOTEIO). > > Similar to dma-direct, the sg_dma_mark_pci_p2pdma() flag is used to > indicate bus address segments. On unmap, P2PDMA segments are skipped > over when determining the start and end IOVA addresses. > > With this change, the flags variable in the dma_map_ops is set to > DMA_F_PCI_P2PDMA_SUPPORTED to indicate support for P2PDMA pages. > > Signed-off-by: Logan Gunthorpe > --- > drivers/iommu/dma-iommu.c | 68 +++++++++++++++++++++++++++++++++++---- > 1 file changed, 61 insertions(+), 7 deletions(-) Reviewed-by: Jason Gunthorpe Jason