* [PATCH v2 1/1] drm/amdkfd: Create file descriptor after client is added to smi_clients list
@ 2022-04-01 10:44 Lee Jones
2022-04-01 10:48 ` Lee Jones
0 siblings, 1 reply; 5+ messages in thread
From: Lee Jones @ 2022-04-01 10:44 UTC (permalink / raw)
To: lee.jones
Cc: linux-kernel, Felix Kuehling, Alex Deucher, Christian König,
Pan, Xinhui, David Airlie, Daniel Vetter, amd-gfx, dri-devel
This ensures userspace cannot prematurely clean-up the client before
it is fully initialised which has been proven to cause issues in the
past.
Cc: Felix Kuehling <Felix.Kuehling@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
CAVEAT: This patch is completely untested
I can't seem to find a configuration strategy to compile test this
allyesconfig and allmodconfig do not appear sufficient
v2: Also remove Client from RCU list in error path
drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 24 +++++++++++++--------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
index e4beebb1c80a2..f2e1d506ba211 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
@@ -247,15 +247,6 @@ int kfd_smi_event_open(struct kfd_dev *dev, uint32_t *fd)
return ret;
}
- ret = anon_inode_getfd(kfd_smi_name, &kfd_smi_ev_fops, (void *)client,
- O_RDWR);
- if (ret < 0) {
- kfifo_free(&client->fifo);
- kfree(client);
- return ret;
- }
- *fd = ret;
-
init_waitqueue_head(&client->wait_queue);
spin_lock_init(&client->lock);
client->events = 0;
@@ -265,5 +256,20 @@ int kfd_smi_event_open(struct kfd_dev *dev, uint32_t *fd)
list_add_rcu(&client->list, &dev->smi_clients);
spin_unlock(&dev->smi_lock);
+ ret = anon_inode_getfd(kfd_smi_name, &kfd_smi_ev_fops, (void *)client,
+ O_RDWR);
+ if (ret < 0) {
+ spin_lock(&dev->smi_lock);
+ list_del_rcu(&client->list);
+ spin_unlock(&dev->smi_lock);
+
+ synchronize_rcu();
+
+ kfifo_free(&client->fifo);
+ kfree(client);
+ return ret;
+ }
+ *fd = ret;
+
return 0;
}
--
2.35.1.1021.g381101b075-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] drm/amdkfd: Create file descriptor after client is added to smi_clients list
2022-04-01 10:44 [PATCH v2 1/1] drm/amdkfd: Create file descriptor after client is added to smi_clients list Lee Jones
@ 2022-04-01 10:48 ` Lee Jones
0 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2022-04-01 10:48 UTC (permalink / raw)
To: linux-kernel, Felix Kuehling, Alex Deucher, Christian König,
Pan, Xinhui, David Airlie, Daniel Vetter, amd-gfx, dri-devel
On Fri, 01 Apr 2022, Lee Jones wrote:
> This ensures userspace cannot prematurely clean-up the client before
> it is fully initialised which has been proven to cause issues in the
> past.
>
> Cc: Felix Kuehling <Felix.Kuehling@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: "Christian König" <christian.koenig@amd.com>
> Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: amd-gfx@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>
> CAVEAT: This patch is completely untested
> I can't seem to find a configuration strategy to compile test this
> allyesconfig and allmodconfig do not appear sufficient
>
> v2: Also remove Client from RCU list in error path
>
> drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 24 +++++++++++++--------
> 1 file changed, 15 insertions(+), 9 deletions(-)
Please ignore this re-submission, script error.
--
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] drm/amdkfd: Create file descriptor after client is added to smi_clients list
2022-03-31 14:44 ` Felix Kuehling
@ 2022-03-31 17:15 ` Lee Jones
0 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2022-03-31 17:15 UTC (permalink / raw)
To: Felix Kuehling
Cc: linux-kernel, Alex Deucher, Christian König, Pan, Xinhui,
David Airlie, Daniel Vetter, amd-gfx, dri-devel
On Thu, 31 Mar 2022, Felix Kuehling wrote:
>
> Am 2022-03-31 um 08:21 schrieb Lee Jones:
> > This ensures userspace cannot prematurely clean-up the client before
> > it is fully initialised which has been proven to cause issues in the
> > past.
> >
> > Cc: Felix Kuehling <Felix.Kuehling@amd.com>
> > Cc: Alex Deucher <alexander.deucher@amd.com>
> > Cc: "Christian König" <christian.koenig@amd.com>
> > Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
> > Cc: David Airlie <airlied@linux.ie>
> > Cc: Daniel Vetter <daniel@ffwll.ch>
> > Cc: amd-gfx@lists.freedesktop.org
> > Cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
>
> Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
>
> I will apply to patch to amd-staging-drm-next.
>
> > ---
> >
> > CAVEAT: This patch is completely untested
> > I can't seem to find a configuration strategy to compile test this
> > allyesconfig and allmodconfig do not appear sufficient
>
> That's very strange. It should get compiled if CONFIG_HSA_AMD is
> enabled.
Okay, I figured it out.
Apparently you can't give 'drivers/gpu/drm/amd' as a build param.
'drivers/gpu/drm' works as I expect however.
> I will at least compile-test it before I submit.
Great, thank you.
--
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] drm/amdkfd: Create file descriptor after client is added to smi_clients list
2022-03-31 12:21 Lee Jones
@ 2022-03-31 14:44 ` Felix Kuehling
2022-03-31 17:15 ` Lee Jones
0 siblings, 1 reply; 5+ messages in thread
From: Felix Kuehling @ 2022-03-31 14:44 UTC (permalink / raw)
To: Lee Jones
Cc: linux-kernel, Alex Deucher, Christian König, Pan, Xinhui,
David Airlie, Daniel Vetter, amd-gfx, dri-devel
Am 2022-03-31 um 08:21 schrieb Lee Jones:
> This ensures userspace cannot prematurely clean-up the client before
> it is fully initialised which has been proven to cause issues in the
> past.
>
> Cc: Felix Kuehling <Felix.Kuehling@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: "Christian König" <christian.koenig@amd.com>
> Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: amd-gfx@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
I will apply to patch to amd-staging-drm-next.
> ---
>
> CAVEAT: This patch is completely untested
> I can't seem to find a configuration strategy to compile test this
> allyesconfig and allmodconfig do not appear sufficient
That's very strange. It should get compiled if CONFIG_HSA_AMD is
enabled. I will at least compile-test it before I submit.
Regards,
Felix
>
> v2: Also remove Client from RCU list in error path
>
> drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 24 +++++++++++++--------
> 1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
> index e4beebb1c80a2..f2e1d506ba211 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
> @@ -247,15 +247,6 @@ int kfd_smi_event_open(struct kfd_dev *dev, uint32_t *fd)
> return ret;
> }
>
> - ret = anon_inode_getfd(kfd_smi_name, &kfd_smi_ev_fops, (void *)client,
> - O_RDWR);
> - if (ret < 0) {
> - kfifo_free(&client->fifo);
> - kfree(client);
> - return ret;
> - }
> - *fd = ret;
> -
> init_waitqueue_head(&client->wait_queue);
> spin_lock_init(&client->lock);
> client->events = 0;
> @@ -265,5 +256,20 @@ int kfd_smi_event_open(struct kfd_dev *dev, uint32_t *fd)
> list_add_rcu(&client->list, &dev->smi_clients);
> spin_unlock(&dev->smi_lock);
>
> + ret = anon_inode_getfd(kfd_smi_name, &kfd_smi_ev_fops, (void *)client,
> + O_RDWR);
> + if (ret < 0) {
> + spin_lock(&dev->smi_lock);
> + list_del_rcu(&client->list);
> + spin_unlock(&dev->smi_lock);
> +
> + synchronize_rcu();
> +
> + kfifo_free(&client->fifo);
> + kfree(client);
> + return ret;
> + }
> + *fd = ret;
> +
> return 0;
> }
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/1] drm/amdkfd: Create file descriptor after client is added to smi_clients list
@ 2022-03-31 12:21 Lee Jones
2022-03-31 14:44 ` Felix Kuehling
0 siblings, 1 reply; 5+ messages in thread
From: Lee Jones @ 2022-03-31 12:21 UTC (permalink / raw)
To: lee.jones
Cc: linux-kernel, Felix Kuehling, Alex Deucher, Christian König,
Pan, Xinhui, David Airlie, Daniel Vetter, amd-gfx, dri-devel
This ensures userspace cannot prematurely clean-up the client before
it is fully initialised which has been proven to cause issues in the
past.
Cc: Felix Kuehling <Felix.Kuehling@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
CAVEAT: This patch is completely untested
I can't seem to find a configuration strategy to compile test this
allyesconfig and allmodconfig do not appear sufficient
v2: Also remove Client from RCU list in error path
drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 24 +++++++++++++--------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
index e4beebb1c80a2..f2e1d506ba211 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
@@ -247,15 +247,6 @@ int kfd_smi_event_open(struct kfd_dev *dev, uint32_t *fd)
return ret;
}
- ret = anon_inode_getfd(kfd_smi_name, &kfd_smi_ev_fops, (void *)client,
- O_RDWR);
- if (ret < 0) {
- kfifo_free(&client->fifo);
- kfree(client);
- return ret;
- }
- *fd = ret;
-
init_waitqueue_head(&client->wait_queue);
spin_lock_init(&client->lock);
client->events = 0;
@@ -265,5 +256,20 @@ int kfd_smi_event_open(struct kfd_dev *dev, uint32_t *fd)
list_add_rcu(&client->list, &dev->smi_clients);
spin_unlock(&dev->smi_lock);
+ ret = anon_inode_getfd(kfd_smi_name, &kfd_smi_ev_fops, (void *)client,
+ O_RDWR);
+ if (ret < 0) {
+ spin_lock(&dev->smi_lock);
+ list_del_rcu(&client->list);
+ spin_unlock(&dev->smi_lock);
+
+ synchronize_rcu();
+
+ kfifo_free(&client->fifo);
+ kfree(client);
+ return ret;
+ }
+ *fd = ret;
+
return 0;
}
--
2.35.1.1021.g381101b075-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-01 10:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 10:44 [PATCH v2 1/1] drm/amdkfd: Create file descriptor after client is added to smi_clients list Lee Jones
2022-04-01 10:48 ` Lee Jones
-- strict thread matches above, loose matches on Subject: below --
2022-03-31 12:21 Lee Jones
2022-03-31 14:44 ` Felix Kuehling
2022-03-31 17:15 ` Lee Jones
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).