Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp2556499pxy; Sat, 24 Apr 2021 20:31:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaLYgbC9h+lvpRgINikyE6JB4wnGHb5tk92Biv2ZyJd604n98zKS9tiO/oETe5fGnw6W1q X-Received: by 2002:aa7:c393:: with SMTP id k19mr13350489edq.160.1619321475650; Sat, 24 Apr 2021 20:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619321475; cv=none; d=google.com; s=arc-20160816; b=MPcu3B2Fu0tjKn9sgH2gFZtb978ae07xe+o2sqd+VK1BkvouRefB85eDop2+p/p1RM c/tI8CEuyNr9qvLOlcA92dfOVlwdvM7yPkdAanQcVpmrlApjSR1Fz1Xe4QumlJLlCsNa q7K4qZxIzF/biLkGM+bZyJ691hOhHTnoL1qSifDA0rYn78mPuPvGs9749DefL4+0fBFS miptiiaRLOrMn/eY8S3ynXtgbMPFl3VZLn+5aU1GAEy685Fng9bAabcbvume8gWQ0CxY c/yhzscKAjAYw97Haxa4f2k3kd6LFAu94thzYDBtCqx9CBR+TspsDi43qvzYPxZybnsg j5LQ== 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=hBgeMo4lJ6ritnLjlX2XP5hH+EU2qeqhhYHJP4JQJnU=; b=j6Oot+sATZuLcyT6A8ZCXtRbvqZDCzTaZHZVTwEEOasxvJBQIxKygps7JTfA6hcvZ8 BgOI5lx8dwNI1Pg0xwqOqHWowRmNghZs9XKSebmWi3OANWwuah8ZeHfRtgx7ZNS8tglb cAEekxT0i/xTJZkc3BppJWr9J+eY5L3Bo2rYwuuptMgAXiZlJVFSs1UeGHyaqmep+Uol q2UeM5n9xASAwdlU8926CnLz/nMdgDEMPkJZIszRTuHRf0Lu/0T53Km8HdF1LJ4/4Dz1 GdMogmz4ASzPEqx0sPB6i+kCJoz8A9rPYo2AMrsz7hwJqxXKV7u1p1SQjZEV7+GCdSEq g2Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rli9kLKM; 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 hr29si9125057ejc.136.2021.04.24.20.30.36; Sat, 24 Apr 2021 20:31:15 -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=rli9kLKM; 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 S229690AbhDYD3h (ORCPT + 99 others); Sat, 24 Apr 2021 23:29:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:48008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbhDYD3g (ORCPT ); Sat, 24 Apr 2021 23:29:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 82B4761154; Sun, 25 Apr 2021 03:28:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619321337; bh=rnzq7hymD1yyqndLzmlHZWhdSR/iXxuNvtGqJkDhxxo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rli9kLKMPfWi6nnOMsXMojc7Cl6RLJGWTSM7j8AsfWZ2MfE+Pyj1KUCFkaVcCWwHj nIwS7EDsolGFXYDa1N8ZhmsVTL4g9QZ/bnXdm8AYVdF9+S51sBmcFoPS2a2FvSRkXT tiU+o/flMUuLG+LyCXhYXJyzBrx+8U0u3G1jhf6I4FUVnqEO4xOBLm0PG+qK89AFym BmpcVrGC6VN2KGWBmSldaD8FA4yVXOys+CVqLXhXAaHySJCJJioR8SyM1z+lfUjDhI BVPlGLr0j+g0cvZOc7igYhDwEz9+EzsLIoj3mGsUNKNfjlGgKkTA0/xGc+TPr7smJX Tucm8B0rCbU6w== Date: Sun, 25 Apr 2021 11:28:52 +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: <20210425032852.GA10463@nchen> References: <20210419075053.28467-1-pawell@gli-login.cadence.com> <20210420010846.GA6408@nchen> <20210423104914.GA6448@nchen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210423104914.GA6448@nchen> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21-04-23 18:49:14, Peter Chen wrote: > 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. > After thinking more, I think it is better add judge code at u_audio_start_playback/capture, but not change code here. The reader may not understand the code your change at the first glance. -- Thanks, Peter Chen