linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Yangyu Chen <cyy@cyyself.name>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Cc: Huang Rui <ray.huang@amd.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
	Jiuyang Liu <liu@jiuyang.me>, Yichuan Gao <i@gycis.me>
Subject: Re: [PATCH] drm/ttm: only use DMA32 if needed for dummy_read_page
Date: Tue, 16 Jan 2024 10:45:46 +0100	[thread overview]
Message-ID: <2b715134-9d63-4de1-94e5-37e180aeefd2@amd.com> (raw)
In-Reply-To: <tencent_0B319B215E8D487CC082C0DA5E8E46B86B08@qq.com>

Am 16.01.24 um 08:24 schrieb Yangyu Chen:
> Some platforms may not have any memory in ZONE_DMA32 and use IOMMU to allow
> 32-bit-DMA-only device to work. Forcing GFP_DMA32 on dummy_read_page will
> fail in such platforms. Only use DMA32 when it must to get the bug
> resolved.

Well that makes no sense.

If a platform doesn't have a ZONE_DMA32 then GFP_DMA32 is just ignored 
as far as I know.

This patch here won't work since the use_dma32 flag is a per device flag 
which can't be used for the global initialization.

Otherwise this can randomly fail depending on if a DMA32 device 
initializes first or after some device with larger addressing 
capabilities. This configuration is quite common on older motherboards 
with both integrated and dedicated graphics.

Regards,
Christian.

>
> Signed-off-by: Yangyu Chen <cyy@cyyself.name>
> ---
>   drivers/gpu/drm/ttm/ttm_device.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c
> index d48b39132b32..62f16fb72428 100644
> --- a/drivers/gpu/drm/ttm/ttm_device.c
> +++ b/drivers/gpu/drm/ttm/ttm_device.c
> @@ -63,7 +63,7 @@ static void ttm_global_release(void)
>   	mutex_unlock(&ttm_global_mutex);
>   }
>   
> -static int ttm_global_init(void)
> +static int ttm_global_init(bool use_dma32)
>   {
>   	struct ttm_global *glob = &ttm_glob;
>   	unsigned long num_pages, num_dma32;
> @@ -95,7 +95,8 @@ static int ttm_global_init(void)
>   	ttm_pool_mgr_init(num_pages);
>   	ttm_tt_mgr_init(num_pages, num_dma32);
>   
> -	glob->dummy_read_page = alloc_page(__GFP_ZERO | GFP_DMA32);
> +	glob->dummy_read_page = use_dma32 ? alloc_page(__GFP_ZERO | GFP_DMA32) :
> +					    alloc_page(__GFP_ZERO);
>   
>   	if (unlikely(glob->dummy_read_page == NULL)) {
>   		ret = -ENOMEM;
> @@ -200,7 +201,7 @@ int ttm_device_init(struct ttm_device *bdev, const struct ttm_device_funcs *func
>   	if (WARN_ON(vma_manager == NULL))
>   		return -EINVAL;
>   
> -	ret = ttm_global_init();
> +	ret = ttm_global_init(use_dma32);
>   	if (ret)
>   		return ret;
>   


  reply	other threads:[~2024-01-16  9:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16  7:24 [PATCH] drm/ttm: only use DMA32 if needed for dummy_read_page Yangyu Chen
2024-01-16  9:45 ` Christian König [this message]
2024-01-16 11:27   ` Yangyu Chen
2024-01-16 14:45     ` Christian König

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=2b715134-9d63-4de1-94e5-37e180aeefd2@amd.com \
    --to=christian.koenig@amd.com \
    --cc=airlied@gmail.com \
    --cc=cyy@cyyself.name \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=i@gycis.me \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liu@jiuyang.me \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=ray.huang@amd.com \
    --cc=tzimmermann@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).