Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp436454ybz; Tue, 21 Apr 2020 11:57:54 -0700 (PDT) X-Google-Smtp-Source: APiQypL/R+xklKtgl8AIO3qmZvy1sdXR5Dg6ZtSQuRp6v5+LF0u4AZrr3h9VieQg3b+NpHYf1/yj X-Received: by 2002:a17:906:3443:: with SMTP id d3mr23492996ejb.18.1587495473804; Tue, 21 Apr 2020 11:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587495473; cv=none; d=google.com; s=arc-20160816; b=pq81D/84Ha7lOg6EAShD1mRueCo1gBd97pekj8qLG0GLXNJPjoUJiImKMI+6GlLIgC 8LrR8yX7CjF5Et8F/Ifl9yJVoNuOGGYxUBe5mruXUC+QymUq1D6BsPqYaxlc49JJ6GBi 01aTpfuP057BhVdkcBvvNSkei+Bqg5UHKU1oIjbCcDMsJjtV3kKtnltLB18gvMLyzLBq l4EIUdmENimU5te4ZbwjNkEkUKGuYLtgaBECac6GZmV9XdIPu2VtfEkdB48XxTQeNSmn 8iJZOJc0qtTuFb+wW9rBVV8TePL68WDzUDQHVGJQAlwGz0jUfACg31g3qiM98msSZf6U ClEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature; bh=rLICmTBof8eKNqnysvQtRNeSf1lVpHeOKoMNOJQq6dA=; b=qUaVI/Qtus3kYCVi1PBCZQ1dTo9Q6f60LbmYSjViE9n98aC+W52MKZsHXBVDNi/Wz1 HgeeAWukpK+OO+EQdvAohvlZMlV27XUAEbi9PUdMFR0WXkDTDDXf3f0o41YyIOCZ/GLE aJ9QBbkt/r5Onny9sfh4sZtIb7lapVq0KYVeHgImA2ttJFCIuTCxtNDVnb70aUySFI94 Jcy/FHYfdVhsylzcaHNOt5nrScpaINi/eV91Jm35pcNOJDeltYYdTO64GvlcYaq2AshV 3e7Rol2PGf4oilgfX9a1Xz5jzL1gz8w6Q/LLWt3UrO3OZnj8SWAga509V7bKqHGJC2n8 tgeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=SjPXyMWj; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a24si2044196eds.168.2020.04.21.11.57.18; Tue, 21 Apr 2020 11:57:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=SjPXyMWj; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726006AbgDUS5N (ORCPT + 99 others); Tue, 21 Apr 2020 14:57:13 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:18080 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725870AbgDUS5L (ORCPT ); Tue, 21 Apr 2020 14:57:11 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1587495431; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=rLICmTBof8eKNqnysvQtRNeSf1lVpHeOKoMNOJQq6dA=; b=SjPXyMWj+9MTbqVT6lb8ksV370REGiG8E5rZzg/6EWBEoqXrXiAkL7b7RWsEn5SZaka+rWVE SWHmkOXGCNERf5TzEmr9l1lm/Flg5H4fyvQfrhlldPN60Dx8a7DYkO17LV88THTyy7eV+bug suLyZmlM9AhIU1h4b69qEBZS+x8= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e9f4207.7fe20035b6f8-smtp-out-n02; Tue, 21 Apr 2020 18:57:11 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 08B0EC433F2; Tue, 21 Apr 2020 18:57:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from che-swdbs-01.qca.qualcomm.com (blr-c-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: mkenna) by smtp.codeaurora.org (Postfix) with ESMTPSA id 16DD7C433D2; Tue, 21 Apr 2020 18:57:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 16DD7C433D2 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=mkenna@codeaurora.org From: Maharaja Kennadyrajan To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Maharaja Kennadyrajan Subject: [PATCH] ath10k: Fix the invalid tx/rx chainmask configuration Date: Wed, 22 Apr 2020 00:28:32 +0530 Message-Id: <1587495512-29813-1-git-send-email-mkenna@codeaurora.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The driver is allowing the invalid tx/rx chainmask configuration (other than 1,3,7,15) set by the user. It causes the firmware crash due to the invalid chainmask values. Hence, reject the invalid chainmask values in the driver by not sending the pdev set command to the firmware. Tested hardware: QCA9888 Tested firmware: 10.4-3.10-00047 Signed-off-by: Maharaja Kennadyrajan --- drivers/net/wireless/ath/ath10k/mac.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index a59a7a5..a9f91a1 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -4529,17 +4529,18 @@ static int ath10k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant) return 0; } -static void ath10k_check_chain_mask(struct ath10k *ar, u32 cm, const char *dbg) +static bool ath10k_check_chain_mask(struct ath10k *ar, u32 cm, const char *dbg) { /* It is not clear that allowing gaps in chainmask * is helpful. Probably it will not do what user * is hoping for, so warn in that case. */ if (cm == 15 || cm == 7 || cm == 3 || cm == 1 || cm == 0) - return; + return true; - ath10k_warn(ar, "mac %s antenna chainmask may be invalid: 0x%x. Suggested values: 15, 7, 3, 1 or 0.\n", + ath10k_warn(ar, "mac %s antenna chainmask is invalid: 0x%x. Suggested values: 15, 7, 3, 1 or 0.\n", dbg, cm); + return false; } static int ath10k_mac_get_vht_cap_bf_sts(struct ath10k *ar) @@ -4722,11 +4723,15 @@ static void ath10k_mac_setup_ht_vht_cap(struct ath10k *ar) static int __ath10k_set_antenna(struct ath10k *ar, u32 tx_ant, u32 rx_ant) { int ret; + bool is_valid_tx_chain_mask, is_valid_rx_chain_mask; lockdep_assert_held(&ar->conf_mutex); - ath10k_check_chain_mask(ar, tx_ant, "tx"); - ath10k_check_chain_mask(ar, rx_ant, "rx"); + is_valid_tx_chain_mask = ath10k_check_chain_mask(ar, tx_ant, "tx"); + is_valid_rx_chain_mask = ath10k_check_chain_mask(ar, rx_ant, "rx"); + + if (!is_valid_tx_chain_mask || !is_valid_rx_chain_mask) + return -EINVAL; ar->cfg_tx_chainmask = tx_ant; ar->cfg_rx_chainmask = rx_ant; -- 1.9.1