Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup nvmap flags #23

Merged
merged 2 commits into from Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/libhost1x/host1x-nvhost.c
Expand Up @@ -92,31 +92,31 @@ static struct host1x_bo *nvhost_bo_create(struct host1x *host1x,
switch (flags & ~HOST1X_BO_CREATE_DRM_FLAGS_MASK) {
case 1: /* framebuffer */
heap_mask = 1 << 0;
flags = 1 << 0;
flags = NVMAP_HANDLE_WRITE_COMBINE;
align = 0x100;
break;

case 2: /* command buffer */
heap_mask = 1 << 0;
flags = 0x0a000001;
flags = NVMAP_HANDLE_WRITE_COMBINE;
align = 0x20;
break;

case 3: /* scratch */
heap_mask = 1 << 30;
flags = 1 << 0;
flags = NVMAP_HANDLE_WRITE_COMBINE;
align = 0x20;
break;

case 4: /* attributes */
heap_mask = 1 << 30;
flags = 0x3d000001;
flags = NVMAP_HANDLE_WRITE_COMBINE;
align = 0x4;
break;

default:
heap_mask = 1 << 30;
flags = 0x3d000001;
flags = NVMAP_HANDLE_WRITE_COMBINE;
align = 0x4;
break;
}
Expand Down
11 changes: 11 additions & 0 deletions src/libhost1x/nvhost-nvmap.h
Expand Up @@ -46,6 +46,17 @@ nvmap_handle_get_offset(struct nvmap_handle *handle, void *ptr)
return (unsigned long)ptr - (unsigned long)handle->ptr;
}

#define NVMAP_HANDLE_UNREACHABLE (0x0ul << 0)
#define NVMAP_HANDLE_WRITE_COMBINE (0x1ul << 0)
#define NVMAP_HANDLE_INNER_CACHEABLE (0x2ul << 0)
#define NVMAP_HANDLE_CACHEABLE (0x3ul << 0)
#define NVMAP_HANDLE_CACHE_FLAG (0x3ul << 0)

#define NVMAP_HANDLE_SECURE (0x1ul << 2)
#define NVMAP_HANDLE_KIND_SPECIFIED (0x1ul << 3)
#define NVMAP_HANDLE_COMPR_SPECIFIED (0x1ul << 4)
#define NVMAP_HANDLE_ZEROED_PAGES (0x1ul << 5)

struct nvmap_handle *nvmap_handle_create(struct nvmap *nvmap, size_t size);
void nvmap_handle_free(struct nvmap *nvmap, struct nvmap_handle *handle);
int nvmap_handle_alloc(struct nvmap *nvmap, struct nvmap_handle *handle,
Expand Down
6 changes: 4 additions & 2 deletions tests/nvhost/gr2d.c
Expand Up @@ -140,7 +140,8 @@ struct nvhost_gr2d *nvhost_gr2d_open(struct nvmap *nvmap,
return NULL;
}

err = nvmap_handle_alloc(nvmap, gr2d->buffer, 1 << 0, 0x0a000001, 0x20);
err = nvmap_handle_alloc(nvmap, gr2d->buffer, 1 << 0,
NVMAP_HANDLE_WRITE_COMBINE, 0x20);
if (err < 0) {
nvmap_handle_free(nvmap, gr2d->buffer);
nvhost_client_exit(&gr2d->client);
Expand All @@ -164,7 +165,8 @@ struct nvhost_gr2d *nvhost_gr2d_open(struct nvmap *nvmap,
return NULL;
}

err = nvmap_handle_alloc(nvmap, gr2d->scratch, 1 << 30, 1 << 0, 0x20);
err = nvmap_handle_alloc(nvmap, gr2d->scratch, 1 << 30,
NVMAP_HANDLE_WRITE_COMBINE, 0x20);
if (err < 0) {
nvmap_handle_free(nvmap, gr2d->scratch);
nvmap_handle_free(nvmap, gr2d->buffer);
Expand Down
7 changes: 4 additions & 3 deletions tests/nvhost/gr3d.c
Expand Up @@ -798,7 +798,8 @@ struct nvhost_gr3d *nvhost_gr3d_open(struct nvmap *nvmap,
return NULL;
}

err = nvmap_handle_alloc(nvmap, gr3d->buffer, 1 << 0, 0x0a000001, 0x20);
err = nvmap_handle_alloc(nvmap, gr3d->buffer, 1 << 0,
NVMAP_HANDLE_WRITE_COMBINE, 0x20);
if (err < 0) {
nvmap_handle_free(nvmap, gr3d->buffer);
nvhost_client_exit(&gr3d->client);
Expand All @@ -822,8 +823,8 @@ struct nvhost_gr3d *nvhost_gr3d_open(struct nvmap *nvmap,
return NULL;
}

err = nvmap_handle_alloc(nvmap, gr3d->attributes, 1 << 30, 0x3d000001,
0x4);
err = nvmap_handle_alloc(nvmap, gr3d->attributes, 1 << 30,
NVMAP_HANDLE_WRITE_COMBINE, 0x4);
if (err < 0) {
nvmap_handle_free(nvmap, gr3d->attributes);
nvmap_handle_free(nvmap, gr3d->buffer);
Expand Down
3 changes: 2 additions & 1 deletion tests/nvhost/nvmap.c
Expand Up @@ -307,7 +307,8 @@ struct nvmap_framebuffer *nvmap_framebuffer_create(struct nvmap *nvmap,
return NULL;
}

err = nvmap_handle_alloc(nvmap, fb->handle, 1 << 0, 1 << 0, 0x100);
err = nvmap_handle_alloc(nvmap, fb->handle, 1 << 0,
NVMAP_HANDLE_WRITE_COMBINE, 0x100);
if (err < 0) {
free(fb);
return NULL;
Expand Down
11 changes: 11 additions & 0 deletions tests/nvhost/nvmap.h
Expand Up @@ -47,6 +47,17 @@ nvmap_handle_get_offset(struct nvmap_handle *handle, void *ptr)
return (unsigned long)ptr - (unsigned long)handle->ptr;
}

#define NVMAP_HANDLE_UNREACHABLE (0x0ul << 0)
#define NVMAP_HANDLE_WRITE_COMBINE (0x1ul << 0)
#define NVMAP_HANDLE_INNER_CACHEABLE (0x2ul << 0)
#define NVMAP_HANDLE_CACHEABLE (0x3ul << 0)
#define NVMAP_HANDLE_CACHE_FLAG (0x3ul << 0)

#define NVMAP_HANDLE_SECURE (0x1ul << 2)
#define NVMAP_HANDLE_KIND_SPECIFIED (0x1ul << 3)
#define NVMAP_HANDLE_COMPR_SPECIFIED (0x1ul << 4)
#define NVMAP_HANDLE_ZEROED_PAGES (0x1ul << 5)

struct nvmap_handle *nvmap_handle_create(struct nvmap *nvmap, size_t size);
void nvmap_handle_free(struct nvmap *nvmap, struct nvmap_handle *handle);
int nvmap_handle_alloc(struct nvmap *nvmap, struct nvmap_handle *handle,
Expand Down