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: intel: don't return error when clock stop failed #2671

Merged
merged 1 commit into from
Jan 12, 2021

Conversation

bardliao
Copy link
Collaborator

@bardliao bardliao commented Jan 7, 2021

dev->power.runtime_error will be set to the return value of runtime
suspend callback function, and runtime resume function will return
-EINVAL if dev->power.runtime_error is not 0.
Somehow codec can rarely doesn't ack to the clock prepare command.
If we stop the runtime suspend process and return error, we will not
be able to resume again. As a result, the sdw bus can not be used
anymore.
This patch suggests to finish the runtime suspend process even if we
fail to stop sdw bus clock. Power consumption may be higher and lose
interrupt if fail to stop clock, but at least audio function can still
work after that.

Signed-off-by: Bard Liao yung-chuan.liao@linux.intel.com

@bardliao
Copy link
Collaborator Author

bardliao commented Jan 7, 2021

@aiChaoSONG Could you test if the audio can work after #2606 happens with this PR?

@aiChaoSONG
Copy link
Collaborator

@bardliao Bad news, the only CML STRA device is packaged and will be returned. I cannot verify it on our side, sorry.

@bardliao
Copy link
Collaborator Author

bardliao commented Jan 8, 2021

Verified it on CML sdw platform.

lyakh
lyakh previously approved these changes Jan 8, 2021
Copy link

@lyakh lyakh left a comment

Choose a reason for hiding this comment

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

one could retry a couple of times, not sure if it's worth it though

Copy link

@RanderWang RanderWang left a comment

Choose a reason for hiding this comment

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

@bardliao it will affect resume path. Can you confirm the following path?

clock_stop0 = sdw_cdns_is_clock_stop(&sdw->cdns);

		if (!clock_stop0)

@RanderWang
Copy link

@bardliao it will affect resume path. Can you confirm the following path?

clock_stop0 = sdw_cdns_is_clock_stop(&sdw->cdns);

		if (!clock_stop0)

if the path is ok, in my opinion you can refine the commit message. It is fine to do as this since we will do hardware reset to make everything work in resume function.

@bardliao
Copy link
Collaborator Author

@bardliao it will affect resume path. Can you confirm the following path?

clock_stop0 = sdw_cdns_is_clock_stop(&sdw->cdns);

		if (!clock_stop0)

if the path is ok, in my opinion you can refine the commit message. It is fine to do as this since we will do hardware reset to make everything work in resume function.

Thanks @RanderWang I checked clock_stop0 is 0 as expected when the issue occurred. And my commit message is updated.

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.

minor edits in commit message, see below

@@ -1693,7 +1695,7 @@ static int __maybe_unused intel_suspend_runtime(struct device *dev)
return ret;
}

intel_shim_wake(sdw, true);
intel_shim_wake(sdw, wake_enable);
Copy link
Member

Choose a reason for hiding this comment

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

this seems good to me, let's do this.

Minor edits to the commit message

dev->power.runtime_error will be set to the return value of the runtime
suspend callback function, and runtime resume function will return
-EINVAL if dev->power.runtime_error is not 0.

Somehow the codec rarely doesn't return an ACK to the clock prepare command.
If we stop the runtime suspend process and return error, we will not
be able to resume again. Likewise, if the codec lost sync and did not rejoin, the resume operation will also fail. As a result, the SoundWire bus can not be used
anymore.

This patch suggests to finish the runtime suspend process even if we
fail to stop sdw bus clock. In the case where we do a hardware reset, the codecs will be reconfigured completely.
In the case where we use the regular clock stop, the codecs keep their state and worst case will fall off the bus and reattach.

The only drawback is that the power consumption may be higher and device-initiated interrupts may be lost, but at least audio function can still work after resume

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@plbossart Welcome back. Updated.

@bardliao
Copy link
Collaborator Author

one could retry a couple of times, not sure if it's worth it though

I tried to retry as below, but it didn't help. The result is always -61 in the 10 iterations.

--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -863,6 +863,7 @@ static int sdw_slave_clk_stop_prepare(struct sdw_slave *slave,
        bool wake_en;
        u32 val = 0;
        int ret;
+       int i;

        wake_en = slave->prop.wake_capable;

@@ -882,6 +883,11 @@ static int sdw_slave_clk_stop_prepare(struct sdw_slave *slave,

        ret = sdw_write_no_pm(slave, SDW_SCP_SYSTEMCTRL, val);

+       for (i = 0; i < 10 && ret == -ENODATA; i++) {
+               dev_err(&slave->dev, "bard: Rewrite SDW_SCP_SYSTEMCTRL %d ret %d\n", i, ret);
+               ret = sdw_write_no_pm(slave, SDW_SCP_SYSTEMCTRL, val);
+       }
+
        if (ret != 0)
                dev_err(&slave->dev,
                        "Clock Stop prepare failed for slave: %d", ret);

dev->power.runtime_error will be set to the return value of the runtime
suspend callback function, and runtime resume function will return
-EINVAL if dev->power.runtime_error is not 0.

Somehow the codec rarely doesn't return an ACK to the clock prepare
command. If we stop the runtime suspend process and return error, we
will not be able to resume again. Likewise, if the codec lost sync and
did not rejoin, the resume operation will also fail. As a result, the
SoundWire bus can not be used anymore.

This patch suggests to finish the runtime suspend process even if we fail
to stop sdw bus clock. In the case where we do a hardware reset, the codecs
will be reconfigured completely. In the case where we use the regular clock
stop, the codecs keep their state and worst case will fall off the bus and
reattach.

The only drawback is that the power consumption may be higher and
device-initiated interrupts may be lost, but at least audio function can
still work after resume.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
@plbossart plbossart merged commit 00e9738 into thesofproject:topic/sof-dev Jan 12, 2021
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.

6 participants