Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1297896ybc; Tue, 12 Nov 2019 18:18:59 -0800 (PST) X-Google-Smtp-Source: APXvYqzeIesBDod4Vh78cjXjMSeaopL4GaulhXHI098nECkBJdyxiSIMqXxeHj/Aoz2sAYVY2fDg X-Received: by 2002:a17:906:5586:: with SMTP id y6mr517644ejp.76.1573611539418; Tue, 12 Nov 2019 18:18:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573611539; cv=none; d=google.com; s=arc-20160816; b=XnQA/LedUCrUZC+2p/pboKbOOy2FHtkk7v0iJxpGtsJB+Eb2+9Ue7sfCg7KwVJ/ej8 bJZQ8aEDjlKu/V68dEEt7Ggz7owYsrbVvzBnu/ybjcejrEk2n1fIqAqugCFjQWtCi3SV umHENC96/ijHz2MTMQZK4luqG3HfnvaVS9Ol1noADh4YkmoD0nhApNVGbn+iVrY0C5sm 2qMUz2px1rC1ebHAXTOt20bhFW3AcahOqfhBOCQHGt6EBKh5UDSIZa8s/bwvQRZFSKa8 IhgQWjh+Q3Mzh2ETf8cqjq3M0Z7P2P84XBCx1zOLJB8gUO/eqeWJRU0+Amhy1MBkHuNt VL6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:from; bh=Tujpg7WZBoOThKGX8MEAml/VB3Yc83jertZP/WdKXl0=; b=fWmy0aVsHviH9Uf8YrBED9jo7NuHEA0eQovWsUa/ibx9TLTzxbUIEPFZTelFA99CoI kXHZ2jDJZLvSQ+ryyQ2zoR9Y9kPXNulmLPaMKeULk+AFN2FtrBSb7+jsqntqCeMXZQCa ovOupWvOhaY3FeMn1Kp2wrAUz5REX1jEF98+wZ/5SCgUkIxHWFNoqXR5uotpfrKBYu1/ 5Qz1acD36kul3P9+3HyiDJTcZVC5IM2GyAvA9ZxZlN2FA1H4uOfS9wlTo6asrHd0zBuI Xu1ohz1ZoM/Xlr+Dg0bqExdhRCIbVAO8nQu46s7kmXFwOvZlbXeoQ3S9CyISxdUBPL4y EWdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nvidia.com header.s=n1 header.b="C/6sf+uZ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1si291740eds.170.2019.11.12.18.18.35; Tue, 12 Nov 2019 18:18:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@nvidia.com header.s=n1 header.b="C/6sf+uZ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730171AbfKMCRA (ORCPT + 99 others); Tue, 12 Nov 2019 21:17:00 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:17146 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728471AbfKMCQ5 (ORCPT ); Tue, 12 Nov 2019 21:16:57 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 12 Nov 2019 18:16:01 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 12 Nov 2019 18:16:57 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 12 Nov 2019 18:16:57 -0800 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 13 Nov 2019 02:16:56 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 13 Nov 2019 02:16:56 +0000 Received: from henryl-tu10x.nvidia.com (Not Verified[10.19.109.97]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Tue, 12 Nov 2019 18:16:56 -0800 From: Henry Lin CC: Henry Lin , Jaroslav Kysela , Takashi Iwai , Thomas Gleixner , Allison Randal , Richard Fontana , Greg Kroah-Hartman , , Subject: [PATCH v2] usb-audio: not submit urb for stopped endpoint Date: Wed, 13 Nov 2019 10:14:19 +0800 Message-ID: <20191113021420.13377-1-henryl@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191112065108.7766-1-henryl@nvidia.com> References: <20191112065108.7766-1-henryl@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1573611361; bh=Tujpg7WZBoOThKGX8MEAml/VB3Yc83jertZP/WdKXl0=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=C/6sf+uZj2gOMh/+HER/DbH5WOlnwdrXdu1S2kYhz3Kqc89ZAAQhoOb5k85XqhhvC zWY60Wd/cdyrsszASUdpJmdmOJSLpmnCE0HOHB6Ld1KH2aa40KJPP+kqE/9dgPOy4M S3B0nML7ZS27bkJ0DiQjuH0X+ohSrp6o5a/aOScVdxj5xK4NMzlFpOdliYYVriki45 pMn76QfDjqIX+6NGPq5rlRl69ZjxGym+QgaAoslIKGQAK6zrDvr44DA311pJqXoPQc I3iyVcxdgyj0hRlIq0JD7pk+NawUf0zX1SsrG/rsrXCN5+KCPP3kXCwn8/4eACPeZ8 XMwUJvgDueUEQ== To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While output urb's snd_complete_urb() is executing, calling prepare_outbound_urb() may cause endpoint stopped before prepare_outbound_urb() returns and result in next urb submitted to stopped endpoint. usb-audio driver cannot re-use it afterwards as the urb is still hold by usb stack. This change checks EP_FLAG_RUNNING flag after prepare_outbound_urb() again to let snd_complete_urb() know the endpoint already stopped and does not submit next urb. Below kind of error will be fixed: [ 213.153103] usb 1-2: timeout: still 1 active urbs on EP #1 [ 213.164121] usb 1-2: cannot submit urb 0, error -16: unknown error Signed-off-by: Henry Lin --- sound/usb/endpoint.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index a2ab8e8d3a93..4a9a2f6ef5a4 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -388,6 +388,9 @@ static void snd_complete_urb(struct urb *urb) } prepare_outbound_urb(ep, ctx); + /* can be stopped during prepare callback */ + if (unlikely(!test_bit(EP_FLAG_RUNNING, &ep->flags))) + goto exit_clear; } else { retire_inbound_urb(ep, ctx); /* can be stopped during retire callback */ -- 2.17.1