From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B342C11F65 for ; Tue, 29 Jun 2021 01:15:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A40C61042 for ; Tue, 29 Jun 2021 01:15:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232050AbhF2BRb (ORCPT ); Mon, 28 Jun 2021 21:17:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:39088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231947AbhF2BR3 (ORCPT ); Mon, 28 Jun 2021 21:17:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 93A0961941; Tue, 29 Jun 2021 01:15:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624929302; bh=n4Cp/kJo8UIbf0RkqsSQqrsS7eaLfDxC1AkSxNzUXC0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=knvmbPWv/115WR/zQtzlqwUjidaJkxD4BCR5FqekwRBJyM0RTZOMjuGQhPv2BtH0e v7M7aXOdf4VTwKM04T9tm25dzMBOpJ4BIMmJSg4Gfx4zYleYoLOru78EPRGeNheSq9 UUD4thH46R0RNQxgFzV8t0GLS7GZC4CHTbW0hY4hQJv0fom4HozuCK5W2k1XeTLlhl lxpe76kpatNZO2sHaNNpXxU4KFfdlck/UEBMCb9rnsfsXSUp1XaT0Un03xVIrI6rUY GzjqFyvbdnyNDHctc1DOF0Qy2LfRfJaUmNv6JUVkgbPi4r0savkNwH1e/8YjsezeBF QLbAyvwyH8HRw== Date: Tue, 29 Jun 2021 09:14:57 +0800 From: Peter Chen To: Pawel Laszczak Cc: "rogerq@kernel.org" , "a-govindraju@ti.com" , "gregkh@linuxfoundation.org" , "felipe.balbi@linux.intel.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "kishon@ti.com" , Rahul Kumar , Sanket Parmar , "stable@vger.kernel.org" Subject: Re: [PATCH] usb: cdns3: Fixed incorrect gadget state Message-ID: <20210629011457.GA14090@nchen> References: <20210623070247.46151-1-pawell@gli-login.cadence.com> <20210626085655.GA13671@Peter> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21-06-28 03:46:38, Pawel Laszczak wrote: > > > >On 21-06-23 09:02:47, Pawel Laszczak wrote: > >> From: Pawel Laszczak > >> > >> For delayed status phase, the usb_gadget->state was set > >> to USB_STATE_ADDRESS and it has never been updated to > >> USB_STATE_CONFIGURED. > >> Patch updates the gadget state to correct USB_STATE_CONFIGURED. > >> As a result of this bug the controller was not able to enter to > >> Test Mode while using MSC function. > > > >Pawel, would you please describe more about this issue? I remember the cdns3 > >controller at i.mx series SoC could enter test mode by using current > >code. > > The issue occurs only for MSC class. MSC class has delayed status stage, so > after returning from cdns3_req_ep0_set_configuration function called > for Set Configuration driver remains in USB_STATE_ADDRESS. > > In order to enter to test mode driver needs meet the condition included in > cdns3_ep0_feature_handle_device function: > if (state != USB_STATE_CONFIGURED || speed > USB_SPEED_HIGH) > return -EINVAL; > > But it is still in USB_STATE_ADDRESS, because there was delayed status stage. > To fix issue driver state must be updated to USB_STATE_CONFIGURED before > or after finishing status stage. > I am wondering if the cdns3 driver set gadget state as USB_STATE_ADDRESS is correct for delayed status stage, since the composite core has already set it as USB_STATE_CONFIGURED at function set_config. Peter > > > >> > >> Cc: > >> Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver") > >> Signed-off-by: Pawel Laszczak > >> --- > >> drivers/usb/cdns3/cdns3-ep0.c | 1 + > >> 1 file changed, 1 insertion(+) > >> > >> diff --git a/drivers/usb/cdns3/cdns3-ep0.c b/drivers/usb/cdns3/cdns3-ep0.c > >> index 9a17802275d5..ec5bfd8944c3 100644 > >> --- a/drivers/usb/cdns3/cdns3-ep0.c > >> +++ b/drivers/usb/cdns3/cdns3-ep0.c > >> @@ -731,6 +731,7 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep, > >> request->actual = 0; > >> priv_dev->status_completion_no_call = true; > >> priv_dev->pending_status_request = request; > >> + usb_gadget_set_state(&priv_dev->gadget, USB_STATE_CONFIGURED); > >> spin_unlock_irqrestore(&priv_dev->lock, flags); > >> > >> /* > >> -- > >> 2.25.1 > >> > > > -- > > Thanks, > Pawel Laszczak > -- Thanks, Peter Chen