linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: "fengchunguo@126.com" <fengchunguo@126.com>
Cc: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] usb: typec: Added power_operation_mode_show type check when usb slowly detect
Date: Thu, 16 Jan 2025 11:12:52 +0100	[thread overview]
Message-ID: <2025011634-lurch-goon-d135@gregkh> (raw)
In-Reply-To: <1737011671-88288-1-git-send-email-fengchunguo@126.com>

On Thu, Jan 16, 2025 at 03:14:31PM +0800, fengchunguo@126.com wrote:
> From: Gary <fengchunguo@126.com>

Full name please.

> 
> When the type of usb inserted one un-defined power mode, only 90mA
> voltage, system panic sometime.So added the one condition for avioding it.
> 
> Reproduced:
> 1.Inserted usb cable for charging slowly.
> 2.System panic sometimes. The log:
> Unexpected kernel BRK exception at EL1
> msm-dwc3 4e00000.ssusb: DWC3 exited from low power mode
> Internal error: BRK handler: 00000000f2005512 [#1] PREEMPT SMP
> Skip md ftrace buffer dump for: 0x1609e0
> Hardware name:Qualcomm Technologies, Inc. Blair QRD (DT)
> pstate: a0400005 (NzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> pc : power_operation_mode_show+0x48/0x50
> lr : dev_attr_show+0x38/0x74
> sp : ffffffc015d83c00
> x29: ffffffc015d83c00 x28: ffffff80517212c0 x27: 000000007ffff001
> x26: 0000000000000001 x25: 0000000000000000 x24: ffffff801b9274f0
> x23: ffffff805a9f1cc0 x22: ffffffda7b7a2608 x21: ffffff8050e99000
> x20: ffffffda7c5fb5b0 x19: ffffff801b9274c8 x18: ffffffc01568d070
> x17: 00000000df43c25c x16: 00000000df43c25c x15: 0000000000000000
> x14: 0000000000000000 x13: ffffffa77aadf000 x12: ffffffda7c4a1210
> x11: ffffff8050e99000 x10: 0000000000000000 x9 : ffffffda7ae948ac
> x8 : 00000000fffffffa x7 : 0000000000000000 x6 : 000000000000003f
> x5 : 0000000000000040 x4 : 0000000000000000 x3 : 0000000000000004
> x2 : ffffff8050e99000 x1 : ffffffda7c5fb5b0 x0 : ffffff80858ca008
> Call trace:
>  power_operation_mode_show+0x48/0x50
>  dev_attr_show+0x38/0x74
>  sysfs_kf_seq_show+0xb4/0x130
>  kernfs_seq_show+0x44/0x54
>  seq_read_iter+0x158/0x4ec
>  kernfs_fop_read_iter+0x68/0x1b0
>  vfs_read+0x1d8/0x2b0
>  ksys_read+0x78/0xe8
>  __arm64_sys_read+0x1c/0x2c
>  invoke_syscall+0x58/0x11c
>  el0_svc_common+0xb4/0xf4
>  do_el0_svc+0x2c/0xb0
>  el0_svc+0x2c/0xa4
>  el0t_64_sync_handler+0x68/0xb4
>  el0t_64_sync+0x1a0/0x1a4
> Code: 93407c00 a8c17bfd f85f8e5e d65f03c0 (d42aa240)
> ---[ end trace 0000000000000000 ]---
> Kernel panic - not syncing: BRK handler: Fatal exception
> 
> Signed-off-by: fengchunguo@126.com <fengchunguo@126.com>

This does not match above :(


> ---
>  drivers/usb/typec/class.c | 3 ++-
>  include/linux/usb/typec.h | 1 +
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 4b3047e..22d99ce 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -2163,7 +2163,8 @@ void typec_set_pwr_opmode(struct typec_port *port,
>  {
>  	struct device *partner_dev;
>  
> -	if (port->pwr_opmode == opmode)
> +	if ((port->pwr_opmode == opmode) || (opmode < TYPEC_PWR_MODE_USB)
> +			|| (opmode > TYPEC_PWR_MODE_MAX))

Please use the proper coding style :(


>  		return;
>  
>  	port->pwr_opmode = opmode;
> diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
> index d616b88..3b12c46 100644
> --- a/include/linux/usb/typec.h
> +++ b/include/linux/usb/typec.h
> @@ -71,6 +71,7 @@ enum typec_pwr_opmode {
>  	TYPEC_PWR_MODE_1_5A,
>  	TYPEC_PWR_MODE_3_0A,
>  	TYPEC_PWR_MODE_PD,
> +	TYPEC_PWR_MODE_MAX,

This is odd, you are saying we are somehow running off the end of the
list of enumerated types?  That means something else went wrong here,
not that we need to have a MAX value in the list.

thanks,

greg k-h

      reply	other threads:[~2025-01-16 10:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16  7:14 [PATCH 1/1] usb: typec: Added power_operation_mode_show type check when usb slowly detect fengchunguo
2025-01-16 10:12 ` Greg KH [this message]

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=2025011634-lurch-goon-d135@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=fengchunguo@126.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).