[Mesa-dev] [PATCH 3/6] nvc0: add nvc0_screen_resize_text_area() helper
Samuel Pitoiset
samuel.pitoiset at gmail.com
Wed Aug 31 21:32:42 UTC 2016
On 08/31/2016 11:31 PM, Ilia Mirkin wrote:
> On Wed, Aug 31, 2016 at 4:52 PM, Samuel Pitoiset
> <samuel.pitoiset at gmail.com> wrote:
>> This function will be helpful for resizing the code segment
>> area when we need to evict all shaders.
>>
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>> ---
>> src/gallium/drivers/nouveau/nvc0/nvc0_context.h | 1 +
>> src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 47 +++++++++++++++++++------
>> src/gallium/drivers/nouveau/nvc0/nvc0_screen.h | 2 ++
>> 3 files changed, 40 insertions(+), 10 deletions(-)
>>
>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
>> index ae65f8a..6499f3e 100644
>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
>> @@ -27,6 +27,7 @@
>> #include "nv50/nv50_2d.xml.h"
>> #include "nvc0/nvc0_m2mf.xml.h"
>> #include "nvc0/nve4_p2mf.xml.h"
>> +#include "nvc0/nvc0_compute.xml.h"
>> #include "nvc0/nvc0_macros.h"
>>
>> /* NOTE: must keep NVC0_NEW_3D_...PROG in consecutive bits in this order */
>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> index a4f1605..6c6d177 100644
>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> @@ -701,6 +701,42 @@ nvc0_screen_resize_tls_area(struct nvc0_screen *screen,
>> return 0;
>> }
>>
>> +int
>> +nvc0_screen_resize_text_area(struct nvc0_screen *screen, uint64_t size)
>> +{
>> + struct nouveau_pushbuf *push = screen->base.pushbuf;
>> + struct nouveau_bo *bo;
>> + int ret;
>> +
>> + ret = nouveau_bo_new(screen->base.device, NV_VRAM_DOMAIN(&screen->base),
>> + 1 << 17, size, NULL, &bo);
>> + if (ret)
>> + return ret;
>> +
>> + nouveau_bo_ref(NULL, &screen->text);
>> + screen->text = bo;
>> +
>> + nouveau_heap_destroy(&screen->lib_code);
>> + nouveau_heap_destroy(&screen->text_heap);
>> +
>> + /* XXX: getting a page fault at the end of the code buffer every few
>> + * launches, don't use the last 256 bytes to work around them - prefetch ?
>> + */
>> + nouveau_heap_init(&screen->text_heap, 0, size - 0x100);
>> +
>> + /* update the code segment setup */
>> + BEGIN_NVC0(push, NVC0_3D(CODE_ADDRESS_HIGH), 2);
>> + PUSH_DATAh(push, screen->text->offset);
>> + PUSH_DATA (push, screen->text->offset);
>> + if (screen->compute) {
>> + BEGIN_NVC0(push, NVC0_CP(CODE_ADDRESS_HIGH), 2);
>
> Did you mean to remove something from nvc0_compute.c/nve4_compute.c?
No, I can't because at this point compute has not been initialized yet.
>
>> + PUSH_DATAh(push, screen->text->offset);
>> + PUSH_DATA (push, screen->text->offset);
>> + }
>> +
>> + return 0;
>> +}
>> +
>> #define FAIL_SCREEN_INIT(str, err) \
>> do { \
>> NOUVEAU_ERR(str, err); \
>> @@ -951,16 +987,10 @@ nvc0_screen_create(struct nouveau_device *dev)
>>
>> nvc0_magic_3d_init(push, screen->eng3d->oclass);
>>
>> - ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 17, 1 << 20, NULL,
>> - &screen->text);
>> + ret = nvc0_screen_resize_text_area(screen, 1 << 20);
>> if (ret)
>> FAIL_SCREEN_INIT("Error allocating TEXT area: %d\n", ret);
>>
>> - /* XXX: getting a page fault at the end of the code buffer every few
>> - * launches, don't use the last 256 bytes to work around them - prefetch ?
>> - */
>> - nouveau_heap_init(&screen->text_heap, 0, (1 << 20) - 0x100);
>> -
>> ret = nouveau_bo_new(dev, NV_VRAM_DOMAIN(&screen->base), 1 << 12, 7 << 16, NULL,
>> &screen->uniform_bo);
>> if (ret)
>> @@ -1044,9 +1074,6 @@ nvc0_screen_create(struct nouveau_device *dev)
>> if (ret)
>> FAIL_SCREEN_INIT("Error allocating TLS area: %d\n", ret);
>>
>> - BEGIN_NVC0(push, NVC0_3D(CODE_ADDRESS_HIGH), 2);
>> - PUSH_DATAh(push, screen->text->offset);
>> - PUSH_DATA (push, screen->text->offset);
>> BEGIN_NVC0(push, NVC0_3D(TEMP_ADDRESS_HIGH), 4);
>> PUSH_DATAh(push, screen->tls->offset);
>> PUSH_DATA (push, screen->tls->offset);
>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
>> index 672d515..aff0308 100644
>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
>> @@ -136,6 +136,8 @@ int nvc0_screen_tsc_alloc(struct nvc0_screen *, void *);
>> int nve4_screen_compute_setup(struct nvc0_screen *, struct nouveau_pushbuf *);
>> int nvc0_screen_compute_setup(struct nvc0_screen *, struct nouveau_pushbuf *);
>>
>> +int nvc0_screen_resize_text_area(struct nvc0_screen *, uint64_t);
>> +
>> static inline void
>> nvc0_resource_fence(struct nv04_resource *res, uint32_t flags)
>> {
>> --
>> 2.9.3
>>
>> _______________________________________________
>> 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