Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 1 | From 8318af58a0f5d29352d3c84be6b20fe6d1ca352f Mon Sep 17 00:00:00 2001 |
| 2 | From: Arunachalam Ganapathy <arunachalam.ganapathy@arm.com> |
| 3 | Date: Fri, 14 Jan 2022 13:41:26 +0000 |
| 4 | Subject: [PATCH 23/32] ANDROID: trusty: Remove FFA specific initilization |
| 5 | |
| 6 | Remove FFA specific initialization and its arm_ffa.h file from Trusty |
| 7 | driver. These changes are done so that Trusty can use ARM FFA driver |
| 8 | and its related header files. |
| 9 | |
| 10 | Signed-off-by: Arunachalam Ganapathy <arunachalam.ganapathy@arm.com> |
| 11 | Change-Id: Iaad473659de94930cdf78cd7201f016d59cee8d7 |
| 12 | Upstream-Status: Pending [Not submitted to upstream yet] |
| 13 | --- |
| 14 | drivers/trusty/trusty-mem.c | 37 --- |
| 15 | drivers/trusty/trusty.c | 286 +--------------- |
| 16 | include/linux/trusty/arm_ffa.h | 590 --------------------------------- |
| 17 | include/linux/trusty/trusty.h | 3 - |
| 18 | 4 files changed, 3 insertions(+), 913 deletions(-) |
| 19 | delete mode 100644 include/linux/trusty/arm_ffa.h |
| 20 | |
| 21 | diff --git a/drivers/trusty/trusty-mem.c b/drivers/trusty/trusty-mem.c |
| 22 | index 8a360298e501..7775ff76c38c 100644 |
| 23 | --- a/drivers/trusty/trusty-mem.c |
| 24 | +++ b/drivers/trusty/trusty-mem.c |
| 25 | @@ -5,7 +5,6 @@ |
| 26 | |
| 27 | #include <linux/types.h> |
| 28 | #include <linux/printk.h> |
| 29 | -#include <linux/trusty/arm_ffa.h> |
| 30 | #include <linux/trusty/trusty.h> |
| 31 | #include <linux/trusty/smcall.h> |
| 32 | |
| 33 | @@ -75,8 +74,6 @@ int trusty_encode_page_info(struct ns_mem_page_info *inf, |
| 34 | { |
| 35 | int mem_attr; |
| 36 | u64 pte; |
| 37 | - u8 ffa_mem_attr; |
| 38 | - u8 ffa_mem_perm = 0; |
| 39 | |
| 40 | if (!inf || !page) |
| 41 | return -EINVAL; |
| 42 | @@ -89,30 +86,6 @@ int trusty_encode_page_info(struct ns_mem_page_info *inf, |
| 43 | if (mem_attr < 0) |
| 44 | return mem_attr; |
| 45 | |
| 46 | - switch (mem_attr) { |
| 47 | - case MEM_ATTR_STRONGLY_ORDERED: |
| 48 | - ffa_mem_attr = FFA_MEM_ATTR_DEVICE_NGNRNE; |
| 49 | - break; |
| 50 | - |
| 51 | - case MEM_ATTR_DEVICE: |
| 52 | - ffa_mem_attr = FFA_MEM_ATTR_DEVICE_NGNRE; |
| 53 | - break; |
| 54 | - |
| 55 | - case MEM_ATTR_NORMAL_NON_CACHEABLE: |
| 56 | - ffa_mem_attr = FFA_MEM_ATTR_NORMAL_MEMORY_UNCACHED; |
| 57 | - break; |
| 58 | - |
| 59 | - case MEM_ATTR_NORMAL_WRITE_BACK_READ_ALLOCATE: |
| 60 | - case MEM_ATTR_NORMAL_WRITE_BACK_WRITE_ALLOCATE: |
| 61 | - ffa_mem_attr = FFA_MEM_ATTR_NORMAL_MEMORY_CACHED_WB; |
| 62 | - break; |
| 63 | - |
| 64 | - default: |
| 65 | - return -EINVAL; |
| 66 | - } |
| 67 | - |
| 68 | - inf->paddr = pte; |
| 69 | - |
| 70 | /* add other attributes */ |
| 71 | #if defined(CONFIG_ARM64) || defined(CONFIG_ARM_LPAE) |
| 72 | pte |= pgprot_val(pgprot); |
| 73 | @@ -123,16 +96,6 @@ int trusty_encode_page_info(struct ns_mem_page_info *inf, |
| 74 | pte |= ATTR_INNER_SHAREABLE; /* inner sharable */ |
| 75 | #endif |
| 76 | |
| 77 | - if (!(pte & ATTR_RDONLY)) |
| 78 | - ffa_mem_perm |= FFA_MEM_PERM_RW; |
| 79 | - else |
| 80 | - ffa_mem_perm |= FFA_MEM_PERM_RO; |
| 81 | - |
| 82 | - if ((pte & ATTR_INNER_SHAREABLE) == ATTR_INNER_SHAREABLE) |
| 83 | - ffa_mem_attr |= FFA_MEM_ATTR_INNER_SHAREABLE; |
| 84 | - |
| 85 | - inf->ffa_mem_attr = ffa_mem_attr; |
| 86 | - inf->ffa_mem_perm = ffa_mem_perm; |
| 87 | inf->compat_attr = (pte & 0x0000FFFFFFFFFFFFull) | |
| 88 | ((u64)mem_attr << 48); |
| 89 | return 0; |
| 90 | diff --git a/drivers/trusty/trusty.c b/drivers/trusty/trusty.c |
| 91 | index 265eab52aea0..2dec75398f69 100644 |
| 92 | --- a/drivers/trusty/trusty.c |
| 93 | +++ b/drivers/trusty/trusty.c |
| 94 | @@ -11,7 +11,6 @@ |
| 95 | #include <linux/slab.h> |
| 96 | #include <linux/stat.h> |
| 97 | #include <linux/string.h> |
| 98 | -#include <linux/trusty/arm_ffa.h> |
| 99 | #include <linux/trusty/smcall.h> |
| 100 | #include <linux/trusty/sm_err.h> |
| 101 | #include <linux/trusty/trusty.h> |
| 102 | @@ -42,11 +41,6 @@ struct trusty_state { |
| 103 | struct list_head nop_queue; |
| 104 | spinlock_t nop_lock; /* protects nop_queue */ |
| 105 | struct device_dma_parameters dma_parms; |
| 106 | - void *ffa_tx; |
| 107 | - void *ffa_rx; |
| 108 | - u16 ffa_local_id; |
| 109 | - u16 ffa_remote_id; |
| 110 | - struct mutex share_memory_msg_lock; /* protects share_memory_msg */ |
| 111 | }; |
| 112 | |
| 113 | static inline unsigned long smc(unsigned long r0, unsigned long r1, |
| 114 | @@ -246,19 +240,6 @@ int trusty_transfer_memory(struct device *dev, u64 *id, |
| 115 | struct ns_mem_page_info pg_inf; |
| 116 | struct scatterlist *sg; |
| 117 | size_t count; |
| 118 | - size_t i; |
| 119 | - size_t len; |
| 120 | - u64 ffa_handle = 0; |
| 121 | - size_t total_len; |
| 122 | - size_t endpoint_count = 1; |
| 123 | - struct ffa_mtd *mtd = s->ffa_tx; |
| 124 | - size_t comp_mrd_offset = offsetof(struct ffa_mtd, emad[endpoint_count]); |
| 125 | - struct ffa_comp_mrd *comp_mrd = s->ffa_tx + comp_mrd_offset; |
| 126 | - struct ffa_cons_mrd *cons_mrd = comp_mrd->address_range_array; |
| 127 | - size_t cons_mrd_offset = (void *)cons_mrd - s->ffa_tx; |
| 128 | - struct smc_ret8 smc_ret; |
| 129 | - u32 cookie_low; |
| 130 | - u32 cookie_high; |
| 131 | |
| 132 | if (WARN_ON(dev->driver != &trusty_driver.driver)) |
| 133 | return -EINVAL; |
| 134 | @@ -284,126 +265,11 @@ int trusty_transfer_memory(struct device *dev, u64 *id, |
| 135 | if (ret) { |
| 136 | dev_err(s->dev, "%s: trusty_encode_page_info failed\n", |
| 137 | __func__); |
| 138 | - goto err_encode_page_info; |
| 139 | - } |
| 140 | - |
| 141 | - if (s->api_version < TRUSTY_API_VERSION_MEM_OBJ) { |
| 142 | - *id = pg_inf.compat_attr; |
| 143 | - return 0; |
| 144 | - } |
| 145 | - |
| 146 | - len = 0; |
| 147 | - for_each_sg(sglist, sg, nents, i) |
| 148 | - len += sg_dma_len(sg); |
| 149 | - |
| 150 | - mutex_lock(&s->share_memory_msg_lock); |
| 151 | - |
| 152 | - mtd->sender_id = s->ffa_local_id; |
| 153 | - mtd->memory_region_attributes = pg_inf.ffa_mem_attr; |
| 154 | - mtd->reserved_3 = 0; |
| 155 | - mtd->flags = 0; |
| 156 | - mtd->handle = 0; |
| 157 | - mtd->tag = tag; |
| 158 | - mtd->reserved_24_27 = 0; |
| 159 | - mtd->emad_count = endpoint_count; |
| 160 | - for (i = 0; i < endpoint_count; i++) { |
| 161 | - struct ffa_emad *emad = &mtd->emad[i]; |
| 162 | - /* TODO: support stream ids */ |
| 163 | - emad->mapd.endpoint_id = s->ffa_remote_id; |
| 164 | - emad->mapd.memory_access_permissions = pg_inf.ffa_mem_perm; |
| 165 | - emad->mapd.flags = 0; |
| 166 | - emad->comp_mrd_offset = comp_mrd_offset; |
| 167 | - emad->reserved_8_15 = 0; |
| 168 | - } |
| 169 | - comp_mrd->total_page_count = len / PAGE_SIZE; |
| 170 | - comp_mrd->address_range_count = nents; |
| 171 | - comp_mrd->reserved_8_15 = 0; |
| 172 | - |
| 173 | - total_len = cons_mrd_offset + nents * sizeof(*cons_mrd); |
| 174 | - sg = sglist; |
| 175 | - while (count) { |
| 176 | - size_t lcount = |
| 177 | - min_t(size_t, count, (PAGE_SIZE - cons_mrd_offset) / |
| 178 | - sizeof(*cons_mrd)); |
| 179 | - size_t fragment_len = lcount * sizeof(*cons_mrd) + |
| 180 | - cons_mrd_offset; |
| 181 | - |
| 182 | - for (i = 0; i < lcount; i++) { |
| 183 | - cons_mrd[i].address = sg_dma_address(sg); |
| 184 | - cons_mrd[i].page_count = sg_dma_len(sg) / PAGE_SIZE; |
| 185 | - cons_mrd[i].reserved_12_15 = 0; |
| 186 | - sg = sg_next(sg); |
| 187 | - } |
| 188 | - count -= lcount; |
| 189 | - if (cons_mrd_offset) { |
| 190 | - u32 smc = lend ? SMC_FC_FFA_MEM_LEND : |
| 191 | - SMC_FC_FFA_MEM_SHARE; |
| 192 | - /* First fragment */ |
| 193 | - smc_ret = trusty_smc8(smc, total_len, |
| 194 | - fragment_len, 0, 0, 0, 0, 0); |
| 195 | - } else { |
| 196 | - smc_ret = trusty_smc8(SMC_FC_FFA_MEM_FRAG_TX, |
| 197 | - cookie_low, cookie_high, |
| 198 | - fragment_len, 0, 0, 0, 0); |
| 199 | - } |
| 200 | - if (smc_ret.r0 == SMC_FC_FFA_MEM_FRAG_RX) { |
| 201 | - cookie_low = smc_ret.r1; |
| 202 | - cookie_high = smc_ret.r2; |
| 203 | - dev_dbg(s->dev, "cookie %x %x", cookie_low, |
| 204 | - cookie_high); |
| 205 | - if (!count) { |
| 206 | - /* |
| 207 | - * We have sent all our descriptors. Expected |
| 208 | - * SMC_FC_FFA_SUCCESS, not a request to send |
| 209 | - * another fragment. |
| 210 | - */ |
| 211 | - dev_err(s->dev, "%s: fragment_len %zd/%zd, unexpected SMC_FC_FFA_MEM_FRAG_RX\n", |
| 212 | - __func__, fragment_len, total_len); |
| 213 | - ret = -EIO; |
| 214 | - break; |
| 215 | - } |
| 216 | - } else if (smc_ret.r0 == SMC_FC_FFA_SUCCESS) { |
| 217 | - ffa_handle = smc_ret.r2 | (u64)smc_ret.r3 << 32; |
| 218 | - dev_dbg(s->dev, "%s: fragment_len %zu/%zu, got handle 0x%llx\n", |
| 219 | - __func__, fragment_len, total_len, |
| 220 | - ffa_handle); |
| 221 | - if (count) { |
| 222 | - /* |
| 223 | - * We have not sent all our descriptors. |
| 224 | - * Expected SMC_FC_FFA_MEM_FRAG_RX not |
| 225 | - * SMC_FC_FFA_SUCCESS. |
| 226 | - */ |
| 227 | - dev_err(s->dev, "%s: fragment_len %zu/%zu, unexpected SMC_FC_FFA_SUCCESS, count %zu != 0\n", |
| 228 | - __func__, fragment_len, total_len, |
| 229 | - count); |
| 230 | - ret = -EIO; |
| 231 | - break; |
| 232 | - } |
| 233 | - } else { |
| 234 | - dev_err(s->dev, "%s: fragment_len %zu/%zu, SMC_FC_FFA_MEM_SHARE failed 0x%lx 0x%lx 0x%lx", |
| 235 | - __func__, fragment_len, total_len, |
| 236 | - smc_ret.r0, smc_ret.r1, smc_ret.r2); |
| 237 | - ret = -EIO; |
| 238 | - break; |
| 239 | - } |
| 240 | - |
| 241 | - cons_mrd = s->ffa_tx; |
| 242 | - cons_mrd_offset = 0; |
| 243 | - } |
| 244 | - |
| 245 | - mutex_unlock(&s->share_memory_msg_lock); |
| 246 | - |
| 247 | - if (!ret) { |
| 248 | - *id = ffa_handle; |
| 249 | - dev_dbg(s->dev, "%s: done\n", __func__); |
| 250 | - return 0; |
| 251 | + return ret; |
| 252 | } |
| 253 | |
| 254 | - dev_err(s->dev, "%s: failed %d", __func__, ret); |
| 255 | - |
| 256 | -err_encode_page_info: |
| 257 | - dma_unmap_sg(dev, sglist, nents, DMA_BIDIRECTIONAL); |
| 258 | - return ret; |
| 259 | + *id = pg_inf.compat_attr; |
| 260 | + return 0; |
| 261 | } |
| 262 | EXPORT_SYMBOL(trusty_transfer_memory); |
| 263 | |
| 264 | @@ -433,8 +299,6 @@ int trusty_reclaim_memory(struct device *dev, u64 id, |
| 265 | struct scatterlist *sglist, unsigned int nents) |
| 266 | { |
| 267 | struct trusty_state *s = platform_get_drvdata(to_platform_device(dev)); |
| 268 | - int ret = 0; |
| 269 | - struct smc_ret8 smc_ret; |
| 270 | |
| 271 | if (WARN_ON(dev->driver != &trusty_driver.driver)) |
| 272 | return -EINVAL; |
| 273 | @@ -454,28 +318,6 @@ int trusty_reclaim_memory(struct device *dev, u64 id, |
| 274 | return 0; |
| 275 | } |
| 276 | |
| 277 | - mutex_lock(&s->share_memory_msg_lock); |
| 278 | - |
| 279 | - smc_ret = trusty_smc8(SMC_FC_FFA_MEM_RECLAIM, (u32)id, id >> 32, 0, 0, |
| 280 | - 0, 0, 0); |
| 281 | - if (smc_ret.r0 != SMC_FC_FFA_SUCCESS) { |
| 282 | - dev_err(s->dev, "%s: SMC_FC_FFA_MEM_RECLAIM failed 0x%lx 0x%lx 0x%lx", |
| 283 | - __func__, smc_ret.r0, smc_ret.r1, smc_ret.r2); |
| 284 | - if (smc_ret.r0 == SMC_FC_FFA_ERROR && |
| 285 | - smc_ret.r2 == FFA_ERROR_DENIED) |
| 286 | - ret = -EBUSY; |
| 287 | - else |
| 288 | - ret = -EIO; |
| 289 | - } |
| 290 | - |
| 291 | - mutex_unlock(&s->share_memory_msg_lock); |
| 292 | - |
| 293 | - if (ret != 0) |
| 294 | - return ret; |
| 295 | - |
| 296 | - dma_unmap_sg(dev, sglist, nents, DMA_BIDIRECTIONAL); |
| 297 | - |
| 298 | - dev_dbg(s->dev, "%s: done\n", __func__); |
| 299 | return 0; |
| 300 | } |
| 301 | EXPORT_SYMBOL(trusty_reclaim_memory); |
| 302 | @@ -527,118 +369,6 @@ const char *trusty_version_str_get(struct device *dev) |
| 303 | } |
| 304 | EXPORT_SYMBOL(trusty_version_str_get); |
| 305 | |
| 306 | -static int trusty_init_msg_buf(struct trusty_state *s, struct device *dev) |
| 307 | -{ |
| 308 | - phys_addr_t tx_paddr; |
| 309 | - phys_addr_t rx_paddr; |
| 310 | - int ret; |
| 311 | - struct smc_ret8 smc_ret; |
| 312 | - |
| 313 | - if (s->api_version < TRUSTY_API_VERSION_MEM_OBJ) |
| 314 | - return 0; |
| 315 | - |
| 316 | - /* Get supported FF-A version and check if it is compatible */ |
| 317 | - smc_ret = trusty_smc8(SMC_FC_FFA_VERSION, FFA_CURRENT_VERSION, 0, 0, |
| 318 | - 0, 0, 0, 0); |
| 319 | - if (FFA_VERSION_TO_MAJOR(smc_ret.r0) != FFA_CURRENT_VERSION_MAJOR) { |
| 320 | - dev_err(s->dev, |
| 321 | - "%s: Unsupported FF-A version 0x%lx, expected 0x%x\n", |
| 322 | - __func__, smc_ret.r0, FFA_CURRENT_VERSION); |
| 323 | - ret = -EIO; |
| 324 | - goto err_version; |
| 325 | - } |
| 326 | - |
| 327 | - /* Check that SMC_FC_FFA_MEM_SHARE is implemented */ |
| 328 | - smc_ret = trusty_smc8(SMC_FC_FFA_FEATURES, SMC_FC_FFA_MEM_SHARE, 0, 0, |
| 329 | - 0, 0, 0, 0); |
| 330 | - if (smc_ret.r0 != SMC_FC_FFA_SUCCESS) { |
| 331 | - dev_err(s->dev, |
| 332 | - "%s: SMC_FC_FFA_FEATURES(SMC_FC_FFA_MEM_SHARE) failed 0x%lx 0x%lx 0x%lx\n", |
| 333 | - __func__, smc_ret.r0, smc_ret.r1, smc_ret.r2); |
| 334 | - ret = -EIO; |
| 335 | - goto err_features; |
| 336 | - } |
| 337 | - |
| 338 | - /* |
| 339 | - * Set FF-A endpoint IDs. |
| 340 | - * |
| 341 | - * Hardcode 0x8000 for the secure os. |
| 342 | - * TODO: Use FF-A call or device tree to configure this dynamically |
| 343 | - */ |
| 344 | - smc_ret = trusty_smc8(SMC_FC_FFA_ID_GET, 0, 0, 0, 0, 0, 0, 0); |
| 345 | - if (smc_ret.r0 != SMC_FC_FFA_SUCCESS) { |
| 346 | - dev_err(s->dev, |
| 347 | - "%s: SMC_FC_FFA_ID_GET failed 0x%lx 0x%lx 0x%lx\n", |
| 348 | - __func__, smc_ret.r0, smc_ret.r1, smc_ret.r2); |
| 349 | - ret = -EIO; |
| 350 | - goto err_id_get; |
| 351 | - } |
| 352 | - |
| 353 | - s->ffa_local_id = smc_ret.r2; |
| 354 | - s->ffa_remote_id = 0x8000; |
| 355 | - |
| 356 | - s->ffa_tx = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 357 | - if (!s->ffa_tx) { |
| 358 | - ret = -ENOMEM; |
| 359 | - goto err_alloc_tx; |
| 360 | - } |
| 361 | - tx_paddr = virt_to_phys(s->ffa_tx); |
| 362 | - if (WARN_ON(tx_paddr & (PAGE_SIZE - 1))) { |
| 363 | - ret = -EINVAL; |
| 364 | - goto err_unaligned_tx_buf; |
| 365 | - } |
| 366 | - |
| 367 | - s->ffa_rx = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 368 | - if (!s->ffa_rx) { |
| 369 | - ret = -ENOMEM; |
| 370 | - goto err_alloc_rx; |
| 371 | - } |
| 372 | - rx_paddr = virt_to_phys(s->ffa_rx); |
| 373 | - if (WARN_ON(rx_paddr & (PAGE_SIZE - 1))) { |
| 374 | - ret = -EINVAL; |
| 375 | - goto err_unaligned_rx_buf; |
| 376 | - } |
| 377 | - |
| 378 | - smc_ret = trusty_smc8(SMC_FCZ_FFA_RXTX_MAP, tx_paddr, rx_paddr, 1, 0, |
| 379 | - 0, 0, 0); |
| 380 | - if (smc_ret.r0 != SMC_FC_FFA_SUCCESS) { |
| 381 | - dev_err(s->dev, "%s: SMC_FCZ_FFA_RXTX_MAP failed 0x%lx 0x%lx 0x%lx\n", |
| 382 | - __func__, smc_ret.r0, smc_ret.r1, smc_ret.r2); |
| 383 | - ret = -EIO; |
| 384 | - goto err_rxtx_map; |
| 385 | - } |
| 386 | - |
| 387 | - return 0; |
| 388 | - |
| 389 | -err_rxtx_map: |
| 390 | -err_unaligned_rx_buf: |
| 391 | - kfree(s->ffa_rx); |
| 392 | - s->ffa_rx = NULL; |
| 393 | -err_alloc_rx: |
| 394 | -err_unaligned_tx_buf: |
| 395 | - kfree(s->ffa_tx); |
| 396 | - s->ffa_tx = NULL; |
| 397 | -err_alloc_tx: |
| 398 | -err_id_get: |
| 399 | -err_features: |
| 400 | -err_version: |
| 401 | - return ret; |
| 402 | -} |
| 403 | - |
| 404 | -static void trusty_free_msg_buf(struct trusty_state *s, struct device *dev) |
| 405 | -{ |
| 406 | - struct smc_ret8 smc_ret; |
| 407 | - |
| 408 | - smc_ret = trusty_smc8(SMC_FC_FFA_RXTX_UNMAP, 0, 0, 0, 0, 0, 0, 0); |
| 409 | - if (smc_ret.r0 != SMC_FC_FFA_SUCCESS) { |
| 410 | - dev_err(s->dev, "%s: SMC_FC_FFA_RXTX_UNMAP failed 0x%lx 0x%lx 0x%lx\n", |
| 411 | - __func__, smc_ret.r0, smc_ret.r1, smc_ret.r2); |
| 412 | - } else { |
| 413 | - kfree(s->ffa_rx); |
| 414 | - kfree(s->ffa_tx); |
| 415 | - } |
| 416 | -} |
| 417 | - |
| 418 | static void trusty_init_version(struct trusty_state *s, struct device *dev) |
| 419 | { |
| 420 | int ret; |
| 421 | @@ -842,7 +572,6 @@ static int trusty_probe(struct platform_device *pdev) |
| 422 | spin_lock_init(&s->nop_lock); |
| 423 | INIT_LIST_HEAD(&s->nop_queue); |
| 424 | mutex_init(&s->smc_lock); |
| 425 | - mutex_init(&s->share_memory_msg_lock); |
| 426 | ATOMIC_INIT_NOTIFIER_HEAD(&s->notifier); |
| 427 | init_completion(&s->cpu_idle_completion); |
| 428 | |
| 429 | @@ -862,10 +591,6 @@ static int trusty_probe(struct platform_device *pdev) |
| 430 | if (ret < 0) |
| 431 | goto err_api_version; |
| 432 | |
| 433 | - ret = trusty_init_msg_buf(s, &pdev->dev); |
| 434 | - if (ret < 0) |
| 435 | - goto err_init_msg_buf; |
| 436 | - |
| 437 | s->nop_wq = alloc_workqueue("trusty-nop-wq", WQ_CPU_INTENSIVE, 0); |
| 438 | if (!s->nop_wq) { |
| 439 | ret = -ENODEV; |
| 440 | @@ -910,13 +635,10 @@ static int trusty_probe(struct platform_device *pdev) |
| 441 | err_alloc_works: |
| 442 | destroy_workqueue(s->nop_wq); |
| 443 | err_create_nop_wq: |
| 444 | - trusty_free_msg_buf(s, &pdev->dev); |
| 445 | -err_init_msg_buf: |
| 446 | err_api_version: |
| 447 | s->dev->dma_parms = NULL; |
| 448 | kfree(s->version_str); |
| 449 | device_for_each_child(&pdev->dev, NULL, trusty_remove_child); |
| 450 | - mutex_destroy(&s->share_memory_msg_lock); |
| 451 | mutex_destroy(&s->smc_lock); |
| 452 | kfree(s); |
| 453 | err_allocate_state: |
| 454 | @@ -938,9 +660,7 @@ static int trusty_remove(struct platform_device *pdev) |
| 455 | free_percpu(s->nop_works); |
| 456 | destroy_workqueue(s->nop_wq); |
| 457 | |
| 458 | - mutex_destroy(&s->share_memory_msg_lock); |
| 459 | mutex_destroy(&s->smc_lock); |
| 460 | - trusty_free_msg_buf(s, &pdev->dev); |
| 461 | s->dev->dma_parms = NULL; |
| 462 | kfree(s->version_str); |
| 463 | kfree(s); |
| 464 | diff --git a/include/linux/trusty/arm_ffa.h b/include/linux/trusty/arm_ffa.h |
| 465 | deleted file mode 100644 |
| 466 | index ab7b2afb794c..000000000000 |
| 467 | --- a/include/linux/trusty/arm_ffa.h |
| 468 | +++ /dev/null |
| 469 | @@ -1,590 +0,0 @@ |
| 470 | -/* SPDX-License-Identifier: MIT */ |
| 471 | -/* |
| 472 | - * Copyright (C) 2020 Google, Inc. |
| 473 | - * |
| 474 | - * Trusty and TF-A also have a copy of this header. |
| 475 | - * Please keep the copies in sync. |
| 476 | - */ |
| 477 | -#ifndef __LINUX_TRUSTY_ARM_FFA_H |
| 478 | -#define __LINUX_TRUSTY_ARM_FFA_H |
| 479 | - |
| 480 | -/* |
| 481 | - * Subset of Arm PSA Firmware Framework for Arm v8-A 1.0 EAC 1_0 |
| 482 | - * (https://developer.arm.com/docs/den0077/a) needed for shared memory. |
| 483 | - */ |
| 484 | - |
| 485 | -#include "smcall.h" |
| 486 | - |
| 487 | -#ifndef STATIC_ASSERT |
| 488 | -#define STATIC_ASSERT(e) _Static_assert(e, #e) |
| 489 | -#endif |
| 490 | - |
| 491 | -#define FFA_CURRENT_VERSION_MAJOR (1U) |
| 492 | -#define FFA_CURRENT_VERSION_MINOR (0U) |
| 493 | - |
| 494 | -#define FFA_VERSION_TO_MAJOR(version) ((version) >> 16) |
| 495 | -#define FFA_VERSION_TO_MINOR(version) ((version) & (0xffff)) |
| 496 | -#define FFA_VERSION(major, minor) (((major) << 16) | (minor)) |
| 497 | -#define FFA_CURRENT_VERSION \ |
| 498 | - FFA_VERSION(FFA_CURRENT_VERSION_MAJOR, FFA_CURRENT_VERSION_MINOR) |
| 499 | - |
| 500 | -#define SMC_ENTITY_SHARED_MEMORY 4 |
| 501 | - |
| 502 | -#define SMC_FASTCALL_NR_SHARED_MEMORY(nr) \ |
| 503 | - SMC_FASTCALL_NR(SMC_ENTITY_SHARED_MEMORY, nr) |
| 504 | -#define SMC_FASTCALL64_NR_SHARED_MEMORY(nr) \ |
| 505 | - SMC_FASTCALL64_NR(SMC_ENTITY_SHARED_MEMORY, nr) |
| 506 | - |
| 507 | -/** |
| 508 | - * typedef ffa_endpoint_id16_t - Endpoint ID |
| 509 | - * |
| 510 | - * Current implementation only supports VMIDs. FFA spec also support stream |
| 511 | - * endpoint ids. |
| 512 | - */ |
| 513 | -typedef uint16_t ffa_endpoint_id16_t; |
| 514 | - |
| 515 | -/** |
| 516 | - * struct ffa_cons_mrd - Constituent memory region descriptor |
| 517 | - * @address: |
| 518 | - * Start address of contiguous memory region. Must be 4K page aligned. |
| 519 | - * @page_count: |
| 520 | - * Number of 4K pages in region. |
| 521 | - * @reserved_12_15: |
| 522 | - * Reserve bytes 12-15 to pad struct size to 16 bytes. |
| 523 | - */ |
| 524 | -struct ffa_cons_mrd { |
| 525 | - uint64_t address; |
| 526 | - uint32_t page_count; |
| 527 | - uint32_t reserved_12_15; |
| 528 | -}; |
| 529 | -STATIC_ASSERT(sizeof(struct ffa_cons_mrd) == 16); |
| 530 | - |
| 531 | -/** |
| 532 | - * struct ffa_comp_mrd - Composite memory region descriptor |
| 533 | - * @total_page_count: |
| 534 | - * Number of 4k pages in memory region. Must match sum of |
| 535 | - * @address_range_array[].page_count. |
| 536 | - * @address_range_count: |
| 537 | - * Number of entries in @address_range_array. |
| 538 | - * @reserved_8_15: |
| 539 | - * Reserve bytes 8-15 to pad struct size to 16 byte alignment and |
| 540 | - * make @address_range_array 16 byte aligned. |
| 541 | - * @address_range_array: |
| 542 | - * Array of &struct ffa_cons_mrd entries. |
| 543 | - */ |
| 544 | -struct ffa_comp_mrd { |
| 545 | - uint32_t total_page_count; |
| 546 | - uint32_t address_range_count; |
| 547 | - uint64_t reserved_8_15; |
| 548 | - struct ffa_cons_mrd address_range_array[]; |
| 549 | -}; |
| 550 | -STATIC_ASSERT(sizeof(struct ffa_comp_mrd) == 16); |
| 551 | - |
| 552 | -/** |
| 553 | - * typedef ffa_mem_attr8_t - Memory region attributes |
| 554 | - * |
| 555 | - * * @FFA_MEM_ATTR_DEVICE_NGNRNE: |
| 556 | - * Device-nGnRnE. |
| 557 | - * * @FFA_MEM_ATTR_DEVICE_NGNRE: |
| 558 | - * Device-nGnRE. |
| 559 | - * * @FFA_MEM_ATTR_DEVICE_NGRE: |
| 560 | - * Device-nGRE. |
| 561 | - * * @FFA_MEM_ATTR_DEVICE_GRE: |
| 562 | - * Device-GRE. |
| 563 | - * * @FFA_MEM_ATTR_NORMAL_MEMORY_UNCACHED |
| 564 | - * Normal memory. Non-cacheable. |
| 565 | - * * @FFA_MEM_ATTR_NORMAL_MEMORY_CACHED_WB |
| 566 | - * Normal memory. Write-back cached. |
| 567 | - * * @FFA_MEM_ATTR_NON_SHAREABLE |
| 568 | - * Non-shareable. Combine with FFA_MEM_ATTR_NORMAL_MEMORY_*. |
| 569 | - * * @FFA_MEM_ATTR_OUTER_SHAREABLE |
| 570 | - * Outer Shareable. Combine with FFA_MEM_ATTR_NORMAL_MEMORY_*. |
| 571 | - * * @FFA_MEM_ATTR_INNER_SHAREABLE |
| 572 | - * Inner Shareable. Combine with FFA_MEM_ATTR_NORMAL_MEMORY_*. |
| 573 | - */ |
| 574 | -typedef uint8_t ffa_mem_attr8_t; |
| 575 | -#define FFA_MEM_ATTR_DEVICE_NGNRNE ((1U << 4) | (0x0U << 2)) |
| 576 | -#define FFA_MEM_ATTR_DEVICE_NGNRE ((1U << 4) | (0x1U << 2)) |
| 577 | -#define FFA_MEM_ATTR_DEVICE_NGRE ((1U << 4) | (0x2U << 2)) |
| 578 | -#define FFA_MEM_ATTR_DEVICE_GRE ((1U << 4) | (0x3U << 2)) |
| 579 | -#define FFA_MEM_ATTR_NORMAL_MEMORY_UNCACHED ((2U << 4) | (0x1U << 2)) |
| 580 | -#define FFA_MEM_ATTR_NORMAL_MEMORY_CACHED_WB ((2U << 4) | (0x3U << 2)) |
| 581 | -#define FFA_MEM_ATTR_NON_SHAREABLE (0x0U << 0) |
| 582 | -#define FFA_MEM_ATTR_OUTER_SHAREABLE (0x2U << 0) |
| 583 | -#define FFA_MEM_ATTR_INNER_SHAREABLE (0x3U << 0) |
| 584 | - |
| 585 | -/** |
| 586 | - * typedef ffa_mem_perm8_t - Memory access permissions |
| 587 | - * |
| 588 | - * * @FFA_MEM_ATTR_RO |
| 589 | - * Request or specify read-only mapping. |
| 590 | - * * @FFA_MEM_ATTR_RW |
| 591 | - * Request or allow read-write mapping. |
| 592 | - * * @FFA_MEM_PERM_NX |
| 593 | - * Deny executable mapping. |
| 594 | - * * @FFA_MEM_PERM_X |
| 595 | - * Request executable mapping. |
| 596 | - */ |
| 597 | -typedef uint8_t ffa_mem_perm8_t; |
| 598 | -#define FFA_MEM_PERM_RO (1U << 0) |
| 599 | -#define FFA_MEM_PERM_RW (1U << 1) |
| 600 | -#define FFA_MEM_PERM_NX (1U << 2) |
| 601 | -#define FFA_MEM_PERM_X (1U << 3) |
| 602 | - |
| 603 | -/** |
| 604 | - * typedef ffa_mem_flag8_t - Endpoint memory flags |
| 605 | - * |
| 606 | - * * @FFA_MEM_FLAG_OTHER |
| 607 | - * Other borrower. Memory region must not be or was not retrieved on behalf |
| 608 | - * of this endpoint. |
| 609 | - */ |
| 610 | -typedef uint8_t ffa_mem_flag8_t; |
| 611 | -#define FFA_MEM_FLAG_OTHER (1U << 0) |
| 612 | - |
| 613 | -/** |
| 614 | - * typedef ffa_mtd_flag32_t - Memory transaction descriptor flags |
| 615 | - * |
| 616 | - * * @FFA_MTD_FLAG_ZERO_MEMORY |
| 617 | - * Zero memory after unmapping from sender (must be 0 for share). |
| 618 | - * * @FFA_MTD_FLAG_TIME_SLICING |
| 619 | - * Not supported by this implementation. |
| 620 | - * * @FFA_MTD_FLAG_ZERO_MEMORY_AFTER_RELINQUISH |
| 621 | - * Zero memory after unmapping from borrowers (must be 0 for share). |
| 622 | - * * @FFA_MTD_FLAG_TYPE_MASK |
| 623 | - * Bit-mask to extract memory management transaction type from flags. |
| 624 | - * * @FFA_MTD_FLAG_TYPE_SHARE_MEMORY |
| 625 | - * Share memory transaction flag. |
| 626 | - * Used by @SMC_FC_FFA_MEM_RETRIEVE_RESP to indicate that memory came from |
| 627 | - * @SMC_FC_FFA_MEM_SHARE and by @SMC_FC_FFA_MEM_RETRIEVE_REQ to specify that |
| 628 | - * it must have. |
| 629 | - * * @FFA_MTD_FLAG_ADDRESS_RANGE_ALIGNMENT_HINT_MASK |
| 630 | - * Not supported by this implementation. |
| 631 | - */ |
| 632 | -typedef uint32_t ffa_mtd_flag32_t; |
| 633 | -#define FFA_MTD_FLAG_ZERO_MEMORY (1U << 0) |
| 634 | -#define FFA_MTD_FLAG_TIME_SLICING (1U << 1) |
| 635 | -#define FFA_MTD_FLAG_ZERO_MEMORY_AFTER_RELINQUISH (1U << 2) |
| 636 | -#define FFA_MTD_FLAG_TYPE_MASK (3U << 3) |
| 637 | -#define FFA_MTD_FLAG_TYPE_SHARE_MEMORY (1U << 3) |
| 638 | -#define FFA_MTD_FLAG_ADDRESS_RANGE_ALIGNMENT_HINT_MASK (0x1FU << 5) |
| 639 | - |
| 640 | -/** |
| 641 | - * struct ffa_mapd - Memory access permissions descriptor |
| 642 | - * @endpoint_id: |
| 643 | - * Endpoint id that @memory_access_permissions and @flags apply to. |
| 644 | - * (&typedef ffa_endpoint_id16_t). |
| 645 | - * @memory_access_permissions: |
| 646 | - * FFA_MEM_PERM_* values or'ed together (&typedef ffa_mem_perm8_t). |
| 647 | - * @flags: |
| 648 | - * FFA_MEM_FLAG_* values or'ed together (&typedef ffa_mem_flag8_t). |
| 649 | - */ |
| 650 | -struct ffa_mapd { |
| 651 | - ffa_endpoint_id16_t endpoint_id; |
| 652 | - ffa_mem_perm8_t memory_access_permissions; |
| 653 | - ffa_mem_flag8_t flags; |
| 654 | -}; |
| 655 | -STATIC_ASSERT(sizeof(struct ffa_mapd) == 4); |
| 656 | - |
| 657 | -/** |
| 658 | - * struct ffa_emad - Endpoint memory access descriptor. |
| 659 | - * @mapd: &struct ffa_mapd. |
| 660 | - * @comp_mrd_offset: |
| 661 | - * Offset of &struct ffa_comp_mrd form start of &struct ffa_mtd. |
| 662 | - * @reserved_8_15: |
| 663 | - * Reserved bytes 8-15. Must be 0. |
| 664 | - */ |
| 665 | -struct ffa_emad { |
| 666 | - struct ffa_mapd mapd; |
| 667 | - uint32_t comp_mrd_offset; |
| 668 | - uint64_t reserved_8_15; |
| 669 | -}; |
| 670 | -STATIC_ASSERT(sizeof(struct ffa_emad) == 16); |
| 671 | - |
| 672 | -/** |
| 673 | - * struct ffa_mtd - Memory transaction descriptor. |
| 674 | - * @sender_id: |
| 675 | - * Sender endpoint id. |
| 676 | - * @memory_region_attributes: |
| 677 | - * FFA_MEM_ATTR_* values or'ed together (&typedef ffa_mem_attr8_t). |
| 678 | - * @reserved_3: |
| 679 | - * Reserved bytes 3. Must be 0. |
| 680 | - * @flags: |
| 681 | - * FFA_MTD_FLAG_* values or'ed together (&typedef ffa_mtd_flag32_t). |
| 682 | - * @handle: |
| 683 | - * Id of shared memory object. Most be 0 for MEM_SHARE. |
| 684 | - * @tag: Client allocated tag. Must match original value. |
| 685 | - * @reserved_24_27: |
| 686 | - * Reserved bytes 24-27. Must be 0. |
| 687 | - * @emad_count: |
| 688 | - * Number of entries in @emad. Must be 1 in current implementation. |
| 689 | - * FFA spec allows more entries. |
| 690 | - * @emad: |
| 691 | - * Endpoint memory access descriptor array (see @struct ffa_emad). |
| 692 | - */ |
| 693 | -struct ffa_mtd { |
| 694 | - ffa_endpoint_id16_t sender_id; |
| 695 | - ffa_mem_attr8_t memory_region_attributes; |
| 696 | - uint8_t reserved_3; |
| 697 | - ffa_mtd_flag32_t flags; |
| 698 | - uint64_t handle; |
| 699 | - uint64_t tag; |
| 700 | - uint32_t reserved_24_27; |
| 701 | - uint32_t emad_count; |
| 702 | - struct ffa_emad emad[]; |
| 703 | -}; |
| 704 | -STATIC_ASSERT(sizeof(struct ffa_mtd) == 32); |
| 705 | - |
| 706 | -/** |
| 707 | - * struct ffa_mem_relinquish_descriptor - Relinquish request descriptor. |
| 708 | - * @handle: |
| 709 | - * Id of shared memory object to relinquish. |
| 710 | - * @flags: |
| 711 | - * If bit 0 is set clear memory after unmapping from borrower. Must be 0 |
| 712 | - * for share. Bit[1]: Time slicing. Not supported, must be 0. All other |
| 713 | - * bits are reserved 0. |
| 714 | - * @endpoint_count: |
| 715 | - * Number of entries in @endpoint_array. |
| 716 | - * @endpoint_array: |
| 717 | - * Array of endpoint ids. |
| 718 | - */ |
| 719 | -struct ffa_mem_relinquish_descriptor { |
| 720 | - uint64_t handle; |
| 721 | - uint32_t flags; |
| 722 | - uint32_t endpoint_count; |
| 723 | - ffa_endpoint_id16_t endpoint_array[]; |
| 724 | -}; |
| 725 | -STATIC_ASSERT(sizeof(struct ffa_mem_relinquish_descriptor) == 16); |
| 726 | - |
| 727 | -/** |
| 728 | - * enum ffa_error - FF-A error code |
| 729 | - * @FFA_ERROR_NOT_SUPPORTED: |
| 730 | - * Operation contained possibly valid parameters not supported by the |
| 731 | - * current implementation. Does not match FF-A 1.0 EAC 1_0 definition. |
| 732 | - * @FFA_ERROR_INVALID_PARAMETERS: |
| 733 | - * Invalid parameters. Conditions function specific. |
| 734 | - * @FFA_ERROR_NO_MEMORY: |
| 735 | - * Not enough memory. |
| 736 | - * @FFA_ERROR_DENIED: |
| 737 | - * Operation not allowed. Conditions function specific. |
| 738 | - * |
| 739 | - * FF-A 1.0 EAC 1_0 defines other error codes as well but the current |
| 740 | - * implementation does not use them. |
| 741 | - */ |
| 742 | -enum ffa_error { |
| 743 | - FFA_ERROR_NOT_SUPPORTED = -1, |
| 744 | - FFA_ERROR_INVALID_PARAMETERS = -2, |
| 745 | - FFA_ERROR_NO_MEMORY = -3, |
| 746 | - FFA_ERROR_DENIED = -6, |
| 747 | -}; |
| 748 | - |
| 749 | -/** |
| 750 | - * SMC_FC32_FFA_MIN - First 32 bit SMC opcode reserved for FFA |
| 751 | - */ |
| 752 | -#define SMC_FC32_FFA_MIN SMC_FASTCALL_NR_SHARED_MEMORY(0x60) |
| 753 | - |
| 754 | -/** |
| 755 | - * SMC_FC32_FFA_MAX - Last 32 bit SMC opcode reserved for FFA |
| 756 | - */ |
| 757 | -#define SMC_FC32_FFA_MAX SMC_FASTCALL_NR_SHARED_MEMORY(0x7F) |
| 758 | - |
| 759 | -/** |
| 760 | - * SMC_FC64_FFA_MIN - First 64 bit SMC opcode reserved for FFA |
| 761 | - */ |
| 762 | -#define SMC_FC64_FFA_MIN SMC_FASTCALL64_NR_SHARED_MEMORY(0x60) |
| 763 | - |
| 764 | -/** |
| 765 | - * SMC_FC64_FFA_MAX - Last 64 bit SMC opcode reserved for FFA |
| 766 | - */ |
| 767 | -#define SMC_FC64_FFA_MAX SMC_FASTCALL64_NR_SHARED_MEMORY(0x7F) |
| 768 | - |
| 769 | -/** |
| 770 | - * SMC_FC_FFA_ERROR - SMC error return opcode |
| 771 | - * |
| 772 | - * Register arguments: |
| 773 | - * |
| 774 | - * * w1: VMID in [31:16], vCPU in [15:0] |
| 775 | - * * w2: Error code (&enum ffa_error) |
| 776 | - */ |
| 777 | -#define SMC_FC_FFA_ERROR SMC_FASTCALL_NR_SHARED_MEMORY(0x60) |
| 778 | - |
| 779 | -/** |
| 780 | - * SMC_FC_FFA_SUCCESS - 32 bit SMC success return opcode |
| 781 | - * |
| 782 | - * Register arguments: |
| 783 | - * |
| 784 | - * * w1: VMID in [31:16], vCPU in [15:0] |
| 785 | - * * w2-w7: Function specific |
| 786 | - */ |
| 787 | -#define SMC_FC_FFA_SUCCESS SMC_FASTCALL_NR_SHARED_MEMORY(0x61) |
| 788 | - |
| 789 | -/** |
| 790 | - * SMC_FC64_FFA_SUCCESS - 64 bit SMC success return opcode |
| 791 | - * |
| 792 | - * Register arguments: |
| 793 | - * |
| 794 | - * * w1: VMID in [31:16], vCPU in [15:0] |
| 795 | - * * w2/x2-w7/x7: Function specific |
| 796 | - */ |
| 797 | -#define SMC_FC64_FFA_SUCCESS SMC_FASTCALL64_NR_SHARED_MEMORY(0x61) |
| 798 | - |
| 799 | -/** |
| 800 | - * SMC_FC_FFA_VERSION - SMC opcode to return supported FF-A version |
| 801 | - * |
| 802 | - * Register arguments: |
| 803 | - * |
| 804 | - * * w1: Major version bit[30:16] and minor version in bit[15:0] supported |
| 805 | - * by caller. Bit[31] must be 0. |
| 806 | - * |
| 807 | - * Return: |
| 808 | - * * w0: &SMC_FC_FFA_SUCCESS |
| 809 | - * * w2: Major version bit[30:16], minor version in bit[15:0], bit[31] must |
| 810 | - * be 0. |
| 811 | - * |
| 812 | - * or |
| 813 | - * |
| 814 | - * * w0: SMC_FC_FFA_ERROR |
| 815 | - * * w2: FFA_ERROR_NOT_SUPPORTED if major version passed in is less than the |
| 816 | - * minimum major version supported. |
| 817 | - */ |
| 818 | -#define SMC_FC_FFA_VERSION SMC_FASTCALL_NR_SHARED_MEMORY(0x63) |
| 819 | - |
| 820 | -/** |
| 821 | - * SMC_FC_FFA_FEATURES - SMC opcode to check optional feature support |
| 822 | - * |
| 823 | - * Register arguments: |
| 824 | - * |
| 825 | - * * w1: FF-A function ID |
| 826 | - * |
| 827 | - * Return: |
| 828 | - * * w0: &SMC_FC_FFA_SUCCESS |
| 829 | - * * w2: Bit[0]: Supports custom buffers for memory transactions. |
| 830 | - * Bit[1:0]: For RXTX_MAP min buffer size and alignment boundary. |
| 831 | - * Other bits must be 0. |
| 832 | - * * w3: For FFA_MEM_RETRIEVE_REQ, bit[7-0]: Number of times receiver can |
| 833 | - * retrieve each memory region before relinquishing it specified as |
| 834 | - * ((1U << (value + 1)) - 1 (or value = bits in reference count - 1). |
| 835 | - * For all other bits and commands: must be 0. |
| 836 | - * or |
| 837 | - * |
| 838 | - * * w0: SMC_FC_FFA_ERROR |
| 839 | - * * w2: FFA_ERROR_NOT_SUPPORTED if function is not implemented, or |
| 840 | - * FFA_ERROR_INVALID_PARAMETERS if function id is not valid. |
| 841 | - */ |
| 842 | -#define SMC_FC_FFA_FEATURES SMC_FASTCALL_NR_SHARED_MEMORY(0x64) |
| 843 | - |
| 844 | -/** |
| 845 | - * SMC_FC_FFA_RXTX_MAP - 32 bit SMC opcode to map message buffers |
| 846 | - * |
| 847 | - * Register arguments: |
| 848 | - * |
| 849 | - * * w1: TX address |
| 850 | - * * w2: RX address |
| 851 | - * * w3: RX/TX page count in bit[5:0] |
| 852 | - * |
| 853 | - * Return: |
| 854 | - * * w0: &SMC_FC_FFA_SUCCESS |
| 855 | - */ |
| 856 | -#define SMC_FC_FFA_RXTX_MAP SMC_FASTCALL_NR_SHARED_MEMORY(0x66) |
| 857 | - |
| 858 | -/** |
| 859 | - * SMC_FC64_FFA_RXTX_MAP - 64 bit SMC opcode to map message buffers |
| 860 | - * |
| 861 | - * Register arguments: |
| 862 | - * |
| 863 | - * * x1: TX address |
| 864 | - * * x2: RX address |
| 865 | - * * x3: RX/TX page count in bit[5:0] |
| 866 | - * |
| 867 | - * Return: |
| 868 | - * * w0: &SMC_FC_FFA_SUCCESS |
| 869 | - */ |
| 870 | -#define SMC_FC64_FFA_RXTX_MAP SMC_FASTCALL64_NR_SHARED_MEMORY(0x66) |
| 871 | -#ifdef CONFIG_64BIT |
| 872 | -#define SMC_FCZ_FFA_RXTX_MAP SMC_FC64_FFA_RXTX_MAP |
| 873 | -#else |
| 874 | -#define SMC_FCZ_FFA_RXTX_MAP SMC_FC_FFA_RXTX_MAP |
| 875 | -#endif |
| 876 | - |
| 877 | -/** |
| 878 | - * SMC_FC_FFA_RXTX_UNMAP - SMC opcode to unmap message buffers |
| 879 | - * |
| 880 | - * Register arguments: |
| 881 | - * |
| 882 | - * * w1: ID in [31:16] |
| 883 | - * |
| 884 | - * Return: |
| 885 | - * * w0: &SMC_FC_FFA_SUCCESS |
| 886 | - */ |
| 887 | -#define SMC_FC_FFA_RXTX_UNMAP SMC_FASTCALL_NR_SHARED_MEMORY(0x67) |
| 888 | - |
| 889 | -/** |
| 890 | - * SMC_FC_FFA_ID_GET - SMC opcode to get endpoint id of caller |
| 891 | - * |
| 892 | - * Return: |
| 893 | - * * w0: &SMC_FC_FFA_SUCCESS |
| 894 | - * * w2: ID in bit[15:0], bit[31:16] must be 0. |
| 895 | - */ |
| 896 | -#define SMC_FC_FFA_ID_GET SMC_FASTCALL_NR_SHARED_MEMORY(0x69) |
| 897 | - |
| 898 | -/** |
| 899 | - * SMC_FC_FFA_MEM_DONATE - 32 bit SMC opcode to donate memory |
| 900 | - * |
| 901 | - * Not supported. |
| 902 | - */ |
| 903 | -#define SMC_FC_FFA_MEM_DONATE SMC_FASTCALL_NR_SHARED_MEMORY(0x71) |
| 904 | - |
| 905 | -/** |
| 906 | - * SMC_FC_FFA_MEM_LEND - 32 bit SMC opcode to lend memory |
| 907 | - * |
| 908 | - * Not currently supported. |
| 909 | - */ |
| 910 | -#define SMC_FC_FFA_MEM_LEND SMC_FASTCALL_NR_SHARED_MEMORY(0x72) |
| 911 | - |
| 912 | -/** |
| 913 | - * SMC_FC_FFA_MEM_SHARE - 32 bit SMC opcode to share memory |
| 914 | - * |
| 915 | - * Register arguments: |
| 916 | - * |
| 917 | - * * w1: Total length |
| 918 | - * * w2: Fragment length |
| 919 | - * * w3: Address |
| 920 | - * * w4: Page count |
| 921 | - * |
| 922 | - * Return: |
| 923 | - * * w0: &SMC_FC_FFA_SUCCESS |
| 924 | - * * w2/w3: Handle |
| 925 | - * |
| 926 | - * or |
| 927 | - * |
| 928 | - * * w0: &SMC_FC_FFA_MEM_FRAG_RX |
| 929 | - * * w1-: See &SMC_FC_FFA_MEM_FRAG_RX |
| 930 | - * |
| 931 | - * or |
| 932 | - * |
| 933 | - * * w0: SMC_FC_FFA_ERROR |
| 934 | - * * w2: Error code (&enum ffa_error) |
| 935 | - */ |
| 936 | -#define SMC_FC_FFA_MEM_SHARE SMC_FASTCALL_NR_SHARED_MEMORY(0x73) |
| 937 | - |
| 938 | -/** |
| 939 | - * SMC_FC64_FFA_MEM_SHARE - 64 bit SMC opcode to share memory |
| 940 | - * |
| 941 | - * Register arguments: |
| 942 | - * |
| 943 | - * * w1: Total length |
| 944 | - * * w2: Fragment length |
| 945 | - * * x3: Address |
| 946 | - * * w4: Page count |
| 947 | - * |
| 948 | - * Return: |
| 949 | - * * w0: &SMC_FC_FFA_SUCCESS |
| 950 | - * * w2/w3: Handle |
| 951 | - * |
| 952 | - * or |
| 953 | - * |
| 954 | - * * w0: &SMC_FC_FFA_MEM_FRAG_RX |
| 955 | - * * w1-: See &SMC_FC_FFA_MEM_FRAG_RX |
| 956 | - * |
| 957 | - * or |
| 958 | - * |
| 959 | - * * w0: SMC_FC_FFA_ERROR |
| 960 | - * * w2: Error code (&enum ffa_error) |
| 961 | - */ |
| 962 | -#define SMC_FC64_FFA_MEM_SHARE SMC_FASTCALL64_NR_SHARED_MEMORY(0x73) |
| 963 | - |
| 964 | -/** |
| 965 | - * SMC_FC_FFA_MEM_RETRIEVE_REQ - 32 bit SMC opcode to retrieve shared memory |
| 966 | - * |
| 967 | - * Register arguments: |
| 968 | - * |
| 969 | - * * w1: Total length |
| 970 | - * * w2: Fragment length |
| 971 | - * * w3: Address |
| 972 | - * * w4: Page count |
| 973 | - * |
| 974 | - * Return: |
| 975 | - * * w0: &SMC_FC_FFA_MEM_RETRIEVE_RESP |
| 976 | - * * w1/x1-w5/x5: See &SMC_FC_FFA_MEM_RETRIEVE_RESP |
| 977 | - */ |
| 978 | -#define SMC_FC_FFA_MEM_RETRIEVE_REQ SMC_FASTCALL_NR_SHARED_MEMORY(0x74) |
| 979 | - |
| 980 | -/** |
| 981 | - * SMC_FC64_FFA_MEM_RETRIEVE_REQ - 64 bit SMC opcode to retrieve shared memory |
| 982 | - * |
| 983 | - * Register arguments: |
| 984 | - * |
| 985 | - * * w1: Total length |
| 986 | - * * w2: Fragment length |
| 987 | - * * x3: Address |
| 988 | - * * w4: Page count |
| 989 | - * |
| 990 | - * Return: |
| 991 | - * * w0: &SMC_FC_FFA_MEM_RETRIEVE_RESP |
| 992 | - * * w1/x1-w5/x5: See &SMC_FC_FFA_MEM_RETRIEVE_RESP |
| 993 | - */ |
| 994 | -#define SMC_FC64_FFA_MEM_RETRIEVE_REQ SMC_FASTCALL64_NR_SHARED_MEMORY(0x74) |
| 995 | - |
| 996 | -/** |
| 997 | - * SMC_FC_FFA_MEM_RETRIEVE_RESP - Retrieve 32 bit SMC return opcode |
| 998 | - * |
| 999 | - * Register arguments: |
| 1000 | - * |
| 1001 | - * * w1: Total length |
| 1002 | - * * w2: Fragment length |
| 1003 | - */ |
| 1004 | -#define SMC_FC_FFA_MEM_RETRIEVE_RESP SMC_FASTCALL_NR_SHARED_MEMORY(0x75) |
| 1005 | - |
| 1006 | -/** |
| 1007 | - * SMC_FC_FFA_MEM_RELINQUISH - SMC opcode to relinquish shared memory |
| 1008 | - * |
| 1009 | - * Input in &struct ffa_mem_relinquish_descriptor format in message buffer. |
| 1010 | - * |
| 1011 | - * Return: |
| 1012 | - * * w0: &SMC_FC_FFA_SUCCESS |
| 1013 | - */ |
| 1014 | -#define SMC_FC_FFA_MEM_RELINQUISH SMC_FASTCALL_NR_SHARED_MEMORY(0x76) |
| 1015 | - |
| 1016 | -/** |
| 1017 | - * SMC_FC_FFA_MEM_RECLAIM - SMC opcode to reclaim shared memory |
| 1018 | - * |
| 1019 | - * Register arguments: |
| 1020 | - * |
| 1021 | - * * w1/w2: Handle |
| 1022 | - * * w3: Flags |
| 1023 | - * |
| 1024 | - * Return: |
| 1025 | - * * w0: &SMC_FC_FFA_SUCCESS |
| 1026 | - */ |
| 1027 | -#define SMC_FC_FFA_MEM_RECLAIM SMC_FASTCALL_NR_SHARED_MEMORY(0x77) |
| 1028 | - |
| 1029 | -/** |
| 1030 | - * SMC_FC_FFA_MEM_FRAG_RX - SMC opcode to request next fragment. |
| 1031 | - * |
| 1032 | - * Register arguments: |
| 1033 | - * |
| 1034 | - * * w1/w2: Cookie |
| 1035 | - * * w3: Fragment offset. |
| 1036 | - * * w4: Endpoint id ID in [31:16], if client is hypervisor. |
| 1037 | - * |
| 1038 | - * Return: |
| 1039 | - * * w0: &SMC_FC_FFA_MEM_FRAG_TX |
| 1040 | - * * w1/x1-w5/x5: See &SMC_FC_FFA_MEM_FRAG_TX |
| 1041 | - */ |
| 1042 | -#define SMC_FC_FFA_MEM_FRAG_RX SMC_FASTCALL_NR_SHARED_MEMORY(0x7A) |
| 1043 | - |
| 1044 | -/** |
| 1045 | - * SMC_FC_FFA_MEM_FRAG_TX - SMC opcode to transmit next fragment |
| 1046 | - * |
| 1047 | - * Register arguments: |
| 1048 | - * |
| 1049 | - * * w1/w2: Cookie |
| 1050 | - * * w3: Fragment length. |
| 1051 | - * * w4: Sender endpoint id ID in [31:16], if client is hypervisor. |
| 1052 | - * |
| 1053 | - * Return: |
| 1054 | - * * w0: &SMC_FC_FFA_MEM_FRAG_RX or &SMC_FC_FFA_SUCCESS. |
| 1055 | - * * w1/x1-w5/x5: See opcode in w0. |
| 1056 | - */ |
| 1057 | -#define SMC_FC_FFA_MEM_FRAG_TX SMC_FASTCALL_NR_SHARED_MEMORY(0x7B) |
| 1058 | - |
| 1059 | -#endif /* __LINUX_TRUSTY_ARM_FFA_H */ |
| 1060 | diff --git a/include/linux/trusty/trusty.h b/include/linux/trusty/trusty.h |
| 1061 | index efbb36999a8b..272d96c1c696 100644 |
| 1062 | --- a/include/linux/trusty/trusty.h |
| 1063 | +++ b/include/linux/trusty/trusty.h |
| 1064 | @@ -52,9 +52,6 @@ u32 trusty_get_api_version(struct device *dev); |
| 1065 | bool trusty_get_panic_status(struct device *dev); |
| 1066 | |
| 1067 | struct ns_mem_page_info { |
| 1068 | - u64 paddr; |
| 1069 | - u8 ffa_mem_attr; |
| 1070 | - u8 ffa_mem_perm; |
| 1071 | u64 compat_attr; |
| 1072 | }; |
| 1073 | |
| 1074 | -- |
| 1075 | 2.30.2 |
| 1076 | |