AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Andrey Grodzovsky <andrey.grodzovsky@amd.com>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: alexdeucher@gmail.com, daniel.vetter@ffwll.ch, michel@daenzer.net
Subject: Re: [PATCH 3/6] drm/amdgpu: Wait for all user clients
Date: Mon, 11 May 2020 08:57:40 +0200	[thread overview]
Message-ID: <cb166673-d165-cb48-40a3-7f669c883a4b@gmail.com> (raw)
In-Reply-To: <1589050310-19666-4-git-send-email-andrey.grodzovsky@amd.com>

A commit message would be nice, apart from that the patch looks clean to me.

But question for Daniel and others: Is that in general the right approach?

It can happen that device removal is delayed indefinitely if userspace 
doesn't close the file descriptors.

Regards,
Christian.

Am 09.05.20 um 20:51 schrieb Andrey Grodzovsky:
> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 2 ++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 2 ++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 4 ++++
>   4 files changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index bc1e0fd..79274d5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -990,6 +990,8 @@ struct amdgpu_device {
>   	char				product_number[16];
>   	char				product_name[32];
>   	char				serial[16];
> +
> +	wait_queue_head_t		user_clients_done;
>   };
>   
>   static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev)
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 4da52b7..3bd67cf 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -3271,6 +3271,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
>   	if (r)
>   		dev_err(adev->dev, "amdgpu_pmu_init failed\n");
>   
> +
> +	init_waitqueue_head(&adev->user_clients_done);
> +
>   	return 0;
>   
>   failed:
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index ea2b47e..0531727 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -1141,10 +1141,12 @@ static void
>   amdgpu_pci_remove(struct pci_dev *pdev)
>   {
>   	struct drm_device *dev = pci_get_drvdata(pdev);
> +	struct amdgpu_device *adev = dev->dev_private;
>   
>   	drm_dev_unplug(dev);
>   
>   	amdgpu_force_unmap_user_space_mappings(dev);
> +	wait_event(adev->user_clients_done, (dev->open_count == 0));
>   
>   	amdgpu_driver_unload_kms(dev);
>   	pci_disable_device(pdev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 61fb2ef..d8fc775 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -957,8 +957,12 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
>    */
>   void amdgpu_driver_lastclose_kms(struct drm_device *dev)
>   {
> +	struct amdgpu_device *adev = dev->dev_private;
> +
>   	drm_fb_helper_lastclose(dev);
>   	vga_switcheroo_process_delayed_switch();
> +
> +	wake_up(&adev->user_clients_done);
>   }
>   
>   /**

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  reply	other threads:[~2020-05-11  6:57 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-09 18:51 [PATCH 0/6] RFC Support hot device unplug in amdgpu Andrey Grodzovsky
2020-05-09 18:51 ` [PATCH 1/6] drm/ttm: Add unampping of the entire device address space Andrey Grodzovsky
2020-05-11  6:45   ` Christian König
2020-06-05 14:29     ` Andrey Grodzovsky
2020-06-05 18:40       ` Christian König
2020-06-09 16:37         ` Andrey Grodzovsky
2020-05-09 18:51 ` [PATCH 2/6] drm/amdgpu: Force unmap all user VMAs on device removal Andrey Grodzovsky
2020-05-11  6:47   ` Christian König
2020-05-09 18:51 ` [PATCH 3/6] drm/amdgpu: Wait for all user clients Andrey Grodzovsky
2020-05-11  6:57   ` Christian König [this message]
2020-05-09 18:51 ` [PATCH 4/6] drm/amdgpu: Wait for all clients importing out dma-bufs Andrey Grodzovsky
2020-05-09 18:51 ` [PATCH 5/6] drm/ttm: Add destroy flag in TTM BO eviction interface Andrey Grodzovsky
2020-05-11  7:05   ` Christian König
2020-06-10 10:25   ` Thomas Hellström (Intel)
2020-06-10 13:56     ` Andrey Grodzovsky
2020-05-09 18:51 ` [PATCH 6/6] drm/amdgpu: Use TTM MMs destroy interface Andrey Grodzovsky
2020-05-11  9:26 ` [PATCH 0/6] RFC Support hot device unplug in amdgpu Pekka Paalanen
2020-05-11 12:29   ` Christian König
2020-05-11 16:37   ` Andrey Grodzovsky
2020-05-11  9:54 ` Daniel Vetter
2020-05-11 10:19   ` Chris Wilson
2020-05-11 11:03     ` Daniel Vetter
2020-05-11 11:19   ` Daniel Vetter
2020-05-11 12:34     ` Christian König
2020-05-11 12:43       ` Daniel Vetter
2020-05-11 11:43   ` Lukas Wunner
2020-05-11 12:21     ` Daniel Vetter
2020-05-11 14:08       ` Lukas Wunner
2020-05-11 14:14         ` Daniel Vetter
2020-05-13 14:32   ` Andrey Grodzovsky
2020-05-13 18:05     ` 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=cb166673-d165-cb48-40a3-7f669c883a4b@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=alexdeucher@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=andrey.grodzovsky@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=michel@daenzer.net \
    /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