Skip to content

ASoC: Intel: sof_pcm512x: make HDMI optional for all platforms - #1777

Merged
ranj063 merged 1 commit into
thesofproject:topic/sof-devfrom
kv2019i:fix/sof-pcm512-oops-with-hdac-hdmi
Feb 13, 2020
Merged

ASoC: Intel: sof_pcm512x: make HDMI optional for all platforms#1777
ranj063 merged 1 commit into
thesofproject:topic/sof-devfrom
kv2019i:fix/sof-pcm512-oops-with-hdac-hdmi

Conversation

@kv2019i

@kv2019i kv2019i commented Feb 10, 2020

Copy link
Copy Markdown
Collaborator

If user explicitly selects hdac-hdmi as the SOF HDA HDMI codec
driver, either by passing "use_common_hdmi=0" or by selecting
CONFIG_SND_SOC_SOF_HDA_COMMON_HDMI_CODEC=n, this leads to
a kernel oops in hda_dsp_hdmi_build_control() with sof_pcm512x.
This machine driver only supports snd-hda-codec-hdmi, so
this is an invalid configuration.

Kernel oops happens as hda_dsp_hdmi_build_control() expects
component drvdata to be of type "struct hdac_hda_priv". This is
not the case if the codec driver is hdac-hdmi. To avoid
this problem, add an explicit check to sof_pcm512x probe.

Signed-off-by: Kai Vehmanen kai.vehmanen@linux.intel.com

Comment thread sound/soc/intel/boards/sof_pcm512x.c Outdated

static int sof_audio_probe(struct platform_device *pdev)
{
struct snd_soc_acpi_mach *mach = (&pdev->dev)->platform_data;

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.

see 9084e21

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.

@lyakh ack, fixed

Comment thread sound/soc/intel/boards/sof_pcm512x.c Outdated
if (!mach->mach_params.common_hdmi_codec_drv) {
dev_err(&pdev->dev, "HDMI codec driver error\n");
return -EINVAL;
}

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.

what if you build a kernel with hdac-hdmi disabled, then you shouldn't need to specify use_common_hdmi (not sure it would work in fact, have to check). But this way you fail?

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.

@lyakh that's perfectly ok. Use_common_hdmi is always set if we try to load snd-hda-codec-hdmi driver from SOF. There is no relation to hdac-hdmi, so whether it is enabled/disabled has no impact. Only thing that matters is thet sof_pcm512 only works with snd-hda-codec-hdmi and if you disable loading it, the probe will fail.

I don't think we can get rid of use_common_hdmi any time soon.

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.

@kv2019i you mean if you disable SND_SOC_HDAC_HDMI and enable CONFIG_SND_HDA_CODEC_HDMI this still isn't sufficient to use the common HDMI driver? We still have to specify use_common_hdmi? This doesn't seem very logical to me - if out of two alternatives one isn't available, it seems we should be trying the other one anyway, regardless whether it's explicitly requested or not?

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.

@lyakh By default things go ok. If you want to select sof_pcm512, CONFIG_SND_HDA_CODEC_HDMI is selected as well (via Kconfig rule) and then the default value of USE_COMMON_HDMI will be yes as well (via Kconfig rule), so the right thing will happen.

But you can break this is if you explictly pass an option use_common=hdmi=0 to the kernel driver. SOF code doesn't know what the machine driver supports, so it can't block this.

It's true we could have an additional check that if SND_SOC_HDAC_HDMI is not even built, then we can just set use_common_hdmi to 1. That is not done currently and could be easily added. Or maybe try to improve the loader code more in hda.c.

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.

...also: do we really want to fail probing completely in such a case or rather just disable HDMI / set hdmi_num = 0?

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.

@kv2019i just wondering is there a way to make the module param to be mutually incompatible with the HDA_COMMON_HDMI_CODEC kconfig selection? If we allow setting use_common_hdmi to 0, then we should make it work instead of reporting an error here, no?

@lyakh lyakh Feb 11, 2020

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.

@kv2019i @ranj063 I don't think playing with SND_SOC_HDAC_HDMI can help. Think about distro kernels. They'll have support for all platforms, so, both those HDA HDMI codec options will be selected. And that same kernel will have to run on different platforms - on some it will use the common HDMI driver, on others it will not. So, this has to be decided at run-time. Currently you do that with a kernel parameter. Which is also suboptimal, because how would an average user know, that they have to set that? Unfortunately with the current control flow this cannot be (easily) done from the machine initialisation - ACPI parsing takes place after HDMI initialisation. But I think we really want that - an automatic decision making. I think the proper solution would be postponing the HDMI initialisation after ACPI parsing. Are there any principal objections against that?

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.

@lyakh @ranj063 The whole thing was specifically added for distro kernels, and to support runtime selection from user-space. The kernel will typically have both drivers built-in. As hdac-hdmi registers directly to HDA core, we don't really know until fairly late whether any driver was found, so changing the ACPI parsing timing won't solve this completely. So drivers are typically both there, but selection of HDMI codec driver depends on which UCM config files are installed. Kernell cannot know this. If user-space updates UCM files to common HDMI driver, then they can switch use_common_hdmi kernel module parameter at the same time. This allows to decouple kernel and user-space updates (so moving to new kernel is not blocked by missing some UCM file).

This is just a transition mechanism that will go away after a few kernel releases after all known users have changed. UCM2 helps in this transition, so once we get UCM2 get to major distros, then this doesn't matter as much anymore. We can just install UCM files that work with both and we can just default on common driver always. Chrome transition is also progressing well, but is not done.

The other cases are really very niche developer cases. I'm now working on the no-i915 patches (#1731 ) and after that, if a developer gets the Kconfig options wrong (e.g. forced hdac-hdmi but uses machine driver or platform that doesn't support it), probe will not fail anymore, but you just don't get HDMI functionality. This seems pretty reasonable, right?

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.

@lyakh

...also: do we really want to fail probing completely in such a case or rather just disable HDMI / set hdmi_num = 0?

Ack, I'll fix this. You need to do a bit more work to disable the topology nodes, but why not.

@kv2019i
kv2019i force-pushed the fix/sof-pcm512-oops-with-hdac-hdmi branch from 68a1f0b to 1f1adbe Compare February 10, 2020 15:47
@kv2019i
kv2019i requested a review from lyakh February 11, 2020 11:47
@kv2019i
kv2019i force-pushed the fix/sof-pcm512-oops-with-hdac-hdmi branch from 1f1adbe to 7500ff0 Compare February 11, 2020 11:47
@kv2019i

kv2019i commented Feb 11, 2020

Copy link
Copy Markdown
Collaborator Author

@lyakh @ranj063 How about now? I extended this to cover the generic case of missing i915 support (missing codec driver, missing graphics driver, codec_mask forced to ignore HDMI, probe errors) -> if missing, HDMI gets disabled.

@plbossart

Copy link
Copy Markdown
Member

I'll let @ranj063 and @kv2019i review and approve. Then one of the two can merge (rebase-and-merge!) the consensus. Thanks!

Comment thread sound/soc/intel/boards/sof_pcm512x.c
Comment thread sound/soc/intel/boards/sof_pcm512x.c Outdated
if (list_empty(&ctx->hdmi_pcm_list))
return -EINVAL;

if (!ctx->idisp_codec)

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.

unrelated to this patch: the above "return -EINVAL;" can only be triggered if for some reason .init() wasn't called for any of the three iDisp interfaces. A comment would be nice

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.

@lyakh yeah, this is in all drivers and has been carried over. I think this would be triggered by an invalid topology file, but not 100% sure... would need some investigation to write a good comment.


if (!ctx->idisp_codec)
return 0;

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.

also unrelated: it isn't very obvious either why just taking the first member in the list is good. That means, that hda_dsp_hdmi_build_controls() can be called with any codec DAI component? Looks a bit confusing to me.

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.

@lyakh This is based on the assumption that all HDMI PCMs are handled by the same codec, so we look up the driver via the codec_dai->component of the first PCM. I guess a comment would not hurt.

@kv2019i kv2019i changed the title ASoC: Intel: sof_pcm512x: fix oops with use_common_hdmi=0 ASoC: Intel: sof_pcm512x: make HDMI optional for all platforms Feb 12, 2020
Make HDMI optional for APL and later platforms. If no HDMI codec
is found on the HDA bus, the graphics side driver is missing or
correct codec driver is not part of kernel build, codec_mask
reflects this and HDMI is disabled. The DSP topology will still
have the links for HDMI, so connect these to dummy codec to avoid
failures in topology loading.

This change also fixes a kernel oops that was triggered if
sof_pcm512x was used with SOF configured to use hdac-hdmi (can be
done via "use_common_hdmi=0" or by selecting
CONFIG_SND_SOC_SOF_HDA_COMMON_HDMI_CODEC=n). This is not a supported
configuration.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
@kv2019i
kv2019i force-pushed the fix/sof-pcm512-oops-with-hdac-hdmi branch from 7500ff0 to 7f48610 Compare February 12, 2020 09:36
@ranj063

ranj063 commented Feb 13, 2020

Copy link
Copy Markdown
Collaborator

SOFCI TEST

@ranj063

ranj063 commented Feb 13, 2020

Copy link
Copy Markdown
Collaborator

@plbossart there are some CI failures for APL nocodec and those are unrelated to this PR. Is it OK to merge?

@plbossart

Copy link
Copy Markdown
Member

@plbossart there are some CI failures for APL nocodec and those are unrelated to this PR. Is it OK to merge?

I ignored those issues when merging the upstream code, but we'd need to find out what's going on.

@plbossart

Copy link
Copy Markdown
Member

@plbossart there are some CI failures for APL nocodec and those are unrelated to this PR. Is it OK to merge?

I ignored those issues when merging the upstream code, but we'd need to find out what's going on.

I meant let's merge and recheck apl-nocodec manually.

@ranj063
ranj063 merged commit daf71dc into thesofproject:topic/sof-dev Feb 13, 2020
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