Skip to content

[TEST] [DO NOT MERGE] SoundWire timeouts: revert fwnode changes - #2616

Closed
plbossart wants to merge 2 commits into
thesofproject:topic/sof-devfrom
plbossart:test/revert-fwnode-changes
Closed

plbossart wants to merge 2 commits into
thesofproject:topic/sof-devfrom
plbossart:test/revert-fwnode-changes

Conversation

@plbossart

@plbossart plbossart commented Dec 10, 2020 •

Copy link
Copy Markdown
Member

Git bisect tells us that the changes made by @andy-shev seem to introduce timeout errors for SoundWire during our system suspend-resume tests, specifically when we play with modprobe/rmmod before doing the suspend-resume tests.

See traces in #2603 (comment)

PR2063 makes the timeouts disappear by forcing the codecs and sdw-master devices pm_runtime active on system resume, but it's not clear what the link is with @andy-shev's patches.

This PR is just to test the hypothesis and see if reverting also removes the timeouts. There may be something we are missing here. We do share the same fwnode in the Intel SoundWire drivers, so there's more than a random coincidence IMHO.

…mary firmware node"

This reverts commit 99aed92.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
This reverts commit d5dcce0.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
@plbossart

Copy link
Copy Markdown
Member Author

For more context, here's the git bisect log and the diff that was applied on top of each bisect point to find the issue

git bisect log
git bisect start
# good: [3650b228f83adda7e5ee532e2b90429c03f7b9ec] Linux 5.10-rc1
git bisect good 3650b228f83adda7e5ee532e2b90429c03f7b9ec
# bad: [3cea11cd5e3b00d91caf0b4730194039b45c5891] Linux 5.10-rc2
git bisect bad 3cea11cd5e3b00d91caf0b4730194039b45c5891
# bad: [11ad2a73de10bbebb71199f29abdfc1c2e70d231] Merge tag 'asm-generic-fixes-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic
git bisect bad 11ad2a73de10bbebb71199f29abdfc1c2e70d231
# good: [07e0887302450a62f51dba72df6afb5fabb23d1c] Merge tag 'fallthrough-fixes-clang-5.10-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux
git bisect good 07e0887302450a62f51dba72df6afb5fabb23d1c
# good: [88098fd61b7e52e1f78668b6f1f07d39ca67301f] Merge tag 'mmc-v5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
git bisect good 88098fd61b7e52e1f78668b6f1f07d39ca67301f
# good: [91caef27a15c25948b23f7d400a2c6d70720b2a9] Merge tag 'amlogic-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-amlogic into arm/fixes
git bisect good 91caef27a15c25948b23f7d400a2c6d70720b2a9
# good: [ee176906dc882ba6223d834ae61790e7550515fd] Merge tag 'acpi-5.10-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
git bisect good ee176906dc882ba6223d834ae61790e7550515fd
# good: [3d696f42c7f4bfcc54bde545898d4b89a74f9cc0] soc: ti: ti_sci_pm_domains: check for proper args count in xlate
git bisect good 3d696f42c7f4bfcc54bde545898d4b89a74f9cc0
# bad: [a5a16050d78dd4a8a5a2a6614e64f76d59ef8a2e] Merge tag 'devprop-5.10-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
git bisect bad a5a16050d78dd4a8a5a2a6614e64f76d59ef8a2e
# bad: [99aed9227073fb34ce2880cbc7063e04185a65e1] device property: Don't clear secondary pointer for shared primary firmware node
git bisect bad 99aed9227073fb34ce2880cbc7063e04185a65e1
# bad: [d5dcce0c414fcbfe4c2037b66ac69ea5f9b3f75c] device property: Keep secondary firmware node secondary by type
git bisect bad d5dcce0c414fcbfe4c2037b66ac69ea5f9b3f75c
# first bad commit: [d5dcce0c414fcbfe4c2037b66ac69ea5f9b3f75c] device property: Keep secondary firmware node secondary by type

plb.diff.txt

@aiChaoSONG

Copy link
Copy Markdown

SOFCI TEST

@andy-shev

Copy link
Copy Markdown

I have a theory that SoundWire tries to assign two secondary fwnodes and fails now. Check how you assing device properties and companion devices in the code. Also check if any of that nodes are shared or exclusive (how many devices are actually using it). You see, this is probably the outcome of avoiding device_remove_properties() (read: swnode lifetime issues), but I need to see an evidence before jumping into above conclusion.

@plbossart

plbossart commented Dec 11, 2020 •

Copy link
Copy Markdown
Member Author

@andy-shev we don't assign companion devices, and we only use the same reference in several layers. It's quite possible that we are idiots and never did the right thing...

The initial handle is the PRP0001 device that's the companion of the PCI device.

From there we create 4 platform devices:
https://elixir.bootlin.com/linux/latest/source/drivers/soundwire/intel_init.c#L257

And below we create a master device below each platform device (not my decision...)
https://elixir.bootlin.com/linux/latest/source/drivers/soundwire/intel.c#L1321
https://elixir.bootlin.com/linux/latest/source/drivers/soundwire/master.c#L136

Edit: The only other place where we play with properties is in the machine driver, where we set properties for the RT711.

https://elixir.bootlin.com/linux/v5.9.13/source/sound/soc/intel/boards/sof_sdw_rt711.c#L37
https://elixir.bootlin.com/linux/v5.9.13/source/sound/soc/intel/boards/sof_sdw_rt711.c#L145

Does this help @andy-shev?

@bardliao maybe we should remove this handling of device properties in the RT711 case, just to see if the problem is on the machine driver side or in the Soundwire code.

@andy-shev

Copy link
Copy Markdown

Yeah... You need to use like others do: https://elixir.bootlin.com/linux/latest/source/drivers/i2c/busses/i2c-dln2.c#L211

struct device *dev = &pdev->dev;

dln2->adapter.dev.parent = dev;
ACPI_COMPANION_SET(&dln2->adapter.dev, ACPI_COMPANION(&pdev->dev));

i.o.w. ACPI_COMPANION_SET(dev, ACPI_COMPANION(dev->parent));

@plbossart

Copy link
Copy Markdown
Member Author

i.o.w. ACPI_COMPANION_SET(dev, ACPI_COMPANION(dev->parent));

wow, what a miss! thanks @andy-shev for the tip.

Did you mean to say we have to do this as every additional device layer we create?

@andy-shev

Copy link
Copy Markdown

i.o.w. ACPI_COMPANION_SET(dev, ACPI_COMPANION(dev->parent));

wow, what a miss! thanks @andy-shev for the tip.

Did you mean to say we have to do this as every additional device layer we create?

That is how primary fwnode got shared between "virtual" devices in the Linux kernel. So, parent here, let's say, describes real physical device and we create some other device as it's child. What we want is to have access to the properties provided by firmware for real device, i.e. parent. Thus, we install primary fwnode of the child to be the same as primary of the parent.

@plbossart

Copy link
Copy Markdown
Member Author

i.o.w. ACPI_COMPANION_SET(dev, ACPI_COMPANION(dev->parent));

wow, what a miss! thanks @andy-shev for the tip.
Did you mean to say we have to do this as every additional device layer we create?

That is how primary fwnode got shared between "virtual" devices in the Linux kernel. So, parent here, let's say, describes real physical device and we create some other device as it's child. What we want is to have access to the properties provided by firmware for real device, i.e. parent. Thus, we install primary fwnode of the child to be the same as primary of the parent.

Our code 'worked' before without all this, and the only case where we read the properties of the parent from a lower layer is here:

https://elixir.bootlin.com/linux/latest/source/drivers/soundwire/intel.c#L1213

That part doesn't seem related to the RT711 timeouts though.

I have to run, will look into this on Monday. Thanks @andy-shev for your help

@bardliao

Copy link
Copy Markdown
Collaborator

@bardliao maybe we should remove this handling of device properties in the RT711 case, just to see if the problem is on the machine driver side or in the Soundwire code.

The timed out issue is gone if I removed device_add_properties in sof_sdw_rt711.c. But I think what we really missed is ACPI_COMPANION_SET. We will not go into the if (!(parent && fn == parent->fwnode)) condition with #2630 + ACPI_COMPANION_SET(&slave->dev, ACPI_COMPANION(bus->dev)); .

--- a/sound/soc/intel/boards/sof_sdw_rt711.c
+++ b/sound/soc/intel/boards/sof_sdw_rt711.c
@@ -36,7 +36,8 @@ static int rt711_add_codec_device_props(const char *sdw_dev_name)
                                              SOF_RT711_JDSRC(sof_sdw_quirk));
        }

-       ret = device_add_properties(sdw_dev, props);
+       ret = 0;
        put_device(sdw_dev);

        return ret;

@andy-shev

Copy link
Copy Markdown

Our code 'worked' before without all this, and the only case where we read the properties of the parent from a lower layer is here:

https://elixir.bootlin.com/linux/latest/source/drivers/soundwire/intel.c#L1213

That part doesn't seem related to the RT711 timeouts though.

Something is telling me that your topology is more complex than parent <--> child relation. Perhaps you actually need to use fwnode graph (as V4L2 does).

@plbossart

Copy link
Copy Markdown
Member Author

Our code 'worked' before without all this, and the only case where we read the properties of the parent from a lower layer is here:
https://elixir.bootlin.com/linux/latest/source/drivers/soundwire/intel.c#L1213
That part doesn't seem related to the RT711 timeouts though.

Something is telling me that your topology is more complex than parent <--> child relation. Perhaps you actually need to use fwnode graph (as V4L2 does).

no, it's strictly parent-child. the only exception is when we set properties in the machine driver, but that's not changing the device topology.

we've shown that the issue is that the dev->fwnode is overridden the second time in a modprobe/rmmod/modprobe test. The dev->fwnode is overridden by the properties, and that causes massive issues with suspend/resume.

@plbossart plbossart closed this Dec 15, 2020
@andy-shev

Copy link
Copy Markdown

Something is telling me that your topology is more complex than parent <--> child relation. Perhaps you actually need to use fwnode graph (as V4L2 does).

no, it's strictly parent-child. the only exception is when we set properties in the machine driver, but that's not changing the device topology.

we've shown that the issue is that the dev->fwnode is overridden the second time in a modprobe/rmmod/modprobe test. The dev->fwnode is overridden by the properties, and that causes massive issues with suspend/resume.

Good to know, thanks for clarifying. Let's close this an continue elsewhere.

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