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

ASoC: soc_sdw_utils: skip the endpoint that doesn't present #5351

Merged
merged 2 commits into from
Mar 17, 2025

Conversation

bardliao
Copy link
Collaborator

@bardliao bardliao commented Mar 6, 2025

We can check the DisCo table and know what functions are used by the codec. Then skip the unused endpoints. And we can remove the dai quirk in codec_info_list[].

else if (asoc_sdw_is_unique_device(adr_link, sdw_version, mfg_id, part_id,
class_id, adr_index))
if (asoc_sdw_is_unique_device(adr_link, sdw_version, mfg_id, part_id,
class_id, adr_index))
return devm_kasprintf(dev, GFP_KERNEL, "sdw:0:%01x:%04x:%04x:%02x",
link_id, mfg_id, part_id, class_id);
else
Copy link
Collaborator

Choose a reason for hiding this comment

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

the else is redundant here

if (!slave)
return -EINVAL;

/* Mack sure BIOS provides SDCA properties */
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo Make

for (k = 0; k < slave->sdca_data.num_functions; k++) {
int dai_type = asoc_sdw_get_dai_type(
slave->sdca_data.function[k].type);
dev_dbg(&slave->dev, "function: %s dai_type %d\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

you need a newline here

Copy link
Collaborator

Choose a reason for hiding this comment

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

And won't you be printing this debug for every endpoint match?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, will remove.

dev_dbg(&slave->dev, "function: %s dai_type %d\n",
slave->sdca_data.function[k].name, dai_type);
if (dai_type == dai_info->dai_type) {
dev_dbg(&slave->dev, "DAI type %d found\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe say something along the lines of SDCA device function found ?

}
}
if (k == slave->sdca_data.num_functions) {
dev_dbg(&slave->dev, "DAI type %d not found, skip endpoint\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also here, maybe "SDCA device function for DAI type %d not supported, skip endpoint"

@bardliao bardliao force-pushed the sdca-endpoint-test branch 2 times, most recently from 5167bbe to b153c6f Compare March 7, 2025 07:00
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

May need a little more in the logs

@@ -1204,6 +1228,55 @@ int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
!(dai_info->quirk_exclude ^ !!(dai_info->quirk & ctx->mc_quirk)))
continue;

/* No need to check SDCA functions if there is only 1 endpoint present */
if (adr_dev->num_endpoints == 1)
Copy link
Member

Choose a reason for hiding this comment

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

do we need a log entry here to state that only 1 endpoint is found and we assume it to be type X

@bardliao
Copy link
Collaborator Author

Not sure what happened to PTLP_RVP_SDW tests. All playback/capture tests failed. And there is no dmesg. But, I run the test manually on the same DUT (ba-ptlh-rvp-01) and they passed. Also, the dmesg of https://sof-ci.01.org/linuxpr/PR5351/build6503/devicetest/index.html?model=PTLP_RVP_SDW&testcase=verify-kernel-boot-log looks good to me.

Mar 07 07:54:02 ba-ptlh-rvp-01 kernel: soundwire_bus:sdw_extract_slave_id: soundwire sdw-master-0-3: SDW Slave Addr: 330025d072201
Mar 07 07:54:02 ba-ptlh-rvp-01 kernel: soundwire_bus:sdw_extract_slave_id: soundwire sdw-master-0-3: SDW Slave class_id 0x01, mfg_id 0x025d, part_id 0x0722, unique_id 0x0, version 0x3
Mar 07 07:54:02 ba-ptlh-rvp-01 kernel: acpi device:1f: find_sdca_function: SDCA function UAJ (type 6) at 0x1
Mar 07 07:54:02 ba-ptlh-rvp-01 kernel: acpi device:20: find_sdca_function: SDCA function SmartMic (type 3) at 0x2
Mar 07 07:54:02 ba-ptlh-rvp-01 kernel: acpi device:21: find_sdca_function: SDCA function HID (type 10) at 0x3
Mar 07 07:54:02 ba-ptlh-rvp-01 kernel: acpi device:22: find_sdca_function: SDCA function SmartAmp (type 1) at 0x4

@bardliao
Copy link
Collaborator Author

SOFCI TEST

@bardliao bardliao force-pushed the sdca-endpoint-test branch from b153c6f to fc371ba Compare March 10, 2025 02:08
@bardliao
Copy link
Collaborator Author

SOFCI TEST

Currently asoc_sdw_get_codec_name will return codec_info->codec_name if
it is set. However, in some case we need the sdw codec name no matter if
codec_info->codec_name is set or not.
_asoc_sdw_get_codec_name() will be used in the follow up commit.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
@bardliao bardliao force-pushed the sdca-endpoint-test branch from fc371ba to 76db426 Compare March 10, 2025 06:57
@bardliao
Copy link
Collaborator Author

PTLP_RVP_SDW is not tested. Trigger CI test again.

@bardliao
Copy link
Collaborator Author

SOFCI TEST

lgirdwood
lgirdwood previously approved these changes Mar 10, 2025
Copy link
Collaborator

@ujfalusi ujfalusi left a comment

Choose a reason for hiding this comment

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

@bardliao, will this work with already release topology files (where split ones are not available)?

/* Make sure BIOS provides SDCA properties */
if (!slave->sdca_data.interface_revision) {
dev_warn(&slave->dev,
"SDCA properties not found in the BIOS\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is every sdw device is SDCA?
I think this should be at most in info or even dbg level.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or check is it a SDCA codec first?

dai_info->dai_type);
continue;
}
skip_sdca_function_check:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know, but jumping within a loop does not sound right.
It might be better to move this new code into a sdca helper function.

@bardliao
Copy link
Collaborator Author

@bardliao, will this work with already release topology files (where split ones are not available)?

In theory, yes. We use DMI quirk to set optional SDCA DAI types for all existing. We should get the same result with this PR is the BIOS is configured properly.

if (ret < 0)
return ret;

if (!ret)
Copy link
Collaborator

@ujfalusi ujfalusi Mar 10, 2025

Choose a reason for hiding this comment

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

is_sdca_function_present()
ret < 0 is error
ret == 0 is true
ret == 1 is false
?
I would swap the true/false with a comment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

or not, I'm not sure what is going on ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My first thought wat let is_sdca_function_present() return true/false only and it will be Intuitive. However, I would like to include the error checking in is_sdca_function_present(), so I changed the return type to int. Maybe we should rename is_sdca_function_present() as it is not just checking is SDCA function present. The purpose of the helper is to decide whether we should skip the endpoint. We should only skip the endpoint if there are more than 1 endpoints and we can get the SDCA supported functions and none of the supported functions matches the DAI type.

@bardliao bardliao force-pushed the sdca-endpoint-test branch 2 times, most recently from e3ee7ee to 5756cb1 Compare March 11, 2025 08:35
@@ -1203,6 +1306,22 @@ int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
!(dai_info->quirk_exclude ^ !!(dai_info->quirk & ctx->mc_quirk)))
continue;

/*
* Don't check is sdca endpoint present if machine quirk is set
* In other works, quirk should have higher priority than the sdca
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo: s/works/words

@bardliao bardliao force-pushed the sdca-endpoint-test branch from 5756cb1 to bc0821a Compare March 11, 2025 08:55
ujfalusi
ujfalusi previously approved these changes Mar 11, 2025
@bardliao bardliao force-pushed the sdca-endpoint-test branch 2 times, most recently from 9348f77 to dc21a44 Compare March 11, 2025 10:43
@@ -1196,6 +1308,22 @@ int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
!(dai_info->quirk_exclude ^ !!(dai_info->quirk & ctx->mc_quirk)))
continue;

/*
* Don't check is sdca endpoint present if machine quirk is set

Choose a reason for hiding this comment

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

*Don't check if

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

*Don't check if

Changed

@bardliao bardliao force-pushed the sdca-endpoint-test branch from dc21a44 to 32d8a10 Compare March 11, 2025 13:54
@@ -1203,6 +1308,22 @@ int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
!(dai_info->quirk_exclude ^ !!(dai_info->quirk & ctx->mc_quirk)))
continue;

/*
* Don't check if sdca endpoint present if machine quirk is set
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't check the sdca endpoint presence if machine quirk is set.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or
Skip the sdca endpoint presence check if machine quirk is set.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

A codec endpoint may not be used. We could check the present SDCA
functions to know if the endpoint is used or not. Skip the endpoint
which is not used.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
@bardliao bardliao force-pushed the sdca-endpoint-test branch from 32d8a10 to eae45e1 Compare March 12, 2025 01:16
@ranj063
Copy link
Collaborator

ranj063 commented Mar 12, 2025

@charleskeepax are you good with this PR?

@ranj063
Copy link
Collaborator

ranj063 commented Mar 14, 2025

@bardliao I see some failures on PTL SDW that I do not see in other PRs. Do you think it is related to the changes here?

@bardliao
Copy link
Collaborator Author

SOFCI TEST

@bardliao
Copy link
Collaborator Author

@bardliao I see some failures on PTL SDW that I do not see in other PRs. Do you think it is related to the changes here?

No, it is related to display audio

@bardliao bardliao merged commit 7209bcb into thesofproject:topic/sof-dev Mar 17, 2025
12 of 15 checks passed
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.

5 participants