Received: by 10.213.65.68 with SMTP id h4csp1421204imn; Thu, 29 Mar 2018 04:35:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/zTBArP7960bmEBBlvgGofJuCKCU07GiTe1QZ9w/CktQp60ySSXEcf/lqO33R3QEz2j17F X-Received: by 10.98.172.21 with SMTP id v21mr6087591pfe.203.1522323342015; Thu, 29 Mar 2018 04:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522323341; cv=none; d=google.com; s=arc-20160816; b=k3BlH/o34SLe85Hg+7yShw8jizYFjOO0o91s7KnYlNJcSUfdx4V+xBbpdsCJQg2R6D 4fJynvDa6OLo9jDQwyDGl6meoqUgWXO4wTJaxdpp9+hq1lnsS36kmPv5jVL2f4ByYDAp +4dMkkUeOJSFKiA2trjdLWyk1WepPed5/kw/mc5cxiDHJhoSVgEY9SfJUgqDLI73wU59 AV3eaSAuNO95Ba4Dc2xVKIF0pijOc/K7Nm3Ryd0djAaARwBj8FD0muEOAMnKm4GEiLxC twPJK2Z5L14Yga6YFtAeIOQnZl3cqNIpRiSv/sNrFZ1EOQUDAXJ028M952ACg0n4I2Ir v69A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:reply-to:dkim-signature :arc-authentication-results; bh=IDiQgD4jL4aSziilgdrm2CrjR/d147nZ5nfsfUWkhUY=; b=Ekz/L/VwJpfAFqs27ahlLlE3HP9P/vPrwG2OLQrr09wGzQb95+NczXlDf+GGpb7w7Q +DsExyr6A8GucnDoXUDxnd62krGDAkjQR9DMzGzDXoIiL2btmiFnS4AqZ7PwCsJwlEMZ 7M/36bmkoK3wE1H1KhwTBLkRFb4FxSszKKCMH9IbLdzwp5/q8TR27rvqDU1y4qtRTrO1 vTKCA1sa2wcd0MRsqlbex43JBxvAuXZAb/bZnAcSxjAVEqdhADeXq3fqW96fwblw3Bik oyTwEJk+GA7iLrPdZEodS5zh6D4y2e3ZxVaVowOkamPw/qvM7WGZNvJ+MzlUNEfr/eEy 04HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Vuqh2qgD; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f64-v6si5801262plf.624.2018.03.29.04.35.28; Thu, 29 Mar 2018 04:35:41 -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=pass header.i=@gmail.com header.s=20161025 header.b=Vuqh2qgD; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753223AbeC2Lea (ORCPT + 99 others); Thu, 29 Mar 2018 07:34:30 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:39357 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752979AbeC2Le2 (ORCPT ); Thu, 29 Mar 2018 07:34:28 -0400 Received: by mail-wm0-f44.google.com with SMTP id f125so10932948wme.4; Thu, 29 Mar 2018 04:34:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=IDiQgD4jL4aSziilgdrm2CrjR/d147nZ5nfsfUWkhUY=; b=Vuqh2qgD6nAjxTtI9jCis7xE+qz3VABxTH0tc8fO6TJHqh8EY/SnVhXNAcH6eDAc/a L3cW8yzZqjSlew5tm6BORWyVbuVCmY1EcPDxFo50fKo3uXXKcRmp3y9vrDuHZO1l+dJr Pd66pxn2RcYZEp8Yxi2oKVHuLckoC7Q+Nc9d676d0zhL7VxnwdA0ErxzkoFsmFdQviS9 VGr3on7gKxY0jnZt0BEYbqOCNfjduaLkvyQxHT/HF0cNS5wu1mtg9RsTMaPdVLXzpEkj wZKfb4hIT9jLD38myurQg9Dv75yrgubbCsocj9S0GXnIBgBtUfvlOMtbjkgQbdks7MuF Ug2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=IDiQgD4jL4aSziilgdrm2CrjR/d147nZ5nfsfUWkhUY=; b=Cfs5k68gLvptu/DuFQYtzdsMr+ykcOQEQuHkokJld+Bj9GaZt278WsUnTHSzu/L0jS +Ulb/RiKqT5QUtKqTkjxOsZFcZoA+OnBTLqLRBev5rD347WTIf7z6SlImd7h4ZtBUHdM FHGWLGNxvOTtw0fBTMDy866AEsOBxrWzla0ynkC3dftBjIDfus+FPqmGvBrILmhPWFGb BZmzL4uYpvCDFVmJ66G0RpekyfEmZMTV38fQq6PrgFXbch2JkITGQGCkrnNCk4ZBeVby STBsQiks9mk7tFClPckhGLg1ipXE1S5wePJZkWud3ZEYoznF5NSZyjR4F516NbHJPhtd 9uCg== X-Gm-Message-State: AElRT7FOHYHmzRg5nyUOu090IrRjBNt1tjQ8cuaenK4YUff8mXcCFZzl 6AZBdffC0ERjpWDaQ19ljBox2WBD X-Received: by 10.28.110.17 with SMTP id j17mr6121569wmc.65.1522323266317; Thu, 29 Mar 2018 04:34:26 -0700 (PDT) Received: from ?IPv6:2a02:8109:500:e1c:8d9f:809a:df07:714b? ([2a02:8109:500:e1c:8d9f:809a:df07:714b]) by smtp.gmail.com with ESMTPSA id j4sm8396465wrd.53.2018.03.29.04.34.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Mar 2018 04:34:25 -0700 (PDT) Reply-To: christian.koenig@amd.com Subject: Re: [PATCH 4/8] dma-buf: add peer2peer flag To: 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> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <8b823458-8bdc-3217-572b-509a28aae742@gmail.com> Date: Thu, 29 Mar 2018 13:34:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180329065753.GD3881@phenom.ffwll.local> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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. > 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