Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2920379pxb; Mon, 19 Apr 2021 18:09:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzc4YdAFY4eeNR06hDZG2C5WSxYuWaxoDVbczUIogsnDWeX2pRgThtMz8/oUQR+weC4TvWn X-Received: by 2002:a17:90a:bb13:: with SMTP id u19mr1991435pjr.96.1618880978980; Mon, 19 Apr 2021 18:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618880978; cv=none; d=google.com; s=arc-20160816; b=tUn9eTPd8DcQJ+RTn9jHmrZUfxAw0NS/7Gbrso1JlPtMIW9cgijB+Wbry+ZVzgPeJ2 XZmIiO8hKB3JiiiAPWoMDVNLj7ezllaEF3RR464kvwTwqpZh2LmZ5YuW7XnG7VMxACQI aWov/xVZkL/ggCUZYLrkPUpPhouqJP9LvlQcnq6V1LTfOu/xqH43voj30w+p7lZUGhPQ G2BLY1vLFooMymU/e/G8/iV4cII2VLwme9xR19YE3HXOr/YWNSWHukBzLewj/81ZKIcm 1wdqdiGW21k8XXFAoe53wzh26SRgRFUzyadFe/Y0DiofhBEbMSqgdd+DXphQYJJU7NSk mzMw== 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=MnRp02WqkY5Z0wHphtxrUuck3GouVAVMxnTejFNGsQU=; b=1FnKENY9RoF88V3fdg3YxaicJYzADmRGL8zJs1Dusgk0BfhVl107txTqIjpSksuAqm nILNN2TRIWrrp6mgeAyquLR1crKop/VxhNqJ/itPAqhje4RK8k2tRKRcZpVLBaG5gO0y fEstw/sFVNgezeY6GhCnUe8xswp4/NzwLZWHH7bDErGzWN/iUZLOXrrZ5N/boifEV+n9 E7n5pOS+2rF0YsqDyZni7z3147f5R5wN6DQ2IDJ359cB469USNOl5EXnh9rJtVUFL7Ys gKCfucIHAQn/VDzZTbTdHF/1MLtEgzpDpni7ppVWlKRUraiv3dMOiG69K/KIobv8HwOr /eCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="B/Ne2h/f"; 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 a14si1374006pjv.27.2021.04.19.18.09.26; Mon, 19 Apr 2021 18:09:38 -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="B/Ne2h/f"; 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 S231378AbhDTBJZ (ORCPT + 99 others); Mon, 19 Apr 2021 21:09:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:58614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229994AbhDTBJZ (ORCPT ); Mon, 19 Apr 2021 21:09:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B234461363; Tue, 20 Apr 2021 01:08:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618880935; bh=yOhwTEEdJ51D9ecoqLz/L5DtMsNDmzT+3Upf6xsRNeE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B/Ne2h/fSACpMFCfIwqYN1hyJyZqXWEdgsSs+1KNrKm4sbkVsfhyAQCKScJusXruS 5Jv2/oeSSrP5D7ZgcLuzVQZTds4oOJpqTxlldTZqGxHH1g6xDTJpzKypYcR2Dm8obr z4W2PtSYU97GdwocE87uThsWpJKqJE2JR6eP7mu2TnjUJqBt8J7lfrkJ3bm6R3TT4x WfMGrRMFBOq2i6xMo24ANJ80+s4HMEuOL6q/PhWwVoCdCDnPdz/LOKHJaEwSXmJ6qN gBypnW2sB+D+AMGqa1bwwvDDZAIwyBqxDjfUBagZ4WTG6zUusF9b57oAexuLS6rnCX TKN26rQOd+slA== Date: Tue, 20 Apr 2021 09:08:47 +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, kurahul@cadence.com Subject: Re: [PATCH 1/2] usb: gadget: f_uac2: Stop endpoint before enabling it. Message-ID: <20210420010846.GA6408@nchen> References: <20210419075053.28467-1-pawell@gli-login.cadence.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210419075053.28467-1-pawell@gli-login.cadence.com> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- Thanks, Peter Chen