From: Scott D Phillips <scott.d.phillips@intel.com>
To: Jordan Justen <jordan.l.justen@intel.com>,
IGT GPU Tools <igt-dev@lists.freedesktop.org>
Subject: Re: [igt-dev] [PATCH i-g-t 2/6] aubdump: Add bitmap to track gtt pages that have been mapped
Date: Wed, 21 Feb 2018 16:52:17 -0800 [thread overview]
Message-ID: <87a7w13kxq.fsf@intel.com> (raw)
In-Reply-To: <20180221231905.15580-2-jordan.l.justen@intel.com>
Jordan Justen <jordan.l.justen@intel.com> writes:
> This will allow us to map ranges as they are used, but prevents
> remapping already mapped regions.
>
> By mapping ranges as they are used, we can support pinned pages
> without having to map all pages of the first 32-bits.
>
> Cc: Scott D Phillips <scott.d.phillips@intel.com>
> Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
> ---
> tools/aubdump.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 74 insertions(+), 1 deletion(-)
>
> diff --git a/tools/aubdump.c b/tools/aubdump.c
> index 2e60e547..661509e3 100644
> --- a/tools/aubdump.c
> +++ b/tools/aubdump.c
> @@ -383,7 +383,7 @@ register_write_out(uint32_t addr, uint32_t value)
> }
>
> static void
> -gen8_map_range(uint64_t start, uint64_t end)
> +gen8_emit_pte_for_range(uint64_t start, uint64_t end)
> {
> uint64_t entry_addr;
> uint64_t page_num;
> @@ -411,6 +411,79 @@ gen8_map_range(uint64_t start, uint64_t end)
> } while (entry_addr < end);
> }
>
> +static uint32_t*
> +get_mapped_bitmap()
> +{
> + static uint32_t *bitmap = NULL;
> + if (bitmap == NULL)
> + bitmap = calloc(0x100000000 / 0x1000 / 32, sizeof(*bitmap));
> + return bitmap;
> +}
> +
> +static void
> +set_mapped(uint64_t start, uint64_t end)
> +{
> + uint64_t addr;
> + uint32_t *bitmap = get_mapped_bitmap();
> + if (bitmap == NULL)
> + return;
> +
> + addr = start & ~(4096 - 1);
> + while (addr < end) {
> + const uint32_t bit = 1 << ((addr >> 12) & 0x1f);
> + if (bit == 1 && (end - addr) > 32 * 4096) {
> + bitmap[addr >> 17] = 0xffffffff;
> + addr += 32 * 4096;
> + } else {
> + bitmap[addr >> 17] |= bit;
> + addr += 4096;
> + }
> + }
> +}
> +
> +static void
> +gen8_map_range(uint64_t start, uint64_t end)
> +{
> + uint64_t addr1, addr2;
> + uint32_t *bitmap = get_mapped_bitmap();
> + if (bitmap == NULL)
> + return;
> +
> + addr1 = addr2 = start & ~(4096 - 1);
> + while (addr2 < end) {
> + while (addr1 < end) {
> + const uint32_t dw = bitmap[addr1 >> 17];
> + const uint32_t bit = 1 << ((addr1 >> 12) & 0x1f);
> + if ((dw & bit) == 0)
> + break;
> + else if (bit == 1 && dw == 0xffffffff)
> + addr1 += 32 * 4096;
> + else
> + addr1 += 4096;
> + }
> + if (addr1 >= end)
> + break;
> +
> + addr2 = addr1;
> + while (addr2 < end) {
> + const uint32_t dw = bitmap[addr2 >> 17];
> + const uint32_t bit = 1 << ((addr2 >> 12) & 0x1f);
> + if ((dw & bit) != 0)
> + break;
> + else if (bit == 1 && dw == 0)
> + addr2 += 32 * 4096;
> + else
> + addr2 += 4096;
> + }
> + if (addr2 > end)
> + addr2 = (end + 4096 - 1) & ~(4096 - 1);
you could use ALIGN() here too. I wouldn't say no to a macro for the
searches above if you want and it doesn't get too ugly.
Reviewed-by: Scott D Phillips <scott.d.phillips@intel.com>
> + gen8_emit_pte_for_range(addr1, addr2);
> + set_mapped(addr1, addr2);
> + addr1 = addr2;
> + }
> +}
> +
> static void
> gen10_write_header(void)
> {
> --
> 2.16.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2018-02-22 0:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-21 23:19 [igt-dev] [PATCH i-g-t 1/6] aubdump: Add gen8_map_range Jordan Justen
2018-02-21 23:19 ` [igt-dev] [PATCH i-g-t 2/6] aubdump: Add bitmap to track gtt pages that have been mapped Jordan Justen
2018-02-22 0:52 ` Scott D Phillips [this message]
2018-02-21 23:19 ` [igt-dev] [PATCH i-g-t 3/6] aubdump: For gen10+ support addresses up to 4GB Jordan Justen
2018-02-22 0:58 ` Scott D Phillips
2018-02-22 1:49 ` Jordan Justen
2018-02-21 23:19 ` [igt-dev] [PATCH i-g-t 4/6] aubdump: Support alignment of BO in execbuffer2 Jordan Justen
2018-02-21 23:19 ` [igt-dev] [PATCH i-g-t 5/6] aubdump: Note pinned BO in verbose output Jordan Justen
2018-02-21 23:19 ` [igt-dev] [PATCH i-g-t 6/6] aubdump: Signal drm sync objects when device override is used Jordan Justen
2018-02-22 1:03 ` Scott D Phillips
2018-02-22 1:06 ` Jason Ekstrand
2018-02-22 0:34 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/6] aubdump: Add gen8_map_range Patchwork
2018-02-22 0:43 ` [igt-dev] [PATCH i-g-t 1/6] " Scott D Phillips
2018-02-22 5:24 ` [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,1/6] " Patchwork
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=87a7w13kxq.fsf@intel.com \
--to=scott.d.phillips@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jordan.l.justen@intel.com \
/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.