Re: [Mesa-dev] [PATCH v5 1/2] intel/ppgtt: memory address alignment

2018-08-16 Thread Sergii Romantsov
And also thanks to you :).

On Thu, Aug 16, 2018 at 4:16 PM, Lionel Landwerlin <
lionel.g.landwer...@intel.com> wrote:

> Both patches pushed to master.
>
> Thanks!
>
> -
> Lionel
>
>
> On 15/08/18 16:03, Lionel Landwerlin wrote:
>
>> On 15/08/18 12:23, Sergii Romantsov wrote:
>>
>>> Kernel (for ppgtt) requires memory address to be
>>> aligned to page size (4096).
>>>
>>> -v2: added marking that also fixes initial commit 01058a552294.
>>> -v3: numbers replaced by PAGE_SIZE; buffer-object size is aligned
>>> instead of alignment of offsets (Chris Wilson).
>>> -v4: changes related to PAGE_SIZE moved to separate commit
>>> -v5: restored alignment to page-size for 0-size.
>>>
>>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106997
>>> Fixes: a363bb2cd0e2 (i965: Allocate VMA in userspace for full-PPGTT
>>> systems.)
>>> Fixes: 01058a552294 (i965: Add virtual memory allocator infrastructure
>>> to brw_bufmgr.)
>>> Signed-off-by: Sergii Romantsov 
>>>
>>
>> CI seems happy this time :
>>
>> Reviewed-by: Lionel Landwerlin 
>>
>> ---
>>>   src/mesa/drivers/dri/i965/brw_bufmgr.c | 7 +++
>>>   1 file changed, 3 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c
>>> b/src/mesa/drivers/dri/i965/brw_bufmgr.c
>>> index 09d45e3..19e2d14 100644
>>> --- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
>>> +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
>>> @@ -496,7 +496,6 @@ bo_alloc_internal(struct brw_bufmgr *bufmgr,
>>> uint32_t stride)
>>>   {
>>>  struct brw_bo *bo;
>>> -   unsigned int page_size = getpagesize();
>>>  int ret;
>>>  struct bo_cache_bucket *bucket;
>>>  bool alloc_from_cache;
>>> @@ -522,12 +521,12 @@ bo_alloc_internal(struct brw_bufmgr *bufmgr,
>>>   * allocation up.
>>>   */
>>>  if (bucket == NULL) {
>>> -  bo_size = size;
>>> -  if (bo_size < page_size)
>>> - bo_size = page_size;
>>> +  unsigned int page_size = getpagesize();
>>> +  bo_size = size == 0 ? page_size : ALIGN(size, page_size);
>>>  } else {
>>> bo_size = bucket->size;
>>>  }
>>> +   assert(bo_size);
>>>mtx_lock(&bufmgr->lock);
>>>  /* Get a buffer out of the cache if available */
>>>
>>
>>
>> ___
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
>
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>



-- 
Sergii Romantsov
GlobalLogic Inc.
www.globallogic.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v5 1/2] intel/ppgtt: memory address alignment

2018-08-16 Thread Lionel Landwerlin

Both patches pushed to master.

Thanks!

-
Lionel

On 15/08/18 16:03, Lionel Landwerlin wrote:

On 15/08/18 12:23, Sergii Romantsov wrote:

Kernel (for ppgtt) requires memory address to be
aligned to page size (4096).

-v2: added marking that also fixes initial commit 01058a552294.
-v3: numbers replaced by PAGE_SIZE; buffer-object size is aligned
instead of alignment of offsets (Chris Wilson).
-v4: changes related to PAGE_SIZE moved to separate commit
-v5: restored alignment to page-size for 0-size.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106997
Fixes: a363bb2cd0e2 (i965: Allocate VMA in userspace for full-PPGTT 
systems.)
Fixes: 01058a552294 (i965: Add virtual memory allocator 
infrastructure to brw_bufmgr.)

Signed-off-by: Sergii Romantsov 


CI seems happy this time :

Reviewed-by: Lionel Landwerlin 


---
  src/mesa/drivers/dri/i965/brw_bufmgr.c | 7 +++
  1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c 
b/src/mesa/drivers/dri/i965/brw_bufmgr.c

index 09d45e3..19e2d14 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -496,7 +496,6 @@ bo_alloc_internal(struct brw_bufmgr *bufmgr,
    uint32_t stride)
  {
 struct brw_bo *bo;
-   unsigned int page_size = getpagesize();
 int ret;
 struct bo_cache_bucket *bucket;
 bool alloc_from_cache;
@@ -522,12 +521,12 @@ bo_alloc_internal(struct brw_bufmgr *bufmgr,
  * allocation up.
  */
 if (bucket == NULL) {
-  bo_size = size;
-  if (bo_size < page_size)
- bo_size = page_size;
+  unsigned int page_size = getpagesize();
+  bo_size = size == 0 ? page_size : ALIGN(size, page_size);
 } else {
    bo_size = bucket->size;
 }
+   assert(bo_size);
   mtx_lock(&bufmgr->lock);
 /* Get a buffer out of the cache if available */



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v5 1/2] intel/ppgtt: memory address alignment

2018-08-15 Thread Lionel Landwerlin

On 15/08/18 12:23, Sergii Romantsov wrote:

Kernel (for ppgtt) requires memory address to be
aligned to page size (4096).

-v2: added marking that also fixes initial commit 01058a552294.
-v3: numbers replaced by PAGE_SIZE; buffer-object size is aligned
instead of alignment of offsets (Chris Wilson).
-v4: changes related to PAGE_SIZE moved to separate commit
-v5: restored alignment to page-size for 0-size.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106997
Fixes: a363bb2cd0e2 (i965: Allocate VMA in userspace for full-PPGTT systems.)
Fixes: 01058a552294 (i965: Add virtual memory allocator infrastructure to 
brw_bufmgr.)
Signed-off-by: Sergii Romantsov 


CI seems happy this time :

Reviewed-by: Lionel Landwerlin 


---
  src/mesa/drivers/dri/i965/brw_bufmgr.c | 7 +++
  1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c 
b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index 09d45e3..19e2d14 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -496,7 +496,6 @@ bo_alloc_internal(struct brw_bufmgr *bufmgr,
uint32_t stride)
  {
 struct brw_bo *bo;
-   unsigned int page_size = getpagesize();
 int ret;
 struct bo_cache_bucket *bucket;
 bool alloc_from_cache;
@@ -522,12 +521,12 @@ bo_alloc_internal(struct brw_bufmgr *bufmgr,
  * allocation up.
  */
 if (bucket == NULL) {
-  bo_size = size;
-  if (bo_size < page_size)
- bo_size = page_size;
+  unsigned int page_size = getpagesize();
+  bo_size = size == 0 ? page_size : ALIGN(size, page_size);
 } else {
bo_size = bucket->size;
 }
+   assert(bo_size);
  
 mtx_lock(&bufmgr->lock);

 /* Get a buffer out of the cache if available */



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v5 1/2] intel/ppgtt: memory address alignment

2018-08-15 Thread Lionel Landwerlin

On 15/08/18 12:23, Sergii Romantsov wrote:

Kernel (for ppgtt) requires memory address to be
aligned to page size (4096).

-v2: added marking that also fixes initial commit 01058a552294.
-v3: numbers replaced by PAGE_SIZE; buffer-object size is aligned
instead of alignment of offsets (Chris Wilson).
-v4: changes related to PAGE_SIZE moved to separate commit
-v5: restored alignment to page-size for 0-size.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106997
Fixes: a363bb2cd0e2 (i965: Allocate VMA in userspace for full-PPGTT systems.)
Fixes: 01058a552294 (i965: Add virtual memory allocator infrastructure to 
brw_bufmgr.)
Signed-off-by: Sergii Romantsov 
---
  src/mesa/drivers/dri/i965/brw_bufmgr.c | 7 +++
  1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c 
b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index 09d45e3..19e2d14 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -496,7 +496,6 @@ bo_alloc_internal(struct brw_bufmgr *bufmgr,
uint32_t stride)
  {
 struct brw_bo *bo;
-   unsigned int page_size = getpagesize();
 int ret;
 struct bo_cache_bucket *bucket;
 bool alloc_from_cache;
@@ -522,12 +521,12 @@ bo_alloc_internal(struct brw_bufmgr *bufmgr,
  * allocation up.
  */
 if (bucket == NULL) {
-  bo_size = size;
-  if (bo_size < page_size)
- bo_size = page_size;
+  unsigned int page_size = getpagesize();
+  bo_size = size == 0 ? page_size : ALIGN(size, page_size);


You could even have :

bo_size = MIN(page_size, ALIGN(size, page_size));

Let me run this through the CI.

Thanks,

-
Lionel


 } else {
bo_size = bucket->size;
 }
+   assert(bo_size);
  
 mtx_lock(&bufmgr->lock);

 /* Get a buffer out of the cache if available */



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev