Received: by 10.213.65.68 with SMTP id h4csp3290654imn; Tue, 3 Apr 2018 02:11:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/luenILDCaADQaBKCw2VrtpRyuAAH9owUVRC6zuZehBQuYWpEXdx2kbVbj8ZZEXP/tAp/5 X-Received: by 2002:a17:902:a2:: with SMTP id a31-v6mr13250964pla.204.1522746710979; Tue, 03 Apr 2018 02:11:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522746710; cv=none; d=google.com; s=arc-20160816; b=0+9m/IKnUuqgCbwKyR67zMOHs7snaRXzYGmpooHfGJAPB3C8HfaMobDkOXtBGfN+FC x1gGyR40jks6vahRPnAZByqfo5ZigDiK+VXHUcumIYL6oJKG9QkMXcJfQWN6fmJuBypi e5MqM+9Od+xfGflduoDZ9mIxbtbosjxs2T2XJtKcVeF9kbU/imASgU0WlAhLuILorBqd uHOYqm6tCRPe6Zr48X3KLVvCF77xN4eb+5CgGA2n7VYf7wGjyiYskudvYmMb5lWt+pV6 JZLmkkjt9AuuDKbJf/cW0aIWi4CtDP9KlV8fru9LfhZzCKzgzxtHH6hV4UQp97zU5eCh AeqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=F+MRr745Bqq1p3p0rnx4bSihSiow9iRLXA6TzWLdySQ=; b=ePoGjOCywiIVJ0VNCLCs/UNoquK1aVjqAzFC9t95TB9LLqifi9dZmoQXlnqJ1j4zIr h9mL57pilZ/yrPsGqX5MtN5zMPhC7SCdXTBdkg1/auDlLhCTkMSiGa152BWJ8UEv/zzf Sqaz6WpmpHeCk4Bk542kF4fTDNayfzpZFZMP83Wkem4zWq6XjlaM9zT82Q7khsTYC3MW wV4MeGbN4kLkb26mFqqpxqVTIybRf9W2oThvb7OxzPKVvotyglCUu17zaN3OPh5krebk 6LS/lZlTcH8HSHxvocBZwvTUI9qLz/ESBu9wJw0SqhxyRY56Iy8YZ7eLACrmfg2gqHEl lyGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=QVRN2b85; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 u7si656690pgv.251.2018.04.03.02.11.37; Tue, 03 Apr 2018 02:11:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=QVRN2b85; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755224AbeDCJJP (ORCPT + 99 others); Tue, 3 Apr 2018 05:09:15 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:56245 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753441AbeDCJJN (ORCPT ); Tue, 3 Apr 2018 05:09:13 -0400 Received: by mail-wm0-f52.google.com with SMTP id b127so31101975wmf.5 for ; Tue, 03 Apr 2018 02:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=F+MRr745Bqq1p3p0rnx4bSihSiow9iRLXA6TzWLdySQ=; b=QVRN2b85VaJrg8SKkEkOH7Ea6uXU8Ct384Qbw5wz0b4L7NB0Fg1m1GGko6pql0/otd zIJRxUm86HXvY6FhonVzcWOZwWqjjNL90vMqs2atuvIhAFDvMOWKQWvHndwj3BnfO9u4 uhfD9havLucePG1pckFyyi7846DrMqLxeIM7k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=F+MRr745Bqq1p3p0rnx4bSihSiow9iRLXA6TzWLdySQ=; b=cYRlj84JqIb+Irrhq7pFyfwtAMDTzNTZ+NIjV7QFCxh74kPAu0EdM+oTTmAkBlPIZB w3/LIyqjif3rQD76hFT4zoYTXyUeXJDLdMR3nSSK2+jqenGw2JzXFHcMjcXdOkMlR87k iuLhEHslqk2g3lBeXdFeg3trDd+1NQHZeclrzQvpQ5lZcWrPkLe6DeRey8DiiRRvbu1V g4ZF7J3uwGqYPsuiI6MGxoUBIszV9lLLFFSpHtwDvYVhTW2qctdpDg4pKVVItgSNK+nL KgETcVZUbC24Znhjw5KmeZGvBsD8uQsqGmoNyxLn6uYSkOZkcRDXwA0bh9YXjKXpoT/E Cylw== X-Gm-Message-State: AElRT7EcxYsJ0H/adP61fYuu9ZHSI5FZF+2q83S5gIJcqkOY6I8420WE ZLDbrvENYzJLBupAr1nIqOLIUg== X-Received: by 10.80.140.200 with SMTP id r8mr15372205edr.310.1522746552355; Tue, 03 Apr 2018 02:09:12 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by smtp.gmail.com with ESMTPSA id 4sm1468904edx.8.2018.04.03.02.09.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Apr 2018 02:09:11 -0700 (PDT) Date: Tue, 3 Apr 2018 11:09:09 +0200 From: Daniel Vetter To: christian.koenig@amd.com Cc: linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/8] dma-buf: add peer2peer flag Message-ID: <20180403090909.GN3881@phenom.ffwll.local> Mail-Followup-To: christian.koenig@amd.com, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20180325110000.2238-1-christian.koenig@amd.com> <20180325110000.2238-4-christian.koenig@amd.com> <20180329065753.GD3881@phenom.ffwll.local> <8b823458-8bdc-3217-572b-509a28aae742@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8b823458-8bdc-3217-572b-509a28aae742@gmail.com> X-Operating-System: Linux phenom 4.15.0-1-amd64 User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 29, 2018 at 01:34:24PM +0200, Christian K?nig wrote: > Am 29.03.2018 um 08:57 schrieb Daniel Vetter: > > On Sun, Mar 25, 2018 at 12:59:56PM +0200, Christian K?nig wrote: > > > Add a peer2peer flag noting that the importer can deal with device > > > resources which are not backed by pages. > > > > > > Signed-off-by: Christian K?nig > > Um strictly speaking they all should, but ttm never bothered to use the > > real interfaces but just hacked around the provided sg list, grabbing the > > underlying struct pages, then rebuilding&remapping the sg list again. > > Actually that isn't correct. TTM converts them to a dma address array > because drivers need it like this (at least nouveau, radeon and amdgpu). > > I've fixed radeon and amdgpu to be able to deal without it and mailed with > Ben about nouveau, but the outcome is they don't really know. > > TTM itself doesn't have any need for the pages on imported BOs (you can't > mmap them anyway), the real underlying problem is that sg tables doesn't > provide what drivers need. > > I think we could rather easily fix sg tables, but that is a totally separate > task. Looking at patch 8, the sg table seems perfectly sufficient to convey the right dma addresses to the importer. Ofcourse the exporter has to set up the right kind of iommu mappings to make this work. > > The entire point of using sg lists was exactly to allow this use case of > > peer2peer dma (or well in general have special exporters which managed > > memory/IO ranges not backed by struct page). So essentially you're having > > a "I'm totally not broken flag" here. > > No, independent of needed struct page pointers we need to note if the > exporter can handle peer2peer stuff from the hardware side in general. > > So what I've did is just to set peer2peer allowed on the importer because of > the driver needs and clear it in the exporter if the hardware can't handle > that. The only thing the importer seems to do is call the pci_peer_traffic_supported, which the exporter could call too. What am I missing (since the sturct_page stuff sounds like it's fixed already by you)? -Daniel > > I think a better approach would be if we add a requires_struct_page or so, > > and annotate the current importers accordingly. Or we just fix them up (it > > is all in shared ttm code after all, I think everyone else got this > > right). > > I would rather not bed on that. > > Christian. > > > -Daniel > > > > > --- > > > drivers/dma-buf/dma-buf.c | 1 + > > > include/linux/dma-buf.h | 4 ++++ > > > 2 files changed, 5 insertions(+) > > > > > > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c > > > index ffaa2f9a9c2c..f420225f93c6 100644 > > > --- a/drivers/dma-buf/dma-buf.c > > > +++ b/drivers/dma-buf/dma-buf.c > > > @@ -565,6 +565,7 @@ struct dma_buf_attachment *dma_buf_attach(const struct dma_buf_attach_info *info > > > attach->dev = info->dev; > > > attach->dmabuf = dmabuf; > > > + attach->peer2peer = info->peer2peer; > > > attach->priv = info->priv; > > > attach->invalidate = info->invalidate; > > > diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h > > > index 15dd8598bff1..1ef50bd9bc5b 100644 > > > --- a/include/linux/dma-buf.h > > > +++ b/include/linux/dma-buf.h > > > @@ -313,6 +313,7 @@ struct dma_buf { > > > * @dmabuf: buffer for this attachment. > > > * @dev: device attached to the buffer. > > > * @node: list of dma_buf_attachment. > > > + * @peer2peer: true if the importer can handle peer resources without pages. > > > * @priv: exporter specific attachment data. > > > * > > > * This structure holds the attachment information between the dma_buf buffer > > > @@ -328,6 +329,7 @@ struct dma_buf_attachment { > > > struct dma_buf *dmabuf; > > > struct device *dev; > > > struct list_head node; > > > + bool peer2peer; > > > void *priv; > > > /** > > > @@ -392,6 +394,7 @@ struct dma_buf_export_info { > > > * @dmabuf: the exported dma_buf > > > * @dev: the device which wants to import the attachment > > > * @priv: private data of importer to this attachment > > > + * @peer2peer: true if the importer can handle peer resources without pages > > > * @invalidate: callback to use for invalidating mappings > > > * > > > * This structure holds the information required to attach to a buffer. Used > > > @@ -401,6 +404,7 @@ struct dma_buf_attach_info { > > > struct dma_buf *dmabuf; > > > struct device *dev; > > > void *priv; > > > + bool peer2peer; > > > void (*invalidate)(struct dma_buf_attachment *attach); > > > }; > > > -- > > > 2.14.1 > > > > > > _______________________________________________ > > > dri-devel mailing list > > > dri-devel@lists.freedesktop.org > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch