All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Chew <achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: CUDA fixed VA allocations and sparse mappings
Date: Mon, 6 Jul 2015 17:42:49 -0700	[thread overview]
Message-ID: <20150707004249.GC27924@achew-linux64.nvidia.com> (raw)

Hello,

I am currently looking into ways to support fixed virtual address allocations
and sparse mappings in nouveau, as a step towards supporting CUDA.

CUDA requires that the GPU virtual address for a given buffer match the
CPU virtual address.  Therefore, when mapping a CUDA buffer, we have to have
a way of specifying a particular virtual address to map to (we would ask that
the CPU virtual address be used).  Currently, as I understand it, the allocator
implemented in nvkm/core/mm.c, used to provision virtual addresses, doesn't
allow for this (but it's very easy to modify the allocator slightly to allow
for this, which I have done locally in my experiments).

In addition, the CUDA use case typically involves allocating a big chunk of
address space ahead of time as a way to reserve that chunk for future CUDA
use.  It then maps individual buffers into that address space as needed.
Currently, the virtual address allocation is done during buffer mapping, so
in order to support these sparse mappings, it seems to me that the virtual
address allocation and buffer mapping need to be decoupled into separate
operations.

My current strawman proposal for supporting this is to introduce two new ioctls
DRM_IOCTL_NOUVEAU_AS_ALLOC and DRM_IOCTL_NOUVEAU_AS_FREE, that look roughly
like this:

#define NOUVEAU_AS_ALLOC_FLAGS_FIXED_OFFSET 0x1
struct drm_nouveau_as_alloc {
        uint64_t pages;     /* in, pages */
        uint32_t page_size; /* in, bytes */
        uint32_t flags;     /* in */
        uint64_t offset;    /* in/out, byte address */
};

struct drm_nouveau_as_free {
        uint64_t offset;    /* in, byte address */
};

These ioctls just call into the allocator to allocate a range of addresses,
resulting in a struct nvkm_vma that tracks that allocation (or releases the
struct nvkm_vma back into the virtual address pool in the case of the free
ioctl).  If NOUVEAU_AS_ALLOC_FLAGS_FIXED_OFFSET is set, offset specifies the
requested virtual address.  Otherwise, an arbitrary address will be
allocated.

In addition to this, a way to map/unmap buffers is needed.  Ordinarily, one
would just use DRM_IOCTL_PRIME_FD_TO_HANDLE to import and map a dmabuf into
gem.  However, this ioctl will try to grab the virtual address range for this
buffer, which will fail in the CUDA case since the virtual address range
has been reserved ahead of time.  So we perhaps introduce a set of ioctls
to map/unmap buffers on top of an already existing virtual address allocation.

Please, feedback and questions are very much appreciated.
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

             reply	other threads:[~2015-07-07  0:42 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07  0:42 Andrew Chew [this message]
2015-07-07 15:29 ` [Nouveau] CUDA fixed VA allocations and sparse mappings Ilia Mirkin
     [not found]   ` <CAKb7UviePF2XcmyeKHQ2cv=hy=NZyYcMrWiTpajJxTFE+10LwQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-07 17:27     ` Jerome Glisse
2015-07-09  9:26       ` [Nouveau] " Oded Gabbay
     [not found]         ` <CAFCwf11pEc7vq0aPxdCRypzcbuaJRgWb_55q4ZUQPAvw5zXzHg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-10  0:31           ` Andrew Chew
2015-07-07 18:47     ` Andrew Chew
     [not found] ` <20150707004249.GC27924-hKyou4+EtHjTuHN6Nbh//0n48jw8i0AO@public.gmane.org>
2015-07-07 21:09   ` Ben Skeggs
     [not found]     ` <CACAvsv6=OwXnabpY5c_HHaMkumV-QqCvPd+zia15S_G+Oq29UA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-07 23:53       ` C Bergström
     [not found]         ` <CAOnawYpbqZ04-h2q4JpWjWfygPk5UQX9JWC4oj0RWNn7rzhcBA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-07 23:58           ` Ben Skeggs
     [not found]             ` <CACAvsv5ZrSLzb=N5kLpZP5fwbF+=S414O_QDgsNbi9FvvqxxLA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-08  0:07               ` C Bergström
     [not found]                 ` <CAOnawYphTmUDxkKrEhUsVR6YRyLQj0P4hwgOkw2Jf4b0BZOSnw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-08  0:08                   ` Ilia Mirkin
     [not found]                     ` <CAKb7UviOx-rNJUkwYB4h8XyQ4x8qp3xAbeHOAeW++O+bHFuyKQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-08  0:11                       ` C Bergström
     [not found]                         ` <CAOnawYo=EFk6KhmudKWi3r-z_J4AHjswTrZSfyp_qZfdmQc=tw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-08  0:13                           ` Ilia Mirkin
     [not found]                             ` <CAKb7UvhOM+65x80HPAcdTsQB4KsPA780cKg8_30vOy5qWFZt4w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-08  0:15                               ` Andrew Chew
     [not found]                                 ` <20150708001559.GA30347-hKyou4+EtHjTuHN6Nbh//0n48jw8i0AO@public.gmane.org>
2015-07-08  0:18                                   ` Ben Skeggs
     [not found]                                     ` <CACAvsv5q5yJUmjPgJtxnv1dU--UzD1veePkJzvqjRyNtx=EEbw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-08  0:31                                       ` Andrew Chew
     [not found]                                         ` <20150708003153.GA30426-hKyou4+EtHjTuHN6Nbh//0n48jw8i0AO@public.gmane.org>
2015-07-08  0:37                                           ` Ben Skeggs
     [not found]                                             ` <CACAvsv5DtA2WsBQkNWnxZMsonbHsvJ-oKA+frVd-btZXfgiAyw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-08  0:47                                               ` Andrew Chew
     [not found]                                                 ` <20150708004735.GA30570-hKyou4+EtHjTuHN6Nbh//0n48jw8i0AO@public.gmane.org>
2015-07-08  0:51                                                   ` Ben Skeggs
     [not found]                                                     ` <CACAvsv56doVLnMJKCfQyrPj-ijsW7yuAMv53kR0OKxJ0LKM5iQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-08 19:40                                                       ` Jerome Glisse
     [not found]                                                         ` <20150708194004.GA8122-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-07-08 21:18                                                           ` Andrew Chew
     [not found]                                                             ` <20150708211801.GA27080-hKyou4+EtHjTuHN6Nbh//0n48jw8i0AO@public.gmane.org>
2015-07-13 18:45                                                               ` Andrew Chew
2015-07-16  6:34                                                                 ` [Nouveau] " Alexandre Courbot
2015-07-08 18:27                                       ` Ken Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150707004249.GC27924@achew-linux64.nvidia.com \
    --to=achew-ddmlm1+adcrqt0dzr+alfa@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.