[RFC libdrm] Add NVIDIA Tegra support

Thierry Reding thierry.reding at avionic-design.de
Tue Dec 4 07:38:41 PST 2012


On Tue, Dec 04, 2012 at 09:28:25AM -0600, Rob Clark wrote:
> On Tue, Dec 4, 2012 at 9:13 AM, Thierry Reding
> <thierry.reding at avionic-design.de> wrote:
> > +int drm_tegra_bo_new(struct drm_tegra *device, uint32_t flags, uint32_t size,
> > +                    struct drm_tegra_bo **bop)
> > +{
> > +       struct drm_tegra_gem_create args;
> > +       struct drm_tegra_bo *bo;
> > +       struct tegra_bo *priv;
> > +       int err;
> > +
> > +       if (!device || size == 0 || !bop)
> > +               return -EINVAL;
> > +
> > +       bo = calloc(1, sizeof(*bo));
> > +       if (!bo)
> > +               return -ENOMEM;
> > +
> > +       priv = tegra_bo(bo);
> > +
> > +       DRMLISTINITHEAD(&priv->list);
> > +       atomic_set(&priv->ref, 1);
> > +       bo->device = device;
> > +       bo->flags = flags;
> > +       bo->size = size;
> > +
> > +       memset(&args, 0, sizeof(args));
> > +       args.flags = flags;
> > +       args.size = size;
> > +
> > +       err = drmCommandWriteRead(device->fd, DRM_TEGRA_GEM_CREATE, &args,
> > +                                 sizeof(args));
> > +       if (err < 0) {
> > +               err = -errno;
> > +               free(bo);
> > +               return err;
> > +       }
> > +
> > +       DRMLISTADD(&priv->list, &device->bo_list);
> > +       bo->handle = args.handle;
> > +       bo->offset = args.offset;
> 
> btw, x11 can rapidly create/destroy temporary pixmaps.. which don't
> necessarily need userspace access.  You might prefer to avoid creating
> mmap offset on GEM bo creation, and instead do this only if userspace
> needs to mmap the bo

Ah, so that's the reason for the MMAP IOCTL provided by other DRMs. Yes,
that might be better in the long run. For now I don't think it makes
much of a difference since the GEM objects are backed by CMA, and
therefore the offset will be created along with the GEM anyway.

With Terje's upcoming rework that handles all the allocations in host1x
this should become more important, especially when the mapping is done
through the Tegra30's IOMMU.

I'll rework that. Thanks for the quick reply.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/dri-devel/attachments/20121204/4e69453b/attachment-0001.pgp>


More information about the dri-devel mailing list