mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: francisco_flynn <francisco_flynn@foxmail.com>
To: Felix Kuehling <felix.kuehling@amd.com>
Cc: alexander.deucher@amd.com, christian.koenig@amd.com,
	airlied@gmail.com, simona@ffwll.ch,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/amdkfd: register HMM dev memory to DMA-able range first
Date: Tue, 10 Jun 2025 08:45:07 +0800	[thread overview]
Message-ID: <tencent_1EB006F3EADC43F9710EC002C328BC474B09@qq.com> (raw)
In-Reply-To: <560baf50-1bc5-473c-9889-59f7d625ddd9@amd.com>

On 6/9/25 20:46, Felix Kuehling wrote:
> On 2025-06-09 5:36, francisco_flynn wrote:
>> HMM device memory is allocated at the top of
>> iomem_resource, when iomem_resource is larger than
>> GPU device's dma mask, after devm_memremap_pages,
>> max_pfn will also be update and exceed device's
>> dma mask, when there are multiple card on system
>> need to be init, ttm_device_init would be called
>> with use_dma32=true, and this is not necessary at
>> all. let's request dev memory region at DMA-able
>> range first.
> That doesn't make sense to me. The addresses allocated here are not DMA addresses. They cannot be accessed by the GPU via DMA. They are purely fictional addresses for the purposes of creating struct pages for device-private memory. There should be no need to limit them by the GPU's DMA mask.


yes, this address is used by CPU to access VRAM. The patch is intended 
to cope with a special case, after checking the latest kernel code, i 
found this problem has been solved by this commit,

https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=7170130e4c72ce0caa0cb42a1627c635cc262821

thanks for you reply.

Best regards,
flynn


> Regards,
>    Felix
>
>
>> Signed-off-by: francisco_flynn <francisco_flynn@foxmail.com>
>> ---
>>   drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
>> index 79251f22b702..3856b9fd2a70 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
>> @@ -1020,6 +1020,7 @@ int kgd2kfd_init_zone_device(struct amdgpu_device *adev)
>>   	struct amdgpu_kfd_dev *kfddev = &adev->kfd;
>>   	struct dev_pagemap *pgmap;
>>   	struct resource *res = NULL;
>> +	struct resource temp_res = iomem_resource;
>>   	unsigned long size;
>>   	void *r;
>>   
>> @@ -1042,7 +1043,10 @@ int kgd2kfd_init_zone_device(struct amdgpu_device *adev)
>>   		pgmap->range.end = adev->gmc.aper_base + adev->gmc.aper_size - 1;
>>   		pgmap->type = MEMORY_DEVICE_COHERENT;
>>   	} else {
>> -		res = devm_request_free_mem_region(adev->dev, &iomem_resource, size);
>> +		temp_res.end = dma_get_mask(adev->dev);
>> +		res = devm_request_free_mem_region(adev->dev, &temp_res, size);
>> +		if (IS_ERR(res))
>> +			res = devm_request_free_mem_region(adev->dev, &iomem_resource, size);
>>   		if (IS_ERR(res))
>>   			return PTR_ERR(res);
>>   		pgmap->range.start = res->start;


      reply	other threads:[~2025-06-10  0:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-09  9:36 francisco_flynn
2025-06-09 12:46 ` Felix Kuehling
2025-06-10  0:45   ` francisco_flynn [this message]

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=tencent_1EB006F3EADC43F9710EC002C328BC474B09@qq.com \
    --to=francisco_flynn@foxmail.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=felix.kuehling@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=simona@ffwll.ch \
    /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

all inboxes | Powered by JetHome®