Skip to content

ASoC: Intel: fix sof_es8336 probe - #3798

Merged
plbossart merged 4 commits into
thesofproject:topic/sof-devfrom
plbossart:fix/es8336-board-ids
Aug 11, 2022
Merged

plbossart merged 4 commits into
thesofproject:topic/sof-devfrom
plbossart:fix/es8336-board-ids

Conversation

@plbossart

Copy link
Copy Markdown
Member

Changes to add HDMI capture support broke the machine driver probe for
all other platforms. The commit listed in the Fixes tag added a
board_id descriptor but didn't add the default name for the
sof_essx8336 machine driver.

Add the missing entry and remove the now-useless platform driver
alias.

Reported-by: Eugene J. Markow ejmarkow@yahoo.com
BugLink: #3336
Fixes: 86b1959 ("ASoC: Intel: sof_es8336: add support for HDMI_In capture")
Signed-off-by: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com

Changes to add HDMI capture support broke the machine driver probe for
all other platforms. The commit listed in the Fixes tag added a
board_id descriptor but didn't add the default name for the
sof_essx8336 machine driver.

Add the missing entry and remove the now-useless platform driver
alias.

Reported-by: Eugene J. Markow <ejmarkow@yahoo.com>
BugLink: thesofproject#3336
Fixes: 86b1959 ("ASoC: Intel: sof_es8336: add support for HDMI_In capture")
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
bardliao
bardliao previously approved these changes Aug 4, 2022
Some Intel-based platforms rely on a topology file that hard-codes the
use of MCLK0. This is incorrect in 10% of the cases. Rather than
generating yet another set of topology files, this patch adds a kernel
module parameter to override the topology value.

In hindsight, we should never have allowed mclks to be specified in
topology, this is a hardware-level information that should not have
been visible in the topology.

Future patches will try to set this value automagically, e.g. by
parsing the NHLT content.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
SOF topologies hard-code the MCLK used for SSP connections. That was a
bad idea in hindsight, this information should really come from BIOS
and/or machine driver.

This patch introduces a helper to scan all SSP endpoints connected to
a codec, and all formats to see what MCLK is used. When BIT(0) of the
mdivc offset if set in the SSP blob, MCLK0 is used, and likewise when
BIT(1) is set MCLK1 is used.

The case where both MCLKs are used is possible but has never been seen
in practice so should be treated as an error by the caller.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The NHLT is already used to determine which SSP is connected to an
audio codec, we can parse the SSP blob to get the mclk_id from NHLT.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
@plbossart
plbossart force-pushed the fix/es8336-board-ids branch from 537c5db to 013290a Compare August 5, 2022 13:09
@plbossart

Copy link
Copy Markdown
Member Author

@juimonen and @crojewsk-intel can you please take a look at the sound/hda/intel-nhlt.c changes. I think I have the blob formats right based on the alsa-utils header but it's Friday and my brain is fried.

@kv2019i kv2019i left a comment

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.

Looks good. I do wonder a bit should one level of sanitization be done to the binary parsing in second-to-last patch. If this is already done in elsewhere in NHLT code, then ok...

Comment thread sound/hda/intel-nhlt.c
epnt->device_type == NHLT_DEVICE_I2S &&
epnt->virtual_bus_id == ssp_num) {

fmt = (struct nhlt_fmt *)(epnt->config.caps + epnt->config.size);

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.

Hmm, should there be some input validation that this does end up reading past the allocated struct?

@plbossart plbossart Aug 5, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The code I took was copy/pasted/modified from the existing NHLT helpers. It's quite true that nothing checks that the size isn't corrupted. The NHLT can be overridden as I understand it, so clearly there are means to create an out-of-bounds access.

Comment thread sound/hda/intel-nhlt.c
cfg = (struct nhlt_fmt_cfg *)(cfg->config.caps + cfg->config.size);
}
}
epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);

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.

Likewise here...?

@plbossart

Copy link
Copy Markdown
Member Author

Results are good, see #3336 (comment)

@plbossart
plbossart requested a review from bardliao August 9, 2022 08:12
@plbossart

Copy link
Copy Markdown
Member Author

@bardliao @ujfalusi I could use your reviews, this needs to go upstream quickly.

@plbossart
plbossart merged commit 371d86a into thesofproject:topic/sof-dev Aug 11, 2022
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.

3 participants