From patchwork Thu Aug 15 11:59:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 19169 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f199.google.com (mail-ye0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DDD1E25A1B for ; Thu, 15 Aug 2013 11:59:41 +0000 (UTC) Received: by mail-ye0-f199.google.com with SMTP id l12sf679108yen.6 for ; Thu, 15 Aug 2013 04:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=delivered-to:date:from:to:message-id:mail-followup-to:references :mime-version:in-reply-to:user-agent:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-disposition :content-type:content-transfer-encoding; bh=ZlxI1dFvv9eypG60vWnJHZhe+ib48S28Cbi/WuD9hnc=; b=UtWG7ehbL2eFlwYfFHyxT6Dhha87sG6Ie4WxxzemLdtgFP746v2lqq9YGFUrc+ek67 AQvu48YAtxqEji+QVpIWlQ5F00lmzyKJYELK/Ke+v8v+OJ9SbLKPLi0NwX1pbLK6zMRD 4HDMPUiKDMPMTc0lKdBZe9t+1+zN0HUghaSH8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:delivered-to:date:from:to:message-id :mail-followup-to:references:mime-version:in-reply-to:user-agent:cc :subject:precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-disposition :content-type:content-transfer-encoding; bh=ZlxI1dFvv9eypG60vWnJHZhe+ib48S28Cbi/WuD9hnc=; b=Mdy3hXnZAxJDEjdnbwxMj8ct/aE6TYmc49A1NN35mrsV0uGc/36LtstIf5ziDQHChj 2aL7rXcoYuIHn4hDih5ILMaZN1nIJ8uvjhSIuwOwIl9Shh/QlSOLOAL0iUMClE5Sbs1g 7ObNKa9QKpm+oblFNFYI2bEguGNKMuRQRJNcMqdkkfiztQRBfjbDbMqieWF2gM9oz8w4 lFOaYG7EAWEVD/DEQqbK+/lUBYTKL1hmkPH+DIUgOIWM/9uZPAqt+Tkqvi7Fjtc2xsUM +tqvS+h5sF4y2xpUwUwFSrjbfiJTNzTBhjtOxfrXi0Tj154MtyRC5D22zC1gvaNE/zHP yOEw== X-Received: by 10.58.97.129 with SMTP id ea1mr4932946veb.25.1376567981124; Thu, 15 Aug 2013 04:59:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.88.38 with SMTP id bd6ls266785qeb.29.gmail; Thu, 15 Aug 2013 04:59:41 -0700 (PDT) X-Received: by 10.58.164.101 with SMTP id yp5mr14325221veb.0.1376567980971; Thu, 15 Aug 2013 04:59:40 -0700 (PDT) Received: from mail-ve0-x22d.google.com (mail-ve0-x22d.google.com [2607:f8b0:400c:c01::22d]) by mx.google.com with ESMTPS id fw17si12428423vec.142.2013.08.15.04.59.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Aug 2013 04:59:40 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22d is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22d; Received: by mail-ve0-f173.google.com with SMTP id cy12so462779veb.18 for ; Thu, 15 Aug 2013 04:59:40 -0700 (PDT) X-Gm-Message-State: ALoCoQlJUq51MVAZA5G9FIVP82z8uA19Q6+YXXtxV8/3BgOzolQKa9dw1DkAi2RMPwI3Zj4qSAUd X-Received: by 10.58.237.105 with SMTP id vb9mr14326340vec.2.1376567980848; Thu, 15 Aug 2013 04:59:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp7220vcz; Thu, 15 Aug 2013 04:59:40 -0700 (PDT) X-Received: by 10.194.110.6 with SMTP id hw6mr10088004wjb.3.1376567979489; Thu, 15 Aug 2013 04:59:39 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id bv20si847251wib.84.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 15 Aug 2013 04:59:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1V9wCn-0002Jf-35; Thu, 15 Aug 2013 11:59:05 +0000 Received: from mail-ea0-f176.google.com ([209.85.215.176]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1V9wCl-0002Ja-26 for linaro-mm-sig@lists.linaro.org; Thu, 15 Aug 2013 11:59:03 +0000 Received: by mail-ea0-f176.google.com with SMTP id q16so319233ead.35 for ; Thu, 15 Aug 2013 04:59:24 -0700 (PDT) X-Received: by 10.15.107.132 with SMTP id cb4mr4459684eeb.54.1376567964268; Thu, 15 Aug 2013 04:59:24 -0700 (PDT) Received: from phenom.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPSA id p5sm83906086eeg.5.2013.08.15.04.59.22 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 15 Aug 2013 04:59:23 -0700 (PDT) Date: Thu, 15 Aug 2013 13:59:32 +0200 From: Daniel Vetter To: Christopher James Halse Rogers Message-ID: <20130815115932.GC776@phenom.ffwll.local> Mail-Followup-To: Christopher James Halse Rogers , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, robclark@gmail.com, linux-media@vger.kernel.org References: <1375683720-4748-1-git-send-email-christopher.halse.rogers@canonical.com> MIME-Version: 1.0 In-Reply-To: <1375683720-4748-1-git-send-email-christopher.halse.rogers@canonical.com> X-Operating-System: Linux phenom 3.11.0-rc2+ User-Agent: Mutt/1.5.21 (2010-09-15) Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, robclark@gmail.com, linux-media@vger.kernel.org Subject: Re: [Linaro-mm-sig] [PATCH] dma-buf: Expose buffer size to userspace X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: linaro-mm-sig-bounces@lists.linaro.org Sender: linaro-mm-sig-bounces@lists.linaro.org X-Original-Sender: daniel@ffwll.ch X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22d is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (bad format) header.i=@ffwll.ch Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Content-Disposition: inline On Mon, Aug 05, 2013 at 04:22:00PM +1000, Christopher James Halse Rogers wrote: > Each dma-buf has an associated size and it's reasonable for userspace > to want to know what it is. > > Since userspace already has an fd, expose the size using the > size = lseek(fd, SEEK_END, 0); lseek(fd, SEEK_CUR, 0); > idiom. > > Signed-off-by: Christopher James Halse Rogers Yeah, loosk good to me and rather useful, so (with the dma-buf docs improved as suggested below): Reviewed-by: Daniel Vetter I've also written some small prime tests in igt, so also: Tested-by: Daniel Vetter > --- > > I've run into a point in the radeon DRM userspace where I need the > size of a dma-buf. I could add a radeon-specific mechanism to get that, > but this seems like something that would be more generally useful. > > I'm not entirely sure about supporting both SEEK_END and SEEK_CUR; this > is somewhat of an abuse of lseek, as seeking obviously doesn't make sense. > It's the obivous idiom for getting the size of what's on the other end of a > file descriptor, though. > > I didn't notice anywhere to document this; Documentation/dma-buf-api didn't > seem like the right place. Is there somewhere I've overlooked? I think adding a section about various other userspace interfaces exposed below the mmap support section would be good. Feel free to squash in the belo diff for v2. Cheers, Daniel Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch diff --git a/Documentation/dma-buf-sharing.txt b/Documentation/dma-buf-sharing.txt index 0b23261..b3a8aa2 100644 --- a/Documentation/dma-buf-sharing.txt +++ b/Documentation/dma-buf-sharing.txt @@ -407,6 +407,18 @@ Being able to mmap an export dma-buf buffer object has 2 main use-cases: interesting ways depending upong the exporter (if userspace starts depending upon this implicit synchronization). +Other Interfaces Exposed to Userspace on the dma-buf FD +------------------------------------------------------ + +- Since kernel 3.12 the dma-buf FD supports the llseek system call, but only + with offset=0 and whence=SEEK_END|SEEK_SET. SEEK_SET is supported to allowe + the usual size discover pattern size = SEEK_END(0); SEEK_SET(0). Every other + llseek operation will report -EINVAL. + + If llseek on dma-buf FDs isn't support the kernel will report -ESPIPE for all + cases. Userspace can use this to detect support for discovering the dma-buf + size using llsee. + Miscellaneous notes ------------------- -- Daniel Vetter