Skip to content

usb: typec: hd3ss3220: Fix VBUS regulator reference handling - #972

Open
Chang Wu (kunjinkao-os) wants to merge 2 commits into
qualcomm-linux:qcom-6.18.yfrom
kunjinkao-os:fix/hd3ss3220-vbus-qcom-6.18.y
Open

usb: typec: hd3ss3220: Fix VBUS regulator reference handling#972
Chang Wu (kunjinkao-os) wants to merge 2 commits into
qualcomm-linux:qcom-6.18.yfrom
kunjinkao-os:fix/hd3ss3220-vbus-qcom-6.18.y

Conversation

@kunjinkao-os

Copy link
Copy Markdown

The HD3SS3220 driver uses regulator_is_enabled() to determine whether
VBUS needs to be enabled or disabled. However, this reports the
aggregate regulator state and cannot determine whether this consumer holds an enable reference.

If another consumer enables VBUS first, the driver may skip its own
regulator_enable() call and later issue an unbalanced regulator_disable() call.

Track the VBUS enable state locally for this consumer and update the state only after successful regulator operations. This keeps the regulator enable/disable references balanced across role and ID notifications.

Also fix the VBUS regulator error message to report the operation that was actually attempted.

Fixes: b3f9d6e ("usb: typec: hd3ss3220: Check if regulator needs to be switched")

Testing:

  • Not tested on hardware.

The error message currently reports the inverse operation because the enable/disable names are selected backwards. Report the operation that was actually attempted.

Signed-off-by: Chang Wu <kunjinkao.jp@gmail.com>
regulator_is_enabled() may report enabled when another consumer holds the
enable reference, so it cannot be used to determine whether this consumer
called regulator_enable(). If another consumer enables VBUS first, hd3ss3220
can skip its own enable. A later disable then attempts to drop a reference it
never acquired, causing an unbalanced regulator disable.

Track successful enable and disable calls locally. Do not update the state when a regulator operation fails, so repeated role and ID notifications remain balanced.

Fixes: b3f9d6e ("usb: typec: hd3ss3220: Check if regulator needs to be switched")

Signed-off-by: Chang Wu <kunjinkao.jp@gmail.com>
@qswat-orbit-external

Copy link
Copy Markdown

Merge Check Failed: No CR Numbers Found

Error: No Change Request numbers were found.

Please add Change Request numbers to your pull request description in the format CRs-Fixed: 12345 or link GitHub issues that are associated with Change Requests.

1 similar comment
@qswat-orbit-external

Copy link
Copy Markdown

Merge Check Failed: No CR Numbers Found

Error: No Change Request numbers were found.

Please add Change Request numbers to your pull request description in the format CRs-Fixed: 12345 or link GitHub issues that are associated with Change Requests.

@kunjinkao-os

Copy link
Copy Markdown
Author

Dmitry Baryshkov (@lumag) yijiyang jingyiwang42

The VBUS regulator warning was observed in the log attached to #472, but it is
independent of that issue's IRQ test failure. The IRQ test false positive was
already fixed in qualcomm-linux/qcom-linux-testkit#462 , which was merged.

This PR only fixes the independent
"unbalanced disables for vbus_supply_1" warning. As an external contributor,
I do not have access to Qualcomm's internal CR system.

Could you please advise the appropriate CR to reference for this fix, or the
accepted process for an external fix without a CR?

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.

1 participant