From patchwork Sun Jun 10 10:51:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10456599 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 09895601F7 for ; Sun, 10 Jun 2018 10:51:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F04072625B for ; Sun, 10 Jun 2018 10:51:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E508526490; Sun, 10 Jun 2018 10:51:43 +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 8E01326861 for ; Sun, 10 Jun 2018 10:51:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932194AbeFJKvh (ORCPT ); Sun, 10 Jun 2018 06:51:37 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:38404 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753868AbeFJKve (ORCPT ); Sun, 10 Jun 2018 06:51:34 -0400 Received: by mail-wr0-f196.google.com with SMTP id e18-v6so9182005wrs.5 for ; Sun, 10 Jun 2018 03:51:34 -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=f1EuAbh58/92FTkN08h0juA82+Ic7GMk48BSyskH5Iw=; b=R/2bT70IadU+v1MRDefWrYlAAvx5xyjQNK75yIKSaEEQi6hMAvA2B1QBoQuMrKcElc lM27bpuHGcwxGB3lFFyGgkIJU+Jjl+NFTL5gMpZb9d96K/KsTCRKUYU3ZjH25aNZVtIG Go1cAx4lg8f57BP+RJ/AVBGe642jAZVLw57vOfmz1SYDUFnW7YZZfsYOccYXeDqujy0e r0gkKXdpg3dM5KS6H6zL8Zqgcf8dT73ZOREB+QTyMuF5D/Vp4LQhGSge8K7Lvki3OElp p9tZvVAI6hQlap/a1wXBw+6WMTPfFrZqwqsL3Z8WXcQ0I1FY4hi0MFtf1/4K389hOKo6 4iMw== X-Gm-Message-State: APt69E1dqhCf+xV0nHyrnXtx3IZNm46Nuj+McfdGEuD5gWqeyiu552Jk 9nWfekETtbgBvlKi0y/11Z7oVD2yZ+U= X-Google-Smtp-Source: ADUXVKLe/NM+m2NtB/oC9DEVtBypIRtJbyrVGQxOupQWu6icrptLT0XW1DjSlCKSzugbRT/0rA1EOg== X-Received: by 2002:adf:aef3:: with SMTP id y106-v6mr10596815wrc.53.1528627893616; Sun, 10 Jun 2018 03:51:33 -0700 (PDT) Received: from localhost.localdomain ([151.66.62.211]) by smtp.gmail.com with ESMTPSA id 194-v6sm8638793wml.20.2018.06.10.03.51.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Jun 2018 03:51:33 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, sgruszka@redhat.com Subject: [RFC v3 01/19] mt76x2: use completion instead of wait_queue for mcu rx queue Date: Sun, 10 Jun 2018 12:51:08 +0200 Message-Id: <20180610105126.28425-2-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.17.1 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 dc12bbdbb2ee..a0a2f7727df9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x2.h @@ -50,7 +50,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); }