Message ID | 20250326113901.3308804-3-sebastianene@google.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | KVM: arm64: Separate the hyp FF-A buffers init from the host | expand |
On Wednesday 26 Mar 2025 at 11:39:00 (+0000), Sebastian Ene wrote: > Keep the ffa_to_linux error map in the header and move it away > from the arm ffa driver to make it accessible for other components. > > Signed-off-by: Sebastian Ene <sebastianene@google.com> > Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Reviewed-by: Quentin Perret <qperret@google.com> > --- > drivers/firmware/arm_ffa/driver.c | 26 -------------------------- > include/linux/arm_ffa.h | 27 +++++++++++++++++++++++++++ > 2 files changed, 27 insertions(+), 26 deletions(-) > > diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c > index 2c2ec3c35f15..3f88509a15b7 100644 > --- a/drivers/firmware/arm_ffa/driver.c > +++ b/drivers/firmware/arm_ffa/driver.c > @@ -61,30 +61,6 @@ > > static ffa_fn *invoke_ffa_fn; > > -static const int ffa_linux_errmap[] = { > - /* better than switch case as long as return value is continuous */ > - 0, /* FFA_RET_SUCCESS */ > - -EOPNOTSUPP, /* FFA_RET_NOT_SUPPORTED */ > - -EINVAL, /* FFA_RET_INVALID_PARAMETERS */ > - -ENOMEM, /* FFA_RET_NO_MEMORY */ > - -EBUSY, /* FFA_RET_BUSY */ > - -EINTR, /* FFA_RET_INTERRUPTED */ > - -EACCES, /* FFA_RET_DENIED */ > - -EAGAIN, /* FFA_RET_RETRY */ > - -ECANCELED, /* FFA_RET_ABORTED */ > - -ENODATA, /* FFA_RET_NO_DATA */ > - -EAGAIN, /* FFA_RET_NOT_READY */ > -}; > - > -static inline int ffa_to_linux_errno(int errno) > -{ > - int err_idx = -errno; > - > - if (err_idx >= 0 && err_idx < ARRAY_SIZE(ffa_linux_errmap)) > - return ffa_linux_errmap[err_idx]; > - return -EINVAL; > -} > - > struct ffa_pcpu_irq { > struct ffa_drv_info *info; > }; > @@ -238,8 +214,6 @@ static int ffa_features(u32 func_feat_id, u32 input_props, > 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, > diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h > index 74169dd0f659..cdaa162060f4 100644 > --- a/include/linux/arm_ffa.h > +++ b/include/linux/arm_ffa.h > @@ -223,6 +223,9 @@ extern const struct bus_type ffa_bus_type; > /* The FF-A 1.0 partition structure lacks the uuid[4] */ > #define FFA_1_0_PARTITON_INFO_SZ (8) > > +/* Return the count of partitions deployed in the system */ > +#define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0) > + > /* FFA transport related */ > struct ffa_partition_info { > u16 id; > @@ -475,4 +478,28 @@ struct ffa_ops { > const struct ffa_notifier_ops *notifier_ops; > }; > > +static const int ffa_linux_errmap[] = { > + /* better than switch case as long as return value is continuous */ > + 0, /* FFA_RET_SUCCESS */ > + -EOPNOTSUPP, /* FFA_RET_NOT_SUPPORTED */ > + -EINVAL, /* FFA_RET_INVALID_PARAMETERS */ > + -ENOMEM, /* FFA_RET_NO_MEMORY */ > + -EBUSY, /* FFA_RET_BUSY */ > + -EINTR, /* FFA_RET_INTERRUPTED */ > + -EACCES, /* FFA_RET_DENIED */ > + -EAGAIN, /* FFA_RET_RETRY */ > + -ECANCELED, /* FFA_RET_ABORTED */ > + -ENODATA, /* FFA_RET_NO_DATA */ > + -EAGAIN, /* FFA_RET_NOT_READY */ > +}; > + > +static inline int ffa_to_linux_errno(int errno) > +{ > + int err_idx = -errno; > + > + if (err_idx >= 0 && err_idx < ARRAY_SIZE(ffa_linux_errmap)) > + return ffa_linux_errmap[err_idx]; > + return -EINVAL; > +} > + > #endif /* _LINUX_ARM_FFA_H */ > -- > 2.49.0.395.g12beb8f557-goog >
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 2c2ec3c35f15..3f88509a15b7 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -61,30 +61,6 @@ static ffa_fn *invoke_ffa_fn; -static const int ffa_linux_errmap[] = { - /* better than switch case as long as return value is continuous */ - 0, /* FFA_RET_SUCCESS */ - -EOPNOTSUPP, /* FFA_RET_NOT_SUPPORTED */ - -EINVAL, /* FFA_RET_INVALID_PARAMETERS */ - -ENOMEM, /* FFA_RET_NO_MEMORY */ - -EBUSY, /* FFA_RET_BUSY */ - -EINTR, /* FFA_RET_INTERRUPTED */ - -EACCES, /* FFA_RET_DENIED */ - -EAGAIN, /* FFA_RET_RETRY */ - -ECANCELED, /* FFA_RET_ABORTED */ - -ENODATA, /* FFA_RET_NO_DATA */ - -EAGAIN, /* FFA_RET_NOT_READY */ -}; - -static inline int ffa_to_linux_errno(int errno) -{ - int err_idx = -errno; - - if (err_idx >= 0 && err_idx < ARRAY_SIZE(ffa_linux_errmap)) - return ffa_linux_errmap[err_idx]; - return -EINVAL; -} - struct ffa_pcpu_irq { struct ffa_drv_info *info; }; @@ -238,8 +214,6 @@ static int ffa_features(u32 func_feat_id, u32 input_props, 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, diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 74169dd0f659..cdaa162060f4 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -223,6 +223,9 @@ extern const struct bus_type ffa_bus_type; /* The FF-A 1.0 partition structure lacks the uuid[4] */ #define FFA_1_0_PARTITON_INFO_SZ (8) +/* Return the count of partitions deployed in the system */ +#define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0) + /* FFA transport related */ struct ffa_partition_info { u16 id; @@ -475,4 +478,28 @@ struct ffa_ops { const struct ffa_notifier_ops *notifier_ops; }; +static const int ffa_linux_errmap[] = { + /* better than switch case as long as return value is continuous */ + 0, /* FFA_RET_SUCCESS */ + -EOPNOTSUPP, /* FFA_RET_NOT_SUPPORTED */ + -EINVAL, /* FFA_RET_INVALID_PARAMETERS */ + -ENOMEM, /* FFA_RET_NO_MEMORY */ + -EBUSY, /* FFA_RET_BUSY */ + -EINTR, /* FFA_RET_INTERRUPTED */ + -EACCES, /* FFA_RET_DENIED */ + -EAGAIN, /* FFA_RET_RETRY */ + -ECANCELED, /* FFA_RET_ABORTED */ + -ENODATA, /* FFA_RET_NO_DATA */ + -EAGAIN, /* FFA_RET_NOT_READY */ +}; + +static inline int ffa_to_linux_errno(int errno) +{ + int err_idx = -errno; + + if (err_idx >= 0 && err_idx < ARRAY_SIZE(ffa_linux_errmap)) + return ffa_linux_errmap[err_idx]; + return -EINVAL; +} + #endif /* _LINUX_ARM_FFA_H */