* [PATCH backport for 5.4] tee: optee: Fix missing devices unregister during optee_remove
@ 2021-10-19 9:45 Sumit Garg
2021-10-20 12:34 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Sumit Garg @ 2021-10-19 9:45 UTC (permalink / raw)
To: stable; +Cc: gregkh, jens.wiklander, sudeep.holla, Sumit Garg
upstream commit 7f565d0ead26
When OP-TEE driver is built as a module, OP-TEE client devices
registered on TEE bus during probe should be unregistered during
optee_remove. So implement optee_unregister_devices() accordingly.
Fixes: c3fa24af9244 ("tee: optee: add TEE bus device enumeration support")
Reported-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
[SG: backport to 5.4, dev name s/optee-ta/optee-clnt/]
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
---
drivers/tee/optee/core.c | 3 +++
drivers/tee/optee/device.c | 22 ++++++++++++++++++++++
drivers/tee/optee/optee_private.h | 1 +
3 files changed, 26 insertions(+)
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index 4bb4c8f28cbd..5eaef45799e6 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -582,6 +582,9 @@ static struct optee *optee_probe(struct device_node *np)
if (sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM)
pool = optee_config_dyn_shm();
+ /* Unregister OP-TEE specific client devices on TEE bus */
+ optee_unregister_devices();
+
/*
* If dynamic shared memory is not available or failed - try static one
*/
diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c
index e3a148521ec1..acff7dd677d6 100644
--- a/drivers/tee/optee/device.c
+++ b/drivers/tee/optee/device.c
@@ -65,6 +65,13 @@ static int get_devices(struct tee_context *ctx, u32 session,
return 0;
}
+static void optee_release_device(struct device *dev)
+{
+ struct tee_client_device *optee_device = to_tee_client_device(dev);
+
+ kfree(optee_device);
+}
+
static int optee_register_device(const uuid_t *device_uuid, u32 device_id)
{
struct tee_client_device *optee_device = NULL;
@@ -75,6 +82,7 @@ static int optee_register_device(const uuid_t *device_uuid, u32 device_id)
return -ENOMEM;
optee_device->dev.bus = &tee_bus_type;
+ optee_device->dev.release = optee_release_device;
dev_set_name(&optee_device->dev, "optee-clnt%u", device_id);
uuid_copy(&optee_device->id.uuid, device_uuid);
@@ -158,3 +166,17 @@ int optee_enumerate_devices(void)
return rc;
}
+
+static int __optee_unregister_device(struct device *dev, void *data)
+{
+ if (!strncmp(dev_name(dev), "optee-clnt", strlen("optee-clnt")))
+ device_unregister(dev);
+
+ return 0;
+}
+
+void optee_unregister_devices(void)
+{
+ bus_for_each_dev(&tee_bus_type, NULL, NULL,
+ __optee_unregister_device);
+}
diff --git a/drivers/tee/optee/optee_private.h b/drivers/tee/optee/optee_private.h
index 3eeaad2a2868..54c3fa01d002 100644
--- a/drivers/tee/optee/optee_private.h
+++ b/drivers/tee/optee/optee_private.h
@@ -175,6 +175,7 @@ void optee_fill_pages_list(u64 *dst, struct page **pages, int num_pages,
size_t page_offset);
int optee_enumerate_devices(void);
+void optee_unregister_devices(void);
/*
* Small helpers
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH backport for 5.4] tee: optee: Fix missing devices unregister during optee_remove
2021-10-19 9:45 [PATCH backport for 5.4] tee: optee: Fix missing devices unregister during optee_remove Sumit Garg
@ 2021-10-20 12:34 ` Greg KH
2021-10-20 12:37 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2021-10-20 12:34 UTC (permalink / raw)
To: Sumit Garg; +Cc: stable, jens.wiklander, sudeep.holla
On Tue, Oct 19, 2021 at 03:15:32PM +0530, Sumit Garg wrote:
> upstream commit 7f565d0ead26
>
> When OP-TEE driver is built as a module, OP-TEE client devices
> registered on TEE bus during probe should be unregistered during
> optee_remove. So implement optee_unregister_devices() accordingly.
>
> Fixes: c3fa24af9244 ("tee: optee: add TEE bus device enumeration support")
> Reported-by: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
> [SG: backport to 5.4, dev name s/optee-ta/optee-clnt/]
> Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
> ---
> drivers/tee/optee/core.c | 3 +++
> drivers/tee/optee/device.c | 22 ++++++++++++++++++++++
> drivers/tee/optee/optee_private.h | 1 +
> 3 files changed, 26 insertions(+)
Doesn't this also need to go into 5.10 and 5.14? We can not have people
upgrading and having regressions.
Can you provide backports for those trees too? I can not take just this
one, sorry.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH backport for 5.4] tee: optee: Fix missing devices unregister during optee_remove
2021-10-20 12:34 ` Greg KH
@ 2021-10-20 12:37 ` Greg KH
2021-10-20 12:38 ` Sumit Garg
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2021-10-20 12:37 UTC (permalink / raw)
To: Sumit Garg; +Cc: stable, jens.wiklander, sudeep.holla
On Wed, Oct 20, 2021 at 02:34:31PM +0200, Greg KH wrote:
> On Tue, Oct 19, 2021 at 03:15:32PM +0530, Sumit Garg wrote:
> > upstream commit 7f565d0ead26
> >
> > When OP-TEE driver is built as a module, OP-TEE client devices
> > registered on TEE bus during probe should be unregistered during
> > optee_remove. So implement optee_unregister_devices() accordingly.
> >
> > Fixes: c3fa24af9244 ("tee: optee: add TEE bus device enumeration support")
> > Reported-by: Sudeep Holla <sudeep.holla@arm.com>
> > Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
> > Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
> > [SG: backport to 5.4, dev name s/optee-ta/optee-clnt/]
> > Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
> > ---
> > drivers/tee/optee/core.c | 3 +++
> > drivers/tee/optee/device.c | 22 ++++++++++++++++++++++
> > drivers/tee/optee/optee_private.h | 1 +
> > 3 files changed, 26 insertions(+)
>
> Doesn't this also need to go into 5.10 and 5.14? We can not have people
> upgrading and having regressions.
>
> Can you provide backports for those trees too? I can not take just this
> one, sorry.
Nevermind, it's already there, sorry for the noise, I'll go queue this
up right now...
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH backport for 5.4] tee: optee: Fix missing devices unregister during optee_remove
2021-10-20 12:37 ` Greg KH
@ 2021-10-20 12:38 ` Sumit Garg
0 siblings, 0 replies; 4+ messages in thread
From: Sumit Garg @ 2021-10-20 12:38 UTC (permalink / raw)
To: Greg KH; +Cc: stable, Jens Wiklander, Sudeep Holla
On Wed, 20 Oct 2021 at 18:07, Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Oct 20, 2021 at 02:34:31PM +0200, Greg KH wrote:
> > On Tue, Oct 19, 2021 at 03:15:32PM +0530, Sumit Garg wrote:
> > > upstream commit 7f565d0ead26
> > >
> > > When OP-TEE driver is built as a module, OP-TEE client devices
> > > registered on TEE bus during probe should be unregistered during
> > > optee_remove. So implement optee_unregister_devices() accordingly.
> > >
> > > Fixes: c3fa24af9244 ("tee: optee: add TEE bus device enumeration support")
> > > Reported-by: Sudeep Holla <sudeep.holla@arm.com>
> > > Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
> > > Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
> > > [SG: backport to 5.4, dev name s/optee-ta/optee-clnt/]
> > > Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
> > > ---
> > > drivers/tee/optee/core.c | 3 +++
> > > drivers/tee/optee/device.c | 22 ++++++++++++++++++++++
> > > drivers/tee/optee/optee_private.h | 1 +
> > > 3 files changed, 26 insertions(+)
> >
> > Doesn't this also need to go into 5.10 and 5.14? We can not have people
> > upgrading and having regressions.
> >
> > Can you provide backports for those trees too? I can not take just this
> > one, sorry.
>
> Nevermind, it's already there, sorry for the noise, I'll go queue this
> up right now...
>
Thanks
-Sumit
> greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-20 12:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 9:45 [PATCH backport for 5.4] tee: optee: Fix missing devices unregister during optee_remove Sumit Garg
2021-10-20 12:34 ` Greg KH
2021-10-20 12:37 ` Greg KH
2021-10-20 12:38 ` Sumit Garg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.