[Mesa-dev] [PATCH v2 07/16] intel/tools/aubinator: aubinate ppgtt aubs

Rafael Antognolli rafael.antognolli at intel.com
Wed Jun 20 19:03:11 UTC 2018


On Wed, Jun 20, 2018 at 12:01:28PM -0700, Rafael Antognolli wrote:
> On Wed, Jun 20, 2018 at 11:03:32AM +0100, Lionel Landwerlin wrote:
> > On 20/06/18 01:00, Rafael Antognolli wrote:
> > > On Tue, Jun 19, 2018 at 02:45:22PM +0100, Lionel Landwerlin wrote:
> > > > From: Scott D Phillips <scott.d.phillips at intel.com>
> > > > 
> > > > v2: by Lionel
> > > >      Fix memfd_create compilation issue
> 
> I guess this memfd_create was supposed to be on patch 05, right?

Oops, I meant patch 06 :P

> 
> With this and the extra memfd_create() removed, this patch is
> 
> Reviewed-by: Rafael Antognolli <rafael.antognolli at intel.com>
> 
> > > >      Fix pml4 address stored on 32 instead of 64bits
> > > >      Return no buffer if first ppgtt page is not mapped
> > > > 
> > > > Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
> > > > ---
> > > >   src/intel/tools/aubinator.c | 76 ++++++++++++++++++++++++++++++++++++-
> > > >   1 file changed, 75 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
> > > > index 962546d360c..3368ac521bd 100644
> > > > --- a/src/intel/tools/aubinator.c
> > > > +++ b/src/intel/tools/aubinator.c
> > > > @@ -336,6 +336,68 @@ get_ggtt_batch_bo(void *user_data, uint64_t address)
> > > >      return bo;
> > > >   }
> > > > +
> > > > +static struct phys_mem *
> > > > +ppgtt_walk(uint64_t pml4, uint64_t address)
> > > > +{
> > > > +   uint64_t shift = 39;
> > > > +   uint64_t addr = pml4;
> > > > +   for (int level = 4; level > 0; level--) {
> > > > +      struct phys_mem *table = search_phys_mem(addr);
> > > > +      if (!table)
> > > > +         return NULL;
> > > > +      int index = (address >> shift) & 0x1ff;
> > > > +      uint64_t entry = ((uint64_t *)table->data)[index];
> > > > +      if (!(entry & 1))
> > > > +         return NULL;
> > > > +      addr = entry & ~0xfff;
> > > > +      shift -= 9;
> > > > +   }
> > > > +   return search_phys_mem(addr);
> > > > +}
> > > > +
> > > > +static bool
> > > > +ppgtt_mapped(uint64_t pml4, uint64_t address)
> > > > +{
> > > > +   return ppgtt_walk(pml4, address) != NULL;
> > > > +}
> > > > +
> > > > +static struct gen_batch_decode_bo
> > > > +get_ppgtt_batch_bo(void *user_data, uint64_t address)
> > > > +{
> > > > +   struct gen_batch_decode_bo bo = {0};
> > > > +   uint64_t pml4 = *(uint64_t *)user_data;
> > > > +
> > > > +   address &= ~0xfff;
> > > > +
> > > > +   if (!ppgtt_mapped(pml4, address))
> > > > +      return bo;
> > > > +
> > > > +   /* Map everything until the first gap since we don't know how much the
> > > > +    * decoder actually needs.
> > > > +    */
> > > > +   uint64_t end = address;
> > > > +   while (ppgtt_mapped(pml4, end))
> > > > +      end += 4096;
> > > > +
> > > > +   bo.addr = address;
> > > > +   bo.size = end - address;
> > > > +   bo.map = mmap(NULL, bo.size, PROT_READ, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
> > > > +   assert(bo.map != MAP_FAILED);
> > > > +
> > > > +   for (uint64_t page = address; page < end; page += 4096) {
> > > > +      struct phys_mem *phys_mem = ppgtt_walk(pml4, page);
> > > > +
> > > > +      void *res = mmap((uint8_t *)bo.map + (page - bo.addr), 4096, PROT_READ,
> > > > +                       MAP_SHARED | MAP_FIXED, mem_fd, phys_mem->fd_offset);
> > > > +      assert(res != MAP_FAILED);
> > > > +   }
> > > > +
> > > > +   add_gtt_bo_map(bo, true);
> > > > +
> > > > +   return bo;
> > > > +}
> > > > +
> > > >   #define GEN_ENGINE_RENDER 1
> > > >   #define GEN_ENGINE_BLITTER 2
> > > > @@ -377,6 +439,7 @@ handle_trace_block(uint32_t *p)
> > > >         }
> > > >         (void)engine; /* TODO */
> > > > +      batch_ctx.get_bo = get_ggtt_batch_bo;
> > > >         gen_print_batch(&batch_ctx, bo.map, bo.size, 0);
> > > >         clear_bo_maps();
> > > > @@ -402,7 +465,7 @@ aubinator_init(uint16_t aub_pci_id, const char *app_name)
> > > >      batch_flags |= GEN_BATCH_DECODE_FLOATS;
> > > >      gen_batch_decode_ctx_init(&batch_ctx, &devinfo, outfile, batch_flags,
> > > > -                             xml_path, get_ggtt_batch_bo, NULL, NULL);
> > > > +                             xml_path, NULL, NULL, NULL);
> > > >      batch_ctx.max_vbo_decoded_lines = max_vbo_lines;
> > > >      char *color = GREEN_HEADER, *reset_color = NORMAL;
> > > > @@ -542,12 +605,20 @@ handle_memtrace_reg_write(uint32_t *p)
> > > >      uint32_t ring_buffer_head = context[5];
> > > >      uint32_t ring_buffer_tail = context[7];
> > > >      uint32_t ring_buffer_start = context[9];
> > > > +   uint64_t pml4 = (uint64_t)context[49] << 32 | context[51];
> > > >      struct gen_batch_decode_bo ring_bo = get_ggtt_batch_bo(NULL,
> > > >                                                             ring_buffer_start);
> > > >      assert(ring_bo.size > 0);
> > > >      void *commands = (uint8_t *)ring_bo.map + (ring_bo.addr - ring_buffer_start);
> > > > +   if (context_descriptor & 0x100 /* ppgtt */) {
> > > > +      batch_ctx.get_bo = get_ppgtt_batch_bo;
> > > > +      batch_ctx.user_data = &pml4;
> > > > +   } else {
> > > > +      batch_ctx.get_bo = get_ggtt_batch_bo;
> > > > +   }
> > > > +
> > > >      (void)engine; /* TODO */
> > > >      gen_print_batch(&batch_ctx, commands, ring_buffer_tail - ring_buffer_head,
> > > >                      0);
> > > > @@ -849,6 +920,9 @@ int main(int argc, char *argv[])
> > > >      list_inithead(&maps);
> > > > +   mem_fd = memfd_create("phys memory", 0);
> > > > +
> > > > +
> > > It seems like this memfd_create() got duplicated here (it was added in
> > > the previous patch).
> > 
> > Oops... Dropped locally.
> > 
> > > 
> > > >      file = aub_file_open(input_file);
> > > >      while (aub_file_more_stuff(file) &&
> > > > -- 
> > > > 2.17.1
> > > > 
> > > _______________________________________________
> > > mesa-dev mailing list
> > > mesa-dev at lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> > 
> > 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list