Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5153783ybh; Wed, 7 Aug 2019 01:30:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqx35XYe/uNSMwa5EU28vWYOT5HCJn9aU8Jqr9iJElZdN+Z3blz11cj8L5OEf+Iadcj/LURW X-Received: by 2002:a63:7d49:: with SMTP id m9mr6943997pgn.161.1565166636143; Wed, 07 Aug 2019 01:30:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565166636; cv=none; d=google.com; s=arc-20160816; b=bi2rXo0XShvS/sZs4Z3hOPWf2cJhZe8FqXT0bUoAgUb0qt6PayfJyuJl1qq1Z2QdT3 cgBgu3vVUzBMELcJ18VlOmlvCOD0MUP2UDZvFprPkXzPu65PQF0/JdrVo6q63Qf7IkBy eVkriGAdm840/UQSI/UmUxeV+T7aZVfyx4X3RDDfcsSj/Y7LRie4wH3TnxDiZj4y3X6C csPBU3aCiWHG2JBVqLelXTAYVlBUjdNHpSt1sNH7BQQv0zo/pyO+KW7N5I038QK8FDQz E41/L9NGlvHwalcipUBp0XKQ9aALGnvxBnJ8ovWWdfH2Y6wdiofuQV2EBChhm8hr2i8F EzaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6VqkYW5Pb9NPAUWAJ1Hm+13eBgHLhXTSOzj6pGDrWaE=; b=tCpfkmC9vmZ2Km9w1A8lB7y/xcZewrt3akt3dStJs0HwxOknvx2S+weg1o1toY5+wJ sfvdlRabf3AqZb7cXtnEbiKpcLGWU8KTAtImW85LMHhScyq85/V7CUpmBFDphCtw4OHm Rr0WTjGoXYBYQBQfEwgzAOL4q/q2r4BcdSQROuuyU/4QRiXnnF951a4INsky/KpBrsY8 SxrON99GR6U5IrvsHa0aJ8lGmHMN3j5yjw8eGq9Di0iqdRVUR5aQx+6MrJYrLXzIEhnf SoXDrKKetJ7TcxFNlCuByxLUMzBdcg0wtBANONtA+SHl1bRYuqnw9RWAMK/AmESdRwYb vKVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=QK21tnj2; 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 n6si17107101pjb.73.2019.08.07.01.30.20; Wed, 07 Aug 2019 01:30:36 -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=@ffwll.ch header.s=google header.b=QK21tnj2; 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 S2387645AbfHGI2N (ORCPT + 99 others); Wed, 7 Aug 2019 04:28:13 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:34486 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387414AbfHGI2M (ORCPT ); Wed, 7 Aug 2019 04:28:12 -0400 Received: by mail-ot1-f65.google.com with SMTP id n5so101148832otk.1 for ; Wed, 07 Aug 2019 01:28:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6VqkYW5Pb9NPAUWAJ1Hm+13eBgHLhXTSOzj6pGDrWaE=; b=QK21tnj2wA2WAGFXzboom94BfRwn1VGhGTG6G9qemB4Z1SDyDwLhNic25qBROeA+AO Otpbp/+1Z5xkFz2u3hnoNZl/7sxTpen5B6V3/zwbN6d3y8xKK5XCIRXb4BBm3yOt9/uk dmBZXigpTm+moy+wJpK9MV+2TKlKA3eVZ91iM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6VqkYW5Pb9NPAUWAJ1Hm+13eBgHLhXTSOzj6pGDrWaE=; b=on6h78Lyt0algPISmgjNBgJrObcnE3UjT+VnYrSiA+uhIQqifAatMkHlbOrg1ggJmv BLmHH0rph2bz3wDYRlYRs+D1/L4AfasOCJg7qxYGy1gDAxYZl1wJFJY06zDXzpYwPXm/ jsU28YlbS8XLoixEePMtHtb6PIwD9aCRsDz6wAWElPAUZ+WrbE5N5oICFie54BqVgqET Nv7cxsnjj2FOUbG0TGFoSPU8I0+mm5Tj7RtjqSqRIgQv2vrc0ptBbIr58xMpNIUnaIoU LxX1XV9fT9XMV+QA36OfSHvwfF5rBDae4kaXk/LEFMzOO7FlL4HgQbMCyQMr1o0/bL/W qKwA== X-Gm-Message-State: APjAAAW39yu92NWKPJdYgCEew3Gu38Grp+GTMXqiFKh/buPdQeMK7d6s DffHHfwKGjdMHqWTARMyasQM5gr+Iiu2g+Gs9+Mn0Q== X-Received: by 2002:a05:6808:118:: with SMTP id b24mr4623781oie.128.1565166491437; Wed, 07 Aug 2019 01:28:11 -0700 (PDT) MIME-Version: 1.0 References: <20190806133454.8254-1-kraxel@redhat.com> <20190806133454.8254-2-kraxel@redhat.com> <20190806135426.GA7444@phenom.ffwll.local> <20190807072654.arqvx37p4yxhegcu@sirius.home.kraxel.org> In-Reply-To: <20190807072654.arqvx37p4yxhegcu@sirius.home.kraxel.org> From: Daniel Vetter Date: Wed, 7 Aug 2019 10:28:00 +0200 Message-ID: Subject: Re: [PATCH 1/3] drm: add gem ttm helpers To: Gerd Hoffmann Cc: dri-devel , Thomas Zimmermann , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 7, 2019 at 9:29 AM Gerd Hoffmann wrote: > > > > +/** > > > + * 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. It got reverted out again: commit 415d2e9e07574d3de63b8df77dc686e0ebf64865 Author: Rob Herring Date: Wed Jul 3 16:38:50 2019 -0600 Revert "drm/gem: Rename drm_gem_dumb_map_offset() to drm_gem_map_offset()" > 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. More code to unify first? This should work exactly the same way for all gem based drivers I think ... Only tricky bit is making sure vmwgfx keeps working correctly. -Daniel > > cheers, > Gerd > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch