Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp440073lqp; Tue, 11 Jun 2024 08:45:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUN6S062p6NKnEPmg8hYNX0T8vI2vou7bgnyfWb4dSok2DJYueSzaoSWJSwxjEdmfOaRz2LBF6FSdXw+TQDtnokKr0HR6sXs6/m414H6A== X-Google-Smtp-Source: AGHT+IHi7/jhGwXUCmXvhfXWoqjP1WE8wq6vcFJNhwc7XQ4fZaPslkAteGlGOuN9oxYj+dxkrJxB X-Received: by 2002:a17:906:b349:b0:a6e:fad9:6dbb with SMTP id a640c23a62f3a-a6efad96e63mr668230466b.0.1718120735382; Tue, 11 Jun 2024 08:45:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718120735; cv=pass; d=google.com; s=arc-20160816; b=lY5O42BVNW4VzPxstqATzAxDoUscTuKlObVByFe5ZgDuFu9oYo+F4ZCDlTRo13JBnt xxwLBqZT/iAYCy3DkCHNSeYnyS1/l6eVq6AdUsNivI08g/UpHJLd1c/+noYr5DtJTHdR Uyu7ZwPhawW6vhZR4lLRru8AfSDNQLgORz32GCM23XklhGNMZD0ZSIsMYXukNRTAvfHg qEgubOeeA3mld+nG0IecEuzcb84iAssoqe/Naa2h3fpsP2H/ebtPqcRLaMa5PLQ3EJDr 6mGNrn4gbdyZxBzBX80sE0AHWB8BoDSaka492qCRp830gMVnJ1vL615V2Wm/FX7Tla9V nMPA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oc2eqbMXkAVLIaVnQZ8lbsbNYnsCeobEtpDB3bTLDUU=; fh=3UoOG683VS7Fhntxc7hv+2/ARXlqbRoosARFB55v8e0=; b=vk5xyk+N+2Z5DCXhxe5g7+52l991XbHoZGk8aI/+ez1mhxfGcTuGk0kExRWSEAf3uL 6Tv/xW+dK8ADnRG6E6VPyH036RO+mhOznVbp0FyJG/QknOpxkLS9Ip6hQyv3QYrJFwSQ SPjYIbdpNJYMf1oSfr6d8d06KbYUBJvTqyk8MeaDjcWD1yTZ0GdZ66csuZvxJnWn8JdS cQFGc1mbJ5S5u0u6SNZWhOZgeaoQeV4dN47c7JLYNt4qsdnt1DKM/KbWcPy9IPuCB8Fo sLWsRENPsnYJk1atKHP3mfWJTXz0WJuymeGxtVs7ROSgmwFstAKDVBsTyzvBc1TX7WLt 2pwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Em6r9Li6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-210172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57c82b28827si2036256a12.186.2024.06.11.08.45.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 08:45:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Em6r9Li6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-210172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E782D1F2581F for ; Tue, 11 Jun 2024 15:45:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08EA738390; Tue, 11 Jun 2024 15:45:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Em6r9Li6" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF7523839C; Tue, 11 Jun 2024 15:45:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718120721; cv=none; b=k8dDiLxjUVTQhqgbI4Ylwup1VFMw2tfssqT9KNST+pPNydLo4EPYyKLMCdUpl1HvVUu6OwhHRS4aNhEDhJN6Zx7AN2joZOVS9CCg8Lw20e+0quw3Emx3o72rPkK4+5OFxcye/UBJ1QRKmj/kRnP/8BA1QfmObOWr0l3/8MT6B9s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718120721; c=relaxed/simple; bh=alWpFRyGJPPxpA/qvEhIVLYBDfG5gKLw2O2vjFdIXBU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=czunXMBSo9nYx1wQ169rUewIPe+WhxELmLSBnbIUgixTW/sVe7I6qhI1aAF0uciXWUg232p8cLB0KOjEPQDbkbEbw11eFheeDqVOgIqbhlr/N+3QwN4pqKnaqvG+ainypWLtptADGcMITxAVlEi6HdbrOqnvCKqlGIuyUy4hy0I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Em6r9Li6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06EE2C2BD10; Tue, 11 Jun 2024 15:45:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718120719; bh=alWpFRyGJPPxpA/qvEhIVLYBDfG5gKLw2O2vjFdIXBU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Em6r9Li64MS4dfA1Fm6Omrjb4w5oyfw2XsNlofj9qeCLh5G5cxfGwuZ4yQPTUgZzW 6kxO2WwG1YbfeA57p9rgmFg6DOXF7B/o2lriNTV968OIdIJj6h+vJ28mFcLCklf+8k loMrtXfftGiWNK48qosW/nixEPYc2CM6BDV0pD+OBtk1iB7sMjJs6yl/UgKehavFC0 ucx5PHa+Nq4Qc5SPa5Zz1cwEjWeiDWr0yVMVZnqrufT33mec/2ulkMu2y2JlMDYEFe LOKNY2IV8maq2WwEhsDrM6P7s8EXMvED5vtpoqf+uru1kkwcRDd4cMFZ+KsLRjANr5 5MbGSb9lFaR2g== Date: Tue, 11 Jun 2024 18:45:15 +0300 From: Leon Romanovsky To: "Zeng, Oak" Cc: Jason Gunthorpe , Christoph Hellwig , Robin Murphy , Marek Szyprowski , Joerg Roedel , Will Deacon , Chaitanya Kulkarni , "Brost, Matthew" , "Hellstrom, Thomas" , Jonathan Corbet , Jens Axboe , Keith Busch , Sagi Grimberg , Yishai Hadas , Shameer Kolothum , "Tian, Kevin" , Alex Williamson , =?iso-8859-1?B?Suly9G1l?= Glisse , Andrew Morton , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-rdma@vger.kernel.org" , "iommu@lists.linux.dev" , "linux-nvme@lists.infradead.org" , "kvm@vger.kernel.org" , "linux-mm@kvack.org" , Bart Van Assche , Damien Le Moal , Amir Goldstein , "josef@toxicpanda.com" , "Martin K. Petersen" , "daniel@iogearbox.net" , "Williams, Dan J" , "jack@suse.com" , Zhu Yanjun , "Bommu, Krishnaiah" , "Ghimiray, Himal Prasad" Subject: Re: [RFC RESEND 00/16] Split IOMMU DMA mapping operation to two steps Message-ID: <20240611154515.GC4966@unreal> References: <20240503164239.GB901876@ziepe.ca> <20240610161826.GA4966@unreal> <20240610172501.GJ791043@ziepe.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Jun 10, 2024 at 09:28:04PM +0000, Zeng, Oak wrote: > Hi Jason, Leon, > > I was able to fix the issue from my side. Things work fine now. I got two questions though: > > 1) The value returned from dma_link_range function is not contiguous, see below print. The "linked pa" is the function return. > I think dma_map_sgtable API would return some contiguous dma address. Is the dma-map_sgtable api is more efficient regarding the iommu page table? i.e., try to use bigger page size, such as use 2M page size when it is possible. With your new API, does it also have such consideration? I vaguely remembered Jason mentioned such thing, but my print below doesn't look like so. Maybe I need to test bigger range (only 16 pages range in the test of below printing). Comment? My API gives you the flexibility to use any page size you want. You can use 2M pages instead of 4K pages. The API doesn't enforce any page size. > > [17584.665126] drm_svm_hmmptr_map_dma_pages iova.dma_addr = 0x0, linked pa = 18ef3f000 > [17584.665146] drm_svm_hmmptr_map_dma_pages iova.dma_addr = 0x0, linked pa = 190d00000 > [17584.665150] drm_svm_hmmptr_map_dma_pages iova.dma_addr = 0x0, linked pa = 190024000 > [17584.665153] drm_svm_hmmptr_map_dma_pages iova.dma_addr = 0x0, linked pa = 178e89000 > > 2) in the comment of dma_link_range function, it is said: " @dma_offset needs to be advanced by the caller with the size of previous page that was linked + DMA address returned for the previous page". > Is this description correct? I don't understand the part "+ DMA address returned for the previous page ". > In my codes, let's say I call this function to link 10 pages, the first dma_offset is 0, second is 4k, third 8k. This worked for me. I didn't add the previously returned dma address. > Maybe I need more test. But any comment? You did it perfectly right. This is the correct way to advance dma_offset. Thanks > > Thanks, > Oak > > > -----Original Message----- > > From: Jason Gunthorpe > > Sent: Monday, June 10, 2024 1:25 PM > > To: Zeng, Oak > > Cc: Leon Romanovsky ; Christoph Hellwig ; > > Robin Murphy ; Marek Szyprowski > > ; Joerg Roedel ; Will > > Deacon ; Chaitanya Kulkarni ; > > Brost, Matthew ; Hellstrom, Thomas > > ; Jonathan Corbet ; Jens > > Axboe ; Keith Busch ; Sagi > > Grimberg ; Yishai Hadas ; > > Shameer Kolothum ; Tian, Kevin > > ; Alex Williamson ; > > J?r?me Glisse ; Andrew Morton > foundation.org>; linux-doc@vger.kernel.org; linux-kernel@vger.kernel.org; > > linux-block@vger.kernel.org; linux-rdma@vger.kernel.org; > > iommu@lists.linux.dev; linux-nvme@lists.infradead.org; > > kvm@vger.kernel.org; linux-mm@kvack.org; Bart Van Assche > > ; Damien Le Moal > > ; Amir Goldstein > > ; josef@toxicpanda.com; Martin K. Petersen > > ; daniel@iogearbox.net; Williams, Dan J > > ; jack@suse.com; Zhu Yanjun > > ; Bommu, Krishnaiah > > ; Ghimiray, Himal Prasad > > > > Subject: Re: [RFC RESEND 00/16] Split IOMMU DMA mapping operation to > > two steps > > > > On Mon, Jun 10, 2024 at 04:40:19PM +0000, Zeng, Oak wrote: > > > Thanks Leon and Yanjun for the reply! > > > > > > Based on the reply, we will continue use the current version for > > > test (as it is tested for vfio and rdma). We will switch to v1 once > > > it is fully tested/reviewed. > > > > I'm glad you are finding it useful, one of my interests with this work > > is to improve all the HMM users. > > > > Jason