From patchwork Fri Aug 24 10:41: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: 10575189 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 52D7E921 for ; Fri, 24 Aug 2018 10:42:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40EA42C42B for ; Fri, 24 Aug 2018 10:42:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 334F92C441; Fri, 24 Aug 2018 10:42: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 DB15F2C42B for ; Fri, 24 Aug 2018 10:42:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726785AbeHXOQK (ORCPT ); Fri, 24 Aug 2018 10:16:10 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33953 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726382AbeHXOQK (ORCPT ); Fri, 24 Aug 2018 10:16:10 -0400 Received: by mail-wr1-f67.google.com with SMTP id g33-v6so7095818wrd.1 for ; Fri, 24 Aug 2018 03:42: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:in-reply-to :references; bh=he4Q34xE9otFhWJXIi3VYXQeJPaz1eEQv/2HQ4kS4jI=; b=DdBs0qlBcr19rIbK9hZSS29PN5HgkD2dUsRDof/fWJLx7Cf36dZSZVjq2gBaq7CKuG Du+CVCxyj8QDbWiokjOIhSdfbn6bomzBOW1c9cAfMy181q4pI+y0nQNjK4nXuIn6Oxvu a6tjMyDh6Wrrso9QqtlcUcFKYxDqxclpUpdsnUP0SCTOkhrsY1Xtk2s463bMOk6aNn8Q iLDQn7X1niAIdLEIlamVMheAkmzXxg73kqljfQSONfe1fghIDOHlM0XSFbVM0TQzlTQR clk1nsSoX1gq22krELzpkIFem5vTX39Aey90yC1ePU5ASmlPkTDmoFCRZM2NbxiZKjyD qL6w== X-Gm-Message-State: APzg51B5nBoq8YuOETdNS/NSG7z8YgwJT2Xf1K8bdqyZDVibNhn/8QSY KxCxLCc1C10xzevQAysFS14cM1ZGzCs= X-Google-Smtp-Source: ANB0Vdab7Z15pd942sX7p8EH1B5eO+BdygPxKaI/kS9GOILsSIWabw4WZ8bkJ3Y1ir6pwk+EqA77Yw== X-Received: by 2002:a5d:4a44:: with SMTP id v4-v6mr819801wrs.278.1535107325717; Fri, 24 Aug 2018 03:42:05 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id r140-v6sm1355647wmd.7.2018.08.24.03.42.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Aug 2018 03:42:05 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org Subject: [PATCH] mt76: verify evt type in usb mcu response Date: Fri, 24 Aug 2018 12:41:44 +0200 Message-Id: <56664707fd600dc2ff49c6e845b0d573a9cf9c89.1535106415.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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 Verify if evt field is set to EVT_CMD_DONE in usb mcu response messages Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/dma.h | 10 ++++++++++ drivers/net/wireless/mediatek/mt76/usb_mcu.c | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/dma.h b/drivers/net/wireless/mediatek/mt76/dma.h index 27248e24a19b..828e52ae70e8 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.h +++ b/drivers/net/wireless/mediatek/mt76/dma.h @@ -75,6 +75,16 @@ enum dma_msg_port { DISCARD, }; +enum mt76_mcu_evt_type { + EVT_CMD_DONE, + EVT_CMD_ERROR, + EVT_CMD_RETRY, + EVT_EVENT_PWR_RSP, + EVT_EVENT_WOW_RSP, + EVT_EVENT_CARRIER_DETECT_RSP, + EVT_EVENT_DFS_DETECT_RSP, +}; + int mt76_dma_attach(struct mt76_dev *dev); void mt76_dma_cleanup(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 070be803d463..ebf3e7ffb26b 100644 --- a/drivers/net/wireless/mediatek/mt76/usb_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/usb_mcu.c @@ -73,7 +73,8 @@ static int mt76u_mcu_wait_resp(struct mt76_dev *dev, u8 seq) if (ret) return ret; - if (seq == FIELD_GET(MT_RX_FCE_INFO_CMD_SEQ, rxfce)) + if (seq == FIELD_GET(MT_RX_FCE_INFO_CMD_SEQ, rxfce) && + FIELD_GET(MT_RX_FCE_INFO_EVT_TYPE, rxfce) == EVT_CMD_DONE) return 0; dev_err(dev->dev, "error: MCU resp evt:%lx seq:%hhx-%lx\n",