All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Junzhong Pan" <panjunzhong@linux.spacemit.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 5/9] usb: chipidea: usb2: add SpacemiT K1 support
Date: Tue, 08 Sep 2026 10:05:11 +0000	[thread overview]
Message-ID: <20260908100512.38FE81F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908-b4-spacemit-k1-usb2-v2-5-f07342ffa051@linux.spacemit.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Dynamic dual-role switching via `usb-role-switch` or `extcon` is completely broken when `CI_HDRC_DUAL_ROLE_NOT_OTG` is used.
- [Medium] Unsafe unconditional accesses to the OTGSC register on platforms without OTG registers.
--

commit 8804983329a666f72771103794460f9ba731c4b4
Author: Junzhong Pan <panjunzhong@linux.spacemit.com>

usb: chipidea: usb2: add SpacemiT K1 support

This commit adds a compatible string and platform data for the SpacemiT K1
USB2 controller. It configures the hardware with specific flags to account
for the lack of internal OTG register support.

> diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
> index f81673edca3c1..606ca367343f3 100644
> --- a/drivers/usb/chipidea/ci_hdrc_usb2.c
> +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
> @@ -40,10 +40,18 @@ static const struct ci_hdrc_platform_data ci_zevio_pdata = {
>  	.flags		= CI_HDRC_REGS_SHARED | CI_HDRC_FORCE_FULLSPEED,
>  };
>  
> +static const struct ci_hdrc_platform_data ci_k1_pdata = {
> +	.capoffset	= DEF_CAPOFFSET,
> +	.flags		= CI_HDRC_DISABLE_STREAMING |
> +			  CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS |
> +			  CI_HDRC_DUAL_ROLE_NOT_OTG,

[Severity: Medium]
This isn't a bug introduced by this patch, but this flag configuration
exposes a pre-existing flaw in the core driver. Can the K1 SoC bus fabric
generate a slave error for accesses to unimplemented registers within the
USB IP?

During a USB resume following a wakeup event, ci_controller_resume()
unconditionally calls ci_extcon_wakeup_int(), which does a blind read to the
unsupported OTGSC register:

drivers/usb/chipidea/core.c:ci_extcon_wakeup_int() {
        ...
        u32 otgsc = hw_read_otgsc(ci, ~0);
        ...
}

Similarly, if power is lost during suspend while in host mode,
ci_power_lost_work() calls ci_handle_id_switch(), which unconditionally
calls ci_otg_role(), resulting in another read of OTGSC.

If the K1 hardware generates an access fault instead of returning 0 for
unimplemented register reads, could this cause a synchronous load access
fault on resume or wakeup?

[Severity: High]
This is a pre-existing issue, but does dynamic dual-role switching work on
this hardware when using this flag?

The CI_HDRC_DUAL_ROLE_NOT_OTG flag forces ci->is_otg to be false. However,
the role switch framework relies on ci_irq() to process changes. Looking at
ci_irq_handler(), the entire extcon and OTG event processing block is gated
by a check for ci->is_otg:

drivers/usb/chipidea/core.c:ci_irq_handler() {
        ...
        if (ci->is_otg) {
                otgsc = hw_read_otgsc(ci, ~0);
        ...
}

If a Type-C controller or extcon driver invokes usb_role_switch_set() or
ci_cable_notifier(), both call ci_irq(). Since ci->is_otg is false, will
these events be silently ignored by the handler, leaving the port stuck in
its default role despite the standard kernel APIs being registered?

> +};
> +
>  static const struct of_device_id ci_hdrc_usb2_of_match[] = {
>  	{ .compatible = "chipidea,usb2" },
>  	{ .compatible = "xlnx,zynq-usb-2.20a", .data = &ci_zynq_pdata },
>  	{ .compatible = "lsi,zevio-usb", .data = &ci_zevio_pdata },
> +	{ .compatible = "spacemit,k1-usb2", .data = &ci_k1_pdata },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, ci_hdrc_usb2_of_match);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260908-b4-spacemit-k1-usb2-v2-0-f07342ffa051@linux.spacemit.com?part=5

  reply	other threads:[~2026-09-08 10:05 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08  9:48 [PATCH v2 0/9] Add SpacemiT K1 USB2.0 controllers support Junzhong Pan
2026-09-08  9:48 ` Junzhong Pan
2026-09-08  9:48 ` [PATCH v2 1/9] dt-bindings: usb: ci-hdrc-usb2: add spacemit,k1-usb2 compatible Junzhong Pan
2026-09-08  9:48   ` Junzhong Pan
2026-09-08  9:48 ` [PATCH v2 2/9] dt-bindings: usb: ci-hdrc-usb2: require clocks and resets for spacemit,k1-usb2 Junzhong Pan
2026-09-08  9:48   ` Junzhong Pan
2026-09-08 17:50   ` Conor Dooley
2026-09-08 17:50     ` Conor Dooley
2026-09-09 12:29     ` Junzhong Pan
2026-09-09 12:29       ` Junzhong Pan
2026-09-08  9:48 ` [PATCH v2 3/9] usb: chipidea: usb2: use devm_clk_get_optional_enabled() Junzhong Pan
2026-09-08  9:48   ` Junzhong Pan
2026-09-08  9:55   ` sashiko-bot
2026-09-08 10:01   ` Junzhong Pan
2026-09-08 10:01     ` Junzhong Pan
2026-09-08  9:48 ` [PATCH v2 4/9] usb: chipidea: usb2: add optional reset support Junzhong Pan
2026-09-08  9:48   ` Junzhong Pan
2026-09-08 10:00   ` sashiko-bot
2026-09-08  9:48 ` [PATCH v2 5/9] usb: chipidea: usb2: add SpacemiT K1 support Junzhong Pan
2026-09-08  9:48   ` Junzhong Pan
2026-09-08 10:05   ` sashiko-bot [this message]
2026-09-08 13:11   ` Troy Mitchell
2026-09-08 13:11     ` Troy Mitchell
2026-09-08  9:48 ` [PATCH v2 6/9] riscv: dts: spacemit: add USB2.0 controller nodes for K1 Junzhong Pan
2026-09-08  9:48   ` Junzhong Pan
2026-09-08 10:10   ` sashiko-bot
2026-09-08  9:48 ` [PATCH v2 7/9] riscv: dts: spacemit: enable USB2.0 controllers on BananaPi F3 Junzhong Pan
2026-09-08  9:48   ` Junzhong Pan
2026-09-08 13:11   ` Troy Mitchell
2026-09-08 13:11     ` Troy Mitchell
2026-09-08  9:48 ` [PATCH v2 8/9] riscv: dts: spacemit: enable USB2.0 controllers on OrangePi RV2 Junzhong Pan
2026-09-08  9:48   ` Junzhong Pan
2026-09-13  8:33   ` Ze Huang
2026-09-13  8:33     ` Ze Huang
2026-09-08  9:48 ` [PATCH v2 9/9] riscv: defconfig: enable ChipIdea USB controller support Junzhong Pan
2026-09-08  9:48   ` Junzhong Pan
2026-09-08 22:07   ` Yixun Lan
2026-09-08 22:07     ` Yixun Lan
2026-09-09 12:31     ` Junzhong Pan
2026-09-09 12:31       ` Junzhong Pan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260908100512.38FE81F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=panjunzhong@linux.spacemit.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.