From patchwork Thu Sep 4 08:18:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 4843341 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C86A79F390 for ; Thu, 4 Sep 2014 08:29:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CB129201FB for ; Thu, 4 Sep 2014 08:29:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A75CE20160 for ; Thu, 4 Sep 2014 08:29:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754294AbaIDI32 (ORCPT ); Thu, 4 Sep 2014 04:29:28 -0400 Received: from mail-lb0-f182.google.com ([209.85.217.182]:39714 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751356AbaIDI30 (ORCPT ); Thu, 4 Sep 2014 04:29:26 -0400 Received: by mail-lb0-f182.google.com with SMTP id u10so11116251lbd.13 for ; Thu, 04 Sep 2014 01:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id; bh=nAoIG0gK0Xa30NAu1e7/DKcmKiIcfpe94DCi8yx1Qx8=; b=r7IevBKrYolWKhl96bTUORVX3040cziZLpsuDY8+EsD14GMHuE/Uv5Sw6WfocS7Kgi 7SRbLKTRr4End2kozwOg5/LIdupLRapQAcg6bWKyFmIBbEQ13IWziYKHyM88GfsLXrth N3U9UPQoorB5JaLQprb4cPvMfbqk5Orga22Wk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nAoIG0gK0Xa30NAu1e7/DKcmKiIcfpe94DCi8yx1Qx8=; b=mb8pUC9YF/pEzXzfDr3G9BouYIUfn9I7jYyPyCSnj24dtQgxteHTW53kd/RNs8Zfa6 XLqWUUj2DL5Hci45LbRnOQCkYm5aWARQlzNjQfRgoTmm3Ir0Auj/vBbMrR+grscNMIot mrgHtzeOdFq4PatZA0NsNDAQ26l8fLOOFLVZAFHLgK3Gn7dwv+H/U+on0E1un/h+Egrf BUhH8A3KzOtQbs6D8HsB2wjIAseHeucckSapl6TSWWhdafDHM3tPey48ZoiQWM92TGVK oVK6jxwCq+0mYFN0NjX3EQ8KBk8GYA3ARfFkN2N9/oJAHPMsILDGjeL/0HL74sTX0bU8 5QgQ== X-Gm-Message-State: ALoCoQmJcdEc9NlbhqZZ+ciiW0hGNvOEZiZ+O2xm8EPE2G9/QzXBlE3n4FqbxkVQhTrkDE72YEDPvFQYxP1w8oU7cMXI4H7Emy3uhPCdHQNDqEVsPt9qKDa0o2KzG9O9LAAb3YBoPNzX X-Received: by 10.152.121.8 with SMTP id lg8mr1811616lab.98.1409819364026; Thu, 04 Sep 2014 01:29:24 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id vz9sm300754lbb.16.2014.09.04.01.29.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Sep 2014 01:29:23 -0700 (PDT) From: Michal Kazior To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Michal Kazior Subject: [PATCH] ath10k: use proper service bitmap size Date: Thu, 4 Sep 2014 10:18:32 +0200 Message-Id: <1409818712-7493-1-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.8.5.3 X-DomainID: tieto.com Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 32bit systems the bitmap was too small and it was overwritten partially by the stat completion structure. This was visible with 10.2 firmware only due to it using a few of the last service ids. Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/core.h | 2 +- drivers/net/wireless/ath/ath10k/debug.c | 2 +- drivers/net/wireless/ath/ath10k/wmi.c | 4 ++-- drivers/net/wireless/ath/ath10k/wmi.h | 12 +++++------- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index 797741d..a2695e3 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -293,7 +293,7 @@ struct ath10k_debug { struct dentry *debugfs_phy; struct ath10k_target_stats target_stats; - DECLARE_BITMAP(wmi_service_bitmap, WMI_SERVICE_BM_SIZE); + DECLARE_BITMAP(wmi_service_bitmap, WMI_SERVICE_MAX); struct completion event_stats_compl; diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c index d922ef4..e487064 100644 --- a/drivers/net/wireless/ath/ath10k/debug.c +++ b/drivers/net/wireless/ath/ath10k/debug.c @@ -208,7 +208,7 @@ static ssize_t ath10k_read_wmi_services(struct file *file, if (len > buf_len) len = buf_len; - for (i = 0; i < WMI_MAX_SERVICE; i++) { + for (i = 0; i < WMI_SERVICE_MAX; i++) { enabled = test_bit(i, ar->debug.wmi_service_bitmap); name = wmi_service_name(i); diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c index b13ccf6..e7edc89 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c @@ -2164,7 +2164,7 @@ static void ath10k_wmi_service_ready_event_rx(struct ath10k *ar, struct sk_buff *skb) { struct wmi_service_ready_event *ev = (void *)skb->data; - DECLARE_BITMAP(svc_bmap, WMI_SERVICE_BM_SIZE) = {}; + DECLARE_BITMAP(svc_bmap, WMI_SERVICE_MAX) = {}; if (skb->len < sizeof(*ev)) { ath10k_warn(ar, "Service ready event was %d B but expected %zu B. Wrong firmware version?\n", @@ -2241,7 +2241,7 @@ static void ath10k_wmi_10x_service_ready_event_rx(struct ath10k *ar, u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i; int ret; struct wmi_service_ready_event_10x *ev = (void *)skb->data; - DECLARE_BITMAP(svc_bmap, WMI_SERVICE_BM_SIZE) = {}; + DECLARE_BITMAP(svc_bmap, WMI_SERVICE_MAX) = {}; if (skb->len < sizeof(*ev)) { ath10k_warn(ar, "Service ready event was %d B but expected %zu B. Wrong firmware version?\n", diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h index e708365..bdb2e6c 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.h +++ b/drivers/net/wireless/ath/ath10k/wmi.h @@ -109,6 +109,9 @@ enum wmi_service { WMI_SERVICE_BURST, WMI_SERVICE_SMART_ANTENNA_SW_SUPPORT, WMI_SERVICE_SMART_ANTENNA_HW_SUPPORT, + + /* keep last */ + WMI_SERVICE_MAX, }; enum wmi_10x_service { @@ -219,8 +222,6 @@ static inline char *wmi_service_name(int service_id) #undef SVCSTR } -#define WMI_MAX_SERVICE 64 - #define WMI_SERVICE_IS_ENABLED(wmi_svc_bmap, svc_id) \ (__le32_to_cpu((wmi_svc_bmap)[(svc_id)/(sizeof(u32))]) & \ BIT((svc_id)%(sizeof(u32)))) @@ -347,9 +348,6 @@ static inline void wmi_main_svc_map(const __le32 *in, unsigned long *out) #undef SVCMAP -#define WMI_SERVICE_BM_SIZE \ - ((WMI_MAX_SERVICE + sizeof(u32) - 1)/sizeof(u32)) - /* 2 word representation of MAC addr */ struct wmi_mac_addr { union { @@ -1405,7 +1403,7 @@ struct wmi_service_ready_event { __le32 phy_capability; /* Maximum number of frag table entries that SW will populate less 1 */ __le32 max_frag_entry; - __le32 wmi_service_bitmap[WMI_SERVICE_BM_SIZE]; + __le32 wmi_service_bitmap[16]; __le32 num_rf_chains; /* * The following field is only valid for service type @@ -1444,7 +1442,7 @@ struct wmi_service_ready_event_10x { /* Maximum number of frag table entries that SW will populate less 1 */ __le32 max_frag_entry; - __le32 wmi_service_bitmap[WMI_SERVICE_BM_SIZE]; + __le32 wmi_service_bitmap[16]; __le32 num_rf_chains; /*