From: Arunpravin Paneer Selvam <arunpravin.paneerselvam@amd.com>
To: Matthew Auld <matthew.auld@intel.com>,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org
Cc: christian.koenig@amd.com, alexander.deucher@amd.com,
mario.limonciello@amd.com
Subject: Re: [PATCH] drm/buddy: Fix alloc_range() error handling code
Date: Fri, 9 Feb 2024 18:28:36 +0530 [thread overview]
Message-ID: <e72b0b7c-b446-e306-d01e-2d9e1ca5eaad@amd.com> (raw)
In-Reply-To: <5c6fdae4-6fb0-4735-afe6-fe35481929fb@intel.com>
On 2/8/2024 7:47 PM, Matthew Auld wrote:
> On 08/02/2024 13:47, Arunpravin Paneer Selvam wrote:
>> Hi Matthew,
>>
>> On 2/8/2024 7:00 PM, Matthew Auld wrote:
>>> On 07/02/2024 17:44, Arunpravin Paneer Selvam wrote:
>>>> Few users have observed display corruption when they boot
>>>> the machine to KDE Plasma or playing games. We have root
>>>> caused the problem that whenever alloc_range() couldn't
>>>> find the required memory blocks the function was returning
>>>> SUCCESS in some of the corner cases.
>>>
>>> Can you please give an example here?
>>>
>> In the try hard contiguous allocation, for example the requested
>> memory is 1024 pages,
>> it might go and pick the highest and last block (of size 512 pages)
>> in the freelist where
>> there are no more space exist in the total address range. In this
>> kind of corner case,
>> alloc_range was returning success though the allocated size is less
>> than the requested size.
>> Hence in try_hard_contiguous_allocation, we will not proceed to the
>> LHS allocation and
>> we return only with the RHS allocation having only the 512 pages of
>> allocation. This
>> leads to display corruption in many use cases (I think mainly when
>> requested for contiguous huge buffer)
>> mainly on APU platforms.
>
> Ok, I guess other thing is doing:
>
> lhs_offset = drm_buddy_block_offset(block) - lhs_size;
>
> I presume it's possible for block_offset < lhs_size here, which might
> be funny?
yes, seems it is possible, I will modify the lhs_offset calculation and
send the patch for review.
Thanks,
Arun.
>
>>
>> Thanks,
>> Arun.
>>>>
>>>> The right approach would be if the total allocated size
>>>> is less than the required size, the function should
>>>> return -ENOSPC.
>>>>
>>>> Gitlab ticket link -
>>>> https://gitlab.freedesktop.org/drm/amd/-/issues/3097
>>>> Fixes: 0a1844bf0b53 ("drm/buddy: Improve contiguous memory
>>>> allocation")
>>>> Signed-off-by: Arunpravin Paneer Selvam
>>>> <Arunpravin.PaneerSelvam@amd.com>
>>>> Tested-by: Mario Limonciello <mario.limonciello@amd.com>
>>>> ---
>>>> drivers/gpu/drm/drm_buddy.c | 6 ++++++
>>>> 1 file changed, 6 insertions(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
>>>> index f57e6d74fb0e..c1a99bf4dffd 100644
>>>> --- a/drivers/gpu/drm/drm_buddy.c
>>>> +++ b/drivers/gpu/drm/drm_buddy.c
>>>> @@ -539,6 +539,12 @@ static int __alloc_range(struct drm_buddy *mm,
>>>> } while (1);
>>>> list_splice_tail(&allocated, blocks);
>>>> +
>>>> + if (total_allocated < size) {
>>>> + err = -ENOSPC;
>>>> + goto err_free;
>>>> + }
>>>> +
>>>> return 0;
>>>> err_undo:
>>
next prev parent reply other threads:[~2024-02-09 12:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-07 17:44 [PATCH] drm/buddy: Fix alloc_range() error handling code Arunpravin Paneer Selvam
2024-02-07 18:46 ` ✓ Fi.CI.BAT: success for " Patchwork
2024-02-07 21:09 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-02-08 6:57 ` [PATCH] " Christian König
2024-02-08 12:06 ` Arunpravin Paneer Selvam
2024-02-08 13:59 ` Mario Limonciello
2024-02-08 13:30 ` Matthew Auld
2024-02-08 13:47 ` Arunpravin Paneer Selvam
2024-02-08 14:17 ` Matthew Auld
2024-02-08 14:44 ` Matthew Auld
2024-02-09 12:58 ` Arunpravin Paneer Selvam [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-02-09 15:18 Arunpravin Paneer Selvam
2024-02-09 15:26 Arunpravin Paneer Selvam
2024-02-09 18:04 ` Daniel Vetter
2024-02-09 18:36 ` Arunpravin Paneer Selvam
2024-02-09 19:40 ` Daniel Vetter
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=e72b0b7c-b446-e306-d01e-2d9e1ca5eaad@amd.com \
--to=arunpravin.paneerselvam@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=mario.limonciello@amd.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox