Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

firmware: stratix10-svc: add FCS polling command

Introduce a new SMC command INTEL_SIP_SMC_FUNCID_SERVICE_COMPLETED
that polls if a previous asynchronous command was completed. This
SMC command is used by the new FPGA Crypto Service (FCS).
A basic example is that the FCS sends an AES data encryption
call to the secure device manager(SDM) and waits for the completion
of the operation by continuously polling the results with the new
command.

Signed-off-by: Ang Tien Sung <tien.sung.ang@intel.com>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
Link: https://lore.kernel.org/r/20220711223140.2307945-2-dinguyen@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ang Tien Sung and committed by
Greg Kroah-Hartman
79b93625 e6281c26

+67 -5
+37 -5
drivers/firmware/stratix10-svc.c
··· 248 248 { 249 249 struct arm_smccc_res res; 250 250 int count_in_sec; 251 + unsigned long a0, a1, a2; 251 252 252 253 cb_data->kaddr1 = NULL; 253 254 cb_data->kaddr2 = NULL; ··· 257 256 258 257 pr_debug("%s: polling config status\n", __func__); 259 258 259 + a0 = INTEL_SIP_SMC_FPGA_CONFIG_ISDONE; 260 + a1 = (unsigned long)p_data->paddr; 261 + a2 = (unsigned long)p_data->size; 262 + 263 + if (p_data->command == COMMAND_POLL_SERVICE_STATUS) 264 + a0 = INTEL_SIP_SMC_SERVICE_COMPLETED; 265 + 260 266 count_in_sec = FPGA_CONFIG_STATUS_TIMEOUT_SEC; 261 267 while (count_in_sec) { 262 - ctrl->invoke_fn(INTEL_SIP_SMC_FPGA_CONFIG_ISDONE, 263 - 0, 0, 0, 0, 0, 0, 0, &res); 268 + ctrl->invoke_fn(a0, a1, a2, 0, 0, 0, 0, 0, &res); 264 269 if ((res.a0 == INTEL_SIP_SMC_STATUS_OK) || 265 - (res.a0 == INTEL_SIP_SMC_STATUS_ERROR)) 270 + (res.a0 == INTEL_SIP_SMC_STATUS_ERROR) || 271 + (res.a0 == INTEL_SIP_SMC_STATUS_REJECTED)) 266 272 break; 267 273 268 274 /* 269 - * configuration is still in progress, wait one second then 275 + * request is still in progress, wait one second then 270 276 * poll again 271 277 */ 272 278 msleep(1000); 273 279 count_in_sec--; 274 280 } 275 281 276 - if (res.a0 == INTEL_SIP_SMC_STATUS_OK && count_in_sec) 282 + if (!count_in_sec) { 283 + pr_err("%s: poll status timeout\n", __func__); 284 + cb_data->status = BIT(SVC_STATUS_BUSY); 285 + } else if (res.a0 == INTEL_SIP_SMC_STATUS_OK) { 277 286 cb_data->status = BIT(SVC_STATUS_COMPLETED); 287 + cb_data->kaddr2 = (res.a2) ? 288 + svc_pa_to_va(res.a2) : NULL; 289 + cb_data->kaddr3 = (res.a3) ? &res.a3 : NULL; 290 + } else { 291 + pr_err("%s: poll status error\n", __func__); 292 + cb_data->kaddr1 = &res.a1; 293 + cb_data->kaddr2 = (res.a2) ? 294 + svc_pa_to_va(res.a2) : NULL; 295 + cb_data->kaddr3 = (res.a3) ? &res.a3 : NULL; 296 + cb_data->status = BIT(SVC_STATUS_ERROR); 297 + } 278 298 279 299 p_data->chan->scl->receive_cb(p_data->chan->scl, cb_data); 280 300 } ··· 320 298 case COMMAND_RECONFIG: 321 299 case COMMAND_RSU_UPDATE: 322 300 case COMMAND_RSU_NOTIFY: 301 + case COMMAND_POLL_SERVICE_STATUS: 323 302 cb_data->status = BIT(SVC_STATUS_OK); 324 303 break; 325 304 case COMMAND_RECONFIG_DATA_SUBMIT: ··· 453 430 a1 = 0; 454 431 a2 = 0; 455 432 break; 433 + /* for polling */ 434 + case COMMAND_POLL_SERVICE_STATUS: 435 + a0 = INTEL_SIP_SMC_SERVICE_COMPLETED; 436 + a1 = (unsigned long)pdata->paddr; 437 + a2 = (unsigned long)pdata->size; 438 + 439 + break; 440 + 456 441 default: 457 442 pr_warn("it shouldn't happen\n"); 458 443 break; ··· 501 470 pdata, cbdata); 502 471 break; 503 472 case COMMAND_RECONFIG_STATUS: 473 + case COMMAND_POLL_SERVICE_STATUS: 504 474 svc_thread_cmd_config_status(ctrl, 505 475 pdata, cbdata); 506 476 break;
+25
include/linux/firmware/intel/stratix10-smc.h
··· 404 404 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_MAX_RETRY) 405 405 406 406 /** 407 + * Request INTEL_SIP_SMC_SERVICE_COMPLETED 408 + * Sync call to check if the secure world have completed service request 409 + * or not. 410 + * 411 + * Call register usage: 412 + * a0: INTEL_SIP_SMC_SERVICE_COMPLETED 413 + * a1: this register is optional. If used, it is the physical address for 414 + * secure firmware to put output data 415 + * a2: this register is optional. If used, it is the size of output data 416 + * a3-a7: not used 417 + * 418 + * Return status: 419 + * a0: INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_STATUS_ERROR, 420 + * INTEL_SIP_SMC_REJECTED or INTEL_SIP_SMC_STATUS_BUSY 421 + * a1: mailbox error if a0 is INTEL_SIP_SMC_STATUS_ERROR 422 + * a2: physical address containing the process info 423 + * for FCS certificate -- the data contains the certificate status 424 + * for FCS cryption -- the data contains the actual data size FW processes 425 + * a3: output data size 426 + */ 427 + #define INTEL_SIP_SMC_FUNCID_SERVICE_COMPLETED 30 428 + #define INTEL_SIP_SMC_SERVICE_COMPLETED \ 429 + INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_SERVICE_COMPLETED) 430 + 431 + /** 407 432 * Request INTEL_SIP_SMC_FIRMWARE_VERSION 408 433 * 409 434 * Sync call used to query the version of running firmware
+5
include/linux/firmware/intel/stratix10-svc-client.h
··· 106 106 * @COMMAND_RSU_DCMF_VERSION: query firmware for the DCMF version, return status 107 107 * is SVC_STATUS_OK or SVC_STATUS_ERROR 108 108 * 109 + * @COMMAND_POLL_SERVICE_STATUS: poll if the service request is complete, 110 + * return statis is SVC_STATUS_OK, SVC_STATUS_ERROR or SVC_STATUS_BUSY 111 + * 109 112 * @COMMAND_FIRMWARE_VERSION: query running firmware version, return status 110 113 * is SVC_STATUS_OK or SVC_STATUS_ERROR 111 114 */ ··· 125 122 COMMAND_RSU_MAX_RETRY, 126 123 COMMAND_RSU_DCMF_VERSION, 127 124 COMMAND_FIRMWARE_VERSION, 125 + /* for general status poll */ 126 + COMMAND_POLL_SERVICE_STATUS = 40, 128 127 }; 129 128 130 129 /**