From patchwork Mon Jan 18 08:46:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 365488 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp2060458jap; Mon, 18 Jan 2021 00:49:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwc80dNztrIgYqJvatKC1ZFVbacyl+/Gc68s1KsXogezJo1RcQ7W5i2VDFMkPR6eTPmxTZ1 X-Received: by 2002:aa7:d386:: with SMTP id x6mr223491edq.194.1610959757689; Mon, 18 Jan 2021 00:49:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610959757; cv=none; d=google.com; s=arc-20160816; b=Y6AGPxoizEUD+DZ2HEoaH91QKHVhFpM2uoRMYMLK6vr8NBtwkBtT2d2bCNFZ7Jkjbq 1tvfIuIsttgZ1tDA6Vv9Zg7ghvBLXcWenUqbKOulWTruABvmjtxUwjaab4org5eaGyTv vq1kVQVtOQgFyskSudp7A+04P46j3wdv7N3gvIkkT7ZwAT8seIaWdbJi4xql8cWjbV0K o67UnaR9fOZZfexzKUPhsSAa1sbWBxjz6bSLB1ADt5wWWuD9YCpVGm4YIKs0wda2eWwZ ik6mL+gdt2Mu8N+lNSocrwrNooFK8W9rhXC+TnUtrfj1JxlaThH5E9RZwqjM2/2Fa0H0 UtVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OyQZB4rl5Zar0wRlUg3JZS81nsXMFf2BksOtPVpSskk=; b=uKDYVPQgw7H3dfPPweZtk2lwKXBc3QeYkxG3vNVrWlyHSXf5yzLM5HEZGAD860zuw4 Vy3W85mQw/qtXYuM3hKhsXxF1zzXKOAFsFkgXJm5W6gUJM/bTRoTAWh+NOsLox6lJa/A epV5QxXfZ/XdZoOx6BlOSJlzcXZBJRd++QkCQ9zwC4uB2Kb62lBo3/1UAA7YKX/QCZUv fG98cFDOumOM1NE1E77CnJ83qrNGICFqWDj3mW+iMB5DmSblg5nznwOC8rdCwI47/s1g 5OLu7tN/P1GyC3U/KnS06D10QR+du2Ub4kVR1uLt3boQ2RiLJUr0hBtkmV8CSbCnGHNF vZhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=1eDIvqm2; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t14si7889997edd.161.2021.01.18.00.49.17; Mon, 18 Jan 2021 00:49:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-usb-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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=1eDIvqm2; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387927AbhARIsN (ORCPT + 3 others); Mon, 18 Jan 2021 03:48:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387859AbhARIrp (ORCPT ); Mon, 18 Jan 2021 03:47:45 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4884BC061757 for ; Mon, 18 Jan 2021 00:47:04 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id y17so15583722wrr.10 for ; Mon, 18 Jan 2021 00:47:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OyQZB4rl5Zar0wRlUg3JZS81nsXMFf2BksOtPVpSskk=; b=1eDIvqm2DYBQvrlEqrZOdoWFbDIRO661ivbAjhUrNDhelTRzl7byhn20hOJ85oJkbL b7zrCpvOOaWz6/ecVYNyQ9+YN9D55OrwQgAjzIWATqfremCD8/lk8X6iMYKtdaGnvSpb m+eLJP37fOXg5Z0WUwwbqFmRw748VjyEYfp7ApQHwSF41krg9wAExURz+5ScqvdOk4mg WzRgr/PPaFcn8eUOi8Mq95V0H/jF4fvilivYDzZ1uZurTW9RNtjk+3d23p/fsUcPaqGC ZzchM2EtTLBQOpYSu5VimxKpLNG042e1NYdZb7kDM3Zlw5rxjQmIwQVl4Z05XVJB7vZB xujQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OyQZB4rl5Zar0wRlUg3JZS81nsXMFf2BksOtPVpSskk=; b=B0A7B5hxR6UoLxCxOTsAccCoB5qGtuQ3sbm3Pui4tYHmodyDgOKk3Kx/gJtZ6wLoKM IJFwKZH8HJEb8WJsF0+0SiKfzNXL907gAAEcLMG4Gxf439Gj+kjy6jKhcga5Lqvml+yA JUe7tnccCmXRVA3QMDEWMfMj4qGJt8hHDr7fZyymczHxzTBsSG3VC+JOMVu7+r/7JFp1 jHFU/adv2gvNWv+4vACvPt+9nGSoXsucNVA7hrzBb5eUE/paJODqeqlySOa4suYGSuaC f27Wd3QCSy80xA48NTBD1u0Ni8b4STx9+uSi1e4JHBzluYIH6VCiih+mLzvrFbVeEbiQ vhVA== X-Gm-Message-State: AOAM530o0UAzOcY7/mOO/ppTUeEbfZQ6cZfw74CIKDDffGwbGON7jlRZ 91FMZYtSzEIyWLHMgiBnPaF3Pg== X-Received: by 2002:a5d:6cd4:: with SMTP id c20mr24712137wrc.57.1610959622969; Mon, 18 Jan 2021 00:47:02 -0800 (PST) Received: from starbuck.lan (82-65-169-74.subs.proxad.net. [82.65.169.74]) by smtp.googlemail.com with ESMTPSA id y63sm26224518wmd.21.2021.01.18.00.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 00:47:02 -0800 (PST) From: Jerome Brunet To: Felipe Balbi , Greg Kroah-Hartman Cc: Jack Pham , Ruslan Bilovol , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Ferry Toth , Peter Chen , Jerome Brunet Subject: [PATCH v3 1/4] usb: gadget: u_audio: Free requests only after callback Date: Mon, 18 Jan 2021 09:46:39 +0100 Message-Id: <20210118084642.322510-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118084642.322510-1-jbrunet@baylibre.com> References: <20210118084642.322510-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Jack Pham As per the kernel doc for usb_ep_dequeue(), it states that "this routine is asynchronous, that is, it may return before the completion routine runs". And indeed since v5.0 the dwc3 gadget driver updated its behavior to place dequeued requests on to a cancelled list to be given back later after the endpoint is stopped. The free_ep() was incorrectly assuming that a request was ready to be freed after calling dequeue which results in a use-after-free in dwc3 when it traverses its cancelled list. Fix this by moving the usb_ep_free_request() call to the callback itself in case the ep is disabled. Fixes: eb9fecb9e69b0 ("usb: gadget: f_uac2: split out audio core") Reported-and-tested-by: Ferry Toth Reviewed-and-tested-by: Peter Chen Signed-off-by: Jack Pham Signed-off-by: Jerome Brunet Acked-by: Felipe Balbi --- drivers/usb/gadget/function/u_audio.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) -- 2.29.2 diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c index e6d32c536781..908e49dafd62 100644 --- a/drivers/usb/gadget/function/u_audio.c +++ b/drivers/usb/gadget/function/u_audio.c @@ -89,7 +89,12 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) struct snd_uac_chip *uac = prm->uac; /* i/f shutting down */ - if (!prm->ep_enabled || req->status == -ESHUTDOWN) + if (!prm->ep_enabled) { + usb_ep_free_request(ep, req); + return; + } + + if (req->status == -ESHUTDOWN) return; /* @@ -336,8 +341,14 @@ static inline void free_ep(struct uac_rtd_params *prm, struct usb_ep *ep) for (i = 0; i < params->req_number; i++) { if (prm->ureq[i].req) { - usb_ep_dequeue(ep, prm->ureq[i].req); - usb_ep_free_request(ep, prm->ureq[i].req); + if (usb_ep_dequeue(ep, prm->ureq[i].req)) + usb_ep_free_request(ep, prm->ureq[i].req); + /* + * If usb_ep_dequeue() cannot successfully dequeue the + * request, the request will be freed by the completion + * callback. + */ + prm->ureq[i].req = NULL; } } From patchwork Mon Jan 18 08:46:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 365489 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp2060462jap; Mon, 18 Jan 2021 00:49:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4KQnT5gBDoez3Ha31v9LirZv4EMOq0hfD2ClgQR7GrH/hPvnVHXQMFwHCNDNPNOe45Tpe X-Received: by 2002:a17:906:5043:: with SMTP id e3mr16769229ejk.260.1610959758425; Mon, 18 Jan 2021 00:49:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610959758; cv=none; d=google.com; s=arc-20160816; b=YZyZnn8ZEcx/howDjmX4xtfNrYmptoFfw4hy3BKUuf08gsebtDTxa1Pqw2Pq2zYEFP MbXWcsm0f7iNV8BHDcikTcqsYDXGDgg+wdiExNrSHWZ8tJg/0IV9JEqbKtiH+l16feBU oihHgeJqd2JH+QJXuqNUe9VpV8q0e1SJMWIDUHPI6l7yJrUDzMsWTpTkafgKhsAieGEh Zy0RrySc8z8IodUgnomfBVoTPkIv6+8Eyc8zkvfYHCdwvIfi9luPUIuJ9HOiBNZ5+WRA p47IlYErtjYifwPzh3Ee1JtySAf0IMlMIYkEYsNcvjeTbLNfSaPKHU1891H5DMBrBlJD Ye0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8u2QoVss2UavcelbE4BrawmKFXEyru6c+YRhQ7iYuuo=; b=Al4THLfi2i32w23NzVkc9ZNxmZuByaXnIUjbD8WbJkHwuyw6DD+17Yy4iSmgcIUwje +k4ArSl38WnUA5qiKjNALYEjvtokKAPdBZKUQC/xlQXRau4Pnmeb4JhWyuVKV0RfBUo2 H8tPqu2O0WSl58kFpDkYBaAH9Zl6KbSFp0FFh74duF5lZ9dDiuotRTTZq+L34XYPmfvv LjtIVWBmFJA5AN9R8eiqHblANDOmYZoPMSG7y8yxMoEZjxKWDRRK0WxXORMzEf/MvdCf w9itjYVUD4Q0qcr6RyBQnsidoZ+4znFmdrXYP3ZAF8AQGnltotPS452h1e68+wV+nf5D P/Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=Sm3PhrpB; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t14si7889997edd.161.2021.01.18.00.49.18; Mon, 18 Jan 2021 00:49:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-usb-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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=Sm3PhrpB; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387972AbhARIsX (ORCPT + 3 others); Mon, 18 Jan 2021 03:48:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387946AbhARIsQ (ORCPT ); Mon, 18 Jan 2021 03:48:16 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4532EC0613D3 for ; Mon, 18 Jan 2021 00:47:05 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id m4so15579959wrx.9 for ; Mon, 18 Jan 2021 00:47:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8u2QoVss2UavcelbE4BrawmKFXEyru6c+YRhQ7iYuuo=; b=Sm3PhrpBPJ137AQ3z5B1ZzYmp5XOc27tFEKSH7DZzea2NsslTMdd4ll2jv+fInlKud P4fKiBDUoWVNbFzr2/SJ9PI+ALG3UxWl2WcmrjJyK9OVmlLKWzJccGondH2tASIDy7PN tyDelH5GLOhJplrYl7A4VOdiZKaedrunuuoW66BXfZI/Cw1l36Y1ItbluxTVrrDA9rMX 9vYe7dWh0dmJt5lT0Peg4epzlQmlH4GLPtZaAGvIGljtspNHoqbQr7FuRarayJ4UOe0O GPQ8GlhC/nKpnWqOgGgMFtD+dDfqMVYdKCAAIaxbBhDyzBVZIjqpACvcLx2kiewzP+HJ ZkLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8u2QoVss2UavcelbE4BrawmKFXEyru6c+YRhQ7iYuuo=; b=Lrm4TgAuXteVCJ7wfpDPSQ0NXhYqQrrvzKf+uUrDt2Vpo0mfcYMcsCcDAYClXsf+jn NUEKR6VVhwGUdlCN5PY0W4MzJzOreZ9cnL7FNOKrQ1qZsi6NiQMBei4UUYuYLfrgJowu 7ouZFjSdDUzIwrrqchatk398zKXXm4R1EQ5Sf2ndeZsjBJz66QVnqPay5XB5ud+J8Aqt mXm/joWi11mN5B8mrUKQNeZnvmtBTgrtMzr21b13tBPSCJ+WoRyS0lL12Bfxz7+VXpwC NNRxQ7m89w0xPrO9sF0aXa2/nDtY++PCfRI7GDINiGE1gLWMX/pK/dk61p5b+9lgA0Pr sY2w== X-Gm-Message-State: AOAM533O2ssovIw3wy83QcbV+GMo1+e+kxQerhmEcMqeQHpEIvaPA5gZ Fw4wKak1FaMhdhCjl7F85DBheQ== X-Received: by 2002:adf:8503:: with SMTP id 3mr24920822wrh.56.1610959624016; Mon, 18 Jan 2021 00:47:04 -0800 (PST) Received: from starbuck.lan (82-65-169-74.subs.proxad.net. [82.65.169.74]) by smtp.googlemail.com with ESMTPSA id y63sm26224518wmd.21.2021.01.18.00.47.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 00:47:03 -0800 (PST) From: Jerome Brunet To: Felipe Balbi , Greg Kroah-Hartman Cc: Jerome Brunet , Ruslan Bilovol , Jack Pham , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/4] usb: gadget: u_audio: factorize ssize to alsa fmt conversion Date: Mon, 18 Jan 2021 09:46:40 +0100 Message-Id: <20210118084642.322510-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118084642.322510-1-jbrunet@baylibre.com> References: <20210118084642.322510-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Factorize format related code common to the capture and playback path. Acked-by: Felipe Balbi Signed-off-by: Jerome Brunet --- drivers/usb/gadget/function/u_audio.c | 43 +++++++++++++-------------- 1 file changed, 21 insertions(+), 22 deletions(-) -- 2.29.2 diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c index 908e49dafd62..27f941f71a9d 100644 --- a/drivers/usb/gadget/function/u_audio.c +++ b/drivers/usb/gadget/function/u_audio.c @@ -244,6 +244,25 @@ static snd_pcm_uframes_t uac_pcm_pointer(struct snd_pcm_substream *substream) return bytes_to_frames(substream->runtime, prm->hw_ptr); } +static u64 uac_ssize_to_fmt(int ssize) +{ + u64 ret; + + switch (ssize) { + case 3: + ret = SNDRV_PCM_FMTBIT_S24_3LE; + break; + case 4: + ret = SNDRV_PCM_FMTBIT_S32_LE; + break; + default: + ret = SNDRV_PCM_FMTBIT_S16_LE; + break; + } + + return ret; +} + static int uac_pcm_open(struct snd_pcm_substream *substream) { struct snd_uac_chip *uac = snd_pcm_substream_chip(substream); @@ -269,34 +288,14 @@ static int uac_pcm_open(struct snd_pcm_substream *substream) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { spin_lock_init(&uac->p_prm.lock); runtime->hw.rate_min = p_srate; - switch (p_ssize) { - case 3: - runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_3LE; - break; - case 4: - runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE; - break; - default: - runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; - break; - } + runtime->hw.formats = uac_ssize_to_fmt(p_ssize); runtime->hw.channels_min = num_channels(p_chmask); runtime->hw.period_bytes_min = 2 * uac->p_prm.max_psize / runtime->hw.periods_min; } else { spin_lock_init(&uac->c_prm.lock); runtime->hw.rate_min = c_srate; - switch (c_ssize) { - case 3: - runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_3LE; - break; - case 4: - runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE; - break; - default: - runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; - break; - } + runtime->hw.formats = uac_ssize_to_fmt(c_ssize); runtime->hw.channels_min = num_channels(c_chmask); runtime->hw.period_bytes_min = 2 * uac->c_prm.max_psize / runtime->hw.periods_min; From patchwork Mon Jan 18 08:46:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 365490 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp2060468jap; Mon, 18 Jan 2021 00:49:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzm6lXLNiZ3RK/HLPZWx5psB/tjsxlFRXD2yJx4aHu2xHbqtZIEWxgGP075z3e4htH2CLbl X-Received: by 2002:a17:906:3792:: with SMTP id n18mr712996ejc.47.1610959759212; Mon, 18 Jan 2021 00:49:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610959759; cv=none; d=google.com; s=arc-20160816; b=BaMpE+8bJL3rkpwpMtPrCgBxRMhNy+NKOThSKuUtYUEpfmOBMqqwutQqc1X6NKdMfk 3nRi7Aa2V7j9t+G25LraK4pJtYH4H9JgiX5YG3U2dvhKCmjAdGyMaRVcH5gTYOHoUkU9 908RuVNkenpGhg+YjxVX9K8oSUO5elBVjj4GHHVzZKHFpwJMqOwErgQkYRu1o/+GGBb6 NtGGrH/Z32jEBIITPkSc778n9C8NEirGWlAmeWqe5WJh9Uj3sAUZB8yzDB3zaG8iTEsV 2YhtaGXoXo1K8p1MW5MULYL6hlMkF7PW5bUY2hchjco17WZYxYQUTXWy777L/2KaTkzb i79g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Sr6l15TWUkoLpe2YUMRX8nPBc3XsL3PtVca29QVV2RU=; b=vk3gRaax0OUeDYEpw9fIcd/JiR05ZXffUCe884M3GISMnB9DJ5GXf6ZDYDIgNeH74m 0nXVu7HLdRsKJBr3Y/4r5hpoQyivhMR3z4IV5xyvetzQ7VhJSyuzskV7axSKKLEUE6wb bfoFD0CKXD0ogYcEv++Eg0pMqSZChHbO445MIBHS+HHDKgIiB1zuTC0vZCffSOOyOAkx HFNoJtqY2aO+pIPqvl7LFabSIDPX3nZZJnrhqWR8qshGHaiUbaR0k1JB+T/Oej6+W8Uz VP+kpEdHU1rFujWBtUdjJPSvmeDGtPkK+h0xwhUh+qtcXju9TprOuVQLcQMgAIb2buOO Ok1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=d1wWOpKt; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t14si7889997edd.161.2021.01.18.00.49.19; Mon, 18 Jan 2021 00:49:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-usb-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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=d1wWOpKt; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387999AbhARIsh (ORCPT + 3 others); Mon, 18 Jan 2021 03:48:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387977AbhARIsZ (ORCPT ); Mon, 18 Jan 2021 03:48:25 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48971C0613D6 for ; Mon, 18 Jan 2021 00:47:06 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id v15so11938591wrx.4 for ; Mon, 18 Jan 2021 00:47:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Sr6l15TWUkoLpe2YUMRX8nPBc3XsL3PtVca29QVV2RU=; b=d1wWOpKtxL3bQFme34xvxo9phvPySOvA/REPdrSa14GAR33OV+e1KcU73HrjkYNyJh G6HARgNhlDDZ0bxFn3Oa3LfCQxoXHrdndaxkFFQnkcypuSnt6wOqThsFffQ309MC7w+u o7zhxp94hZ1y3B1UJq7W3cfscuT6NxIfVmuLHjfQe5hPmIbXcIvLPmozeQ/oj5L1EDcP GDp8a/wdSIV/iO0Mpeo07Zasw+kfL+tijj6VlxELcrcoJlTQiBWBcoO0ikSF7JfqVDsD mP2nUCi/361OhHiMh4fDVUYWUd8cQ0pEYBdQeMhYsiuMKHV0J9bOd/oDsQmr1JhF64f9 xpqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Sr6l15TWUkoLpe2YUMRX8nPBc3XsL3PtVca29QVV2RU=; b=bWF1blDTcHXKyWeNgrFQ4xBEuXLS2uIQlLmdkLhMyI3O2yWmXYW+wt4x2AtZyuElrZ BdFWPqQqQbieI3rhe/yu2lWUJfmvQ0Kidhrxpw76agUto4L/dGVt3vxaPtRFt7cV+qX+ BcxNNBm+SIfAXei+hosQ+OAhOcMcUqsIUtwABUgoo1uhSVwsH8lxmfJrXP3muTmm5vqa Y6FeD+oyq07DzV4p3eX6rFcFo08jlIRea/PhEnlj6g3PbPu48HloHj02IdSzFJcbVyeP T8vah63hvZuHQkI5+eE1W1sOkzbGQc3OiUThJRn4lAFCDdny2RIHrvqPMTCHYlwIozhH JOvQ== X-Gm-Message-State: AOAM530Omsk0TvCKkclBMA7p8kl3EXKoTeE43HpMTTsD6QlIY+j3BOfT 2Pw+/yJxKiYPgI47ur4XuK6ISg== X-Received: by 2002:adf:9e47:: with SMTP id v7mr24337382wre.185.1610959625003; Mon, 18 Jan 2021 00:47:05 -0800 (PST) Received: from starbuck.lan (82-65-169-74.subs.proxad.net. [82.65.169.74]) by smtp.googlemail.com with ESMTPSA id y63sm26224518wmd.21.2021.01.18.00.47.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 00:47:04 -0800 (PST) From: Jerome Brunet To: Felipe Balbi , Greg Kroah-Hartman Cc: Jerome Brunet , Ruslan Bilovol , Jack Pham , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/4] usb: gadget: u_audio: remove struct uac_req Date: Mon, 18 Jan 2021 09:46:41 +0100 Message-Id: <20210118084642.322510-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118084642.322510-1-jbrunet@baylibre.com> References: <20210118084642.322510-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 'struct uac_req' purpose is to link 'struct usb_request' to the corresponding 'struct uac_rtd_params'. However member req is never used. Using the context of the usb request, we can keep track of the corresponding 'struct uac_rtd_params' just as well, without allocating extra memory. Acked-by: Felipe Balbi Signed-off-by: Jerome Brunet --- drivers/usb/gadget/function/u_audio.c | 58 ++++++++++++--------------- 1 file changed, 26 insertions(+), 32 deletions(-) -- 2.29.2 diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c index 27f941f71a9d..a1a1f4c8685c 100644 --- a/drivers/usb/gadget/function/u_audio.c +++ b/drivers/usb/gadget/function/u_audio.c @@ -23,11 +23,6 @@ #define PRD_SIZE_MAX PAGE_SIZE #define MIN_PERIODS 4 -struct uac_req { - struct uac_rtd_params *pp; /* parent param */ - struct usb_request *req; -}; - /* Runtime data params for one stream */ struct uac_rtd_params { struct snd_uac_chip *uac; /* parent chip */ @@ -41,7 +36,7 @@ struct uac_rtd_params { void *rbuf; unsigned int max_psize; /* MaxPacketSize of endpoint */ - struct uac_req *ureq; + struct usb_request **reqs; spinlock_t lock; }; @@ -82,10 +77,9 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) unsigned long flags, flags2; unsigned int hw_ptr; int status = req->status; - struct uac_req *ur = req->context; struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; - struct uac_rtd_params *prm = ur->pp; + struct uac_rtd_params *prm = req->context; struct snd_uac_chip *uac = prm->uac; /* i/f shutting down */ @@ -339,16 +333,16 @@ static inline void free_ep(struct uac_rtd_params *prm, struct usb_ep *ep) params = &audio_dev->params; for (i = 0; i < params->req_number; i++) { - if (prm->ureq[i].req) { - if (usb_ep_dequeue(ep, prm->ureq[i].req)) - usb_ep_free_request(ep, prm->ureq[i].req); + if (prm->reqs[i]) { + if (usb_ep_dequeue(ep, prm->reqs[i])) + usb_ep_free_request(ep, prm->reqs[i]); /* * If usb_ep_dequeue() cannot successfully dequeue the * request, the request will be freed by the completion * callback. */ - prm->ureq[i].req = NULL; + prm->reqs[i] = NULL; } } @@ -377,22 +371,21 @@ int u_audio_start_capture(struct g_audio *audio_dev) usb_ep_enable(ep); for (i = 0; i < params->req_number; i++) { - if (!prm->ureq[i].req) { + if (!prm->reqs[i]) { req = usb_ep_alloc_request(ep, GFP_ATOMIC); if (req == NULL) return -ENOMEM; - prm->ureq[i].req = req; - prm->ureq[i].pp = prm; + prm->reqs[i] = req; req->zero = 0; - req->context = &prm->ureq[i]; + req->context = prm; req->length = req_len; req->complete = u_audio_iso_complete; req->buf = prm->rbuf + i * ep->maxpacket; } - if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC)) + if (usb_ep_queue(ep, prm->reqs[i], GFP_ATOMIC)) dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); } @@ -455,22 +448,21 @@ int u_audio_start_playback(struct g_audio *audio_dev) usb_ep_enable(ep); for (i = 0; i < params->req_number; i++) { - if (!prm->ureq[i].req) { + if (!prm->reqs[i]) { req = usb_ep_alloc_request(ep, GFP_ATOMIC); if (req == NULL) return -ENOMEM; - prm->ureq[i].req = req; - prm->ureq[i].pp = prm; + prm->reqs[i] = req; req->zero = 0; - req->context = &prm->ureq[i]; + req->context = prm; req->length = req_len; req->complete = u_audio_iso_complete; req->buf = prm->rbuf + i * ep->maxpacket; } - if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC)) + if (usb_ep_queue(ep, prm->reqs[i], GFP_ATOMIC)) dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); } @@ -515,9 +507,10 @@ int g_audio_setup(struct g_audio *g_audio, const char *pcm_name, uac->c_prm.uac = uac; prm->max_psize = g_audio->out_ep_maxpsize; - prm->ureq = kcalloc(params->req_number, sizeof(struct uac_req), - GFP_KERNEL); - if (!prm->ureq) { + prm->reqs = kcalloc(params->req_number, + sizeof(struct usb_request *), + GFP_KERNEL); + if (!prm->reqs) { err = -ENOMEM; goto fail; } @@ -537,9 +530,10 @@ int g_audio_setup(struct g_audio *g_audio, const char *pcm_name, uac->p_prm.uac = uac; prm->max_psize = g_audio->in_ep_maxpsize; - prm->ureq = kcalloc(params->req_number, sizeof(struct uac_req), - GFP_KERNEL); - if (!prm->ureq) { + prm->reqs = kcalloc(params->req_number, + sizeof(struct usb_request *), + GFP_KERNEL); + if (!prm->reqs) { err = -ENOMEM; goto fail; } @@ -592,8 +586,8 @@ int g_audio_setup(struct g_audio *g_audio, const char *pcm_name, snd_fail: snd_card_free(card); fail: - kfree(uac->p_prm.ureq); - kfree(uac->c_prm.ureq); + kfree(uac->p_prm.reqs); + kfree(uac->c_prm.reqs); kfree(uac->p_prm.rbuf); kfree(uac->c_prm.rbuf); kfree(uac); @@ -615,8 +609,8 @@ void g_audio_cleanup(struct g_audio *g_audio) if (card) snd_card_free(card); - kfree(uac->p_prm.ureq); - kfree(uac->c_prm.ureq); + kfree(uac->p_prm.reqs); + kfree(uac->c_prm.reqs); kfree(uac->p_prm.rbuf); kfree(uac->c_prm.rbuf); kfree(uac); From patchwork Mon Jan 18 08:49:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 365491 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp2061516jap; Mon, 18 Jan 2021 00:50:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJR758z5V6SA0z6evavYYSzieFT1EzQrDplgmmkEiQbevbcdjY9TB/HCh+6F5K1O7BC7WE X-Received: by 2002:a17:906:7253:: with SMTP id n19mr3536444ejk.543.1610959854055; Mon, 18 Jan 2021 00:50:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610959854; cv=none; d=google.com; s=arc-20160816; b=lGyqfyVTt5UJxNVNe4d5UddXrbwXhPA89jCr6uZ+uYDodQOYb5yDjU5Rp7xX2J3pnS RvVpEc2poU6wmQeE+MS+7zs/nC1WrgpEYc0LHyxhVH7SJhpoEOnZgCDXfpa0L3NDIJFY pP9zMqrPvTLrq8I89uJGRLosshwKuvFWyexb5qnPPv+1JLxc5Udr0G8AFbzvhPYzbM7o uO1u/uybUZKDq4sxLVoB6NK8rgayVuqJfNnDO+OG+y+h6d8Tm+rGyL0wU51/ngMwzzNP EBUakIsqTnRrFE8h8/x+pALYwrUheYSLLa9il0DHRcA7F9WblNjr71RK4xqQDnc57wLZ 5HmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YN9R4ncGY5I9okKgQc69PrWQgu7d0QiAoW90YzkPRN0=; b=yXEFCj9zyZ2wAfnzgj1Xaa0XMr2x4d0392LOu09QxeOrUf+6dKDA36YI5KDPqDSSp/ joB/Rdih0HfoIb0fsl1yZkZBvnKrAM5aDP0sjrvhm5aETadkFfW5V5B28AflPV+uV1mB gEPDLnqFj0nvm4xGtJK4fK9c/xuEDldhiDErunRtx200ti1M77eE0MGIO8UdzcuSdqnJ z//veyFuWDAExyKY26GSjPZzGKXPrRsMCa6CT//L0+p0j0gOwRptXAUjc1z5EBM2Ulic e2G4nqEAzuH3RcsYpfnSHjDs+PkXBl1oMyBl3xE7+6GX3+KMHYg5Jzj5+HN0w+K9EHQ4 /X8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=MV+Unwxt; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s24si7533246ejd.135.2021.01.18.00.50.53; Mon, 18 Jan 2021 00:50:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-usb-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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=MV+Unwxt; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388081AbhARIum (ORCPT + 3 others); Mon, 18 Jan 2021 03:50:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387991AbhARIua (ORCPT ); Mon, 18 Jan 2021 03:50:30 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D657C061573 for ; Mon, 18 Jan 2021 00:49:45 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id h17so12625716wmq.1 for ; Mon, 18 Jan 2021 00:49:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YN9R4ncGY5I9okKgQc69PrWQgu7d0QiAoW90YzkPRN0=; b=MV+UnwxtiGCI8jrwIqDhEbvHnsfQ5+GVMYufMM1BUhj6Lb0wjtNv7PNIFd8vp6JqrC IPGrI3FRR5IyfhysBMa4E1pu/9s+4VXHK6xIqE014azlv2aEVlQlKPevDPMrQ7WYMNn5 YqjqCO3lxFUuQYjev2zyPN4OeEMt+m85/lba3qSYiHxzKJ+r6KR+W+bWO73M4YZHMHum hPvc5Y9LiB9RH2C5MsIX3JjFX7GCwE+ay/jCUpIIIQS6aZmVqqZ7ifiSd7eo55gECvhY zvj/Bf54BV/n//RH4A5KfBNd5BZCmsaewhveucEqrWHo0mNFxA6mvLqerxcRRZvD6YIk BgNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YN9R4ncGY5I9okKgQc69PrWQgu7d0QiAoW90YzkPRN0=; b=O1pF+XjQO6ynYpkSr8HYHpdl64k4F+qfVvMKQWDyoXOSnZzTv4UWIMESvmnfMdW7c4 drto33eTIBVL5/WRJaLhNc4ED29GyHl2XFF+UxHoW5jly+D6zOJtN8HLzvXxqZeJEj2K h99aCfK8ZUu/QaKmii0+JlVSMeq/6UzTlFIH3R3u2zl+9ESwBZHUjMY43mqqIJj/5Dzn PGb4RTTQHdB33XKZr3gCccJNVVmeGBzGsR8YeVrsR7Pi6vM9tVhmMPuPiLe1lmIKmjJd XDJznzdFu6u1lqH2OGfzPlzTVcdxFYQmfK1Kl9+yWUJVPaXga8YXWdUoSSJFL6bz6tru YO/Q== X-Gm-Message-State: AOAM531pMSrWuZYsG79Gz6SQzrfqkE0WW3vaWxKv4IkTBffeIk4Ne0Gr mEdWaeBV9E2E3jZoM9Eq39v2Vg== X-Received: by 2002:a05:600c:1483:: with SMTP id c3mr19638067wmh.87.1610959783969; Mon, 18 Jan 2021 00:49:43 -0800 (PST) Received: from starbuck.lan (82-65-169-74.subs.proxad.net. [82.65.169.74]) by smtp.googlemail.com with ESMTPSA id a24sm18205619wmj.17.2021.01.18.00.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 00:49:43 -0800 (PST) From: Jerome Brunet To: Felipe Balbi , Greg Kroah-Hartman Cc: Jerome Brunet , Ruslan Bilovol , Jack Pham , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/4] usb: gadget: u_audio: clean up locking Date: Mon, 18 Jan 2021 09:49:31 +0100 Message-Id: <20210118084931.322861-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118084642.322510-1-jbrunet@baylibre.com> References: <20210118084642.322510-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org snd_pcm_stream_lock() is held when the ALSA .trigger() callback is called. The lock of 'struct uac_rtd_params' is not necessary since all its locking operation are done under the snd_pcm_stream_lock() too. Also, usb_request .complete() is called with irqs disabled, so saving and restoring the irqs is not necessary. Acked-by: Felipe Balbi Signed-off-by: Jerome Brunet --- drivers/usb/gadget/function/u_audio.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) -- 2.29.2 diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c index a1a1f4c8685c..265c4d805f81 100644 --- a/drivers/usb/gadget/function/u_audio.c +++ b/drivers/usb/gadget/function/u_audio.c @@ -36,9 +36,8 @@ struct uac_rtd_params { void *rbuf; unsigned int max_psize; /* MaxPacketSize of endpoint */ - struct usb_request **reqs; - spinlock_t lock; + struct usb_request **reqs; }; struct snd_uac_chip { @@ -74,7 +73,6 @@ static const struct snd_pcm_hardware uac_pcm_hardware = { static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) { unsigned int pending; - unsigned long flags, flags2; unsigned int hw_ptr; int status = req->status; struct snd_pcm_substream *substream; @@ -105,16 +103,14 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) if (!substream) goto exit; - snd_pcm_stream_lock_irqsave(substream, flags2); + snd_pcm_stream_lock(substream); runtime = substream->runtime; if (!runtime || !snd_pcm_running(substream)) { - snd_pcm_stream_unlock_irqrestore(substream, flags2); + snd_pcm_stream_unlock(substream); goto exit; } - spin_lock_irqsave(&prm->lock, flags); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { /* * For each IN packet, take the quotient of the current data @@ -141,8 +137,6 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) hw_ptr = prm->hw_ptr; - spin_unlock_irqrestore(&prm->lock, flags); - /* Pack USB load in ALSA ring buffer */ pending = runtime->dma_bytes - hw_ptr; @@ -166,12 +160,10 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) } } - spin_lock_irqsave(&prm->lock, flags); /* update hw_ptr after data is copied to memory */ prm->hw_ptr = (hw_ptr + req->actual) % runtime->dma_bytes; hw_ptr = prm->hw_ptr; - spin_unlock_irqrestore(&prm->lock, flags); - snd_pcm_stream_unlock_irqrestore(substream, flags2); + snd_pcm_stream_unlock(substream); if ((hw_ptr % snd_pcm_lib_period_bytes(substream)) < req->actual) snd_pcm_period_elapsed(substream); @@ -187,7 +179,6 @@ static int uac_pcm_trigger(struct snd_pcm_substream *substream, int cmd) struct uac_rtd_params *prm; struct g_audio *audio_dev; struct uac_params *params; - unsigned long flags; int err = 0; audio_dev = uac->audio_dev; @@ -198,8 +189,6 @@ static int uac_pcm_trigger(struct snd_pcm_substream *substream, int cmd) else prm = &uac->c_prm; - spin_lock_irqsave(&prm->lock, flags); - /* Reset */ prm->hw_ptr = 0; @@ -216,8 +205,6 @@ static int uac_pcm_trigger(struct snd_pcm_substream *substream, int cmd) err = -EINVAL; } - spin_unlock_irqrestore(&prm->lock, flags); - /* Clear buffer after Play stops */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && !prm->ss) memset(prm->rbuf, 0, prm->max_psize * params->req_number); @@ -280,14 +267,12 @@ static int uac_pcm_open(struct snd_pcm_substream *substream) runtime->hw = uac_pcm_hardware; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - spin_lock_init(&uac->p_prm.lock); runtime->hw.rate_min = p_srate; runtime->hw.formats = uac_ssize_to_fmt(p_ssize); runtime->hw.channels_min = num_channels(p_chmask); runtime->hw.period_bytes_min = 2 * uac->p_prm.max_psize / runtime->hw.periods_min; } else { - spin_lock_init(&uac->c_prm.lock); runtime->hw.rate_min = c_srate; runtime->hw.formats = uac_ssize_to_fmt(c_ssize); runtime->hw.channels_min = num_channels(c_chmask);