From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752201AbbKPUid (ORCPT ); Mon, 16 Nov 2015 15:38:33 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:39604 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751543AbbKPUia (ORCPT ); Mon, 16 Nov 2015 15:38:30 -0500 Date: Mon, 16 Nov 2015 15:38:29 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Julius Werner cc: Doug Anderson , Felipe Balbi , John Youn , Yunzhi Li , =?UTF-8?Q?Heiko_St=C3=BCbner?= , "open list:ARM/Rockchip SoC..." , "Herrero, Gregory" , "Kaukab, Yousaf" , Dinh Nguyen , John Youn , Greg Kroah-Hartman , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 1/2] usb: dwc2: host: Fix missing device insertions In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Nov 2015, Julius Werner wrote: > Another point to note, which I think is what prevents the flow Alan > suggested from working, is this little snippet in DWC2's hub_control > GetPortStatus callback: > > if (!hsotg->flags.b.port_connect_status) { > /* > * The port is disconnected, which means the core is > * either in device mode or it soon will be. > Just > * return 0's for the remainder of the port status > * since the port register can't be read if the core > * is in device mode. > */ > *(__le32 *)buf = cpu_to_le32(port_status); > break; > } > > This is before it actually checks the register state of the port. So > it relies on dwc2_hcd_connect() and dwc2_hcd_disconnect() to be called > in the right order to give the correct answer for > USB_PORT_STAT_CONNECTION. This could maybe be improved but I don't > know what kind of weird interactions with device mode operation made > that snippet necessary in the first place. Why does this test hsotg->flags.b.port_connect_status? What it really needs to know is whether the core is in device mode. It should test for that instead. Then it could accurately report the true connection state whenever the core is in host mode, regardless of the order in which dwc2_hcd_connect() and dwc2_hcd_disconnect() get called. No? My guess would be that using the wrong test was simply a misguided attempt at optimization. Alan Stern From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Stern Subject: Re: [PATCH v2 1/2] usb: dwc2: host: Fix missing device insertions Date: Mon, 16 Nov 2015 15:38:29 -0500 (EST) Message-ID: References: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Return-path: In-Reply-To: Sender: linux-usb-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Julius Werner Cc: Doug Anderson , Felipe Balbi , John Youn , Yunzhi Li , =?UTF-8?Q?Heiko_St=C3=BCbner?= , "open list:ARM/Rockchip SoC..." , "Herrero, Gregory" , "Kaukab, Yousaf" , Dinh Nguyen , John Youn , Greg Kroah-Hartman , "linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" List-Id: linux-rockchip.vger.kernel.org On Mon, 16 Nov 2015, Julius Werner wrote: > Another point to note, which I think is what prevents the flow Alan > suggested from working, is this little snippet in DWC2's hub_control > GetPortStatus callback: > > if (!hsotg->flags.b.port_connect_status) { > /* > * The port is disconnected, which means the core is > * either in device mode or it soon will be. > Just > * return 0's for the remainder of the port status > * since the port register can't be read if the core > * is in device mode. > */ > *(__le32 *)buf = cpu_to_le32(port_status); > break; > } > > This is before it actually checks the register state of the port. So > it relies on dwc2_hcd_connect() and dwc2_hcd_disconnect() to be called > in the right order to give the correct answer for > USB_PORT_STAT_CONNECTION. This could maybe be improved but I don't > know what kind of weird interactions with device mode operation made > that snippet necessary in the first place. Why does this test hsotg->flags.b.port_connect_status? What it really needs to know is whether the core is in device mode. It should test for that instead. Then it could accurately report the true connection state whenever the core is in host mode, regardless of the order in which dwc2_hcd_connect() and dwc2_hcd_disconnect() get called. No? My guess would be that using the wrong test was simply a misguided attempt at optimization. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html