Skip to content

SoundWire: revisit interrupt and lcount handling - #3933

Merged
plbossart merged 8 commits into
thesofproject:topic/sof-devfrom
plbossart:sdw/chip-interrupt
Nov 7, 2022
Merged

SoundWire: revisit interrupt and lcount handling#3933
plbossart merged 8 commits into
thesofproject:topic/sof-devfrom
plbossart:sdw/chip-interrupt

Conversation

@plbossart

Copy link
Copy Markdown
Member

The code in drivers/soundwire/intel_init.c is hardware-dependent and the code does not apply to new generations starting with MeteorLake. Refactor and clean-up the code to make this intel_init.c hardware-agnostic and move all hardware-dependencies in the SOF driver using chip descriptors.

Tested on TGL SKU 0A32

Comment threadsound/soc/sof/intel/hda.c Outdated
Comment threadsound/soc/sof/intel/hda.c Outdated
bardliao
bardliao previously approved these changes Oct 18, 2022
RanderWang
RanderWang previously approved these changes Oct 19, 2022

@RanderWangRanderWang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

bardliao
bardliao previously approved these changes Oct 19, 2022
@plbossart

Copy link
Copy Markdown
MemberAuthor

Going back to draft, I am not happy with the PR, it needs more work to move the startup and interrupt enabling.

@plbossart
plbossart marked this pull request as draft October 19, 2022 14:43
…pt thread
When the code reaches the SoundWire interrupt thread handling, the
interrupt was enabled already, and there is no code that disables it
-> this is a no-op sequence.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
@plbossart
plbossart dismissed stale reviews from bardliao and RanderWang via 9729667November 1, 2022 20:00
@plbossart

Copy link
Copy Markdown
MemberAuthor

let's give @bardliao a chance to review.

bardliao
bardliao previously approved these changes Nov 3, 2022
Comment threadsound/soc/sof/intel/hda.c Outdated
Comment threadsound/soc/sof/intel/shim.h
Comment threadsound/soc/sof/intel/mtl.c Outdated
Comment threadsound/soc/sof/intel/shim.h
Comment threadsound/soc/sof/intel/hda.c
@plbossart

Copy link
Copy Markdown
MemberAuthor

changes since last version (comments from @ranj063 and @ujfalusi )

diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index bc32636c2014..944f95bd1e92 100644
--- a/sound/soc/sof/intel/hda.c+++ b/sound/soc/sof/intel/hda.c@@ -165,14 +165,9 @@ void hda_common_enable_sdw_irq(struct snd_sof_dev *sdev, bool enable)
if (!hdev->sdw)
return;
- val = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC2);-- if (enable)- val |= HDA_DSP_REG_ADSPIC2_SNDW;- else- val &= ~HDA_DSP_REG_ADSPIC2_SNDW;-- snd_sof_dsp_write(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC2, val);+ snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC2,+ HDA_DSP_REG_ADSPIC2_SNDW,+ enable ? HDA_DSP_REG_ADSPIC2_SNDW : 0);
}
void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable)
@@ -935,6 +930,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
struct hdac_bus *bus = sof_to_bus(sdev);
struct snd_sof_pdata *pdata = sdev->pdata;
struct sof_intel_hda_dev *hdev = pdata->hw_pdata;
+ bool i915_off = false;
u32 link_mask;
int ret;
@@ -975,6 +971,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
ret = hda_sdw_probe(sdev);
if (ret < 0) {
dev_err(sdev->dev, "SoundWire probe error: %d\n", ret);
+ i915_off = true;
goto err;
}
@@ -984,7 +981,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
hda_codec_probe_bus(sdev);
err:
- if (!HDA_IDISP_CODEC(bus->codec_mask))+ if (!HDA_IDISP_CODEC(bus->codec_mask) || i915_off)
hda_codec_i915_display_power(sdev, false);
hda_bus_ml_put_all(bus);
diff --git a/sound/soc/sof/intel/mtl.c b/sound/soc/sof/intel/mtl.c
index d20f04a19ad6..904ae42534e1 100644
--- a/sound/soc/sof/intel/mtl.c+++ b/sound/soc/sof/intel/mtl.c@@ -576,7 +576,7 @@ static void mtl_ipc_dump(struct snd_sof_dev *sdev)
static int mtl_dsp_disable_interrupts(struct snd_sof_dev *sdev)
{
- hda_sdw_int_enable(sdev, false);+ mtl_enable_sdw_irq(sdev, false);
mtl_disable_ipc_interrupts(sdev);
return mtl_enable_interrupts(sdev, false);
}

Different generations of Intel hardware rely on different programming
sequences to enable SoundWire IP. In existing hardware, the SoundWire
interrupt is enabled with a register field in the DSP register
space. With HDaudio multi-link extensions registers, the SoundWire
interrupt will be enabled with a generic interrupt enable field in
LCTL, without any dependency on the DSP being enabled.
Add a per-chip callback following the example of the check_sdw_irq()
model already upstream.
Note that the callback is not populated yet for MeteorLake (MTL) since
the interrupts are already enabled in the init. A follow-up patch will
move the functionality to this callback after a couple of cleanups.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
…tions
The offsets and sequences are identical for interrupt enabling and
disabling, we can refactor the code with a single routine and a
boolean.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
There's no real rationale for enabling the SoundWire interrupt in the
init, this can be done from the enable_sdw_irq() callback.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
…tion
The number of links is stored in different registers depending on the
IP version, add sdw_check_lcount() callback. This callback only checks
that the number of links supported in hardware is compatible with the
number of links exposed in ACPI _DSD properties.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The functionality is implemented with per-chip callbacks, there are no
users of this symbol, remove the code.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The number of links is checked with a chip-dependent helper in the
caller, remove the check in drivers/soundwire/intel_init.c
This change makes intel_init.c hardware-agnostic - which is quite
fitting for a layer that only creates auxiliary devices.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Comment threadsound/soc/sof/intel/hda.c Outdated
Comment threadsound/soc/sof/intel/hda.h
Comment threadsound/soc/sof/intel/hda.c
There's no reason to delay the multi-link parsing, this can be done
earlier before checking the SoundWire capabilities.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
@plbossart

Copy link
Copy Markdown
MemberAuthor

dropped "ASoC: SOF: Intel: hda: improve error handling on SoundWire probe", no other change.

@plbossart
plbossart merged commit c693d0c into thesofproject:topic/sof-devNov 7, 2022
Sign up for freeto 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.

5 participants

@plbossart@ranj063@bardliao@ujfalusi@RanderWang