From patchwork Sat Sep 5 09:26:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 259389 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8210AC43461 for ; Sat, 5 Sep 2020 09:26:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D3F6206A5 for ; Sat, 5 Sep 2020 09:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599297979; bh=FXrJfxbMWk8s8N/MakKjCLApr3kebpI1J4vYqNHhl64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=V+I1uLeoruyVV0GL6l9cnZM0Wd3Lq/BEdy4yCkYRLWZmKEyvfkeYhQk4gJdo/r2wW miiGF6IgFCfmnwqml0S9xU9q26qfJL9bLl39XcDqUZsWPQbaepXhCDosG0M8HxKiuQ y1BPKIgqjtUGLIY3Y0VFg7yDAfsrsSNcA2ctrBbE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726597AbgIEJ0S (ORCPT ); Sat, 5 Sep 2020 05:26:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:40154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726302AbgIEJ0S (ORCPT ); Sat, 5 Sep 2020 05:26:18 -0400 Received: from localhost.localdomain (unknown [151.66.86.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CE39F20757; Sat, 5 Sep 2020 09:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599297977; bh=FXrJfxbMWk8s8N/MakKjCLApr3kebpI1J4vYqNHhl64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d9lGQDEsbt7FfrM/VMYdryklUvLjvi7Z0l14hbt6EcBJXEcsT4P6zznrzbVzo5gNb Fj0wkwqtdz7hVwAB715xS8y46AOgaQkfo7BlG0Mj5GWBeh+m1kd26Ds4fHgXNuG+oz mAJ5vnzJMOPZ1JuKbLgZNT4J4J90aawfhdV+zvJE= From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org, sean.wang@mediatek.com Subject: [PATCH 1/7] mt76: mt7663s: do not use altx for ctl/mgmt traffic Date: Sat, 5 Sep 2020 11:26:01 +0200 Message-Id: <9cc863c3d8e9b36af2add3c42474f14adbdc2df1.1599297449.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Since the sdio engine does not report quota for altx queue, move ctl/mgmt traffic to standard data queues Tested-by: Sean Wang Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7615/sdio.c | 2 +- .../net/wireless/mediatek/mt76/mt7615/sdio_txrx.c | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/sdio.c b/drivers/net/wireless/mediatek/mt76/mt7615/sdio.c index e0603e82e33d..8621c6f579aa 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/sdio.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/sdio.c @@ -323,7 +323,7 @@ static int mt7663s_probe(struct sdio_func *func, { static const struct mt76_driver_ops drv_ops = { .txwi_size = MT_USB_TXD_SIZE, - .drv_flags = MT_DRV_RX_DMA_HDR | MT_DRV_HW_MGMT_TXQ, + .drv_flags = MT_DRV_RX_DMA_HDR, .tx_prepare_skb = mt7663_usb_sdio_tx_prepare_skb, .tx_complete_skb = mt7663_usb_sdio_tx_complete_skb, .tx_status_data = mt7663_usb_sdio_tx_status_data, diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c index 3557df52846f..b2b528cba7f1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c @@ -124,16 +124,14 @@ static int mt7663s_tx_update_sched(struct mt76_dev *dev, bool mcu) { struct mt76_sdio *sdio = &dev->sdio; - struct mt76_phy *mphy = &dev->phy; - struct ieee80211_hdr *hdr; int size, ret = -EBUSY; + if (!test_bit(MT76_STATE_MCU_RUNNING, &dev->phy.state)) + return 0; + size = DIV_ROUND_UP(e->buf_sz + sdio->sched.deficit, MT_PSE_PAGE_SZ); if (mcu) { - if (!test_bit(MT76_STATE_MCU_RUNNING, &mphy->state)) - return 0; - mutex_lock(&sdio->sched.lock); if (sdio->sched.pse_mcu_quota > size) { sdio->sched.pse_mcu_quota -= size; @@ -144,10 +142,6 @@ static int mt7663s_tx_update_sched(struct mt76_dev *dev, return ret; } - hdr = (struct ieee80211_hdr *)(e->skb->data + MT_USB_TXD_SIZE); - if (ieee80211_is_ctl(hdr->frame_control)) - return 0; - mutex_lock(&sdio->sched.lock); if (sdio->sched.pse_data_quota > size && sdio->sched.ple_data_quota > 0) { From patchwork Sat Sep 5 09:26:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 259388 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AACB8C43461 for ; Sat, 5 Sep 2020 09:26:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74FFB2078D for ; Sat, 5 Sep 2020 09:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599297982; bh=ITisLbejlUiuih/wCCOSMvzBUU8yH0x6BvFqlT9mogE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zkQbjgOjlA08ZW1CgjUwB8PMlsdmjwq1PS0q52UavbiyjJTUBFJZyhZYhsnGr7ByO yY7QLxvmCWpMe1PFedwyI6CLqR+ba14vK93StvXmnLPSLXkNpxu5+dk1DdVQH5EQqW oLUHwZ5Csigj/D89mrBRaAcwdUIj9exj8NYjvxg8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728297AbgIEJ0V (ORCPT ); Sat, 5 Sep 2020 05:26:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:40182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726302AbgIEJ0V (ORCPT ); Sat, 5 Sep 2020 05:26:21 -0400 Received: from localhost.localdomain (unknown [151.66.86.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 88366206A5; Sat, 5 Sep 2020 09:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599297980; bh=ITisLbejlUiuih/wCCOSMvzBUU8yH0x6BvFqlT9mogE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0ggOKeUqQ416N0smwXyxduWat/5bBfX7QuRBJKIy6N08sVMNxIm6raTFWYiVPmfF9 djHMOp3I5gMU51aeDceVpSgWNIHQ1MMs0XAQtsvdf1utN/FNmewnRQhps/YNt1KQdl rp5Ca/Lz2qq8WoGI8tmkQB3qYw4QXuyP9KU3m9Lg= From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org, sean.wang@mediatek.com Subject: [PATCH 3/7] mt76: mt7663s: introduce __mt7663s_xmit_queue routine Date: Sat, 5 Sep 2020 11:26:03 +0200 Message-Id: <170fde26f917b16879ae711eab65b4b47c822183.1599297449.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is a preliminary patch to introduce sdio tx aggregation Tested-by: Sean Wang Co-developed-by: Sean Wang Signed-off-by: Sean Wang Signed-off-by: Lorenzo Bianconi --- .../wireless/mediatek/mt76/mt7615/sdio_txrx.c | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c index ced7820021c2..ebae2a24c45b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c @@ -158,6 +158,24 @@ static void mt7663s_tx_update_quota(struct mt76_sdio *sdio, enum mt76_txq_id qid mutex_unlock(&sdio->sched.lock); } +static int __mt7663s_xmit_queue(struct mt76_dev *dev, u8 *data, int len) +{ + struct mt76_sdio *sdio = &dev->sdio; + int err; + + if (len > sdio->func->cur_blksize) + len = roundup(len, sdio->func->cur_blksize); + + sdio_claim_host(sdio->func); + err = sdio_writesb(sdio->func, MCR_WTDR1, data, len); + sdio_release_host(sdio->func); + + if (err) + dev_err(dev->dev, "sdio write failed: %d\n", err); + + return err; +} + static int mt7663s_tx_run_queue(struct mt76_dev *dev, enum mt76_txq_id qid) { int nframes = 0, pse_sz = 0, ple_sz = 0; @@ -166,24 +184,15 @@ static int mt7663s_tx_run_queue(struct mt76_dev *dev, enum mt76_txq_id qid) while (q->first != q->head) { struct mt76_queue_entry *e = &q->entry[q->first]; - int err, len = e->skb->len; + int err; if (mt7663s_tx_pick_quota(dev, qid, e->buf_sz, &pse_sz, &ple_sz)) break; - if (len > sdio->func->cur_blksize) - len = roundup(len, sdio->func->cur_blksize); - - /* TODO: skb_walk_frags and then write to SDIO port */ - sdio_claim_host(sdio->func); - err = sdio_writesb(sdio->func, MCR_WTDR1, e->skb->data, len); - sdio_release_host(sdio->func); - - if (err) { - dev_err(dev->dev, "sdio write failed: %d\n", err); - return -EIO; - } + err = __mt7663s_xmit_queue(dev, e->skb->data, e->skb->len); + if (err) + return err; e->done = true; q->first = (q->first + 1) % q->ndesc; From patchwork Sat Sep 5 09:26:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 259387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 841E0C43461 for ; Sat, 5 Sep 2020 09:26:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C4D620760 for ; Sat, 5 Sep 2020 09:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599297985; bh=27iJwRfY74SCfzmkfNmv1It2jJJ/kZKlF9GiIuGLyZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TLbZzRH+r6bE6SbMH/3TXx3Eo+1gp1elSpQPxfp6Yp6pQwD8I6zJTW3wxnQRhmWQI MNiwZaaMaiNQp4xHAo8ECWBPXiL/H8OOeS/tWEGmaYrCmFdYYjvrODGQEsD44uNvSh 7N1vZgGr1TMv8MbLWIyY6pKnv0+6B5qZPpDtQEJE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726568AbgIEJ0Y (ORCPT ); Sat, 5 Sep 2020 05:26:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:40226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728347AbgIEJ0Y (ORCPT ); Sat, 5 Sep 2020 05:26:24 -0400 Received: from localhost.localdomain (unknown [151.66.86.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3F4CE2074D; Sat, 5 Sep 2020 09:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599297983; bh=27iJwRfY74SCfzmkfNmv1It2jJJ/kZKlF9GiIuGLyZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O8ZQZlBsQu1gGEO0OPECncS4ESBdomqFW6Hyd8KXNaeXnEKX3IE20ylEVlwg5XJqz 5jctiFmwAu3BGzrEBPF+VHxe7bhug0GR0bPjl/PzkVZcLRScjyxenJInQWeA8fnist LlDQXmpqHVVCZfThLSLT4r9vAb39Y4J0kiin4P98= From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org, sean.wang@mediatek.com Subject: [PATCH 5/7] mt76: mt7663s: fix possible quota leak in mt7663s_refill_sched_quota Date: Sat, 5 Sep 2020 11:26:05 +0200 Message-Id: X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Look just at reported quota since the hw sporadically reports mcu tx quota without setting WHIER_TX_DONE_INT_EN bit Tested-by: Sean Wang Signed-off-by: Lorenzo Bianconi --- .../wireless/mediatek/mt76/mt7615/sdio_txrx.c | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c index 4754b3abd0a2..4033fe431312 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c @@ -19,21 +19,40 @@ #include "sdio.h" #include "mac.h" -static void mt7663s_refill_sched_quota(struct mt76_dev *dev, u32 *data) +static int mt7663s_refill_sched_quota(struct mt76_dev *dev, u32 *data) { + u32 ple_ac_data_quota[] = { + FIELD_GET(TXQ_CNT_L, data[4]), /* VO */ + FIELD_GET(TXQ_CNT_H, data[3]), /* VI */ + FIELD_GET(TXQ_CNT_L, data[3]), /* BE */ + FIELD_GET(TXQ_CNT_H, data[2]), /* BK */ + }; + u32 pse_ac_data_quota[] = { + FIELD_GET(TXQ_CNT_H, data[1]), /* VO */ + FIELD_GET(TXQ_CNT_L, data[1]), /* VI */ + FIELD_GET(TXQ_CNT_H, data[0]), /* BE */ + FIELD_GET(TXQ_CNT_L, data[0]), /* BK */ + }; + u32 pse_mcu_quota = FIELD_GET(TXQ_CNT_L, data[2]); + u32 pse_data_quota = 0, ple_data_quota = 0; struct mt76_sdio *sdio = &dev->sdio; + int i; + + for (i = 0; i < ARRAY_SIZE(pse_ac_data_quota); i++) { + pse_data_quota += pse_ac_data_quota[i]; + ple_data_quota += ple_ac_data_quota[i]; + } + + if (!pse_data_quota && !ple_data_quota && !pse_mcu_quota) + return 0; mutex_lock(&sdio->sched.lock); - sdio->sched.pse_data_quota += FIELD_GET(TXQ_CNT_L, data[0]) + /* BK */ - FIELD_GET(TXQ_CNT_H, data[0]) + /* BE */ - FIELD_GET(TXQ_CNT_L, data[1]) + /* VI */ - FIELD_GET(TXQ_CNT_H, data[1]); /* VO */ - sdio->sched.ple_data_quota += FIELD_GET(TXQ_CNT_H, data[2]) + /* BK */ - FIELD_GET(TXQ_CNT_L, data[3]) + /* BE */ - FIELD_GET(TXQ_CNT_H, data[3]) + /* VI */ - FIELD_GET(TXQ_CNT_L, data[4]); /* VO */ - sdio->sched.pse_mcu_quota += FIELD_GET(TXQ_CNT_L, data[2]); + sdio->sched.pse_mcu_quota += pse_mcu_quota; + sdio->sched.pse_data_quota += pse_data_quota; + sdio->sched.ple_data_quota += ple_data_quota; mutex_unlock(&sdio->sched.lock); + + return pse_data_quota + ple_data_quota + pse_mcu_quota; } static struct sk_buff *mt7663s_build_rx_skb(void *data, int data_len, @@ -259,10 +278,8 @@ void mt7663s_rx_work(struct work_struct *work) } } - if (intr->isr & WHIER_TX_DONE_INT_EN) { - mt7663s_refill_sched_quota(dev, intr->tx.wtqcr); + if (mt7663s_refill_sched_quota(dev, intr->tx.wtqcr)) queue_work(sdio->txrx_wq, &sdio->tx.xmit_work); - } if (nframes) { queue_work(sdio->txrx_wq, &sdio->rx.recv_work); From patchwork Sat Sep 5 09:26:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 259386 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E781C43461 for ; Sat, 5 Sep 2020 09:26:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 34B3E206A5 for ; Sat, 5 Sep 2020 09:26:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599297990; bh=YIftfxD2XJ7ikfzyIsGJ9Eqff2OMPAJrwVxIyVY6D48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=x2cjhUEp4vdUCSzVDGm20AAy6neu4YPwVE151qx3tE2XfohcYu4spVu6Gg2RXY9le W5HIFB6gzBLC90oIQ8a+EWIClSpeL+ahHEvsZDNYO+pEzl4MA57xSPszjdINjTNsXE WTZpAblXscnRB18hm3yzNMUdN+VFoB72+iCaMra4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728376AbgIEJ03 (ORCPT ); Sat, 5 Sep 2020 05:26:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:40276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728347AbgIEJ00 (ORCPT ); Sat, 5 Sep 2020 05:26:26 -0400 Received: from localhost.localdomain (unknown [151.66.86.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB30720757; Sat, 5 Sep 2020 09:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599297985; bh=YIftfxD2XJ7ikfzyIsGJ9Eqff2OMPAJrwVxIyVY6D48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kfRKd+GflFZTdSSO2hYfuuXfLBk2ftJa700PR6IgHfFdPIA5CduQfYxrY26ikfspN FJcwVflE0Boi8MY3bYZMqyS09F4EnEqEpC0CDnNDG+eQDjdGDJdrpM562wgFYQeJeI 2SZ7hzhd6SQkb36ZT+vAAJtTtE/BdHRN0q9M0Cgo= From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org, sean.wang@mediatek.com Subject: [PATCH 7/7] mt76: mt7663: check isr read return value in mt7663s_rx_work Date: Sat, 5 Sep 2020 11:26:07 +0200 Message-Id: X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org In order to avoid using stale isr values, check return value from sdio_readsb() in mt7663s_rx_work() Tested-by: Sean Wang Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c index e82f6bdcbce4..2486cda3243b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c @@ -278,9 +278,12 @@ void mt7663s_rx_work(struct work_struct *work) /* disable interrupt */ sdio_claim_host(sdio->func); sdio_writel(sdio->func, WHLPCR_INT_EN_CLR, MCR_WHLPCR, NULL); - sdio_readsb(sdio->func, intr, MCR_WHISR, sizeof(struct mt76s_intr)); + ret = sdio_readsb(sdio->func, intr, MCR_WHISR, sizeof(*intr)); sdio_release_host(sdio->func); + if (ret < 0) + goto out; + trace_dev_irq(dev, intr->isr, 0); if (intr->isr & WHIER_RX0_DONE_INT_EN) { @@ -306,7 +309,7 @@ void mt7663s_rx_work(struct work_struct *work) queue_work(sdio->txrx_wq, &sdio->rx.recv_work); return; } - +out: /* enable interrupt */ sdio_claim_host(sdio->func); sdio_writel(sdio->func, WHLPCR_INT_EN_SET, MCR_WHLPCR, NULL);