* [PATCH v2 00/10] firmware: arm_ffa: Refactoring and initial/minor v1.1 update
@ 2022-09-02 12:40 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
Hi All,
This series is just some refactoring in preparation to add FF-A v1.1
support. It doesn't have any memory layout or notification changes
supported in v1.1 yet.
Regards,
Sudeep
v1[1]->v2:
- Merged dropping of ffa_ops in optee_ffa structure and using
ffa_dev->ops into single patch
- Added separate patch(didn't fit any patch strictly to fit in)
to rename ffa_dev_ops as ffa_ops as suggested by Sumit
- Fixed some minor comments, handling size > structure size in
partition_info_get and added extra parameter to ffa_features
to get both possible output/interface properties.
[1] https://lore.kernel.org/all/20220830100700.344594-1-sudeep.holla@arm.com/
Sudeep Holla (10):
firmware: arm_ffa: Add pointer to the ffa_dev_ops in struct ffa_dev
tee: optee: Drop ffa_ops in optee_ffa structure using ffa_dev->ops directly
firmware: arm_ffa: Remove ffa_dev_ops_get()
firmware: arm_ffa: Add support for querying FF-A features
firmware: arm_ffa: Use FFA_FEATURES to detect if native versions are supported
firmware: arm_ffa: Make memory apis ffa_device independent
firmware: arm_ffa: Rename ffa_dev_ops as ffa_ops
firmware: arm_ffa: Add v1.1 get_partition_info support
firmware: arm_ffa: Set up 32bit execution mode flag using partiion property
firmware: arm_ffa: Split up ffa_ops into info, message and memory operations
drivers/firmware/arm_ffa/bus.c | 4 +-
drivers/firmware/arm_ffa/driver.c | 130 +++++++++++++++++++++++-------
drivers/tee/optee/ffa_abi.c | 46 +++++------
drivers/tee/optee/optee_private.h | 1 -
include/linux/arm_ffa.h | 36 ++++++---
5 files changed, 150 insertions(+), 67 deletions(-)
--
2.37.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v2 00/10] firmware: arm_ffa: Refactoring and initial/minor v1.1 update
@ 2022-09-02 12:40 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
Hi All,
This series is just some refactoring in preparation to add FF-A v1.1
support. It doesn't have any memory layout or notification changes
supported in v1.1 yet.
Regards,
Sudeep
v1[1]->v2:
- Merged dropping of ffa_ops in optee_ffa structure and using
ffa_dev->ops into single patch
- Added separate patch(didn't fit any patch strictly to fit in)
to rename ffa_dev_ops as ffa_ops as suggested by Sumit
- Fixed some minor comments, handling size > structure size in
partition_info_get and added extra parameter to ffa_features
to get both possible output/interface properties.
[1] https://lore.kernel.org/all/20220830100700.344594-1-sudeep.holla@arm.com/
Sudeep Holla (10):
firmware: arm_ffa: Add pointer to the ffa_dev_ops in struct ffa_dev
tee: optee: Drop ffa_ops in optee_ffa structure using ffa_dev->ops directly
firmware: arm_ffa: Remove ffa_dev_ops_get()
firmware: arm_ffa: Add support for querying FF-A features
firmware: arm_ffa: Use FFA_FEATURES to detect if native versions are supported
firmware: arm_ffa: Make memory apis ffa_device independent
firmware: arm_ffa: Rename ffa_dev_ops as ffa_ops
firmware: arm_ffa: Add v1.1 get_partition_info support
firmware: arm_ffa: Set up 32bit execution mode flag using partiion property
firmware: arm_ffa: Split up ffa_ops into info, message and memory operations
drivers/firmware/arm_ffa/bus.c | 4 +-
drivers/firmware/arm_ffa/driver.c | 130 +++++++++++++++++++++++-------
drivers/tee/optee/ffa_abi.c | 46 +++++------
drivers/tee/optee/optee_private.h | 1 -
include/linux/arm_ffa.h | 36 ++++++---
5 files changed, 150 insertions(+), 67 deletions(-)
--
2.37.3
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v2 01/10] firmware: arm_ffa: Add pointer to the ffa_dev_ops in struct ffa_dev
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-02 12:40 ` Sudeep Holla
-1 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
Currently ffa_dev_ops_get() is the way to fetch the ffa_dev_ops pointer.
It checks if the ffa_dev structure pointer is valid before returning the
ffa_dev_ops pointer.
Instead, the pointer can be made part of the ffa_dev structure and since
the core driver is incharge of creating ffa_device for each identified
partition, there is no need to check for the validity explicitly if the
pointer is embedded in the structure.
Add the pointer to the ffa_dev_ops in the ffa_dev structure itself and
initialise the same as part of creation of the device.
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/bus.c | 4 +++-
drivers/firmware/arm_ffa/driver.c | 2 +-
include/linux/arm_ffa.h | 7 +++++--
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c
index 641a91819088..69328041fbc3 100644
--- a/drivers/firmware/arm_ffa/bus.c
+++ b/drivers/firmware/arm_ffa/bus.c
@@ -167,7 +167,8 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev)
return valid;
}
-struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id)
+struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
+ const struct ffa_dev_ops *ops)
{
int ret;
struct device *dev;
@@ -183,6 +184,7 @@ struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id)
dev_set_name(&ffa_dev->dev, "arm-ffa-%04x", vm_id);
ffa_dev->vm_id = vm_id;
+ ffa_dev->ops = ops;
uuid_copy(&ffa_dev->uuid, uuid);
ret = device_register(&ffa_dev->dev);
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index ec731e9e942b..213665e5ad0e 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -688,7 +688,7 @@ static void ffa_setup_partitions(void)
* as part of the discovery API, we need to pass the
* discovered UUID here instead.
*/
- ffa_dev = ffa_device_register(&uuid_null, tpbuf->id);
+ ffa_dev = ffa_device_register(&uuid_null, tpbuf->id, &ffa_ops);
if (!ffa_dev) {
pr_err("%s: failed to register partition ID 0x%x\n",
__func__, tpbuf->id);
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index e5c76c1ef9ed..91b47e42b73d 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -17,6 +17,7 @@ struct ffa_device {
bool mode_32bit;
uuid_t uuid;
struct device dev;
+ const struct ffa_dev_ops *ops;
};
#define to_ffa_dev(d) container_of(d, struct ffa_device, dev)
@@ -47,7 +48,8 @@ static inline void *ffa_dev_get_drvdata(struct ffa_device *fdev)
}
#if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT)
-struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id);
+struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
+ const struct ffa_dev_ops *ops);
void ffa_device_unregister(struct ffa_device *ffa_dev);
int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
const char *mod_name);
@@ -57,7 +59,8 @@ const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev);
#else
static inline
-struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id)
+struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
+ const struct ffa_dev_ops *ops)
{
return NULL;
}
--
2.37.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 01/10] firmware: arm_ffa: Add pointer to the ffa_dev_ops in struct ffa_dev
@ 2022-09-02 12:40 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
Currently ffa_dev_ops_get() is the way to fetch the ffa_dev_ops pointer.
It checks if the ffa_dev structure pointer is valid before returning the
ffa_dev_ops pointer.
Instead, the pointer can be made part of the ffa_dev structure and since
the core driver is incharge of creating ffa_device for each identified
partition, there is no need to check for the validity explicitly if the
pointer is embedded in the structure.
Add the pointer to the ffa_dev_ops in the ffa_dev structure itself and
initialise the same as part of creation of the device.
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/bus.c | 4 +++-
drivers/firmware/arm_ffa/driver.c | 2 +-
include/linux/arm_ffa.h | 7 +++++--
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c
index 641a91819088..69328041fbc3 100644
--- a/drivers/firmware/arm_ffa/bus.c
+++ b/drivers/firmware/arm_ffa/bus.c
@@ -167,7 +167,8 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev)
return valid;
}
-struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id)
+struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
+ const struct ffa_dev_ops *ops)
{
int ret;
struct device *dev;
@@ -183,6 +184,7 @@ struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id)
dev_set_name(&ffa_dev->dev, "arm-ffa-%04x", vm_id);
ffa_dev->vm_id = vm_id;
+ ffa_dev->ops = ops;
uuid_copy(&ffa_dev->uuid, uuid);
ret = device_register(&ffa_dev->dev);
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index ec731e9e942b..213665e5ad0e 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -688,7 +688,7 @@ static void ffa_setup_partitions(void)
* as part of the discovery API, we need to pass the
* discovered UUID here instead.
*/
- ffa_dev = ffa_device_register(&uuid_null, tpbuf->id);
+ ffa_dev = ffa_device_register(&uuid_null, tpbuf->id, &ffa_ops);
if (!ffa_dev) {
pr_err("%s: failed to register partition ID 0x%x\n",
__func__, tpbuf->id);
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index e5c76c1ef9ed..91b47e42b73d 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -17,6 +17,7 @@ struct ffa_device {
bool mode_32bit;
uuid_t uuid;
struct device dev;
+ const struct ffa_dev_ops *ops;
};
#define to_ffa_dev(d) container_of(d, struct ffa_device, dev)
@@ -47,7 +48,8 @@ static inline void *ffa_dev_get_drvdata(struct ffa_device *fdev)
}
#if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT)
-struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id);
+struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
+ const struct ffa_dev_ops *ops);
void ffa_device_unregister(struct ffa_device *ffa_dev);
int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
const char *mod_name);
@@ -57,7 +59,8 @@ const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev);
#else
static inline
-struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id)
+struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
+ const struct ffa_dev_ops *ops)
{
return NULL;
}
--
2.37.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 02/10] tee: optee: Drop ffa_ops in optee_ffa structure using ffa_dev->ops directly
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-02 12:40 ` Sudeep Holla
-1 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen, Sumit Garg
Now that the ffa_device structure holds the pointer to ffa_dev_ops,
there is no need to obtain the same through ffa_dev_ops_get().
Just use the ffa_dev->ops directly. Since the ffa_device itself carries
ffa_dev_ops now, there is no need to keep a copy in optee_ffa structure.
Drop ffa_ops in the optee_ffa structure as it is not needed anymore.
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/tee/optee/ffa_abi.c | 15 +++++----------
drivers/tee/optee/optee_private.h | 1 -
2 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
index 7ab31740cff8..3d4079575ccd 100644
--- a/drivers/tee/optee/ffa_abi.c
+++ b/drivers/tee/optee/ffa_abi.c
@@ -271,8 +271,8 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
unsigned long start)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
- const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_ops;
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
+ const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
struct ffa_mem_region_attributes mem_attr = {
.receiver = ffa_dev->vm_id,
.attrs = FFA_MEM_RW,
@@ -314,8 +314,8 @@ static int optee_ffa_shm_unregister(struct tee_context *ctx,
struct tee_shm *shm)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
- const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_ops;
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
+ const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
u64 global_handle = shm->sec_world_id;
struct ffa_send_direct_data data = {
.data0 = OPTEE_FFA_UNREGISTER_SHM,
@@ -342,7 +342,7 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
struct tee_shm *shm)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
- const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_ops;
+ const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_dev->ops;
u64 global_handle = shm->sec_world_id;
int rc;
@@ -529,8 +529,8 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
struct optee_msg_arg *rpc_arg)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
- const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_ops;
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
+ const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
struct optee_call_waiter w;
u32 cmd = data->data0;
u32 w4 = data->data1;
@@ -793,11 +793,7 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev)
u32 sec_caps;
int rc;
- ffa_ops = ffa_dev_ops_get(ffa_dev);
- if (!ffa_ops) {
- pr_warn("failed \"method\" init: ffa\n");
- return -ENOENT;
- }
+ ffa_ops = ffa_dev->ops;
if (!optee_ffa_api_is_compatbile(ffa_dev, ffa_ops))
return -EINVAL;
@@ -821,7 +817,6 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev)
optee->ops = &optee_ffa_ops;
optee->ffa.ffa_dev = ffa_dev;
- optee->ffa.ffa_ops = ffa_ops;
optee->rpc_param_count = rpc_param_count;
teedev = tee_device_alloc(&optee_ffa_clnt_desc, NULL, optee->pool,
diff --git a/drivers/tee/optee/optee_private.h b/drivers/tee/optee/optee_private.h
index a33d98d17cfd..04ae58892608 100644
--- a/drivers/tee/optee/optee_private.h
+++ b/drivers/tee/optee/optee_private.h
@@ -111,7 +111,6 @@ struct optee_smc {
*/
struct optee_ffa {
struct ffa_device *ffa_dev;
- const struct ffa_dev_ops *ffa_ops;
/* Serializes access to @global_ids */
struct mutex mutex;
struct rhashtable global_ids;
--
2.37.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 02/10] tee: optee: Drop ffa_ops in optee_ffa structure using ffa_dev->ops directly
@ 2022-09-02 12:40 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen, Sumit Garg
Now that the ffa_device structure holds the pointer to ffa_dev_ops,
there is no need to obtain the same through ffa_dev_ops_get().
Just use the ffa_dev->ops directly. Since the ffa_device itself carries
ffa_dev_ops now, there is no need to keep a copy in optee_ffa structure.
Drop ffa_ops in the optee_ffa structure as it is not needed anymore.
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/tee/optee/ffa_abi.c | 15 +++++----------
drivers/tee/optee/optee_private.h | 1 -
2 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
index 7ab31740cff8..3d4079575ccd 100644
--- a/drivers/tee/optee/ffa_abi.c
+++ b/drivers/tee/optee/ffa_abi.c
@@ -271,8 +271,8 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
unsigned long start)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
- const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_ops;
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
+ const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
struct ffa_mem_region_attributes mem_attr = {
.receiver = ffa_dev->vm_id,
.attrs = FFA_MEM_RW,
@@ -314,8 +314,8 @@ static int optee_ffa_shm_unregister(struct tee_context *ctx,
struct tee_shm *shm)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
- const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_ops;
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
+ const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
u64 global_handle = shm->sec_world_id;
struct ffa_send_direct_data data = {
.data0 = OPTEE_FFA_UNREGISTER_SHM,
@@ -342,7 +342,7 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
struct tee_shm *shm)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
- const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_ops;
+ const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_dev->ops;
u64 global_handle = shm->sec_world_id;
int rc;
@@ -529,8 +529,8 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
struct optee_msg_arg *rpc_arg)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
- const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_ops;
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
+ const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
struct optee_call_waiter w;
u32 cmd = data->data0;
u32 w4 = data->data1;
@@ -793,11 +793,7 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev)
u32 sec_caps;
int rc;
- ffa_ops = ffa_dev_ops_get(ffa_dev);
- if (!ffa_ops) {
- pr_warn("failed \"method\" init: ffa\n");
- return -ENOENT;
- }
+ ffa_ops = ffa_dev->ops;
if (!optee_ffa_api_is_compatbile(ffa_dev, ffa_ops))
return -EINVAL;
@@ -821,7 +817,6 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev)
optee->ops = &optee_ffa_ops;
optee->ffa.ffa_dev = ffa_dev;
- optee->ffa.ffa_ops = ffa_ops;
optee->rpc_param_count = rpc_param_count;
teedev = tee_device_alloc(&optee_ffa_clnt_desc, NULL, optee->pool,
diff --git a/drivers/tee/optee/optee_private.h b/drivers/tee/optee/optee_private.h
index a33d98d17cfd..04ae58892608 100644
--- a/drivers/tee/optee/optee_private.h
+++ b/drivers/tee/optee/optee_private.h
@@ -111,7 +111,6 @@ struct optee_smc {
*/
struct optee_ffa {
struct ffa_device *ffa_dev;
- const struct ffa_dev_ops *ffa_ops;
/* Serializes access to @global_ids */
struct mutex mutex;
struct rhashtable global_ids;
--
2.37.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 03/10] firmware: arm_ffa: Remove ffa_dev_ops_get()
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-02 12:40 ` Sudeep Holla
-1 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
The only user of this exported ffa_dev_ops_get() was OPTEE driver which
now uses ffa_dev->ops directly, there are no other users for this.
Also, since any ffa driver can use ffa_dev->ops directly, there will be
no need for ffa_dev_ops_get(), so just remove ffa_dev_ops_get().
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 9 ---------
include/linux/arm_ffa.h | 6 ------
2 files changed, 15 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 213665e5ad0e..04e7cbb1b9aa 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -644,15 +644,6 @@ static const struct ffa_dev_ops ffa_ops = {
.memory_lend = ffa_memory_lend,
};
-const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev)
-{
- if (ffa_device_is_valid(dev))
- return &ffa_ops;
-
- return NULL;
-}
-EXPORT_SYMBOL_GPL(ffa_dev_ops_get);
-
void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
{
int count, idx;
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index 91b47e42b73d..556f50f27fb1 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -55,7 +55,6 @@ int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
const char *mod_name);
void ffa_driver_unregister(struct ffa_driver *driver);
bool ffa_device_is_valid(struct ffa_device *ffa_dev);
-const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev);
#else
static inline
@@ -79,11 +78,6 @@ static inline void ffa_driver_unregister(struct ffa_driver *driver) {}
static inline
bool ffa_device_is_valid(struct ffa_device *ffa_dev) { return false; }
-static inline
-const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev)
-{
- return NULL;
-}
#endif /* CONFIG_ARM_FFA_TRANSPORT */
#define ffa_register(driver) \
--
2.37.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 03/10] firmware: arm_ffa: Remove ffa_dev_ops_get()
@ 2022-09-02 12:40 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
The only user of this exported ffa_dev_ops_get() was OPTEE driver which
now uses ffa_dev->ops directly, there are no other users for this.
Also, since any ffa driver can use ffa_dev->ops directly, there will be
no need for ffa_dev_ops_get(), so just remove ffa_dev_ops_get().
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 9 ---------
include/linux/arm_ffa.h | 6 ------
2 files changed, 15 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 213665e5ad0e..04e7cbb1b9aa 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -644,15 +644,6 @@ static const struct ffa_dev_ops ffa_ops = {
.memory_lend = ffa_memory_lend,
};
-const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev)
-{
- if (ffa_device_is_valid(dev))
- return &ffa_ops;
-
- return NULL;
-}
-EXPORT_SYMBOL_GPL(ffa_dev_ops_get);
-
void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
{
int count, idx;
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index 91b47e42b73d..556f50f27fb1 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -55,7 +55,6 @@ int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
const char *mod_name);
void ffa_driver_unregister(struct ffa_driver *driver);
bool ffa_device_is_valid(struct ffa_device *ffa_dev);
-const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev);
#else
static inline
@@ -79,11 +78,6 @@ static inline void ffa_driver_unregister(struct ffa_driver *driver) {}
static inline
bool ffa_device_is_valid(struct ffa_device *ffa_dev) { return false; }
-static inline
-const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev)
-{
- return NULL;
-}
#endif /* CONFIG_ARM_FFA_TRANSPORT */
#define ffa_register(driver) \
--
2.37.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 04/10] firmware: arm_ffa: Add support for querying FF-A features
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-02 12:40 ` Sudeep Holla
-1 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
Add support for FFA_FEATURES to discover properties supported at the
FF-A interface. This interface can be used to query:
- If an FF-A interface is implemented by the component at the higher EL,
- If an implemented FF-A interface also implements any optional features
described in its interface definition, and
- Any implementation details exported by an implemented FF-A interface
as described in its interface definition.
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 04e7cbb1b9aa..81b8d578b6ea 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -571,6 +571,32 @@ static int ffa_memory_reclaim(u64 g_handle, u32 flags)
return 0;
}
+static int ffa_features(u32 func_feat_id, u32 input_props,
+ u32 *if_props_1, u32 *if_props_2)
+{
+ ffa_value_t id;
+
+ if (!ARM_SMCCC_IS_FAST_CALL(func_feat_id) && input_props) {
+ pr_err("%s: Invalid Parameters: %x, %x", __func__,
+ func_feat_id, input_props);
+ return ffa_to_linux_errno(FFA_RET_INVALID_PARAMETERS);
+ }
+
+ invoke_ffa_fn((ffa_value_t){
+ .a0 = FFA_FEATURES, .a1 = func_feat_id, .a2 = input_props,
+ }, &id);
+
+ if (id.a0 == FFA_ERROR)
+ return ffa_to_linux_errno((int)id.a2);
+
+ if (if_props_1)
+ *if_props_1 = id.a2;
+ if (if_props_2)
+ *if_props_2 = id.a3;
+
+ return 0;
+}
+
static u32 ffa_api_version_get(void)
{
return drv_info->version;
--
2.37.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 04/10] firmware: arm_ffa: Add support for querying FF-A features
@ 2022-09-02 12:40 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
Add support for FFA_FEATURES to discover properties supported at the
FF-A interface. This interface can be used to query:
- If an FF-A interface is implemented by the component at the higher EL,
- If an implemented FF-A interface also implements any optional features
described in its interface definition, and
- Any implementation details exported by an implemented FF-A interface
as described in its interface definition.
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 04e7cbb1b9aa..81b8d578b6ea 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -571,6 +571,32 @@ static int ffa_memory_reclaim(u64 g_handle, u32 flags)
return 0;
}
+static int ffa_features(u32 func_feat_id, u32 input_props,
+ u32 *if_props_1, u32 *if_props_2)
+{
+ ffa_value_t id;
+
+ if (!ARM_SMCCC_IS_FAST_CALL(func_feat_id) && input_props) {
+ pr_err("%s: Invalid Parameters: %x, %x", __func__,
+ func_feat_id, input_props);
+ return ffa_to_linux_errno(FFA_RET_INVALID_PARAMETERS);
+ }
+
+ invoke_ffa_fn((ffa_value_t){
+ .a0 = FFA_FEATURES, .a1 = func_feat_id, .a2 = input_props,
+ }, &id);
+
+ if (id.a0 == FFA_ERROR)
+ return ffa_to_linux_errno((int)id.a2);
+
+ if (if_props_1)
+ *if_props_1 = id.a2;
+ if (if_props_2)
+ *if_props_2 = id.a3;
+
+ return 0;
+}
+
static u32 ffa_api_version_get(void)
{
return drv_info->version;
--
2.37.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 05/10] firmware: arm_ffa: Use FFA_FEATURES to detect if native versions are supported
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-02 12:40 ` Sudeep Holla
-1 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
Currently, the ffa_dev->mode_32bit is use to detect if the native 64-bit
or 32-bit versions of FF-A ABI needs to be used. However for the FF-A
memory ABIs, it is not dependent on the ffa_device(i.e. the partition)
itself, but the partition manager(SPM).
So, the FFA_FEATURES can be use to detect if the native 64bit ABIs are
supported or not and appropriate calls can be made based on that.
Use FFA_FEATURES to detect if native versions of MEM_LEND or MEM_SHARE
are implemented and make of the same to use native memory ABIs later on.
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 81b8d578b6ea..37a8ee304508 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -163,6 +163,7 @@ struct ffa_drv_info {
struct mutex tx_lock; /* lock to protect Tx buffer */
void *rx_buffer;
void *tx_buffer;
+ bool mem_ops_native;
};
static struct ffa_drv_info *drv_info;
@@ -597,6 +598,13 @@ static int ffa_features(u32 func_feat_id, u32 input_props,
return 0;
}
+static void ffa_set_up_mem_ops_native_flag(void)
+{
+ if (!ffa_features(FFA_FN_NATIVE(MEM_LEND), 0, NULL, NULL) ||
+ !ffa_features(FFA_FN_NATIVE(MEM_SHARE), 0, NULL, NULL))
+ drv_info->mem_ops_native = true;
+}
+
static u32 ffa_api_version_get(void)
{
return drv_info->version;
@@ -638,10 +646,10 @@ static int ffa_sync_send_receive(struct ffa_device *dev,
static int
ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args)
{
- if (dev->mode_32bit)
- return ffa_memory_ops(FFA_MEM_SHARE, args);
+ if (drv_info->mem_ops_native)
+ return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args);
- return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args);
+ return ffa_memory_ops(FFA_MEM_SHARE, args);
}
static int
@@ -654,10 +662,10 @@ ffa_memory_lend(struct ffa_device *dev, struct ffa_mem_ops_args *args)
* however on systems without a hypervisor the responsibility
* falls to the calling kernel driver to prevent access.
*/
- if (dev->mode_32bit)
- return ffa_memory_ops(FFA_MEM_LEND, args);
+ if (drv_info->mem_ops_native)
+ return ffa_memory_ops(FFA_FN_NATIVE(MEM_LEND), args);
- return ffa_memory_ops(FFA_FN_NATIVE(MEM_LEND), args);
+ return ffa_memory_ops(FFA_MEM_LEND, args);
}
static const struct ffa_dev_ops ffa_ops = {
@@ -768,6 +776,8 @@ static int __init ffa_init(void)
ffa_setup_partitions();
+ ffa_set_up_mem_ops_native_flag();
+
return 0;
free_pages:
if (drv_info->tx_buffer)
--
2.37.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 05/10] firmware: arm_ffa: Use FFA_FEATURES to detect if native versions are supported
@ 2022-09-02 12:40 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
Currently, the ffa_dev->mode_32bit is use to detect if the native 64-bit
or 32-bit versions of FF-A ABI needs to be used. However for the FF-A
memory ABIs, it is not dependent on the ffa_device(i.e. the partition)
itself, but the partition manager(SPM).
So, the FFA_FEATURES can be use to detect if the native 64bit ABIs are
supported or not and appropriate calls can be made based on that.
Use FFA_FEATURES to detect if native versions of MEM_LEND or MEM_SHARE
are implemented and make of the same to use native memory ABIs later on.
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 81b8d578b6ea..37a8ee304508 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -163,6 +163,7 @@ struct ffa_drv_info {
struct mutex tx_lock; /* lock to protect Tx buffer */
void *rx_buffer;
void *tx_buffer;
+ bool mem_ops_native;
};
static struct ffa_drv_info *drv_info;
@@ -597,6 +598,13 @@ static int ffa_features(u32 func_feat_id, u32 input_props,
return 0;
}
+static void ffa_set_up_mem_ops_native_flag(void)
+{
+ if (!ffa_features(FFA_FN_NATIVE(MEM_LEND), 0, NULL, NULL) ||
+ !ffa_features(FFA_FN_NATIVE(MEM_SHARE), 0, NULL, NULL))
+ drv_info->mem_ops_native = true;
+}
+
static u32 ffa_api_version_get(void)
{
return drv_info->version;
@@ -638,10 +646,10 @@ static int ffa_sync_send_receive(struct ffa_device *dev,
static int
ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args)
{
- if (dev->mode_32bit)
- return ffa_memory_ops(FFA_MEM_SHARE, args);
+ if (drv_info->mem_ops_native)
+ return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args);
- return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args);
+ return ffa_memory_ops(FFA_MEM_SHARE, args);
}
static int
@@ -654,10 +662,10 @@ ffa_memory_lend(struct ffa_device *dev, struct ffa_mem_ops_args *args)
* however on systems without a hypervisor the responsibility
* falls to the calling kernel driver to prevent access.
*/
- if (dev->mode_32bit)
- return ffa_memory_ops(FFA_MEM_LEND, args);
+ if (drv_info->mem_ops_native)
+ return ffa_memory_ops(FFA_FN_NATIVE(MEM_LEND), args);
- return ffa_memory_ops(FFA_FN_NATIVE(MEM_LEND), args);
+ return ffa_memory_ops(FFA_MEM_LEND, args);
}
static const struct ffa_dev_ops ffa_ops = {
@@ -768,6 +776,8 @@ static int __init ffa_init(void)
ffa_setup_partitions();
+ ffa_set_up_mem_ops_native_flag();
+
return 0;
free_pages:
if (drv_info->tx_buffer)
--
2.37.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 06/10] firmware: arm_ffa: Make memory apis ffa_device independent
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-02 12:40 ` Sudeep Holla
-1 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
There is a requirement to make memory APIs independent of the ffa_device.
One of the use-case is to have a common memory driver that manages the
memory for all the ffa_devices. That common memory driver won't be a
ffa_driver or won't have any ffa_device associated with it. So having
these memory APIs accessible without a ffa_device is needed and should
be possible as most of these are handled by the partition manager(SPM
or hypervisor).
Drop the ffa_device argument to the memory APIs and make them ffa_device
independent.
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 6 ++----
drivers/tee/optee/ffa_abi.c | 2 +-
include/linux/arm_ffa.h | 6 ++----
3 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 37a8ee304508..e4fd35773071 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -643,8 +643,7 @@ static int ffa_sync_send_receive(struct ffa_device *dev,
dev->mode_32bit, data);
}
-static int
-ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args)
+static int ffa_memory_share(struct ffa_mem_ops_args *args)
{
if (drv_info->mem_ops_native)
return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args);
@@ -652,8 +651,7 @@ ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args)
return ffa_memory_ops(FFA_MEM_SHARE, args);
}
-static int
-ffa_memory_lend(struct ffa_device *dev, struct ffa_mem_ops_args *args)
+static int ffa_memory_lend(struct ffa_mem_ops_args *args)
{
/* Note that upon a successful MEM_LEND request the caller
* must ensure that the memory region specified is not accessed
diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
index 3d4079575ccd..7257b42d0545 100644
--- a/drivers/tee/optee/ffa_abi.c
+++ b/drivers/tee/optee/ffa_abi.c
@@ -294,7 +294,7 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
if (rc)
return rc;
args.sg = sgt.sgl;
- rc = ffa_ops->memory_share(ffa_dev, &args);
+ rc = ffa_ops->memory_share(&args);
sg_free_table(&sgt);
if (rc)
return rc;
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index 556f50f27fb1..eafab07c9f58 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -262,10 +262,8 @@ struct ffa_dev_ops {
int (*sync_send_receive)(struct ffa_device *dev,
struct ffa_send_direct_data *data);
int (*memory_reclaim)(u64 g_handle, u32 flags);
- int (*memory_share)(struct ffa_device *dev,
- struct ffa_mem_ops_args *args);
- int (*memory_lend)(struct ffa_device *dev,
- struct ffa_mem_ops_args *args);
+ int (*memory_share)(struct ffa_mem_ops_args *args);
+ int (*memory_lend)(struct ffa_mem_ops_args *args);
};
#endif /* _LINUX_ARM_FFA_H */
--
2.37.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 06/10] firmware: arm_ffa: Make memory apis ffa_device independent
@ 2022-09-02 12:40 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
There is a requirement to make memory APIs independent of the ffa_device.
One of the use-case is to have a common memory driver that manages the
memory for all the ffa_devices. That common memory driver won't be a
ffa_driver or won't have any ffa_device associated with it. So having
these memory APIs accessible without a ffa_device is needed and should
be possible as most of these are handled by the partition manager(SPM
or hypervisor).
Drop the ffa_device argument to the memory APIs and make them ffa_device
independent.
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 6 ++----
drivers/tee/optee/ffa_abi.c | 2 +-
include/linux/arm_ffa.h | 6 ++----
3 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 37a8ee304508..e4fd35773071 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -643,8 +643,7 @@ static int ffa_sync_send_receive(struct ffa_device *dev,
dev->mode_32bit, data);
}
-static int
-ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args)
+static int ffa_memory_share(struct ffa_mem_ops_args *args)
{
if (drv_info->mem_ops_native)
return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args);
@@ -652,8 +651,7 @@ ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args)
return ffa_memory_ops(FFA_MEM_SHARE, args);
}
-static int
-ffa_memory_lend(struct ffa_device *dev, struct ffa_mem_ops_args *args)
+static int ffa_memory_lend(struct ffa_mem_ops_args *args)
{
/* Note that upon a successful MEM_LEND request the caller
* must ensure that the memory region specified is not accessed
diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
index 3d4079575ccd..7257b42d0545 100644
--- a/drivers/tee/optee/ffa_abi.c
+++ b/drivers/tee/optee/ffa_abi.c
@@ -294,7 +294,7 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
if (rc)
return rc;
args.sg = sgt.sgl;
- rc = ffa_ops->memory_share(ffa_dev, &args);
+ rc = ffa_ops->memory_share(&args);
sg_free_table(&sgt);
if (rc)
return rc;
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index 556f50f27fb1..eafab07c9f58 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -262,10 +262,8 @@ struct ffa_dev_ops {
int (*sync_send_receive)(struct ffa_device *dev,
struct ffa_send_direct_data *data);
int (*memory_reclaim)(u64 g_handle, u32 flags);
- int (*memory_share)(struct ffa_device *dev,
- struct ffa_mem_ops_args *args);
- int (*memory_lend)(struct ffa_device *dev,
- struct ffa_mem_ops_args *args);
+ int (*memory_share)(struct ffa_mem_ops_args *args);
+ int (*memory_lend)(struct ffa_mem_ops_args *args);
};
#endif /* _LINUX_ARM_FFA_H */
--
2.37.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 07/10] firmware: arm_ffa: Rename ffa_dev_ops as ffa_ops
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-02 12:40 ` Sudeep Holla
-1 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen, Sumit Garg
Except the message APIs, all other APIs are ffa_device independent and can
be used without any associated ffa_device from a non ffa_driver.
In order to reflect the same, just rename ffa_dev_ops as ffa_ops to
avoid any confusion or to keep it simple.
Suggested-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/bus.c | 2 +-
drivers/firmware/arm_ffa/driver.c | 2 +-
drivers/tee/optee/ffa_abi.c | 14 +++++++-------
include/linux/arm_ffa.h | 8 ++++----
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c
index 69328041fbc3..99d439480612 100644
--- a/drivers/firmware/arm_ffa/bus.c
+++ b/drivers/firmware/arm_ffa/bus.c
@@ -168,7 +168,7 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev)
}
struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
- const struct ffa_dev_ops *ops)
+ const struct ffa_ops *ops)
{
int ret;
struct device *dev;
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index e4fd35773071..2532e0f16cc9 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -666,7 +666,7 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args)
return ffa_memory_ops(FFA_MEM_LEND, args);
}
-static const struct ffa_dev_ops ffa_ops = {
+static const struct ffa_ops ffa_ops = {
.api_version_get = ffa_api_version_get,
.partition_info_get = ffa_partition_info_get,
.mode_32bit_set = ffa_mode_32bit_set,
diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
index 7257b42d0545..2ce5b87dfb27 100644
--- a/drivers/tee/optee/ffa_abi.c
+++ b/drivers/tee/optee/ffa_abi.c
@@ -272,7 +272,7 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
- const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
+ const struct ffa_ops *ffa_ops = ffa_dev->ops;
struct ffa_mem_region_attributes mem_attr = {
.receiver = ffa_dev->vm_id,
.attrs = FFA_MEM_RW,
@@ -315,7 +315,7 @@ static int optee_ffa_shm_unregister(struct tee_context *ctx,
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
- const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
+ const struct ffa_ops *ffa_ops = ffa_dev->ops;
u64 global_handle = shm->sec_world_id;
struct ffa_send_direct_data data = {
.data0 = OPTEE_FFA_UNREGISTER_SHM,
@@ -342,7 +342,7 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
struct tee_shm *shm)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
- const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_dev->ops;
+ const struct ffa_ops *ffa_ops = optee->ffa.ffa_dev->ops;
u64 global_handle = shm->sec_world_id;
int rc;
@@ -530,7 +530,7 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
- const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
+ const struct ffa_ops *ffa_ops = ffa_dev->ops;
struct optee_call_waiter w;
u32 cmd = data->data0;
u32 w4 = data->data1;
@@ -652,7 +652,7 @@ static int optee_ffa_do_call_with_arg(struct tee_context *ctx,
*/
static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
- const struct ffa_dev_ops *ops)
+ const struct ffa_ops *ops)
{
struct ffa_send_direct_data data = { OPTEE_FFA_GET_API_VERSION };
int rc;
@@ -687,7 +687,7 @@ static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
}
static bool optee_ffa_exchange_caps(struct ffa_device *ffa_dev,
- const struct ffa_dev_ops *ops,
+ const struct ffa_ops *ops,
u32 *sec_caps,
unsigned int *rpc_param_count)
{
@@ -783,7 +783,7 @@ static void optee_ffa_remove(struct ffa_device *ffa_dev)
static int optee_ffa_probe(struct ffa_device *ffa_dev)
{
- const struct ffa_dev_ops *ffa_ops;
+ const struct ffa_ops *ffa_ops;
unsigned int rpc_param_count;
struct tee_shm_pool *pool;
struct tee_device *teedev;
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index eafab07c9f58..4c4b06783035 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -17,7 +17,7 @@ struct ffa_device {
bool mode_32bit;
uuid_t uuid;
struct device dev;
- const struct ffa_dev_ops *ops;
+ const struct ffa_ops *ops;
};
#define to_ffa_dev(d) container_of(d, struct ffa_device, dev)
@@ -49,7 +49,7 @@ static inline void *ffa_dev_get_drvdata(struct ffa_device *fdev)
#if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT)
struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
- const struct ffa_dev_ops *ops);
+ const struct ffa_ops *ops);
void ffa_device_unregister(struct ffa_device *ffa_dev);
int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
const char *mod_name);
@@ -59,7 +59,7 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev);
#else
static inline
struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
- const struct ffa_dev_ops *ops)
+ const struct ffa_ops *ops)
{
return NULL;
}
@@ -254,7 +254,7 @@ struct ffa_mem_ops_args {
struct ffa_mem_region_attributes *attrs;
};
-struct ffa_dev_ops {
+struct ffa_ops {
u32 (*api_version_get)(void);
int (*partition_info_get)(const char *uuid_str,
struct ffa_partition_info *buffer);
--
2.37.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 07/10] firmware: arm_ffa: Rename ffa_dev_ops as ffa_ops
@ 2022-09-02 12:40 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen, Sumit Garg
Except the message APIs, all other APIs are ffa_device independent and can
be used without any associated ffa_device from a non ffa_driver.
In order to reflect the same, just rename ffa_dev_ops as ffa_ops to
avoid any confusion or to keep it simple.
Suggested-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/bus.c | 2 +-
drivers/firmware/arm_ffa/driver.c | 2 +-
drivers/tee/optee/ffa_abi.c | 14 +++++++-------
include/linux/arm_ffa.h | 8 ++++----
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c
index 69328041fbc3..99d439480612 100644
--- a/drivers/firmware/arm_ffa/bus.c
+++ b/drivers/firmware/arm_ffa/bus.c
@@ -168,7 +168,7 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev)
}
struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
- const struct ffa_dev_ops *ops)
+ const struct ffa_ops *ops)
{
int ret;
struct device *dev;
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index e4fd35773071..2532e0f16cc9 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -666,7 +666,7 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args)
return ffa_memory_ops(FFA_MEM_LEND, args);
}
-static const struct ffa_dev_ops ffa_ops = {
+static const struct ffa_ops ffa_ops = {
.api_version_get = ffa_api_version_get,
.partition_info_get = ffa_partition_info_get,
.mode_32bit_set = ffa_mode_32bit_set,
diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
index 7257b42d0545..2ce5b87dfb27 100644
--- a/drivers/tee/optee/ffa_abi.c
+++ b/drivers/tee/optee/ffa_abi.c
@@ -272,7 +272,7 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
- const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
+ const struct ffa_ops *ffa_ops = ffa_dev->ops;
struct ffa_mem_region_attributes mem_attr = {
.receiver = ffa_dev->vm_id,
.attrs = FFA_MEM_RW,
@@ -315,7 +315,7 @@ static int optee_ffa_shm_unregister(struct tee_context *ctx,
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
- const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
+ const struct ffa_ops *ffa_ops = ffa_dev->ops;
u64 global_handle = shm->sec_world_id;
struct ffa_send_direct_data data = {
.data0 = OPTEE_FFA_UNREGISTER_SHM,
@@ -342,7 +342,7 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
struct tee_shm *shm)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
- const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_dev->ops;
+ const struct ffa_ops *ffa_ops = optee->ffa.ffa_dev->ops;
u64 global_handle = shm->sec_world_id;
int rc;
@@ -530,7 +530,7 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
- const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
+ const struct ffa_ops *ffa_ops = ffa_dev->ops;
struct optee_call_waiter w;
u32 cmd = data->data0;
u32 w4 = data->data1;
@@ -652,7 +652,7 @@ static int optee_ffa_do_call_with_arg(struct tee_context *ctx,
*/
static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
- const struct ffa_dev_ops *ops)
+ const struct ffa_ops *ops)
{
struct ffa_send_direct_data data = { OPTEE_FFA_GET_API_VERSION };
int rc;
@@ -687,7 +687,7 @@ static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
}
static bool optee_ffa_exchange_caps(struct ffa_device *ffa_dev,
- const struct ffa_dev_ops *ops,
+ const struct ffa_ops *ops,
u32 *sec_caps,
unsigned int *rpc_param_count)
{
@@ -783,7 +783,7 @@ static void optee_ffa_remove(struct ffa_device *ffa_dev)
static int optee_ffa_probe(struct ffa_device *ffa_dev)
{
- const struct ffa_dev_ops *ffa_ops;
+ const struct ffa_ops *ffa_ops;
unsigned int rpc_param_count;
struct tee_shm_pool *pool;
struct tee_device *teedev;
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index eafab07c9f58..4c4b06783035 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -17,7 +17,7 @@ struct ffa_device {
bool mode_32bit;
uuid_t uuid;
struct device dev;
- const struct ffa_dev_ops *ops;
+ const struct ffa_ops *ops;
};
#define to_ffa_dev(d) container_of(d, struct ffa_device, dev)
@@ -49,7 +49,7 @@ static inline void *ffa_dev_get_drvdata(struct ffa_device *fdev)
#if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT)
struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
- const struct ffa_dev_ops *ops);
+ const struct ffa_ops *ops);
void ffa_device_unregister(struct ffa_device *ffa_dev);
int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
const char *mod_name);
@@ -59,7 +59,7 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev);
#else
static inline
struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
- const struct ffa_dev_ops *ops)
+ const struct ffa_ops *ops)
{
return NULL;
}
@@ -254,7 +254,7 @@ struct ffa_mem_ops_args {
struct ffa_mem_region_attributes *attrs;
};
-struct ffa_dev_ops {
+struct ffa_ops {
u32 (*api_version_get)(void);
int (*partition_info_get)(const char *uuid_str,
struct ffa_partition_info *buffer);
--
2.37.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 08/10] firmware: arm_ffa: Add v1.1 get_partition_info support
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-02 12:40 ` Sudeep Holla
-1 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
FF-A v1.1 adds support to discovery the UUIDs of the partitions that was
missing in v1.0 and which the driver workarounds by using UUIDs supplied
by the ffa_drivers.
Add the v1.1 get_partition_info support and disable the workaround if
the detected FF-A version is greater than v1.0.
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 42 +++++++++++++++++++++++++------
include/linux/arm_ffa.h | 1 +
2 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 2532e0f16cc9..dd6ab2f81580 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -264,18 +264,24 @@ static int ffa_rxtx_unmap(u16 vm_id)
return 0;
}
+#define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0)
+
/* buffer must be sizeof(struct ffa_partition_info) * num_partitions */
static int
__ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
struct ffa_partition_info *buffer, int num_partitions)
{
- int count;
+ int idx, count, flags = 0, size;
ffa_value_t partition_info;
+ if (!buffer || !num_partitions) /* Just get the count for now */
+ flags = PARTITION_INFO_GET_RETURN_COUNT_ONLY;
+
mutex_lock(&drv_info->rx_lock);
invoke_ffa_fn((ffa_value_t){
.a0 = FFA_PARTITION_INFO_GET,
.a1 = uuid0, .a2 = uuid1, .a3 = uuid2, .a4 = uuid3,
+ .a5 = flags,
}, &partition_info);
if (partition_info.a0 == FFA_ERROR) {
@@ -285,8 +291,18 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
count = partition_info.a2;
+ if (drv_info->version > FFA_VERSION_1_0) {
+ size = partition_info.a3;
+ if (size > sizeof(*buffer))
+ size = sizeof(*buffer);
+ } else {
+ size = 8; /* FFA_VERSION_1_0 lacks size in the response */
+ }
+
if (buffer && count <= num_partitions)
- memcpy(buffer, drv_info->rx_buffer, sizeof(*buffer) * count);
+ for (idx = 0; idx < count; idx++)
+ memcpy(buffer + idx, drv_info->rx_buffer + idx * size,
+ size);
ffa_rx_release();
@@ -681,6 +697,14 @@ void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
int count, idx;
struct ffa_partition_info *pbuf, *tpbuf;
+ /*
+ * FF-A v1.1 provides UUID for each partition as part of the discovery
+ * API, the discovered UUID must be populated in the device's UUID and
+ * there is no need to copy the same from the driver table.
+ */
+ if (drv_info->version > FFA_VERSION_1_0)
+ return;
+
count = ffa_partition_probe(uuid, &pbuf);
if (count <= 0)
return;
@@ -694,6 +718,7 @@ void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
static void ffa_setup_partitions(void)
{
int count, idx;
+ uuid_t uuid;
struct ffa_device *ffa_dev;
struct ffa_partition_info *pbuf, *tpbuf;
@@ -704,14 +729,15 @@ static void ffa_setup_partitions(void)
}
for (idx = 0, tpbuf = pbuf; idx < count; idx++, tpbuf++) {
- /* Note that the &uuid_null parameter will require
+ import_uuid(&uuid, (u8 *)tpbuf->uuid);
+
+ /* Note that if the UUID will be uuid_null, that will require
* ffa_device_match() to find the UUID of this partition id
- * with help of ffa_device_match_uuid(). Once the FF-A spec
- * is updated to provide correct UUID here for each partition
- * as part of the discovery API, we need to pass the
- * discovered UUID here instead.
+ * with help of ffa_device_match_uuid(). FF-A v1.1 and above
+ * provides UUID here for each partition as part of the
+ * discovery API and the same is passed.
*/
- ffa_dev = ffa_device_register(&uuid_null, tpbuf->id, &ffa_ops);
+ ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_ops);
if (!ffa_dev) {
pr_err("%s: failed to register partition ID 0x%x\n",
__func__, tpbuf->id);
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index 4c4b06783035..09567ffd1f49 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -107,6 +107,7 @@ struct ffa_partition_info {
/* partition can send and receive indirect messages. */
#define FFA_PARTITION_INDIRECT_MSG BIT(2)
u32 properties;
+ u32 uuid[4];
};
/* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registers */
--
2.37.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 08/10] firmware: arm_ffa: Add v1.1 get_partition_info support
@ 2022-09-02 12:40 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
FF-A v1.1 adds support to discovery the UUIDs of the partitions that was
missing in v1.0 and which the driver workarounds by using UUIDs supplied
by the ffa_drivers.
Add the v1.1 get_partition_info support and disable the workaround if
the detected FF-A version is greater than v1.0.
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 42 +++++++++++++++++++++++++------
include/linux/arm_ffa.h | 1 +
2 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 2532e0f16cc9..dd6ab2f81580 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -264,18 +264,24 @@ static int ffa_rxtx_unmap(u16 vm_id)
return 0;
}
+#define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0)
+
/* buffer must be sizeof(struct ffa_partition_info) * num_partitions */
static int
__ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
struct ffa_partition_info *buffer, int num_partitions)
{
- int count;
+ int idx, count, flags = 0, size;
ffa_value_t partition_info;
+ if (!buffer || !num_partitions) /* Just get the count for now */
+ flags = PARTITION_INFO_GET_RETURN_COUNT_ONLY;
+
mutex_lock(&drv_info->rx_lock);
invoke_ffa_fn((ffa_value_t){
.a0 = FFA_PARTITION_INFO_GET,
.a1 = uuid0, .a2 = uuid1, .a3 = uuid2, .a4 = uuid3,
+ .a5 = flags,
}, &partition_info);
if (partition_info.a0 == FFA_ERROR) {
@@ -285,8 +291,18 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
count = partition_info.a2;
+ if (drv_info->version > FFA_VERSION_1_0) {
+ size = partition_info.a3;
+ if (size > sizeof(*buffer))
+ size = sizeof(*buffer);
+ } else {
+ size = 8; /* FFA_VERSION_1_0 lacks size in the response */
+ }
+
if (buffer && count <= num_partitions)
- memcpy(buffer, drv_info->rx_buffer, sizeof(*buffer) * count);
+ for (idx = 0; idx < count; idx++)
+ memcpy(buffer + idx, drv_info->rx_buffer + idx * size,
+ size);
ffa_rx_release();
@@ -681,6 +697,14 @@ void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
int count, idx;
struct ffa_partition_info *pbuf, *tpbuf;
+ /*
+ * FF-A v1.1 provides UUID for each partition as part of the discovery
+ * API, the discovered UUID must be populated in the device's UUID and
+ * there is no need to copy the same from the driver table.
+ */
+ if (drv_info->version > FFA_VERSION_1_0)
+ return;
+
count = ffa_partition_probe(uuid, &pbuf);
if (count <= 0)
return;
@@ -694,6 +718,7 @@ void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
static void ffa_setup_partitions(void)
{
int count, idx;
+ uuid_t uuid;
struct ffa_device *ffa_dev;
struct ffa_partition_info *pbuf, *tpbuf;
@@ -704,14 +729,15 @@ static void ffa_setup_partitions(void)
}
for (idx = 0, tpbuf = pbuf; idx < count; idx++, tpbuf++) {
- /* Note that the &uuid_null parameter will require
+ import_uuid(&uuid, (u8 *)tpbuf->uuid);
+
+ /* Note that if the UUID will be uuid_null, that will require
* ffa_device_match() to find the UUID of this partition id
- * with help of ffa_device_match_uuid(). Once the FF-A spec
- * is updated to provide correct UUID here for each partition
- * as part of the discovery API, we need to pass the
- * discovered UUID here instead.
+ * with help of ffa_device_match_uuid(). FF-A v1.1 and above
+ * provides UUID here for each partition as part of the
+ * discovery API and the same is passed.
*/
- ffa_dev = ffa_device_register(&uuid_null, tpbuf->id, &ffa_ops);
+ ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_ops);
if (!ffa_dev) {
pr_err("%s: failed to register partition ID 0x%x\n",
__func__, tpbuf->id);
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index 4c4b06783035..09567ffd1f49 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -107,6 +107,7 @@ struct ffa_partition_info {
/* partition can send and receive indirect messages. */
#define FFA_PARTITION_INDIRECT_MSG BIT(2)
u32 properties;
+ u32 uuid[4];
};
/* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registers */
--
2.37.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 09/10] firmware: arm_ffa: Set up 32bit execution mode flag using partiion property
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-02 12:40 ` Sudeep Holla
-1 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
FF-A v1.1 adds a flag in the partition properties to indicate if the
partition runs in the AArch32 or AArch64 execution state. Use the same
to set-up the 32-bit execution flag mode in the ffa_dev automatically
and ignore any requests to do the same from the ffa_driver.
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 13 ++++++++++++-
include/linux/arm_ffa.h | 2 ++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index dd6ab2f81580..dbbe15592173 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -647,11 +647,19 @@ static int ffa_partition_info_get(const char *uuid_str,
return 0;
}
-static void ffa_mode_32bit_set(struct ffa_device *dev)
+static void _ffa_mode_32bit_set(struct ffa_device *dev)
{
dev->mode_32bit = true;
}
+static void ffa_mode_32bit_set(struct ffa_device *dev)
+{
+ if (drv_info->version > FFA_VERSION_1_0)
+ return;
+
+ _ffa_mode_32bit_set(dev);
+}
+
static int ffa_sync_send_receive(struct ffa_device *dev,
struct ffa_send_direct_data *data)
{
@@ -743,6 +751,9 @@ static void ffa_setup_partitions(void)
__func__, tpbuf->id);
continue;
}
+
+ if (tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)
+ _ffa_mode_32bit_set(ffa_dev);
}
kfree(pbuf);
}
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index 09567ffd1f49..5964b6104996 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -106,6 +106,8 @@ struct ffa_partition_info {
#define FFA_PARTITION_DIRECT_SEND BIT(1)
/* partition can send and receive indirect messages. */
#define FFA_PARTITION_INDIRECT_MSG BIT(2)
+/* partition runs in the AArch64 execution state. */
+#define FFA_PARTITION_AARCH64_EXEC BIT(8)
u32 properties;
u32 uuid[4];
};
--
2.37.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 09/10] firmware: arm_ffa: Set up 32bit execution mode flag using partiion property
@ 2022-09-02 12:40 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
FF-A v1.1 adds a flag in the partition properties to indicate if the
partition runs in the AArch32 or AArch64 execution state. Use the same
to set-up the 32-bit execution flag mode in the ffa_dev automatically
and ignore any requests to do the same from the ffa_driver.
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 13 ++++++++++++-
include/linux/arm_ffa.h | 2 ++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index dd6ab2f81580..dbbe15592173 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -647,11 +647,19 @@ static int ffa_partition_info_get(const char *uuid_str,
return 0;
}
-static void ffa_mode_32bit_set(struct ffa_device *dev)
+static void _ffa_mode_32bit_set(struct ffa_device *dev)
{
dev->mode_32bit = true;
}
+static void ffa_mode_32bit_set(struct ffa_device *dev)
+{
+ if (drv_info->version > FFA_VERSION_1_0)
+ return;
+
+ _ffa_mode_32bit_set(dev);
+}
+
static int ffa_sync_send_receive(struct ffa_device *dev,
struct ffa_send_direct_data *data)
{
@@ -743,6 +751,9 @@ static void ffa_setup_partitions(void)
__func__, tpbuf->id);
continue;
}
+
+ if (tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)
+ _ffa_mode_32bit_set(ffa_dev);
}
kfree(pbuf);
}
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index 09567ffd1f49..5964b6104996 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -106,6 +106,8 @@ struct ffa_partition_info {
#define FFA_PARTITION_DIRECT_SEND BIT(1)
/* partition can send and receive indirect messages. */
#define FFA_PARTITION_INDIRECT_MSG BIT(2)
+/* partition runs in the AArch64 execution state. */
+#define FFA_PARTITION_AARCH64_EXEC BIT(8)
u32 properties;
u32 uuid[4];
};
--
2.37.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 10/10] firmware: arm_ffa: Split up ffa_ops into info, message and memory operations
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-02 12:40 ` Sudeep Holla
-1 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
In preparation to make memory operations accessible for a non
ffa_driver/device, it is better to split the ffa_ops into different
categories of operations: info, message and memory. The info and memory
are ffa_device independent and can be used without any associated
ffa_device from a non ffa_driver.
However, we don't export these info and memory APIs yet without the user.
The first users of these APIs can export them.
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 16 +++++++++++++--
drivers/tee/optee/ffa_abi.c | 33 +++++++++++++++++--------------
include/linux/arm_ffa.h | 14 ++++++++++++-
3 files changed, 45 insertions(+), 18 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index dbbe15592173..639ae3911387 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -690,16 +690,28 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args)
return ffa_memory_ops(FFA_MEM_LEND, args);
}
-static const struct ffa_ops ffa_ops = {
+static const struct ffa_info_ops ffa_drv_info_ops = {
.api_version_get = ffa_api_version_get,
.partition_info_get = ffa_partition_info_get,
+};
+
+static const struct ffa_msg_ops ffa_drv_msg_ops = {
.mode_32bit_set = ffa_mode_32bit_set,
.sync_send_receive = ffa_sync_send_receive,
+};
+
+static const struct ffa_mem_ops ffa_drv_mem_ops = {
.memory_reclaim = ffa_memory_reclaim,
.memory_share = ffa_memory_share,
.memory_lend = ffa_memory_lend,
};
+static const struct ffa_ops ffa_drv_ops = {
+ .info_ops = &ffa_drv_info_ops,
+ .msg_ops = &ffa_drv_msg_ops,
+ .mem_ops = &ffa_drv_mem_ops,
+};
+
void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
{
int count, idx;
@@ -745,7 +757,7 @@ static void ffa_setup_partitions(void)
* provides UUID here for each partition as part of the
* discovery API and the same is passed.
*/
- ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_ops);
+ ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_drv_ops);
if (!ffa_dev) {
pr_err("%s: failed to register partition ID 0x%x\n",
__func__, tpbuf->id);
diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
index 2ce5b87dfb27..0828240f27e6 100644
--- a/drivers/tee/optee/ffa_abi.c
+++ b/drivers/tee/optee/ffa_abi.c
@@ -272,7 +272,7 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
- const struct ffa_ops *ffa_ops = ffa_dev->ops;
+ const struct ffa_mem_ops *mem_ops = ffa_dev->ops->mem_ops;
struct ffa_mem_region_attributes mem_attr = {
.receiver = ffa_dev->vm_id,
.attrs = FFA_MEM_RW,
@@ -294,14 +294,14 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
if (rc)
return rc;
args.sg = sgt.sgl;
- rc = ffa_ops->memory_share(&args);
+ rc = mem_ops->memory_share(&args);
sg_free_table(&sgt);
if (rc)
return rc;
rc = optee_shm_add_ffa_handle(optee, shm, args.g_handle);
if (rc) {
- ffa_ops->memory_reclaim(args.g_handle, 0);
+ mem_ops->memory_reclaim(args.g_handle, 0);
return rc;
}
@@ -315,7 +315,8 @@ static int optee_ffa_shm_unregister(struct tee_context *ctx,
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
- const struct ffa_ops *ffa_ops = ffa_dev->ops;
+ const struct ffa_msg_ops *msg_ops = ffa_dev->ops->msg_ops;
+ const struct ffa_mem_ops *mem_ops = ffa_dev->ops->mem_ops;
u64 global_handle = shm->sec_world_id;
struct ffa_send_direct_data data = {
.data0 = OPTEE_FFA_UNREGISTER_SHM,
@@ -327,11 +328,11 @@ static int optee_ffa_shm_unregister(struct tee_context *ctx,
optee_shm_rem_ffa_handle(optee, global_handle);
shm->sec_world_id = 0;
- rc = ffa_ops->sync_send_receive(ffa_dev, &data);
+ rc = msg_ops->sync_send_receive(ffa_dev, &data);
if (rc)
pr_err("Unregister SHM id 0x%llx rc %d\n", global_handle, rc);
- rc = ffa_ops->memory_reclaim(global_handle, 0);
+ rc = mem_ops->memory_reclaim(global_handle, 0);
if (rc)
pr_err("mem_reclaim: 0x%llx %d", global_handle, rc);
@@ -342,7 +343,7 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
struct tee_shm *shm)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
- const struct ffa_ops *ffa_ops = optee->ffa.ffa_dev->ops;
+ const struct ffa_mem_ops *mem_ops;
u64 global_handle = shm->sec_world_id;
int rc;
@@ -353,7 +354,8 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
*/
optee_shm_rem_ffa_handle(optee, global_handle);
- rc = ffa_ops->memory_reclaim(global_handle, 0);
+ mem_ops = optee->ffa.ffa_dev->ops->mem_ops;
+ rc = mem_ops->memory_reclaim(global_handle, 0);
if (rc)
pr_err("mem_reclaim: 0x%llx %d", global_handle, rc);
@@ -530,7 +532,7 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
- const struct ffa_ops *ffa_ops = ffa_dev->ops;
+ const struct ffa_msg_ops *msg_ops = ffa_dev->ops->msg_ops;
struct optee_call_waiter w;
u32 cmd = data->data0;
u32 w4 = data->data1;
@@ -541,7 +543,7 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
/* Initialize waiter */
optee_cq_wait_init(&optee->call_queue, &w);
while (true) {
- rc = ffa_ops->sync_send_receive(ffa_dev, data);
+ rc = msg_ops->sync_send_receive(ffa_dev, data);
if (rc)
goto done;
@@ -576,7 +578,7 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
* OP-TEE has returned with a RPC request.
*
* Note that data->data4 (passed in register w7) is already
- * filled in by ffa_ops->sync_send_receive() returning
+ * filled in by ffa_mem_ops->sync_send_receive() returning
* above.
*/
cond_resched();
@@ -654,12 +656,13 @@ static int optee_ffa_do_call_with_arg(struct tee_context *ctx,
static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
const struct ffa_ops *ops)
{
+ const struct ffa_msg_ops *msg_ops = ops->msg_ops;
struct ffa_send_direct_data data = { OPTEE_FFA_GET_API_VERSION };
int rc;
- ops->mode_32bit_set(ffa_dev);
+ msg_ops->mode_32bit_set(ffa_dev);
- rc = ops->sync_send_receive(ffa_dev, &data);
+ rc = msg_ops->sync_send_receive(ffa_dev, &data);
if (rc) {
pr_err("Unexpected error %d\n", rc);
return false;
@@ -672,7 +675,7 @@ static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
}
data = (struct ffa_send_direct_data){ OPTEE_FFA_GET_OS_VERSION };
- rc = ops->sync_send_receive(ffa_dev, &data);
+ rc = msg_ops->sync_send_receive(ffa_dev, &data);
if (rc) {
pr_err("Unexpected error %d\n", rc);
return false;
@@ -694,7 +697,7 @@ static bool optee_ffa_exchange_caps(struct ffa_device *ffa_dev,
struct ffa_send_direct_data data = { OPTEE_FFA_EXCHANGE_CAPABILITIES };
int rc;
- rc = ops->sync_send_receive(ffa_dev, &data);
+ rc = ops->msg_ops->sync_send_receive(ffa_dev, &data);
if (rc) {
pr_err("Unexpected error %d", rc);
return false;
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index 5964b6104996..5f02d2e6b9d9 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -257,16 +257,28 @@ struct ffa_mem_ops_args {
struct ffa_mem_region_attributes *attrs;
};
-struct ffa_ops {
+struct ffa_info_ops {
u32 (*api_version_get)(void);
int (*partition_info_get)(const char *uuid_str,
struct ffa_partition_info *buffer);
+};
+
+struct ffa_msg_ops {
void (*mode_32bit_set)(struct ffa_device *dev);
int (*sync_send_receive)(struct ffa_device *dev,
struct ffa_send_direct_data *data);
+};
+
+struct ffa_mem_ops {
int (*memory_reclaim)(u64 g_handle, u32 flags);
int (*memory_share)(struct ffa_mem_ops_args *args);
int (*memory_lend)(struct ffa_mem_ops_args *args);
};
+struct ffa_ops {
+ const struct ffa_info_ops *info_ops;
+ const struct ffa_msg_ops *msg_ops;
+ const struct ffa_mem_ops *mem_ops;
+};
+
#endif /* _LINUX_ARM_FFA_H */
--
2.37.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH v2 10/10] firmware: arm_ffa: Split up ffa_ops into info, message and memory operations
@ 2022-09-02 12:40 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-02 12:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, op-tee
Cc: Sudeep Holla, Marc Bonnici, Achin Gupta, Jens Wiklander,
Valentin Laurent, Lukas Hanel, Coboy Chen
In preparation to make memory operations accessible for a non
ffa_driver/device, it is better to split the ffa_ops into different
categories of operations: info, message and memory. The info and memory
are ffa_device independent and can be used without any associated
ffa_device from a non ffa_driver.
However, we don't export these info and memory APIs yet without the user.
The first users of these APIs can export them.
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_ffa/driver.c | 16 +++++++++++++--
drivers/tee/optee/ffa_abi.c | 33 +++++++++++++++++--------------
include/linux/arm_ffa.h | 14 ++++++++++++-
3 files changed, 45 insertions(+), 18 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index dbbe15592173..639ae3911387 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -690,16 +690,28 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args)
return ffa_memory_ops(FFA_MEM_LEND, args);
}
-static const struct ffa_ops ffa_ops = {
+static const struct ffa_info_ops ffa_drv_info_ops = {
.api_version_get = ffa_api_version_get,
.partition_info_get = ffa_partition_info_get,
+};
+
+static const struct ffa_msg_ops ffa_drv_msg_ops = {
.mode_32bit_set = ffa_mode_32bit_set,
.sync_send_receive = ffa_sync_send_receive,
+};
+
+static const struct ffa_mem_ops ffa_drv_mem_ops = {
.memory_reclaim = ffa_memory_reclaim,
.memory_share = ffa_memory_share,
.memory_lend = ffa_memory_lend,
};
+static const struct ffa_ops ffa_drv_ops = {
+ .info_ops = &ffa_drv_info_ops,
+ .msg_ops = &ffa_drv_msg_ops,
+ .mem_ops = &ffa_drv_mem_ops,
+};
+
void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
{
int count, idx;
@@ -745,7 +757,7 @@ static void ffa_setup_partitions(void)
* provides UUID here for each partition as part of the
* discovery API and the same is passed.
*/
- ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_ops);
+ ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_drv_ops);
if (!ffa_dev) {
pr_err("%s: failed to register partition ID 0x%x\n",
__func__, tpbuf->id);
diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
index 2ce5b87dfb27..0828240f27e6 100644
--- a/drivers/tee/optee/ffa_abi.c
+++ b/drivers/tee/optee/ffa_abi.c
@@ -272,7 +272,7 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
- const struct ffa_ops *ffa_ops = ffa_dev->ops;
+ const struct ffa_mem_ops *mem_ops = ffa_dev->ops->mem_ops;
struct ffa_mem_region_attributes mem_attr = {
.receiver = ffa_dev->vm_id,
.attrs = FFA_MEM_RW,
@@ -294,14 +294,14 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
if (rc)
return rc;
args.sg = sgt.sgl;
- rc = ffa_ops->memory_share(&args);
+ rc = mem_ops->memory_share(&args);
sg_free_table(&sgt);
if (rc)
return rc;
rc = optee_shm_add_ffa_handle(optee, shm, args.g_handle);
if (rc) {
- ffa_ops->memory_reclaim(args.g_handle, 0);
+ mem_ops->memory_reclaim(args.g_handle, 0);
return rc;
}
@@ -315,7 +315,8 @@ static int optee_ffa_shm_unregister(struct tee_context *ctx,
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
- const struct ffa_ops *ffa_ops = ffa_dev->ops;
+ const struct ffa_msg_ops *msg_ops = ffa_dev->ops->msg_ops;
+ const struct ffa_mem_ops *mem_ops = ffa_dev->ops->mem_ops;
u64 global_handle = shm->sec_world_id;
struct ffa_send_direct_data data = {
.data0 = OPTEE_FFA_UNREGISTER_SHM,
@@ -327,11 +328,11 @@ static int optee_ffa_shm_unregister(struct tee_context *ctx,
optee_shm_rem_ffa_handle(optee, global_handle);
shm->sec_world_id = 0;
- rc = ffa_ops->sync_send_receive(ffa_dev, &data);
+ rc = msg_ops->sync_send_receive(ffa_dev, &data);
if (rc)
pr_err("Unregister SHM id 0x%llx rc %d\n", global_handle, rc);
- rc = ffa_ops->memory_reclaim(global_handle, 0);
+ rc = mem_ops->memory_reclaim(global_handle, 0);
if (rc)
pr_err("mem_reclaim: 0x%llx %d", global_handle, rc);
@@ -342,7 +343,7 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
struct tee_shm *shm)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
- const struct ffa_ops *ffa_ops = optee->ffa.ffa_dev->ops;
+ const struct ffa_mem_ops *mem_ops;
u64 global_handle = shm->sec_world_id;
int rc;
@@ -353,7 +354,8 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
*/
optee_shm_rem_ffa_handle(optee, global_handle);
- rc = ffa_ops->memory_reclaim(global_handle, 0);
+ mem_ops = optee->ffa.ffa_dev->ops->mem_ops;
+ rc = mem_ops->memory_reclaim(global_handle, 0);
if (rc)
pr_err("mem_reclaim: 0x%llx %d", global_handle, rc);
@@ -530,7 +532,7 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
- const struct ffa_ops *ffa_ops = ffa_dev->ops;
+ const struct ffa_msg_ops *msg_ops = ffa_dev->ops->msg_ops;
struct optee_call_waiter w;
u32 cmd = data->data0;
u32 w4 = data->data1;
@@ -541,7 +543,7 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
/* Initialize waiter */
optee_cq_wait_init(&optee->call_queue, &w);
while (true) {
- rc = ffa_ops->sync_send_receive(ffa_dev, data);
+ rc = msg_ops->sync_send_receive(ffa_dev, data);
if (rc)
goto done;
@@ -576,7 +578,7 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
* OP-TEE has returned with a RPC request.
*
* Note that data->data4 (passed in register w7) is already
- * filled in by ffa_ops->sync_send_receive() returning
+ * filled in by ffa_mem_ops->sync_send_receive() returning
* above.
*/
cond_resched();
@@ -654,12 +656,13 @@ static int optee_ffa_do_call_with_arg(struct tee_context *ctx,
static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
const struct ffa_ops *ops)
{
+ const struct ffa_msg_ops *msg_ops = ops->msg_ops;
struct ffa_send_direct_data data = { OPTEE_FFA_GET_API_VERSION };
int rc;
- ops->mode_32bit_set(ffa_dev);
+ msg_ops->mode_32bit_set(ffa_dev);
- rc = ops->sync_send_receive(ffa_dev, &data);
+ rc = msg_ops->sync_send_receive(ffa_dev, &data);
if (rc) {
pr_err("Unexpected error %d\n", rc);
return false;
@@ -672,7 +675,7 @@ static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
}
data = (struct ffa_send_direct_data){ OPTEE_FFA_GET_OS_VERSION };
- rc = ops->sync_send_receive(ffa_dev, &data);
+ rc = msg_ops->sync_send_receive(ffa_dev, &data);
if (rc) {
pr_err("Unexpected error %d\n", rc);
return false;
@@ -694,7 +697,7 @@ static bool optee_ffa_exchange_caps(struct ffa_device *ffa_dev,
struct ffa_send_direct_data data = { OPTEE_FFA_EXCHANGE_CAPABILITIES };
int rc;
- rc = ops->sync_send_receive(ffa_dev, &data);
+ rc = ops->msg_ops->sync_send_receive(ffa_dev, &data);
if (rc) {
pr_err("Unexpected error %d", rc);
return false;
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index 5964b6104996..5f02d2e6b9d9 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -257,16 +257,28 @@ struct ffa_mem_ops_args {
struct ffa_mem_region_attributes *attrs;
};
-struct ffa_ops {
+struct ffa_info_ops {
u32 (*api_version_get)(void);
int (*partition_info_get)(const char *uuid_str,
struct ffa_partition_info *buffer);
+};
+
+struct ffa_msg_ops {
void (*mode_32bit_set)(struct ffa_device *dev);
int (*sync_send_receive)(struct ffa_device *dev,
struct ffa_send_direct_data *data);
+};
+
+struct ffa_mem_ops {
int (*memory_reclaim)(u64 g_handle, u32 flags);
int (*memory_share)(struct ffa_mem_ops_args *args);
int (*memory_lend)(struct ffa_mem_ops_args *args);
};
+struct ffa_ops {
+ const struct ffa_info_ops *info_ops;
+ const struct ffa_msg_ops *msg_ops;
+ const struct ffa_mem_ops *mem_ops;
+};
+
#endif /* _LINUX_ARM_FFA_H */
--
2.37.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v2 07/10] firmware: arm_ffa: Rename ffa_dev_ops as ffa_ops
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-05 7:20 ` Sumit Garg
-1 siblings, 0 replies; 40+ messages in thread
From: Sumit Garg @ 2022-09-05 7:20 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Achin Gupta, Jens Wiklander, Valentin Laurent, Lukas Hanel,
Coboy Chen
On Fri, 2 Sept 2022 at 18:10, Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> Except the message APIs, all other APIs are ffa_device independent and can
> be used without any associated ffa_device from a non ffa_driver.
>
> In order to reflect the same, just rename ffa_dev_ops as ffa_ops to
> avoid any confusion or to keep it simple.
>
> Suggested-by: Sumit Garg <sumit.garg@linaro.org>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/arm_ffa/bus.c | 2 +-
> drivers/firmware/arm_ffa/driver.c | 2 +-
> drivers/tee/optee/ffa_abi.c | 14 +++++++-------
> include/linux/arm_ffa.h | 8 ++++----
> 4 files changed, 13 insertions(+), 13 deletions(-)
>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
-Sumit
> diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c
> index 69328041fbc3..99d439480612 100644
> --- a/drivers/firmware/arm_ffa/bus.c
> +++ b/drivers/firmware/arm_ffa/bus.c
> @@ -168,7 +168,7 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev)
> }
>
> struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
> - const struct ffa_dev_ops *ops)
> + const struct ffa_ops *ops)
> {
> int ret;
> struct device *dev;
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index e4fd35773071..2532e0f16cc9 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -666,7 +666,7 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args)
> return ffa_memory_ops(FFA_MEM_LEND, args);
> }
>
> -static const struct ffa_dev_ops ffa_ops = {
> +static const struct ffa_ops ffa_ops = {
> .api_version_get = ffa_api_version_get,
> .partition_info_get = ffa_partition_info_get,
> .mode_32bit_set = ffa_mode_32bit_set,
> diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
> index 7257b42d0545..2ce5b87dfb27 100644
> --- a/drivers/tee/optee/ffa_abi.c
> +++ b/drivers/tee/optee/ffa_abi.c
> @@ -272,7 +272,7 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
> - const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = ffa_dev->ops;
> struct ffa_mem_region_attributes mem_attr = {
> .receiver = ffa_dev->vm_id,
> .attrs = FFA_MEM_RW,
> @@ -315,7 +315,7 @@ static int optee_ffa_shm_unregister(struct tee_context *ctx,
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
> - const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = ffa_dev->ops;
> u64 global_handle = shm->sec_world_id;
> struct ffa_send_direct_data data = {
> .data0 = OPTEE_FFA_UNREGISTER_SHM,
> @@ -342,7 +342,7 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
> struct tee_shm *shm)
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> - const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = optee->ffa.ffa_dev->ops;
> u64 global_handle = shm->sec_world_id;
> int rc;
>
> @@ -530,7 +530,7 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
> - const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = ffa_dev->ops;
> struct optee_call_waiter w;
> u32 cmd = data->data0;
> u32 w4 = data->data1;
> @@ -652,7 +652,7 @@ static int optee_ffa_do_call_with_arg(struct tee_context *ctx,
> */
>
> static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
> - const struct ffa_dev_ops *ops)
> + const struct ffa_ops *ops)
> {
> struct ffa_send_direct_data data = { OPTEE_FFA_GET_API_VERSION };
> int rc;
> @@ -687,7 +687,7 @@ static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
> }
>
> static bool optee_ffa_exchange_caps(struct ffa_device *ffa_dev,
> - const struct ffa_dev_ops *ops,
> + const struct ffa_ops *ops,
> u32 *sec_caps,
> unsigned int *rpc_param_count)
> {
> @@ -783,7 +783,7 @@ static void optee_ffa_remove(struct ffa_device *ffa_dev)
>
> static int optee_ffa_probe(struct ffa_device *ffa_dev)
> {
> - const struct ffa_dev_ops *ffa_ops;
> + const struct ffa_ops *ffa_ops;
> unsigned int rpc_param_count;
> struct tee_shm_pool *pool;
> struct tee_device *teedev;
> diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
> index eafab07c9f58..4c4b06783035 100644
> --- a/include/linux/arm_ffa.h
> +++ b/include/linux/arm_ffa.h
> @@ -17,7 +17,7 @@ struct ffa_device {
> bool mode_32bit;
> uuid_t uuid;
> struct device dev;
> - const struct ffa_dev_ops *ops;
> + const struct ffa_ops *ops;
> };
>
> #define to_ffa_dev(d) container_of(d, struct ffa_device, dev)
> @@ -49,7 +49,7 @@ static inline void *ffa_dev_get_drvdata(struct ffa_device *fdev)
>
> #if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT)
> struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
> - const struct ffa_dev_ops *ops);
> + const struct ffa_ops *ops);
> void ffa_device_unregister(struct ffa_device *ffa_dev);
> int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
> const char *mod_name);
> @@ -59,7 +59,7 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev);
> #else
> static inline
> struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
> - const struct ffa_dev_ops *ops)
> + const struct ffa_ops *ops)
> {
> return NULL;
> }
> @@ -254,7 +254,7 @@ struct ffa_mem_ops_args {
> struct ffa_mem_region_attributes *attrs;
> };
>
> -struct ffa_dev_ops {
> +struct ffa_ops {
> u32 (*api_version_get)(void);
> int (*partition_info_get)(const char *uuid_str,
> struct ffa_partition_info *buffer);
> --
> 2.37.3
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 07/10] firmware: arm_ffa: Rename ffa_dev_ops as ffa_ops
@ 2022-09-05 7:20 ` Sumit Garg
0 siblings, 0 replies; 40+ messages in thread
From: Sumit Garg @ 2022-09-05 7:20 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Achin Gupta, Jens Wiklander, Valentin Laurent, Lukas Hanel,
Coboy Chen
On Fri, 2 Sept 2022 at 18:10, Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> Except the message APIs, all other APIs are ffa_device independent and can
> be used without any associated ffa_device from a non ffa_driver.
>
> In order to reflect the same, just rename ffa_dev_ops as ffa_ops to
> avoid any confusion or to keep it simple.
>
> Suggested-by: Sumit Garg <sumit.garg@linaro.org>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/arm_ffa/bus.c | 2 +-
> drivers/firmware/arm_ffa/driver.c | 2 +-
> drivers/tee/optee/ffa_abi.c | 14 +++++++-------
> include/linux/arm_ffa.h | 8 ++++----
> 4 files changed, 13 insertions(+), 13 deletions(-)
>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
-Sumit
> diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c
> index 69328041fbc3..99d439480612 100644
> --- a/drivers/firmware/arm_ffa/bus.c
> +++ b/drivers/firmware/arm_ffa/bus.c
> @@ -168,7 +168,7 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev)
> }
>
> struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
> - const struct ffa_dev_ops *ops)
> + const struct ffa_ops *ops)
> {
> int ret;
> struct device *dev;
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index e4fd35773071..2532e0f16cc9 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -666,7 +666,7 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args)
> return ffa_memory_ops(FFA_MEM_LEND, args);
> }
>
> -static const struct ffa_dev_ops ffa_ops = {
> +static const struct ffa_ops ffa_ops = {
> .api_version_get = ffa_api_version_get,
> .partition_info_get = ffa_partition_info_get,
> .mode_32bit_set = ffa_mode_32bit_set,
> diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
> index 7257b42d0545..2ce5b87dfb27 100644
> --- a/drivers/tee/optee/ffa_abi.c
> +++ b/drivers/tee/optee/ffa_abi.c
> @@ -272,7 +272,7 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
> - const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = ffa_dev->ops;
> struct ffa_mem_region_attributes mem_attr = {
> .receiver = ffa_dev->vm_id,
> .attrs = FFA_MEM_RW,
> @@ -315,7 +315,7 @@ static int optee_ffa_shm_unregister(struct tee_context *ctx,
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
> - const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = ffa_dev->ops;
> u64 global_handle = shm->sec_world_id;
> struct ffa_send_direct_data data = {
> .data0 = OPTEE_FFA_UNREGISTER_SHM,
> @@ -342,7 +342,7 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
> struct tee_shm *shm)
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> - const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = optee->ffa.ffa_dev->ops;
> u64 global_handle = shm->sec_world_id;
> int rc;
>
> @@ -530,7 +530,7 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
> - const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = ffa_dev->ops;
> struct optee_call_waiter w;
> u32 cmd = data->data0;
> u32 w4 = data->data1;
> @@ -652,7 +652,7 @@ static int optee_ffa_do_call_with_arg(struct tee_context *ctx,
> */
>
> static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
> - const struct ffa_dev_ops *ops)
> + const struct ffa_ops *ops)
> {
> struct ffa_send_direct_data data = { OPTEE_FFA_GET_API_VERSION };
> int rc;
> @@ -687,7 +687,7 @@ static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
> }
>
> static bool optee_ffa_exchange_caps(struct ffa_device *ffa_dev,
> - const struct ffa_dev_ops *ops,
> + const struct ffa_ops *ops,
> u32 *sec_caps,
> unsigned int *rpc_param_count)
> {
> @@ -783,7 +783,7 @@ static void optee_ffa_remove(struct ffa_device *ffa_dev)
>
> static int optee_ffa_probe(struct ffa_device *ffa_dev)
> {
> - const struct ffa_dev_ops *ffa_ops;
> + const struct ffa_ops *ffa_ops;
> unsigned int rpc_param_count;
> struct tee_shm_pool *pool;
> struct tee_device *teedev;
> diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
> index eafab07c9f58..4c4b06783035 100644
> --- a/include/linux/arm_ffa.h
> +++ b/include/linux/arm_ffa.h
> @@ -17,7 +17,7 @@ struct ffa_device {
> bool mode_32bit;
> uuid_t uuid;
> struct device dev;
> - const struct ffa_dev_ops *ops;
> + const struct ffa_ops *ops;
> };
>
> #define to_ffa_dev(d) container_of(d, struct ffa_device, dev)
> @@ -49,7 +49,7 @@ static inline void *ffa_dev_get_drvdata(struct ffa_device *fdev)
>
> #if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT)
> struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
> - const struct ffa_dev_ops *ops);
> + const struct ffa_ops *ops);
> void ffa_device_unregister(struct ffa_device *ffa_dev);
> int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
> const char *mod_name);
> @@ -59,7 +59,7 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev);
> #else
> static inline
> struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
> - const struct ffa_dev_ops *ops)
> + const struct ffa_ops *ops)
> {
> return NULL;
> }
> @@ -254,7 +254,7 @@ struct ffa_mem_ops_args {
> struct ffa_mem_region_attributes *attrs;
> };
>
> -struct ffa_dev_ops {
> +struct ffa_ops {
> u32 (*api_version_get)(void);
> int (*partition_info_get)(const char *uuid_str,
> struct ffa_partition_info *buffer);
> --
> 2.37.3
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 00/10] firmware: arm_ffa: Refactoring and initial/minor v1.1 update
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-06 10:34 ` Sudeep Holla
-1 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-06 10:34 UTC (permalink / raw)
To: Jens Wiklander, linux-arm-kernel, linux-kernel, op-tee
Cc: Marc Bonnici, Achin Gupta, Valentin Laurent, Lukas Hanel, Coboy Chen
Hi Jens,
On Fri, Sep 02, 2022 at 01:40:22PM +0100, Sudeep Holla wrote:
> Hi All,
>
> This series is just some refactoring in preparation to add FF-A v1.1
> support. It doesn't have any memory layout or notification changes
> supported in v1.1 yet.
>
Thanks for the review of v1. There are some trivial changes that touches
optee files in v2 that needs official ack/review from you to take it
via my tree for v6.1. Please provide the same if you are OK especially
for patch 06,07/10 and even others if possible.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 00/10] firmware: arm_ffa: Refactoring and initial/minor v1.1 update
@ 2022-09-06 10:34 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-06 10:34 UTC (permalink / raw)
To: Jens Wiklander, linux-arm-kernel, linux-kernel, op-tee
Cc: Marc Bonnici, Achin Gupta, Valentin Laurent, Lukas Hanel, Coboy Chen
Hi Jens,
On Fri, Sep 02, 2022 at 01:40:22PM +0100, Sudeep Holla wrote:
> Hi All,
>
> This series is just some refactoring in preparation to add FF-A v1.1
> support. It doesn't have any memory layout or notification changes
> supported in v1.1 yet.
>
Thanks for the review of v1. There are some trivial changes that touches
optee files in v2 that needs official ack/review from you to take it
via my tree for v6.1. Please provide the same if you are OK especially
for patch 06,07/10 and even others if possible.
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 06/10] firmware: arm_ffa: Make memory apis ffa_device independent
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-07 8:27 ` Jens Wiklander
-1 siblings, 0 replies; 40+ messages in thread
From: Jens Wiklander @ 2022-09-07 8:27 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Achin Gupta, Valentin Laurent, Lukas Hanel, Coboy Chen
On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> There is a requirement to make memory APIs independent of the ffa_device.
> One of the use-case is to have a common memory driver that manages the
> memory for all the ffa_devices. That common memory driver won't be a
> ffa_driver or won't have any ffa_device associated with it. So having
> these memory APIs accessible without a ffa_device is needed and should
> be possible as most of these are handled by the partition manager(SPM
> or hypervisor).
>
> Drop the ffa_device argument to the memory APIs and make them ffa_device
> independent.
>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/arm_ffa/driver.c | 6 ++----
> drivers/tee/optee/ffa_abi.c | 2 +-
> include/linux/arm_ffa.h | 6 ++----
> 3 files changed, 5 insertions(+), 9 deletions(-)
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
>
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index 37a8ee304508..e4fd35773071 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -643,8 +643,7 @@ static int ffa_sync_send_receive(struct ffa_device *dev,
> dev->mode_32bit, data);
> }
>
> -static int
> -ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args)
> +static int ffa_memory_share(struct ffa_mem_ops_args *args)
> {
> if (drv_info->mem_ops_native)
> return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args);
> @@ -652,8 +651,7 @@ ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args)
> return ffa_memory_ops(FFA_MEM_SHARE, args);
> }
>
> -static int
> -ffa_memory_lend(struct ffa_device *dev, struct ffa_mem_ops_args *args)
> +static int ffa_memory_lend(struct ffa_mem_ops_args *args)
> {
> /* Note that upon a successful MEM_LEND request the caller
> * must ensure that the memory region specified is not accessed
> diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
> index 3d4079575ccd..7257b42d0545 100644
> --- a/drivers/tee/optee/ffa_abi.c
> +++ b/drivers/tee/optee/ffa_abi.c
> @@ -294,7 +294,7 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
> if (rc)
> return rc;
> args.sg = sgt.sgl;
> - rc = ffa_ops->memory_share(ffa_dev, &args);
> + rc = ffa_ops->memory_share(&args);
> sg_free_table(&sgt);
> if (rc)
> return rc;
> diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
> index 556f50f27fb1..eafab07c9f58 100644
> --- a/include/linux/arm_ffa.h
> +++ b/include/linux/arm_ffa.h
> @@ -262,10 +262,8 @@ struct ffa_dev_ops {
> int (*sync_send_receive)(struct ffa_device *dev,
> struct ffa_send_direct_data *data);
> int (*memory_reclaim)(u64 g_handle, u32 flags);
> - int (*memory_share)(struct ffa_device *dev,
> - struct ffa_mem_ops_args *args);
> - int (*memory_lend)(struct ffa_device *dev,
> - struct ffa_mem_ops_args *args);
> + int (*memory_share)(struct ffa_mem_ops_args *args);
> + int (*memory_lend)(struct ffa_mem_ops_args *args);
> };
>
> #endif /* _LINUX_ARM_FFA_H */
> --
> 2.37.3
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 06/10] firmware: arm_ffa: Make memory apis ffa_device independent
@ 2022-09-07 8:27 ` Jens Wiklander
0 siblings, 0 replies; 40+ messages in thread
From: Jens Wiklander @ 2022-09-07 8:27 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Achin Gupta, Valentin Laurent, Lukas Hanel, Coboy Chen
On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> There is a requirement to make memory APIs independent of the ffa_device.
> One of the use-case is to have a common memory driver that manages the
> memory for all the ffa_devices. That common memory driver won't be a
> ffa_driver or won't have any ffa_device associated with it. So having
> these memory APIs accessible without a ffa_device is needed and should
> be possible as most of these are handled by the partition manager(SPM
> or hypervisor).
>
> Drop the ffa_device argument to the memory APIs and make them ffa_device
> independent.
>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/arm_ffa/driver.c | 6 ++----
> drivers/tee/optee/ffa_abi.c | 2 +-
> include/linux/arm_ffa.h | 6 ++----
> 3 files changed, 5 insertions(+), 9 deletions(-)
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
>
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index 37a8ee304508..e4fd35773071 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -643,8 +643,7 @@ static int ffa_sync_send_receive(struct ffa_device *dev,
> dev->mode_32bit, data);
> }
>
> -static int
> -ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args)
> +static int ffa_memory_share(struct ffa_mem_ops_args *args)
> {
> if (drv_info->mem_ops_native)
> return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args);
> @@ -652,8 +651,7 @@ ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args)
> return ffa_memory_ops(FFA_MEM_SHARE, args);
> }
>
> -static int
> -ffa_memory_lend(struct ffa_device *dev, struct ffa_mem_ops_args *args)
> +static int ffa_memory_lend(struct ffa_mem_ops_args *args)
> {
> /* Note that upon a successful MEM_LEND request the caller
> * must ensure that the memory region specified is not accessed
> diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
> index 3d4079575ccd..7257b42d0545 100644
> --- a/drivers/tee/optee/ffa_abi.c
> +++ b/drivers/tee/optee/ffa_abi.c
> @@ -294,7 +294,7 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
> if (rc)
> return rc;
> args.sg = sgt.sgl;
> - rc = ffa_ops->memory_share(ffa_dev, &args);
> + rc = ffa_ops->memory_share(&args);
> sg_free_table(&sgt);
> if (rc)
> return rc;
> diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
> index 556f50f27fb1..eafab07c9f58 100644
> --- a/include/linux/arm_ffa.h
> +++ b/include/linux/arm_ffa.h
> @@ -262,10 +262,8 @@ struct ffa_dev_ops {
> int (*sync_send_receive)(struct ffa_device *dev,
> struct ffa_send_direct_data *data);
> int (*memory_reclaim)(u64 g_handle, u32 flags);
> - int (*memory_share)(struct ffa_device *dev,
> - struct ffa_mem_ops_args *args);
> - int (*memory_lend)(struct ffa_device *dev,
> - struct ffa_mem_ops_args *args);
> + int (*memory_share)(struct ffa_mem_ops_args *args);
> + int (*memory_lend)(struct ffa_mem_ops_args *args);
> };
>
> #endif /* _LINUX_ARM_FFA_H */
> --
> 2.37.3
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 07/10] firmware: arm_ffa: Rename ffa_dev_ops as ffa_ops
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-07 8:29 ` Jens Wiklander
-1 siblings, 0 replies; 40+ messages in thread
From: Jens Wiklander @ 2022-09-07 8:29 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Achin Gupta, Valentin Laurent, Lukas Hanel, Coboy Chen,
Sumit Garg
On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> Except the message APIs, all other APIs are ffa_device independent and can
> be used without any associated ffa_device from a non ffa_driver.
>
> In order to reflect the same, just rename ffa_dev_ops as ffa_ops to
> avoid any confusion or to keep it simple.
>
> Suggested-by: Sumit Garg <sumit.garg@linaro.org>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/arm_ffa/bus.c | 2 +-
> drivers/firmware/arm_ffa/driver.c | 2 +-
> drivers/tee/optee/ffa_abi.c | 14 +++++++-------
> include/linux/arm_ffa.h | 8 ++++----
> 4 files changed, 13 insertions(+), 13 deletions(-)
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
>
> diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c
> index 69328041fbc3..99d439480612 100644
> --- a/drivers/firmware/arm_ffa/bus.c
> +++ b/drivers/firmware/arm_ffa/bus.c
> @@ -168,7 +168,7 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev)
> }
>
> struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
> - const struct ffa_dev_ops *ops)
> + const struct ffa_ops *ops)
> {
> int ret;
> struct device *dev;
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index e4fd35773071..2532e0f16cc9 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -666,7 +666,7 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args)
> return ffa_memory_ops(FFA_MEM_LEND, args);
> }
>
> -static const struct ffa_dev_ops ffa_ops = {
> +static const struct ffa_ops ffa_ops = {
> .api_version_get = ffa_api_version_get,
> .partition_info_get = ffa_partition_info_get,
> .mode_32bit_set = ffa_mode_32bit_set,
> diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
> index 7257b42d0545..2ce5b87dfb27 100644
> --- a/drivers/tee/optee/ffa_abi.c
> +++ b/drivers/tee/optee/ffa_abi.c
> @@ -272,7 +272,7 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
> - const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = ffa_dev->ops;
> struct ffa_mem_region_attributes mem_attr = {
> .receiver = ffa_dev->vm_id,
> .attrs = FFA_MEM_RW,
> @@ -315,7 +315,7 @@ static int optee_ffa_shm_unregister(struct tee_context *ctx,
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
> - const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = ffa_dev->ops;
> u64 global_handle = shm->sec_world_id;
> struct ffa_send_direct_data data = {
> .data0 = OPTEE_FFA_UNREGISTER_SHM,
> @@ -342,7 +342,7 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
> struct tee_shm *shm)
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> - const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = optee->ffa.ffa_dev->ops;
> u64 global_handle = shm->sec_world_id;
> int rc;
>
> @@ -530,7 +530,7 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
> - const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = ffa_dev->ops;
> struct optee_call_waiter w;
> u32 cmd = data->data0;
> u32 w4 = data->data1;
> @@ -652,7 +652,7 @@ static int optee_ffa_do_call_with_arg(struct tee_context *ctx,
> */
>
> static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
> - const struct ffa_dev_ops *ops)
> + const struct ffa_ops *ops)
> {
> struct ffa_send_direct_data data = { OPTEE_FFA_GET_API_VERSION };
> int rc;
> @@ -687,7 +687,7 @@ static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
> }
>
> static bool optee_ffa_exchange_caps(struct ffa_device *ffa_dev,
> - const struct ffa_dev_ops *ops,
> + const struct ffa_ops *ops,
> u32 *sec_caps,
> unsigned int *rpc_param_count)
> {
> @@ -783,7 +783,7 @@ static void optee_ffa_remove(struct ffa_device *ffa_dev)
>
> static int optee_ffa_probe(struct ffa_device *ffa_dev)
> {
> - const struct ffa_dev_ops *ffa_ops;
> + const struct ffa_ops *ffa_ops;
> unsigned int rpc_param_count;
> struct tee_shm_pool *pool;
> struct tee_device *teedev;
> diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
> index eafab07c9f58..4c4b06783035 100644
> --- a/include/linux/arm_ffa.h
> +++ b/include/linux/arm_ffa.h
> @@ -17,7 +17,7 @@ struct ffa_device {
> bool mode_32bit;
> uuid_t uuid;
> struct device dev;
> - const struct ffa_dev_ops *ops;
> + const struct ffa_ops *ops;
> };
>
> #define to_ffa_dev(d) container_of(d, struct ffa_device, dev)
> @@ -49,7 +49,7 @@ static inline void *ffa_dev_get_drvdata(struct ffa_device *fdev)
>
> #if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT)
> struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
> - const struct ffa_dev_ops *ops);
> + const struct ffa_ops *ops);
> void ffa_device_unregister(struct ffa_device *ffa_dev);
> int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
> const char *mod_name);
> @@ -59,7 +59,7 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev);
> #else
> static inline
> struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
> - const struct ffa_dev_ops *ops)
> + const struct ffa_ops *ops)
> {
> return NULL;
> }
> @@ -254,7 +254,7 @@ struct ffa_mem_ops_args {
> struct ffa_mem_region_attributes *attrs;
> };
>
> -struct ffa_dev_ops {
> +struct ffa_ops {
> u32 (*api_version_get)(void);
> int (*partition_info_get)(const char *uuid_str,
> struct ffa_partition_info *buffer);
> --
> 2.37.3
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 07/10] firmware: arm_ffa: Rename ffa_dev_ops as ffa_ops
@ 2022-09-07 8:29 ` Jens Wiklander
0 siblings, 0 replies; 40+ messages in thread
From: Jens Wiklander @ 2022-09-07 8:29 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Achin Gupta, Valentin Laurent, Lukas Hanel, Coboy Chen,
Sumit Garg
On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> Except the message APIs, all other APIs are ffa_device independent and can
> be used without any associated ffa_device from a non ffa_driver.
>
> In order to reflect the same, just rename ffa_dev_ops as ffa_ops to
> avoid any confusion or to keep it simple.
>
> Suggested-by: Sumit Garg <sumit.garg@linaro.org>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/arm_ffa/bus.c | 2 +-
> drivers/firmware/arm_ffa/driver.c | 2 +-
> drivers/tee/optee/ffa_abi.c | 14 +++++++-------
> include/linux/arm_ffa.h | 8 ++++----
> 4 files changed, 13 insertions(+), 13 deletions(-)
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
>
> diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c
> index 69328041fbc3..99d439480612 100644
> --- a/drivers/firmware/arm_ffa/bus.c
> +++ b/drivers/firmware/arm_ffa/bus.c
> @@ -168,7 +168,7 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev)
> }
>
> struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
> - const struct ffa_dev_ops *ops)
> + const struct ffa_ops *ops)
> {
> int ret;
> struct device *dev;
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index e4fd35773071..2532e0f16cc9 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -666,7 +666,7 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args)
> return ffa_memory_ops(FFA_MEM_LEND, args);
> }
>
> -static const struct ffa_dev_ops ffa_ops = {
> +static const struct ffa_ops ffa_ops = {
> .api_version_get = ffa_api_version_get,
> .partition_info_get = ffa_partition_info_get,
> .mode_32bit_set = ffa_mode_32bit_set,
> diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
> index 7257b42d0545..2ce5b87dfb27 100644
> --- a/drivers/tee/optee/ffa_abi.c
> +++ b/drivers/tee/optee/ffa_abi.c
> @@ -272,7 +272,7 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
> - const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = ffa_dev->ops;
> struct ffa_mem_region_attributes mem_attr = {
> .receiver = ffa_dev->vm_id,
> .attrs = FFA_MEM_RW,
> @@ -315,7 +315,7 @@ static int optee_ffa_shm_unregister(struct tee_context *ctx,
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
> - const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = ffa_dev->ops;
> u64 global_handle = shm->sec_world_id;
> struct ffa_send_direct_data data = {
> .data0 = OPTEE_FFA_UNREGISTER_SHM,
> @@ -342,7 +342,7 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
> struct tee_shm *shm)
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> - const struct ffa_dev_ops *ffa_ops = optee->ffa.ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = optee->ffa.ffa_dev->ops;
> u64 global_handle = shm->sec_world_id;
> int rc;
>
> @@ -530,7 +530,7 @@ static int optee_ffa_yielding_call(struct tee_context *ctx,
> {
> struct optee *optee = tee_get_drvdata(ctx->teedev);
> struct ffa_device *ffa_dev = optee->ffa.ffa_dev;
> - const struct ffa_dev_ops *ffa_ops = ffa_dev->ops;
> + const struct ffa_ops *ffa_ops = ffa_dev->ops;
> struct optee_call_waiter w;
> u32 cmd = data->data0;
> u32 w4 = data->data1;
> @@ -652,7 +652,7 @@ static int optee_ffa_do_call_with_arg(struct tee_context *ctx,
> */
>
> static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
> - const struct ffa_dev_ops *ops)
> + const struct ffa_ops *ops)
> {
> struct ffa_send_direct_data data = { OPTEE_FFA_GET_API_VERSION };
> int rc;
> @@ -687,7 +687,7 @@ static bool optee_ffa_api_is_compatbile(struct ffa_device *ffa_dev,
> }
>
> static bool optee_ffa_exchange_caps(struct ffa_device *ffa_dev,
> - const struct ffa_dev_ops *ops,
> + const struct ffa_ops *ops,
> u32 *sec_caps,
> unsigned int *rpc_param_count)
> {
> @@ -783,7 +783,7 @@ static void optee_ffa_remove(struct ffa_device *ffa_dev)
>
> static int optee_ffa_probe(struct ffa_device *ffa_dev)
> {
> - const struct ffa_dev_ops *ffa_ops;
> + const struct ffa_ops *ffa_ops;
> unsigned int rpc_param_count;
> struct tee_shm_pool *pool;
> struct tee_device *teedev;
> diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
> index eafab07c9f58..4c4b06783035 100644
> --- a/include/linux/arm_ffa.h
> +++ b/include/linux/arm_ffa.h
> @@ -17,7 +17,7 @@ struct ffa_device {
> bool mode_32bit;
> uuid_t uuid;
> struct device dev;
> - const struct ffa_dev_ops *ops;
> + const struct ffa_ops *ops;
> };
>
> #define to_ffa_dev(d) container_of(d, struct ffa_device, dev)
> @@ -49,7 +49,7 @@ static inline void *ffa_dev_get_drvdata(struct ffa_device *fdev)
>
> #if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT)
> struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
> - const struct ffa_dev_ops *ops);
> + const struct ffa_ops *ops);
> void ffa_device_unregister(struct ffa_device *ffa_dev);
> int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
> const char *mod_name);
> @@ -59,7 +59,7 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev);
> #else
> static inline
> struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
> - const struct ffa_dev_ops *ops)
> + const struct ffa_ops *ops)
> {
> return NULL;
> }
> @@ -254,7 +254,7 @@ struct ffa_mem_ops_args {
> struct ffa_mem_region_attributes *attrs;
> };
>
> -struct ffa_dev_ops {
> +struct ffa_ops {
> u32 (*api_version_get)(void);
> int (*partition_info_get)(const char *uuid_str,
> struct ffa_partition_info *buffer);
> --
> 2.37.3
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 08/10] firmware: arm_ffa: Add v1.1 get_partition_info support
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-07 8:38 ` Jens Wiklander
-1 siblings, 0 replies; 40+ messages in thread
From: Jens Wiklander @ 2022-09-07 8:38 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Achin Gupta, Valentin Laurent, Lukas Hanel, Coboy Chen
On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> FF-A v1.1 adds support to discovery the UUIDs of the partitions that was
> missing in v1.0 and which the driver workarounds by using UUIDs supplied
> by the ffa_drivers.
>
> Add the v1.1 get_partition_info support and disable the workaround if
> the detected FF-A version is greater than v1.0.
>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/arm_ffa/driver.c | 42 +++++++++++++++++++++++++------
> include/linux/arm_ffa.h | 1 +
> 2 files changed, 35 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index 2532e0f16cc9..dd6ab2f81580 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -264,18 +264,24 @@ static int ffa_rxtx_unmap(u16 vm_id)
> return 0;
> }
>
> +#define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0)
> +
> /* buffer must be sizeof(struct ffa_partition_info) * num_partitions */
> static int
> __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
> struct ffa_partition_info *buffer, int num_partitions)
> {
> - int count;
> + int idx, count, flags = 0, size;
> ffa_value_t partition_info;
>
> + if (!buffer || !num_partitions) /* Just get the count for now */
> + flags = PARTITION_INFO_GET_RETURN_COUNT_ONLY;
> +
> mutex_lock(&drv_info->rx_lock);
> invoke_ffa_fn((ffa_value_t){
> .a0 = FFA_PARTITION_INFO_GET,
> .a1 = uuid0, .a2 = uuid1, .a3 = uuid2, .a4 = uuid3,
> + .a5 = flags,
> }, &partition_info);
>
> if (partition_info.a0 == FFA_ERROR) {
> @@ -285,8 +291,18 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
>
> count = partition_info.a2;
>
> + if (drv_info->version > FFA_VERSION_1_0) {
> + size = partition_info.a3;
> + if (size > sizeof(*buffer))
> + size = sizeof(*buffer);
Below when calculating the address in the source buffer with
"drv_info->rx_buffer + idx * size" you should use the size from
partition_info.a3 even if it's larger than sizeof(*buffer). The amount
of bytes to copy looks correct though. Does that make sense?
Cheers,
Jens
> + } else {
> + size = 8; /* FFA_VERSION_1_0 lacks size in the response */
> + }
> +
> if (buffer && count <= num_partitions)
> - memcpy(buffer, drv_info->rx_buffer, sizeof(*buffer) * count);
> + for (idx = 0; idx < count; idx++)
> + memcpy(buffer + idx, drv_info->rx_buffer + idx * size,
> + size);
>
> ffa_rx_release();
>
> @@ -681,6 +697,14 @@ void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
> int count, idx;
> struct ffa_partition_info *pbuf, *tpbuf;
>
> + /*
> + * FF-A v1.1 provides UUID for each partition as part of the discovery
> + * API, the discovered UUID must be populated in the device's UUID and
> + * there is no need to copy the same from the driver table.
> + */
> + if (drv_info->version > FFA_VERSION_1_0)
> + return;
> +
> count = ffa_partition_probe(uuid, &pbuf);
> if (count <= 0)
> return;
> @@ -694,6 +718,7 @@ void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
> static void ffa_setup_partitions(void)
> {
> int count, idx;
> + uuid_t uuid;
> struct ffa_device *ffa_dev;
> struct ffa_partition_info *pbuf, *tpbuf;
>
> @@ -704,14 +729,15 @@ static void ffa_setup_partitions(void)
> }
>
> for (idx = 0, tpbuf = pbuf; idx < count; idx++, tpbuf++) {
> - /* Note that the &uuid_null parameter will require
> + import_uuid(&uuid, (u8 *)tpbuf->uuid);
> +
> + /* Note that if the UUID will be uuid_null, that will require
> * ffa_device_match() to find the UUID of this partition id
> - * with help of ffa_device_match_uuid(). Once the FF-A spec
> - * is updated to provide correct UUID here for each partition
> - * as part of the discovery API, we need to pass the
> - * discovered UUID here instead.
> + * with help of ffa_device_match_uuid(). FF-A v1.1 and above
> + * provides UUID here for each partition as part of the
> + * discovery API and the same is passed.
> */
> - ffa_dev = ffa_device_register(&uuid_null, tpbuf->id, &ffa_ops);
> + ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_ops);
> if (!ffa_dev) {
> pr_err("%s: failed to register partition ID 0x%x\n",
> __func__, tpbuf->id);
> diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
> index 4c4b06783035..09567ffd1f49 100644
> --- a/include/linux/arm_ffa.h
> +++ b/include/linux/arm_ffa.h
> @@ -107,6 +107,7 @@ struct ffa_partition_info {
> /* partition can send and receive indirect messages. */
> #define FFA_PARTITION_INDIRECT_MSG BIT(2)
> u32 properties;
> + u32 uuid[4];
> };
>
> /* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registers */
> --
> 2.37.3
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 08/10] firmware: arm_ffa: Add v1.1 get_partition_info support
@ 2022-09-07 8:38 ` Jens Wiklander
0 siblings, 0 replies; 40+ messages in thread
From: Jens Wiklander @ 2022-09-07 8:38 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Achin Gupta, Valentin Laurent, Lukas Hanel, Coboy Chen
On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> FF-A v1.1 adds support to discovery the UUIDs of the partitions that was
> missing in v1.0 and which the driver workarounds by using UUIDs supplied
> by the ffa_drivers.
>
> Add the v1.1 get_partition_info support and disable the workaround if
> the detected FF-A version is greater than v1.0.
>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/arm_ffa/driver.c | 42 +++++++++++++++++++++++++------
> include/linux/arm_ffa.h | 1 +
> 2 files changed, 35 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index 2532e0f16cc9..dd6ab2f81580 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -264,18 +264,24 @@ static int ffa_rxtx_unmap(u16 vm_id)
> return 0;
> }
>
> +#define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0)
> +
> /* buffer must be sizeof(struct ffa_partition_info) * num_partitions */
> static int
> __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
> struct ffa_partition_info *buffer, int num_partitions)
> {
> - int count;
> + int idx, count, flags = 0, size;
> ffa_value_t partition_info;
>
> + if (!buffer || !num_partitions) /* Just get the count for now */
> + flags = PARTITION_INFO_GET_RETURN_COUNT_ONLY;
> +
> mutex_lock(&drv_info->rx_lock);
> invoke_ffa_fn((ffa_value_t){
> .a0 = FFA_PARTITION_INFO_GET,
> .a1 = uuid0, .a2 = uuid1, .a3 = uuid2, .a4 = uuid3,
> + .a5 = flags,
> }, &partition_info);
>
> if (partition_info.a0 == FFA_ERROR) {
> @@ -285,8 +291,18 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
>
> count = partition_info.a2;
>
> + if (drv_info->version > FFA_VERSION_1_0) {
> + size = partition_info.a3;
> + if (size > sizeof(*buffer))
> + size = sizeof(*buffer);
Below when calculating the address in the source buffer with
"drv_info->rx_buffer + idx * size" you should use the size from
partition_info.a3 even if it's larger than sizeof(*buffer). The amount
of bytes to copy looks correct though. Does that make sense?
Cheers,
Jens
> + } else {
> + size = 8; /* FFA_VERSION_1_0 lacks size in the response */
> + }
> +
> if (buffer && count <= num_partitions)
> - memcpy(buffer, drv_info->rx_buffer, sizeof(*buffer) * count);
> + for (idx = 0; idx < count; idx++)
> + memcpy(buffer + idx, drv_info->rx_buffer + idx * size,
> + size);
>
> ffa_rx_release();
>
> @@ -681,6 +697,14 @@ void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
> int count, idx;
> struct ffa_partition_info *pbuf, *tpbuf;
>
> + /*
> + * FF-A v1.1 provides UUID for each partition as part of the discovery
> + * API, the discovered UUID must be populated in the device's UUID and
> + * there is no need to copy the same from the driver table.
> + */
> + if (drv_info->version > FFA_VERSION_1_0)
> + return;
> +
> count = ffa_partition_probe(uuid, &pbuf);
> if (count <= 0)
> return;
> @@ -694,6 +718,7 @@ void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
> static void ffa_setup_partitions(void)
> {
> int count, idx;
> + uuid_t uuid;
> struct ffa_device *ffa_dev;
> struct ffa_partition_info *pbuf, *tpbuf;
>
> @@ -704,14 +729,15 @@ static void ffa_setup_partitions(void)
> }
>
> for (idx = 0, tpbuf = pbuf; idx < count; idx++, tpbuf++) {
> - /* Note that the &uuid_null parameter will require
> + import_uuid(&uuid, (u8 *)tpbuf->uuid);
> +
> + /* Note that if the UUID will be uuid_null, that will require
> * ffa_device_match() to find the UUID of this partition id
> - * with help of ffa_device_match_uuid(). Once the FF-A spec
> - * is updated to provide correct UUID here for each partition
> - * as part of the discovery API, we need to pass the
> - * discovered UUID here instead.
> + * with help of ffa_device_match_uuid(). FF-A v1.1 and above
> + * provides UUID here for each partition as part of the
> + * discovery API and the same is passed.
> */
> - ffa_dev = ffa_device_register(&uuid_null, tpbuf->id, &ffa_ops);
> + ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_ops);
> if (!ffa_dev) {
> pr_err("%s: failed to register partition ID 0x%x\n",
> __func__, tpbuf->id);
> diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
> index 4c4b06783035..09567ffd1f49 100644
> --- a/include/linux/arm_ffa.h
> +++ b/include/linux/arm_ffa.h
> @@ -107,6 +107,7 @@ struct ffa_partition_info {
> /* partition can send and receive indirect messages. */
> #define FFA_PARTITION_INDIRECT_MSG BIT(2)
> u32 properties;
> + u32 uuid[4];
> };
>
> /* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registers */
> --
> 2.37.3
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 09/10] firmware: arm_ffa: Set up 32bit execution mode flag using partiion property
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-07 9:01 ` Jens Wiklander
-1 siblings, 0 replies; 40+ messages in thread
From: Jens Wiklander @ 2022-09-07 9:01 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Achin Gupta, Valentin Laurent, Lukas Hanel, Coboy Chen
On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> FF-A v1.1 adds a flag in the partition properties to indicate if the
> partition runs in the AArch32 or AArch64 execution state. Use the same
> to set-up the 32-bit execution flag mode in the ffa_dev automatically
> and ignore any requests to do the same from the ffa_driver.
>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/arm_ffa/driver.c | 13 ++++++++++++-
> include/linux/arm_ffa.h | 2 ++
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index dd6ab2f81580..dbbe15592173 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -647,11 +647,19 @@ static int ffa_partition_info_get(const char *uuid_str,
> return 0;
> }
>
> -static void ffa_mode_32bit_set(struct ffa_device *dev)
> +static void _ffa_mode_32bit_set(struct ffa_device *dev)
> {
> dev->mode_32bit = true;
> }
>
> +static void ffa_mode_32bit_set(struct ffa_device *dev)
> +{
> + if (drv_info->version > FFA_VERSION_1_0)
> + return;
> +
> + _ffa_mode_32bit_set(dev);
> +}
> +
> static int ffa_sync_send_receive(struct ffa_device *dev,
> struct ffa_send_direct_data *data)
> {
> @@ -743,6 +751,9 @@ static void ffa_setup_partitions(void)
> __func__, tpbuf->id);
> continue;
> }
> +
> + if (tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)
Shouldn't this be !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)?
Before this, we used 64-bit calling convention by default for FF-A
v1.0. I suppose we would like to keep that behaviour.
Cheers,
Jens
> + _ffa_mode_32bit_set(ffa_dev);
> }
> kfree(pbuf);
> }
> diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
> index 09567ffd1f49..5964b6104996 100644
> --- a/include/linux/arm_ffa.h
> +++ b/include/linux/arm_ffa.h
> @@ -106,6 +106,8 @@ struct ffa_partition_info {
> #define FFA_PARTITION_DIRECT_SEND BIT(1)
> /* partition can send and receive indirect messages. */
> #define FFA_PARTITION_INDIRECT_MSG BIT(2)
> +/* partition runs in the AArch64 execution state. */
> +#define FFA_PARTITION_AARCH64_EXEC BIT(8)
> u32 properties;
> u32 uuid[4];
> };
> --
> 2.37.3
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 09/10] firmware: arm_ffa: Set up 32bit execution mode flag using partiion property
@ 2022-09-07 9:01 ` Jens Wiklander
0 siblings, 0 replies; 40+ messages in thread
From: Jens Wiklander @ 2022-09-07 9:01 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Achin Gupta, Valentin Laurent, Lukas Hanel, Coboy Chen
On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> FF-A v1.1 adds a flag in the partition properties to indicate if the
> partition runs in the AArch32 or AArch64 execution state. Use the same
> to set-up the 32-bit execution flag mode in the ffa_dev automatically
> and ignore any requests to do the same from the ffa_driver.
>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/arm_ffa/driver.c | 13 ++++++++++++-
> include/linux/arm_ffa.h | 2 ++
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index dd6ab2f81580..dbbe15592173 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -647,11 +647,19 @@ static int ffa_partition_info_get(const char *uuid_str,
> return 0;
> }
>
> -static void ffa_mode_32bit_set(struct ffa_device *dev)
> +static void _ffa_mode_32bit_set(struct ffa_device *dev)
> {
> dev->mode_32bit = true;
> }
>
> +static void ffa_mode_32bit_set(struct ffa_device *dev)
> +{
> + if (drv_info->version > FFA_VERSION_1_0)
> + return;
> +
> + _ffa_mode_32bit_set(dev);
> +}
> +
> static int ffa_sync_send_receive(struct ffa_device *dev,
> struct ffa_send_direct_data *data)
> {
> @@ -743,6 +751,9 @@ static void ffa_setup_partitions(void)
> __func__, tpbuf->id);
> continue;
> }
> +
> + if (tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)
Shouldn't this be !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)?
Before this, we used 64-bit calling convention by default for FF-A
v1.0. I suppose we would like to keep that behaviour.
Cheers,
Jens
> + _ffa_mode_32bit_set(ffa_dev);
> }
> kfree(pbuf);
> }
> diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
> index 09567ffd1f49..5964b6104996 100644
> --- a/include/linux/arm_ffa.h
> +++ b/include/linux/arm_ffa.h
> @@ -106,6 +106,8 @@ struct ffa_partition_info {
> #define FFA_PARTITION_DIRECT_SEND BIT(1)
> /* partition can send and receive indirect messages. */
> #define FFA_PARTITION_INDIRECT_MSG BIT(2)
> +/* partition runs in the AArch64 execution state. */
> +#define FFA_PARTITION_AARCH64_EXEC BIT(8)
> u32 properties;
> u32 uuid[4];
> };
> --
> 2.37.3
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 09/10] firmware: arm_ffa: Set up 32bit execution mode flag using partiion property
2022-09-07 9:01 ` Jens Wiklander
@ 2022-09-07 11:01 ` Sudeep Holla
-1 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-07 11:01 UTC (permalink / raw)
To: Jens Wiklander
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Sudeep Holla, Achin Gupta, Valentin Laurent, Lukas Hanel,
Coboy Chen
On Wed, Sep 07, 2022 at 11:01:27AM +0200, Jens Wiklander wrote:
> On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
> >
> > FF-A v1.1 adds a flag in the partition properties to indicate if the
> > partition runs in the AArch32 or AArch64 execution state. Use the same
> > to set-up the 32-bit execution flag mode in the ffa_dev automatically
> > and ignore any requests to do the same from the ffa_driver.
> >
> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> > ---
> > drivers/firmware/arm_ffa/driver.c | 13 ++++++++++++-
> > include/linux/arm_ffa.h | 2 ++
> > 2 files changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> > index dd6ab2f81580..dbbe15592173 100644
> > --- a/drivers/firmware/arm_ffa/driver.c
> > +++ b/drivers/firmware/arm_ffa/driver.c
> > @@ -647,11 +647,19 @@ static int ffa_partition_info_get(const char *uuid_str,
> > return 0;
> > }
> >
> > -static void ffa_mode_32bit_set(struct ffa_device *dev)
> > +static void _ffa_mode_32bit_set(struct ffa_device *dev)
> > {
> > dev->mode_32bit = true;
> > }
> >
> > +static void ffa_mode_32bit_set(struct ffa_device *dev)
> > +{
> > + if (drv_info->version > FFA_VERSION_1_0)
> > + return;
> > +
> > + _ffa_mode_32bit_set(dev);
> > +}
> > +
> > static int ffa_sync_send_receive(struct ffa_device *dev,
> > struct ffa_send_direct_data *data)
> > {
> > @@ -743,6 +751,9 @@ static void ffa_setup_partitions(void)
> > __func__, tpbuf->id);
> > continue;
> > }
> > +
> > + if (tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)
>
> Shouldn't this be !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)?
>
> Before this, we used 64-bit calling convention by default for FF-A
> v1.0. I suppose we would like to keep that behaviour.
>
Correct, it is stupid mistake on my part. I did notice this but somehow
messed up not to add the change I made to test with OPTEE. Thanks for
noticing this.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 09/10] firmware: arm_ffa: Set up 32bit execution mode flag using partiion property
@ 2022-09-07 11:01 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-07 11:01 UTC (permalink / raw)
To: Jens Wiklander
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Sudeep Holla, Achin Gupta, Valentin Laurent, Lukas Hanel,
Coboy Chen
On Wed, Sep 07, 2022 at 11:01:27AM +0200, Jens Wiklander wrote:
> On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
> >
> > FF-A v1.1 adds a flag in the partition properties to indicate if the
> > partition runs in the AArch32 or AArch64 execution state. Use the same
> > to set-up the 32-bit execution flag mode in the ffa_dev automatically
> > and ignore any requests to do the same from the ffa_driver.
> >
> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> > ---
> > drivers/firmware/arm_ffa/driver.c | 13 ++++++++++++-
> > include/linux/arm_ffa.h | 2 ++
> > 2 files changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> > index dd6ab2f81580..dbbe15592173 100644
> > --- a/drivers/firmware/arm_ffa/driver.c
> > +++ b/drivers/firmware/arm_ffa/driver.c
> > @@ -647,11 +647,19 @@ static int ffa_partition_info_get(const char *uuid_str,
> > return 0;
> > }
> >
> > -static void ffa_mode_32bit_set(struct ffa_device *dev)
> > +static void _ffa_mode_32bit_set(struct ffa_device *dev)
> > {
> > dev->mode_32bit = true;
> > }
> >
> > +static void ffa_mode_32bit_set(struct ffa_device *dev)
> > +{
> > + if (drv_info->version > FFA_VERSION_1_0)
> > + return;
> > +
> > + _ffa_mode_32bit_set(dev);
> > +}
> > +
> > static int ffa_sync_send_receive(struct ffa_device *dev,
> > struct ffa_send_direct_data *data)
> > {
> > @@ -743,6 +751,9 @@ static void ffa_setup_partitions(void)
> > __func__, tpbuf->id);
> > continue;
> > }
> > +
> > + if (tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)
>
> Shouldn't this be !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)?
>
> Before this, we used 64-bit calling convention by default for FF-A
> v1.0. I suppose we would like to keep that behaviour.
>
Correct, it is stupid mistake on my part. I did notice this but somehow
messed up not to add the change I made to test with OPTEE. Thanks for
noticing this.
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 08/10] firmware: arm_ffa: Add v1.1 get_partition_info support
2022-09-07 8:38 ` Jens Wiklander
@ 2022-09-07 11:04 ` Sudeep Holla
-1 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-07 11:04 UTC (permalink / raw)
To: Jens Wiklander
Cc: linux-arm-kernel, linux-kernel, op-tee, Sudeep Holla,
Marc Bonnici, Achin Gupta, Valentin Laurent, Lukas Hanel,
Coboy Chen
On Wed, Sep 07, 2022 at 10:38:05AM +0200, Jens Wiklander wrote:
> On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
> >
> > FF-A v1.1 adds support to discovery the UUIDs of the partitions that was
> > missing in v1.0 and which the driver workarounds by using UUIDs supplied
> > by the ffa_drivers.
> >
> > Add the v1.1 get_partition_info support and disable the workaround if
> > the detected FF-A version is greater than v1.0.
> >
> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> > ---
> > drivers/firmware/arm_ffa/driver.c | 42 +++++++++++++++++++++++++------
> > include/linux/arm_ffa.h | 1 +
> > 2 files changed, 35 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> > index 2532e0f16cc9..dd6ab2f81580 100644
> > --- a/drivers/firmware/arm_ffa/driver.c
> > +++ b/drivers/firmware/arm_ffa/driver.c
> > @@ -264,18 +264,24 @@ static int ffa_rxtx_unmap(u16 vm_id)
> > return 0;
> > }
> >
> > +#define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0)
> > +
> > /* buffer must be sizeof(struct ffa_partition_info) * num_partitions */
> > static int
> > __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
> > struct ffa_partition_info *buffer, int num_partitions)
> > {
> > - int count;
> > + int idx, count, flags = 0, size;
> > ffa_value_t partition_info;
> >
> > + if (!buffer || !num_partitions) /* Just get the count for now */
> > + flags = PARTITION_INFO_GET_RETURN_COUNT_ONLY;
> > +
> > mutex_lock(&drv_info->rx_lock);
> > invoke_ffa_fn((ffa_value_t){
> > .a0 = FFA_PARTITION_INFO_GET,
> > .a1 = uuid0, .a2 = uuid1, .a3 = uuid2, .a4 = uuid3,
> > + .a5 = flags,
> > }, &partition_info);
> >
> > if (partition_info.a0 == FFA_ERROR) {
> > @@ -285,8 +291,18 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
> >
> > count = partition_info.a2;
> >
> > + if (drv_info->version > FFA_VERSION_1_0) {
> > + size = partition_info.a3;
> > + if (size > sizeof(*buffer))
> > + size = sizeof(*buffer);
>
> Below when calculating the address in the source buffer with
> "drv_info->rx_buffer + idx * size" you should use the size from
> partition_info.a3 even if it's larger than sizeof(*buffer). The amount
> of bytes to copy looks correct though. Does that make sense?
>
Good spot, I missed to see that. It makes complete sense. I will fix it.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 08/10] firmware: arm_ffa: Add v1.1 get_partition_info support
@ 2022-09-07 11:04 ` Sudeep Holla
0 siblings, 0 replies; 40+ messages in thread
From: Sudeep Holla @ 2022-09-07 11:04 UTC (permalink / raw)
To: Jens Wiklander
Cc: linux-arm-kernel, linux-kernel, op-tee, Sudeep Holla,
Marc Bonnici, Achin Gupta, Valentin Laurent, Lukas Hanel,
Coboy Chen
On Wed, Sep 07, 2022 at 10:38:05AM +0200, Jens Wiklander wrote:
> On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
> >
> > FF-A v1.1 adds support to discovery the UUIDs of the partitions that was
> > missing in v1.0 and which the driver workarounds by using UUIDs supplied
> > by the ffa_drivers.
> >
> > Add the v1.1 get_partition_info support and disable the workaround if
> > the detected FF-A version is greater than v1.0.
> >
> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> > ---
> > drivers/firmware/arm_ffa/driver.c | 42 +++++++++++++++++++++++++------
> > include/linux/arm_ffa.h | 1 +
> > 2 files changed, 35 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> > index 2532e0f16cc9..dd6ab2f81580 100644
> > --- a/drivers/firmware/arm_ffa/driver.c
> > +++ b/drivers/firmware/arm_ffa/driver.c
> > @@ -264,18 +264,24 @@ static int ffa_rxtx_unmap(u16 vm_id)
> > return 0;
> > }
> >
> > +#define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0)
> > +
> > /* buffer must be sizeof(struct ffa_partition_info) * num_partitions */
> > static int
> > __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
> > struct ffa_partition_info *buffer, int num_partitions)
> > {
> > - int count;
> > + int idx, count, flags = 0, size;
> > ffa_value_t partition_info;
> >
> > + if (!buffer || !num_partitions) /* Just get the count for now */
> > + flags = PARTITION_INFO_GET_RETURN_COUNT_ONLY;
> > +
> > mutex_lock(&drv_info->rx_lock);
> > invoke_ffa_fn((ffa_value_t){
> > .a0 = FFA_PARTITION_INFO_GET,
> > .a1 = uuid0, .a2 = uuid1, .a3 = uuid2, .a4 = uuid3,
> > + .a5 = flags,
> > }, &partition_info);
> >
> > if (partition_info.a0 == FFA_ERROR) {
> > @@ -285,8 +291,18 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
> >
> > count = partition_info.a2;
> >
> > + if (drv_info->version > FFA_VERSION_1_0) {
> > + size = partition_info.a3;
> > + if (size > sizeof(*buffer))
> > + size = sizeof(*buffer);
>
> Below when calculating the address in the source buffer with
> "drv_info->rx_buffer + idx * size" you should use the size from
> partition_info.a3 even if it's larger than sizeof(*buffer). The amount
> of bytes to copy looks correct though. Does that make sense?
>
Good spot, I missed to see that. It makes complete sense. I will fix it.
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 04/10] firmware: arm_ffa: Add support for querying FF-A features
2022-09-02 12:40 ` Sudeep Holla
@ 2022-09-07 12:10 ` Jens Wiklander
-1 siblings, 0 replies; 40+ messages in thread
From: Jens Wiklander @ 2022-09-07 12:10 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Achin Gupta, Valentin Laurent, Lukas Hanel, Coboy Chen
On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> Add support for FFA_FEATURES to discover properties supported at the
> FF-A interface. This interface can be used to query:
> - If an FF-A interface is implemented by the component at the higher EL,
> - If an implemented FF-A interface also implements any optional features
> described in its interface definition, and
> - Any implementation details exported by an implemented FF-A interface
> as described in its interface definition.
>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/arm_ffa/driver.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
>
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index 04e7cbb1b9aa..81b8d578b6ea 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -571,6 +571,32 @@ static int ffa_memory_reclaim(u64 g_handle, u32 flags)
> return 0;
> }
>
> +static int ffa_features(u32 func_feat_id, u32 input_props,
> + u32 *if_props_1, u32 *if_props_2)
> +{
> + ffa_value_t id;
> +
> + if (!ARM_SMCCC_IS_FAST_CALL(func_feat_id) && input_props) {
> + pr_err("%s: Invalid Parameters: %x, %x", __func__,
> + func_feat_id, input_props);
> + return ffa_to_linux_errno(FFA_RET_INVALID_PARAMETERS);
> + }
> +
> + invoke_ffa_fn((ffa_value_t){
> + .a0 = FFA_FEATURES, .a1 = func_feat_id, .a2 = input_props,
> + }, &id);
> +
> + if (id.a0 == FFA_ERROR)
> + return ffa_to_linux_errno((int)id.a2);
> +
> + if (if_props_1)
> + *if_props_1 = id.a2;
> + if (if_props_2)
> + *if_props_2 = id.a3;
> +
> + return 0;
> +}
> +
> static u32 ffa_api_version_get(void)
> {
> return drv_info->version;
> --
> 2.37.3
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v2 04/10] firmware: arm_ffa: Add support for querying FF-A features
@ 2022-09-07 12:10 ` Jens Wiklander
0 siblings, 0 replies; 40+ messages in thread
From: Jens Wiklander @ 2022-09-07 12:10 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-arm-kernel, linux-kernel, op-tee, Marc Bonnici,
Achin Gupta, Valentin Laurent, Lukas Hanel, Coboy Chen
On Fri, Sep 2, 2022 at 2:40 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> Add support for FFA_FEATURES to discover properties supported at the
> FF-A interface. This interface can be used to query:
> - If an FF-A interface is implemented by the component at the higher EL,
> - If an implemented FF-A interface also implements any optional features
> described in its interface definition, and
> - Any implementation details exported by an implemented FF-A interface
> as described in its interface definition.
>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/arm_ffa/driver.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
>
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index 04e7cbb1b9aa..81b8d578b6ea 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -571,6 +571,32 @@ static int ffa_memory_reclaim(u64 g_handle, u32 flags)
> return 0;
> }
>
> +static int ffa_features(u32 func_feat_id, u32 input_props,
> + u32 *if_props_1, u32 *if_props_2)
> +{
> + ffa_value_t id;
> +
> + if (!ARM_SMCCC_IS_FAST_CALL(func_feat_id) && input_props) {
> + pr_err("%s: Invalid Parameters: %x, %x", __func__,
> + func_feat_id, input_props);
> + return ffa_to_linux_errno(FFA_RET_INVALID_PARAMETERS);
> + }
> +
> + invoke_ffa_fn((ffa_value_t){
> + .a0 = FFA_FEATURES, .a1 = func_feat_id, .a2 = input_props,
> + }, &id);
> +
> + if (id.a0 == FFA_ERROR)
> + return ffa_to_linux_errno((int)id.a2);
> +
> + if (if_props_1)
> + *if_props_1 = id.a2;
> + if (if_props_2)
> + *if_props_2 = id.a3;
> +
> + return 0;
> +}
> +
> static u32 ffa_api_version_get(void)
> {
> return drv_info->version;
> --
> 2.37.3
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 40+ messages in thread
end of thread, other threads:[~2022-09-07 12:11 UTC | newest]
Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 12:40 [PATCH v2 00/10] firmware: arm_ffa: Refactoring and initial/minor v1.1 update Sudeep Holla
2022-09-02 12:40 ` Sudeep Holla
2022-09-02 12:40 ` [PATCH v2 01/10] firmware: arm_ffa: Add pointer to the ffa_dev_ops in struct ffa_dev Sudeep Holla
2022-09-02 12:40 ` Sudeep Holla
2022-09-02 12:40 ` [PATCH v2 02/10] tee: optee: Drop ffa_ops in optee_ffa structure using ffa_dev->ops directly Sudeep Holla
2022-09-02 12:40 ` Sudeep Holla
2022-09-02 12:40 ` [PATCH v2 03/10] firmware: arm_ffa: Remove ffa_dev_ops_get() Sudeep Holla
2022-09-02 12:40 ` Sudeep Holla
2022-09-02 12:40 ` [PATCH v2 04/10] firmware: arm_ffa: Add support for querying FF-A features Sudeep Holla
2022-09-02 12:40 ` Sudeep Holla
2022-09-07 12:10 ` Jens Wiklander
2022-09-07 12:10 ` Jens Wiklander
2022-09-02 12:40 ` [PATCH v2 05/10] firmware: arm_ffa: Use FFA_FEATURES to detect if native versions are supported Sudeep Holla
2022-09-02 12:40 ` Sudeep Holla
2022-09-02 12:40 ` [PATCH v2 06/10] firmware: arm_ffa: Make memory apis ffa_device independent Sudeep Holla
2022-09-02 12:40 ` Sudeep Holla
2022-09-07 8:27 ` Jens Wiklander
2022-09-07 8:27 ` Jens Wiklander
2022-09-02 12:40 ` [PATCH v2 07/10] firmware: arm_ffa: Rename ffa_dev_ops as ffa_ops Sudeep Holla
2022-09-02 12:40 ` Sudeep Holla
2022-09-05 7:20 ` Sumit Garg
2022-09-05 7:20 ` Sumit Garg
2022-09-07 8:29 ` Jens Wiklander
2022-09-07 8:29 ` Jens Wiklander
2022-09-02 12:40 ` [PATCH v2 08/10] firmware: arm_ffa: Add v1.1 get_partition_info support Sudeep Holla
2022-09-02 12:40 ` Sudeep Holla
2022-09-07 8:38 ` Jens Wiklander
2022-09-07 8:38 ` Jens Wiklander
2022-09-07 11:04 ` Sudeep Holla
2022-09-07 11:04 ` Sudeep Holla
2022-09-02 12:40 ` [PATCH v2 09/10] firmware: arm_ffa: Set up 32bit execution mode flag using partiion property Sudeep Holla
2022-09-02 12:40 ` Sudeep Holla
2022-09-07 9:01 ` Jens Wiklander
2022-09-07 9:01 ` Jens Wiklander
2022-09-07 11:01 ` Sudeep Holla
2022-09-07 11:01 ` Sudeep Holla
2022-09-02 12:40 ` [PATCH v2 10/10] firmware: arm_ffa: Split up ffa_ops into info, message and memory operations Sudeep Holla
2022-09-02 12:40 ` Sudeep Holla
2022-09-06 10:34 ` [PATCH v2 00/10] firmware: arm_ffa: Refactoring and initial/minor v1.1 update Sudeep Holla
2022-09-06 10:34 ` Sudeep Holla
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.