Repository navigation
[TEST] Fix Cyan module load/unload issues by retrying the firmware boot #2271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5fcb87a
edf4880
83e64a5
ea1e8ba
2458e65
5130057
be9940e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,7 +97,7 @@ static void byt_get_registers(struct snd_sof_dev *sdev, | |
| { | ||
| u32 offset = sdev->dsp_oops_offset; | ||
|
|
||
| /* first read regsisters */ | ||
| /* first read registers */ | ||
| sof_mailbox_read(sdev, offset, xoops, sizeof(*xoops)); | ||
|
|
||
| /* note: variable AR register array is not read */ | ||
|
|
@@ -121,31 +121,32 @@ static void byt_dump(struct snd_sof_dev *sdev, u32 flags) | |
| struct sof_ipc_dsp_oops_xtensa xoops; | ||
| struct sof_ipc_panic_info panic_info; | ||
| u32 stack[BYT_STACK_DUMP_SIZE]; | ||
| u64 status, panic, imrd, imrx; | ||
| u64 ipcd, ipcx, imrd, imrx; | ||
|
|
||
| /* now try generic SOF status messages */ | ||
| status = snd_sof_dsp_read64(sdev, BYT_DSP_BAR, SHIM_IPCD); | ||
| panic = snd_sof_dsp_read64(sdev, BYT_DSP_BAR, SHIM_IPCX); | ||
| ipcd = snd_sof_dsp_read64(sdev, BYT_DSP_BAR, SHIM_IPCD); | ||
| ipcx = snd_sof_dsp_read64(sdev, BYT_DSP_BAR, SHIM_IPCX); | ||
| imrx = snd_sof_dsp_read64(sdev, BYT_DSP_BAR, SHIM_IMRX); | ||
| imrd = snd_sof_dsp_read64(sdev, BYT_DSP_BAR, SHIM_IMRD); | ||
|
|
||
| byt_get_registers(sdev, &xoops, &panic_info, stack, | ||
| BYT_STACK_DUMP_SIZE); | ||
| snd_sof_get_status(sdev, status, panic, &xoops, &panic_info, stack, | ||
| snd_sof_get_status(sdev, ipcd, ipcx, &xoops, &panic_info, stack, | ||
| BYT_STACK_DUMP_SIZE); | ||
|
|
||
| /* provide some context for firmware debug */ | ||
| imrx = snd_sof_dsp_read64(sdev, BYT_DSP_BAR, SHIM_IMRX); | ||
| imrd = snd_sof_dsp_read64(sdev, BYT_DSP_BAR, SHIM_IMRD); | ||
| dev_err(sdev->dev, | ||
| "error: ipc host -> DSP: pending %s complete %s raw 0x%llx\n", | ||
| (panic & SHIM_IPCX_BUSY) ? "yes" : "no", | ||
| (panic & SHIM_IPCX_DONE) ? "yes" : "no", panic); | ||
| (ipcx & SHIM_BYT_IPCX_BUSY) ? "yes" : "no", | ||
| (ipcx & SHIM_BYT_IPCX_DONE) ? "yes" : "no", ipcx); | ||
| dev_err(sdev->dev, | ||
| "error: mask host: pending %s complete %s raw 0x%llx\n", | ||
| (imrx & SHIM_IMRX_BUSY) ? "yes" : "no", | ||
| (imrx & SHIM_IMRX_DONE) ? "yes" : "no", imrx); | ||
| dev_err(sdev->dev, | ||
| "error: ipc DSP -> host: pending %s complete %s raw 0x%llx\n", | ||
| (status & SHIM_IPCD_BUSY) ? "yes" : "no", | ||
| (status & SHIM_IPCD_DONE) ? "yes" : "no", status); | ||
| (ipcd & SHIM_BYT_IPCD_BUSY) ? "yes" : "no", | ||
| (ipcd & SHIM_BYT_IPCD_DONE) ? "yes" : "no", ipcd); | ||
| dev_err(sdev->dev, | ||
| "error: mask DSP: pending %s complete %s raw 0x%llx\n", | ||
| (imrd & SHIM_IMRD_BUSY) ? "yes" : "no", | ||
|
|
@@ -250,7 +251,7 @@ static int byt_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) | |
|
|
||
| static void byt_get_reply(struct snd_sof_dev *sdev) | ||
| { | ||
| struct snd_sof_ipc_msg *msg = sdev->msg; | ||
| struct snd_sof_ipc_msg *msg = &sdev->ipc->msg; | ||
| struct sof_ipc_reply reply; | ||
| int ret = 0; | ||
|
|
||
|
|
@@ -259,7 +260,7 @@ static void byt_get_reply(struct snd_sof_dev *sdev) | |
| * ipc belongs to none of the ipcs sent from driver. | ||
| * In this case, the driver must ignore the ipc. | ||
| */ | ||
| if (!msg) { | ||
| if (msg->ipc_complete) { | ||
| dev_warn(sdev->dev, "unexpected ipc interrupt raised!\n"); | ||
| return; | ||
| } | ||
|
|
@@ -327,7 +328,9 @@ static int byt_run(struct snd_sof_dev *sdev) | |
|
|
||
| /* release stall and wait to unstall */ | ||
| snd_sof_dsp_update_bits64(sdev, BYT_DSP_BAR, SHIM_CSR, | ||
| SHIM_BYT_CSR_STALL, 0x0); | ||
| SHIM_BYT_CSR_XT_SNOOP | SHIM_BYT_CSR_STALL, | ||
| SHIM_BYT_CSR_XT_SNOOP); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this enable PCIe snooping of the DSP traffic? And without it it's disabled? I'm not an expert in that but in general that seems like a good thing to maintain cache coherency? I don't know why it would be possible to disable it, but maybe my guess is wrong and it's something different entirely.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's wrong, will remove this.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would that leave snooping disabled? Or does that flag disable snooping when set? |
||
|
|
||
| while (tries--) { | ||
| if (!(snd_sof_dsp_read64(sdev, BYT_DSP_BAR, SHIM_CSR) & | ||
| SHIM_BYT_CSR_PWAITMODE)) | ||
|
|
@@ -730,6 +733,7 @@ static int byt_acpi_probe(struct snd_sof_dev *sdev) | |
| container_of(sdev->dev, struct platform_device, dev); | ||
| struct resource *mmio; | ||
| u32 base, size; | ||
| u32 pmc_status; | ||
| int ret; | ||
|
|
||
| /* DSP DMA can only access low 31 bits of host memory */ | ||
|
|
@@ -764,6 +768,36 @@ static int byt_acpi_probe(struct snd_sof_dev *sdev) | |
| sdev->mmio_bar = BYT_DSP_BAR; | ||
| sdev->mailbox_bar = BYT_DSP_BAR; | ||
|
|
||
| /* PCI base */ | ||
| mmio = platform_get_resource(pdev, IORESOURCE_MEM, | ||
| desc->resindex_pcicfg_base); | ||
| if (mmio) { | ||
| base = mmio->start; | ||
| size = resource_size(mmio); | ||
| } else { | ||
| dev_err(sdev->dev, "error: failed to get PCI base at idx %d\n", | ||
| desc->resindex_pcicfg_base); | ||
| return -ENODEV; | ||
| } | ||
|
|
||
| dev_dbg(sdev->dev, "PCI base at 0x%x size 0x%x", base, size); | ||
| sdev->bar[BYT_PCI_BAR] = devm_ioremap(sdev->dev, base, size); | ||
| if (!sdev->bar[BYT_PCI_BAR]) { | ||
| dev_err(sdev->dev, | ||
| "error: failed to ioremap PCI base 0x%x size 0x%x\n", | ||
| base, size); | ||
| return -ENODEV; | ||
| } | ||
| dev_dbg(sdev->dev, "PCI VADDR %p\n", sdev->bar[BYT_PCI_BAR]); | ||
|
|
||
| pmc_status = snd_sof_dsp_read(sdev, BYT_PCI_BAR, PCI_PMCS); | ||
| if (pmc_status & 0x3) { | ||
| dev_err(sdev->dev, "error: PMC status does not indicated D0 state %x\n", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo "indicate" |
||
| pmc_status); | ||
| return -ENODEV; | ||
|
|
||
| } | ||
|
|
||
| /* IMR base - optional */ | ||
| if (desc->resindex_imr_base == -1) | ||
| goto irq; | ||
|
|
@@ -954,6 +988,8 @@ const struct snd_sof_dsp_ops sof_cht_ops = { | |
| /*Firmware loading */ | ||
| .load_firmware = snd_sof_load_firmware_memcpy, | ||
|
|
||
| .firmware_boot_retries = 2, | ||
|
|
||
| /* PM */ | ||
| .suspend = byt_suspend, | ||
| .resume = byt_resume, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -728,18 +728,6 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev) | |
|
|
||
| init_waitqueue_head(&sdev->boot_wait); | ||
|
|
||
| /* create read-only fw_version debugfs to store boot version info */ | ||
| if (sdev->first_boot) { | ||
| ret = snd_sof_debugfs_buf_item(sdev, &sdev->fw_version, | ||
| sizeof(sdev->fw_version), | ||
| "fw_version", 0444); | ||
| /* errors are only due to memory allocation, not debugfs */ | ||
| if (ret < 0) { | ||
| dev_err(sdev->dev, "error: snd_sof_debugfs_buf_item failed\n"); | ||
| return ret; | ||
| } | ||
| } | ||
|
|
||
| /* perform pre fw run operations */ | ||
| ret = snd_sof_dsp_pre_fw_run(sdev); | ||
| if (ret < 0) { | ||
|
|
@@ -790,6 +778,18 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev) | |
| /* fw boot is complete. Update the active cores mask */ | ||
| sdev->enabled_cores_mask = init_core_mask; | ||
|
|
||
| /* create read-only fw_version debugfs to store boot version info */ | ||
| if (sdev->first_boot) { | ||
| ret = snd_sof_debugfs_buf_item(sdev, &sdev->fw_version, | ||
| sizeof(sdev->fw_version), | ||
| "fw_version", 0444); | ||
| /* errors are only due to memory allocation, not debugfs */ | ||
| if (ret < 0) { | ||
| dev_err(sdev->dev, "error: snd_sof_debugfs_buf_item failed\n"); | ||
| return ret; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also changes the error processing semantics: before this patch if debugfs file creation failed, we wouldn't boot the firmware, now the firmware is already running but we still fail probing... Maybe make this a soft failure now?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @plbossart I think we shoudl keep the debugfs creationg before attempting to boot. The sdev->fw_version member is populated when the FW_READY IPC message is received and if you move this to after boot is complete, I think this would never get populated
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ranj063 this was to work around the debugfs error warnings that the item is already created if you try and reboot multiple times when FW_READY never happens.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @plbossart ahh I see. Then I think this should be moved to ipc.c where we handle the FW_READY IPC. That would for sure indicate that the FW boot is complete and so its good to create the debugfs entry and copy the fw_version from the IPC reply.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well we don't want to have a memory allocation failure in ipc.c, we should maybe create this earlier instead of in the firmware_run function.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. then maybe we should just create this during dbg init? |
||
| } | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
| EXPORT_SYMBOL(snd_sof_run_firmware); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we have to reset the
sdev->fw_statetoSOF_FW_BOOT_PREPAREwhen retrying? You could also extractsnd_sof_load_firmware()andsnd_sof_run_firmware()into a separate function and call it in a loop, thus avoiding a goto, but I'll probably do that anyway when my VirtIO patches reach that state... since they're touching this code too.