Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1243879pxy; Fri, 23 Apr 2021 03:51:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykcPVN9S1jNb0+/PirLLACwj92AIwQ7ARfrQ3vjwXDl356bA1Qt50LLjGLg4Id1KISSkiB X-Received: by 2002:a17:906:3e4a:: with SMTP id t10mr3474146eji.553.1619175061650; Fri, 23 Apr 2021 03:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619175061; cv=none; d=google.com; s=arc-20160816; b=EMSlTV8NZerOahMQ7CRj31xsHbT4iMFh06XXAYmGi3hwT2UoDt8TyJ91OjuIye9Myy tzvLfJWkxUQOhMaz26tc8KSiMGdtN3vYsLb8Mjlc7m1beW0Lmt2ej0jDRswyWuSJeuey An+HnTJE4ZZPrQQGOpQRrfblltQQsMWcwhwYfZLyWPbgyeJxPC/JqMHzPx4sN/ZEVOI8 C6KZ8Y6xSLqJBtriA+6vpctnUm3FL0r8q19kOo4hUjxh/BDrfzDCsGUIb5YS291l3yBq BIY3n5/CndD2XMKi4pJKk2I2btBpt+85zdfK/3dweu+xwNZ1uOpCbnylyXWIKp0dQ6wq XUQA== 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=f1+cY7qOc4MPw90rQfRfET2tCct/GN+kcbfc9/V5MPY=; b=dg7eC84+8PcZY2QWa3qWLyFGoZWrJRQ4x5XGhOXpCGxvjv2NZ/pkkzTXzHx422bcTJ JHLLPyfJsThAsPSYh9FdBN8miY1cjmHu8fFL1VlAfls2VgjIBk9zJA7wbA8nifTRkinX DdYGgk986yNTuI+E44YOzjMvBn+IpqIGDoQPMmWe15QMZz+ps/JUX+EbyzDhY2ZQ4pdT yV2s7rI4ly2e1FPNtrAjpLD8DV1m3uHQ8H9NM86NqHbLA3511eADEd24cbdfD0omPiFH 1XUpaDnHKQQ1VBEc+uMWq6o8qjprt4NyIctvA1DdOJV6up4DYpfwucmvalZLKWqeYI9z NHBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LWKwa2Lb; 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 gw24si4776517ejb.508.2021.04.23.03.50.37; Fri, 23 Apr 2021 03:51:01 -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=LWKwa2Lb; 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 S241973AbhDWKuC (ORCPT + 99 others); Fri, 23 Apr 2021 06:50:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:51318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbhDWKuB (ORCPT ); Fri, 23 Apr 2021 06:50:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 67E7A6128D; Fri, 23 Apr 2021 10:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619174964; bh=E+vpFsp/R+WM1vqQtLJUe0CuSmKyJ83MOrvEkWsXm/s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LWKwa2Lbst7h1Rh6P/D4L4KwGqy+n0yU2tkqQmOb3aedOd6QDSqfd0/vZMbb92FGs Ac1kWKeg6QAYVWiXVPDIEnrUbSWplqB/vWBQgQ10AuNCrmk4014YUFjy4iC7aI5/zM Yy47pDitHAMPSEd3jkfc3lj01xVmGZPlPy4DbkC5rFVF5Jam9MvqLTjDQCKCgakFXY Ip//gztp4y3NS8QNsplERlkP47QzKY6lZomYBy9mS3crWWN8dTa9rMdDVR0pzgjgwW 3eDArb4LS9xkkL8gJzK2ufj876t3GqrNhLfv90JKZgk+hIW5CcTfI9+DWqovqqPK8/ Lm5AW4Vcq5CHQ== Date: Fri, 23 Apr 2021 18:49:14 +0800 From: Peter Chen To: Pawel Laszczak Cc: "balbi@kernel.org" , "gregkh@linuxfoundation.org" , "ruslan.bilovol@gmail.com" , "jbrunet@baylibre.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Rahul Kumar Subject: Re: [PATCH 1/2] usb: gadget: f_uac2: Stop endpoint before enabling it. Message-ID: <20210423104914.GA6448@nchen> References: <20210419075053.28467-1-pawell@gli-login.cadence.com> <20210420010846.GA6408@nchen> 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-04-20 03:56:25, Pawel Laszczak wrote: > >On 21-04-19 09:50:53, Pawel Laszczak wrote: > >> From: Pawel Laszczak > >> > >> Patch adds disabling endpoint before enabling it during changing > >> alternate setting. Lack of this functionality causes that in some > >> cases uac2 queue the same request multiple time. > >> Such situation can occur when host send set interface with > >> alternate setting 1 twice. > >> > >> Signed-off-by: Pawel Laszczak > >> --- > >> drivers/usb/gadget/function/f_uac2.c | 8 ++++---- > >> 1 file changed, 4 insertions(+), 4 deletions(-) > >> > >> diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c > >> index 9cc5c512a5cd..7d20a9d8a1b4 100644 > >> --- a/drivers/usb/gadget/function/f_uac2.c > >> +++ b/drivers/usb/gadget/function/f_uac2.c > >> @@ -890,17 +890,17 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt) > >> if (intf == uac2->as_out_intf) { > >> uac2->as_out_alt = alt; > >> > >> + u_audio_stop_capture(&uac2->g_audio); > >> + > >> if (alt) > >> ret = u_audio_start_capture(&uac2->g_audio); > >> - else > >> - u_audio_stop_capture(&uac2->g_audio); > >> } else if (intf == uac2->as_in_intf) { > >> uac2->as_in_alt = alt; > >> > >> + u_audio_stop_playback(&uac2->g_audio); > >> + > >> if (alt) > >> ret = u_audio_start_playback(&uac2->g_audio); > >> - else > >> - u_audio_stop_playback(&uac2->g_audio); > >> } else { > >> dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); > >> return -EINVAL; > > > >To avoid this, you may use prm->ep_enabled to judge if the endpoint has > >already enabled. > > Such condition is as first instruction inside u_audio_stop_playback->free_ep function, > so we don't need duplicate it here. > Get your points, you may add more explanations both the code your change and the commit log. -- Thanks, Peter Chen