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 support for RSU commands in asynchronous framework

Integrate Remote System Update(RSU) service commands into the
asynchronous framework for communicating with SDM. This allows the RSU
commands to be processed asynchronously, improving the responsiveness
of the Stratix10 service channel.

The asynchronous framework now supports the following RSU commands:
* COMMAND_RSU_GET_SPT_TABLE
* COMMAND_RSU_STATUS
* COMMAND_RSU_NOTIFY

Signed-off-by: Mahesh Rao <mahesh.rao@altera.com>
Reviewed-by: Matthew Gerlach <matthew.gerlach@altera.com>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>

authored by

Mahesh Rao and committed by
Dinh Nguyen
ec523793 bcb9f4f0

+128
+72
drivers/firmware/stratix10-svc.c
··· 90 90 #define STRATIX10_SIP_SMC_SET_TRANSACTIONID_X1(transaction_id) \ 91 91 (FIELD_PREP(STRATIX10_TRANS_ID_FIELD, transaction_id)) 92 92 93 + /* 10-bit mask for extracting the SDM status code */ 94 + #define STRATIX10_SDM_STATUS_MASK GENMASK(9, 0) 95 + /* Macro to get the SDM mailbox error status */ 96 + #define STRATIX10_GET_SDM_STATUS_CODE(status) \ 97 + (FIELD_GET(STRATIX10_SDM_STATUS_MASK, status)) 98 + 93 99 typedef void (svc_invoke_fn)(unsigned long, unsigned long, unsigned long, 94 100 unsigned long, unsigned long, unsigned long, 95 101 unsigned long, unsigned long, ··· 1279 1273 STRATIX10_SIP_SMC_SET_TRANSACTIONID_X1(handle->transaction_id); 1280 1274 1281 1275 switch (p_msg->command) { 1276 + case COMMAND_RSU_GET_SPT_TABLE: 1277 + args.a0 = INTEL_SIP_SMC_ASYNC_RSU_GET_SPT; 1278 + break; 1279 + case COMMAND_RSU_STATUS: 1280 + args.a0 = INTEL_SIP_SMC_ASYNC_RSU_GET_ERROR_STATUS; 1281 + break; 1282 + case COMMAND_RSU_NOTIFY: 1283 + args.a0 = INTEL_SIP_SMC_ASYNC_RSU_NOTIFY; 1284 + args.a2 = p_msg->arg[0]; 1285 + break; 1282 1286 default: 1283 1287 dev_err(ctrl->dev, "Invalid command ,%d\n", p_msg->command); 1284 1288 ret = -EINVAL; ··· 1342 1326 return ret; 1343 1327 } 1344 1328 EXPORT_SYMBOL_GPL(stratix10_svc_async_send); 1329 + 1330 + /** 1331 + * stratix10_svc_async_prepare_response - Prepare the response data for 1332 + * an asynchronous transaction. 1333 + * @chan: Pointer to the service channel structure. 1334 + * @handle: Pointer to the asynchronous handler structure. 1335 + * @data: Pointer to the callback data structure. 1336 + * 1337 + * This function prepares the response data for an asynchronous transaction. It 1338 + * extracts the response data from the SMC response structure and stores it in 1339 + * the callback data structure. The function also logs the completion of the 1340 + * asynchronous transaction. 1341 + * 1342 + * Return: 0 on success, -ENOENT if the command is invalid 1343 + */ 1344 + static int stratix10_svc_async_prepare_response(struct stratix10_svc_chan *chan, 1345 + struct stratix10_svc_async_handler *handle, 1346 + struct stratix10_svc_cb_data *data) 1347 + { 1348 + struct stratix10_svc_client_msg *p_msg = 1349 + (struct stratix10_svc_client_msg *)handle->msg; 1350 + struct stratix10_svc_controller *ctrl = chan->ctrl; 1351 + 1352 + data->status = STRATIX10_GET_SDM_STATUS_CODE(handle->res.a1); 1353 + 1354 + switch (p_msg->command) { 1355 + case COMMAND_RSU_NOTIFY: 1356 + break; 1357 + case COMMAND_RSU_GET_SPT_TABLE: 1358 + data->kaddr1 = (void *)&handle->res.a2; 1359 + data->kaddr2 = (void *)&handle->res.a3; 1360 + break; 1361 + case COMMAND_RSU_STATUS: 1362 + /* COMMAND_RSU_STATUS has more elements than the cb_data 1363 + * can acomodate, so passing the response structure to the 1364 + * response function to be handled before done command is 1365 + * executed by the client. 1366 + */ 1367 + data->kaddr1 = (void *)&handle->res; 1368 + break; 1369 + 1370 + default: 1371 + dev_alert(ctrl->dev, "Invalid command\n ,%d", p_msg->command); 1372 + return -ENOENT; 1373 + } 1374 + dev_dbg(ctrl->dev, "Async message completed transaction_id 0x%02x\n", 1375 + handle->transaction_id); 1376 + return 0; 1377 + } 1378 + 1345 1379 /** 1346 1380 * stratix10_svc_async_poll - Polls the status of an asynchronous 1347 1381 * transaction. ··· 1421 1355 struct stratix10_svc_controller *ctrl; 1422 1356 struct stratix10_async_ctrl *actrl; 1423 1357 struct stratix10_async_chan *achan; 1358 + int ret; 1424 1359 1425 1360 if (!chan || !tx_handle || !data) 1426 1361 return -EINVAL; ··· 1453 1386 memset(data, 0, sizeof(*data)); 1454 1387 1455 1388 if (handle->res.a0 == INTEL_SIP_SMC_STATUS_OK) { 1389 + ret = stratix10_svc_async_prepare_response(chan, handle, data); 1390 + if (ret) { 1391 + dev_err(ctrl->dev, "Error in preparation of response,%d\n", ret); 1392 + WARN_ON_ONCE(1); 1393 + } 1456 1394 return 0; 1457 1395 } else if (handle->res.a0 == INTEL_SIP_SMC_STATUS_BUSY) { 1458 1396 dev_dbg(ctrl->dev, "async message is still in progress\n");
+52
include/linux/firmware/intel/stratix10-smc.h
··· 679 679 #define INTEL_SIP_SMC_ASYNC_FUNC_ID_POLL (0xC8) 680 680 #define INTEL_SIP_SMC_ASYNC_POLL \ 681 681 INTEL_SIP_SMC_ASYNC_VAL(INTEL_SIP_SMC_ASYNC_FUNC_ID_POLL) 682 + 683 + /** 684 + * Request INTEL_SIP_SMC_ASYNC_RSU_GET_SPT 685 + * Async call to get RSU SPT from SDM. 686 + * Call register usage: 687 + * a0 INTEL_SIP_SMC_ASYNC_RSU_GET_SPT 688 + * a1 transaction job id 689 + * a2-a17 not used 690 + * 691 + * Return status: 692 + * a0 INTEL_SIP_SMC_STATUS_OK ,INTEL_SIP_SMC_STATUS_REJECTED 693 + * or INTEL_SIP_SMC_STATUS_BUSY 694 + * a1-a17 not used 695 + */ 696 + #define INTEL_SIP_SMC_ASYNC_FUNC_ID_RSU_GET_SPT (0xEA) 697 + #define INTEL_SIP_SMC_ASYNC_RSU_GET_SPT \ 698 + INTEL_SIP_SMC_ASYNC_VAL(INTEL_SIP_SMC_ASYNC_FUNC_ID_RSU_GET_SPT) 699 + 700 + /** 701 + * Request INTEL_SIP_SMC_ASYNC_RSU_GET_ERROR_STATUS 702 + * Async call to get RSU error status from SDM. 703 + * Call register usage: 704 + * a0 INTEL_SIP_SMC_ASYNC_RSU_GET_ERROR_STATUS 705 + * a1 transaction job id 706 + * a2-a17 not used 707 + * 708 + * Return status: 709 + * a0 INTEL_SIP_SMC_STATUS_OK ,INTEL_SIP_SMC_STATUS_REJECTED 710 + * or INTEL_SIP_SMC_STATUS_BUSY 711 + * a1-a17 not used 712 + */ 713 + #define INTEL_SIP_SMC_ASYNC_FUNC_ID_RSU_GET_ERROR_STATUS (0xEB) 714 + #define INTEL_SIP_SMC_ASYNC_RSU_GET_ERROR_STATUS \ 715 + INTEL_SIP_SMC_ASYNC_VAL(INTEL_SIP_SMC_ASYNC_FUNC_ID_RSU_GET_ERROR_STATUS) 716 + 717 + /** 718 + * Request INTEL_SIP_SMC_ASYNC_RSU_NOTIFY 719 + * Async call to send NOTIFY value to SDM. 720 + * Call register usage: 721 + * a0 INTEL_SIP_SMC_ASYNC_RSU_NOTIFY 722 + * a1 transaction job id 723 + * a2 notify value 724 + * a3-a17 not used 725 + * 726 + * Return status: 727 + * a0 INTEL_SIP_SMC_STATUS_OK ,INTEL_SIP_SMC_STATUS_REJECTED 728 + * or INTEL_SIP_SMC_STATUS_BUSY 729 + * a1-a17 not used 730 + */ 731 + #define INTEL_SIP_SMC_ASYNC_FUNC_ID_RSU_NOTIFY (0xEC) 732 + #define INTEL_SIP_SMC_ASYNC_RSU_NOTIFY \ 733 + INTEL_SIP_SMC_ASYNC_VAL(INTEL_SIP_SMC_ASYNC_FUNC_ID_RSU_NOTIFY) 682 734 #endif
+4
include/linux/firmware/intel/stratix10-svc-client.h
··· 128 128 * @COMMAND_RSU_DCMF_STATUS: query firmware for the DCMF status 129 129 * return status is SVC_STATUS_OK or SVC_STATUS_ERROR 130 130 * 131 + * @COMMAND_RSU_GET_SPT_TABLE: query firmware for SPT table 132 + * return status is SVC_STATUS_OK or SVC_STATUS_ERROR 133 + * 131 134 * @COMMAND_FCS_REQUEST_SERVICE: request validation of image from firmware, 132 135 * return status is SVC_STATUS_OK, SVC_STATUS_INVALID_PARAM 133 136 * ··· 165 162 COMMAND_RSU_DCMF_VERSION, 166 163 COMMAND_RSU_DCMF_STATUS, 167 164 COMMAND_FIRMWARE_VERSION, 165 + COMMAND_RSU_GET_SPT_TABLE, 168 166 /* for FCS */ 169 167 COMMAND_FCS_REQUEST_SERVICE = 20, 170 168 COMMAND_FCS_SEND_CERTIFICATE,