From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Philip Yang <Philip.Yang@amd.com>, amd-gfx@lists.freedesktop.org
Cc: Felix.Kuehling@amd.com, christian.koenig@amd.com,
Arunpravin.PaneerSelvam@amd.com
Subject: Re: [PATCH v5 2/6] drm/amdgpu: Handle sg size limit for contiguous allocation
Date: Wed, 24 Apr 2024 08:14:48 +0200 [thread overview]
Message-ID: <ee919dfb-ca12-4dfe-8b87-435cd7c12a12@gmail.com> (raw)
In-Reply-To: <20240423152900.533-3-Philip.Yang@amd.com>
Am 23.04.24 um 17:28 schrieb Philip Yang:
> Define macro MAX_SG_SEGMENT_SIZE 2GB, because struct scatterlist length
> is unsigned int, and some users of it cast to a signed int, so every
> segment of sg table is limited to size 2GB maximum.
>
> For contiguous VRAM allocation, don't limit the max buddy block size in
> order to get contiguous VRAM memory. To workaround the sg table segment
> size limit, allocate multiple segments if contiguous size is bigger than
> MAX_SG_SEGMENT_SIZE.
>
> Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index 4be8b091099a..ebffb58ea53a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -31,6 +31,8 @@
> #include "amdgpu_atomfirmware.h"
> #include "atom.h"
>
> +#define AMDGPU_MAX_SG_SEGMENT_SIZE (2UL << 30)
> +
> struct amdgpu_vram_reservation {
> u64 start;
> u64 size;
> @@ -532,9 +534,7 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
>
> BUG_ON(min_block_size < mm->chunk_size);
>
> - /* Limit maximum size to 2GiB due to SG table limitations */
> - size = min(remaining_size, 2ULL << 30);
> -
> + size = remaining_size;
> if ((size >= (u64)pages_per_block << PAGE_SHIFT) &&
> !(size & (((u64)pages_per_block << PAGE_SHIFT) - 1)))
> min_block_size = (u64)pages_per_block << PAGE_SHIFT;
> @@ -675,7 +675,7 @@ int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
> amdgpu_res_first(res, offset, length, &cursor);
> while (cursor.remaining) {
> num_entries++;
> - amdgpu_res_next(&cursor, cursor.size);
> + amdgpu_res_next(&cursor, min(cursor.size, AMDGPU_MAX_SG_SEGMENT_SIZE));
> }
>
> r = sg_alloc_table(*sgt, num_entries, GFP_KERNEL);
> @@ -695,7 +695,7 @@ int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
> amdgpu_res_first(res, offset, length, &cursor);
> for_each_sgtable_sg((*sgt), sg, i) {
> phys_addr_t phys = cursor.start + adev->gmc.aper_base;
> - size_t size = cursor.size;
> + unsigned long size = min(cursor.size, AMDGPU_MAX_SG_SEGMENT_SIZE);
> dma_addr_t addr;
>
> addr = dma_map_resource(dev, phys, size, dir,
> @@ -708,7 +708,7 @@ int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
> sg_dma_address(sg) = addr;
> sg_dma_len(sg) = size;
>
> - amdgpu_res_next(&cursor, cursor.size);
> + amdgpu_res_next(&cursor, size);
> }
>
> return 0;
next prev parent reply other threads:[~2024-04-24 6:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-23 15:28 [PATCH v5 0/6] Best effort contiguous VRAM allocation Philip Yang
2024-04-23 15:28 ` [PATCH v5 1/6] drm/amdgpu: Support " Philip Yang
2024-04-23 22:17 ` Felix Kuehling
2024-04-24 13:58 ` Philip Yang
2024-04-23 15:28 ` [PATCH v5 2/6] drm/amdgpu: Handle sg size limit for contiguous allocation Philip Yang
2024-04-24 6:14 ` Christian König [this message]
2024-04-23 15:28 ` [PATCH v5 3/6] drm/amdgpu: Evict BOs from same process " Philip Yang
2024-04-23 22:16 ` Felix Kuehling
2024-04-23 15:28 ` [PATCH v5 4/6] drm/amdkfd: Evict BO itself " Philip Yang
2024-04-23 22:15 ` Felix Kuehling
2024-04-24 13:41 ` Philip Yang
2024-04-23 15:28 ` [PATCH v5 5/6] drm/amdkfd: Increase KFD bo restore wait time Philip Yang
2024-04-23 22:06 ` Felix Kuehling
2024-04-23 15:29 ` [PATCH v5 6/6] drm/amdkfd: Bump kfd version for contiguous VRAM allocation Philip Yang
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=ee919dfb-ca12-4dfe-8b87-435cd7c12a12@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=Arunpravin.PaneerSelvam@amd.com \
--cc=Felix.Kuehling@amd.com \
--cc=Philip.Yang@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.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.