Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hongyang Zhao" <hongyang.zhao@163.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/3] usb: typec: Add Hynetek HUSB320 Type-C controller driver
Date: Mon, 20 Jul 2026 08:32:05 +0000	[thread overview]
Message-ID: <20260720083206.8AC781F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260720-husb320-v1-2-4a1e259d7dc8@163.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Masking interrupt status bits before Write-1-to-Clear (W1C) clearing causes unhandled or reserved interrupts to remain asserted, leading to an interrupt storm.
- [Medium] The driver incorrectly reports the power role as TYPEC_SOURCE when connected to a Charge-Through Audio Accessory.
--

--- Patch [2]: [PATCH 2/3] usb: typec: Add Hynetek HUSB320 Type-C controller driver ---
commit e0d1ae316e83fd4e771770397178a91c9673d5ac
Author: Hongyang Zhao <hongyang.zhao@163.com>

usb: typec: Add Hynetek HUSB320 Type-C controller driver

This commit adds a new USB Type-C controller driver for the Hynetek HUSB320.
The driver implements autonomous Configuration Channel handling, supporting
attach/detach detection, role switching, and accessory modes.

> diff --git a/drivers/usb/typec/husb320.c b/drivers/usb/typec/husb320.c
> new file mode 100644
> index 0000000000000..fd9f949d9b522
> --- /dev/null
> +++ b/drivers/usb/typec/husb320.c

[ ... ]

> +static enum husb320_state husb320_get_state(unsigned int status,
> +					    unsigned int type)
> +{
> +	if (!(status & HUSB320_STATUS_ATTACHED))
> +		return HUSB320_STATE_UNATTACHED;
> +
> +	if (type & HUSB320_TYPE_DEBUG_SOURCE)
> +		return HUSB320_STATE_DEBUG_SOURCE;
> +	if (type & HUSB320_TYPE_DEBUG_SINK)
> +		return HUSB320_STATE_DEBUG_SINK;
> +	if (type & HUSB320_TYPE_SINK)
> +		return HUSB320_STATE_SINK;
> +	if (type & HUSB320_TYPE_SOURCE)
> +		return HUSB320_STATE_SOURCE;
> +	if (type & (HUSB320_TYPE_AUDIO_VBUS | HUSB320_TYPE_AUDIO))
> +		return HUSB320_STATE_AUDIO;

[Severity: Medium]
Does mapping HUSB320_TYPE_AUDIO_VBUS to HUSB320_STATE_AUDIO cause
charge-through accessories to be treated exactly the same as standard audio
accessories?

Since husb320_state_power_role() forces TYPEC_SOURCE for HUSB320_STATE_AUDIO,
would this result in incorrectly reporting the host as providing power when
it is actually receiving it?

> +
> +	return HUSB320_STATE_UNATTACHED;
> +}

[ ... ]

> +static irqreturn_t husb320_irq_thread(int irq, void *data)
> +{
> +	struct husb320 *husb = data;
> +	unsigned int interrupt;
> +	unsigned int interrupt1;
> +	int disable_ret;
> +	int ret;
> +
> +	mutex_lock(&husb->lock);
> +	if (husb->shutting_down) {
> +		disable_irq_nosync(irq);
> +		mutex_unlock(&husb->lock);
> +		return IRQ_HANDLED;
> +	}
> +
> +	ret = regmap_read(husb->regmap, HUSB320_REG_INTERRUPT, &interrupt);
> +	if (ret)
> +		goto err;
> +
> +	ret = regmap_read(husb->regmap, HUSB320_REG_INTERRUPT1, &interrupt1);
> +	if (ret)
> +		goto err;
> +
> +	interrupt &= HUSB320_INT_VALID;
> +	interrupt1 &= HUSB320_INT1_VALID;
> +	if (!interrupt && !interrupt1) {
> +		mutex_unlock(&husb->lock);
> +		return IRQ_NONE;
> +	}
> +
> +	if (interrupt) {
> +		ret = regmap_write(husb->regmap, HUSB320_REG_INTERRUPT,
> +				   interrupt);

[Severity: High]
If the hardware asserts a reserved or undocumented interrupt bit, will
masking the interrupt variable against HUSB320_INT_VALID prevent that bit
from being cleared when written back?

Could this cause an unhandled hardware interrupt to remain asserted,
leading to an interrupt storm that eventually forces the kernel to disable
the IRQ line?

> +		if (ret)
> +			goto err;
> +	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260720-husb320-v1-0-4a1e259d7dc8@163.com?part=2

  reply	other threads:[~2026-07-20  8:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20  8:17 [PATCH 0/3] Add Hynetek HUSB320 Type-C controller support Hongyang Zhao
2026-07-20  8:17 ` [PATCH 1/3] dt-bindings: usb: Add Hynetek HUSB320 Type-C controller Hongyang Zhao
2026-07-20  8:17 ` [PATCH 2/3] usb: typec: Add Hynetek HUSB320 Type-C controller driver Hongyang Zhao
2026-07-20  8:32   ` sashiko-bot [this message]
2026-07-20  8:17 ` [PATCH 3/3] MAINTAINERS: Add HUSB320 Type-C controller entry Hongyang Zhao

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=20260720083206.8AC781F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hongyang.zhao@163.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox