Skip to content

Commit 5def4a9

Browse files
committed
Merge branch 'for-next/ffa' into for-next/core
* for-next/ffa: firmware: arm_ffa: Move comment before the field it is documenting firmware: arm_ffa: Move constants to header file
2 parents f455fb6 + c8e320b commit 5def4a9

File tree

2 files changed

+94
-92
lines changed

2 files changed

+94
-92
lines changed

drivers/firmware/arm_ffa/driver.c

Lines changed: 10 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -36,81 +36,6 @@
3636
#include "common.h"
3737

3838
#define FFA_DRIVER_VERSION FFA_VERSION_1_0
39-
40-
#define FFA_SMC(calling_convention, func_num) \
41-
ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, (calling_convention), \
42-
ARM_SMCCC_OWNER_STANDARD, (func_num))
43-
44-
#define FFA_SMC_32(func_num) FFA_SMC(ARM_SMCCC_SMC_32, (func_num))
45-
#define FFA_SMC_64(func_num) FFA_SMC(ARM_SMCCC_SMC_64, (func_num))
46-
47-
#define FFA_ERROR FFA_SMC_32(0x60)
48-
#define FFA_SUCCESS FFA_SMC_32(0x61)
49-
#define FFA_INTERRUPT FFA_SMC_32(0x62)
50-
#define FFA_VERSION FFA_SMC_32(0x63)
51-
#define FFA_FEATURES FFA_SMC_32(0x64)
52-
#define FFA_RX_RELEASE FFA_SMC_32(0x65)
53-
#define FFA_RXTX_MAP FFA_SMC_32(0x66)
54-
#define FFA_FN64_RXTX_MAP FFA_SMC_64(0x66)
55-
#define FFA_RXTX_UNMAP FFA_SMC_32(0x67)
56-
#define FFA_PARTITION_INFO_GET FFA_SMC_32(0x68)
57-
#define FFA_ID_GET FFA_SMC_32(0x69)
58-
#define FFA_MSG_POLL FFA_SMC_32(0x6A)
59-
#define FFA_MSG_WAIT FFA_SMC_32(0x6B)
60-
#define FFA_YIELD FFA_SMC_32(0x6C)
61-
#define FFA_RUN FFA_SMC_32(0x6D)
62-
#define FFA_MSG_SEND FFA_SMC_32(0x6E)
63-
#define FFA_MSG_SEND_DIRECT_REQ FFA_SMC_32(0x6F)
64-
#define FFA_FN64_MSG_SEND_DIRECT_REQ FFA_SMC_64(0x6F)
65-
#define FFA_MSG_SEND_DIRECT_RESP FFA_SMC_32(0x70)
66-
#define FFA_FN64_MSG_SEND_DIRECT_RESP FFA_SMC_64(0x70)
67-
#define FFA_MEM_DONATE FFA_SMC_32(0x71)
68-
#define FFA_FN64_MEM_DONATE FFA_SMC_64(0x71)
69-
#define FFA_MEM_LEND FFA_SMC_32(0x72)
70-
#define FFA_FN64_MEM_LEND FFA_SMC_64(0x72)
71-
#define FFA_MEM_SHARE FFA_SMC_32(0x73)
72-
#define FFA_FN64_MEM_SHARE FFA_SMC_64(0x73)
73-
#define FFA_MEM_RETRIEVE_REQ FFA_SMC_32(0x74)
74-
#define FFA_FN64_MEM_RETRIEVE_REQ FFA_SMC_64(0x74)
75-
#define FFA_MEM_RETRIEVE_RESP FFA_SMC_32(0x75)
76-
#define FFA_MEM_RELINQUISH FFA_SMC_32(0x76)
77-
#define FFA_MEM_RECLAIM FFA_SMC_32(0x77)
78-
#define FFA_MEM_OP_PAUSE FFA_SMC_32(0x78)
79-
#define FFA_MEM_OP_RESUME FFA_SMC_32(0x79)
80-
#define FFA_MEM_FRAG_RX FFA_SMC_32(0x7A)
81-
#define FFA_MEM_FRAG_TX FFA_SMC_32(0x7B)
82-
#define FFA_NORMAL_WORLD_RESUME FFA_SMC_32(0x7C)
83-
84-
/*
85-
* For some calls it is necessary to use SMC64 to pass or return 64-bit values.
86-
* For such calls FFA_FN_NATIVE(name) will choose the appropriate
87-
* (native-width) function ID.
88-
*/
89-
#ifdef CONFIG_64BIT
90-
#define FFA_FN_NATIVE(name) FFA_FN64_##name
91-
#else
92-
#define FFA_FN_NATIVE(name) FFA_##name
93-
#endif
94-
95-
/* FFA error codes. */
96-
#define FFA_RET_SUCCESS (0)
97-
#define FFA_RET_NOT_SUPPORTED (-1)
98-
#define FFA_RET_INVALID_PARAMETERS (-2)
99-
#define FFA_RET_NO_MEMORY (-3)
100-
#define FFA_RET_BUSY (-4)
101-
#define FFA_RET_INTERRUPTED (-5)
102-
#define FFA_RET_DENIED (-6)
103-
#define FFA_RET_RETRY (-7)
104-
#define FFA_RET_ABORTED (-8)
105-
106-
#define MAJOR_VERSION_MASK GENMASK(30, 16)
107-
#define MINOR_VERSION_MASK GENMASK(15, 0)
108-
#define MAJOR_VERSION(x) ((u16)(FIELD_GET(MAJOR_VERSION_MASK, (x))))
109-
#define MINOR_VERSION(x) ((u16)(FIELD_GET(MINOR_VERSION_MASK, (x))))
110-
#define PACK_VERSION_INFO(major, minor) \
111-
(FIELD_PREP(MAJOR_VERSION_MASK, (major)) | \
112-
FIELD_PREP(MINOR_VERSION_MASK, (minor)))
113-
#define FFA_VERSION_1_0 PACK_VERSION_INFO(1, 0)
11439
#define FFA_MIN_VERSION FFA_VERSION_1_0
11540

11641
#define SENDER_ID_MASK GENMASK(31, 16)
@@ -120,12 +45,6 @@
12045
#define PACK_TARGET_INFO(s, r) \
12146
(FIELD_PREP(SENDER_ID_MASK, (s)) | FIELD_PREP(RECEIVER_ID_MASK, (r)))
12247

123-
/*
124-
* FF-A specification mentions explicitly about '4K pages'. This should
125-
* not be confused with the kernel PAGE_SIZE, which is the translation
126-
* granule kernel is configured and may be one among 4K, 16K and 64K.
127-
*/
128-
#define FFA_PAGE_SIZE SZ_4K
12948
/*
13049
* Keeping RX TX buffer size as 4K for now
13150
* 64K may be preferred to keep it min a page in 64K PAGE_SIZE config
@@ -178,9 +97,9 @@ static struct ffa_drv_info *drv_info;
17897
*/
17998
static u32 ffa_compatible_version_find(u32 version)
18099
{
181-
u16 major = MAJOR_VERSION(version), minor = MINOR_VERSION(version);
182-
u16 drv_major = MAJOR_VERSION(FFA_DRIVER_VERSION);
183-
u16 drv_minor = MINOR_VERSION(FFA_DRIVER_VERSION);
100+
u16 major = FFA_MAJOR_VERSION(version), minor = FFA_MINOR_VERSION(version);
101+
u16 drv_major = FFA_MAJOR_VERSION(FFA_DRIVER_VERSION);
102+
u16 drv_minor = FFA_MINOR_VERSION(FFA_DRIVER_VERSION);
184103

185104
if ((major < drv_major) || (major == drv_major && minor <= drv_minor))
186105
return version;
@@ -204,16 +123,16 @@ static int ffa_version_check(u32 *version)
204123

205124
if (ver.a0 < FFA_MIN_VERSION) {
206125
pr_err("Incompatible v%d.%d! Earliest supported v%d.%d\n",
207-
MAJOR_VERSION(ver.a0), MINOR_VERSION(ver.a0),
208-
MAJOR_VERSION(FFA_MIN_VERSION),
209-
MINOR_VERSION(FFA_MIN_VERSION));
126+
FFA_MAJOR_VERSION(ver.a0), FFA_MINOR_VERSION(ver.a0),
127+
FFA_MAJOR_VERSION(FFA_MIN_VERSION),
128+
FFA_MINOR_VERSION(FFA_MIN_VERSION));
210129
return -EINVAL;
211130
}
212131

213-
pr_info("Driver version %d.%d\n", MAJOR_VERSION(FFA_DRIVER_VERSION),
214-
MINOR_VERSION(FFA_DRIVER_VERSION));
215-
pr_info("Firmware version %d.%d found\n", MAJOR_VERSION(ver.a0),
216-
MINOR_VERSION(ver.a0));
132+
pr_info("Driver version %d.%d\n", FFA_MAJOR_VERSION(FFA_DRIVER_VERSION),
133+
FFA_MINOR_VERSION(FFA_DRIVER_VERSION));
134+
pr_info("Firmware version %d.%d found\n", FFA_MAJOR_VERSION(ver.a0),
135+
FFA_MINOR_VERSION(ver.a0));
217136
*version = ffa_compatible_version_find(ver.a0);
218137

219138
return 0;

include/linux/arm_ffa.h

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,89 @@
1111
#include <linux/types.h>
1212
#include <linux/uuid.h>
1313

14+
#define FFA_SMC(calling_convention, func_num) \
15+
ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, (calling_convention), \
16+
ARM_SMCCC_OWNER_STANDARD, (func_num))
17+
18+
#define FFA_SMC_32(func_num) FFA_SMC(ARM_SMCCC_SMC_32, (func_num))
19+
#define FFA_SMC_64(func_num) FFA_SMC(ARM_SMCCC_SMC_64, (func_num))
20+
21+
#define FFA_ERROR FFA_SMC_32(0x60)
22+
#define FFA_SUCCESS FFA_SMC_32(0x61)
23+
#define FFA_INTERRUPT FFA_SMC_32(0x62)
24+
#define FFA_VERSION FFA_SMC_32(0x63)
25+
#define FFA_FEATURES FFA_SMC_32(0x64)
26+
#define FFA_RX_RELEASE FFA_SMC_32(0x65)
27+
#define FFA_RXTX_MAP FFA_SMC_32(0x66)
28+
#define FFA_FN64_RXTX_MAP FFA_SMC_64(0x66)
29+
#define FFA_RXTX_UNMAP FFA_SMC_32(0x67)
30+
#define FFA_PARTITION_INFO_GET FFA_SMC_32(0x68)
31+
#define FFA_ID_GET FFA_SMC_32(0x69)
32+
#define FFA_MSG_POLL FFA_SMC_32(0x6A)
33+
#define FFA_MSG_WAIT FFA_SMC_32(0x6B)
34+
#define FFA_YIELD FFA_SMC_32(0x6C)
35+
#define FFA_RUN FFA_SMC_32(0x6D)
36+
#define FFA_MSG_SEND FFA_SMC_32(0x6E)
37+
#define FFA_MSG_SEND_DIRECT_REQ FFA_SMC_32(0x6F)
38+
#define FFA_FN64_MSG_SEND_DIRECT_REQ FFA_SMC_64(0x6F)
39+
#define FFA_MSG_SEND_DIRECT_RESP FFA_SMC_32(0x70)
40+
#define FFA_FN64_MSG_SEND_DIRECT_RESP FFA_SMC_64(0x70)
41+
#define FFA_MEM_DONATE FFA_SMC_32(0x71)
42+
#define FFA_FN64_MEM_DONATE FFA_SMC_64(0x71)
43+
#define FFA_MEM_LEND FFA_SMC_32(0x72)
44+
#define FFA_FN64_MEM_LEND FFA_SMC_64(0x72)
45+
#define FFA_MEM_SHARE FFA_SMC_32(0x73)
46+
#define FFA_FN64_MEM_SHARE FFA_SMC_64(0x73)
47+
#define FFA_MEM_RETRIEVE_REQ FFA_SMC_32(0x74)
48+
#define FFA_FN64_MEM_RETRIEVE_REQ FFA_SMC_64(0x74)
49+
#define FFA_MEM_RETRIEVE_RESP FFA_SMC_32(0x75)
50+
#define FFA_MEM_RELINQUISH FFA_SMC_32(0x76)
51+
#define FFA_MEM_RECLAIM FFA_SMC_32(0x77)
52+
#define FFA_MEM_OP_PAUSE FFA_SMC_32(0x78)
53+
#define FFA_MEM_OP_RESUME FFA_SMC_32(0x79)
54+
#define FFA_MEM_FRAG_RX FFA_SMC_32(0x7A)
55+
#define FFA_MEM_FRAG_TX FFA_SMC_32(0x7B)
56+
#define FFA_NORMAL_WORLD_RESUME FFA_SMC_32(0x7C)
57+
58+
/*
59+
* For some calls it is necessary to use SMC64 to pass or return 64-bit values.
60+
* For such calls FFA_FN_NATIVE(name) will choose the appropriate
61+
* (native-width) function ID.
62+
*/
63+
#ifdef CONFIG_64BIT
64+
#define FFA_FN_NATIVE(name) FFA_FN64_##name
65+
#else
66+
#define FFA_FN_NATIVE(name) FFA_##name
67+
#endif
68+
69+
/* FFA error codes. */
70+
#define FFA_RET_SUCCESS (0)
71+
#define FFA_RET_NOT_SUPPORTED (-1)
72+
#define FFA_RET_INVALID_PARAMETERS (-2)
73+
#define FFA_RET_NO_MEMORY (-3)
74+
#define FFA_RET_BUSY (-4)
75+
#define FFA_RET_INTERRUPTED (-5)
76+
#define FFA_RET_DENIED (-6)
77+
#define FFA_RET_RETRY (-7)
78+
#define FFA_RET_ABORTED (-8)
79+
80+
/* FFA version encoding */
81+
#define FFA_MAJOR_VERSION_MASK GENMASK(30, 16)
82+
#define FFA_MINOR_VERSION_MASK GENMASK(15, 0)
83+
#define FFA_MAJOR_VERSION(x) ((u16)(FIELD_GET(FFA_MAJOR_VERSION_MASK, (x))))
84+
#define FFA_MINOR_VERSION(x) ((u16)(FIELD_GET(FFA_MINOR_VERSION_MASK, (x))))
85+
#define FFA_PACK_VERSION_INFO(major, minor) \
86+
(FIELD_PREP(FFA_MAJOR_VERSION_MASK, (major)) | \
87+
FIELD_PREP(FFA_MINOR_VERSION_MASK, (minor)))
88+
#define FFA_VERSION_1_0 FFA_PACK_VERSION_INFO(1, 0)
89+
90+
/**
91+
* FF-A specification mentions explicitly about '4K pages'. This should
92+
* not be confused with the kernel PAGE_SIZE, which is the translation
93+
* granule kernel is configured and may be one among 4K, 16K and 64K.
94+
*/
95+
#define FFA_PAGE_SIZE SZ_4K
96+
1497
/* FFA Bus/Device/Driver related */
1598
struct ffa_device {
1699
int vm_id;
@@ -161,11 +244,11 @@ struct ffa_mem_region_attributes {
161244
*/
162245
#define FFA_MEM_RETRIEVE_SELF_BORROWER BIT(0)
163246
u8 flag;
164-
u32 composite_off;
165247
/*
166248
* Offset in bytes from the start of the outer `ffa_memory_region` to
167249
* an `struct ffa_mem_region_addr_range`.
168250
*/
251+
u32 composite_off;
169252
u64 reserved;
170253
};
171254

0 commit comments

Comments
 (0)