Skip to content

[RFC] Multicore support#195

Closed
ranj063 wants to merge 254 commits into
thesofproject:topic/sof-devfrom
ranj063:multicore
Closed

[RFC] Multicore support#195
ranj063 wants to merge 254 commits into
thesofproject:topic/sof-devfrom
ranj063:multicore

Conversation

@ranj063

@ranj063 ranj063 commented Oct 19, 2018

Copy link
Copy Markdown
Collaborator

This patch adds support for scheduling pipelines on multiple cores.

Still untested. Please do not merge.

A couple of opens:

  1. If multiple pipelines are scheduled on the same core, there needs to be a check to make sure we're not trying to enable the same core over and over
  2. during core enabling, should leaving reset and unstalling be followed by powering up explicitly?

plbossart and others added 30 commits August 13, 2018 16:10
There is no need to deal with DMICs if the DSP is not present and
there is no ACPI machine ID found.

Simplify before moving these ACPI tables to sound/soc/intel/common

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit 5f15f26)
No functionality change, just move to common tables to make it easier
to deal with SOF and share the same machine drivers - as done
previously for BYT/CHT/HSW/BDW.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit cbaa7f0)
This patch adds da7219_max98357a machine driver entry into
machine table

Signed-off-by: Naveen Manohar <naveen.m@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit 65a3388)
No functionality change for Skylake driver, add relevant names needed
by SOF for BXT/APL, GLK and CNL.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit e6d298f)
While we are at it, add entries for machine drivers that are used on
SOF-based platforms. The drivers will be submitted upstream after the
core SOF patches, but there's no harm in adding these references now.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit b453501)
… file

There are two commercially-available Broadwell platforms based on I2S
(Dell XPS13 and 'Samus' Pixel 2015 Chromebook).

Fix a copy/paste issue to allow each platform to enable different
features if needed when SOF is enabled

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit f0d9034)
Align with firmware tools, no functionality change

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit 4f722a6)
Somehow I missed the Nau8824 support which was added in 4.17. Oops

Fixes: 4f722a6 ("ASoC: Intel: common: rename 'reef' to 'sof' in ACPI matching table")
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit bb450fa)
…fig.

Machine drivers statically define a number of DAI links that currently
cannot be changed or removed by topology. This means PCMs and platform
components cannot be changed by topology at runtime AND machine drivers
are tightly coupled to topology.

This patch allows topology to override the machine driver DAI link config
in order to reuse machine drivers with different topologies and platform
components. The patch supports :-

1) create new FE PCMs with a topology defined PCM ID.
2) destroy existing static FE PCMs
3) change the platform component driver.
4) assign any new HW params fixups.
5) assign a new card name prefix to differentiate this topology to userspace.

The patch requires no changes to the machine drivers, but does add some
platform component flags that the platform component driver can assign
before loading topologies.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit a655de8)
Currently ALSA core blocks userspace for about 10 seconds for PCM R/W IO.
This needs to be configurable for modern hardware like DSPs where no
pointer update in milliseconds can indicate terminal DSP errors.

Add a substream variable to set the wait time in ms. This allows userspace
and drivers to recover more quickly from terminal DSP errors.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
(cherry picked from commit d64c5cf)
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
MX98373 is used on some CNL boards

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
When the same machine driver is reused between platforms but with a
different alias, using the driver name is not enough. Add additional
fallback case to use the card device name.

Tested on GeminiLake with bxt_da7219_max98357a machine driver

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The Sound Open Firmware driver core is a generic architecture
independent layer that allows SOF to be used on many different different
architectures and platforms. It abstracts DSP operations and IO methods
so that the target DSP can be an internal memory mapped or external SPI
or I2C based device. This abstraction also allows SOF to be run on
many different VMs on the same physical HW.

SOF also requires some data in ASoC PCM runtime data for looking up
SOF data during ASoC PCM operations.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
SOF exposes regular ALSA Kcontrols that are defined by topology. This
patch converts the Kcontrol IO to DSP IPC.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add debugFS files that can be used to expose DSP memories and
and peripherals to userspace to assist with firmware debugging.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Define an IPC ABI for all host <--> DSP communication. This ABI should
be transport agnostic. i.e. it should work on MMIO and SPI/I2C style
interfaces.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add support for exposing PCMs to userspace. PCMs are defined by topology
and the operations in this patch map to SOF IPC calls.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
SOF uses topology to define the DAPM graphs and widgets, DAIs, PCMs and set
parameters for init and run time usage. This patch loads topology and
maps it to IPC commands that are build the topology on the DSP.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add a trace event buffer that can be used by userspace to read DSP runtime
trace events alongside bespoke trace data in realtime for firmware debug.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add operation pointers that can be called by core to control a wide
variety of DSP targets. The DSP HW drivers will fill in these
operations.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The firmware loader exports APIs that can be called by core to load and
process multiple different file formats.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add userspace ABI for audio userspace application IO outside of regular
ALSA PCM and kcontrols. This is intended to be used to format
coefficients and data for custom processing components.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add support for compressed audio playback/capture in SOF.

TODO: to be completed.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add support for saving and restoring DSP context in D3 to host DDR.

The suspend callback includes: suspend all pcm's stream that are running,
send CTX_SAVE ipc, drop all ipc's, release trace dma and then
power off the DSP.

And the resume callback performs the following steps: load FW, run FW,
re-initialize trace, restore pipeline, restore the kcontrol values
and finally send the ctx restore ipc to the dsp.

The streams that are suspended are resumed by the ALSA resume trigger.
If the streams are paused during system suspend, they are marked
explicitly so they can be restored during PAUSE_RELEASE.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add a simple "fallback" machine driver that can be used to enable SOF
on boards with no codec device. This machine driver can also be forced
for debug/development.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Add support for the audio DSP hardware found on Intel Baytrail,
Cherrytrail and Braswell based devices.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add DSP hardware support for Intel Haswell based devices.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add SOF support for Intel Broadwell based devices.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
RanderWang and others added 12 commits October 17, 2018 11:32
The initialization process of HDA in SOF is:
(1) init HDA to set up a context for i915 initialization
    then stop HDA bus.

(2) init i915 to init HDMI codecs.

(3) init HDA again to make everything ready

On WHL, only HDA analog codec is detected in step (1).
And after step (2) HDMI could be detected. But in function
azx_reset for step(3), the detection code is:

/* detect codecs */
if (!bus->codec_mask) {
	bus->codec_mask = snd_hdac_chip_readw(bus, STATESTS);

	dev_dbg(bus->dev, "codec_mask = 0x%lx\n",
	bus->codec_mask);
}

At step (3) codec_mask is not zero, so no more query would
be triggered. This results to miss detecting HDMI codecs.
Now set codec_mask to zero to query again

For GLK, none codec is detected at step(1), so it is no problem
at step(3)

Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
We should not create debugFW entry for resume, here fix it.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
This patch adds the sof virtio BE and FE support.
It will create a dev node for the communication to the userspace.

It also handles the virtio vq event. It dispatches the different
vq kicks to different handlers. In the virtio vq handling, it handles
all the ipc events from vFE.

When there is position update from FW, it will check whether there is
an available entry in notification vq. If yes, send the position update
notification immediately. If there is no available entry, add the position
update event in a list. As soon as the notification vq has an available
entry, send the position update to the vFE.

For vFE, it will create a virtual audio device driver and communite with
vBE audio driver to create PCMs and playback/capture streams.

Signed-off-by: Libin Yang <libin.yang@intel.com>
We don't delete the debugFS entry for trace at suspend, so we
should not allocate buffer again for it at resume, otherwise,
the trace will be copied to new buffer and can't be read via
old entry.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Normal flow if no HDMI devices are connected.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
Signed-off-by: Pan Xiuli <xiuli.pant@linux.intel.com>
Set direction for dai from topology

Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Cleaned up for easier debug.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Introduce core_enable/core_disable dsp ops. These will be called
during topology parsing to schedule pipelines on the core
specified in topology.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
This patch adds the changes required to schedule pipelines on the
core specified in topology.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
@ranj063 ranj063 requested review from keyonjie and lgirdwood October 19, 2018 13:57
Comment thread sound/soc/sof/intel/apl.c
.run = hda_dsp_cl_boot_firmware,

/* dsp core enable/disable */
.core_enable = hda_dsp_core_run,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

hda_dsp_core_run fails, because core is not powered up.

Suggested change
.core_enable = hda_dsp_core_run,
.core_enable = hda_dsp_enable_core,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yes, there are difference with these two APIs, hda_dsp_enable_core will eventually call hda_dsp_core_run

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.

@tlauda , yes this is one of my opens too. I will need to modify it. BTW, how are you testing this? Do you have a topology with a pipeline scheduled on core 1?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@ranj063 Yes.

@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.

Not fully clear what 'enable' means for a core.

Comment thread sound/soc/sof/topology.c
}

/* free private value */
kfree(swidget->private);

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.

you are not returning ret? What is it used for then?

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 my bad, sorry. Will fix it.

Comment thread sound/soc/sof/sof-priv.h
unsigned int core_mask);
int (*core_disable)(struct snd_sof_dev *sof_dev,
unsigned int core_mask);

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.

what is the definition of enable/disable compared to run/reset? You should add some comments 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.

@plbossart sure will explain the difference in the comments in the next version

@tlauda

tlauda commented Oct 23, 2018

Copy link
Copy Markdown

@ranj063 @keyonjie This patch also lacks support for context restore flow for multicores. Currently it doesn't work, because after restore only master core is enabled.

@ranj063

ranj063 commented Oct 26, 2018

Copy link
Copy Markdown
Collaborator Author

@tlauda ack your comment. I'll add support for resume early next week.

@tlauda

tlauda commented Nov 20, 2018

Copy link
Copy Markdown

@ranj063 Any updates? It's been quite a while. I'm still pending with multicore tests on CNL.

@plbossart

Copy link
Copy Markdown
Member

@ranj063 can you either close or update this PR, it's unclear what the status is

@tlauda

tlauda commented Nov 27, 2018

Copy link
Copy Markdown

@ranj063 Any update?

@ranj063

ranj063 commented Dec 3, 2018

Copy link
Copy Markdown
Collaborator Author

@plbossart @tlauda I'm closing this one. will open a new one within the next day or two!

@ranj063 ranj063 closed this Dec 3, 2018
@ranj063 ranj063 deleted the multicore branch December 3, 2018 06:53
oder-chiou pushed a commit to oder-chiou/linux-soundwire that referenced this pull request May 5, 2026
test_bpf tail call tests end up as:

  test_bpf: #0 Tail call leaf jited:1 85 PASS
  test_bpf: thesofproject#1 Tail call 2 jited:1 111 PASS
  test_bpf: thesofproject#2 Tail call 3 jited:1 145 PASS
  test_bpf: thesofproject#3 Tail call 4 jited:1 170 PASS
  test_bpf: thesofproject#4 Tail call load/store leaf jited:1 190 PASS
  test_bpf: thesofproject#5 Tail call load/store jited:1
  BUG: Unable to handle kernel data access on write at 0xf1b4e000
  Faulting instruction address: 0xbe86b710
  Oops: Kernel access of bad area, sig: 11 [thesofproject#1]
  BE PAGE_SIZE=4K MMU=Hash PowerMac
  Modules linked in: test_bpf(+)
  CPU: 0 PID: 97 Comm: insmod Not tainted 6.1.0-rc4+ thesofproject#195
  Hardware name: PowerMac3,1 750CL 0x87210 PowerMac
  NIP:  be86b710 LR: be857e88 CTR: be86b704
  REGS: f1b4df20 TRAP: 0300   Not tainted  (6.1.0-rc4+)
  MSR:  00009032 <EE,ME,IR,DR,RI>  CR: 28008242  XER: 00000000
  DAR: f1b4e000 DSISR: 42000000
  GPR00: 00000001 f1b4dfe c11d2280 00000000 00000000 00000000 00000002 00000000
  GPR08: f1b4e000 be86b704 f1b4e000 00000000 00000000 100d816a f2440000 fe73baa8
  GPR16: f2458000 00000000 c1941ae4 f1fe2248 00000045 c0de0000 f2458030 00000000
  GPR24: 000003e8 0000000f f2458000 f1b4dc90 3e584b46 00000000 f24466a0 c1941a00
  NIP [be86b710] 0xbe86b710
  LR [be857e88] __run_one+0xec/0x264 [test_bpf]
  Call Trace:
  [f1b4dfe] [00000002] 0x2 (unreliable)
  Instruction dump:
  XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
  XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
  ---[ end trace 0000000000000000 ]---

This is a tentative to write above the stack. The problem is encoutered
with tests added by commit 38608ee ("bpf, tests: Add load store
test case for tail call")

This happens because tail call is done to a BPF prog with a different
stack_depth. At the time being, the stack is kept as is when the caller
tail calls its callee. But at exit, the callee restores the stack based
on its own properties. Therefore here, at each run, r1 is erroneously
increased by 32 - 16 = 16 bytes.

This was done that way in order to pass the tail call count from caller
to callee through the stack. As powerpc32 doesn't have a red zone in
the stack, it was necessary the maintain the stack as is for the tail
call. But it was not anticipated that the BPF frame size could be
different.

Let's take a new approach. Use register r4 to carry the tail call count
during the tail call, and save it into the stack at function entry if
required. This means the input parameter must be in r3, which is more
correct as it is a 32 bits parameter, then tail call better match with
normal BPF function entry, the down side being that we move that input
parameter back and forth between r3 and r4. That can be optimised later.

Doing that also has the advantage of maximising the common parts between
tail calls and a normal function exit.

With the fix, tail call tests are now successfull:

  test_bpf: #0 Tail call leaf jited:1 53 PASS
  test_bpf: thesofproject#1 Tail call 2 jited:1 115 PASS
  test_bpf: thesofproject#2 Tail call 3 jited:1 154 PASS
  test_bpf: thesofproject#3 Tail call 4 jited:1 165 PASS
  test_bpf: thesofproject#4 Tail call load/store leaf jited:1 101 PASS
  test_bpf: thesofproject#5 Tail call load/store jited:1 141 PASS
  test_bpf: thesofproject#6 Tail call error path, max count reached jited:1 994 PASS
  test_bpf: thesofproject#7 Tail call count preserved across function calls jited:1 140975 PASS
  test_bpf: thesofproject#8 Tail call error path, NULL target jited:1 110 PASS
  test_bpf: thesofproject#9 Tail call error path, index out of range jited:1 69 PASS
  test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed]

Suggested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Fixes: 51c66ad ("powerpc/bpf: Implement extended BPF on PPC32")
Cc: stable@vger.kernel.org
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/757acccb7fbfc78efa42dcf3c974b46678198905.1669278887.git.christophe.leroy@csgroup.eu
oder-chiou pushed a commit to oder-chiou/linux-soundwire that referenced this pull request May 5, 2026
…nslate the same key

The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:

1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[thesofproject#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[thesofproject#195], so this is what happens:

    - KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
    - KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
    - KEY_GRAVE -> KEY_102ND (this part is not reached!)
    ...

2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.

Normally, these are the steps that should happen:

    - KEY_102ND -> KEY_GRAVE
    - KEY_GRAVE -> KEY_ESC (Fn is pressed)
    - KEY_ESC is returned

Though this is what happens instead, as dependencies on other
translations are not supported:

    - KEY_102ND -> KEY_ESC (Fn is pressed)
    - KEY_ESC is returned

This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.

This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[thesofproject#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).

Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc4 ("HID: apple: Add "GANSS" to the non-Apple list").

Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.

Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
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.