mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Koenig, Christian" <Christian.Koenig@amd.com>
To: Brian Yip <itsbriany@gmail.com>
Cc: "Huang, Ray" <Ray.Huang@amd.com>,
	"Zhang, Jerry" <Jerry.Zhang@amd.com>,
	"airlied@linux.ie" <airlied@linux.ie>,
	"daniel@ffwll.ch" <daniel@ffwll.ch>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] drm/ttm: Reset num_zones on ttm_mem_global cleanup
Date: Mon, 15 Apr 2019 06:25:44 +0000	[thread overview]
Message-ID: <0de8d12a-06b8-c4f7-e22e-77a00905ae5f@amd.com> (raw)
In-Reply-To: <20190414233729.17956-2-itsbriany@gmail.com>

Am 15.04.19 um 01:37 schrieb Brian Yip:
> num_zones in the ttm_mem_global structure was never reset after calling
> ttm_mem_global_release(). Consequently, when multiple GPU drivers
> are loaded, and the first one fails to load its firmware, the second
> driver will attempt to load its own firmware. Initializing the
> second driver invokes ttm_mem_global_init where ttm_mem_global.num_zones
> is eventually incremented beyond TTM_MEM_MAX_ZONES.
> ttm_mem_global.num_zones is then used to dereference a ttm_mem_zone beyond
> the amount of ttm_mem_zones allocated, resulting in a crash.
>
> Signed-off-by: Brian Yip <itsbriany@gmail.com>
> ---
>   drivers/gpu/drm/ttm/ttm_memory.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
> index 699fed9e08ee..55ccb9800893 100644
> --- a/drivers/gpu/drm/ttm/ttm_memory.c
> +++ b/drivers/gpu/drm/ttm/ttm_memory.c
> @@ -478,6 +478,9 @@ void ttm_mem_global_release(struct ttm_mem_global *glob)
>   			}
>   	kobject_del(&glob->kobj);
>   	kobject_put(&glob->kobj);
> +
> +	if (!kref_read(&glob->kobj.kref))
> +		glob->num_zones = 0;

NAK. It's nice to see that somebody tries to take care of this problem, 
but this is certainly not the right fix.

Instead of all of this the problem is simply that the glob structure is 
not zero initialized in ttm_mem_global_init(), a simple memset should do 
the trick.

Regards,
Christian.

>   }
>   
>   static void ttm_check_swapping(struct ttm_mem_global *glob)


  reply	other threads:[~2019-04-15  6:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-14 23:37 [PATCH 0/3] drm/ttm: Cleanup state in global ttm structures Brian Yip
2019-04-14 23:37 ` [PATCH 1/3] drm/ttm: Reset num_zones on ttm_mem_global cleanup Brian Yip
2019-04-15  6:25   ` Koenig, Christian [this message]
2019-04-14 23:37 ` [PATCH 2/3] drm/ttm: Fix ttm_mem_glob.kobj state on cleanup Brian Yip
2019-04-14 23:37 ` [PATCH 3/3] drm/ttm: Fix ttm_bo_glob.kobj " Brian Yip

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=0de8d12a-06b8-c4f7-e22e-77a00905ae5f@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Jerry.Zhang@amd.com \
    --cc=Ray.Huang@amd.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=itsbriany@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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®