From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1016324B240 for ; Fri, 10 Jan 2025 19:24:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736537068; cv=none; b=ZwxZGiGHX1jeXrJw8+mvFaI7YMpw8oVDQI0Spe0cbxRdxrms42I5gnl7kXWOpyeO+5yhQfx+wODWzf30maASL20U9B473GYn3Pjx/Wjyj3it1v5ItVy9VDdEPWvFAAfSRUwpDxtxY+qIU++egfWEvY18gaYIEGhrHRltdfzhh/0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736537068; c=relaxed/simple; bh=GAXiVwRl5hX0nr5x2c6GDMtUgYBmYNxhBnIp/PYb1FQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eUZzgP84Vjbf3dS9m81N/vvvtjKBpT26oCa7imBFgZrhuc1Rz/idX69R+oGX0/RJxebT4Wy5vYZwYRW+I/AvvcVDLYQuOBnFs/She6Ljwq09U55/UpsiMAQUzLHiH6pfIsUuDBAJLPeBOTX3jooEJ2IFOAPE6ChFEt8VU4ZG29I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch; spf=none smtp.mailfrom=ffwll.ch; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b=ULCkposT; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ffwll.ch Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="ULCkposT" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-436341f575fso25961015e9.1 for ; Fri, 10 Jan 2025 11:24:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; t=1736537065; x=1737141865; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=9ACopzyajfJRcuBL6kkHr9KV+I23S42u7LRA+BIOf1M=; b=ULCkposT/Gm25LgersU71BEgkzgTyUegXvreUI6kRtUy0RkZ/aQGSFkVbIfktpsygl 1OlM6J+tyMQeqX0c86M6SVJT+O1+L6VI+wyjRPs8v6+Ip7cM+ZrZ177hSGcNNc/4R/t9 Xj+2sID7HgJMgmlxUNDIBxWUoQxIFlxUp1Cws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736537065; x=1737141865; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9ACopzyajfJRcuBL6kkHr9KV+I23S42u7LRA+BIOf1M=; b=kjFaOQrdteMNiXfEx+bJf73mRShpFPO0y5KpnSpoA+e6teK6SeqbuP5um9onDq4bFT XSTD9xFIrM1F/mW+tjS4Hchy5p0potOqXmCL192pvPmFvYsPe/sjP/KJgqCPApZAJItm EXZpX69Efa75cjPcu4IGKsLm8Soe+PRP2r2f3sQ945j97AHKKpfL4qQzVGym2M05/mWJ JH2b4blDzrUvrScJ1jgGMCO4xIu0Kg01TF8vDtxgPNlWCrFfq6ZFtZBaYTRlOtZskhIZ Ai0iVt0S2CYlgTI4aCZhkcUlYYg50KulxHmMmcakwKnha/JQIsI09u+IlVLWwmEgvRzg kiMg== X-Forwarded-Encrypted: i=1; AJvYcCV/hw83vfNYFD8FvzPHLf7oyVCU4qExB/Mik9MxEfb3yGwcxl5bKxjBKAW3kQWiuBJe1USmV7kj+wh/72Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yzfx3YoVOTZUjFPRi5m+1KCitnbru7V18vqngaYeVQeeYlFPu4W o9m3WrWzQvHCAv3g0SmtpgwmevTCbDAxkTCaR9bdBreqIYNIR6tPElgEoIQsxAw= X-Gm-Gg: ASbGnctB0nRL1kB1e7qPWkgS96tBQks9sTnvda8HUCp5Z/YRFNf2nns+O/IiTMYcnKb BEX/Mc9FgYFdEfwv8h9Nn4DGLfIj2qYz7Z6UtzGracEF0pd4HTOUhtMyfCcG1euNE2rb8uzT6D7 m8QGBJo5LM8mgt8qHb7rMgc+TQxdst3yzzMUerR/Cbp/syLirLS6sWHxMvHS5zkcpv8fk3K5FND vSEN87HLz8BsjEVisQLPFi2qMjv/Aq/PEcWVtN8fC/CXs8zpYcne/awWhclsjO23OLK X-Google-Smtp-Source: AGHT+IGQsKQI4LrL1qdpFjuY9ZWEttHxIv9pv69yZaLOwftdrmmCEXmYM32sp7WuieWtkMyPIHFCuw== X-Received: by 2002:a05:600c:a0a:b0:434:a04d:1670 with SMTP id 5b1f17b1804b1-436e25548e3mr2817985e9.0.1736537065429; Fri, 10 Jan 2025 11:24:25 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:5485:d4b2:c087:b497]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e37d11csm5313117f8f.16.2025.01.10.11.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 11:24:24 -0800 (PST) Date: Fri, 10 Jan 2025 20:24:22 +0100 From: Simona Vetter To: Xu Yilun Cc: Jason Gunthorpe , Christian =?iso-8859-1?Q?K=F6nig?= , Christoph Hellwig , Leon Romanovsky , kvm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, sumit.semwal@linaro.org, pbonzini@redhat.com, seanjc@google.com, alex.williamson@redhat.com, vivek.kasireddy@intel.com, dan.j.williams@intel.com, aik@amd.com, yilun.xu@intel.com, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, lukas@wunner.de, yan.y.zhao@intel.com, daniel.vetter@ffwll.ch, leon@kernel.org, baolu.lu@linux.intel.com, zhenzhong.duan@intel.com, tao1.su@intel.com Subject: Re: [RFC PATCH 01/12] dma-buf: Introduce dma_buf_get_pfn_unlocked() kAPI Message-ID: Mail-Followup-To: Xu Yilun , Jason Gunthorpe , Christian =?iso-8859-1?Q?K=F6nig?= , Christoph Hellwig , Leon Romanovsky , kvm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, sumit.semwal@linaro.org, pbonzini@redhat.com, seanjc@google.com, alex.williamson@redhat.com, vivek.kasireddy@intel.com, dan.j.williams@intel.com, aik@amd.com, yilun.xu@intel.com, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, lukas@wunner.de, yan.y.zhao@intel.com, leon@kernel.org, baolu.lu@linux.intel.com, zhenzhong.duan@intel.com, tao1.su@intel.com References: <20250107142719.179636-1-yilun.xu@linux.intel.com> <20250107142719.179636-2-yilun.xu@linux.intel.com> <20250108132358.GP5556@nvidia.com> <20250108145843.GR5556@nvidia.com> <5a858e00-6fea-4a7a-93be-f23b66e00835@amd.com> <20250108162227.GT5556@nvidia.com> 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=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 6.12.3-amd64 On Thu, Jan 09, 2025 at 01:56:02AM +0800, Xu Yilun wrote: > > > > 5) iommufd and kvm are both using CPU addresses without DMA. No > > > > exporter mapping is possible > > > > > > We have customers using both KVM and XEN with DMA-buf, so I can clearly > > > confirm that this isn't true. > > > > Today they are mmaping the dma-buf into a VMA and then using KVM's > > follow_pfn() flow to extract the CPU pfn from the PTE. Any mmapable > > dma-buf must have a CPU PFN. > > Yes, the final target for KVM is still the CPU PFN, just with the help > of CPU mapping table. > > I also found the xen gntdev-dmabuf is calculating pfn from mapped > sgt. See the comment, it's ok because it's a fake device with fake iommu and the xen code has special knowledge to peek behind the curtain. -Sima > From Christion's point, I assume only sgl->dma_address should be > used by importers but in fact not. More importers are 'abusing' sg dma > helpers. > > That said there are existing needs for importers to know more about the > real buffer resource, for mapping, or even more than mapping, > e.g. dmabuf_imp_grant_foreign_access() -- Simona Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch