Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5102979ybh; Wed, 7 Aug 2019 00:28:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqPhDxLsca1oO1xggfDZDY2sbtkebVWdtRrX7ECsGFxgrnZmatUO4XsJR8xl6xVxgdl6gj X-Received: by 2002:a62:be02:: with SMTP id l2mr8105089pff.63.1565162896165; Wed, 07 Aug 2019 00:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565162896; cv=none; d=google.com; s=arc-20160816; b=ZcuBJRYjpFteuZ8tAYo67tB0J9IL/mLk/FT2cEn4LwuPjJu8a+cU751Ezc6KblxipN uvLk/lCXtmMf4S/Mvi3m131wwnfUd4Uir5n3a2zvnLT3lw9Yf9t3LaHFB2VPwonnXxZh aTV8LUA9ZMHw5oJOovGx5dNhV253cs/C2fb1YalnWAbcVPn3Rm/95BBufFtGanGjWuwa tVN+8cwB6x6VZqaIXbBFnM/yShrjBkBOZw6QXTE2QBbbzAnEQowfVnhYMM5nBlLyA0p6 4uwcncH6S1HLMsWMRVeiIt1V5crfviNxdCCDfGmQTpyK3ukz/FyNjUva5SDhEudbiws/ Ij8g== 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-disposition:mime-version:references:message-id:subject:to :from:date; bh=Dug6HUzoUL4JuW1iGCWJnCil/jd/ed4eRTuq3lc3QCk=; b=PlrE+cCsHGeRCWwrJd0jhODwSEXCJO2lqYOTpxYRpL0wf6bmEVJkcl1YWPI25adv8R ZWhNLegKdK/GvdSeHTEYnGuNJEos6MZh7M9t27so1hhZWxoTCDqyk7fw+tLDxzfCqnao FpDD2xVEmeDepJC3x6FI9X9FxE13pErAPwZoi3Z3+3Zdn2DK3RuCsnAQXpEV2KoKj4Tb 6dwBx+Ig1Ka8h1/m+y08sIVOpcISPz9iztgZR8FD6L74jTdrTXlSuGNewbP0T90n0zh/ aT93KSfGZ/Fzr+tWgr4x3LlKTCxJ/Rl7ivr2JxfU/Mnfq+a8/8dhb1WpqEL1MLPr97ja srwQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 130si51581196pgg.18.2019.08.07.00.28.00; Wed, 07 Aug 2019 00:28:16 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387450AbfHGH04 (ORCPT + 99 others); Wed, 7 Aug 2019 03:26:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44786 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727566AbfHGH04 (ORCPT ); Wed, 7 Aug 2019 03:26:56 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F07F230B1B7E; Wed, 7 Aug 2019 07:26:55 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-144.ams2.redhat.com [10.36.116.144]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8722826164; Wed, 7 Aug 2019 07:26:55 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 8E28811AB8; Wed, 7 Aug 2019 09:26:54 +0200 (CEST) Date: Wed, 7 Aug 2019 09:26:54 +0200 From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org, tzimmermann@suse.de, Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , open list Subject: Re: [PATCH 1/3] drm: add gem ttm helpers Message-ID: <20190807072654.arqvx37p4yxhegcu@sirius.home.kraxel.org> References: <20190806133454.8254-1-kraxel@redhat.com> <20190806133454.8254-2-kraxel@redhat.com> <20190806135426.GA7444@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190806135426.GA7444@phenom.ffwll.local> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 07 Aug 2019 07:26:56 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > +/** > > + * drm_gem_ttm_mmap_offset() - Returns a GEM ttm object's mmap offset > > + * @gbo: the GEM ttm object > > + * > > + * See drm_vma_node_offset_addr() for more information. > > + * > > + * Returns: > > + * The buffer object's offset for userspace mappings on success, or > > + * 0 if no offset is allocated. > > + */ > > +u64 drm_gem_ttm_mmap_offset(struct ttm_buffer_object *bo) > > +{ > > + return drm_vma_node_offset_addr(&bo->base.vma_node); > > Why do we need a new one here, can't we use the existing gem > implementation for this (there really should only be one I hope, but I > didn't check). Havn't found one. But maybe we don't need this as separate function and can simply move the drm_vma_node_offset_addr() call into drm_gem_ttm_driver_dumb_mmap_offset(). > > +int drm_gem_ttm_driver_dumb_mmap_offset(struct drm_file *file, > > + struct drm_device *dev, > > + uint32_t handle, uint64_t *offset) > > +{ > > + struct drm_gem_object *gem; > > + struct ttm_buffer_object *bo; > > + > > + gem = drm_gem_object_lookup(file, handle); > > + if (!gem) > > + return -ENOENT; > > + > > + bo = drm_gem_ttm_of_gem(gem); > > + *offset = drm_gem_ttm_mmap_offset(bo); > > + > > + drm_gem_object_put_unlocked(gem); > > + > > + return 0; > > +} > > +EXPORT_SYMBOL(drm_gem_ttm_driver_dumb_mmap_offset); > > Same for this, you're just upcasting to ttm_bo and then downcasting to > gem_bo again ... I think just a series to roll out the existing gem > helpers everywhere should work? I don't think so. drm_gem_dumb_map_offset() calls drm_gem_create_mmap_offset(), which I think is not correct for ttm objects because ttm_bo_init() handles vma_node initialization. cheers, Gerd