Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1188358ybk; Sat, 16 May 2020 03:53:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBpjSocwfVjuncLvOAaNBpR8JZ10lFrnPyn3K++9GABb/96+87UOc3zchGmmTsXv1We8Xz X-Received: by 2002:a17:906:d8c1:: with SMTP id re1mr7162451ejb.184.1589626386558; Sat, 16 May 2020 03:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589626386; cv=none; d=google.com; s=arc-20160816; b=cWCfaEI1eecQD3ucAyV8Deelaxau+T5xByXsUAKjdp+54ewuk/E96No+yZulDiHQiS D6NkCmPI/8ISB8DMb1iINlXeOWOamE7jfmzNO1JviOF1x0J55/341J6XfMqsaxy7Omfu LvrmHLNJtvqo4uLe8tAhXqlAvg1aObIaesHS4lZcIzN+xqB+HHhph26dkg5G30Ig1yN3 P+9quanUa0q159WsH5LceJefaye+oKCMyOM66JV6Mw1YAYBl2Ch/HB+m+PUtBP89lsfU z/e0JHvJS3yzm8iF1KTweSm7EdNB63iI/Yq43U3f0f/RJPb5PXXCUUz+imG+hKf+HSlM T8Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:mime-version:user-agent:date:message-id:subject :from:cc:to:dkim-signature; bh=lEXuPvFGjE4malU7fQB2EUdQISjNfzYyGgcDPxh2TpY=; b=ApLJAXgH7KdVWpZMG4/yiO0rmfRICBuc7Gd3rA8Xk3vGGw1EEYxIOo8/2fAPIj1ehu /A9Sv1JWGCzZq4PhMAxmS/B7ysbeK3kh3RgVGBp+a2mLSRTJ5TtTg72r0lYvjrgTlvGs TdLJLM7Na5qfbmDbBNTcHvzEnkfK0xkvIePvv5hV8RG5it278rctv1Ozxef/ak+sA2hH m0cjD3OARJ1S1Yxpm9lpDiTkntxbc6KstyzaVUoK7xhIQC/bqiDI9s1KC2Bg8TxNwJRW qjYTfCf8Os2mTV/2vK9m+VxvnRETQN5rO5OscZ0aUBk5u6RnrXe+/IpgWkvz/iSwNFBY YPXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ROksojIE; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v21si3065943ejx.356.2020.05.16.03.52.39; Sat, 16 May 2020 03:53:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@gmail.com header.s=20161025 header.b=ROksojIE; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726197AbgEPKun (ORCPT + 99 others); Sat, 16 May 2020 06:50:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725917AbgEPKun (ORCPT ); Sat, 16 May 2020 06:50:43 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FA84C061A0C for ; Sat, 16 May 2020 03:50:42 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id h17so6282347wrc.8 for ; Sat, 16 May 2020 03:50:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=lEXuPvFGjE4malU7fQB2EUdQISjNfzYyGgcDPxh2TpY=; b=ROksojIEr6T11iwZiyy0Wxqos6BCJayDicZzAa9sQUtvbLFJ0UbHS2HaMPihlf+6rN rhKD5IGnTlR4TAlLOMxUDWFRBoHO3ettjdEMHkzYCMPP3M728lS0/xZ7LJhjyEshelSm k3GwtVvkLLVuYPS3g4c9Gn79j+ntnQhYuMrnZSw+vtTzbdyj2qK1YCAC1sleWZ5QU+nm r1AyAL5lMPc/oxlyr+WmvUovGuQ+eztk1+RfURedDA6+mgMhuMwXLkDk8GRQizkANOPK fEcDO/FYIsLJkOtqlYNx+KGTJqRo5b7B8S11JlT3o2D8B3YFkAFBoye9bUAJps9EJRCj iInA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=lEXuPvFGjE4malU7fQB2EUdQISjNfzYyGgcDPxh2TpY=; b=SnRebaok/vSyIXeV/yCP847eBXaKI76slQjSmfkSOUQCCAMKEbjAeyH7GSLbILuc/f kjhjfSir42wC2edMYbC/K0IOYqsqRkLURWuPGI0nmfyvKtE9bWjGdxhO3YWQsZDjdvRr ZoZvwexgUCvyE6M0FS1cSJM2FZycb68F2YjalxTksWH5pQiLO3G1aGKzbng5DDFRQWEA b65oQPwi4xyUKy36J5al5BoW4S+H/OeXLJqzA6wTn3+3NB41W9+4iVEQDNSdSYmRLhfC qaXNLA9qHj3iOYX+hGgU9dDcnzG7M4zvigJmIM0lbGW0L7D8NRPipFHYhLRVPbgU3hi4 5tog== X-Gm-Message-State: AOAM53235G+qq0RCwWaHV4eF9lWSZ+aUhdbKSLEla45bnU9F84VYUo7F 0eH191UtA9gy89eOuLvk/srToLCN X-Received: by 2002:a5d:4c86:: with SMTP id z6mr8702803wrs.279.1589626240978; Sat, 16 May 2020 03:50:40 -0700 (PDT) Received: from [192.168.43.18] ([185.69.145.77]) by smtp.gmail.com with ESMTPSA id m65sm7413289wmm.17.2020.05.16.03.50.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 16 May 2020 03:50:40 -0700 (PDT) To: Greg Kroah-Hartman Cc: "devel@driverdev.osuosl.org" , linux-wireless@vger.kernel.org From: Malcolm Priestley Subject: [PATCH 4/4] staging: vt6656: use usb_anchor for tx queue. Message-ID: <077f42f8-4f7f-adc4-5a14-955165cef9f1@gmail.com> Date: Sat, 16 May 2020 11:50:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Use usb_anchor to track tx submitted urbs and initialize the urb as needed in vnt_tx_context. Signed-off-by: Malcolm Priestley --- drivers/staging/vt6656/device.h | 2 +- drivers/staging/vt6656/main_usb.c | 18 ++++-------------- drivers/staging/vt6656/usbpipe.c | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 08294b21c4e9..d1b19dcaf991 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -238,7 +238,6 @@ struct vnt_rcb { struct vnt_usb_send_context { void *priv; struct sk_buff *skb; - struct urb *urb; struct ieee80211_hdr *hdr; void *tx_buffer; unsigned int buf_len; @@ -292,6 +291,7 @@ struct vnt_private { /* Variables to track resources for the BULK Out Pipe */ struct vnt_usb_send_context *tx_context[CB_MAX_TX_DESC]; + struct usb_anchor tx_submitted; u32 num_tx_context; /* Variables to track resources for the Interrupt In Pipe */ diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 930ee424ecdf..c0169e32621b 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -445,17 +445,13 @@ static void vnt_free_tx_bufs(struct vnt_private *priv) struct vnt_usb_send_context *tx_context; int ii; + usb_kill_anchored_urbs(&priv->tx_submitted); + for (ii = 0; ii < priv->num_tx_context; ii++) { tx_context = priv->tx_context[ii]; if (!tx_context) continue; - /* deallocate URBs */ - if (tx_context->urb) { - usb_kill_urb(tx_context->urb); - usb_free_urb(tx_context->urb); - } - kfree(tx_context); } } @@ -496,6 +492,8 @@ static int vnt_alloc_bufs(struct vnt_private *priv) struct vnt_rcb *rcb; int ii; + init_usb_anchor(&priv->tx_submitted); + for (ii = 0; ii < priv->num_tx_context; ii++) { tx_context = kmalloc(sizeof(*tx_context), GFP_KERNEL); if (!tx_context) { @@ -506,14 +504,6 @@ static int vnt_alloc_bufs(struct vnt_private *priv) priv->tx_context[ii] = tx_context; tx_context->priv = priv; tx_context->pkt_no = ii; - - /* allocate URBs */ - tx_context->urb = usb_alloc_urb(0, GFP_KERNEL); - if (!tx_context->urb) { - ret = -ENOMEM; - goto free_tx; - } - tx_context->in_use = false; } diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 43f1ef32a9ce..2164f45e13ab 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -456,7 +456,7 @@ int vnt_tx_context(struct vnt_private *priv, struct vnt_usb_send_context *context) { int status; - struct urb *urb = context->urb; + struct urb *urb; if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) { context->in_use = false; @@ -468,6 +468,12 @@ int vnt_tx_context(struct vnt_private *priv, return -E2BIG; } + urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!urb) { + context->in_use = false; + return -ENOMEM; + } + usb_fill_bulk_urb(urb, priv->usb, usb_sndbulkpipe(priv->usb, 3), @@ -476,12 +482,16 @@ int vnt_tx_context(struct vnt_private *priv, vnt_tx_context_complete, context); + usb_anchor_urb(urb, &priv->tx_submitted); + status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { dev_dbg(&priv->usb->dev, "Submit Tx URB failed %d\n", status); - + usb_unanchor_urb(urb); context->in_use = false; } + usb_free_urb(urb); + return status; } -- 2.25.1