From patchwork Sun May 20 08:15:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10413239 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1CF6C602A0 for ; Sun, 20 May 2018 08:15:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11A5B28703 for ; Sun, 20 May 2018 08:15:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06A3B28714; Sun, 20 May 2018 08:15:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FB1528703 for ; Sun, 20 May 2018 08:15:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751067AbeETIPh (ORCPT ); Sun, 20 May 2018 04:15:37 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:35139 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750869AbeETIPd (ORCPT ); Sun, 20 May 2018 04:15:33 -0400 Received: by mail-wr0-f196.google.com with SMTP id i14-v6so13028543wre.2 for ; Sun, 20 May 2018 01:15:32 -0700 (PDT) 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; bh=3YkY3KzdnGheqxgjYPgKGvoA6C3wp6Mf2m/bzJcHa9I=; b=lXTKQ+sfjw/SPDcesRuH05w9q4jgsOOjVJF7gHbSl0SDjJtymcU/hhdOBK9nXbRpNR H6sng5XoQZyvDWVLRm63J19ugvLYe4LhYSbmJuspYL/9YJzqRG3eWFAVdtQuwt8+0f51 +eCW248OapE+71tuXPmj5WR31KjlaGxr048ZkFHKKKULfPsyRqbcKUqGM5gfYAswo5xz XWNZPerIIQarVL8SdIxyWgnvofF6o9OuOE3LoDA1m5O9vSC8w4TEiG6eXO6bUWq2P+xN 2ZWj7rJgO7g7DGYLw9ON3KXVhALOT1QUfAm2q6uq49+NI+Gm+FloZNJnjoFtjrRDkLen moLg== X-Gm-Message-State: ALKqPwcQrb5L1IVU4Jps/NoRglfZRnx7UixqIhaJ9YMg1TcrJ4bMvX6v SXBn0RZ4ksMOOAt2o+1QEPrxDw== X-Google-Smtp-Source: AB8JxZplDa6/43BTEgpFgK8+ubf/QNjwUi7pkOY7l14uJuB0jtuqBGSOaylA6AiZuT94Y+w3087FKg== X-Received: by 2002:adf:e8c3:: with SMTP id k3-v6mr2796533wrn.182.1526804132215; Sun, 20 May 2018 01:15:32 -0700 (PDT) Received: from localhost.localdomain ([151.66.25.157]) by smtp.gmail.com with ESMTPSA id z7-v6sm13981716wrg.56.2018.05.20.01.15.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 May 2018 01:15:31 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, sgruszka@redhat.com Subject: [RFC v2 01/18] mt76x2: use completion instead of wait_queue for mcu rx queue Date: Sun, 20 May 2018 10:15:05 +0200 Message-Id: <20180520081522.10163-2-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.16.3 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to reuse mcu related code supporting mt76x2u based devices, use completion instead of wait_queue for mcu responses queue Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76x2.h | 2 +- drivers/net/wireless/mediatek/mt76/mt76x2_dma.c | 4 ++-- drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2.h b/drivers/net/wireless/mediatek/mt76/mt76x2.h index a5d1255e4b9c..a31602d9310e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x2.h @@ -47,7 +47,7 @@ struct mt76x2_mcu { struct mutex mutex; - wait_queue_head_t wait; + struct completion resp_cmpl; struct sk_buff_head res_q; u32 msg_seq; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_dma.c b/drivers/net/wireless/mediatek/mt76/mt76x2_dma.c index fd1ec4743e0b..ab71b6e6c6dc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_dma.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_dma.c @@ -74,7 +74,7 @@ void mt76x2_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, if (q == MT_RXQ_MCU) { skb_queue_tail(&dev->mcu.res_q, skb); - wake_up(&dev->mcu.wait); + complete(&dev->mcu.resp_cmpl); return; } @@ -139,7 +139,7 @@ int mt76x2_dma_init(struct mt76x2_dev *dev) mt76_dma_attach(&dev->mt76); - init_waitqueue_head(&dev->mcu.wait); + init_completion(&dev->mcu.resp_cmpl); skb_queue_head_init(&dev->mcu.res_q); tasklet_init(&dev->tx_tasklet, mt76x2_tx_tasklet, (unsigned long) dev); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c index dfd36d736b06..3e2a7216ffdd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c @@ -61,8 +61,7 @@ mt76x2_mcu_get_response(struct mt76x2_dev *dev, unsigned long expires) return NULL; timeout = expires - jiffies; - wait_event_timeout(dev->mcu.wait, !skb_queue_empty(&dev->mcu.res_q), - timeout); + wait_for_completion_timeout(&dev->mcu.resp_cmpl, timeout); return skb_dequeue(&dev->mcu.res_q); }