forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/intel/skylake/skl-sst-ipc.c
....@@ -1,16 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * skl-sst-ipc.c - Intel skl IPC Support
34 *
45 * Copyright (C) 2014-15, Intel Corporation.
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as version 2, as
8
- * published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful, but
11
- * WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- * General Public License for more details.
146 */
157 #include <linux/device.h>
168
....@@ -249,6 +241,8 @@
249241 IPC_GLB_REPLY_INVALID_CONFIG_DATA_LEN = 121,
250242 IPC_GLB_REPLY_GATEWAY_NOT_INITIALIZED = 140,
251243 IPC_GLB_REPLY_GATEWAY_NOT_EXIST = 141,
244
+ IPC_GLB_REPLY_SCLK_ALREADY_RUNNING = 150,
245
+ IPC_GLB_REPLY_MCLK_ALREADY_RUNNING = 151,
252246
253247 IPC_GLB_REPLY_PPL_NOT_INITIALIZED = 160,
254248 IPC_GLB_REPLY_PPL_NOT_EXIST = 161,
....@@ -287,7 +281,7 @@
287281 size_t tx_size)
288282 {
289283 if (tx_size)
290
- memcpy(msg->tx_data, tx_data, tx_size);
284
+ memcpy(msg->tx.data, tx_data, tx_size);
291285 }
292286
293287 static bool skl_ipc_is_dsp_busy(struct sst_dsp *dsp)
....@@ -301,10 +295,10 @@
301295 /* Lock to be held by caller */
302296 static void skl_ipc_tx_msg(struct sst_generic_ipc *ipc, struct ipc_message *msg)
303297 {
304
- struct skl_ipc_header *header = (struct skl_ipc_header *)(&msg->header);
298
+ struct skl_ipc_header *header = (struct skl_ipc_header *)(&msg->tx.header);
305299
306
- if (msg->tx_size)
307
- sst_dsp_outbox_write(ipc->dsp, msg->tx_data, msg->tx_size);
300
+ if (msg->tx.size)
301
+ sst_dsp_outbox_write(ipc->dsp, msg->tx.data, msg->tx.size);
308302 sst_dsp_shim_write_unlocked(ipc->dsp, SKL_ADSP_REG_HIPCIE,
309303 header->extension);
310304 sst_dsp_shim_write_unlocked(ipc->dsp, SKL_ADSP_REG_HIPCI,
....@@ -342,6 +336,7 @@
342336
343337 msg = list_first_entry(&ipc->rx_list, struct ipc_message, list);
344338
339
+ list_del(&msg->list);
345340 out:
346341 return msg;
347342
....@@ -350,7 +345,7 @@
350345 int skl_ipc_process_notification(struct sst_generic_ipc *ipc,
351346 struct skl_ipc_header header)
352347 {
353
- struct skl_sst *skl = container_of(ipc, struct skl_sst, ipc);
348
+ struct skl_dev *skl = container_of(ipc, struct skl_dev, ipc);
354349
355350 if (IPC_GLB_NOTIFY_MSG_TYPE(header.primary)) {
356351 switch (IPC_GLB_NOTIFY_TYPE(header.primary)) {
....@@ -392,18 +387,47 @@
392387 return 0;
393388 }
394389
395
-static int skl_ipc_set_reply_error_code(u32 reply)
390
+struct skl_ipc_err_map {
391
+ const char *msg;
392
+ enum skl_ipc_glb_reply reply;
393
+ int err;
394
+};
395
+
396
+static struct skl_ipc_err_map skl_err_map[] = {
397
+ {"DSP out of memory", IPC_GLB_REPLY_OUT_OF_MEMORY, -ENOMEM},
398
+ {"DSP busy", IPC_GLB_REPLY_BUSY, -EBUSY},
399
+ {"SCLK already running", IPC_GLB_REPLY_SCLK_ALREADY_RUNNING,
400
+ IPC_GLB_REPLY_SCLK_ALREADY_RUNNING},
401
+ {"MCLK already running", IPC_GLB_REPLY_MCLK_ALREADY_RUNNING,
402
+ IPC_GLB_REPLY_MCLK_ALREADY_RUNNING},
403
+};
404
+
405
+static int skl_ipc_set_reply_error_code(struct sst_generic_ipc *ipc, u32 reply)
396406 {
397
- switch (reply) {
398
- case IPC_GLB_REPLY_OUT_OF_MEMORY:
399
- return -ENOMEM;
407
+ int i;
400408
401
- case IPC_GLB_REPLY_BUSY:
402
- return -EBUSY;
409
+ for (i = 0; i < ARRAY_SIZE(skl_err_map); i++) {
410
+ if (skl_err_map[i].reply == reply)
411
+ break;
412
+ }
403413
404
- default:
414
+ if (i == ARRAY_SIZE(skl_err_map)) {
415
+ dev_err(ipc->dev, "ipc FW reply: %d FW Error Code: %u\n",
416
+ reply,
417
+ ipc->dsp->fw_ops.get_fw_errcode(ipc->dsp));
405418 return -EINVAL;
406419 }
420
+
421
+ if (skl_err_map[i].err < 0)
422
+ dev_err(ipc->dev, "ipc FW reply: %s FW Error Code: %u\n",
423
+ skl_err_map[i].msg,
424
+ ipc->dsp->fw_ops.get_fw_errcode(ipc->dsp));
425
+ else
426
+ dev_info(ipc->dev, "ipc FW reply: %s FW Error Code: %u\n",
427
+ skl_err_map[i].msg,
428
+ ipc->dsp->fw_ops.get_fw_errcode(ipc->dsp));
429
+
430
+ return skl_err_map[i].err;
407431 }
408432
409433 void skl_ipc_process_reply(struct sst_generic_ipc *ipc,
....@@ -412,7 +436,7 @@
412436 struct ipc_message *msg;
413437 u32 reply = header.primary & IPC_GLB_REPLY_STATUS_MASK;
414438 u64 *ipc_header = (u64 *)(&header);
415
- struct skl_sst *skl = container_of(ipc, struct skl_sst, ipc);
439
+ struct skl_dev *skl = container_of(ipc, struct skl_dev, ipc);
416440 unsigned long flags;
417441
418442 spin_lock_irqsave(&ipc->dsp->spinlock, flags);
....@@ -423,11 +447,12 @@
423447 return;
424448 }
425449
450
+ msg->rx.header = *ipc_header;
426451 /* first process the header */
427452 if (reply == IPC_GLB_REPLY_SUCCESS) {
428453 dev_dbg(ipc->dev, "ipc FW reply %x: success\n", header.primary);
429454 /* copy the rx data from the mailbox */
430
- sst_dsp_inbox_read(ipc->dsp, msg->rx_data, msg->rx_size);
455
+ sst_dsp_inbox_read(ipc->dsp, msg->rx.data, msg->rx.size);
431456 switch (IPC_GLB_NOTIFY_MSG_TYPE(header.primary)) {
432457 case IPC_GLB_LOAD_MULTIPLE_MODS:
433458 case IPC_GLB_LOAD_LIBRARY:
....@@ -441,10 +466,7 @@
441466
442467 }
443468 } else {
444
- msg->errno = skl_ipc_set_reply_error_code(reply);
445
- dev_err(ipc->dev, "ipc FW reply: reply=%d\n", reply);
446
- dev_err(ipc->dev, "FW Error Code: %u\n",
447
- ipc->dsp->fw_ops.get_fw_errcode(ipc->dsp));
469
+ msg->errno = skl_ipc_set_reply_error_code(ipc, reply);
448470 switch (IPC_GLB_NOTIFY_MSG_TYPE(header.primary)) {
449471 case IPC_GLB_LOAD_MULTIPLE_MODS:
450472 case IPC_GLB_LOAD_LIBRARY:
....@@ -460,7 +482,6 @@
460482 }
461483
462484 spin_lock_irqsave(&ipc->dsp->spinlock, flags);
463
- list_del(&msg->list);
464485 sst_ipc_tx_msg_reply_complete(ipc, msg);
465486 spin_unlock_irqrestore(&ipc->dsp->spinlock, flags);
466487 }
....@@ -468,7 +489,7 @@
468489 irqreturn_t skl_dsp_irq_thread_handler(int irq, void *context)
469490 {
470491 struct sst_dsp *dsp = context;
471
- struct skl_sst *skl = sst_dsp_get_thread_context(dsp);
492
+ struct skl_dev *skl = dsp->thread_context;
472493 struct sst_generic_ipc *ipc = &skl->ipc;
473494 struct skl_ipc_header header = {0};
474495 u32 hipcie, hipct, hipcte;
....@@ -483,6 +504,7 @@
483504
484505 hipcie = sst_dsp_shim_read_unlocked(dsp, SKL_ADSP_REG_HIPCIE);
485506 hipct = sst_dsp_shim_read_unlocked(dsp, SKL_ADSP_REG_HIPCT);
507
+ hipcte = sst_dsp_shim_read_unlocked(dsp, SKL_ADSP_REG_HIPCTE);
486508
487509 /* reply message from DSP */
488510 if (hipcie & SKL_ADSP_REG_HIPCIE_DONE) {
....@@ -502,7 +524,6 @@
502524
503525 /* New message from DSP */
504526 if (hipct & SKL_ADSP_REG_HIPCT_BUSY) {
505
- hipcte = sst_dsp_shim_read_unlocked(dsp, SKL_ADSP_REG_HIPCTE);
506527 header.primary = hipct;
507528 header.extension = hipcte;
508529 dev_dbg(dsp->dev, "IPC irq: Firmware respond primary:%x\n",
....@@ -575,7 +596,7 @@
575596 SKL_ADSP_REG_ADSPIS) & SKL_ADSPIS_IPC;
576597 }
577598
578
-int skl_ipc_init(struct device *dev, struct skl_sst *skl)
599
+int skl_ipc_init(struct device *dev, struct skl_dev *skl)
579600 {
580601 struct sst_generic_ipc *ipc;
581602 int err;
....@@ -615,7 +636,7 @@
615636 u16 ppl_mem_size, u8 ppl_type, u8 instance_id, u8 lp_mode)
616637 {
617638 struct skl_ipc_header header = {0};
618
- u64 *ipc_header = (u64 *)(&header);
639
+ struct sst_ipc_message request = {0};
619640 int ret;
620641
621642 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
....@@ -626,9 +647,10 @@
626647 header.primary |= IPC_PPL_MEM_SIZE(ppl_mem_size);
627648
628649 header.extension = IPC_PPL_LP_MODE(lp_mode);
650
+ request.header = *(u64 *)(&header);
629651
630652 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary);
631
- ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0);
653
+ ret = sst_ipc_tx_message_wait(ipc, request, NULL);
632654 if (ret < 0) {
633655 dev_err(ipc->dev, "ipc: create pipeline fail, err: %d\n", ret);
634656 return ret;
....@@ -641,16 +663,17 @@
641663 int skl_ipc_delete_pipeline(struct sst_generic_ipc *ipc, u8 instance_id)
642664 {
643665 struct skl_ipc_header header = {0};
644
- u64 *ipc_header = (u64 *)(&header);
666
+ struct sst_ipc_message request = {0};
645667 int ret;
646668
647669 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
648670 header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST);
649671 header.primary |= IPC_GLB_TYPE(IPC_GLB_DELETE_PPL);
650672 header.primary |= IPC_INSTANCE_ID(instance_id);
673
+ request.header = *(u64 *)(&header);
651674
652675 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary);
653
- ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0);
676
+ ret = sst_ipc_tx_message_wait(ipc, request, NULL);
654677 if (ret < 0) {
655678 dev_err(ipc->dev, "ipc: delete pipeline failed, err %d\n", ret);
656679 return ret;
....@@ -664,7 +687,7 @@
664687 u8 instance_id, enum skl_ipc_pipeline_state state)
665688 {
666689 struct skl_ipc_header header = {0};
667
- u64 *ipc_header = (u64 *)(&header);
690
+ struct sst_ipc_message request = {0};
668691 int ret;
669692
670693 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
....@@ -672,9 +695,10 @@
672695 header.primary |= IPC_GLB_TYPE(IPC_GLB_SET_PPL_STATE);
673696 header.primary |= IPC_INSTANCE_ID(instance_id);
674697 header.primary |= IPC_PPL_STATE(state);
698
+ request.header = *(u64 *)(&header);
675699
676700 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary);
677
- ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0);
701
+ ret = sst_ipc_tx_message_wait(ipc, request, NULL);
678702 if (ret < 0) {
679703 dev_err(ipc->dev, "ipc: set pipeline state failed, err: %d\n", ret);
680704 return ret;
....@@ -687,7 +711,7 @@
687711 skl_ipc_save_pipeline(struct sst_generic_ipc *ipc, u8 instance_id, int dma_id)
688712 {
689713 struct skl_ipc_header header = {0};
690
- u64 *ipc_header = (u64 *)(&header);
714
+ struct sst_ipc_message request = {0};
691715 int ret;
692716
693717 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
....@@ -696,8 +720,10 @@
696720 header.primary |= IPC_INSTANCE_ID(instance_id);
697721
698722 header.extension = IPC_DMA_ID(dma_id);
723
+ request.header = *(u64 *)(&header);
724
+
699725 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary);
700
- ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0);
726
+ ret = sst_ipc_tx_message_wait(ipc, request, NULL);
701727 if (ret < 0) {
702728 dev_err(ipc->dev, "ipc: save pipeline failed, err: %d\n", ret);
703729 return ret;
....@@ -710,16 +736,17 @@
710736 int skl_ipc_restore_pipeline(struct sst_generic_ipc *ipc, u8 instance_id)
711737 {
712738 struct skl_ipc_header header = {0};
713
- u64 *ipc_header = (u64 *)(&header);
739
+ struct sst_ipc_message request = {0};
714740 int ret;
715741
716742 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
717743 header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST);
718744 header.primary |= IPC_GLB_TYPE(IPC_GLB_RESTORE_PPL);
719745 header.primary |= IPC_INSTANCE_ID(instance_id);
746
+ request.header = *(u64 *)(&header);
720747
721748 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary);
722
- ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0);
749
+ ret = sst_ipc_tx_message_wait(ipc, request, NULL);
723750 if (ret < 0) {
724751 dev_err(ipc->dev, "ipc: restore pipeline failed, err: %d\n", ret);
725752 return ret;
....@@ -733,7 +760,7 @@
733760 u16 module_id, struct skl_ipc_dxstate_info *dx)
734761 {
735762 struct skl_ipc_header header = {0};
736
- u64 *ipc_header = (u64 *)(&header);
763
+ struct sst_ipc_message request;
737764 int ret;
738765
739766 header.primary = IPC_MSG_TARGET(IPC_MOD_MSG);
....@@ -742,10 +769,13 @@
742769 header.primary |= IPC_MOD_INSTANCE_ID(instance_id);
743770 header.primary |= IPC_MOD_ID(module_id);
744771
772
+ request.header = *(u64 *)(&header);
773
+ request.data = dx;
774
+ request.size = sizeof(*dx);
775
+
745776 dev_dbg(ipc->dev, "In %s primary =%x ext=%x\n", __func__,
746777 header.primary, header.extension);
747
- ret = sst_ipc_tx_message_wait(ipc, *ipc_header,
748
- dx, sizeof(*dx), NULL, 0);
778
+ ret = sst_ipc_tx_message_wait(ipc, request, NULL);
749779 if (ret < 0) {
750780 dev_err(ipc->dev, "ipc: set dx failed, err %d\n", ret);
751781 return ret;
....@@ -759,7 +789,7 @@
759789 struct skl_ipc_init_instance_msg *msg, void *param_data)
760790 {
761791 struct skl_ipc_header header = {0};
762
- u64 *ipc_header = (u64 *)(&header);
792
+ struct sst_ipc_message request;
763793 int ret;
764794 u32 *buffer = (u32 *)param_data;
765795 /* param_block_size must be in dwords */
....@@ -779,10 +809,13 @@
779809 header.extension |= IPC_PARAM_BLOCK_SIZE(param_block_size);
780810 header.extension |= IPC_DOMAIN(msg->domain);
781811
812
+ request.header = *(u64 *)(&header);
813
+ request.data = param_data;
814
+ request.size = msg->param_data_size;
815
+
782816 dev_dbg(ipc->dev, "In %s primary =%x ext=%x\n", __func__,
783817 header.primary, header.extension);
784
- ret = sst_ipc_tx_message_wait(ipc, *ipc_header, param_data,
785
- msg->param_data_size, NULL, 0);
818
+ ret = sst_ipc_tx_message_wait(ipc, request, NULL);
786819
787820 if (ret < 0) {
788821 dev_err(ipc->dev, "ipc: init instance failed\n");
....@@ -797,7 +830,7 @@
797830 struct skl_ipc_bind_unbind_msg *msg)
798831 {
799832 struct skl_ipc_header header = {0};
800
- u64 *ipc_header = (u64 *)(&header);
833
+ struct sst_ipc_message request = {0};
801834 u8 bind_unbind = msg->bind ? IPC_MOD_BIND : IPC_MOD_UNBIND;
802835 int ret;
803836
....@@ -811,10 +844,11 @@
811844 header.extension |= IPC_DST_MOD_INSTANCE_ID(msg->dst_instance_id);
812845 header.extension |= IPC_DST_QUEUE(msg->dst_queue);
813846 header.extension |= IPC_SRC_QUEUE(msg->src_queue);
847
+ request.header = *(u64 *)(&header);
814848
815849 dev_dbg(ipc->dev, "In %s hdr=%x ext=%x\n", __func__, header.primary,
816850 header.extension);
817
- ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0);
851
+ ret = sst_ipc_tx_message_wait(ipc, request, NULL);
818852 if (ret < 0) {
819853 dev_err(ipc->dev, "ipc: bind/unbind failed\n");
820854 return ret;
....@@ -834,7 +868,7 @@
834868 u8 module_cnt, void *data)
835869 {
836870 struct skl_ipc_header header = {0};
837
- u64 *ipc_header = (u64 *)(&header);
871
+ struct sst_ipc_message request;
838872 int ret;
839873
840874 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
....@@ -842,8 +876,11 @@
842876 header.primary |= IPC_GLB_TYPE(IPC_GLB_LOAD_MULTIPLE_MODS);
843877 header.primary |= IPC_LOAD_MODULE_CNT(module_cnt);
844878
845
- ret = sst_ipc_tx_message_nowait(ipc, *ipc_header, data,
846
- (sizeof(u16) * module_cnt));
879
+ request.header = *(u64 *)(&header);
880
+ request.data = data;
881
+ request.size = sizeof(u16) * module_cnt;
882
+
883
+ ret = sst_ipc_tx_message_nowait(ipc, request);
847884 if (ret < 0)
848885 dev_err(ipc->dev, "ipc: load modules failed :%d\n", ret);
849886
....@@ -855,7 +892,7 @@
855892 void *data)
856893 {
857894 struct skl_ipc_header header = {0};
858
- u64 *ipc_header = (u64 *)(&header);
895
+ struct sst_ipc_message request;
859896 int ret;
860897
861898 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
....@@ -863,8 +900,11 @@
863900 header.primary |= IPC_GLB_TYPE(IPC_GLB_UNLOAD_MULTIPLE_MODS);
864901 header.primary |= IPC_LOAD_MODULE_CNT(module_cnt);
865902
866
- ret = sst_ipc_tx_message_wait(ipc, *ipc_header, data,
867
- (sizeof(u16) * module_cnt), NULL, 0);
903
+ request.header = *(u64 *)(&header);
904
+ request.data = data;
905
+ request.size = sizeof(u16) * module_cnt;
906
+
907
+ ret = sst_ipc_tx_message_wait(ipc, request, NULL);
868908 if (ret < 0)
869909 dev_err(ipc->dev, "ipc: unload modules failed :%d\n", ret);
870910
....@@ -876,7 +916,7 @@
876916 struct skl_ipc_large_config_msg *msg, u32 *param)
877917 {
878918 struct skl_ipc_header header = {0};
879
- u64 *ipc_header = (u64 *)(&header);
919
+ struct sst_ipc_message request;
880920 int ret = 0;
881921 size_t sz_remaining, tx_size, data_offset;
882922
....@@ -903,9 +943,11 @@
903943 header.primary, header.extension);
904944 dev_dbg(ipc->dev, "transmitting offset: %#x, size: %#x\n",
905945 (unsigned)data_offset, (unsigned)tx_size);
906
- ret = sst_ipc_tx_message_wait(ipc, *ipc_header,
907
- ((char *)param) + data_offset,
908
- tx_size, NULL, 0);
946
+
947
+ request.header = *(u64 *)(&header);
948
+ request.data = ((char *)param) + data_offset;
949
+ request.size = tx_size;
950
+ ret = sst_ipc_tx_message_wait(ipc, request, NULL);
909951 if (ret < 0) {
910952 dev_err(ipc->dev,
911953 "ipc: set large config fail, err: %d\n", ret);
....@@ -927,12 +969,17 @@
927969 EXPORT_SYMBOL_GPL(skl_ipc_set_large_config);
928970
929971 int skl_ipc_get_large_config(struct sst_generic_ipc *ipc,
930
- struct skl_ipc_large_config_msg *msg, u32 *param)
972
+ struct skl_ipc_large_config_msg *msg,
973
+ u32 **payload, size_t *bytes)
931974 {
932975 struct skl_ipc_header header = {0};
933
- u64 *ipc_header = (u64 *)(&header);
934
- int ret = 0;
935
- size_t sz_remaining, rx_size, data_offset;
976
+ struct sst_ipc_message request, reply = {0};
977
+ unsigned int *buf;
978
+ int ret;
979
+
980
+ reply.data = kzalloc(SKL_ADSP_W1_SZ, GFP_KERNEL);
981
+ if (!reply.data)
982
+ return -ENOMEM;
936983
937984 header.primary = IPC_MSG_TARGET(IPC_MOD_MSG);
938985 header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST);
....@@ -945,33 +992,21 @@
945992 header.extension |= IPC_FINAL_BLOCK(1);
946993 header.extension |= IPC_INITIAL_BLOCK(1);
947994
948
- sz_remaining = msg->param_data_size;
949
- data_offset = 0;
995
+ request.header = *(u64 *)&header;
996
+ request.data = *payload;
997
+ request.size = *bytes;
998
+ reply.size = SKL_ADSP_W1_SZ;
950999
951
- while (sz_remaining != 0) {
952
- rx_size = sz_remaining > SKL_ADSP_W1_SZ
953
- ? SKL_ADSP_W1_SZ : sz_remaining;
954
- if (rx_size == sz_remaining)
955
- header.extension |= IPC_FINAL_BLOCK(1);
1000
+ ret = sst_ipc_tx_message_wait(ipc, request, &reply);
1001
+ if (ret < 0)
1002
+ dev_err(ipc->dev, "ipc: get large config fail, err: %d\n", ret);
9561003
957
- ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0,
958
- ((char *)param) + data_offset,
959
- msg->param_data_size);
960
- if (ret < 0) {
961
- dev_err(ipc->dev,
962
- "ipc: get large config fail, err: %d\n", ret);
963
- return ret;
964
- }
965
- sz_remaining -= rx_size;
966
- data_offset = msg->param_data_size - sz_remaining;
967
-
968
- /* clear the fields */
969
- header.extension &= IPC_INITIAL_BLOCK_CLEAR;
970
- header.extension &= IPC_DATA_OFFSET_SZ_CLEAR;
971
- /* fill the fields */
972
- header.extension |= IPC_INITIAL_BLOCK(1);
973
- header.extension |= IPC_DATA_OFFSET_SZ(data_offset);
974
- }
1004
+ reply.size = (reply.header >> 32) & IPC_DATA_OFFSET_SZ_MASK;
1005
+ buf = krealloc(reply.data, reply.size, GFP_KERNEL);
1006
+ if (!buf)
1007
+ return -ENOMEM;
1008
+ *payload = buf;
1009
+ *bytes = reply.size;
9751010
9761011 return ret;
9771012 }
....@@ -981,7 +1016,7 @@
9811016 u8 dma_id, u8 table_id, bool wait)
9821017 {
9831018 struct skl_ipc_header header = {0};
984
- u64 *ipc_header = (u64 *)(&header);
1019
+ struct sst_ipc_message request = {0};
9851020 int ret = 0;
9861021
9871022 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
....@@ -989,12 +1024,12 @@
9891024 header.primary |= IPC_GLB_TYPE(IPC_GLB_LOAD_LIBRARY);
9901025 header.primary |= IPC_MOD_INSTANCE_ID(table_id);
9911026 header.primary |= IPC_MOD_ID(dma_id);
1027
+ request.header = *(u64 *)(&header);
9921028
9931029 if (wait)
994
- ret = sst_ipc_tx_message_wait(ipc, *ipc_header,
995
- NULL, 0, NULL, 0);
1030
+ ret = sst_ipc_tx_message_wait(ipc, request, NULL);
9961031 else
997
- ret = sst_ipc_tx_message_nowait(ipc, *ipc_header, NULL, 0);
1032
+ ret = sst_ipc_tx_message_nowait(ipc, request);
9981033
9991034 if (ret < 0)
10001035 dev_err(ipc->dev, "ipc: load lib failed\n");
....@@ -1006,7 +1041,7 @@
10061041 int skl_ipc_set_d0ix(struct sst_generic_ipc *ipc, struct skl_ipc_d0ix_msg *msg)
10071042 {
10081043 struct skl_ipc_header header = {0};
1009
- u64 *ipc_header = (u64 *)(&header);
1044
+ struct sst_ipc_message request = {0};
10101045 int ret;
10111046
10121047 header.primary = IPC_MSG_TARGET(IPC_MOD_MSG);
....@@ -1017,6 +1052,7 @@
10171052
10181053 header.extension = IPC_D0IX_WAKE(msg->wake);
10191054 header.extension |= IPC_D0IX_STREAMING(msg->streaming);
1055
+ request.header = *(u64 *)(&header);
10201056
10211057 dev_dbg(ipc->dev, "In %s primary=%x ext=%x\n", __func__,
10221058 header.primary, header.extension);
....@@ -1024,7 +1060,7 @@
10241060 /*
10251061 * Use the nopm IPC here as we dont want it checking for D0iX
10261062 */
1027
- ret = sst_ipc_tx_message_nopm(ipc, *ipc_header, NULL, 0, NULL, 0);
1063
+ ret = sst_ipc_tx_message_nopm(ipc, request, NULL);
10281064 if (ret < 0)
10291065 dev_err(ipc->dev, "ipc: set d0ix failed, err %d\n", ret);
10301066