From patchwork Sat Aug 25 10:40:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576059 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-2.web.codeaurora.org (Postfix) with ESMTP id 4617D174C for ; Sat, 25 Aug 2018 10:41:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 233072B009 for ; Sat, 25 Aug 2018 10:41:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 068322AFC2; Sat, 25 Aug 2018 10:41:09 +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 994292AE6D for ; Sat, 25 Aug 2018 10:41:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726712AbeHYOTi (ORCPT ); Sat, 25 Aug 2018 10:19:38 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39667 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726624AbeHYOTi (ORCPT ); Sat, 25 Aug 2018 10:19:38 -0400 Received: by mail-wr1-f65.google.com with SMTP id o37-v6so9448039wrf.6 for ; Sat, 25 Aug 2018 03:41:03 -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=CcnPklmROzl1quW51pHcm/43LmaYboCrl835RGLsu0g=; b=pQZRoZG3Y+p4JQ7j++l0xHTrfnRlnAEAQcWsmMVRPR1oy0HhZDvRm1LrefzAMIVWY5 MuyfFb3Lr9uarAsYFOD42WCOJaG6IYhf+j9GLQ7NE1Cf1iXkcQMi+AT38HHM/EQEiYHY TWA8pF/lWkFKUyXJJsN+qHQSvCRCxRS5+fEHZlrk/ABdxAg2Pf7KloMSvq1dYw3oodhu Uu1xZqGLDOOEamjuvaJMMqLd7lzp7/zpz9vmLqjhbRuWDshzMtujgXJCpHkRxMxjoxn3 mGSpd12btxQ9pMyx1uteRPabo+F8MX6nKZjncQxJ3/cSzPEYisg6G25bpS9sliVWDlt9 HQzQ== X-Gm-Message-State: APzg51B1Ghn9U/xCBvrt/cud3OV21TkVQAnXkq/t6lLZQXqfE6rrWA3C qhpszg8nNbMllZaP3dFe8BzXmg== X-Google-Smtp-Source: ANB0VdZQl9h9XLd25XmurZwUgi0w6zAyrcXKiHJNgx8KOZmm6m2fRe5D/r7eDPCngyXLRwNprduApQ== X-Received: by 2002:a5d:61c1:: with SMTP id q1-v6mr3749500wrv.33.1535193662949; Sat, 25 Aug 2018 03:41:02 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:02 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 01/16] mt76: move mt76_reg_pair definition in mt76.h Date: Sat, 25 Aug 2018 12:40:41 +0200 Message-Id: <20180825104056.9130-2-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Move common definition of mt76_reg_pair in mt76.h and remove duplicated code in mt76x2_init_common.c Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76.h | 5 +++++ drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h | 5 ----- .../net/wireless/mediatek/mt76/mt76x2_init_common.c | 11 +++-------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index b02b4191ef37..fc27260080af 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -53,6 +53,11 @@ enum mt76_txq_id { __MT_TXQ_MAX }; +struct mt76_reg_pair { + u32 reg; + u32 value; +}; + enum mt76_rxq_id { MT_RXQ_MAIN, MT_RXQ_MCU, diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h index 12f3dd1cc405..a694cc46fac8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h @@ -219,11 +219,6 @@ struct mt76x0_wcid { u8 tx_rate_nss; }; -struct mt76_reg_pair { - u32 reg; - u32 value; -}; - struct mt76x0_rxwi; extern const struct ieee80211_ops mt76x0_ops; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_init_common.c b/drivers/net/wireless/mediatek/mt76/mt76x2_init_common.c index 953effec8c1a..6af26350c177 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_init_common.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_init_common.c @@ -47,11 +47,6 @@ struct ieee80211_rate mt76x2_rates[] = { }; EXPORT_SYMBOL_GPL(mt76x2_rates); -struct mt76x2_reg_pair { - u32 reg; - u32 value; -}; - static void mt76x2_set_wlan_state(struct mt76x2_dev *dev, bool enable) { @@ -93,7 +88,7 @@ EXPORT_SYMBOL_GPL(mt76x2_reset_wlan); static void mt76x2_write_reg_pairs(struct mt76x2_dev *dev, - const struct mt76x2_reg_pair *data, int len) + const struct mt76_reg_pair *data, int len) { while (len > 0) { mt76_wr(dev, data->reg, data->value); @@ -128,7 +123,7 @@ void mt76_write_mac_initvals(struct mt76x2_dev *dev) FIELD_PREP(MT_PROT_CFG_NAV, 1) | \ FIELD_PREP(MT_PROT_CFG_TXOP_ALLOW, 0x3f)) - static const struct mt76x2_reg_pair vals[] = { + static const struct mt76_reg_pair vals[] = { /* Copied from MediaTek reference source */ { MT_PBF_SYS_CTRL, 0x00080c00 }, { MT_PBF_CFG, 0x1efebcff }, @@ -184,7 +179,7 @@ void mt76_write_mac_initvals(struct mt76x2_dev *dev) { MT_PROT_AUTO_TX_CFG, 0x00830083 }, { MT_HT_CTRL_CFG, 0x000001ff }, }; - struct mt76x2_reg_pair prot_vals[] = { + struct mt76_reg_pair prot_vals[] = { { MT_CCK_PROT_CFG, DEFAULT_PROT_CFG_CCK }, { MT_OFDM_PROT_CFG, DEFAULT_PROT_CFG_OFDM }, { MT_MM20_PROT_CFG, DEFAULT_PROT_CFG_20 }, From patchwork Sat Aug 25 10:40:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576061 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-2.web.codeaurora.org (Postfix) with ESMTP id 5984914BD for ; Sat, 25 Aug 2018 10:41:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 481072AEE7 for ; Sat, 25 Aug 2018 10:41:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C8422AF1F; Sat, 25 Aug 2018 10:41:09 +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 B987B2AEE7 for ; Sat, 25 Aug 2018 10:41:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726776AbeHYOTj (ORCPT ); Sat, 25 Aug 2018 10:19:39 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36973 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbeHYOTj (ORCPT ); Sat, 25 Aug 2018 10:19:39 -0400 Received: by mail-wm0-f65.google.com with SMTP id n11-v6so3849615wmc.2 for ; Sat, 25 Aug 2018 03:41:04 -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=4xBbERyQOtISFMnh9oSyb9XM7lpJ6qdF/QTvEzQL7cc=; b=j5CN8mHfzVHAX13Iud1s9cjpMDjZS+z1Z9wwUMviOOXJVbYHZSfMP06p8AncvZ4aO4 TbYPYt/P0hHvtdPFNiWkHdR1W82Vyvr9nQl9YRPnZb0EFtgYVZn70GmWvYP/zB/k1Ujd AXmMshszEnbhD4ErTizmgdgfFHiKAQqv5nsbOXyJoRBh2hsabXMX3Q0Uv+QvfVwNb/KV h3isEZEPG3DlVbWyG+uBcbeAFj/kp7LWwK4XsFU/Ah3D1JIR0QHltEpUkf8TqTS4ERqd N6T7qAioHLe8sJthHNWQQyswweryAlR78U0Rv6f+XjDcyzrXo0+1i1fdR+C6FplUtQbR uWEg== X-Gm-Message-State: APzg51AP1G/4jPmsy0u9xe5UtY2lzbd2OzPBYlmdl8Xx6IVPXq9vj7xg 0bxG/lg+VKLY8zZt0l6u0EZ80Q== X-Google-Smtp-Source: ANB0Vdb/6vpW17BpsuYf7EUzRKh+VAA3Zw4nwCBSU/KfhokcDvFT2+lsxu2+aZQbJVDSsGGIRoAT/w== X-Received: by 2002:a1c:1092:: with SMTP id 140-v6mr859326wmq.120.1535193664009; Sat, 25 Aug 2018 03:41:04 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:03 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 02/16] mt76: split __mt76u_mcu_send_msg and mt76u_mcu_send_msg routines Date: Sat, 25 Aug 2018 12:40:42 +0200 Message-Id: <20180825104056.9130-3-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Split __mt76u_mcu_send_msg and mt76u_mcu_send_msg in order to be reused by mt76x0 driver in usb mcu layer unification between mt76x0 and mt76x2u drivers Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76.h | 2 ++ drivers/net/wireless/mediatek/mt76/usb_mcu.c | 27 +++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index fc27260080af..5579b90afee9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -623,6 +623,8 @@ int mt76u_mcu_fw_send_data(struct mt76_dev *dev, const void *data, int data_len, u32 max_payload, u32 offset); void mt76u_mcu_complete_urb(struct urb *urb); struct sk_buff *mt76u_mcu_msg_alloc(const void *data, int len); +int __mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, + int cmd, bool wait_resp); int mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, int cmd, bool wait_resp); void mt76u_mcu_fw_reset(struct mt76_dev *dev); diff --git a/drivers/net/wireless/mediatek/mt76/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/usb_mcu.c index ebf3e7ffb26b..4039b0b709a0 100644 --- a/drivers/net/wireless/mediatek/mt76/usb_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/usb_mcu.c @@ -86,8 +86,8 @@ static int mt76u_mcu_wait_resp(struct mt76_dev *dev, u8 seq) return -ETIMEDOUT; } -int mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, - int cmd, bool wait_resp) +int __mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, + int cmd, bool wait_resp) { struct usb_interface *intf = to_usb_interface(dev->dev); struct usb_device *udev = interface_to_usbdev(intf); @@ -100,8 +100,6 @@ int mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, if (test_bit(MT76_REMOVED, &dev->state)) return 0; - mutex_lock(&usb->mcu.mutex); - pipe = usb_sndbulkpipe(udev, usb->out_ep[MT_EP_OUT_INBAND_CMD]); if (wait_resp) { seq = ++usb->mcu.msg_seq & 0xf; @@ -114,22 +112,33 @@ int mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, MT_MCU_MSG_TYPE_CMD; ret = mt76u_skb_dma_info(skb, CPU_TX_PORT, info); if (ret) - goto out; + return ret; ret = usb_bulk_msg(udev, pipe, skb->data, skb->len, &sent, 500); if (ret) - goto out; + return ret; if (wait_resp) ret = mt76u_mcu_wait_resp(dev, seq); -out: - mutex_unlock(&usb->mcu.mutex); - consume_skb(skb); return ret; } +EXPORT_SYMBOL_GPL(__mt76u_mcu_send_msg); + +int mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, + int cmd, bool wait_resp) +{ + struct mt76_usb *usb = &dev->usb; + int err; + + mutex_lock(&usb->mcu.mutex); + err = __mt76u_mcu_send_msg(dev, skb, cmd, wait_resp); + mutex_unlock(&usb->mcu.mutex); + + return err; +} EXPORT_SYMBOL_GPL(mt76u_mcu_send_msg); void mt76u_mcu_fw_reset(struct mt76_dev *dev) From patchwork Sat Aug 25 10:40:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576065 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-2.web.codeaurora.org (Postfix) with ESMTP id 6C0391926 for ; Sat, 25 Aug 2018 10:41:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CC832AE30 for ; Sat, 25 Aug 2018 10:41:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 512622AFC2; Sat, 25 Aug 2018 10:41:09 +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 E3DCA2AFB5 for ; Sat, 25 Aug 2018 10:41:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726821AbeHYOTk (ORCPT ); Sat, 25 Aug 2018 10:19:40 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40668 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726624AbeHYOTk (ORCPT ); Sat, 25 Aug 2018 10:19:40 -0400 Received: by mail-wr1-f68.google.com with SMTP id n2-v6so9429073wrw.7 for ; Sat, 25 Aug 2018 03:41:05 -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=9hvf1tb/hVQu6qEkDJTVRe+7M4jU/MejQpXvrig5aVI=; b=XCJQ/mTPmlaiKcoC6seTV8WwJkQ8d2uEkobI6k/x45U5HhgbjF4SOFYRJLh/HKnswF 24hjQtjNEKxofdNzs4wbDZDYyaXBdoay2cfAgGil6Qn4hMFHgj3r7EKLKJIIsY6iW5VC QqEUCGv5Zp/Sv8oqRrp2gMZuska9OwrIT/VwHK/7gJx5PXAAGiH/+tPrmpyrIlNOe3O5 T98zhymfImN3JuSuOd415Sltwxks8zBHDdr1rsStbOG+C5Jp7oNeNoroMCteFZlHt1+Z 16mrkKA0YOaWKTbxpK+jZ2kqPA78/HUqlt5n+1bgJFzOESPT2DDIK8g73BhJkyOXKNxw JDFQ== X-Gm-Message-State: APzg51AOHtY4ICyyDIcMpdllkr6dFv2t/P+IcwLSsKbpS5Yn12oIOWYw 9IZxkxfYHJ+f6Gju/kC/0aTbROp2z+k= X-Google-Smtp-Source: ANB0VdZzt6w08xQl4hfnTPh8d6NqdJqv+mveOeB+eH07GKAiHvKRQkBb4Nkr3SiLKSlrPIWmx2ZOAw== X-Received: by 2002:adf:8425:: with SMTP id 34-v6mr3629963wrf.127.1535193665051; Sat, 25 Aug 2018 03:41:05 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:04 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 03/16] mt76: move mt76x2u_mcu_deinit routine in mt76-usb module Date: Sat, 25 Aug 2018 12:40:43 +0200 Message-Id: <20180825104056.9130-4-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Move mt76x2u_mcu_deinit routine in usb_mcu layer in order to be reused by mt76x0 driver in usb mcu layer unification between mt76x0 and mt76x2u drivers Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76.h | 1 + drivers/net/wireless/mediatek/mt76/mt76x2u.h | 1 - drivers/net/wireless/mediatek/mt76/mt76x2u_init.c | 2 +- drivers/net/wireless/mediatek/mt76/mt76x2u_mcu.c | 8 -------- drivers/net/wireless/mediatek/mt76/usb_mcu.c | 9 +++++++++ 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 5579b90afee9..f84f35c2e37a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -629,5 +629,6 @@ int mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, int cmd, bool wait_resp); void mt76u_mcu_fw_reset(struct mt76_dev *dev); int mt76u_mcu_init_rx(struct mt76_dev *dev); +void mt76u_mcu_deinit(struct mt76_dev *dev); #endif diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2u.h b/drivers/net/wireless/mediatek/mt76/mt76x2u.h index 008092f0cd8a..a83c17cb6be5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2u.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x2u.h @@ -65,7 +65,6 @@ int mt76x2u_mcu_load_cr(struct mt76x2_dev *dev, u8 type, u8 temp_level, u8 channel); int mt76x2u_mcu_init(struct mt76x2_dev *dev); int mt76x2u_mcu_fw_init(struct mt76x2_dev *dev); -void mt76x2u_mcu_deinit(struct mt76x2_dev *dev); int mt76x2u_alloc_queues(struct mt76x2_dev *dev); void mt76x2u_queues_deinit(struct mt76x2_dev *dev); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2u_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2u_init.c index 4986f5388222..48b0b941c0fe 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2u_init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2u_init.c @@ -312,5 +312,5 @@ void mt76x2u_cleanup(struct mt76x2_dev *dev) mt76x2u_mcu_set_radio_state(dev, false); mt76x2u_stop_hw(dev); mt76u_queues_deinit(&dev->mt76); - mt76x2u_mcu_deinit(dev); + mt76u_mcu_deinit(&dev->mt76); } diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2u_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x2u_mcu.c index 22c16d638baa..31677e898427 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2u_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2u_mcu.c @@ -453,11 +453,3 @@ int mt76x2u_mcu_init(struct mt76x2_dev *dev) return mt76x2u_mcu_set_radio_state(dev, true); } - -void mt76x2u_mcu_deinit(struct mt76x2_dev *dev) -{ - struct mt76_usb *usb = &dev->mt76.usb; - - usb_kill_urb(usb->mcu.res.urb); - mt76u_buf_free(&usb->mcu.res); -} diff --git a/drivers/net/wireless/mediatek/mt76/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/usb_mcu.c index 4039b0b709a0..1edc5c3d637b 100644 --- a/drivers/net/wireless/mediatek/mt76/usb_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/usb_mcu.c @@ -250,3 +250,12 @@ int mt76u_mcu_init_rx(struct mt76_dev *dev) return err; } EXPORT_SYMBOL_GPL(mt76u_mcu_init_rx); + +void mt76u_mcu_deinit(struct mt76_dev *dev) +{ + struct mt76_usb *usb = &dev->usb; + + usb_kill_urb(usb->mcu.res.urb); + mt76u_buf_free(&usb->mcu.res); +} +EXPORT_SYMBOL_GPL(mt76u_mcu_deinit); From patchwork Sat Aug 25 10:40:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576067 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-2.web.codeaurora.org (Postfix) with ESMTP id 288E414BD for ; Sat, 25 Aug 2018 10:41:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A19E2AE30 for ; Sat, 25 Aug 2018 10:41:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EBD62AFB5; Sat, 25 Aug 2018 10:41:12 +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 A4E452AE30 for ; Sat, 25 Aug 2018 10:41:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726887AbeHYOTm (ORCPT ); Sat, 25 Aug 2018 10:19:42 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35375 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726624AbeHYOTm (ORCPT ); Sat, 25 Aug 2018 10:19:42 -0400 Received: by mail-wm0-f66.google.com with SMTP id o18-v6so3864492wmc.0 for ; Sat, 25 Aug 2018 03:41:06 -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=cuPjx6fHiUuYiqBIWfJSfSbgEbUs9jvLu/Sw8UmmEJI=; b=QCPqOz0ez6vsXhW6a6PdhM4pw86nOSna9qTur8HqWd4xkTaV5dG77H8mNOyZt4ktwa E1w4QrpItOMWcbEFnD55OXwBrto6QHDBB1jgtIrQOoBs+h+kUa572Mfu4s/DDzMgjfHt dIqOCx4EVC4yhLEJpRhaPaV7PVokx4YsnoWFiDX+nfMCxkQCZL8cphOW856ukTZqFcar vzzPVYlF+Ah4rFz7A13wr23mSRMwTIUrkg3BYT/QXqI5fHGvh0cv/A5R8hUIzWD8iqWn LLjHJ+lhK2g+3nfmJ9DT/qTcj9xLD5gTKrIpSNe8CeGcsKzLG5F8Y/8ofcEJevLmUZ6x Rosg== X-Gm-Message-State: APzg51A74jdSbE8NM2f9lyfZua/SrMfbWpOmLmdc1RKM1wwiCZQTVE1o 5RF3WQ316wjO2NayGxlmuCpNVw== X-Google-Smtp-Source: ANB0Vdab38aC+wAR8SzMpA/Xm+sC0AEXl0UOVcSTf+GioYv/JHX8Rs/2V3UZ2HAAFle0m7R4jwfnGQ== X-Received: by 2002:a1c:b6d6:: with SMTP id g205-v6mr957073wmf.17.1535193666100; Sat, 25 Aug 2018 03:41:06 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:05 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 04/16] mt76: add multiple regs read support to usb_mcu layer Date: Sat, 25 Aug 2018 12:40:44 +0200 Message-Id: <20180825104056.9130-5-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Introduce multiple regs read support to mcu layer in mt76-usb module. Multiple regs read will be reused by mt76x0 driver in usb mcu layer unification between mt76x0 and mt76x2u drivers Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76.h | 6 +++ drivers/net/wireless/mediatek/mt76/usb_mcu.c | 39 +++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index f84f35c2e37a..e9e46612c7f3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -312,6 +312,12 @@ struct mt76_usb { struct completion cmpl; struct mt76u_buf res; u32 msg_seq; + + /* multiple reads */ + struct mt76_reg_pair *rp; + int rp_len; + u32 base; + bool burst; } mcu; }; diff --git a/drivers/net/wireless/mediatek/mt76/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/usb_mcu.c index 1edc5c3d637b..d80dbfafba6d 100644 --- a/drivers/net/wireless/mediatek/mt76/usb_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/usb_mcu.c @@ -49,12 +49,44 @@ void mt76u_mcu_complete_urb(struct urb *urb) } EXPORT_SYMBOL_GPL(mt76u_mcu_complete_urb); +static void +mt76u_multiple_mcu_reads(struct mt76_dev *dev, u8 *data, + int len) +{ + struct mt76_usb *usb = &dev->usb; + u32 reg, val; + int i; + + if (usb->mcu.burst) { + WARN_ON_ONCE(len / 4 != usb->mcu.rp_len); + + reg = usb->mcu.rp[0].reg - usb->mcu.base; + for (i = 0; i < usb->mcu.rp_len; i++) { + val = get_unaligned_le32(data + 4 * i); + usb->mcu.rp[i].reg = reg++; + usb->mcu.rp[i].value = val; + } + } else { + WARN_ON_ONCE(len / 8 != usb->mcu.rp_len); + + for (i = 0; i < usb->mcu.rp_len; i++) { + reg = get_unaligned_le32(data + 8 * i) - + usb->mcu.base; + val = get_unaligned_le32(data + 8 * i + 4); + + WARN_ON_ONCE(usb->mcu.rp[i].reg != reg); + usb->mcu.rp[i].value = val; + } + } +} + static int mt76u_mcu_wait_resp(struct mt76_dev *dev, u8 seq) { struct mt76_usb *usb = &dev->usb; struct mt76u_buf *buf = &usb->mcu.res; int i, ret; u32 rxfce; + u8 *data; for (i = 0; i < 5; i++) { if (!wait_for_completion_timeout(&usb->mcu.cmpl, @@ -64,7 +96,12 @@ static int mt76u_mcu_wait_resp(struct mt76_dev *dev, u8 seq) if (buf->urb->status) return -EIO; - rxfce = get_unaligned_le32(sg_virt(&buf->urb->sg[0])); + data = sg_virt(&buf->urb->sg[0]); + if (usb->mcu.rp) + mt76u_multiple_mcu_reads(dev, data + 4, + buf->urb->actual_length - 8); + + rxfce = get_unaligned_le32(data); ret = mt76u_submit_buf(dev, USB_DIR_IN, MT_EP_IN_CMD_RESP, buf, GFP_KERNEL, From patchwork Sat Aug 25 10:40:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576071 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-2.web.codeaurora.org (Postfix) with ESMTP id C464D109C for ; Sat, 25 Aug 2018 10:41:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B0DB2AE6D for ; Sat, 25 Aug 2018 10:41:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F3382AF1F; Sat, 25 Aug 2018 10:41:12 +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 D127A2AE6D for ; Sat, 25 Aug 2018 10:41:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbeHYOTn (ORCPT ); Sat, 25 Aug 2018 10:19:43 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:32794 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726842AbeHYOTn (ORCPT ); Sat, 25 Aug 2018 10:19:43 -0400 Received: by mail-wr1-f67.google.com with SMTP id v90-v6so9469960wrc.0 for ; Sat, 25 Aug 2018 03:41:07 -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=20d9Y8bMIvQ3uutcvtyXBv6TBpUaywQoM4//mTV/Av8=; b=lYYOitlqYNCliaACKZ/iPV7DnKFdzRQyXz35itSvzZGs16vihy36/WpPSk6Ct5eyrt TkIFYAdd7gZFA0pi6uI5MNuIfeVBYDoLzH6rJ4vXjFRhKvVtmtuoqH+8rYOOzzVcIB/7 UbyhRiav6gfTJjKB1GPHqSLt4uA8k+qR2Vp0LwggipjnPrgaWTi5IRl9oliMFQMa5rQ4 a88sgY25yp6TlbZIcx/+MO4zrYjPzxyDmjGMtcQLRECHgCzwbBywauRgdepi3cmynZrM d5lTHWlMESGsPK0R4nihY/MCUuaKY10AfTf6GJWZj2nlD+mmoYXMXG0OXsTCLPBDeflv UncQ== X-Gm-Message-State: APzg51AhaMP9beHnie98GGlCzYm1IxGeAkH1yFnVULEq6cCWTgSKlUwZ DM1n42JXRv6hYPCoP1r55iT9/A== X-Google-Smtp-Source: ANB0VdZfZOUqDZhKKzjS8Jq1FzW1iKdEenKQO+pP0kzixaL5Z9iBJZiXq9LF23vLtjCzxFMNjnmp2A== X-Received: by 2002:adf:9b9b:: with SMTP id d27-v6mr3650004wrc.240.1535193667270; Sat, 25 Aug 2018 03:41:07 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:06 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 05/16] mt76x0: use mt76u_init for bus initialization Date: Sat, 25 Aug 2018 12:40:45 +0200 Message-Id: <20180825104056.9130-6-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Use mt76u_init utility routine for usb initialization. Moreover remove following unused routines: - mt76x0_rr - mt76x0_wr - mt76x0_rmw - mt76x0_wr_copy - mt76x0_assign_pipes Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt76x0/dma.c | 6 +- .../net/wireless/mediatek/mt76/mt76x0/init.c | 3 +- .../net/wireless/mediatek/mt76/mt76x0/mcu.c | 3 +- .../net/wireless/mediatek/mt76/mt76x0/usb.c | 109 +----------------- 4 files changed, 12 insertions(+), 109 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/dma.c b/drivers/net/wireless/mediatek/mt76/mt76x0/dma.c index e2efb430419b..715c3734a307 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/dma.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/dma.c @@ -279,7 +279,8 @@ static int mt76x0_dma_submit_tx(struct mt76x0_dev *dev, struct sk_buff *skb, u8 ep) { struct usb_device *usb_dev = mt76x0_to_usb_dev(dev); - unsigned snd_pipe = usb_sndbulkpipe(usb_dev, dev->out_ep[ep]); + struct mt76_usb *usb = &dev->mt76.usb; + unsigned snd_pipe = usb_sndbulkpipe(usb_dev, usb->out_ep[ep]); struct mt76x0_dma_buf_tx *e; struct mt76x0_tx_queue *q = &dev->tx_q[ep]; unsigned long flags; @@ -375,11 +376,12 @@ static int mt76x0_submit_rx_buf(struct mt76x0_dev *dev, struct mt76x0_dma_buf_rx *e, gfp_t gfp) { struct usb_device *usb_dev = mt76x0_to_usb_dev(dev); + struct mt76_usb *usb = &dev->mt76.usb; u8 *buf = page_address(e->p); unsigned pipe; int ret; - pipe = usb_rcvbulkpipe(usb_dev, dev->in_ep[MT_EP_IN_PKT_RX]); + pipe = usb_rcvbulkpipe(usb_dev, usb->in_ep[MT_EP_IN_PKT_RX]); usb_fill_bulk_urb(e->urb, usb_dev, pipe, buf, MT_RX_URB_SIZE, mt76x0_complete_rx, dev); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c index d020df859e30..48d7eb1599d7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c @@ -109,6 +109,7 @@ static void mt76x0_reset_csr_bbp(struct mt76x0_dev *dev) static void mt76x0_init_usb_dma(struct mt76x0_dev *dev) { + struct mt76_usb *usb = &dev->mt76.usb; u32 val; val = mt76_rr(dev, MT_USB_DMA_CFG); @@ -117,7 +118,7 @@ static void mt76x0_init_usb_dma(struct mt76x0_dev *dev) FIELD_PREP(MT_USB_DMA_CFG_RX_BULK_AGG_LMT, MT_USB_AGGR_SIZE_LIMIT) | MT_USB_DMA_CFG_RX_BULK_EN | MT_USB_DMA_CFG_TX_BULK_EN; - if (dev->in_max_packet == 512) + if (usb->in_max_packet == 512) val |= MT_USB_DMA_CFG_RX_BULK_AGG_EN; mt76_wr(dev, MT_USB_DMA_CFG, val); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c index 96e04afc73f4..75768ebf8b30 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c @@ -154,8 +154,9 @@ __mt76x0_mcu_msg_send(struct mt76x0_dev *dev, struct sk_buff *skb, enum mcu_cmd cmd, bool wait_resp) { struct usb_device *usb_dev = mt76x0_to_usb_dev(dev); + struct mt76_usb *usb = &dev->mt76.usb; unsigned cmd_pipe = usb_sndbulkpipe(usb_dev, - dev->out_ep[MT_EP_OUT_INBAND_CMD]); + usb->out_ep[MT_EP_OUT_INBAND_CMD]); int sent, ret; u8 seq = 0; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c index d535012c506e..09e7f9590f01 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c @@ -71,13 +71,14 @@ int mt76x0_usb_submit_buf(struct mt76x0_dev *dev, int dir, int ep_idx, usb_complete_t complete_fn, void *context) { struct usb_device *usb_dev = mt76x0_to_usb_dev(dev); + struct mt76_usb *usb = &dev->mt76.usb; unsigned pipe; int ret; if (dir == USB_DIR_IN) - pipe = usb_rcvbulkpipe(usb_dev, dev->in_ep[ep_idx]); + pipe = usb_rcvbulkpipe(usb_dev, usb->in_ep[ep_idx]); else - pipe = usb_sndbulkpipe(usb_dev, dev->out_ep[ep_idx]); + pipe = usb_sndbulkpipe(usb_dev, usb->out_ep[ep_idx]); usb_fill_bulk_urb(buf->urb, usb_dev, pipe, buf->buf, buf->len, complete_fn, context); @@ -136,30 +137,6 @@ void mt76x0_vendor_reset(struct mt76x0_dev *dev) MT_VEND_DEV_MODE_RESET, 0, NULL, 0); } -static u32 mt76x0_rr(struct mt76_dev *dev, u32 offset) -{ - struct mt76x0_dev *mdev = (struct mt76x0_dev *) dev; - int ret; - u32 val = ~0; - - WARN_ONCE(offset > USHRT_MAX, "read high off:%08x", offset); - - mutex_lock(&mdev->usb_ctrl_mtx); - - ret = mt76x0_vendor_request((struct mt76x0_dev *)dev, MT_VEND_MULTI_READ, USB_DIR_IN, - 0, offset, mdev->data, MT_VEND_BUF); - if (ret == MT_VEND_BUF) - val = get_unaligned_le32(mdev->data); - else if (ret > 0) - dev_err(dev->dev, "Error: wrong size read:%d off:%08x\n", - ret, offset); - - mutex_unlock(&mdev->usb_ctrl_mtx); - - trace_mt76x0_reg_read(dev, offset, val); - return val; -} - int mt76x0_vendor_single_wr(struct mt76x0_dev *dev, const u8 req, const u16 offset, const u32 val) { @@ -179,82 +156,12 @@ int mt76x0_vendor_single_wr(struct mt76x0_dev *dev, const u8 req, return ret; } -static void mt76x0_wr(struct mt76_dev *dev, u32 offset, u32 val) -{ - struct mt76x0_dev *mdev = (struct mt76x0_dev *) dev; - int ret; - - WARN_ONCE(offset > USHRT_MAX, "write high off:%08x", offset); - - mutex_lock(&mdev->usb_ctrl_mtx); - - put_unaligned_le32(val, mdev->data); - ret = mt76x0_vendor_request(mdev, MT_VEND_MULTI_WRITE, USB_DIR_OUT, - 0, offset, mdev->data, MT_VEND_BUF); - trace_mt76x0_reg_write(dev, offset, val); - - mutex_unlock(&mdev->usb_ctrl_mtx); -} - -static u32 mt76x0_rmw(struct mt76_dev *dev, u32 offset, u32 mask, u32 val) -{ - val |= mt76x0_rr(dev, offset) & ~mask; - mt76x0_wr(dev, offset, val); - return val; -} - -static void mt76x0_wr_copy(struct mt76_dev *dev, u32 offset, - const void *data, int len) -{ - WARN_ONCE(offset & 3, "unaligned write copy off:%08x", offset); - WARN_ONCE(len & 3, "short write copy off:%08x", offset); - - mt76x0_burst_write_regs((struct mt76x0_dev *) dev, offset, data, len / 4); -} - void mt76x0_addr_wr(struct mt76x0_dev *dev, const u32 offset, const u8 *addr) { mt76_wr(dev, offset, get_unaligned_le32(addr)); mt76_wr(dev, offset + 4, addr[4] | addr[5] << 8); } -static int mt76x0_assign_pipes(struct usb_interface *usb_intf, - struct mt76x0_dev *dev) -{ - struct usb_endpoint_descriptor *ep_desc; - struct usb_host_interface *intf_desc = usb_intf->cur_altsetting; - unsigned i, ep_i = 0, ep_o = 0; - - BUILD_BUG_ON(sizeof(dev->in_ep) < __MT_EP_IN_MAX); - BUILD_BUG_ON(sizeof(dev->out_ep) < __MT_EP_OUT_MAX); - - for (i = 0; i < intf_desc->desc.bNumEndpoints; i++) { - ep_desc = &intf_desc->endpoint[i].desc; - - if (usb_endpoint_is_bulk_in(ep_desc) && - ep_i++ < __MT_EP_IN_MAX) { - dev->in_ep[ep_i - 1] = usb_endpoint_num(ep_desc); - dev->in_max_packet = usb_endpoint_maxp(ep_desc); - /* Note: this is ignored by usb sub-system but vendor - * code does it. We can drop this at some point. - */ - dev->in_ep[ep_i - 1] |= USB_DIR_IN; - } else if (usb_endpoint_is_bulk_out(ep_desc) && - ep_o++ < __MT_EP_OUT_MAX) { - dev->out_ep[ep_o - 1] = usb_endpoint_num(ep_desc); - dev->out_max_packet = usb_endpoint_maxp(ep_desc); - } - } - - if (ep_i != __MT_EP_IN_MAX || ep_o != __MT_EP_OUT_MAX) { - dev_err(dev->mt76.dev, "Error: wrong pipe number in:%d out:%d\n", - ep_i, ep_o); - return -EINVAL; - } - - return 0; -} - static int mt76x0_probe(struct usb_interface *usb_intf, const struct usb_device_id *id) { @@ -262,12 +169,6 @@ static int mt76x0_probe(struct usb_interface *usb_intf, struct mt76x0_dev *dev; u32 asic_rev, mac_rev; int ret; - static const struct mt76_bus_ops usb_ops = { - .rr = mt76x0_rr, - .wr = mt76x0_wr, - .rmw = mt76x0_rmw, - .copy = mt76x0_wr_copy, - }; dev = mt76x0_alloc_device(&usb_intf->dev); if (!dev) @@ -278,9 +179,7 @@ static int mt76x0_probe(struct usb_interface *usb_intf, usb_set_intfdata(usb_intf, dev); - dev->mt76.bus = &usb_ops; - - ret = mt76x0_assign_pipes(usb_intf, dev); + ret = mt76u_init(&dev->mt76, usb_intf); if (ret) goto err; From patchwork Sat Aug 25 10:40:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576069 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-2.web.codeaurora.org (Postfix) with ESMTP id C3F73174C for ; Sat, 25 Aug 2018 10:41:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 759D02AE30 for ; Sat, 25 Aug 2018 10:41:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67FCB2AF1F; Sat, 25 Aug 2018 10:41:12 +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 0912F2AEE7 for ; Sat, 25 Aug 2018 10:41:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726925AbeHYOTo (ORCPT ); Sat, 25 Aug 2018 10:19:44 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39682 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726624AbeHYOTn (ORCPT ); Sat, 25 Aug 2018 10:19:43 -0400 Received: by mail-wr1-f68.google.com with SMTP id o37-v6so9448241wrf.6 for ; Sat, 25 Aug 2018 03:41:09 -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=QOLwGPt5VaS1BVWTn01/K9PL1idQIJaxAhsKBFETJOs=; b=Z9flVO4WwyK1/xc3UiOFGJPMM6yR8yjrlRtuyA+ytw5yuGXS4xo7i8ksn7I9eU0YfZ hOphyG+qdxSKn8D/GHMmO8VG9LhXr39LdPbPtvFYqrXWI5T/nW6z62g+SyK1HyznX7bQ sYONPsjtNMFRInoOuD8Z2NX2NPV8kzq1spzf7k58/WQA4eQkS4CqopNgzVjd8d8V1zZL LNrYPP+2p4tuTGKvvNa5xbzfgHlFk+lL4YdlwTJiBPrjecauR31uLWDK69VEd2pHxyJ3 mUjZolKNO634+8nLSAp3HWzxnN6z0dMcoeKHqFS/gdVUewGMIxHYDMqieS7IGu6q8im+ BbXA== X-Gm-Message-State: APzg51CPzAo4ljXdHUl8HebQaMUXqoN4eCDHG1Raq/3KtWFcnYcUeAeU rVgqSYoL4IZFLjMndWpJFjEN97PnB7Q= X-Google-Smtp-Source: ANB0VdapExPqkT28/u0uRZNljrzp7naqJrbnz78Wi29fhBkjNH7dU37SkfAfP8Z+AceRgz0GFDPrrw== X-Received: by 2002:adf:d110:: with SMTP id a16-v6mr3726463wri.17.1535193668406; Sat, 25 Aug 2018 03:41:08 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:07 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 06/16] mt76x0: remove mt76x0_vendor_reset routine Date: Sat, 25 Aug 2018 12:40:46 +0200 Message-Id: <20180825104056.9130-7-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Remove mt76x0_vendor_reset duplicated routine and use mt76u_mcu_fw_reset utility function for mcu fw reset Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c | 2 +- drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 6 ------ drivers/net/wireless/mediatek/mt76/mt76x0/usb.h | 1 - 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c index 75768ebf8b30..c8ea3126e7dc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c @@ -571,7 +571,7 @@ static int mt76x0_load_firmware(struct mt76x0_dev *dev) mt76_set(dev, MT_USB_DMA_CFG, (MT_USB_DMA_CFG_RX_BULK_EN | MT_USB_DMA_CFG_TX_BULK_EN) | FIELD_PREP(MT_USB_DMA_CFG_RX_BULK_AGG_TOUT, 0x20)); - mt76x0_vendor_reset(dev); + mt76u_mcu_fw_reset(&dev->mt76); msleep(5); /* mt76x0_rmw(dev, MT_PBF_CFG, 0, (MT_PBF_CFG_TX0Q_EN | diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c index 09e7f9590f01..fdb71b907419 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c @@ -131,12 +131,6 @@ int mt76x0_vendor_request(struct mt76x0_dev *dev, const u8 req, return ret; } -void mt76x0_vendor_reset(struct mt76x0_dev *dev) -{ - mt76x0_vendor_request(dev, MT_VEND_DEV_MODE, USB_DIR_OUT, - MT_VEND_DEV_MODE_RESET, 0, NULL, 0); -} - int mt76x0_vendor_single_wr(struct mt76x0_dev *dev, const u8 req, const u16 offset, const u32 val) { diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h index 492e431390a8..d23ca45a294e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h @@ -54,7 +54,6 @@ void mt76x0_complete_urb(struct urb *urb); int mt76x0_vendor_request(struct mt76x0_dev *dev, const u8 req, const u8 direction, const u16 val, const u16 offset, void *buf, const size_t buflen); -void mt76x0_vendor_reset(struct mt76x0_dev *dev); int mt76x0_vendor_single_wr(struct mt76x0_dev *dev, const u8 req, const u16 offset, const u32 val); From patchwork Sat Aug 25 10:40:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576073 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-2.web.codeaurora.org (Postfix) with ESMTP id A260F109C for ; Sat, 25 Aug 2018 10:41:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 932D52AE6D for ; Sat, 25 Aug 2018 10:41:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8743A2AE30; Sat, 25 Aug 2018 10:41:13 +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 253572AE30 for ; Sat, 25 Aug 2018 10:41:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726958AbeHYOTp (ORCPT ); Sat, 25 Aug 2018 10:19:45 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34217 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726842AbeHYOTp (ORCPT ); Sat, 25 Aug 2018 10:19:45 -0400 Received: by mail-wm0-f67.google.com with SMTP id m199-v6so6025417wma.1 for ; Sat, 25 Aug 2018 03:41:10 -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=/WLpZF0IP0X8cVD7B6dDqoy8w1iEKF4b6BbWQbQpTW4=; b=XJF7bzpOal4Isa8f4Jcfu4uln09Ej7Ue1uD4jdv7+x2DBTJCTBnwypU+HxQ0agRfDz n4cB/uD6EYV970omXL1eCE1AStrDF++Hb5cOOnUA14IM6cbMB0+FahwFWHedFhRPMZYC XG2nZOKXhebS9s/q5SpC+5lt+MmzQVTFNLmdqo/wFKr/dwUTJ4eWzVssxBU8nlMaL2Jz fPHgn73Tp6cJCbZA2+xXt2yoKOpFFML9/9O8FTyay81WXzCVjEuIlWZEAwjAEBzQLbg7 KfohijiMs51Is+QP5eZYmS0fYVT0L7HNBTo02Gnpnwj8vTH3dZjgz6vSY0ZOIL7iXO7Q 5Lcg== X-Gm-Message-State: APzg51D2XP9hSsEiFYezoZMCjbl+25p9VHwI8P5gXNwJupge4Wx2BxlE Stbxhn+mXUKmG4pT9u8asD/aqg== X-Google-Smtp-Source: ANB0VdZB0XYeEx743az/9HpzHGp50XbppPrw+nqHVJwbL57Y8QCe4hh5yfBtD+fzUhZmx1o2og1Jdg== X-Received: by 2002:a1c:6a06:: with SMTP id f6-v6mr859283wmc.159.1535193669402; Sat, 25 Aug 2018 03:41:09 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:08 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 07/16] mt76x0: remove mt76x0_vendor_single_wr routine Date: Sat, 25 Aug 2018 12:40:47 +0200 Message-Id: <20180825104056.9130-8-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Remove mt76x0_vendor_single_wr routine and use mt76u_single_wr utility function for mcu firmware loading Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt76x0/mcu.c | 13 +++++-------- .../net/wireless/mediatek/mt76/mt76x0/usb.c | 19 ------------------- .../net/wireless/mediatek/mt76/mt76x0/usb.h | 2 -- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c index c8ea3126e7dc..cf3acee12dc3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c @@ -416,15 +416,12 @@ static int __mt76x0_dma_fw(struct mt76x0_dev *dev, memcpy(buf.buf + sizeof(reg), data, len); memset(buf.buf + sizeof(reg) + len, 0, 8); - ret = mt76x0_vendor_single_wr(dev, MT_VEND_WRITE_FCE, - MT_FCE_DMA_ADDR, dst_addr); - if (ret) - return ret; + mt76u_single_wr(&dev->mt76, MT_VEND_WRITE_FCE, MT_FCE_DMA_ADDR, + dst_addr); + len = roundup(len, 4); - ret = mt76x0_vendor_single_wr(dev, MT_VEND_WRITE_FCE, - MT_FCE_DMA_LEN, len << 16); - if (ret) - return ret; + mt76u_single_wr(&dev->mt76, MT_VEND_WRITE_FCE, MT_FCE_DMA_LEN, + len << 16); buf.len = MT_DMA_HDR_LEN + len + 4; ret = mt76x0_usb_submit_buf(dev, USB_DIR_OUT, MT_EP_OUT_INBAND_CMD, diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c index fdb71b907419..a9835bb7b921 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c @@ -131,25 +131,6 @@ int mt76x0_vendor_request(struct mt76x0_dev *dev, const u8 req, return ret; } -int mt76x0_vendor_single_wr(struct mt76x0_dev *dev, const u8 req, - const u16 offset, const u32 val) -{ - struct mt76x0_dev *mdev = dev; - int ret; - - mutex_lock(&mdev->usb_ctrl_mtx); - - ret = mt76x0_vendor_request(dev, req, USB_DIR_OUT, - val & 0xffff, offset, NULL, 0); - if (!ret) - ret = mt76x0_vendor_request(dev, req, USB_DIR_OUT, - val >> 16, offset + 2, NULL, 0); - - mutex_unlock(&mdev->usb_ctrl_mtx); - - return ret; -} - void mt76x0_addr_wr(struct mt76x0_dev *dev, const u32 offset, const u8 *addr) { mt76_wr(dev, offset, get_unaligned_le32(addr)); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h index d23ca45a294e..931c36554ff4 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h @@ -54,7 +54,5 @@ void mt76x0_complete_urb(struct urb *urb); int mt76x0_vendor_request(struct mt76x0_dev *dev, const u8 req, const u8 direction, const u16 val, const u16 offset, void *buf, const size_t buflen); -int mt76x0_vendor_single_wr(struct mt76x0_dev *dev, const u8 req, - const u16 offset, const u32 val); #endif From patchwork Sat Aug 25 10:40:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576075 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-2.web.codeaurora.org (Postfix) with ESMTP id 5BEAF14BD for ; Sat, 25 Aug 2018 10:41:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D7062AE30 for ; Sat, 25 Aug 2018 10:41:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40F2D2AEE7; Sat, 25 Aug 2018 10:41:14 +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 E3CD32AE30 for ; Sat, 25 Aug 2018 10:41:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726969AbeHYOTq (ORCPT ); Sat, 25 Aug 2018 10:19:46 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42618 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726624AbeHYOTq (ORCPT ); Sat, 25 Aug 2018 10:19:46 -0400 Received: by mail-wr1-f68.google.com with SMTP id v17-v6so9438398wrr.9 for ; Sat, 25 Aug 2018 03:41:11 -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=gNkdiaeAgblVxBSNA7XpWLi3ngMQwYaEXpzFeTQ+vvw=; b=fmt3KwlIymRFvNr8Poi/mto5Y+eO+qCTYx7P/jMnT1OMM0IxWDZhUxAwXgeJLVukVk qx2BnoInI3zkJg0+XxptDu2LVKj6IbZwtuheF2+xqIPYJRAicHb6MRkDQnDN6heJEe1B DCQh7cDr5AdkRwkooXeMMtjOzZ8HbHctREG5C5Qec8sKxeEsLqEGU5dCGNMRNNSlHdP8 NDoEML2K5V7iwTKM3mmjIxXfK8Vpk7eJN+wZ06UJh31W0Vf2YMJp1/D7fEW/KEjb6Hrp gBlbQnPHrtJ05Zp+9QrsbfWQ9EfVUtJclmkvlssMzTB/++6jOkHVdOHYHqtVzVpyGGOc rq3g== X-Gm-Message-State: APzg51AgHNHqYlzjR2Fg8/Hr6GSQ+CN4uCAefAiBumMcZfQ9cEQqCWSr cv1MG9zBYHqN0iVgOHTDIEtiXA== X-Google-Smtp-Source: ANB0VdZQcQGwLqzVyIAXtLiaBcE5L1nvkExmq/RlopNBo0PTQm3PD/oy9CE407VGqQgTX/FUOBO4wQ== X-Received: by 2002:adf:b243:: with SMTP id y3-v6mr3540157wra.90.1535193670625; Sat, 25 Aug 2018 03:41:10 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:10 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 08/16] mt76x0: remove mt76x0_mcu_msg_alloc routine Date: Sat, 25 Aug 2018 12:40:48 +0200 Message-Id: <20180825104056.9130-9-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Remove mt76x0_mcu_msg_alloc duplicated routine and use mt76u_mcu_msg_alloc utility function for usb mcu message allocation Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt76x0/mcu.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c index cf3acee12dc3..8a258fa33c2a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c @@ -59,21 +59,6 @@ static inline void trace_mt76x0_mcu_msg_send_cs(struct mt76_dev *dev, trace_mt76x0_mcu_msg_send(dev, skb, csum, need_resp); } -static struct sk_buff * -mt76x0_mcu_msg_alloc(struct mt76x0_dev *dev, const void *data, int len) -{ - struct sk_buff *skb; - - WARN_ON(len % 4); /* if length is not divisible by 4 we need to pad */ - - skb = alloc_skb(len + MT_DMA_HDR_LEN + 4, GFP_KERNEL); - if (skb) { - skb_reserve(skb, MT_DMA_HDR_LEN); - memcpy(skb_put(skb, len), data, len); - } - return skb; -} - static void mt76x0_read_resp_regs(struct mt76x0_dev *dev, int len) { int i; @@ -217,7 +202,7 @@ int mt76x0_mcu_function_select(struct mt76x0_dev *dev, .value = cpu_to_le32(val), }; - skb = mt76x0_mcu_msg_alloc(dev, &msg, sizeof(msg)); + skb = mt76u_mcu_msg_alloc(&msg, sizeof(msg)); if (!skb) return -ENOMEM; return mt76x0_mcu_msg_send(dev, skb, CMD_FUN_SET_OP, func == 5); @@ -235,7 +220,7 @@ mt76x0_mcu_calibrate(struct mt76x0_dev *dev, enum mcu_calibrate cal, u32 val) .value = cpu_to_le32(val), }; - skb = mt76x0_mcu_msg_alloc(dev, &msg, sizeof(msg)); + skb = mt76u_mcu_msg_alloc(&msg, sizeof(msg)); if (!skb) return -ENOMEM; return mt76x0_mcu_msg_send(dev, skb, CMD_CALIBRATION_OP, true); From patchwork Sat Aug 25 10:40:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576077 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-2.web.codeaurora.org (Postfix) with ESMTP id A8A9E14BD for ; Sat, 25 Aug 2018 10:41:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9915E2AE30 for ; Sat, 25 Aug 2018 10:41:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D62F2AEE7; Sat, 25 Aug 2018 10:41:15 +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 2F8B72AE30 for ; Sat, 25 Aug 2018 10:41:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727020AbeHYOTr (ORCPT ); Sat, 25 Aug 2018 10:19:47 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:38508 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726842AbeHYOTr (ORCPT ); Sat, 25 Aug 2018 10:19:47 -0400 Received: by mail-wm0-f68.google.com with SMTP id t25-v6so3834039wmi.3 for ; Sat, 25 Aug 2018 03:41:12 -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=n1HxunubKdlHSAAzpaKjGyCviuccAzkp06wP867cUSY=; b=qPWt+j+yVFVZCfSRBZwj+507JQm78XAzJ9QV8h3+DLLlgIQMEMkT9AomknlMtNnkk1 oE3o4b89oNOdKdEvM2KUnBWl//2nec2WFvidieg3wxoNu3iefAHTSct6L6GbFtAAcbOY QCaX/fexIRJasnc4ogMilxtKFmXv5k+8Li9EHLDlvu6rnRcIyHGnKjJFT6dTzF/xIh5M ftncheGllmTa5u+l1YsTQT1XobSNNs7IkJn//C1SYb/AnWCANaW6FLMj7bM8cgpSyRL0 sN32S7j2R6ivPqXt09OqdSsALMdAuOCY1Z4obtaKrOrhB7PW6Kz5OLUkmWe+dm6Vw2rE GZoQ== X-Gm-Message-State: APzg51Bizea3nZHZlAtYtV6RpPrsxgPb0SqOFMU93xx8MhjKbFBUhnDs aM4d07JLftbROhycVASLIhgFY+MlLN8= X-Google-Smtp-Source: ANB0VdaZ5vF5++gJ+9qnZt2gh6gZmDAD3s+4w17X2CHfmrbndZ0kq/cZEkTlRkXjZ79KBfdChjKRSw== X-Received: by 2002:a1c:200c:: with SMTP id g12-v6mr938626wmg.102.1535193671646; Sat, 25 Aug 2018 03:41:11 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:11 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 09/16] mt76x0: use shared mt76 usb mcu completion Date: Sat, 25 Aug 2018 12:40:49 +0200 Message-Id: <20180825104056.9130-10-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Use mt76 usb shared completion data structure in mt76x0_mcu_wait_resp routine and remove mt76x0 private one Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c | 11 ++++++----- drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c index 8a258fa33c2a..bfaabe018216 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c @@ -93,11 +93,12 @@ static void mt76x0_read_resp_regs(struct mt76x0_dev *dev, int len) static int mt76x0_mcu_wait_resp(struct mt76x0_dev *dev, u8 seq) { struct urb *urb = dev->mcu.resp.urb; + struct mt76_usb *usb = &dev->mt76.usb; u32 rxfce; int urb_status, ret, try = 5; while (try--) { - if (!wait_for_completion_timeout(&dev->mcu.resp_cmpl, + if (!wait_for_completion_timeout(&usb->mcu.cmpl, msecs_to_jiffies(300))) { dev_warn(dev->mt76.dev, "Warning: %s retrying\n", __func__); continue; @@ -113,7 +114,7 @@ static int mt76x0_mcu_wait_resp(struct mt76x0_dev *dev, u8 seq) ret = mt76x0_usb_submit_buf(dev, USB_DIR_IN, MT_EP_IN_CMD_RESP, &dev->mcu.resp, GFP_KERNEL, mt76x0_complete_urb, - &dev->mcu.resp_cmpl); + &usb->mcu.cmpl); if (ret) return ret; @@ -151,7 +152,7 @@ __mt76x0_mcu_msg_send(struct mt76x0_dev *dev, struct sk_buff *skb, mt76x0_dma_skb_wrap_cmd(skb, seq, cmd); - if (dev->mcu.resp_cmpl.done) + if (&usb->mcu.cmpl.done) dev_err(dev->mt76.dev, "Error: MCU response pre-completed!\n"); trace_mt76x0_mcu_msg_send_cs(&dev->mt76, skb, wait_resp); @@ -609,13 +610,13 @@ int mt76x0_mcu_init(struct mt76x0_dev *dev) int mt76x0_mcu_cmd_init(struct mt76x0_dev *dev) { + struct mt76_usb *usb = &dev->mt76.usb; int ret; ret = mt76x0_mcu_function_select(dev, Q_SELECT, 1); if (ret) return ret; - init_completion(&dev->mcu.resp_cmpl); if (mt76x0_usb_alloc_buf(dev, MCU_RESP_URB_SIZE, &dev->mcu.resp)) { mt76x0_usb_free_buf(dev, &dev->mcu.resp); return -ENOMEM; @@ -623,7 +624,7 @@ int mt76x0_mcu_cmd_init(struct mt76x0_dev *dev) ret = mt76x0_usb_submit_buf(dev, USB_DIR_IN, MT_EP_IN_CMD_RESP, &dev->mcu.resp, GFP_KERNEL, - mt76x0_complete_urb, &dev->mcu.resp_cmpl); + mt76x0_complete_urb, &usb->mcu.cmpl); if (ret) { mt76x0_usb_free_buf(dev, &dev->mcu.resp); return ret; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h index a694cc46fac8..298b7af31911 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h @@ -55,7 +55,6 @@ struct mt76x0_mcu { u8 msg_seq; struct mt76x0_dma_buf resp; - struct completion resp_cmpl; struct mt76_reg_pair *reg_pairs; unsigned int reg_pairs_len; From patchwork Sat Aug 25 10:40:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576079 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-2.web.codeaurora.org (Postfix) with ESMTP id 5B183109C for ; Sat, 25 Aug 2018 10:41:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AB402AE6D for ; Sat, 25 Aug 2018 10:41:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3ED992AEE7; Sat, 25 Aug 2018 10:41:17 +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 319972AE30 for ; Sat, 25 Aug 2018 10:41:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727040AbeHYOTs (ORCPT ); Sat, 25 Aug 2018 10:19:48 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:40682 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726624AbeHYOTs (ORCPT ); Sat, 25 Aug 2018 10:19:48 -0400 Received: by mail-wr1-f67.google.com with SMTP id n2-v6so9429328wrw.7 for ; Sat, 25 Aug 2018 03:41:13 -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=Kjpo9XP6rmB6ejBt3e2nyHnDGbXn1m1HwplfKTXpOzA=; b=tUnvQw4xkpOMCltc4rMuAHwrndYzi0CsK4ssC06jvk7qkiX04kOm06Q3K4eatiBh92 ZlgondpUIW5/oGpRSWEuSo1C7StZatfE386H9XArCxvTOHKpRRMJsc1Vtp1Lzel91FHR h35kCXkg18yMg2PuxylPsY4nvVKtuQXsceNnTb1Xci2tB/pihg89FkedoIn3lai9UITA Q5//yPw05zKy6ane5wRhwanTETMndUegpeygI+Gz2x7OnrYlG7kleZSqaV1wL6jd34dE GdOXkdDYQu3IUgrdbqDWFmCb03O4D803rGZgflNS0VtN6nAZng1SPupci1ypoLyNMrbP gJbw== X-Gm-Message-State: APzg51CZmYLvBLFAzBIVNmqPXEv54/rBBRKoSq+mnDw1yQT1vlqAZ5RM 1Nk7qInUXOiSwWWDnQCMa2yQsuGPJjk= X-Google-Smtp-Source: ANB0VdZ7iVNu32djhcbLnAQ6Ks6RjnSNmo/YdOhF04VaXS/sruuWbMJios3Rw9llwTOo/yL0qW+eVQ== X-Received: by 2002:adf:eaca:: with SMTP id o10-v6mr3350026wrn.98.1535193672755; Sat, 25 Aug 2018 03:41:12 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:12 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 10/16] mt76x0: remove mt76x0_complete_urb routine Date: Sat, 25 Aug 2018 12:40:50 +0200 Message-Id: <20180825104056.9130-11-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Remove mt76x0_complete_urb routine and use mt76u_mcu_complete_urb utility function as usb mcu completion handler Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c | 6 +++--- drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 7 ------- drivers/net/wireless/mediatek/mt76/mt76x0/usb.h | 1 - 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c index bfaabe018216..3f985c1d45f0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c @@ -113,7 +113,7 @@ static int mt76x0_mcu_wait_resp(struct mt76x0_dev *dev, u8 seq) ret = mt76x0_usb_submit_buf(dev, USB_DIR_IN, MT_EP_IN_CMD_RESP, &dev->mcu.resp, GFP_KERNEL, - mt76x0_complete_urb, + mt76u_mcu_complete_urb, &usb->mcu.cmpl); if (ret) return ret; @@ -412,7 +412,7 @@ static int __mt76x0_dma_fw(struct mt76x0_dev *dev, buf.len = MT_DMA_HDR_LEN + len + 4; ret = mt76x0_usb_submit_buf(dev, USB_DIR_OUT, MT_EP_OUT_INBAND_CMD, &buf, GFP_KERNEL, - mt76x0_complete_urb, &cmpl); + mt76u_mcu_complete_urb, &cmpl); if (ret) return ret; @@ -624,7 +624,7 @@ int mt76x0_mcu_cmd_init(struct mt76x0_dev *dev) ret = mt76x0_usb_submit_buf(dev, USB_DIR_IN, MT_EP_IN_CMD_RESP, &dev->mcu.resp, GFP_KERNEL, - mt76x0_complete_urb, &usb->mcu.cmpl); + mt76u_mcu_complete_urb, &usb->mcu.cmpl); if (ret) { mt76x0_usb_free_buf(dev, &dev->mcu.resp); return ret; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c index a9835bb7b921..fcca1e990475 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c @@ -93,13 +93,6 @@ int mt76x0_usb_submit_buf(struct mt76x0_dev *dev, int dir, int ep_idx, return ret; } -void mt76x0_complete_urb(struct urb *urb) -{ - struct completion *cmpl = urb->context; - - complete(cmpl); -} - int mt76x0_vendor_request(struct mt76x0_dev *dev, const u8 req, const u8 direction, const u16 val, const u16 offset, void *buf, const size_t buflen) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h index 931c36554ff4..0d1ba95dcf2e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h @@ -49,7 +49,6 @@ void mt76x0_usb_free_buf(struct mt76x0_dev *dev, struct mt76x0_dma_buf *buf); int mt76x0_usb_submit_buf(struct mt76x0_dev *dev, int dir, int ep_idx, struct mt76x0_dma_buf *buf, gfp_t gfp, usb_complete_t complete_fn, void *context); -void mt76x0_complete_urb(struct urb *urb); int mt76x0_vendor_request(struct mt76x0_dev *dev, const u8 req, const u8 direction, const u16 val, const u16 offset, From patchwork Sat Aug 25 10:40:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576081 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-2.web.codeaurora.org (Postfix) with ESMTP id CCAEC174C for ; Sat, 25 Aug 2018 10:41:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE7032AE30 for ; Sat, 25 Aug 2018 10:41:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2A732AF1F; Sat, 25 Aug 2018 10:41:17 +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 455322AE30 for ; Sat, 25 Aug 2018 10:41:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727059AbeHYOTu (ORCPT ); Sat, 25 Aug 2018 10:19:50 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46185 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726842AbeHYOTt (ORCPT ); Sat, 25 Aug 2018 10:19:49 -0400 Received: by mail-wr1-f66.google.com with SMTP id a108-v6so9421970wrc.13 for ; Sat, 25 Aug 2018 03:41:14 -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=UhNCSpik5flN2EfpWI85iafBqxSTb5Oj9orcL2z5y5o=; b=LQpVzbMBaMQAQ6mmh8aV+DUaJW1cbp11iFwIi1Ff5dvH60o6V1jYG3VwB8HY/FRmyR fVH7WVjZ82kV8Sj6YuM84zmi41aAK3z02xg04RbvQybPZtOC35zEf8DUkl+9YV1SZQNE tJ5nELTgm7xN4NcKY63xPXkRVS0MwLsK2hCUW0+gBtjBQ1Y2Kc0PfwUgP/bPqJcqeXgU mOoGmTP0OLwKW4XvmdgnnZymIIQC+BRjm3Jqxcj7fmADaTSlH7R1mxRCdbLgHcPr0CFV 03U+VeMV41fxpuJLV1W5sNCyzLrgwFbPlp9QiQ4IVhOGy2ZFHZCoiayhanKVE2ypdUGO eqag== X-Gm-Message-State: APzg51Ai6Ab/nDQKV7mixZCBb3Ed4cIEjopJPbyZH3kd1x2hi6jSOeNR KatYgfbC/0KsWbICMVETZuilUQ== X-Google-Smtp-Source: ANB0VdY8FcoKj5t2NJYd/6ZhkdTTJ9tDSv/l2lepZdQpQ+Y7m/iAJ+d+5+YTHxEdL9glfkQouylGMA== X-Received: by 2002:a5d:53cf:: with SMTP id a15-v6mr3692623wrw.151.1535193673879; Sat, 25 Aug 2018 03:41:13 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:13 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 11/16] mt76x0: remove mt76x0_vendor_request routine Date: Sat, 25 Aug 2018 12:40:51 +0200 Message-Id: <20180825104056.9130-12-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Remove mt76x0_vendor_request routine and use mt76u_vendor_request utility function from mt76-usb layer in mt76x0_upload_firmware Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt76x0/mcu.c | 5 +-- .../net/wireless/mediatek/mt76/mt76x0/usb.c | 31 ------------------- .../net/wireless/mediatek/mt76/mt76x0/usb.h | 4 --- 3 files changed, 3 insertions(+), 37 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c index 3f985c1d45f0..7c2217307828 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c @@ -488,8 +488,9 @@ mt76x0_upload_firmware(struct mt76x0_dev *dev, const struct mt76_fw *fw) if (ret) goto error; - ret = mt76x0_vendor_request(dev, MT_VEND_DEV_MODE, USB_DIR_OUT, - 0x12, 0, ivb, sizeof(fw->ivb)); + ret = mt76u_vendor_request(&dev->mt76, MT_VEND_DEV_MODE, + USB_DIR_OUT | USB_TYPE_VENDOR, + 0x12, 0, ivb, sizeof(fw->ivb)); if (ret < 0) goto error; ret = 0; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c index fcca1e990475..e2b55d0d31da 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c @@ -93,37 +93,6 @@ int mt76x0_usb_submit_buf(struct mt76x0_dev *dev, int dir, int ep_idx, return ret; } -int mt76x0_vendor_request(struct mt76x0_dev *dev, const u8 req, - const u8 direction, const u16 val, const u16 offset, - void *buf, const size_t buflen) -{ - int i, ret; - struct usb_device *usb_dev = mt76x0_to_usb_dev(dev); - const u8 req_type = direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE; - const unsigned int pipe = (direction == USB_DIR_IN) ? - usb_rcvctrlpipe(usb_dev, 0) : usb_sndctrlpipe(usb_dev, 0); - - for (i = 0; i < MT_VEND_REQ_MAX_RETRY; i++) { - ret = usb_control_msg(usb_dev, pipe, req, req_type, - val, offset, buf, buflen, - MT_VEND_REQ_TOUT_MS); - trace_mt76x0_vend_req(&dev->mt76, pipe, req, req_type, val, offset, - buf, buflen, ret); - - if (ret == -ENODEV) - set_bit(MT76_REMOVED, &dev->mt76.state); - if (ret >= 0 || ret == -ENODEV) - return ret; - - msleep(5); - } - - dev_err(dev->mt76.dev, "Vendor request req:%02x off:%04x failed:%d\n", - req, offset, ret); - - return ret; -} - void mt76x0_addr_wr(struct mt76x0_dev *dev, const u32 offset, const u8 *addr) { mt76_wr(dev, offset, get_unaligned_le32(addr)); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h index 0d1ba95dcf2e..b4a5d98416ab 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h @@ -50,8 +50,4 @@ int mt76x0_usb_submit_buf(struct mt76x0_dev *dev, int dir, int ep_idx, struct mt76x0_dma_buf *buf, gfp_t gfp, usb_complete_t complete_fn, void *context); -int mt76x0_vendor_request(struct mt76x0_dev *dev, const u8 req, - const u8 direction, const u16 val, const u16 offset, - void *buf, const size_t buflen); - #endif From patchwork Sat Aug 25 10:40:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576083 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-2.web.codeaurora.org (Postfix) with ESMTP id 0339914BD for ; Sat, 25 Aug 2018 10:41:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7B6C2AE30 for ; Sat, 25 Aug 2018 10:41:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC12D2AF1F; Sat, 25 Aug 2018 10:41:18 +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 29F662AE30 for ; Sat, 25 Aug 2018 10:41:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727091AbeHYOTv (ORCPT ); Sat, 25 Aug 2018 10:19:51 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:51279 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726624AbeHYOTu (ORCPT ); Sat, 25 Aug 2018 10:19:50 -0400 Received: by mail-wm0-f67.google.com with SMTP id y2-v6so3714288wma.1 for ; Sat, 25 Aug 2018 03:41:15 -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=cNIACiowubO73QaLozFJBKec/NjTCfONj0thNTjBbyg=; b=qC/1+wKxLdjU/a8j1Xm+U8fGRWan5Lecuivs5PgzZ195p2FBsCeaTW0OOGxQR8zay1 0/XvA7uddAWlbguoLNl5voIpeGnG8IJPdHfxw6RZaU84zS+jravZ7AdNWneNppuvelZP Q7z2BbOmBsUtjisaXQRBhUqof47ZsqUDeUofzWBgx2YJf2WFnGiXRmu0KJUobHXkQkgQ S2rmzCyHRfKajBJIbvD/67aarzFf+pM6lXExob7EnsTKvCH/7lf1Cw4KRJSpA8a5UpKU QTk+7T7HddXnkbWA40lsiQX9DVs8UBtj5+QAHjOyQHkacvlJ5cQQfkcjZGgz9Aiuu/Wu UxfA== X-Gm-Message-State: APzg51Dg7I1855bDYGeJxSM6jtr5dYvTqndQhK+ZVsyng2LsNyR4h/cR J9vdWr3qcVbl6XLp9dCZCkRdJg== X-Google-Smtp-Source: ANB0VdbnybUYWTbWMskQSsAloQCIpauS70qBU21pCpJZtIS59aMepTP8/7ZdXkGJTgVIkF0vyNudpQ== X-Received: by 2002:a1c:cf08:: with SMTP id f8-v6mr941751wmg.27.1535193674888; Sat, 25 Aug 2018 03:41:14 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:14 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 12/16] mt76x0: remove unused mt76x0_wait_asic_ready routine Date: Sat, 25 Aug 2018 12:40:52 +0200 Message-Id: <20180825104056.9130-13-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Delete core.c source file since, removing mt76x0_wait_asic_ready routine, it is no longer needed Signed-off-by: Lorenzo Bianconi --- .../wireless/mediatek/mt76/mt76x0/Makefile | 2 +- .../net/wireless/mediatek/mt76/mt76x0/core.c | 34 ------------------- 2 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/core.c diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/Makefile b/drivers/net/wireless/mediatek/mt76/mt76x0/Makefile index 7843908261ba..2f1721263aa5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/Makefile +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/Makefile @@ -2,6 +2,6 @@ obj-$(CONFIG_MT76x0U) += mt76x0.o mt76x0-objs = \ usb.o init.o main.o mcu.o trace.o dma.o eeprom.o phy.o \ - mac.o util.o debugfs.o tx.o core.o + mac.o util.o debugfs.o tx.o # ccflags-y := -DDEBUG CFLAGS_trace.o := -I$(src) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/core.c b/drivers/net/wireless/mediatek/mt76/mt76x0/core.c deleted file mode 100644 index 892803fce842..000000000000 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/core.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2014 Felix Fietkau - * Copyright (C) 2015 Jakub Kicinski - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "mt76x0.h" - -int mt76x0_wait_asic_ready(struct mt76x0_dev *dev) -{ - int i = 100; - u32 val; - - do { - if (test_bit(MT76_REMOVED, &dev->mt76.state)) - return -EIO; - - val = mt76_rr(dev, MT_MAC_CSR0); - if (val && ~val) - return 0; - - udelay(10); - } while (i--); - - return -EIO; -} From patchwork Sat Aug 25 10:40:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576085 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-2.web.codeaurora.org (Postfix) with ESMTP id E372314BD for ; Sat, 25 Aug 2018 10:41:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1F372AE30 for ; Sat, 25 Aug 2018 10:41:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C55602AF1F; Sat, 25 Aug 2018 10:41:20 +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 F3B3A2AE30 for ; Sat, 25 Aug 2018 10:41:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727110AbeHYOTx (ORCPT ); Sat, 25 Aug 2018 10:19:53 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36983 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726842AbeHYOTw (ORCPT ); Sat, 25 Aug 2018 10:19:52 -0400 Received: by mail-wm0-f66.google.com with SMTP id n11-v6so3849870wmc.2 for ; Sat, 25 Aug 2018 03:41:16 -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=MH4kni99RuvaX5FPC4ZpS0Xy6o/IpROzOr5ujSBzfD4=; b=m31HqXlpz+Ez8nQ+MsX+Ks1+rCV6A3q3h3tD4+jxMDwN50D4B7RwEeBchM7EeiIgl5 NobVYn90zQPnQQrYZ9QRCu06fyGsPwHaof8k8Y5aoQJJpifeVTfr1d1ydAr9LSjrsv8H RHoS7lhXut6d+W4IVWmtEMvjmp/NbDtmHUpXEtrKex0ROnqo21gOiDSFoYAqfuVCIsbn M7SovWeZytHu68FK1oARxoSgmjAzz6vw69iMnn9e0mRw2kg8JAIRY/P0hDBUzV6bZ3PJ Tv2hwRtJjEOmWEhoIFiJN28/0WMB2sEQkThN9K1dMqHm4JYRiF7adB9SLZtDmu6d/7t5 3lzA== X-Gm-Message-State: APzg51Don0JdY9ga/Rw6iz3TW0/bZdt9fIT88mfLKIEQEEe15mihyYag PdTZVta4qmsLx3lIvaJ2We7bEA== X-Google-Smtp-Source: ANB0VdYQnTPBnxkmqYoB0E2nK+0+Ur4B9cl+zSoWfiPvuZPE+NboJo3Ijo1mFKCcg/I5v8g0JKH5sQ== X-Received: by 2002:a1c:8406:: with SMTP id g6-v6mr853815wmd.18.1535193676092; Sat, 25 Aug 2018 03:41:16 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:15 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 13/16] mt76x0: use mt76u_mcu_send_msg utility routine to send fw cmds Date: Sat, 25 Aug 2018 12:40:53 +0200 Message-Id: <20180825104056.9130-14-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Use mt76u_mcu_send_msg/__mt76u_mcu_send_msg utility routines to send commands to usb mcu. Remove following unused routines: - mt76x0_mcu_wait_resp - __mt76x0_mcu_msg_send - mt76x0_mcu_msg_send - mt76x0_dma_skb_wrap_cmd - trace_mt_mcu_msg_send_cs - mt76x0_mcu_cmd_deinit Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt76x0/init.c | 4 +- .../net/wireless/mediatek/mt76/mt76x0/mcu.c | 226 +++--------------- .../net/wireless/mediatek/mt76/mt76x0/mcu.h | 1 - 3 files changed, 31 insertions(+), 200 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c index 48d7eb1599d7..d3bb173a9474 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c @@ -465,7 +465,7 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev) err_rx: mt76x0_dma_cleanup(dev); err_mcu: - mt76x0_mcu_cmd_deinit(dev); + mt76u_mcu_deinit(&dev->mt76); err: mt76x0_chip_onoff(dev, false, false); return ret; @@ -478,7 +478,7 @@ void mt76x0_cleanup(struct mt76x0_dev *dev) mt76x0_stop_hardware(dev); mt76x0_dma_cleanup(dev); - mt76x0_mcu_cmd_deinit(dev); + mt76u_mcu_deinit(&dev->mt76); } struct mt76x0_dev *mt76x0_alloc_device(struct device *pdev) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c index 7c2217307828..39b2ec0c1ee0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c @@ -40,157 +40,6 @@ static inline void skb_put_le32(struct sk_buff *skb, u32 val) put_unaligned_le32(val, skb_put(skb, 4)); } -static inline void mt76x0_dma_skb_wrap_cmd(struct sk_buff *skb, - u8 seq, enum mcu_cmd cmd) -{ - WARN_ON(mt76x0_dma_skb_wrap(skb, CPU_TX_PORT, DMA_COMMAND, - FIELD_PREP(MT_TXD_CMD_SEQ, seq) | - FIELD_PREP(MT_TXD_CMD_TYPE, cmd))); -} - -static inline void trace_mt76x0_mcu_msg_send_cs(struct mt76_dev *dev, - struct sk_buff *skb, bool need_resp) -{ - u32 i, csum = 0; - - for (i = 0; i < skb->len / 4; i++) - csum ^= get_unaligned_le32(skb->data + i * 4); - - trace_mt76x0_mcu_msg_send(dev, skb, csum, need_resp); -} - -static void mt76x0_read_resp_regs(struct mt76x0_dev *dev, int len) -{ - int i; - int n = dev->mcu.reg_pairs_len; - u8 *buf = dev->mcu.resp.buf; - - buf += 4; - len -= 8; - - if (dev->mcu.burst_read) { - u32 reg = dev->mcu.reg_pairs[0].reg - dev->mcu.reg_base; - - WARN_ON_ONCE(len/4 != n); - for (i = 0; i < n; i++) { - u32 val = get_unaligned_le32(buf + 4*i); - - dev->mcu.reg_pairs[i].reg = reg++; - dev->mcu.reg_pairs[i].value = val; - } - } else { - WARN_ON_ONCE(len/8 != n); - for (i = 0; i < n; i++) { - u32 reg = get_unaligned_le32(buf + 8*i) - dev->mcu.reg_base; - u32 val = get_unaligned_le32(buf + 8*i + 4); - - WARN_ON_ONCE(dev->mcu.reg_pairs[i].reg != reg); - dev->mcu.reg_pairs[i].value = val; - } - } -} - -static int mt76x0_mcu_wait_resp(struct mt76x0_dev *dev, u8 seq) -{ - struct urb *urb = dev->mcu.resp.urb; - struct mt76_usb *usb = &dev->mt76.usb; - u32 rxfce; - int urb_status, ret, try = 5; - - while (try--) { - if (!wait_for_completion_timeout(&usb->mcu.cmpl, - msecs_to_jiffies(300))) { - dev_warn(dev->mt76.dev, "Warning: %s retrying\n", __func__); - continue; - } - - /* Make copies of important data before reusing the urb */ - rxfce = get_unaligned_le32(dev->mcu.resp.buf); - urb_status = urb->status * mt76x0_urb_has_error(urb); - - if (urb_status == 0 && dev->mcu.reg_pairs) - mt76x0_read_resp_regs(dev, urb->actual_length); - - ret = mt76x0_usb_submit_buf(dev, USB_DIR_IN, MT_EP_IN_CMD_RESP, - &dev->mcu.resp, GFP_KERNEL, - mt76u_mcu_complete_urb, - &usb->mcu.cmpl); - if (ret) - return ret; - - if (urb_status) - dev_err(dev->mt76.dev, "Error: MCU resp urb failed:%d\n", - urb_status); - - if (FIELD_GET(MT_RXD_CMD_INFO_CMD_SEQ, rxfce) == seq && - FIELD_GET(MT_RXD_CMD_INFO_EVT_TYPE, rxfce) == CMD_DONE) - return 0; - - dev_err(dev->mt76.dev, "Error: MCU resp evt:%lx seq:%hhx-%lx!\n", - FIELD_GET(MT_RXD_CMD_INFO_EVT_TYPE, rxfce), - seq, FIELD_GET(MT_RXD_CMD_INFO_CMD_SEQ, rxfce)); - } - - dev_err(dev->mt76.dev, "Error: %s timed out\n", __func__); - return -ETIMEDOUT; -} - -static int -__mt76x0_mcu_msg_send(struct mt76x0_dev *dev, struct sk_buff *skb, - enum mcu_cmd cmd, bool wait_resp) -{ - struct usb_device *usb_dev = mt76x0_to_usb_dev(dev); - struct mt76_usb *usb = &dev->mt76.usb; - unsigned cmd_pipe = usb_sndbulkpipe(usb_dev, - usb->out_ep[MT_EP_OUT_INBAND_CMD]); - int sent, ret; - u8 seq = 0; - - if (wait_resp) - while (!seq) - seq = ++dev->mcu.msg_seq & 0xf; - - mt76x0_dma_skb_wrap_cmd(skb, seq, cmd); - - if (&usb->mcu.cmpl.done) - dev_err(dev->mt76.dev, "Error: MCU response pre-completed!\n"); - - trace_mt76x0_mcu_msg_send_cs(&dev->mt76, skb, wait_resp); - trace_mt76x0_submit_urb_sync(&dev->mt76, cmd_pipe, skb->len); - - ret = usb_bulk_msg(usb_dev, cmd_pipe, skb->data, skb->len, &sent, 500); - if (ret) { - dev_err(dev->mt76.dev, "Error: send MCU cmd failed:%d\n", ret); - goto out; - } - if (sent != skb->len) - dev_err(dev->mt76.dev, "Error: %s sent != skb->len\n", __func__); - - if (wait_resp) - ret = mt76x0_mcu_wait_resp(dev, seq); - -out: - return ret; -} - -static int -mt76x0_mcu_msg_send(struct mt76x0_dev *dev, struct sk_buff *skb, - enum mcu_cmd cmd, bool wait_resp) -{ - int ret; - - if (test_bit(MT76_REMOVED, &dev->mt76.state)) - return 0; - - mutex_lock(&dev->mcu.mutex); - ret = __mt76x0_mcu_msg_send(dev, skb, cmd, wait_resp); - mutex_unlock(&dev->mcu.mutex); - - consume_skb(skb); - - return ret; -} - int mt76x0_mcu_function_select(struct mt76x0_dev *dev, enum mcu_function func, u32 val) { @@ -206,7 +55,8 @@ int mt76x0_mcu_function_select(struct mt76x0_dev *dev, skb = mt76u_mcu_msg_alloc(&msg, sizeof(msg)); if (!skb) return -ENOMEM; - return mt76x0_mcu_msg_send(dev, skb, CMD_FUN_SET_OP, func == 5); + return mt76u_mcu_send_msg(&dev->mt76, skb, CMD_FUN_SET_OP, + func == 5); } int @@ -224,7 +74,8 @@ mt76x0_mcu_calibrate(struct mt76x0_dev *dev, enum mcu_calibrate cal, u32 val) skb = mt76u_mcu_msg_alloc(&msg, sizeof(msg)); if (!skb) return -ENOMEM; - return mt76x0_mcu_msg_send(dev, skb, CMD_CALIBRATION_OP, true); + return mt76u_mcu_send_msg(&dev->mt76, skb, CMD_CALIBRATION_OP, + true); } int mt76x0_write_reg_pairs(struct mt76x0_dev *dev, u32 base, @@ -249,7 +100,8 @@ int mt76x0_write_reg_pairs(struct mt76x0_dev *dev, u32 base, skb_put_le32(skb, data[i].value); } - ret = mt76x0_mcu_msg_send(dev, skb, CMD_RANDOM_WRITE, cnt == n); + ret = mt76u_mcu_send_msg(&dev->mt76, skb, CMD_RANDOM_WRITE, + cnt == n); if (ret) return ret; @@ -260,6 +112,7 @@ int mt76x0_read_reg_pairs(struct mt76x0_dev *dev, u32 base, struct mt76_reg_pair *data, int n) { const int max_vals_per_cmd = INBAND_PACKET_MAX_LEN / 8; + struct mt76_usb *usb = &dev->mt76.usb; struct sk_buff *skb; int cnt, i, ret; @@ -280,20 +133,19 @@ int mt76x0_read_reg_pairs(struct mt76x0_dev *dev, u32 base, skb_put_le32(skb, data[i].value); } - mutex_lock(&dev->mcu.mutex); - - dev->mcu.reg_pairs = data; - dev->mcu.reg_pairs_len = n; - dev->mcu.reg_base = base; - dev->mcu.burst_read = false; + mutex_lock(&usb->mcu.mutex); - ret = __mt76x0_mcu_msg_send(dev, skb, CMD_RANDOM_READ, true); + usb->mcu.rp = data; + usb->mcu.rp_len = n; + usb->mcu.base = base; + usb->mcu.burst = false; - dev->mcu.reg_pairs = NULL; + ret = __mt76u_mcu_send_msg(&dev->mt76, skb, CMD_RANDOM_READ, + true); - mutex_unlock(&dev->mcu.mutex); + usb->mcu.rp = NULL; - consume_skb(skb); + mutex_unlock(&usb->mcu.mutex); return ret; @@ -320,7 +172,8 @@ int mt76x0_burst_write_regs(struct mt76x0_dev *dev, u32 offset, for (i = 0; i < cnt; i++) skb_put_le32(skb, data[i]); - ret = mt76x0_mcu_msg_send(dev, skb, CMD_BURST_WRITE, cnt == n); + ret = mt76u_mcu_send_msg(&dev->mt76, skb, CMD_BURST_WRITE, + cnt == n); if (ret) return ret; @@ -333,6 +186,7 @@ static int mt76x0_burst_read_regs(struct mt76x0_dev *dev, u32 base, struct mt76_reg_pair *data, int n) { const int max_vals_per_cmd = INBAND_PACKET_MAX_LEN / 4 - 1; + struct mt76_usb *usb = &dev->mt76.usb; struct sk_buff *skb; int cnt, ret; @@ -351,18 +205,18 @@ static int mt76x0_burst_read_regs(struct mt76x0_dev *dev, u32 base, skb_put_le32(skb, base + data[0].reg); skb_put_le32(skb, n); - mutex_lock(&dev->mcu.mutex); + mutex_lock(&usb->mcu.mutex); - dev->mcu.reg_pairs = data; - dev->mcu.reg_pairs_len = n; - dev->mcu.reg_base = base; - dev->mcu.burst_read = true; + usb->mcu.rp = data; + usb->mcu.rp_len = n; + usb->mcu.base = base; + usb->mcu.burst = false; - ret = __mt76x0_mcu_msg_send(dev, skb, CMD_BURST_READ, true); + ret = __mt76u_mcu_send_msg(&dev->mt76, skb, CMD_BURST_READ, true); - dev->mcu.reg_pairs = NULL; + usb->mcu.rp = NULL; - mutex_unlock(&dev->mcu.mutex); + mutex_unlock(&usb->mcu.mutex); consume_skb(skb); @@ -611,31 +465,9 @@ int mt76x0_mcu_init(struct mt76x0_dev *dev) int mt76x0_mcu_cmd_init(struct mt76x0_dev *dev) { - struct mt76_usb *usb = &dev->mt76.usb; - int ret; - - ret = mt76x0_mcu_function_select(dev, Q_SELECT, 1); + int ret = mt76x0_mcu_function_select(dev, Q_SELECT, 1); if (ret) return ret; - if (mt76x0_usb_alloc_buf(dev, MCU_RESP_URB_SIZE, &dev->mcu.resp)) { - mt76x0_usb_free_buf(dev, &dev->mcu.resp); - return -ENOMEM; - } - - ret = mt76x0_usb_submit_buf(dev, USB_DIR_IN, MT_EP_IN_CMD_RESP, - &dev->mcu.resp, GFP_KERNEL, - mt76u_mcu_complete_urb, &usb->mcu.cmpl); - if (ret) { - mt76x0_usb_free_buf(dev, &dev->mcu.resp); - return ret; - } - - return 0; -} - -void mt76x0_mcu_cmd_deinit(struct mt76x0_dev *dev) -{ - usb_kill_urb(dev->mcu.resp.urb); - mt76x0_usb_free_buf(dev, &dev->mcu.resp); + return mt76u_mcu_init_rx(&dev->mt76); } diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.h b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.h index 8c2f77f4c3f5..010a7f2bbae9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.h @@ -90,7 +90,6 @@ enum mcu_calibrate { int mt76x0_mcu_init(struct mt76x0_dev *dev); int mt76x0_mcu_cmd_init(struct mt76x0_dev *dev); -void mt76x0_mcu_cmd_deinit(struct mt76x0_dev *dev); int mt76x0_mcu_calibrate(struct mt76x0_dev *dev, enum mcu_calibrate cal, u32 val); From patchwork Sat Aug 25 10:40:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576087 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-2.web.codeaurora.org (Postfix) with ESMTP id 67A2A109C for ; Sat, 25 Aug 2018 10:41:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A3BF2AE30 for ; Sat, 25 Aug 2018 10:41:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EFCF2AFC2; Sat, 25 Aug 2018 10:41:21 +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 E3CE42AEE7 for ; Sat, 25 Aug 2018 10:41:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727095AbeHYOTw (ORCPT ); Sat, 25 Aug 2018 10:19:52 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:40420 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726624AbeHYOTw (ORCPT ); Sat, 25 Aug 2018 10:19:52 -0400 Received: by mail-wm0-f66.google.com with SMTP id 207-v6so3837979wme.5 for ; Sat, 25 Aug 2018 03:41:17 -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=TIEv5KMFaHRl+fW7jPC2CI7IvfHinLxJNRCHGgBmqpg=; b=K9aZdgCB86aFScE//VqM940QNsg8tf+F1NAGoqDpHuQC+sj58envLoaHuzz1TmIBH5 kgnhULS+gQv+LRHMeyTUy2q2ScOi4rK0pr9trHI7c/rRqbVNDb+9PmWBkl0t/iyz1HxE aTY52c2x5n3oe15fjc9gaCPwiKukejsTOZu8mU1yKgaLHoW/JrvZh5A/xvsUn4tKrP0r R22FPOpEvo52TBKJBvRM3PJgdHa0jx0cP5C3ZOZ8UREDNhijKNdxrZW4I1ORHPt9SOR8 Lj45QhFfMawmZZ2wk9LX0ba+FilD1p3m6x3T1OIMj1s+9yJg1N7K55Ws31TFNPMfQTtw bARg== X-Gm-Message-State: APzg51DvS6t4cdgISug5gbPvpol4sc/Dm8XELRwgLHu0hd+kMkvf1AXV APNL8QFsE+X2w7As/vkvoiQFTwgh/uM= X-Google-Smtp-Source: ANB0Vdbrl6yd8j/UvCffzRpKXkaOPYfrrKjEB09PxAfay+6UfR83Ak3i1S/6AT+O/16FhgnpjQMhHw== X-Received: by 2002:a1c:148f:: with SMTP id 137-v6mr844599wmu.61.1535193677165; Sat, 25 Aug 2018 03:41:17 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:16 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 14/16] mt76x0: remove unused mt76x0_mcu structure Date: Sat, 25 Aug 2018 12:40:54 +0200 Message-Id: <20180825104056.9130-15-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Remove no longer used mt76x0_mcu data structure Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c | 2 -- .../net/wireless/mediatek/mt76/mt76x0/mt76x0.h | 15 --------------- 2 files changed, 17 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c index 39b2ec0c1ee0..d49557834658 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c @@ -452,8 +452,6 @@ int mt76x0_mcu_init(struct mt76x0_dev *dev) { int ret; - mutex_init(&dev->mcu.mutex); - ret = mt76x0_load_firmware(dev); if (ret) return ret; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h index 298b7af31911..cdace0565d51 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h @@ -49,19 +49,6 @@ struct mt76x0_dma_buf { size_t len; }; -struct mt76x0_mcu { - struct mutex mutex; - - u8 msg_seq; - - struct mt76x0_dma_buf resp; - - struct mt76_reg_pair *reg_pairs; - unsigned int reg_pairs_len; - u32 reg_base; - bool burst_read; -}; - struct mac_stats { u64 rx_stat[6]; u64 tx_stat[6]; @@ -160,8 +147,6 @@ struct mt76x0_dev { unsigned long wcid_mask[DIV_ROUND_UP(N_WCIDS, BITS_PER_LONG)]; unsigned long vif_mask; - struct mt76x0_mcu mcu; - struct delayed_work cal_work; struct delayed_work mac_work; From patchwork Sat Aug 25 10:40:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576091 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-2.web.codeaurora.org (Postfix) with ESMTP id 8D881109C for ; Sat, 25 Aug 2018 10:41:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EC5F2AE30 for ; Sat, 25 Aug 2018 10:41:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 727212B12B; Sat, 25 Aug 2018 10:41:22 +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 056AA2AE30 for ; Sat, 25 Aug 2018 10:41:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727125AbeHYOTy (ORCPT ); Sat, 25 Aug 2018 10:19:54 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42624 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726842AbeHYOTy (ORCPT ); Sat, 25 Aug 2018 10:19:54 -0400 Received: by mail-wr1-f67.google.com with SMTP id v17-v6so9438579wrr.9 for ; Sat, 25 Aug 2018 03:41:19 -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=PMtvMx4oYmIrd4qh0lbAJFdbUY2wLqCNWB/IW0VFeUI=; b=jieQl3M8HUwD/YUDUhG+6xlBC1CAHj806M6C3VEdRb/MDGS1xEh69Hye+xGvz+nNHJ b16U99/FE6GQyCkIRUQCbn4KMI0YjW1DvSdJ0Uclb8lTX2frmaWfgqR2EURqbUfcb1ra 6Jiql60itx7VW4wy+PeXJcNYB/NXQbrCWkacY70utfkku4L4AHtmoSd1mSalecUHfPO5 pHAjJOb6Arom8y9ucMzRRK4UyNDEywhrkGMvt5+WyEbImHc2cx0tJuC1sfmjJjqJ7gqZ EL6Qe5jcquL14PZEftpCTSb2ipKO4mr6qPUw6/TTJLKPLo1oSFYMNH3L5LA1E8I2wzW9 7hpA== X-Gm-Message-State: APzg51C1854CL5vLEZ9cr1aRiaFlww4A7l01YJzv3XPVmxo1m3hs8l4k MbRWSWGaidF3Z1TgyV1I03SzwQ== X-Google-Smtp-Source: ANB0VdZEaxUA2IGoXYgUYFwd3/E42nmslMjcGV7NI6EuVopOG+wh1XR1Iyw4Ucs9DCSB0EgeZ1bIYQ== X-Received: by 2002:adf:9ccb:: with SMTP id h11-v6mr3517147wre.11.1535193678741; Sat, 25 Aug 2018 03:41:18 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:17 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 15/16] mt76x0: use mt76u_mcu_fw_send_data for fw uploading Date: Sat, 25 Aug 2018 12:40:55 +0200 Message-Id: <20180825104056.9130-16-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Use mt76u_mcu_fw_send_data utility routine for firmware uploading and remove unused __mt76x0_dma_fw/mt76x0_dma_fw functions Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt76x0/mcu.c | 88 ++----------------- 1 file changed, 6 insertions(+), 82 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c index d49557834658..0a0deaf1c65d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c @@ -239,83 +239,9 @@ struct mt76_fw { u8 ilm[]; }; -static int __mt76x0_dma_fw(struct mt76x0_dev *dev, - const struct mt76x0_dma_buf *dma_buf, - const void *data, u32 len, u32 dst_addr) -{ - DECLARE_COMPLETION_ONSTACK(cmpl); - struct mt76x0_dma_buf buf = *dma_buf; /* we need to fake length */ - __le32 reg; - u32 val; - int ret; - - reg = cpu_to_le32(FIELD_PREP(MT_TXD_INFO_TYPE, DMA_COMMAND) | - FIELD_PREP(MT_TXD_INFO_D_PORT, CPU_TX_PORT) | - FIELD_PREP(MT_TXD_INFO_LEN, len)); - memcpy(buf.buf, ®, sizeof(reg)); - memcpy(buf.buf + sizeof(reg), data, len); - memset(buf.buf + sizeof(reg) + len, 0, 8); - - mt76u_single_wr(&dev->mt76, MT_VEND_WRITE_FCE, MT_FCE_DMA_ADDR, - dst_addr); - - len = roundup(len, 4); - mt76u_single_wr(&dev->mt76, MT_VEND_WRITE_FCE, MT_FCE_DMA_LEN, - len << 16); - - buf.len = MT_DMA_HDR_LEN + len + 4; - ret = mt76x0_usb_submit_buf(dev, USB_DIR_OUT, MT_EP_OUT_INBAND_CMD, - &buf, GFP_KERNEL, - mt76u_mcu_complete_urb, &cmpl); - if (ret) - return ret; - - if (!wait_for_completion_timeout(&cmpl, msecs_to_jiffies(1000))) { - dev_err(dev->mt76.dev, "Error: firmware upload timed out\n"); - usb_kill_urb(buf.urb); - return -ETIMEDOUT; - } - if (mt76x0_urb_has_error(buf.urb)) { - dev_err(dev->mt76.dev, "Error: firmware upload urb failed:%d\n", - buf.urb->status); - return buf.urb->status; - } - - val = mt76_rr(dev, MT_TX_CPU_FROM_FCE_CPU_DESC_IDX); - val++; - mt76_wr(dev, MT_TX_CPU_FROM_FCE_CPU_DESC_IDX, val); - - msleep(5); - - return 0; -} - -static int -mt76x0_dma_fw(struct mt76x0_dev *dev, struct mt76x0_dma_buf *dma_buf, - const void *data, int len, u32 dst_addr) -{ - int n, ret; - - if (len == 0) - return 0; - - n = min(MCU_FW_URB_MAX_PAYLOAD, len); - ret = __mt76x0_dma_fw(dev, dma_buf, data, n, dst_addr); - if (ret) - return ret; - -#if 0 - if (!mt76_poll_msec(dev, MT_MCU_COM_REG1, BIT(31), BIT(31), 500)) - return -ETIMEDOUT; -#endif - - return mt76x0_dma_fw(dev, dma_buf, data + n, len - n, dst_addr + n); -} - static int mt76x0_upload_firmware(struct mt76x0_dev *dev, const struct mt76_fw *fw) { - struct mt76x0_dma_buf dma_buf; void *ivb; u32 ilm_len, dlm_len; int i, ret; @@ -323,22 +249,21 @@ mt76x0_upload_firmware(struct mt76x0_dev *dev, const struct mt76_fw *fw) ivb = kmemdup(fw->ivb, sizeof(fw->ivb), GFP_KERNEL); if (!ivb) return -ENOMEM; - if (mt76x0_usb_alloc_buf(dev, MCU_FW_URB_SIZE, &dma_buf)) { - ret = -ENOMEM; - goto error; - } ilm_len = le32_to_cpu(fw->hdr.ilm_len) - sizeof(fw->ivb); dev_dbg(dev->mt76.dev, "loading FW - ILM %u + IVB %zu\n", ilm_len, sizeof(fw->ivb)); - ret = mt76x0_dma_fw(dev, &dma_buf, fw->ilm, ilm_len, sizeof(fw->ivb)); + ret = mt76u_mcu_fw_send_data(&dev->mt76, fw->ilm, ilm_len, + MCU_FW_URB_MAX_PAYLOAD, + sizeof(fw->ivb)); if (ret) goto error; dlm_len = le32_to_cpu(fw->hdr.dlm_len); dev_dbg(dev->mt76.dev, "loading FW - DLM %u\n", dlm_len); - ret = mt76x0_dma_fw(dev, &dma_buf, fw->ilm + ilm_len, - dlm_len, MT_MCU_DLM_OFFSET); + ret = mt76u_mcu_fw_send_data(&dev->mt76, fw->ilm + ilm_len, + dlm_len, MCU_FW_URB_MAX_PAYLOAD, + MT_MCU_DLM_OFFSET); if (ret) goto error; @@ -359,7 +284,6 @@ mt76x0_upload_firmware(struct mt76x0_dev *dev, const struct mt76_fw *fw) dev_dbg(dev->mt76.dev, "Firmware running!\n"); error: kfree(ivb); - mt76x0_usb_free_buf(dev, &dma_buf); return ret; } From patchwork Sat Aug 25 10:40:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576093 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-2.web.codeaurora.org (Postfix) with ESMTP id 8172C109C for ; Sat, 25 Aug 2018 10:41:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 714AD2AE30 for ; Sat, 25 Aug 2018 10:41:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65A3B2AEE7; Sat, 25 Aug 2018 10:41:23 +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 098F42AFC2 for ; Sat, 25 Aug 2018 10:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727144AbeHYOTz (ORCPT ); Sat, 25 Aug 2018 10:19:55 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35384 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727113AbeHYOTz (ORCPT ); Sat, 25 Aug 2018 10:19:55 -0400 Received: by mail-wm0-f66.google.com with SMTP id o18-v6so3864788wmc.0 for ; Sat, 25 Aug 2018 03:41:20 -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=SDrCLRfPcI/L2dFjrHn+u/w4Nn4yy5fTZgxHwn8V6i0=; b=uLa1dlcUDsJlw6sxL6TBOZCfK96A+Zvjs9gMYLAjHMZWRIPRM4h6dc9cy8BQpsj1nh XdHNSXXFqQEVvwUA046H551HbopQLWaoBq+bFX6OHmbsvdRiMou2ZTyBgtBUBl5qbS6O qMUGfX4g+Yd+8r3mcADeuKdu5ab8joB/IbarZvh1s7ZdLLjiCEv5ps9VpKOXiwPfxiGs CUKkSSzXM4c0Zp+ZSER/BdTeosYzZ0h4uX17GZhO5iDG5YQdONtRkGATWRcXCFzYxMZ8 2ScrOmpZud2OgWV50Q29HMDRlRYqT7UtQrrl4V2vzHn5tCGU5ndDhPkOtdB3kwM4veZ7 ml2g== X-Gm-Message-State: APzg51BsnA55uEFloxL3loJ3/9h6CaD21ODH+mnpLgaJAdir1duHKyXc THzjIGf0/E8pT+YQ20jrCnEgQQ== X-Google-Smtp-Source: ANB0Vdbv2hC255Xm2Y0k7VRx6MolqB5i96gxUuqlX8JtEAxl9tVeJPjtcylXXdTnjd5g6i719v8mLg== X-Received: by 2002:a1c:3f45:: with SMTP id m66-v6mr862258wma.37.1535193679777; Sat, 25 Aug 2018 03:41:19 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:19 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 16/16] mt76x0: remove unused routines for usb_buff alloc/free Date: Sat, 25 Aug 2018 12:40:56 +0200 Message-Id: <20180825104056.9130-17-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Remove the following unused routines for usb buffer allocation/free/submit: - mt76x0_usb_alloc_buf - mt76x0_usb_free_buf - mt76x0_usb_submit_buf Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt76x0/usb.c | 47 ------------------- .../net/wireless/mediatek/mt76/mt76x0/usb.h | 7 --- 2 files changed, 54 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c index e2b55d0d31da..4e71a13ff54c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c @@ -46,53 +46,6 @@ static struct usb_device_id mt76x0_device_table[] = { { 0, } }; -bool mt76x0_usb_alloc_buf(struct mt76x0_dev *dev, size_t len, - struct mt76x0_dma_buf *buf) -{ - struct usb_device *usb_dev = mt76x0_to_usb_dev(dev); - - buf->len = len; - buf->urb = usb_alloc_urb(0, GFP_KERNEL); - buf->buf = usb_alloc_coherent(usb_dev, buf->len, GFP_KERNEL, &buf->dma); - - return !buf->urb || !buf->buf; -} - -void mt76x0_usb_free_buf(struct mt76x0_dev *dev, struct mt76x0_dma_buf *buf) -{ - struct usb_device *usb_dev = mt76x0_to_usb_dev(dev); - - usb_free_coherent(usb_dev, buf->len, buf->buf, buf->dma); - usb_free_urb(buf->urb); -} - -int mt76x0_usb_submit_buf(struct mt76x0_dev *dev, int dir, int ep_idx, - struct mt76x0_dma_buf *buf, gfp_t gfp, - usb_complete_t complete_fn, void *context) -{ - struct usb_device *usb_dev = mt76x0_to_usb_dev(dev); - struct mt76_usb *usb = &dev->mt76.usb; - unsigned pipe; - int ret; - - if (dir == USB_DIR_IN) - pipe = usb_rcvbulkpipe(usb_dev, usb->in_ep[ep_idx]); - else - pipe = usb_sndbulkpipe(usb_dev, usb->out_ep[ep_idx]); - - usb_fill_bulk_urb(buf->urb, usb_dev, pipe, buf->buf, buf->len, - complete_fn, context); - buf->urb->transfer_dma = buf->dma; - buf->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; - - trace_mt76x0_submit_urb(&dev->mt76, buf->urb); - ret = usb_submit_urb(buf->urb, gfp); - if (ret) - dev_err(dev->mt76.dev, "Error: submit URB dir:%d ep:%d failed:%d\n", - dir, ep_idx, ret); - return ret; -} - void mt76x0_addr_wr(struct mt76x0_dev *dev, const u32 offset, const u8 *addr) { mt76_wr(dev, offset, get_unaligned_le32(addr)); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h index b4a5d98416ab..7bd075319f5b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.h @@ -43,11 +43,4 @@ static inline bool mt76x0_urb_has_error(struct urb *urb) urb->status != -ESHUTDOWN; } -bool mt76x0_usb_alloc_buf(struct mt76x0_dev *dev, size_t len, - struct mt76x0_dma_buf *buf); -void mt76x0_usb_free_buf(struct mt76x0_dev *dev, struct mt76x0_dma_buf *buf); -int mt76x0_usb_submit_buf(struct mt76x0_dev *dev, int dir, int ep_idx, - struct mt76x0_dma_buf *buf, gfp_t gfp, - usb_complete_t complete_fn, void *context); - #endif