All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: "Arunpravin Paneer Selvam" <arunpravin.paneerselvam@amd.com>,
	"Christian König" <ckoenig.leichtzumerken@gmail.com>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, matthew.auld@intel.com
Subject: Re: [Intel-gfx] [PATCH v2] drm: add a check to verify the size alignment
Date: Tue, 29 Mar 2022 13:25:59 +0200	[thread overview]
Message-ID: <a7afe4bb-307e-3c80-5722-8cf322252074@amd.com> (raw)
In-Reply-To: <66f75c1b-41e1-5f96-cad7-aeffb95ce712@amd.com>

Am 29.03.22 um 13:28 schrieb Arunpravin Paneer Selvam:
> On 23/03/22 1:15 pm, Christian König wrote:
>> Am 23.03.22 um 08:34 schrieb Arunpravin Paneer Selvam:
>>> Add a simple check to reject any size not aligned to the
>>> min_page_size.
>>>
>>> handle instances when size is not aligned with the min_page_size.
>>> Unigine Heaven has allocation requests for example required pages
>>> are 257 and alignment request is 256. To allocate the left over 1
>>> page, continues the iteration to find the order value which is 0
>>> and when it compares with min_order = 8, triggers the BUG_ON(order
>>> < min_order). To avoid this problem, we added a simple check to
>>> return -EINVAL if size is not aligned to the min_page_size.
>>>
>>> v2: Added more details to the commit description
>>>
>>> Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
>>> Suggested-by: Matthew Auld <matthew.auld@intel.com>
>>> ---
>>>    drivers/gpu/drm/drm_buddy.c | 3 +++
>>>    1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
>>> index 72f52f293249..b503c88786b0 100644
>>> --- a/drivers/gpu/drm/drm_buddy.c
>>> +++ b/drivers/gpu/drm/drm_buddy.c
>>> @@ -661,6 +661,9 @@ int drm_buddy_alloc_blocks(struct drm_buddy *mm,
>>>    	if (range_overflows(start, size, mm->size))
>>>    		return -EINVAL;
>>>    
>>> +	if (WARN_ON(!IS_ALIGNED(size, min_page_size)))
>>> +		return -EINVAL;
>>> +
>> I'm not that happy with the handling here.
>>
>> See a minimum page size larger than the requested size is perfectly
>> valid, it just means that the remaining pages needs to be trimmed.
>>
>> In other words when the request is to allocate 1 page with an alignment
>> of 256 we just need to give the remaining 255 pages back to the allocator.
> In one of the previous mail Matthew explained that i915 expects to
> return -EINVAL error code if size is not aligned to min_page_size.
>
> can we just modify in amdgpu code where we round_up the size to the
> min_page_size value and keep this error handling in drm_buddy.c?

Yeah, I'm fine with that as well now.

I realized that this is probably the easiest option to check if an 
allocation is contiguous or not between the alloc and trim.

So having two functions for that sounds like a good idea to me.

Thanks,
Christian.

>> Regards,
>> Christian.
>>
>>>    	/* Actual range allocation */
>>>    	if (start + size == end)
>>>    		return __drm_buddy_alloc_range(mm, start, size, blocks);
>>>
>>> base-commit: 056d47eaf6ea753fa2e21da31f9cbd8b721bbb7b


WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: "Arunpravin Paneer Selvam" <arunpravin.paneerselvam@amd.com>,
	"Christian König" <ckoenig.leichtzumerken@gmail.com>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, matthew.auld@intel.com
Subject: Re: [PATCH v2] drm: add a check to verify the size alignment
Date: Tue, 29 Mar 2022 13:25:59 +0200	[thread overview]
Message-ID: <a7afe4bb-307e-3c80-5722-8cf322252074@amd.com> (raw)
In-Reply-To: <66f75c1b-41e1-5f96-cad7-aeffb95ce712@amd.com>

Am 29.03.22 um 13:28 schrieb Arunpravin Paneer Selvam:
> On 23/03/22 1:15 pm, Christian König wrote:
>> Am 23.03.22 um 08:34 schrieb Arunpravin Paneer Selvam:
>>> Add a simple check to reject any size not aligned to the
>>> min_page_size.
>>>
>>> handle instances when size is not aligned with the min_page_size.
>>> Unigine Heaven has allocation requests for example required pages
>>> are 257 and alignment request is 256. To allocate the left over 1
>>> page, continues the iteration to find the order value which is 0
>>> and when it compares with min_order = 8, triggers the BUG_ON(order
>>> < min_order). To avoid this problem, we added a simple check to
>>> return -EINVAL if size is not aligned to the min_page_size.
>>>
>>> v2: Added more details to the commit description
>>>
>>> Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
>>> Suggested-by: Matthew Auld <matthew.auld@intel.com>
>>> ---
>>>    drivers/gpu/drm/drm_buddy.c | 3 +++
>>>    1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
>>> index 72f52f293249..b503c88786b0 100644
>>> --- a/drivers/gpu/drm/drm_buddy.c
>>> +++ b/drivers/gpu/drm/drm_buddy.c
>>> @@ -661,6 +661,9 @@ int drm_buddy_alloc_blocks(struct drm_buddy *mm,
>>>    	if (range_overflows(start, size, mm->size))
>>>    		return -EINVAL;
>>>    
>>> +	if (WARN_ON(!IS_ALIGNED(size, min_page_size)))
>>> +		return -EINVAL;
>>> +
>> I'm not that happy with the handling here.
>>
>> See a minimum page size larger than the requested size is perfectly
>> valid, it just means that the remaining pages needs to be trimmed.
>>
>> In other words when the request is to allocate 1 page with an alignment
>> of 256 we just need to give the remaining 255 pages back to the allocator.
> In one of the previous mail Matthew explained that i915 expects to
> return -EINVAL error code if size is not aligned to min_page_size.
>
> can we just modify in amdgpu code where we round_up the size to the
> min_page_size value and keep this error handling in drm_buddy.c?

Yeah, I'm fine with that as well now.

I realized that this is probably the easiest option to check if an 
allocation is contiguous or not between the alloc and trim.

So having two functions for that sounds like a good idea to me.

Thanks,
Christian.

>> Regards,
>> Christian.
>>
>>>    	/* Actual range allocation */
>>>    	if (start + size == end)
>>>    		return __drm_buddy_alloc_range(mm, start, size, blocks);
>>>
>>> base-commit: 056d47eaf6ea753fa2e21da31f9cbd8b721bbb7b


WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: "Arunpravin Paneer Selvam" <arunpravin.paneerselvam@amd.com>,
	"Christian König" <ckoenig.leichtzumerken@gmail.com>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, matthew.auld@intel.com, daniel@ffwll.ch
Subject: Re: [PATCH v2] drm: add a check to verify the size alignment
Date: Tue, 29 Mar 2022 13:25:59 +0200	[thread overview]
Message-ID: <a7afe4bb-307e-3c80-5722-8cf322252074@amd.com> (raw)
In-Reply-To: <66f75c1b-41e1-5f96-cad7-aeffb95ce712@amd.com>

Am 29.03.22 um 13:28 schrieb Arunpravin Paneer Selvam:
> On 23/03/22 1:15 pm, Christian König wrote:
>> Am 23.03.22 um 08:34 schrieb Arunpravin Paneer Selvam:
>>> Add a simple check to reject any size not aligned to the
>>> min_page_size.
>>>
>>> handle instances when size is not aligned with the min_page_size.
>>> Unigine Heaven has allocation requests for example required pages
>>> are 257 and alignment request is 256. To allocate the left over 1
>>> page, continues the iteration to find the order value which is 0
>>> and when it compares with min_order = 8, triggers the BUG_ON(order
>>> < min_order). To avoid this problem, we added a simple check to
>>> return -EINVAL if size is not aligned to the min_page_size.
>>>
>>> v2: Added more details to the commit description
>>>
>>> Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
>>> Suggested-by: Matthew Auld <matthew.auld@intel.com>
>>> ---
>>>    drivers/gpu/drm/drm_buddy.c | 3 +++
>>>    1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
>>> index 72f52f293249..b503c88786b0 100644
>>> --- a/drivers/gpu/drm/drm_buddy.c
>>> +++ b/drivers/gpu/drm/drm_buddy.c
>>> @@ -661,6 +661,9 @@ int drm_buddy_alloc_blocks(struct drm_buddy *mm,
>>>    	if (range_overflows(start, size, mm->size))
>>>    		return -EINVAL;
>>>    
>>> +	if (WARN_ON(!IS_ALIGNED(size, min_page_size)))
>>> +		return -EINVAL;
>>> +
>> I'm not that happy with the handling here.
>>
>> See a minimum page size larger than the requested size is perfectly
>> valid, it just means that the remaining pages needs to be trimmed.
>>
>> In other words when the request is to allocate 1 page with an alignment
>> of 256 we just need to give the remaining 255 pages back to the allocator.
> In one of the previous mail Matthew explained that i915 expects to
> return -EINVAL error code if size is not aligned to min_page_size.
>
> can we just modify in amdgpu code where we round_up the size to the
> min_page_size value and keep this error handling in drm_buddy.c?

Yeah, I'm fine with that as well now.

I realized that this is probably the easiest option to check if an 
allocation is contiguous or not between the alloc and trim.

So having two functions for that sounds like a good idea to me.

Thanks,
Christian.

>> Regards,
>> Christian.
>>
>>>    	/* Actual range allocation */
>>>    	if (start + size == end)
>>>    		return __drm_buddy_alloc_range(mm, start, size, blocks);
>>>
>>> base-commit: 056d47eaf6ea753fa2e21da31f9cbd8b721bbb7b


  parent reply	other threads:[~2022-03-29 11:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-23  7:34 [PATCH v2] drm: add a check to verify the size alignment Arunpravin Paneer Selvam
2022-03-23  7:34 ` Arunpravin Paneer Selvam
2022-03-23  7:34 ` [Intel-gfx] " Arunpravin Paneer Selvam
2022-03-23  7:45 ` Christian König
2022-03-23  7:45   ` [Intel-gfx] " Christian König
2022-03-23  7:45   ` Christian König
2022-03-29 11:28   ` Arunpravin Paneer Selvam
2022-03-29 11:28     ` Arunpravin Paneer Selvam
2022-03-29 11:28     ` [Intel-gfx] " Arunpravin Paneer Selvam
2022-03-29 11:24     ` Matthew Auld
2022-03-29 11:24       ` [Intel-gfx] " Matthew Auld
2022-03-30  9:17       ` Arunpravin Paneer Selvam
2022-03-30  9:17         ` [Intel-gfx] " Arunpravin Paneer Selvam
2022-03-29 11:25     ` Christian König [this message]
2022-03-29 11:25       ` Christian König
2022-03-29 11:25       ` Christian König
2022-03-23  9:33 ` [Intel-gfx] ✗ Fi.CI.DOCS: warning for drm: add a check to verify the size alignment (rev2) Patchwork
2022-03-23 10:04 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-03-23 11:39 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " 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=a7afe4bb-307e-3c80-5722-8cf322252074@amd.com \
    --to=christian.koenig@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=arunpravin.paneerselvam@amd.com \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.auld@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.