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

ASoC: Intel: catpt: IPC log improvements and code

Merge series from Cezary Rojewski <cezary.rojewski@intel.com>:

Entire patchset provides no new features and does not alter the code
from functional (user) perspective.

The first two improve IPC-error logging 'mechanism' and align the
catpt-driver with what's done in another Intel's driver: the avs-driver.
In essence, no need to log the error in every function, let the common
handler do so instead.

The last three simplify the code, and fix some spacing issues. All in
all, we get better readability with lower LOC.

+49 -121
+4 -3
sound/soc/intel/catpt/core.h
··· 62 62 struct catpt_spec { 63 63 struct snd_soc_acpi_mach *machines; 64 64 u8 core_id; 65 + const char *fw_name; 65 66 u32 host_dram_offset; 66 67 u32 host_iram_offset; 67 68 u32 host_shim_offset; ··· 130 129 * HOST <-> DSP communication yet failure to process specific request. 131 130 * Use below macro to convert returned non-zero values appropriately 132 131 */ 133 - #define CATPT_IPC_ERROR(err) (((err) < 0) ? (err) : -EREMOTEIO) 132 + #define CATPT_IPC_RET(ret) (((ret) <= 0) ? (ret) : -EREMOTEIO) 134 133 135 134 int catpt_dsp_send_msg_timeout(struct catpt_dev *cdev, 136 135 struct catpt_ipc_msg request, 137 - struct catpt_ipc_msg *reply, int timeout); 136 + struct catpt_ipc_msg *reply, int timeout, const char *name); 138 137 int catpt_dsp_send_msg(struct catpt_dev *cdev, struct catpt_ipc_msg request, 139 - struct catpt_ipc_msg *reply); 138 + struct catpt_ipc_msg *reply, const char *name); 140 139 141 140 int catpt_first_boot_firmware(struct catpt_dev *cdev); 142 141 int catpt_boot_firmware(struct catpt_dev *cdev, bool restore);
+4 -2
sound/soc/intel/catpt/device.c
··· 41 41 memset(&cdev->dx_ctx, 0, sizeof(cdev->dx_ctx)); 42 42 ret = catpt_ipc_enter_dxstate(cdev, CATPT_DX_STATE_D3, &cdev->dx_ctx); 43 43 if (ret) { 44 - ret = CATPT_IPC_ERROR(ret); 44 + ret = CATPT_IPC_RET(ret); 45 45 goto release_dma_chan; 46 46 } 47 47 ··· 107 107 108 108 ret = catpt_ipc_set_device_format(cdev, &cdev->devfmt[i]); 109 109 if (ret) 110 - return CATPT_IPC_ERROR(ret); 110 + return CATPT_IPC_RET(ret); 111 111 } 112 112 113 113 return 0; ··· 348 348 static struct catpt_spec lpt_desc = { 349 349 .machines = lpt_machines, 350 350 .core_id = 0x01, 351 + .fw_name = "intel/IntcSST1.bin", 351 352 .host_dram_offset = 0x000000, 352 353 .host_iram_offset = 0x080000, 353 354 .host_shim_offset = 0x0E7000, ··· 364 363 static struct catpt_spec wpt_desc = { 365 364 .machines = wpt_machines, 366 365 .core_id = 0x02, 366 + .fw_name = "intel/IntcSST2.bin", 367 367 .host_dram_offset = 0x000000, 368 368 .host_iram_offset = 0x0A0000, 369 369 .host_shim_offset = 0x0FB000,
+7 -5
sound/soc/intel/catpt/ipc.c
··· 84 84 85 85 static int catpt_dsp_do_send_msg(struct catpt_dev *cdev, 86 86 struct catpt_ipc_msg request, 87 - struct catpt_ipc_msg *reply, int timeout) 87 + struct catpt_ipc_msg *reply, int timeout, const char *name) 88 88 { 89 89 struct catpt_ipc *ipc = &cdev->ipc; 90 90 unsigned long flags; ··· 111 111 } 112 112 113 113 ret = ipc->rx.rsp.status; 114 + if (ret) 115 + dev_err(cdev->dev, "%s (0x%08x) failed: %d\n", name, request.header, ret); 114 116 if (reply) { 115 117 reply->header = ipc->rx.header; 116 118 ··· 125 123 126 124 int catpt_dsp_send_msg_timeout(struct catpt_dev *cdev, 127 125 struct catpt_ipc_msg request, 128 - struct catpt_ipc_msg *reply, int timeout) 126 + struct catpt_ipc_msg *reply, int timeout, const char *name) 129 127 { 130 128 struct catpt_ipc *ipc = &cdev->ipc; 131 129 int ret; 132 130 133 131 mutex_lock(&ipc->mutex); 134 - ret = catpt_dsp_do_send_msg(cdev, request, reply, timeout); 132 + ret = catpt_dsp_do_send_msg(cdev, request, reply, timeout, name); 135 133 mutex_unlock(&ipc->mutex); 136 134 137 135 return ret; 138 136 } 139 137 140 138 int catpt_dsp_send_msg(struct catpt_dev *cdev, struct catpt_ipc_msg request, 141 - struct catpt_ipc_msg *reply) 139 + struct catpt_ipc_msg *reply, const char *name) 142 140 { 143 141 return catpt_dsp_send_msg_timeout(cdev, request, reply, 144 - cdev->ipc.default_timeout); 142 + cdev->ipc.default_timeout, name); 145 143 } 146 144 147 145 static void
+2 -6
sound/soc/intel/catpt/loader.c
··· 580 580 581 581 static int catpt_load_images(struct catpt_dev *cdev, bool restore) 582 582 { 583 - static const char *const names[] = { 584 - "intel/IntcSST1.bin", 585 - "intel/IntcSST2.bin", 586 - }; 587 583 struct dma_chan *chan; 588 584 int ret; 589 585 ··· 587 591 if (IS_ERR(chan)) 588 592 return PTR_ERR(chan); 589 593 590 - ret = catpt_load_image(cdev, chan, names[cdev->spec->core_id - 1], 594 + ret = catpt_load_image(cdev, chan, cdev->spec->fw_name, 591 595 FW_SIGNATURE, restore); 592 596 if (ret) 593 597 goto release_dma_chan; ··· 652 656 653 657 ret = catpt_ipc_get_mixer_stream_info(cdev, &cdev->mixer); 654 658 if (ret) 655 - return CATPT_IPC_ERROR(ret); 659 + return CATPT_IPC_RET(ret); 656 660 657 661 ret = catpt_arm_stream_templates(cdev); 658 662 if (ret) {
+12 -77
sound/soc/intel/catpt/messages.c
··· 15 15 { 16 16 union catpt_global_msg msg = CATPT_GLOBAL_MSG(GET_FW_VERSION); 17 17 struct catpt_ipc_msg request = {{0}}, reply; 18 - int ret; 19 18 20 19 request.header = msg.val; 21 20 reply.size = sizeof(*version); 22 21 reply.data = version; 23 22 24 - ret = catpt_dsp_send_msg(cdev, request, &reply); 25 - if (ret) 26 - dev_err(cdev->dev, "get fw version failed: %d\n", ret); 27 - 28 - return ret; 23 + return catpt_dsp_send_msg(cdev, request, &reply, "get fw version"); 29 24 } 30 25 31 26 struct catpt_alloc_stream_input { ··· 89 94 reply.size = sizeof(*sinfo); 90 95 reply.data = sinfo; 91 96 92 - ret = catpt_dsp_send_msg(cdev, request, &reply); 93 - if (ret) 94 - dev_err(cdev->dev, "alloc stream type %d failed: %d\n", 95 - type, ret); 96 - 97 + ret = catpt_dsp_send_msg(cdev, request, &reply, "alloc stream"); 97 98 kfree(payload); 98 99 return ret; 99 100 } ··· 98 107 { 99 108 union catpt_global_msg msg = CATPT_GLOBAL_MSG(FREE_STREAM); 100 109 struct catpt_ipc_msg request; 101 - int ret; 102 110 103 111 request.header = msg.val; 104 112 request.size = sizeof(stream_hw_id); 105 113 request.data = &stream_hw_id; 106 114 107 - ret = catpt_dsp_send_msg(cdev, request, NULL); 108 - if (ret) 109 - dev_err(cdev->dev, "free stream %d failed: %d\n", 110 - stream_hw_id, ret); 111 - 112 - return ret; 115 + return catpt_dsp_send_msg(cdev, request, NULL, "free stream"); 113 116 } 114 117 115 118 int catpt_ipc_set_device_format(struct catpt_dev *cdev, ··· 111 126 { 112 127 union catpt_global_msg msg = CATPT_GLOBAL_MSG(SET_DEVICE_FORMATS); 113 128 struct catpt_ipc_msg request; 114 - int ret; 115 129 116 130 request.header = msg.val; 117 131 request.size = sizeof(*devfmt); 118 132 request.data = devfmt; 119 133 120 - ret = catpt_dsp_send_msg(cdev, request, NULL); 121 - if (ret) 122 - dev_err(cdev->dev, "set device format failed: %d\n", ret); 123 - 124 - return ret; 134 + return catpt_dsp_send_msg(cdev, request, NULL, "set device format"); 125 135 } 126 136 127 137 int catpt_ipc_enter_dxstate(struct catpt_dev *cdev, enum catpt_dx_state state, ··· 124 144 { 125 145 union catpt_global_msg msg = CATPT_GLOBAL_MSG(ENTER_DX_STATE); 126 146 struct catpt_ipc_msg request, reply; 127 - int ret; 128 147 129 148 request.header = msg.val; 130 149 request.size = sizeof(state); ··· 131 152 reply.size = sizeof(*context); 132 153 reply.data = context; 133 154 134 - ret = catpt_dsp_send_msg(cdev, request, &reply); 135 - if (ret) 136 - dev_err(cdev->dev, "enter dx state failed: %d\n", ret); 137 - 138 - return ret; 155 + return catpt_dsp_send_msg(cdev, request, &reply, "enter dx state"); 139 156 } 140 157 141 158 int catpt_ipc_get_mixer_stream_info(struct catpt_dev *cdev, ··· 139 164 { 140 165 union catpt_global_msg msg = CATPT_GLOBAL_MSG(GET_MIXER_STREAM_INFO); 141 166 struct catpt_ipc_msg request = {{0}}, reply; 142 - int ret; 143 167 144 168 request.header = msg.val; 145 169 reply.size = sizeof(*info); 146 170 reply.data = info; 147 171 148 - ret = catpt_dsp_send_msg(cdev, request, &reply); 149 - if (ret) 150 - dev_err(cdev->dev, "get mixer info failed: %d\n", ret); 151 - 152 - return ret; 172 + return catpt_dsp_send_msg(cdev, request, &reply, "get mixer info"); 153 173 } 154 174 155 175 int catpt_ipc_reset_stream(struct catpt_dev *cdev, u8 stream_hw_id) 156 176 { 157 177 union catpt_stream_msg msg = CATPT_STREAM_MSG(RESET_STREAM); 158 178 struct catpt_ipc_msg request = {{0}}; 159 - int ret; 160 179 161 180 msg.stream_hw_id = stream_hw_id; 162 181 request.header = msg.val; 163 182 164 - ret = catpt_dsp_send_msg(cdev, request, NULL); 165 - if (ret) 166 - dev_err(cdev->dev, "reset stream %d failed: %d\n", 167 - stream_hw_id, ret); 168 - 169 - return ret; 183 + return catpt_dsp_send_msg(cdev, request, NULL, "reset stream"); 170 184 } 171 185 172 186 int catpt_ipc_pause_stream(struct catpt_dev *cdev, u8 stream_hw_id) 173 187 { 174 188 union catpt_stream_msg msg = CATPT_STREAM_MSG(PAUSE_STREAM); 175 189 struct catpt_ipc_msg request = {{0}}; 176 - int ret; 177 190 178 191 msg.stream_hw_id = stream_hw_id; 179 192 request.header = msg.val; 180 193 181 - ret = catpt_dsp_send_msg(cdev, request, NULL); 182 - if (ret) 183 - dev_err(cdev->dev, "pause stream %d failed: %d\n", 184 - stream_hw_id, ret); 185 - 186 - return ret; 194 + return catpt_dsp_send_msg(cdev, request, NULL, "pause stream"); 187 195 } 188 196 189 197 int catpt_ipc_resume_stream(struct catpt_dev *cdev, u8 stream_hw_id) 190 198 { 191 199 union catpt_stream_msg msg = CATPT_STREAM_MSG(RESUME_STREAM); 192 200 struct catpt_ipc_msg request = {{0}}; 193 - int ret; 194 201 195 202 msg.stream_hw_id = stream_hw_id; 196 203 request.header = msg.val; 197 204 198 - ret = catpt_dsp_send_msg(cdev, request, NULL); 199 - if (ret) 200 - dev_err(cdev->dev, "resume stream %d failed: %d\n", 201 - stream_hw_id, ret); 202 - 203 - return ret; 205 + return catpt_dsp_send_msg(cdev, request, NULL, "resume stream"); 204 206 } 205 207 206 208 struct catpt_set_volume_input { ··· 195 243 union catpt_stream_msg msg = CATPT_STAGE_MSG(SET_VOLUME); 196 244 struct catpt_ipc_msg request; 197 245 struct catpt_set_volume_input input; 198 - int ret; 199 246 200 247 msg.stream_hw_id = stream_hw_id; 201 248 input.channel = channel; ··· 206 255 request.size = sizeof(input); 207 256 request.data = &input; 208 257 209 - ret = catpt_dsp_send_msg(cdev, request, NULL); 210 - if (ret) 211 - dev_err(cdev->dev, "set stream %d volume failed: %d\n", 212 - stream_hw_id, ret); 213 - 214 - return ret; 258 + return catpt_dsp_send_msg(cdev, request, NULL, "set stream volume"); 215 259 } 216 260 217 261 struct catpt_set_write_pos_input { ··· 221 275 union catpt_stream_msg msg = CATPT_STAGE_MSG(SET_WRITE_POSITION); 222 276 struct catpt_ipc_msg request; 223 277 struct catpt_set_write_pos_input input; 224 - int ret; 225 278 226 279 msg.stream_hw_id = stream_hw_id; 227 280 input.new_write_pos = pos; ··· 231 286 request.size = sizeof(input); 232 287 request.data = &input; 233 288 234 - ret = catpt_dsp_send_msg(cdev, request, NULL); 235 - if (ret) 236 - dev_err(cdev->dev, "set stream %d write pos failed: %d\n", 237 - stream_hw_id, ret); 238 - 239 - return ret; 289 + return catpt_dsp_send_msg(cdev, request, NULL, "set stream write pos"); 240 290 } 241 291 242 292 int catpt_ipc_mute_loopback(struct catpt_dev *cdev, u8 stream_hw_id, bool mute) 243 293 { 244 294 union catpt_stream_msg msg = CATPT_STAGE_MSG(MUTE_LOOPBACK); 245 295 struct catpt_ipc_msg request; 246 - int ret; 247 296 248 297 msg.stream_hw_id = stream_hw_id; 249 298 request.header = msg.val; 250 299 request.size = sizeof(mute); 251 300 request.data = &mute; 252 301 253 - ret = catpt_dsp_send_msg(cdev, request, NULL); 254 - if (ret) 255 - dev_err(cdev->dev, "mute loopback failed: %d\n", ret); 256 - 257 - return ret; 302 + return catpt_dsp_send_msg(cdev, request, NULL, "mute loopback"); 258 303 }
+19 -27
sound/soc/intel/catpt/pcm.c
··· 114 114 return result; 115 115 } 116 116 117 - static u32 catpt_stream_read_position(struct catpt_dev *cdev, 118 - struct catpt_stream_runtime *stream) 117 + static void catpt_stream_read_position(struct catpt_dev *cdev, 118 + struct catpt_stream_runtime *stream, u32 *pos) 119 119 { 120 - u32 pos; 121 - 122 - memcpy_fromio(&pos, cdev->lpe_ba + stream->info.read_pos_regaddr, 123 - sizeof(pos)); 124 - return pos; 120 + memcpy_fromio(pos, cdev->lpe_ba + stream->info.read_pos_regaddr, sizeof(*pos)); 125 121 } 126 122 127 123 static u32 catpt_stream_volume(struct catpt_dev *cdev, ··· 361 365 if (stream->template->type != CATPT_STRM_TYPE_LOOPBACK) 362 366 return catpt_set_dspvol(cdev, id, (long *)pos->private_value); 363 367 ret = catpt_ipc_mute_loopback(cdev, id, *(bool *)pos->private_value); 364 - if (ret) 365 - return CATPT_IPC_ERROR(ret); 366 - return 0; 368 + return CATPT_IPC_RET(ret); 367 369 } 368 370 369 371 static int catpt_dai_hw_params(struct snd_pcm_substream *substream, ··· 408 414 cdev->scratch, 409 415 &stream->info); 410 416 if (ret) 411 - return CATPT_IPC_ERROR(ret); 417 + return CATPT_IPC_RET(ret); 412 418 413 419 ret = catpt_dai_apply_usettings(dai, stream); 414 420 if (ret) { ··· 450 456 451 457 ret = catpt_ipc_reset_stream(cdev, stream->info.stream_hw_id); 452 458 if (ret) 453 - return CATPT_IPC_ERROR(ret); 459 + return CATPT_IPC_RET(ret); 454 460 455 461 ret = catpt_ipc_pause_stream(cdev, stream->info.stream_hw_id); 456 462 if (ret) 457 - return CATPT_IPC_ERROR(ret); 463 + return CATPT_IPC_RET(ret); 458 464 459 465 stream->prepared = true; 460 466 return 0; ··· 485 491 ret = catpt_ipc_set_write_pos(cdev, stream->info.stream_hw_id, 486 492 pos, false, false); 487 493 if (ret) 488 - return CATPT_IPC_ERROR(ret); 494 + return CATPT_IPC_RET(ret); 489 495 fallthrough; 490 496 case SNDRV_PCM_TRIGGER_RESUME: 491 497 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: ··· 493 499 catpt_dsp_update_lpclock(cdev); 494 500 ret = catpt_ipc_resume_stream(cdev, stream->info.stream_hw_id); 495 501 if (ret) 496 - return CATPT_IPC_ERROR(ret); 502 + return CATPT_IPC_RET(ret); 497 503 break; 498 504 499 505 case SNDRV_PCM_TRIGGER_STOP: ··· 504 510 ret = catpt_ipc_pause_stream(cdev, stream->info.stream_hw_id); 505 511 catpt_dsp_update_lpclock(cdev); 506 512 if (ret) 507 - return CATPT_IPC_ERROR(ret); 513 + return CATPT_IPC_RET(ret); 508 514 break; 509 515 510 516 default: ··· 611 617 return 0; 612 618 613 619 stream = snd_soc_dai_get_dma_data(cpu_dai, substream); 614 - pos = catpt_stream_read_position(cdev, stream); 620 + catpt_stream_read_position(cdev, stream, &pos); 615 621 616 622 return bytes_to_frames(substream->runtime, pos); 617 623 } ··· 673 679 pm_runtime_put_autosuspend(cdev->dev); 674 680 675 681 if (ret) 676 - return CATPT_IPC_ERROR(ret); 682 + return CATPT_IPC_RET(ret); 677 683 678 684 /* store device format set for given SSP */ 679 685 memcpy(&cdev->devfmt[devfmt.iface], &devfmt, sizeof(devfmt)); ··· 687 693 static struct snd_soc_dai_driver dai_drivers[] = { 688 694 /* FE DAIs */ 689 695 { 690 - .name = "System Pin", 696 + .name = "System Pin", 691 697 .id = CATPT_STRM_TYPE_SYSTEM, 692 698 .ops = &catpt_fe_dai_ops, 693 699 .playback = { ··· 710 716 }, 711 717 }, 712 718 { 713 - .name = "Offload0 Pin", 719 + .name = "Offload0 Pin", 714 720 .id = CATPT_STRM_TYPE_RENDER, 715 721 .ops = &catpt_fe_dai_ops, 716 722 .playback = { ··· 724 730 }, 725 731 }, 726 732 { 727 - .name = "Offload1 Pin", 733 + .name = "Offload1 Pin", 728 734 .id = CATPT_STRM_TYPE_RENDER, 729 735 .ops = &catpt_fe_dai_ops, 730 736 .playback = { ··· 738 744 }, 739 745 }, 740 746 { 741 - .name = "Loopback Pin", 747 + .name = "Loopback Pin", 742 748 .id = CATPT_STRM_TYPE_LOOPBACK, 743 749 .ops = &catpt_fe_dai_ops, 744 750 .capture = { ··· 752 758 }, 753 759 }, 754 760 { 755 - .name = "Bluetooth Pin", 761 + .name = "Bluetooth Pin", 756 762 .id = CATPT_STRM_TYPE_BLUETOOTH_RENDER, 757 763 .ops = &catpt_fe_dai_ops, 758 764 .playback = { ··· 843 849 } 844 850 } 845 851 846 - if (ret) 847 - return CATPT_IPC_ERROR(ret); 848 - return 0; 852 + return CATPT_IPC_RET(ret); 849 853 } 850 854 851 855 static int catpt_volume_info(struct snd_kcontrol *kcontrol, ··· 1033 1041 pm_runtime_put_autosuspend(cdev->dev); 1034 1042 1035 1043 if (ret) 1036 - return CATPT_IPC_ERROR(ret); 1044 + return CATPT_IPC_RET(ret); 1037 1045 1038 1046 *(bool *)kcontrol->private_value = mute; 1039 1047 return 0;
+1 -1
sound/soc/intel/catpt/sysfs.c
··· 24 24 pm_runtime_put_autosuspend(cdev->dev); 25 25 26 26 if (ret) 27 - return CATPT_IPC_ERROR(ret); 27 + return CATPT_IPC_RET(ret); 28 28 29 29 return sysfs_emit(buf, "%d.%d.%d.%d\n", version.type, version.major, 30 30 version.minor, version.build);