Skip to content

ASoC: SOF: merge ipc and sdw irq - #1412

Closed
bardliao wants to merge 1 commit into
thesofproject:integration/soundwire-intelfrom
bardliao:topic/sdw-one-irq
Closed

bardliao wants to merge 1 commit into
thesofproject:integration/soundwire-intelfrom
bardliao:topic/sdw-one-irq

Conversation

@bardliao

Copy link
Copy Markdown
Collaborator

So we can use single irq to handle both ipc and sdw interrupts.

Signed-off-by: Bard Liao yung-chuan.liao@linux.intel.com

@bardliao

Copy link
Copy Markdown
Collaborator Author

I did a basic function test and found no issue.

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good @bardliao
I don't fully get some of the changes, looks like the handler is now a thread, not sure if this is a good change?

Comment thread sound/soc/sof/intel/hda-ipc.c Outdated
HDA_DSP_REG_ADSPIC,
HDA_DSP_ADSPIC_IPC, 0);
ret = IRQ_WAKE_THREAD;
spin_unlock(&sdev->hw_lock);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

careful with the unlock. we could have an IPC and SoundWire interrupt at the same time (different registers used for status), so the two if cases are not mutually exclusive in corner cases

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reminding, now I separate the handler and thread. So no problem here now.

Comment thread sound/soc/sof/intel/hda.c Outdated
ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_ipc_irq_handler,
sof_ops(sdev)->irq_thread, IRQF_SHARED,
ret = request_threaded_irq(sdev->ipc_irq, NULL,
hda_dsp_ipc_irq_handler, IRQF_SHARED,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I don't get this one. this would mean we use a generic handler and the current handler becomes a thread?
Is this needed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought there are no other interrupt share the irq and want to do a quick test yesterday. Now I change it back as it is.

Comment thread drivers/soundwire/intel_init.c Outdated
return IRQ_NONE;
return false;
}
EXPORT_SYMBOL(is_sdw_intel_irq);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a static inline instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread sound/soc/sof/intel/hda-ipc.c Outdated
HDA_DSP_ADSPIC_IPC, 0);
ret = IRQ_WAKE_THREAD;
spin_unlock(&sdev->hw_lock);
sof_ops(sdev)->irq_thread(irq, context);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get the change here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sof_ops(sdev)->irq_thread was the irq thread in request_thread_irq(). So we have to call it in the irq thread.

@RanderWang

Copy link
Copy Markdown

@bardliao please check the interrupt design in Linux. handler is in interrupt context and the PCI
interrupt is disabled, and thread is in non-interrupt context with the PCI interrupt enabled. Another irq function for HDA stream is still done with handler & thread. It takes risk that ipc &sdw are done in thread function with the PCI interrupt enabled.

@bardliao

bardliao commented Nov 1, 2019

Copy link
Copy Markdown
Collaborator Author

@bardliao please check the interrupt design in Linux. handler is in interrupt context and the PCI
interrupt is disabled, and thread is in non-interrupt context with the PCI interrupt enabled. Another irq function for HDA stream is still done with handler & thread. It takes risk that ipc &sdw are done in thread function with the PCI interrupt enabled.

Thanks @RanderWang I separate the irq handler and thread in the updated version. :)

@plbossart
plbossart force-pushed the integration/soundwire-intel branch from f417f1c to fcf05e1 Compare November 4, 2019 16:40
sof_ops(sdev)->irq_thread(irq, context);

if (sdev->irq_event & SOF_IRQ_SDW)
sdw_intel_thread(irq, hdev->sdw);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bardliao I understand the intention here but the naming is incorrent. hda_dsp_irq_thread() is the IRQ thread, sof_ops(sdev)->irq_thread() and sdw_intel_thread() are not threads but just normal methods. So I think we should remove the "thread" from their names.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bardliao I understand the intention here but the naming is incorrent. hda_dsp_irq_thread() is the IRQ thread, sof_ops(sdev)->irq_thread() and sdw_intel_thread() are not threads but just normal methods. So I think we should remove the "thread" from their names.

@ranj063 I agree with you. I have a concern regarding sof_ops(sdev)->irq_thread(). Is there anywhere use sof_ops(sdev)->irq_thread() except here? And it looks confusing, too if we remove the _thread suffix. i.e. sof_ops(sdev)->irq. irq_handler may be a better name, but we already have it. Do you have any suggestion for irq_thread?

@ranj063

ranj063 commented Nov 4, 2019

Copy link
Copy Markdown
Collaborator

@bardliao the commit message is very sparse. Why do we need to merge the 2 interrupts? What advantage does it bring?

@plbossart

Copy link
Copy Markdown
Member

@bardliao the commit message is very sparse. Why do we need to merge the 2 interrupts? What advantage does it bring?

we still see IPC issues with SoundWire, that go way if we disable MSI. We did improve the results by merging 4 SoundWire handlers into one, this is an attempt to go further and have a single handler for all interrupts.

@ranj063

ranj063 commented Nov 4, 2019

Copy link
Copy Markdown
Collaborator

we still see IPC issues with SoundWire, that go way if we disable MSI. We did improve the results by merging 4 SoundWire handlers into one, this is an attempt to go further and have a single handler for all interrupts.

@plbossart what confuses me is that even if you had separate IRQ handlers for the SDW and IPC interrupts, they will both get invoked when an interrupt is raised. Why does it help to service them in one handler? Is there a race because of the order the 2 interrupt handlers get invoked?

@plbossart

Copy link
Copy Markdown
Member

we still see IPC issues with SoundWire, that go way if we disable MSI. We did improve the results by merging 4 SoundWire handlers into one, this is an attempt to go further and have a single handler for all interrupts.

@plbossart what confuses me is that even if you had separate IRQ handlers for the SDW and IPC interrupts, they will both get invoked when an interrupt is raised. Why does it help to service them in one handler? Is there a race because of the order the 2 interrupt handlers get invoked?

We have no idea how edge interrupts like MSI are handled if you have multiple handlers. It just works better if we avoid this in the first place.

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bardliao can you rebase on top on integration/soundwire-debug-fixes?

See also comments below, I don't think the use of the sdev->irq_event can work.

{
u32 int_status;

int_status = readl(ctx->mmio_base + 0x14);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HDA_DSP_REG_ADSPIS2

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plbossart HDA_DSP_REG_ADSPIS2 is defined at sound/soc/sof/intel/hda.h, but we don't include hda.h in soundwire driver. I am not sure include hda.h in sdw_intel.h is a good idea or not. If we just add the HDA_DSP_REG_ADSPIS2 define in sdw_intel.h, we will see redefine warning in compiling. Or we can define another name for HDA_DSP_REG_ADSPIS2 in sdw_intel.h?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just redefine them SDW_ADSPIC2 and SDW_ADSIS2. that's fine.

u32 int_status;

int_status = readl(ctx->mmio_base + 0x14);
if (int_status & BIT(5))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HDA_DSP_REG_ADSPIC2_SNDW

snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR,
HDA_DSP_REG_ADSPIC,
HDA_DSP_ADSPIC_IPC, 0);
sdev->irq_event |= SOF_IRQ_IPC;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the use of a field that's set in the handler is problematic. We know we can have new interrupts before the thread is scheduled (that's e.g. how SoundWire handled the commands before, with the wait_for_completion in the thread and the complete() bin the handler

So it's possible that while you have an SoundWire thread scheduled an IPC interrupt quicks in, and you would reset sdev->irq_event.

I don't think this can work...

So we can use single irq to handle both ipc and sdw interrupts.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
@bardliao

bardliao commented Nov 8, 2019

Copy link
Copy Markdown
Collaborator Author

replaced by #1451 which is on top of integration/soundwire-debug-fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants