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

@kunjinkao-os Chang Wu (kunjinkao-os) commented Aug 18, 2026

Copy link
Copy Markdown

The HD3SS3220 driver uses regulator_is_enabled() to determine whether VBUS
needs to be enabled or disabled. However, regulator_is_enabled() reports the
aggregate regulator state and does not indicate 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 so that regulator enable and disable
references remain balanced for this consumer. Update the state only after a
successful regulator operation.

This PR contains two commits:

  1. UPSTREAM: usb: typec: hd3ss3220: fix VBUS regulator error message
    Already merged in the Linux USB subsystem.
  2. FROMLIST: usb: typec: hd3ss3220: track VBUS enable state per consumer
    Submitted upstream at:
    https://lore.kernel.org/linux-usb/20260819152027.90994-1-kunjinkao.jp@gmail.com/

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

Testing:

  • scripts/checkpatch.pl --strict: no errors or warnings
  • Qualcomm CI checkpatch, sparse, DT and UAPI checks: passed
  • Not tested on hardware

I am an external contributor and do not have access to Qualcomm's internal
CR system. Maintainer guidance on the appropriate CR association would be
appreciated.

@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?

@kunjinkao-os
Chang Wu (kunjinkao-os) force-pushed the fix/hd3ss3220-vbus-qcom-6.18.y branch from 3a1bdcc to 1186be0 Compare August 19, 2026 13:26
@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.

2 similar comments
@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.

@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.

Xu Rao and others added 2 commits August 19, 2026 23:30
hd3ss3220_regulator_control() enables the VBUS regulator when @on is
true and disables it when @on is false.  However, its error message uses
the opposite operation name, so an enable failure is reported as a
disable failure and vice versa.

Print the operation that was actually attempted.  Reporting the opposite
regulator operation on failures can mislead debugging of VBUS problems.

Fixes: 27fbc19 ("usb: typec: hd3ss3220: Enable VBUS based on role state")
Cc: stable@vger.kernel.org
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Xu Rao <raoxu@uniontech.com>
Link: https://patch.msgid.link/7A42A287B2B588D0+20260812094632.348581-1-raoxu@uniontech.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
regulator_is_enabled() reports the aggregate regulator state, not
whether this consumer holds an enable reference. If another consumer
enables VBUS first, the driver can skip its own regulator_enable() call
and later attempt to drop a reference it never acquired, triggering an
unbalanced regulator disable warning.

Track successful enable and disable calls locally. Keep the state
unchanged when an operation fails so a later role or ID notification
retries the operation while this consumer keeps balanced references.

Fixes: b3f9d6e ("usb: typec: hd3ss3220: Check if regulator needs to be switched")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/linux-usb/20260819152027.90994-1-kunjinkao.jp@gmail.com/
Signed-off-by: Chang Wu <kunjinkao.jp@gmail.com>
@kunjinkao-os
Chang Wu (kunjinkao-os) force-pushed the fix/hd3ss3220-vbus-qcom-6.18.y branch from 1186be0 to 12aa1d7 Compare August 19, 2026 15:31
@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.

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