Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

soundwire/SOF: add SoundWire Interface support for AMD SOF stack #4699

Merged
merged 12 commits into from Dec 20, 2023

Conversation

vijendarmukunda
Copy link

@vijendarmukunda vijendarmukunda commented Nov 13, 2023

We have redesigned existing platform device creation logic for SoundWire managers (folder path :sound/soc/amd/ps ) and Implemented generic functions for SoundWire manager probe, start and exit sequence which are common for both Legacy(NO DSP enabled) and SOF stack.

We have also prepared legacy driver patches (folder path: sound/soc/amd/ps), as this PR is targeted for pushing SoundWire/SOF stack changes, we haven't included in this PR. We will push legacy patches for upstream review for alsa devel list once this PR review is completed and merged.

We took Intel code as a reference for implementing generic functions for SoundWire managers.
We are working on generic SoundWire machine driver for AMD platforms. There are some functions implemented in intel SoundWire machine driver code, we want to use it in our machine driver code. we will start a separate thread for the discussion.

Firmware changes are submitted for review. Below is the PR.
thesofproject/sof#8472

@vijendarmukunda
Copy link
Author

will fix build dependency error and post v2 set.

@vijendarmukunda vijendarmukunda force-pushed the topic/sof-dev branch 2 times, most recently from cb5e5ee to 2452259 Compare November 14, 2023 10:11
@vijendarmukunda
Copy link
Author

posted new patch set after fixing build dependency errors.

@vijendarmukunda
Copy link
Author

@plbossart, @ranj063
Firmware related changes are got merged. Could you please review this PR?

@plbossart
Copy link
Member

SOFCI TEST

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

Quite a few changes needed but at a high-level
a) some ACPI sharing is possible
b) there is no need for a startup() step I believe, no need to mimick what Intel did to follow specific power management flows.

sound/soc/amd/acp/amd-sdw-acpi.c Show resolved Hide resolved
include/linux/soundwire/sdw_amd.h Show resolved Hide resolved
drivers/soundwire/amd_init.c Outdated Show resolved Hide resolved
include/linux/soundwire/sdw_amd.h Outdated Show resolved Hide resolved
drivers/soundwire/Makefile Show resolved Hide resolved
sound/soc/sof/amd/acp.c Outdated Show resolved Hide resolved
sound/soc/sof/amd/acp-dsp-offset.h Show resolved Hide resolved
sound/soc/sof/ipc3-pcm.c Show resolved Hide resolved
sound/soc/sof/sof-audio.h Show resolved Hide resolved
sound/soc/sof/amd/acp-dsp-offset.h Show resolved Hide resolved
@vijendarmukunda
Copy link
Author

@plbossart : fixed review comments and posted new patch set. Could you please review the patch set?

@@ -0,0 +1,168 @@
// SPDX-License-Identifier: GPL-2.0+
Copy link
Member

Choose a reason for hiding this comment

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

please check with your lawyers. The code is directly inspired from Intel and released with a GPL-2.0-only license.

// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)

There is no '2.0 or later' in the initial Intel code.

Copy link
Author

Choose a reason for hiding this comment

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

we will revisit license terms


/* save context */
acp_data->sdw = sdw;
return sdw_amd_startup(acp_data->sdw);
Copy link
Member

Choose a reason for hiding this comment

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

so why do you need to implement the startup callback? Everything can be moved to sdw_amd_probe(&sdw_res);

Copy link
Author

Choose a reason for hiding this comment

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

As mentioned, earlier, its not possible to move startup callback to sdw_amd_probe(). It will break the interrupt handling functionality in parent driver code as in parent driver irq handler , it will try to deference using sdw_ctx structure. If we move this code to sdw_amd_probe(), we won't get soundwire context structure for handling Soundwire manager interrupts which results in kernel panic. i.e if we move the startup code to sdw_amd_probe() which returns ctx , once the link gets started, we get slave attach interrupt and corresponding SoundWire interrupt will be reported in parent driver IRQ handler.

For example, if we get SoundWire interrupt on SW0 link, in this case in parent driver irq handler code, we will retrieve amd_manger structure from ctx pdev get driver data as shown below.

if (val & ACP_SDW0_IRQ_MASK) {
amd_manager = dev_get_drvdata(&adata->sdw->pdev[0]->dev);

if startup is combined in sdw_amd_probe() call, as ctx is not returned to parent driver, it will result in kernel panic.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, not following any of this.

	sdw = sdw_amd_probe(&sdw_res);
	if (!sdw) {
		dev_err(sdev->dev, "SoundWire probe failed\n");
		return -EINVAL;
	}

	/* save context */
	acp_data->sdw = sdw;
	return sdw_amd_startup(acp_data->sdw);

why can't you pass acp_data in the probe and store the context inside of sdw_amd_probe?

You are trying to stick to an Intel definition of interfaces which makes no sense for you.

Copy link
Author

Choose a reason for hiding this comment

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

  1. acp_data is not a common private data structure for legacy stack and sof stack. It will be different one for legacy stack.
  2. We want to abstract usage of parent driver structures in amd_init.c file.
  3. I think its still possible, passing parent driver private data structure sdw member to the probe function and assign it in probe function itself followed by invoking start sequence in the same probe call.
  4. We want to divide whole probe and start functionality in two functions to increase the readability and scalability and we want to leave a place holder so that in future if start() functionality needs to move to some other place for example after FW loading, there will no option left with this approach.
  5. For example, we need to support a SOF scenario. In case of firmware load failure, there is no point in starting the soundwire managers. In this case if we don't have startup sequence separately, we can't support it.

We don't see any major issue in exporting one more function(start() function) other than probe().
Please note our intention is not to replicate everything in Intel style.

Copy link
Member

Choose a reason for hiding this comment

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

You really want to start the links as early as possible to make sure the peripherals are enumerated in parallel with the rest of firmware loading.

I can't force you to listen or change your code, but at this point you really don't have a good technical rationale for splitting probe/start. I am not the final reviewer so others might have a different opinion.

Copy link
Author

Choose a reason for hiding this comment

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

@plbossart : We accept your review comments. We will do the code modifications and respin the patch set and let you know the test results.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with @plbossart. sdw_amd_startup() is only used here. It is not necessary to have a separated startup function.

Copy link
Author

Choose a reason for hiding this comment

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

@bardliao : will make the changes as per @plbossart comments will combine probe and start sequence and remove separate export function.

@vijendarmukunda
Copy link
Author

Posted new patch set after fixing review comments.

plbossart
plbossart previously approved these changes Dec 19, 2023
Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

two minor points can be improved, see below.

include/linux/soundwire/sdw_amd.h Outdated Show resolved Hide resolved
drivers/soundwire/amd_manager.h Outdated Show resolved Hide resolved
Refactor amd SoundWire manager device node creation logic and
implement generic functions to have a common functionality for
SoundWire manager platform device creation, start and exit sequence
for both legacy(NO DSP) and SOF stack for AMD platforms.
These functions will be invoked from legacy and SOF stack.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Implement function to extract slaves information connected on the bus.
This information is required during machine select logic.
This function will be called from machine select logic code.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
As sdw pads enable sequence is executed only once, invoke it
from probe sequence.

Program required pads for both manager instances
based on link_mask during probe sequence. This will avoid
acquiring mutex lock.
Remove unnecessary delay after programming ACP_SW_PAD_KEEPER_EN
register.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
register mask array structure is no longer needed as except
interrupt control masks, rest of the register masks are not
used in code.

use array for interrupt masks instead of structure.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Add code for invoking Soundwire manager helper functions
when SoundWire configuration is selected.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Add support for interrupt handling for soundwire manager platform
devices.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
…orms

Add support for configuring AMD Soundwire DAI from topology.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Add machine select logic for soundwire endpoints for AMD platforms.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Update acp descriptor fields for acp6.3 version based platform.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
…tform

Select SoundWire dependency flag for acp6.3 based platform for SoundWire
configuration.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Refactor acp driver pm ops to support SoundWire interface.

When SoundWire configuration is enabled, In case of ClockStopMode,
DSP soft reset should be applied and for rest of the scenarios
acp init/deinit sequence should be invoked.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
@vijendarmukunda
Copy link
Author

pushed new patch set after fixing review comments

@plbossart
Copy link
Member

@bardliao can you take a look?

Copy link
Collaborator

@bardliao bardliao left a comment

Choose a reason for hiding this comment

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

LGTM

@plbossart plbossart merged commit 0cba055 into thesofproject:topic/sof-dev Dec 20, 2023
11 of 14 checks passed
@plbossart
Copy link
Member

@vijendarmukunda probably best to wait until next year and the rc1 to send those patches upstream.

@vijendarmukunda
Copy link
Author

@plbossart : will wait till rc1 release. I do have one more question. How can i send patch series which has to go two sub systems?
First patch ( ASoC/soundwire: implement generic api for scanning amd soundwire controller) should be pushed to asoc/soundwire tree.
On top of SoundWire patches should be pushed.

If I push only SoundWire patches then i need to wait till SoundWire patches got reflected in AsoC tree which blocks submitting
ASoC/SOF patches which are part of #4699.

Is it possible to send whole patch series at one go so that two subsystems will pick the patch series?

@plbossart
Copy link
Member

The dependency between the two subsystem is not easy to navigate.

You have to CC: both Mark Brown and Vinod Koul , clearly spell out the dependency in the cover letter and let them figure things out. One of the two will provide his Acked-by tag and the other will apply the patches.

ColinIanKing pushed a commit to ColinIanKing/linux-next that referenced this pull request Feb 1, 2024
Merge series from Vijendar Mukunda <Vijendar.Mukunda@amd.com>:

This patch series is to redesign existing platform device creation logic
for SoundWire managers and Implement generic functions for SoundWire
manager probe, start and exit sequence which are common for both Legacy
(NO DSP enabled) and SOF stack, and add SoundWire Interface support for
AMD SOF stack (ACP 6.3 based platform).

The patch series was reviewed in
thesofproject/linux#4699
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.

None yet

6 participants