core.c (542898c5aa5c6a3179dffb1d1606884a63f75fed) | core.c (6955d9512d0ea814f1c2761bef7ad7b3cedf4d68) |
---|---|
1// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) 2// 3// This file is provided under a dual BSD/GPLv2 license. When using or 4// redistributing this file, you may do so under either license. 5// 6// Copyright(c) 2018 Intel Corporation. All rights reserved. 7// 8// Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> --- 108 unchanged lines hidden (view full) --- 117out: 118 dev_printk(level, sdev->dev, "panic at %s:%d\n", panic_info->filename, 119 panic_info->linenum); 120 sof_oops(sdev, level, oops); 121 sof_stack(sdev, level, oops, stack, stack_words); 122} 123EXPORT_SYMBOL(sof_print_oops_and_stack); 124 | 1// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) 2// 3// This file is provided under a dual BSD/GPLv2 license. When using or 4// redistributing this file, you may do so under either license. 5// 6// Copyright(c) 2018 Intel Corporation. All rights reserved. 7// 8// Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> --- 108 unchanged lines hidden (view full) --- 117out: 118 dev_printk(level, sdev->dev, "panic at %s:%d\n", panic_info->filename, 119 panic_info->linenum); 120 sof_oops(sdev, level, oops); 121 sof_stack(sdev, level, oops, stack, stack_words); 122} 123EXPORT_SYMBOL(sof_print_oops_and_stack); 124 |
125/* Helper to manage DSP state */ 126void sof_set_fw_state(struct snd_sof_dev *sdev, enum sof_fw_state new_state) 127{ 128 if (sdev->fw_state == new_state) 129 return; 130 131 dev_dbg(sdev->dev, "fw_state change: %d -> %d\n", sdev->fw_state, new_state); 132 sdev->fw_state = new_state; 133 134 switch (new_state) { 135 case SOF_FW_BOOT_NOT_STARTED: 136 case SOF_FW_BOOT_COMPLETE: 137 case SOF_FW_CRASHED: 138 sof_client_fw_state_dispatcher(sdev); 139 fallthrough; 140 default: 141 break; 142 } 143} 144EXPORT_SYMBOL(sof_set_fw_state); 145 |
|
125/* 126 * FW Boot State Transition Diagram 127 * 128 * +----------------------------------------------------------------------+ 129 * | | 130 * ------------------ ------------------ | 131 * | | | | | 132 * | BOOT_FAILED |<-------| READY_FAILED | | --- 128 unchanged lines hidden (view full) --- 261 262 ret = snd_sof_machine_register(sdev, plat_data); 263 if (ret < 0) { 264 dev_err(sdev->dev, 265 "error: failed to register machine driver %d\n", ret); 266 goto fw_trace_err; 267 } 268 | 146/* 147 * FW Boot State Transition Diagram 148 * 149 * +----------------------------------------------------------------------+ 150 * | | 151 * ------------------ ------------------ | 152 * | | | | | 153 * | BOOT_FAILED |<-------| READY_FAILED | | --- 128 unchanged lines hidden (view full) --- 282 283 ret = snd_sof_machine_register(sdev, plat_data); 284 if (ret < 0) { 285 dev_err(sdev->dev, 286 "error: failed to register machine driver %d\n", ret); 287 goto fw_trace_err; 288 } 289 |
290 ret = sof_register_clients(sdev); 291 if (ret < 0) { 292 dev_err(sdev->dev, "failed to register clients %d\n", ret); 293 goto sof_machine_err; 294 } 295 |
|
269 /* 270 * Some platforms in SOF, ex: BYT, may not have their platform PM 271 * callbacks set. Increment the usage count so as to 272 * prevent the device from entering runtime suspend. 273 */ 274 if (!sof_ops(sdev)->runtime_suspend || !sof_ops(sdev)->runtime_resume) 275 pm_runtime_get_noresume(sdev->dev); 276 277 if (plat_data->sof_probe_complete) 278 plat_data->sof_probe_complete(sdev->dev); 279 280 sdev->probe_completed = true; 281 282 return 0; 283 | 296 /* 297 * Some platforms in SOF, ex: BYT, may not have their platform PM 298 * callbacks set. Increment the usage count so as to 299 * prevent the device from entering runtime suspend. 300 */ 301 if (!sof_ops(sdev)->runtime_suspend || !sof_ops(sdev)->runtime_resume) 302 pm_runtime_get_noresume(sdev->dev); 303 304 if (plat_data->sof_probe_complete) 305 plat_data->sof_probe_complete(sdev->dev); 306 307 sdev->probe_completed = true; 308 309 return 0; 310 |
311sof_machine_err: 312 snd_sof_machine_unregister(sdev, plat_data); |
|
284fw_trace_err: 285 snd_sof_free_trace(sdev); 286fw_run_err: 287 snd_sof_fw_unload(sdev); 288fw_load_err: 289 snd_sof_ipc_free(sdev); 290ipc_err: 291dbg_err: --- 32 unchanged lines hidden (view full) --- 324 /* initialize sof device */ 325 sdev->dev = dev; 326 327 /* initialize default DSP power state */ 328 sdev->dsp_power_state.state = SOF_DSP_PM_D0; 329 330 sdev->pdata = plat_data; 331 sdev->first_boot = true; | 313fw_trace_err: 314 snd_sof_free_trace(sdev); 315fw_run_err: 316 snd_sof_fw_unload(sdev); 317fw_load_err: 318 snd_sof_ipc_free(sdev); 319ipc_err: 320dbg_err: --- 32 unchanged lines hidden (view full) --- 353 /* initialize sof device */ 354 sdev->dev = dev; 355 356 /* initialize default DSP power state */ 357 sdev->dsp_power_state.state = SOF_DSP_PM_D0; 358 359 sdev->pdata = plat_data; 360 sdev->first_boot = true; |
332 sof_set_fw_state(sdev, SOF_FW_BOOT_NOT_STARTED); | |
333#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_PROBES) 334 sdev->extractor_stream_tag = SOF_PROBE_INVALID_NODE_ID; 335#endif 336 dev_set_drvdata(dev, sdev); 337 338 /* check all mandatory ops */ 339 if (!sof_ops(sdev) || !sof_ops(sdev)->probe || !sof_ops(sdev)->run || 340 !sof_ops(sdev)->block_read || !sof_ops(sdev)->block_write || --- 4 unchanged lines hidden (view full) --- 345 return -EINVAL; 346 } 347 348 INIT_LIST_HEAD(&sdev->pcm_list); 349 INIT_LIST_HEAD(&sdev->kcontrol_list); 350 INIT_LIST_HEAD(&sdev->widget_list); 351 INIT_LIST_HEAD(&sdev->dai_list); 352 INIT_LIST_HEAD(&sdev->route_list); | 361#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_PROBES) 362 sdev->extractor_stream_tag = SOF_PROBE_INVALID_NODE_ID; 363#endif 364 dev_set_drvdata(dev, sdev); 365 366 /* check all mandatory ops */ 367 if (!sof_ops(sdev) || !sof_ops(sdev)->probe || !sof_ops(sdev)->run || 368 !sof_ops(sdev)->block_read || !sof_ops(sdev)->block_write || --- 4 unchanged lines hidden (view full) --- 373 return -EINVAL; 374 } 375 376 INIT_LIST_HEAD(&sdev->pcm_list); 377 INIT_LIST_HEAD(&sdev->kcontrol_list); 378 INIT_LIST_HEAD(&sdev->widget_list); 379 INIT_LIST_HEAD(&sdev->dai_list); 380 INIT_LIST_HEAD(&sdev->route_list); |
381 INIT_LIST_HEAD(&sdev->ipc_client_list); 382 INIT_LIST_HEAD(&sdev->ipc_rx_handler_list); 383 INIT_LIST_HEAD(&sdev->fw_state_handler_list); |
|
353 spin_lock_init(&sdev->ipc_lock); 354 spin_lock_init(&sdev->hw_lock); 355 mutex_init(&sdev->power_state_access); | 384 spin_lock_init(&sdev->ipc_lock); 385 spin_lock_init(&sdev->hw_lock); 386 mutex_init(&sdev->power_state_access); |
387 mutex_init(&sdev->ipc_client_mutex); 388 mutex_init(&sdev->client_event_handler_mutex); |
|
356 357 /* set default timeouts if none provided */ 358 if (plat_data->desc->ipc_timeout == 0) 359 sdev->ipc_timeout = TIMEOUT_DEFAULT_IPC_MS; 360 else 361 sdev->ipc_timeout = plat_data->desc->ipc_timeout; 362 if (plat_data->desc->boot_timeout == 0) 363 sdev->boot_timeout = TIMEOUT_DEFAULT_BOOT_MS; 364 else 365 sdev->boot_timeout = plat_data->desc->boot_timeout; 366 | 389 390 /* set default timeouts if none provided */ 391 if (plat_data->desc->ipc_timeout == 0) 392 sdev->ipc_timeout = TIMEOUT_DEFAULT_IPC_MS; 393 else 394 sdev->ipc_timeout = plat_data->desc->ipc_timeout; 395 if (plat_data->desc->boot_timeout == 0) 396 sdev->boot_timeout = TIMEOUT_DEFAULT_BOOT_MS; 397 else 398 sdev->boot_timeout = plat_data->desc->boot_timeout; 399 |
400 sof_set_fw_state(sdev, SOF_FW_BOOT_NOT_STARTED); 401 |
|
367 if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE)) { 368 INIT_WORK(&sdev->probe_work, sof_probe_work); 369 schedule_work(&sdev->probe_work); 370 return 0; 371 } 372 373 return sof_probe_continue(sdev); 374} --- 12 unchanged lines hidden (view full) --- 387 struct snd_sof_dev *sdev = dev_get_drvdata(dev); 388 struct snd_sof_pdata *pdata = sdev->pdata; 389 int ret; 390 391 if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE)) 392 cancel_work_sync(&sdev->probe_work); 393 394 /* | 402 if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE)) { 403 INIT_WORK(&sdev->probe_work, sof_probe_work); 404 schedule_work(&sdev->probe_work); 405 return 0; 406 } 407 408 return sof_probe_continue(sdev); 409} --- 12 unchanged lines hidden (view full) --- 422 struct snd_sof_dev *sdev = dev_get_drvdata(dev); 423 struct snd_sof_pdata *pdata = sdev->pdata; 424 int ret; 425 426 if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE)) 427 cancel_work_sync(&sdev->probe_work); 428 429 /* |
430 * Unregister any registered client device first before IPC and debugfs 431 * to allow client drivers to be removed cleanly 432 */ 433 sof_unregister_clients(sdev); 434 435 /* |
|
395 * Unregister machine driver. This will unbind the snd_card which 396 * will remove the component driver and unload the topology 397 * before freeing the snd_card. 398 */ 399 snd_sof_machine_unregister(sdev, pdata); 400 401 if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) { 402 snd_sof_free_trace(sdev); --- 43 unchanged lines hidden --- | 436 * Unregister machine driver. This will unbind the snd_card which 437 * will remove the component driver and unload the topology 438 * before freeing the snd_card. 439 */ 440 snd_sof_machine_unregister(sdev, pdata); 441 442 if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) { 443 snd_sof_free_trace(sdev); --- 43 unchanged lines hidden --- |