diff mbox series

usb: typec: altmodes/displayport: Fix probe pin assign check

Message ID 20230208205318.131385-1-pmalani@chromium.org (mailing list archive)
State Accepted
Commit 54e5c00a4eb0a4c663445b245f641bbfab142430
Headers show
Series usb: typec: altmodes/displayport: Fix probe pin assign check | expand

Commit Message

Prashant Malani Feb. 8, 2023, 8:53 p.m. UTC
While checking Pin Assignments of the port and partner during probe, we
don't take into account whether the peripheral is a plug or receptacle.

This manifests itself in a mode entry failure on certain docks and
dongles with captive cables. For instance, the Startech.com Type-C to DP
dongle (Model #CDP2DP) advertises its DP VDO as 0x405. This would fail
the Pin Assignment compatibility check, despite it supporting
Pin Assignment C as a UFP.

Update the check to use the correct DP Pin Assign macros that
take the peripheral's receptacle bit into account.

Fixes: c1e5c2f0cb8a ("usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles")
Cc: stable@vger.kernel.org
Reported-by: Diana Zigterman <dzigterman@chromium.org>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
---

I realize this is a bit late in the release cycle, but figured since it
is a fix it might still be considered. Please let me know if it's too
late and I can re-send this after the 6.3-rc1 is released. Thanks!

 drivers/usb/typec/altmodes/displayport.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Heikki Krogerus Feb. 10, 2023, 8:56 a.m. UTC | #1
On Wed, Feb 08, 2023 at 08:53:19PM +0000, Prashant Malani wrote:
> While checking Pin Assignments of the port and partner during probe, we
> don't take into account whether the peripheral is a plug or receptacle.
> 
> This manifests itself in a mode entry failure on certain docks and
> dongles with captive cables. For instance, the Startech.com Type-C to DP
> dongle (Model #CDP2DP) advertises its DP VDO as 0x405. This would fail
> the Pin Assignment compatibility check, despite it supporting
> Pin Assignment C as a UFP.
> 
> Update the check to use the correct DP Pin Assign macros that
> take the peripheral's receptacle bit into account.
> 
> Fixes: c1e5c2f0cb8a ("usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles")
> Cc: stable@vger.kernel.org
> Reported-by: Diana Zigterman <dzigterman@chromium.org>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> 
> I realize this is a bit late in the release cycle, but figured since it
> is a fix it might still be considered. Please let me know if it's too
> late and I can re-send this after the 6.3-rc1 is released. Thanks!
> 
>  drivers/usb/typec/altmodes/displayport.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
> index 20db51471c98..662cd043b50e 100644
> --- a/drivers/usb/typec/altmodes/displayport.c
> +++ b/drivers/usb/typec/altmodes/displayport.c
> @@ -547,10 +547,10 @@ int dp_altmode_probe(struct typec_altmode *alt)
>  	/* FIXME: Port can only be DFP_U. */
>  
>  	/* Make sure we have compatiple pin configurations */
> -	if (!(DP_CAP_DFP_D_PIN_ASSIGN(port->vdo) &
> -	      DP_CAP_UFP_D_PIN_ASSIGN(alt->vdo)) &&
> -	    !(DP_CAP_UFP_D_PIN_ASSIGN(port->vdo) &
> -	      DP_CAP_DFP_D_PIN_ASSIGN(alt->vdo)))
> +	if (!(DP_CAP_PIN_ASSIGN_DFP_D(port->vdo) &
> +	      DP_CAP_PIN_ASSIGN_UFP_D(alt->vdo)) &&
> +	    !(DP_CAP_PIN_ASSIGN_UFP_D(port->vdo) &
> +	      DP_CAP_PIN_ASSIGN_DFP_D(alt->vdo)))
>  		return -ENODEV;
>  
>  	ret = sysfs_create_group(&alt->dev.kobj, &dp_altmode_group);
> -- 
> 2.39.1.519.gcb327c4b5f-goog

thanks,
Martin Kepplinger Feb. 17, 2023, 11:39 a.m. UTC | #2
Am Mittwoch, dem 08.02.2023 um 20:53 +0000 schrieb Prashant Malani:
> While checking Pin Assignments of the port and partner during probe,
> we
> don't take into account whether the peripheral is a plug or
> receptacle.
> 
> This manifests itself in a mode entry failure on certain docks and
> dongles with captive cables. For instance, the Startech.com Type-C to
> DP
> dongle (Model #CDP2DP) advertises its DP VDO as 0x405. This would
> fail
> the Pin Assignment compatibility check, despite it supporting
> Pin Assignment C as a UFP.
> 
> Update the check to use the correct DP Pin Assign macros that
> take the peripheral's receptacle bit into account.
> 
> Fixes: c1e5c2f0cb8a ("usb: typec: altmodes/displayport: correct pin
> assignment for UFP receptacles")
> Cc: stable@vger.kernel.org
> Reported-by: Diana Zigterman <dzigterman@chromium.org>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>
> ---
> 
> I realize this is a bit late in the release cycle, but figured since
> it
> is a fix it might still be considered. Please let me know if it's too
> late and I can re-send this after the 6.3-rc1 is released. Thanks!


on the imx8mq-librem5r4.dts board, when using a typec-hub with HDMI,
this patch breaks image output in one case for me: For a monitor where
negotiation of resolution fails, a lower resolution works though, I now
get an oops and hence an unusable system, see the
dmesg_typec_hub_hdmi_new.txt logs I append. this should definitely not
happen.

with your patch reverted, I get no oops and a perfectly usable system
like before, which is the file dmesg_typec_hub_hdmi_old_ok.txt

could this patch be wrong or at least no universally good for everyone?
it looks like a regression to me.

thanks a lot!

                                  martin
Feb 17 12:04:47.735075 pureos kernel: xhci-hcd xhci-hcd.5.auto: xHCI Host Controller
Feb 17 12:04:47.736354 pureos kernel: xhci-hcd xhci-hcd.5.auto: new USB bus registered, assigned bus number 3
Feb 17 12:04:47.737289 pureos kernel: xhci-hcd xhci-hcd.5.auto: hcc params 0x0220fe6c hci version 0x110 quirks 0x0000000000010010
Feb 17 12:04:47.738185 pureos kernel: xhci-hcd xhci-hcd.5.auto: irq 207, io mem 0x38100000
Feb 17 12:04:47.739157 pureos kernel: xhci-hcd xhci-hcd.5.auto: xHCI Host Controller
Feb 17 12:04:47.741257 pureos kernel: xhci-hcd xhci-hcd.5.auto: new USB bus registered, assigned bus number 4
Feb 17 12:04:47.742436 pureos kernel: xhci-hcd xhci-hcd.5.auto: Host supports USB 3.0 SuperSpeed
Feb 17 12:04:47.746106 pureos kernel: usb usb3: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.02
Feb 17 12:04:47.747407 pureos kernel: usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
Feb 17 12:04:47.748444 pureos kernel: usb usb3: Product: xHCI Host Controller
Feb 17 12:04:47.749241 pureos kernel: usb usb3: Manufacturer: Linux 6.2.0-rc8-librem5-00356-g8e1de125b8d8 xhci-hcd
Feb 17 12:04:47.750054 pureos kernel: usb usb3: SerialNumber: xhci-hcd.5.auto
Feb 17 12:04:47.750902 pureos kernel: hub 3-0:1.0: USB hub found
Feb 17 12:04:47.755076 pureos kernel: hub 3-0:1.0: 1 port detected
Feb 17 12:04:47.756115 pureos kernel: usb usb4: We don't know the algorithms for LPM for this host, disabling LPM.
Feb 17 12:04:47.757087 pureos kernel: usb usb4: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 6.02
Feb 17 12:04:47.758054 pureos kernel: usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
Feb 17 12:04:47.759093 pureos kernel: usb usb4: Product: xHCI Host Controller
Feb 17 12:04:47.760222 pureos kernel: usb usb4: Manufacturer: Linux 6.2.0-rc8-librem5-00356-g8e1de125b8d8 xhci-hcd
Feb 17 12:04:47.761173 pureos kernel: usb usb4: SerialNumber: xhci-hcd.5.auto
Feb 17 12:04:47.762081 pureos kernel: hub 4-0:1.0: USB hub found
Feb 17 12:04:47.763538 pureos kernel: hub 4-0:1.0: 1 port detected
Feb 17 12:04:47.998914 pureos kernel: usb 3-1: new high-speed USB device number 2 using xhci-hcd
Feb 17 12:04:48.159311 pureos kernel: usb 3-1: New USB device found, idVendor=0bda, idProduct=5411, bcdDevice= 1.04
Feb 17 12:04:48.161004 pureos kernel: usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Feb 17 12:04:48.161982 pureos kernel: usb 3-1: Product: 4-Port USB 2.0 Hub
Feb 17 12:04:48.163109 pureos kernel: usb 3-1: Manufacturer: Generic
Feb 17 12:04:48.164507 pureos kernel: usb 3-1: Device is not authorized for usage
Feb 17 12:04:48.210842 pureos kernel: hub 3-1:1.0: USB hub found
Feb 17 12:04:48.212318 pureos kernel: hub 3-1:1.0: 4 ports detected
Feb 17 12:04:48.275117 pureos kernel: usb 3-1: authorized to connect
Feb 17 12:04:48.276476 pureos kernel: usb 4-1: new SuperSpeed USB device number 2 using xhci-hcd
Feb 17 12:04:48.315335 pureos kernel: usb 4-1: New USB device found, idVendor=0bda, idProduct=0411, bcdDevice= 1.04
Feb 17 12:04:48.317183 pureos kernel: usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Feb 17 12:04:48.318017 pureos kernel: usb 4-1: Product: 4-Port USB 3.0 Hub
Feb 17 12:04:48.318757 pureos kernel: usb 4-1: Manufacturer: Generic
Feb 17 12:04:48.319643 pureos kernel: usb 4-1: Device is not authorized for usage
Feb 17 12:04:48.346866 pureos kernel: hub 4-1:1.0: USB hub found
Feb 17 12:04:48.351962 pureos kernel: hub 4-1:1.0: 4 ports detected
Feb 17 12:04:48.352921 pureos kernel: usb 4-1: authorized to connect
Feb 17 12:04:48.650691 pureos kernel: usb 4-1.4: new SuperSpeed USB device number 3 using xhci-hcd
Feb 17 12:04:48.670055 pureos kernel: usb 4-1.4: New USB device found, idVendor=0bda, idProduct=8153, bcdDevice=30.00
Feb 17 12:04:48.671405 pureos kernel: usb 4-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=6
Feb 17 12:04:48.673006 pureos kernel: usb 4-1.4: Product: USB 10/100/1000 LAN
Feb 17 12:04:48.674036 pureos kernel: usb 4-1.4: Manufacturer: Realtek
Feb 17 12:04:48.675465 pureos kernel: usb 4-1.4: SerialNumber: 000001
Feb 17 12:04:48.676344 pureos kernel: usb 4-1.4: Device is not authorized for usage
Feb 17 12:04:48.707011 pureos kernel: usb 4-1.4: authorized to connect
Feb 17 12:04:48.853369 pureos kernel: usb 4-1.4: reset SuperSpeed USB device number 3 using xhci-hcd
Feb 17 12:04:48.887701 pureos kernel: r8152 4-1.4:1.0: Direct firmware load for rtl_nic/rtl8153a-4.fw failed with error -2
Feb 17 12:04:48.888930 pureos kernel: r8152 4-1.4:1.0: unable to load firmware patch rtl_nic/rtl8153a-4.fw (-2)
Feb 17 12:04:48.923476 pureos kernel: r8152 4-1.4:1.0 eth0: v1.12.13
Feb 17 12:04:49.143305 pureos kernel: [drm] hpd irq
Feb 17 12:04:49.146197 pureos kernel: r8152 4-1.4:1.0 enx00e04c684a8a: renamed from eth0
Feb 17 12:04:49.191366 pureos kernel: Unable to handle kernel paging request at virtual address 00574f5000796c70
Feb 17 12:04:49.192065 pureos kernel: Mem abort info:
Feb 17 12:04:49.386708 pureos kernel:   ESR = 0x0000000096000004
Feb 17 12:04:49.387556 pureos kernel:   EC = 0x25: DABT (current EL), IL = 32 bits
Feb 17 12:04:49.387923 pureos kernel:   SET = 0, FnV = 0
Feb 17 12:04:49.572179 pureos kernel:   EA = 0, S1PTW = 0
Feb 17 12:04:49.576717 pureos kernel:   FSC = 0x04: level 0 translation fault
Feb 17 12:04:49.955640 pureos kernel: Data abort info:
Feb 17 12:04:49.971034 pureos kernel:   ISV = 0, ISS = 0x00000004
Feb 17 12:04:49.971915 pureos kernel:   CM = 0, WnR = 0
Feb 17 12:04:49.982458 pureos kernel: [00574f5000796c70] address between user and kernel address ranges
Feb 17 12:04:49.998149 pureos kernel: Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
Feb 17 12:04:50.018039 pureos kernel: Modules linked in: r8153_ecm cdc_ether r8152 aes_ce_ccm redpine_sdio redpine_91x bluetooth mac80211 cfg80211 usb_f_acm qmi_wwan u_serial usb_f_ecm u_ether cdc_wdm caam_jr mousedev caamhash_desc caamalg_desc crypto_engine usbnet mii option usb_wwan usbserial aes_ce_blk crct10dif_ce ghash_ce sha2_ce sha1_ce pwm_vibra snd_soc_gtm601 hantro_vpu snd_soc_simple_card v4l2_vp9 snd_soc_simple_card_utils v4l2_h264 v4l2_mem2mem s5k3l6xx dw9714 st_lsm6dsx_spi st_magn_spi st_sensors_spi imx7_media_csi leds_lm3560 v4l2_flash_led_class hi846 imx8mq_mipi_csi2(C) videobuf2_dma_contig v4l2_fwnode v4l2_async videobuf2_memops videobuf2_v4l2 edt_ft5x06 gnss_mtk videodev st_magn_i2c videobuf2_common gnss_serial gnss st_lsm6dsx_i2c st_magn vcnl4000 st_lsm6dsx st_sensors_i2c st_sensors snd_soc_wm8962 snd_soc_fsl_sai mc industrialio_triggered_buffer snd_soc_fsl_utils caam kfifo_buf imx_pcm_dma error snd_soc_core snd_pcm_dmaengine snd_pcm snd_timer snd imx2_wdt soundcore rfkill_hks watchdog rfkill
Feb 17 12:04:50.021670 pureos kernel:  libcomposite
Feb 17 12:04:50.021877 pureos kernel: [drm] Connector status: 1
Feb 17 12:04:50.022066 pureos kernel:  ledtrig_timer ledtrig_pattern fuse zram ip_tables x_tables ipv6 uas usb_storage mtdblock mtd_blkdevs overlay xhci_plat_hcd xhci_hcd ofpart usbcore spi_nor dwc3 mtd ulpi tps6598x udc_core typec imx_dcss bq25890_charger cdns_mhdp_imx cdns_mhdp_drmcore drm_display_helper clk_bd718x7 phy_fsl_imx8mq_usb usb_common roles snvs_pwrkey imx_sdma virt_dma
Feb 17 12:04:50.022212 pureos kernel: CPU: 1 PID: 2183 Comm: ifquery Tainted: G         C         6.2.0-rc8-librem5-00356-g8e1de125b8d8 #51
Feb 17 12:04:50.022377 pureos kernel: imx-sdma 30bd0000.dma-controller: restart cyclic channel 3
Feb 17 12:04:50.023376 pureos kernel: Hardware name: Purism Librem 5r4 (DT)
Feb 17 12:04:50.023520 pureos kernel: pstate: 80000005 (Nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
Feb 17 12:04:50.023658 pureos kernel: pc : __pi_strlen+0x14/0x150
Feb 17 12:04:50.023812 pureos kernel: lr : rtnl_fill_ifinfo+0xf38/0x126c
Feb 17 12:04:50.023952 pureos kernel: sp : ffff80000c04b5e0
Feb 17 12:04:50.024103 pureos kernel: x29: ffff80000c04b5e0 x28: ffff0000345bd11c x27: ffff0000345bc000
Feb 17 12:04:50.024299 pureos kernel: x26: ffff0000345bc000 x25: 0000000000001434 x24: 0000000000000000
Feb 17 12:04:50.024459 pureos kernel: x23: ffff0000345bd434 x22: ffff0000345bcec0 x21: 45574f5000796c70
Feb 17 12:04:50.026349 pureos kernel: [drm] HDMI/DP Cable Plug In
Feb 17 12:04:50.026525 pureos kernel: 
Feb 17 12:04:50.028066 pureos kernel: x20: ffff00000115e000 x19: ffff00002b657800 x18: 0000000000000000
Feb 17 12:04:50.028222 pureos kernel: x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
Feb 17 12:04:50.028359 pureos kernel: x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000
Feb 17 12:04:50.028498 pureos kernel: x11: 0000000000000000 x10: 0000000000000001 x9 : ffff800008ad95b4
Feb 17 12:04:50.028647 pureos kernel: x8 : 0101010101010101 x7 : 0000000000000000 x6 : 0000000000001ec0
Feb 17 12:04:50.028785 pureos kernel: x5 : ffff0000345bd438 x4 : 0000000000000c70 x3 : ffff0000345bc000
Feb 17 12:04:50.030090 pureos kernel: x2 : 0000000000000ec0 x1 : 0000000000001434 x0 : 45574f5000796c70
Feb 17 12:04:50.030433 pureos kernel: Call trace:
Feb 17 12:04:50.030756 pureos kernel: [drm] Connector status: 1
Feb 17 12:04:50.030940 pureos kernel: imx-sdma 30bd0000.dma-controller: restart cyclic channel 3
Feb 17 12:04:50.031936 pureos kernel:  __pi_strlen+0x14/0x150
Feb 17 12:04:50.032087 pureos kernel: EDID block 0 (tag 0x00) checksum is invalid, remainder is 2
Feb 17 12:04:50.032256 pureos kernel:  rtnl_dump_ifinfo+0x29c/0x670
Feb 17 12:04:50.032394 pureos kernel:  netlink_dump+0x124/0x324
Feb 17 12:04:50.032531 pureos kernel:  netlink_recvmsg+0x1f4/0x3bc
Feb 17 12:04:50.033134 pureos kernel:         [00] BAD  00 ff ff ff ff ff ff 00 05 e3 52 23 0e 03 00 00
Feb 17 12:04:50.033305 pureos kernel:  ____sys_recvmsg+0x1b0/0x24c
Feb 17 12:04:50.034448 pureos kernel:  ___sys_recvmsg+0x84/0xf0
Feb 17 12:04:50.034635 pureos kernel:  __sys_recvmsg+0x6c/0xd0
Feb 17 12:04:50.034773 pureos kernel:  __arm64_sys_recvmsg+0x2c/0x40
Feb 17 12:04:50.035008 pureos kernel:  invoke_syscall+0x50/0x120
Feb 17 12:04:50.035146 pureos kernel:  el0_svc_common.constprop.0+0xd4/0xf4
Feb 17 12:04:50.035285 pureos kernel:  do_el0_svc+0x24/0x30
Feb 17 12:04:50.035421 pureos kernel:  el0_svc+0x2c/0x84
Feb 17 12:04:50.035559 pureos kernel:         [00] BAD  02 16 01 03 80 33 1d 78 2a ee d1 a5 55 48 9b 26
Feb 17 12:04:50.035695 pureos kernel:  el0t_64_sync_handler+0xb8/0xc0
Feb 17 12:04:50.035834 pureos kernel:  el0t_64_sync+0x190/0x194
Feb 17 12:04:50.035959 pureos kernel: Code: 92402c04 b200c3e8 f13fc09f 5400088c (a9400c02) 
Feb 17 12:04:50.036238 pureos kernel: ---[ end trace 0000000000000000 ]---
Feb 17 12:04:50.057868 pureos kernel:         [00] BAD  00 50 54 bf ef 00 d1 c0 b3 00 95 00 81 80 81 40
Feb 17 12:04:50.058155 pureos kernel:         [00] BAD  00 c0 01 01 01 01 02 3a 80 18 71 38 2d 40 58 2c
Feb 17 12:04:50.058292 pureos kernel:         [00] BAD  45 00 fd 1e 11 00 00 1e 00 00 00 fd 00 32 4c 1e
Feb 17 12:04:50.058423 pureos kernel: ------------[ cut here ]------------
Feb 17 12:04:50.058594 pureos kernel:         [00] BAD  53 11 00 0a 20 20 20 20 20 20 00 00 00 fc 00 32
Feb 17 12:04:50.058725 pureos kernel: WARNING: CPU: 1 PID: 0 at net/netlink/af_netlink.c:414 netlink_sock_destruct+0x94/0xc0
Feb 17 12:04:50.058916 pureos kernel: Modules linked in: r8153_ecm cdc_ether r8152 aes_ce_ccm redpine_sdio redpine_91x bluetooth mac80211 cfg80211 usb_f_acm qmi_wwan u_serial usb_f_ecm u_ether cdc_wdm
Feb 17 12:04:50.059068 pureos kernel:         [00] BAD  33 35 32 0a 20 20 20 20 20 20 20 20 00 00 00 ff
Feb 17 12:04:50.059227 pureos kernel:  caam_jr mousedev caamhash_desc caamalg_desc crypto_engine usbnet mii option usb_wwan usbserial aes_ce_blk crct10dif_ce ghash_ce sha2_ce sha1_ce pwm_vibra
Feb 17 12:04:50.059410 pureos kernel:         [00] BAD  00 44 41 4a 43 31 4a 41 30 30 30 37 38 32 01 6f
Feb 17 12:04:50.059540 pureos kernel:  snd_soc_gtm601 hantro_vpu snd_soc_simple_card v4l2_vp9 snd_soc_simple_card_utils
Feb 17 12:04:50.059677 pureos kernel: [drm:cdns_dp_connector_get_modes [cdns_mhdp_drmcore]] *ERROR* Invalid edid
Feb 17 12:04:50.059847 pureos kernel:  v4l2_h264 v4l2_mem2mem s5k3l6xx dw9714 st_lsm6dsx_spi st_magn_spi st_sensors_spi imx7_media_csi leds_lm3560 v4l2_flash_led_class hi846 imx8mq_mipi_csi2(C) videobuf2_dma_contig v4l2_fwnode v4l2_async videobuf2_memops videobuf2_v4l2 edt_ft5x06 gnss_mtk videodev st_magn_i2c videobuf2_common gnss_serial gnss st_lsm6dsx_i2c st_magn vcnl4000 st_lsm6dsx st_sensors_i2c st_sensors snd_soc_wm8962 snd_soc_fsl_sai mc industrialio_triggered_buffer snd_soc_fsl_utils caam kfifo_buf imx_pcm_dma error snd_soc_core snd_pcm_dmaengine snd_pcm snd_timer snd imx2_wdt soundcore rfkill_hks watchdog rfkill libcomposite ledtrig_timer ledtrig_pattern fuse zram ip_tables x_tables ipv6 uas usb_storage mtdblock mtd_blkdevs overlay xhci_plat_hcd xhci_hcd ofpart usbcore spi_nor dwc3 mtd ulpi tps6598x udc_core typec imx_dcss bq25890_charger cdns_mhdp_imx cdns_mhdp_drmcore drm_display_helper clk_bd718x7 phy_fsl_imx8mq_usb usb_common roles snvs_pwrkey imx_sdma virt_dma
Feb 17 12:04:50.060067 pureos kernel: CPU: 1 PID: 0 Comm: swapper/1 Tainted: G      D  C         6.2.0-rc8-librem5-00356-g8e1de125b8d8 #51
Feb 17 12:04:50.060212 pureos kernel: Hardware name: Purism Librem 5r4 (DT)
Feb 17 12:04:50.060350 pureos kernel: pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
Feb 17 12:04:50.060486 pureos kernel: pc : netlink_sock_destruct+0x94/0xc0
Feb 17 12:04:50.060646 pureos kernel: lr : netlink_sock_destruct+0x50/0xc0
Feb 17 12:04:50.060820 pureos kernel: sp : ffff80000800bdf0
Feb 17 12:04:50.060969 pureos kernel: x29: ffff80000800bdf0 x28: 0000000000000000 x27: 000000000000000a
Feb 17 12:04:50.061109 pureos kernel: x26: ffff0000be64c178 x25: 0000000000000001 x24: ffff80000800bf20
Feb 17 12:04:50.061261 pureos kernel: x23: ffff800009288008 x22: ffff8000096189e0 x21: ffff0000be64c100
Feb 17 12:04:50.061398 pureos kernel: x20: ffff00003459a2e0 x19: ffff00003459a000 x18: 0000000000000000
Feb 17 12:04:50.061531 pureos kernel: x17: 0000000000000579 x16: 0000000000000000 x15: 0000000000000000
Feb 17 12:04:50.061689 pureos kernel: x14: 0000000000000000 x13: 0000000000000001 x12: 0000000000000003
Feb 17 12:04:50.061851 pureos kernel: x11: 0000000000000002 x10: 0000000000000075 x9 : ffff800008a9a27c
Feb 17 12:04:50.062020 pureos kernel: x8 : fffffc0001af4dc8 x7 : 0000000000000000 x6 : ffff00003459a154
Feb 17 12:04:50.062155 pureos kernel: x5 : 0000000000000001 x4 : 0000000000000000 x3 : ffff00003459a0ec
Feb 17 12:04:50.062301 pureos kernel: x2 : 0000000000000000 x1 : ffff000000300e40 x0 : 0000000000002100
Feb 17 12:04:50.062448 pureos kernel: Call trace:
Feb 17 12:04:50.062580 pureos kernel:  netlink_sock_destruct+0x94/0xc0
Feb 17 12:04:50.062714 pureos kernel:  __sk_destruct+0x34/0x27c
Feb 17 12:04:50.064304 pureos kernel:  __sk_free+0xd0/0x170
Feb 17 12:04:50.064451 pureos kernel:  sk_free+0x6c/0x90
Feb 17 12:04:50.064588 pureos kernel:  deferred_put_nlk_sk+0x78/0x100
Feb 17 12:04:50.064762 pureos kernel:  rcu_core+0x274/0xa60
Feb 17 12:04:50.064924 pureos kernel:  rcu_core_si+0x18/0x2c
Feb 17 12:04:50.065087 pureos kernel:  __do_softirq+0x120/0x3c0
Feb 17 12:04:50.065223 pureos kernel:  ____do_softirq+0x18/0x24
Feb 17 12:04:50.065360 pureos kernel:  call_on_irq_stack+0x2c/0x54
Feb 17 12:04:50.065495 pureos kernel:  do_softirq_own_stack+0x24/0x3c
Feb 17 12:04:50.065648 pureos kernel:  __irq_exit_rcu+0xb8/0xe0
Feb 17 12:04:50.065776 pureos kernel:  irq_exit_rcu+0x18/0x24
Feb 17 12:04:50.065909 pureos kernel:  el1_interrupt+0x38/0x70
Feb 17 12:04:50.066044 pureos kernel:  el1h_64_irq_handler+0x18/0x2c
Feb 17 12:04:50.066194 pureos kernel:  el1h_64_irq+0x64/0x68
Feb 17 12:04:50.066345 pureos kernel:  cpuidle_enter_state+0xbc/0x4b0
Feb 17 12:04:50.066506 pureos kernel:  cpuidle_enter+0x40/0x60
Feb 17 12:04:50.066632 pureos kernel:  do_idle+0x234/0x2c0
Feb 17 12:04:50.066783 pureos kernel:  cpu_startup_entry+0x2c/0x3c
Feb 17 12:04:50.068538 pureos kernel:  secondary_start_kernel+0x124/0x14c
Feb 17 12:04:50.069499 pureos kernel:  __secondary_switched+0xb0/0xb4
Feb 17 12:04:50.069641 pureos kernel: ---[ end trace 0000000000000000 ]---
Feb 17 12:04:50.069757 pureos kernel: [drm] Mode: 640x480p25175
Feb 17 12:04:50.174832 pureos kernel: cdns-mhdp-imx 32c00000.hdmi: [drm:cdns_mhdp_set_host_cap [cdns_mhdp_drmcore]] Using 2 lanes
Feb 17 12:04:50.229474 pureos kernel: imx-dcss 32e00000.display-controller: Pixel clock set to 25174 kHz instead of 25175 kHz.
Feb 17 12:04:50.230573 pureos kernel: cdns-mhdp-imx 32c00000.hdmi: [drm:cdns_mhdp_train_link [cdns_mhdp_drmcore]] Starting link training
Feb 17 12:35:03.758985 pureos kernel: xhci-hcd xhci-hcd.5.auto: xHCI Host Controller
Feb 17 12:35:03.761419 pureos kernel: xhci-hcd xhci-hcd.5.auto: new USB bus registered, assigned bus number 3
Feb 17 12:35:03.770536 pureos kernel: xhci-hcd xhci-hcd.5.auto: hcc params 0x0220fe6c hci version 0x110 quirks 0x0000000000010010
Feb 17 12:35:03.771663 pureos kernel: xhci-hcd xhci-hcd.5.auto: irq 207, io mem 0x38100000
Feb 17 12:35:03.772570 pureos kernel: xhci-hcd xhci-hcd.5.auto: xHCI Host Controller
Feb 17 12:35:03.774135 pureos kernel: xhci-hcd xhci-hcd.5.auto: new USB bus registered, assigned bus number 4
Feb 17 12:35:03.775103 pureos kernel: xhci-hcd xhci-hcd.5.auto: Host supports USB 3.0 SuperSpeed
Feb 17 12:35:03.777774 pureos kernel: usb usb3: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.02
Feb 17 12:35:03.778658 pureos kernel: usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
Feb 17 12:35:03.779735 pureos kernel: usb usb3: Product: xHCI Host Controller
Feb 17 12:35:03.780542 pureos kernel: usb usb3: Manufacturer: Linux 6.2.0-rc8-librem5-00355-gcf53b626499e xhci-hcd
Feb 17 12:35:03.781318 pureos kernel: usb usb3: SerialNumber: xhci-hcd.5.auto
Feb 17 12:35:03.782108 pureos kernel: hub 3-0:1.0: USB hub found
Feb 17 12:35:03.783243 pureos kernel: hub 3-0:1.0: 1 port detected
Feb 17 12:35:03.784186 pureos kernel: usb usb4: We don't know the algorithms for LPM for this host, disabling LPM.
Feb 17 12:35:03.785300 pureos kernel: usb usb4: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 6.02
Feb 17 12:35:03.786346 pureos kernel: usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
Feb 17 12:35:03.787456 pureos kernel: usb usb4: Product: xHCI Host Controller
Feb 17 12:35:03.788322 pureos kernel: usb usb4: Manufacturer: Linux 6.2.0-rc8-librem5-00355-gcf53b626499e xhci-hcd
Feb 17 12:35:03.789211 pureos kernel: usb usb4: SerialNumber: xhci-hcd.5.auto
Feb 17 12:35:03.790059 pureos kernel: hub 4-0:1.0: USB hub found
Feb 17 12:35:03.791181 pureos kernel: hub 4-0:1.0: 1 port detected
Feb 17 12:35:04.014868 pureos kernel: usb 3-1: new high-speed USB device number 2 using xhci-hcd
Feb 17 12:35:04.175621 pureos kernel: usb 3-1: New USB device found, idVendor=0bda, idProduct=5411, bcdDevice= 1.04
Feb 17 12:35:04.177524 pureos kernel: usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Feb 17 12:35:04.178520 pureos kernel: usb 3-1: Product: 4-Port USB 2.0 Hub
Feb 17 12:35:04.179581 pureos kernel: usb 3-1: Manufacturer: Generic
Feb 17 12:35:04.180491 pureos kernel: usb 3-1: Device is not authorized for usage
Feb 17 12:35:04.240010 pureos kernel: hub 3-1:1.0: USB hub found
Feb 17 12:35:04.241196 pureos kernel: hub 3-1:1.0: 4 ports detected
Feb 17 12:35:04.303622 pureos kernel: usb 4-1: new SuperSpeed USB device number 2 using xhci-hcd
Feb 17 12:35:04.303933 pureos kernel: usb 3-1: authorized to connect
Feb 17 12:35:04.334682 pureos kernel: usb 4-1: New USB device found, idVendor=0bda, idProduct=0411, bcdDevice= 1.04
Feb 17 12:35:04.336652 pureos kernel: usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Feb 17 12:35:04.337943 pureos kernel: usb 4-1: Product: 4-Port USB 3.0 Hub
Feb 17 12:35:04.338786 pureos kernel: usb 4-1: Manufacturer: Generic
Feb 17 12:35:04.339655 pureos kernel: usb 4-1: Device is not authorized for usage
Feb 17 12:35:04.374902 pureos kernel: hub 4-1:1.0: USB hub found
Feb 17 12:35:04.376219 pureos kernel: hub 4-1:1.0: 4 ports detected
Feb 17 12:35:04.382941 pureos kernel: usb 4-1: authorized to connect
Feb 17 12:35:04.675414 pureos kernel: usb 4-1.4: new SuperSpeed USB device number 3 using xhci-hcd
Feb 17 12:35:04.702159 pureos kernel: usb 4-1.4: New USB device found, idVendor=0bda, idProduct=8153, bcdDevice=30.00
Feb 17 12:35:04.703904 pureos kernel: usb 4-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=6
Feb 17 12:35:04.704976 pureos kernel: usb 4-1.4: Product: USB 10/100/1000 LAN
Feb 17 12:35:04.707255 pureos kernel: usb 4-1.4: Manufacturer: Realtek
Feb 17 12:35:04.708483 pureos kernel: usb 4-1.4: SerialNumber: 000001
Feb 17 12:35:04.709443 pureos kernel: usb 4-1.4: Device is not authorized for usage
Feb 17 12:35:04.735066 pureos kernel: usb 4-1.4: authorized to connect
Feb 17 12:35:04.830572 pureos kernel: usbcore: registered new interface driver r8152
Feb 17 12:35:04.830780 pureos kernel: usbcore: registered new interface driver cdc_ether
Feb 17 12:35:04.837604 pureos kernel: usbcore: registered new interface driver r8153_ecm
Feb 17 12:35:04.942887 pureos kernel: usb 4-1.4: reset SuperSpeed USB device number 3 using xhci-hcd
Feb 17 12:35:04.978883 pureos kernel: r8152 4-1.4:1.0: Direct firmware load for rtl_nic/rtl8153a-4.fw failed with error -2
Feb 17 12:35:04.980133 pureos kernel: r8152 4-1.4:1.0: unable to load firmware patch rtl_nic/rtl8153a-4.fw (-2)
Feb 17 12:35:05.032823 pureos kernel: r8152 4-1.4:1.0 eth0: v1.12.13
Feb 17 12:35:05.095124 pureos kernel: [drm] hpd irq
Feb 17 12:35:05.095532 pureos kernel: r8152 4-1.4:1.0 enx00e04c684a8a: renamed from eth0
Feb 17 12:35:05.284654 pureos kernel: [drm] Connector status: 1
Feb 17 12:35:05.367934 pureos kernel: [drm] Connector status: 1
Feb 17 12:35:05.368357 pureos kernel: EDID block 0 (tag 0x00) checksum is invalid, remainder is 2
Feb 17 12:35:05.368518 pureos kernel:         [00] BAD  00 ff ff ff ff ff ff 00 05 e3 52 23 0e 03 00 00
Feb 17 12:35:05.368640 pureos kernel:         [00] BAD  02 16 01 03 80 33 1d 78 2a ee d1 a5 55 48 9b 26
Feb 17 12:35:05.368761 pureos kernel:         [00] BAD  00 50 54 bf ef 00 d1 c0 b3 00 95 00 81 80 81 40
Feb 17 12:35:05.368856 pureos kernel:         [00] BAD  00 c0 01 01 01 01 02 3a 80 18 71 38 2d 40 58 2c
Feb 17 12:35:05.368974 pureos kernel:         [00] BAD  45 00 fd 1e 11 00 00 1e 00 00 00 fd 00 32 4c 1e
Feb 17 12:35:05.369082 pureos kernel:         [00] BAD  53 11 00 0a 20 20 20 20 20 20 00 00 00 fc 00 32
Feb 17 12:35:05.369212 pureos kernel:         [00] BAD  33 35 32 0a 20 20 20 20 20 20 20 20 00 00 00 ff
Feb 17 12:35:05.369319 pureos kernel:         [00] BAD  00 44 41 4a 43 31 4a 41 30 30 30 37 38 32 01 6f
Feb 17 12:35:05.369413 pureos kernel: [drm:cdns_dp_connector_get_modes [cdns_mhdp_drmcore]] *ERROR* Invalid edid
Feb 17 12:35:05.375044 pureos kernel: [drm] Connector status: 1
Feb 17 12:35:05.375444 pureos kernel: imx-dcss 32e00000.display-controller: [drm] fb1: imx-dcssdrmfb frame buffer device
Feb 17 12:35:05.376593 pureos kernel: [drm] HDMI/DP Cable Plug In
Feb 17 12:35:05.456249 pureos kernel: EDID block 0 (tag 0x00) checksum is invalid, remainder is 2
Feb 17 12:35:05.456474 pureos kernel: [drm:cdns_dp_connector_get_modes [cdns_mhdp_drmcore]] *ERROR* Invalid edid
Feb 17 12:35:05.474913 pureos kernel: [drm] Mode: 640x480p25175
Feb 17 12:35:05.638931 pureos kernel: cdns-mhdp-imx 32c00000.hdmi: [drm:cdns_mhdp_set_host_cap [cdns_mhdp_drmcore]] Using 2 lanes
Feb 17 12:35:05.679378 pureos kernel: imx-dcss 32e00000.display-controller: Pixel clock set to 25174 kHz instead of 25175 kHz.
Feb 17 12:35:05.680537 pureos kernel: cdns-mhdp-imx 32c00000.hdmi: [drm:cdns_mhdp_train_link [cdns_mhdp_drmcore]] Starting link training
Feb 17 12:35:17.840906 pureos kernel: [drm] hpd irq
Feb 17 12:35:17.841132 pureos kernel: usb 4-1: USB disconnect, device number 2
Feb 17 12:35:17.843586 pureos kernel: usb 4-1.4: USB disconnect, device number 3
Feb 17 12:35:17.855078 pureos kernel: r8152 4-1.4:1.0 enx00e04c684a8a: Stop submitting intr, status -108
Feb 17 12:35:17.856150 pureos kernel: xhci-hcd xhci-hcd.5.auto: remove, state 1
Feb 17 12:35:17.857458 pureos kernel: usb usb4: USB disconnect, device number 1
Feb 17 12:35:17.874300 pureos kernel: tps6598x 0-003f: The interrupt is masked , how did it fire ?? 380100a
Feb 17 12:35:17.931334 pureos kernel: usb 3-1: USB disconnect, device number 2
Feb 17 12:35:17.937534 pureos kernel: xhci-hcd xhci-hcd.5.auto: USB bus 4 deregistered
Feb 17 12:35:17.937987 pureos kernel: xhci-hcd xhci-hcd.5.auto: remove, state 1
Feb 17 12:35:17.938199 pureos kernel: usb usb3: USB disconnect, device number 1
Feb 17 12:35:17.970925 pureos kernel: xhci-hcd xhci-hcd.5.auto: USB bus 3 deregistered
Feb 17 12:35:18.042906 pureos kernel: [drm] Connector status: 0
Feb 17 12:35:18.043197 pureos kernel: [drm] HDMI/DP Cable Plug Out
Feb 17 12:35:18.086615 pureos kernel: [drm] Connector status: 0
Prashant Malani Feb. 17, 2023, 5:31 p.m. UTC | #3
On Fri, Feb 17, 2023 at 3:39 AM Martin Kepplinger
<martin.kepplinger@puri.sm> wrote:
>
> Am Mittwoch, dem 08.02.2023 um 20:53 +0000 schrieb Prashant Malani:
> > While checking Pin Assignments of the port and partner during probe,
> > we
> > don't take into account whether the peripheral is a plug or
> > receptacle.
> >
> > This manifests itself in a mode entry failure on certain docks and
> > dongles with captive cables. For instance, the Startech.com Type-C to
> > DP
> > dongle (Model #CDP2DP) advertises its DP VDO as 0x405. This would
> > fail
> > the Pin Assignment compatibility check, despite it supporting
> > Pin Assignment C as a UFP.
> >
> > Update the check to use the correct DP Pin Assign macros that
> > take the peripheral's receptacle bit into account.
> >
> > Fixes: c1e5c2f0cb8a ("usb: typec: altmodes/displayport: correct pin
> > assignment for UFP receptacles")
> > Cc: stable@vger.kernel.org
> > Reported-by: Diana Zigterman <dzigterman@chromium.org>
> > Signed-off-by: Prashant Malani <pmalani@chromium.org>
> > ---
> >
> > I realize this is a bit late in the release cycle, but figured since
> > it
> > is a fix it might still be considered. Please let me know if it's too
> > late and I can re-send this after the 6.3-rc1 is released. Thanks!
>
>
> on the imx8mq-librem5r4.dts board, when using a typec-hub with HDMI,
> this patch breaks image output in one case for me: For a monitor where
> negotiation of resolution fails, a lower resolution works though, I now
> get an oops and hence an unusable system, see the
> dmesg_typec_hub_hdmi_new.txt logs I append. this should definitely not
> happen.

I'll let others comment here too, but more information is required here:
- What's the DP VDO being exported by the Hub?
- What DPConfigure VDM is being sent now (and what was being sent earlier) ?
- Which version of the kernel are you using?
- Can you point to where in the upstream kernel this board file is present?

>
> with your patch reverted, I get no oops and a perfectly usable system
> like before, which is the file dmesg_typec_hub_hdmi_old_ok.txt
>
> could this patch be wrong or at least no universally good for everyone?
> it looks like a regression to me.

I don't think this patch is the cause of the regression you are seeing.

I don't know about the 2nd part, but for the first part, it was
definitely not right
earlier; Pin compatibility checks need to take into account whether the
UFP is a receptacle or not. The stack trace you have shared does not
seem related to PD/Type-C or DRM.

Perhaps this change is uncovering a previously hidden bug on this board.
I'm not sure how this patch causes the failure you see; the patch alters
the conditions for a probe to succeed: either the HUB you are using will
pass this check (in which case you will get DP working) or it won't (in which
case DP should not work at all). Whatever happens after that depends
on the display driver.

BR,
Martin Kepplinger Feb. 20, 2023, 10:39 a.m. UTC | #4
Am Freitag, dem 17.02.2023 um 09:31 -0800 schrieb Prashant Malani:
> On Fri, Feb 17, 2023 at 3:39 AM Martin Kepplinger
> <martin.kepplinger@puri.sm> wrote:
> > 
> > Am Mittwoch, dem 08.02.2023 um 20:53 +0000 schrieb Prashant Malani:
> > > While checking Pin Assignments of the port and partner during
> > > probe,
> > > we
> > > don't take into account whether the peripheral is a plug or
> > > receptacle.
> > > 
> > > This manifests itself in a mode entry failure on certain docks
> > > and
> > > dongles with captive cables. For instance, the Startech.com Type-
> > > C to
> > > DP
> > > dongle (Model #CDP2DP) advertises its DP VDO as 0x405. This would
> > > fail
> > > the Pin Assignment compatibility check, despite it supporting
> > > Pin Assignment C as a UFP.
> > > 
> > > Update the check to use the correct DP Pin Assign macros that
> > > take the peripheral's receptacle bit into account.
> > > 
> > > Fixes: c1e5c2f0cb8a ("usb: typec: altmodes/displayport: correct
> > > pin
> > > assignment for UFP receptacles")
> > > Cc: stable@vger.kernel.org
> > > Reported-by: Diana Zigterman <dzigterman@chromium.org>
> > > Signed-off-by: Prashant Malani <pmalani@chromium.org>
> > > ---
> > > 
> > > I realize this is a bit late in the release cycle, but figured
> > > since
> > > it
> > > is a fix it might still be considered. Please let me know if it's
> > > too
> > > late and I can re-send this after the 6.3-rc1 is released.
> > > Thanks!
> > 
> > 
> > on the imx8mq-librem5r4.dts board, when using a typec-hub with
> > HDMI,
> > this patch breaks image output in one case for me: For a monitor
> > where
> > negotiation of resolution fails, a lower resolution works though, I
> > now
> > get an oops and hence an unusable system, see the
> > dmesg_typec_hub_hdmi_new.txt logs I append. this should definitely
> > not
> > happen.
> 
> I'll let others comment here too, but more information is required
> here:
> - What's the DP VDO being exported by the Hub?
> - What DPConfigure VDM is being sent now (and what was being sent
> earlier) ?
> - Which version of the kernel are you using?
> - Can you point to where in the upstream kernel this board file is
> present?
> 
> > 
> > with your patch reverted, I get no oops and a perfectly usable
> > system
> > like before, which is the file dmesg_typec_hub_hdmi_old_ok.txt
> > 
> > could this patch be wrong or at least no universally good for
> > everyone?
> > it looks like a regression to me.
> 
> I don't think this patch is the cause of the regression you are
> seeing.
> 
> I don't know about the 2nd part, but for the first part, it was
> definitely not right
> earlier; Pin compatibility checks need to take into account whether
> the
> UFP is a receptacle or not. The stack trace you have shared does not
> seem related to PD/Type-C or DRM.
> 
> Perhaps this change is uncovering a previously hidden bug on this
> board.
> I'm not sure how this patch causes the failure you see; the patch
> alters
> the conditions for a probe to succeed: either the HUB you are using
> will
> pass this check (in which case you will get DP working) or it won't
> (in which
> case DP should not work at all). Whatever happens after that depends
> on the display driver.
> 
> BR,


thanks for the quick reply. I think you are right, my report was wrong
and your patch was not the cause of the bug. I was able to reproduce it
without hdmi plugged in. Also, the issue is fixed again in v6.2.

thank you very much and sorry for the false alarm,

                              martin
diff mbox series

Patch

diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
index 20db51471c98..662cd043b50e 100644
--- a/drivers/usb/typec/altmodes/displayport.c
+++ b/drivers/usb/typec/altmodes/displayport.c
@@ -547,10 +547,10 @@  int dp_altmode_probe(struct typec_altmode *alt)
 	/* FIXME: Port can only be DFP_U. */
 
 	/* Make sure we have compatiple pin configurations */
-	if (!(DP_CAP_DFP_D_PIN_ASSIGN(port->vdo) &
-	      DP_CAP_UFP_D_PIN_ASSIGN(alt->vdo)) &&
-	    !(DP_CAP_UFP_D_PIN_ASSIGN(port->vdo) &
-	      DP_CAP_DFP_D_PIN_ASSIGN(alt->vdo)))
+	if (!(DP_CAP_PIN_ASSIGN_DFP_D(port->vdo) &
+	      DP_CAP_PIN_ASSIGN_UFP_D(alt->vdo)) &&
+	    !(DP_CAP_PIN_ASSIGN_UFP_D(port->vdo) &
+	      DP_CAP_PIN_ASSIGN_DFP_D(alt->vdo)))
 		return -ENODEV;
 
 	ret = sysfs_create_group(&alt->dev.kobj, &dp_altmode_group);