Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1627749pxf; Fri, 2 Apr 2021 16:58:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6SN7U+eaJoGyUyAwTb0cTgFT32Gv2dA6ymLal45wk7F14OZO0LnwdgKD6J35x/WPy4fbV X-Received: by 2002:aa7:cb97:: with SMTP id r23mr17845193edt.106.1617407900029; Fri, 02 Apr 2021 16:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617407900; cv=none; d=google.com; s=arc-20160816; b=c5OHEoyx1DeSoZL38OYDY6SNDbXkAYcEAHB1ajA8o06sChBZCx9/akzw8w3F1bU2+O g6QnCg8MdOgT02v7dmGfmwPQmatGVuY3K0KLxtHmaFmyBL2nqdsTWJOa+QyQC4jLmHgP w/wjVSJI8W/9yoWAfug8DqM1mbI1txUjcTehoNGJyTGJNrK/g7r1iDLls+Xok2vjgquZ y9PRlWHzhnz8WqA+C0EbOQ4z+iguMSYh4+FlQbnYzAK99Li3MI4io+4pu188zePKSQOO KrNVurjUZhlPSIEg9UYmXNDH3GchNNTgGZZ155fVl5zMF2TCy3OgjLLIVFuKI7LeocIq uS4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=3ci7pn3C/4dONxPhcFSXRn9G6xSbut+Mask9h7WK0qg=; b=lwXWYydq51ciYbvzAQDG83amsls6OrLlelZ7kmn92oR2JWwYKC7iccRbC0NKesfKHH J2ByV+/rCu8rkcAdrwfOX+Jngh8MvbeujduPr3uIRV6Tjvs5F3ImoFYztTi6aERqkOJC U1XG5VH7qzAsDLrE6yuraVM1OiHEhDYeOMvP2KbyTxklzamxdqwJ4XD09UeF2PYi+BUb TbPhIrBWwg+TybapspZWCUcp9NFvoCKcwyRqQmpWnJeBzeJJi4zSF3VUAaEWmFaXQmpy J11n5a6h+jlB5q5rytBjLtIdBy+tl/MB+AXj0GsjWEJkW72GrxCwNa8PGFBZAXTgDp4L S6lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WKiGXyeO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h16si8042990edv.460.2021.04.02.16.57.56; Fri, 02 Apr 2021 16:58:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WKiGXyeO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235523AbhDBX5d (ORCPT + 99 others); Fri, 2 Apr 2021 19:57:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:36234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234161AbhDBX5c (ORCPT ); Fri, 2 Apr 2021 19:57:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A1DA261183; Fri, 2 Apr 2021 23:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617407850; bh=Vata6kCLaiE5bqC5WOTxOeiahZrrC6iTh6sipAmOB3o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WKiGXyeOdKcitF4x6ZWyOWSLIrHel9JYuiRiKNFOVZYfjFBwu9PC4Hc6tdwONpJ29 g7g03r57n9r+6pIqV4icy/DhklsAultjoSOk8IU5+nHwiOaUvBdGYsSOB7g1gXdHfB XzhhomZXaV54XdY55iUalPKGi0sNMOVg10d2FJ9IulfQWnemo87heBi9/ZqinDrXwm wglZPCdb6rJndDpmDlzIKbCMqyZhbYFNj/9YLPeSs1bUVoHOasDLAcdYhr8W2z29K4 zbpUbXxSKcv22zXXjYUi4il+dNxJgNlB1gs7FUe4cVBho758p+sXkA+tWjn+q5qPfJ RKNwFx5sB+Bfw== Date: Sat, 3 Apr 2021 07:57:26 +0800 From: Peter Chen To: Pawel Laszczak Cc: "gregkh@linuxfoundation.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Rahul Kumar Subject: Re: [PATCH] usb: cdnsp: Fixes issue with Configure Endpoint command Message-ID: <20210402235726.GA18389@b29397-desktop> References: <20210322060902.11197-1-pawell@gli-login.cadence.com> <20210327005417.GB28870@b29397-desktop> 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-03-30 04:26:10, Pawel Laszczak wrote: > Hi Peter, > > > > >On 21-03-22 07:09:02, Pawel Laszczak wrote: > >> From: Pawel Laszczak > >> > >> Patch adds flag EP_UNCONFIGURED to detect whether endpoint was > >> unconfigured. This flag is set in cdnsp_reset_device after Reset Device > >> command. Among others this command disables all non control endpoints. > >> Flag is used in cdnsp_gadget_ep_disable to protect controller against > >> invoking Configure Endpoint command on disabled endpoint. Lack of this > >> protection in some cases caused that Configure Endpoint command completed > >> with Context State Error code completion. > >> > >> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver") > >> Signed-off-by: Pawel Laszczak > >> --- > >> drivers/usb/cdns3/cdnsp-gadget.c | 18 +++++++++++++----- > >> drivers/usb/cdns3/cdnsp-gadget.h | 11 ++++++----- > >> 2 files changed, 19 insertions(+), 10 deletions(-) > >> > >> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c > >> index d7d4bdd57f46..de17cc4ad91a 100644 > >> --- a/drivers/usb/cdns3/cdnsp-gadget.c > >> +++ b/drivers/usb/cdns3/cdnsp-gadget.c > >> @@ -727,7 +727,7 @@ int cdnsp_reset_device(struct cdnsp_device *pdev) > >> * are in Disabled state. > >> */ > >> for (i = 1; i < CDNSP_ENDPOINTS_NUM; ++i) > >> - pdev->eps[i].ep_state |= EP_STOPPED; > >> + pdev->eps[i].ep_state |= EP_STOPPED | EP_UNCONFIGURED; > >> > >> trace_cdnsp_handle_cmd_reset_dev(slot_ctx); > >> > >> @@ -942,6 +942,7 @@ static int cdnsp_gadget_ep_enable(struct usb_ep *ep, > >> > >> pep = to_cdnsp_ep(ep); > >> pdev = pep->pdev; > >> + pep->ep_state &= ~EP_UNCONFIGURED; > >> > >> if (dev_WARN_ONCE(pdev->dev, pep->ep_state & EP_ENABLED, > >> "%s is already enabled\n", pep->name)) > >> @@ -1023,9 +1024,13 @@ static int cdnsp_gadget_ep_disable(struct usb_ep *ep) > >> goto finish; > >> } > >> > >> - cdnsp_cmd_stop_ep(pdev, pep); > >> pep->ep_state |= EP_DIS_IN_RROGRESS; > >> - cdnsp_cmd_flush_ep(pdev, pep); > >> + > >> + /* Endpoint was unconfigured by Reset Device command. */ > >> + if (!(pep->ep_state & EP_UNCONFIGURED)) { > >> + cdnsp_cmd_stop_ep(pdev, pep); > >> + cdnsp_cmd_flush_ep(pdev, pep); > >> + } > >> > >> /* Remove all queued USB requests. */ > >> while (!list_empty(&pep->pending_list)) { > >> @@ -1036,6 +1041,7 @@ static int cdnsp_gadget_ep_disable(struct usb_ep *ep) > >> cdnsp_invalidate_ep_events(pdev, pep); > >> > >> pep->ep_state &= ~EP_DIS_IN_RROGRESS; > >> + > > > >Useless blank line > > > >> drop_flag = cdnsp_get_endpoint_flag(pep->endpoint.desc); > >> ctrl_ctx = cdnsp_get_input_control_ctx(&pdev->in_ctx); > >> ctrl_ctx->drop_flags = cpu_to_le32(drop_flag); > >> @@ -1043,10 +1049,12 @@ static int cdnsp_gadget_ep_disable(struct usb_ep *ep) > >> > >> cdnsp_endpoint_zero(pdev, pep); > >> > >> - ret = cdnsp_update_eps_configuration(pdev, pep); > >> + if (!(pep->ep_state & EP_UNCONFIGURED)) > >> + ret = cdnsp_update_eps_configuration(pdev, pep); > >> + > >> cdnsp_free_endpoint_rings(pdev, pep); > >> > >> - pep->ep_state &= ~EP_ENABLED; > >> + pep->ep_state &= ~(EP_ENABLED | EP_UNCONFIGURED); > >> pep->ep_state |= EP_STOPPED; > >> > >> finish: > >> diff --git a/drivers/usb/cdns3/cdnsp-gadget.h b/drivers/usb/cdns3/cdnsp-gadget.h > >> index 6bbb26548c04..e628bd539e23 100644 > >> --- a/drivers/usb/cdns3/cdnsp-gadget.h > >> +++ b/drivers/usb/cdns3/cdnsp-gadget.h > >> @@ -830,11 +830,12 @@ struct cdnsp_ep { > >> unsigned int ep_state; > >> #define EP_ENABLED BIT(0) > >> #define EP_DIS_IN_RROGRESS BIT(1) > >> -#define EP_HALTED BIT(2) > >> -#define EP_STOPPED BIT(3) > >> -#define EP_WEDGE BIT(4) > >> -#define EP0_HALTED_STATUS BIT(5) > >> -#define EP_HAS_STREAMS BIT(6) > >> +#define EP_UNCONFIGURED BIT(2) > > > >Why add new flag as BIT(2), it causes many changes in this patch? > > In my feeling, EP_UNCONFIGURED is more associates with the first 2 flags, so I've decided > put it after BIT(1). No, you may not add such relationship, each flag has its own meaning, otherwise, the sequence of flag bitmap may be changed again. Peter > > > > >> +#define EP_HALTED BIT(3) > >> +#define EP_STOPPED BIT(4) > >> +#define EP_WEDGE BIT(5) > >> +#define EP0_HALTED_STATUS BIT(6) > >> +#define EP_HAS_STREAMS BIT(7) > >> > >> bool skip; > >> }; > >> -- > >> 2.25.1 > >> > > > >-- > > > >Thanks, > >Peter Chen > -- Thanks, Peter Chen