Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7030058rwr; Wed, 10 May 2023 02:53:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6QzOsiMOFGEzp6fluz8/9dEdurnohBsLMOB3ck95GD8ji6xHFrgKR55f7yCto8Pqf8IpYl X-Received: by 2002:a05:6a00:2e1b:b0:63d:6744:8caf with SMTP id fc27-20020a056a002e1b00b0063d67448cafmr21633495pfb.26.1683712419329; Wed, 10 May 2023 02:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683712419; cv=none; d=google.com; s=arc-20160816; b=YQ2q7HesF3vJqgsd6Vy2vSsKCUGJP+EhaUjWeLp8AOIDi8VHbaXG12OpFcVz/ax64y vtPc1zf/7xHh4a+ss9czY9dIcWU5qm4YJ/PjOY3BdOyIdL8E1qX5Znr5k/eBXlACtwLK 6LZ+9Q6CwxYrCJGL7BqoSOI/vn5It3ltku7vMfMh6X0qILl9P/6RQ6qjLBBhXJM7URQ7 5+m7RkMcWSGC9slcSqtyFqtCklgSJsGW88bGuvvpwPH7DQIkugz4mSJGjUs3VQhXhLxr VVIPkEASHvL01Hg5kNi4/YsOhlI7med3TaMaMt4WVVCX9zfIUj81QNZUYXqZnYzgwjtP Hg3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=uHkiT6Uiynl0Lruythe0Uk6VgeBS4SqWbF3W79uTkOQ=; b=AutCF9zdFyHhxfT7QbmLzizHeV/HTzs8K4RxVLdDmQVijVriT0cMwXX4ldmKeAsTbu C9tg6Mb8k2pvZYpx4ipRrhUqUdMg9Vzt01E7B9nrC9oCUOKcLuXSfIc5sAuvvVddQFsK rgzwg4x3dnYKN0D3vM/z7lwXFVKfqWrXUBma5hIec5xmh2v4Cc6deDQZ5DevRup3Fibe /vdOqHaDdjSROEds+PpS6zC+epktFmPq8fnmpRgmt+eUPpCsnd8B2TWXh5BiXpfZkQVb Ldt1ndQesfPFtGDEb090auPqLC+nYkA+3QAUJF6iZcW59+DDbYcgShCBtncUg1SV62/f Vezg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=XBkSADTR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v202-20020a6361d3000000b0052c6e736acbsi3744273pgb.333.2023.05.10.02.53.24; Wed, 10 May 2023 02:53:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=XBkSADTR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236273AbjEJJbw (ORCPT + 99 others); Wed, 10 May 2023 05:31:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235609AbjEJJbu (ORCPT ); Wed, 10 May 2023 05:31:50 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FC7910F5; Wed, 10 May 2023 02:31:48 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4f22908a082so4791684e87.1; Wed, 10 May 2023 02:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683711107; x=1686303107; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject:from:to:cc :subject:date:message-id:reply-to; bh=uHkiT6Uiynl0Lruythe0Uk6VgeBS4SqWbF3W79uTkOQ=; b=XBkSADTR4TScrcB27eBtMX/nsX8ZEZDE/tSEpJp9ibkEuX1/v8nVP7uCIUvpSrolMY wvKD5HLh3L/64IzOnN0/CSiLBPT5zqYR2xOVhQhadzlnfWj+VYKs5MIFhGgVqaOy6USZ CMNg/UupDl+9Q5uvhQ3Cbo80n9zDZ8BJqSXW60SaQ8HD20mLa/YaZKRtpsaIdevWUCcp xjJUUO2R/vc+sqU256M0tFZiG1guQgz8Wn+4OQAJG4AwUwP+CkILhrvVjuvBCIfzLReF DfC4mF2r1N65Jk/YJ8RWQS9wf+nCysqBEyfUk+WRhmM0mUmWUHtnvVSKHrJlAPvDCIjj Rcow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683711107; x=1686303107; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uHkiT6Uiynl0Lruythe0Uk6VgeBS4SqWbF3W79uTkOQ=; b=GQ8E+iCKoCMwpLYkK9YzPKs/aEfIEH8m6IfRumiB2srOpzhLBheEh4ZHULHSnULGW7 bxniAc25ySWIfnxp2xKkf6GkfNGfU1ujkxaqiIY93NkelIA3joTtvvDM6NcPtLy1KerB FLmgKPx9+6SUOsoUGhgkZ6VLToPNksyOPwGeHuI/rVsM5Czp7qNH2wYzUkGmVwzEAZ4N mcZPDaPh8QJ8djwDDoINSfHJ3QKzzSo0k021ExlMnQzzQkFfN6zDBg604aR17CMxW/ca Jz9bWk25LlkDeRR5j5xJ5Eux3ZQbDM0pTkTrxdoV/ZBv3opFnkK9n3hD6ELULMJCbbnH D3Vg== X-Gm-Message-State: AC+VfDxeHvIWDLZU7XB1L1vt19Us2/lVIRvjCEyLyGIDkIGk4ZDl4cqz nNQgzHaxAFqEwtNZtnARLZYVU1WT4vg= X-Received: by 2002:ac2:4c8a:0:b0:4dd:af29:92c1 with SMTP id d10-20020ac24c8a000000b004ddaf2992c1mr1391092lfl.44.1683711106673; Wed, 10 May 2023 02:31:46 -0700 (PDT) Received: from [192.168.1.103] ([31.173.86.195]) by smtp.gmail.com with ESMTPSA id v15-20020a056512096f00b004b55ddeb7e3sm667654lft.309.2023.05.10.02.31.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 May 2023 02:31:46 -0700 (PDT) Subject: Re: [PATCH v3 2/2] usb: gadget: udc: Handle gadget_connect failure during bind operation To: Krishna Kurapati , Thinh Nguyen , Greg Kroah-Hartman , Alan Stern , Jiantao Zhang , Badhri Jagan Sridharan Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, quic_ppratap@quicinc.com, quic_wcheng@quicinc.com, quic_jackp@quicinc.com References: <20230510075252.31023-1-quic_kriskura@quicinc.com> <20230510075252.31023-3-quic_kriskura@quicinc.com> From: Sergei Shtylyov Message-ID: Date: Wed, 10 May 2023 12:31:44 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20230510075252.31023-3-quic_kriskura@quicinc.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! On 5/10/23 10:52 AM, Krishna Kurapati wrote: > In the event, gadget_connect call (which invokes pullup) fails, > propagate the error to udc bind operation which inturn sends the > error to configfs. The userspace can then retry enumeartion if > it chooses to. > > Signed-off-by: Krishna Kurapati > Acked-by: Alan Stern > --- > changes in v3: Rebase on top of usb-next > > drivers/usb/gadget/udc/core.c | 21 +++++++++++++++++---- > 1 file changed, 17 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c > index 4641153e9706..69041cca5d24 100644 > --- a/drivers/usb/gadget/udc/core.c > +++ b/drivers/usb/gadget/udc/core.c > @@ -1122,12 +1122,16 @@ EXPORT_SYMBOL_GPL(usb_gadget_set_state); > /* ------------------------------------------------------------------------- */ > > /* Acquire connect_lock before calling this function. */ > -static void usb_udc_connect_control_locked(struct usb_udc *udc) __must_hold(&udc->connect_lock) > +static int usb_udc_connect_control_locked(struct usb_udc *udc) __must_hold(&udc->connect_lock) > { > + int ret; > + > if (udc->vbus && udc->started) > - usb_gadget_connect_locked(udc->gadget); > + ret = usb_gadget_connect_locked(udc->gadget); Why not just: return usb_gadget_connect_locked(udc->gadget) > else > - usb_gadget_disconnect_locked(udc->gadget); > + ret = usb_gadget_disconnect_locked(udc->gadget); Likewise here? > + > + return ret; > } > > /** [...] MBR, Sergey