Re: [PATCH 1/1] usb: typec: Added power_operation_mode_show type check when usb slowly detect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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@xxxxxxx <fengchunguo@xxxxxxx>

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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux