From patchwork Tue Aug 27 11:07:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 2850126 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 96E99BF546 for ; Tue, 27 Aug 2013 11:09:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 536ED20306 for ; Tue, 27 Aug 2013 11:09:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5B5DB20263 for ; Tue, 27 Aug 2013 11:09:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752343Ab3H0LJu (ORCPT ); Tue, 27 Aug 2013 07:09:50 -0400 Received: from ebb05.tieto.com ([131.207.168.36]:62807 "EHLO ebb05.tieto.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751971Ab3H0LJt (ORCPT ); Tue, 27 Aug 2013 07:09:49 -0400 X-AuditID: 83cfa824-b7f348e000004c45-e6-521c88fbb948 Received: from FIHGA-EXHUB01.eu.tieto.com ( [131.207.136.34]) by ebb05.tieto.com (SMTP Mailer) with SMTP id 4B.D7.19525.BF88C125; Tue, 27 Aug 2013 14:09:47 +0300 (EEST) Received: from uw001058.eu.tieto.com (10.28.19.57) by inbound.tieto.com (131.207.136.49) with Microsoft SMTP Server id 8.3.298.1; Tue, 27 Aug 2013 14:09:46 +0300 From: Michal Kazior To: CC: , Michal Kazior Subject: [PATCH v2 1/6] ath10k: use inline ce_state structure Date: Tue, 27 Aug 2013 13:07:58 +0200 Message-ID: <1377601683-12072-2-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1377601683-12072-1-git-send-email-michal.kazior@tieto.com> References: <1377068249-26025-1-git-send-email-michal.kazior@tieto.com> <1377601683-12072-1-git-send-email-michal.kazior@tieto.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFIsWRmVeSWpSXmKPExsXSfL5DSfd3h0yQwdIdAhaPLh1jtniz4g67 xbetD9gcmD0+z7zL5rF5Sb3H501yAcxRXDYpqTmZZalF+nYJXBk3175gKmiWrfj97QNbA+M6 iS5GTg4JAROJJ2f3s0LYYhIX7q1n62Lk4hASWMUocfnhA2YIZymjxNyO/4wgVWwCuhKvGs+C dYgIKEj8mvSRDcRmFvCVePZkGROILSxgK7H83DV2EJtFQFVibc8msBpeAXeJR5uvA8U5gLYp SMyZZAMS5hTwkHi2aQYrxK5WRok5l2YyQdQLSpyc+YQFYr6ExMEXL5hBbCEBFYmD6/czT2AU mIWkbBaSsgWMTKsY+VOTkgxM9UoyU0vy9ZLzczcxgoNwhcoOxrMPpA4xCnAwKvHwPmiRDhJi TSwrrsw9xCjJwaQkynuuTSZIiC8pP6UyI7E4I76oNCe1+BCjBAezkgjv1GagHG9KYmVValE+ TEqag0VJnDdXUSxISCA9sSQ1OzW1ILUIJivDwaEkwdvZDtQoWJSanlqRlplTgpBm4uAEGc4D NDwVpIa3uCAxtzgzHSJ/ilFRSpw3BSQhAJLIKM2D64UliVeM4kCvCPMWg1TxABMMXPcroMFM QIMPLpcEGVySiJCSamA8kHpvIoPUrhl3Fjw7qfmK6XMCZ+1M1YJ0r2XWrmfni25mnRb8U+6/ 2HQnX2PrJL5XVTrKeREd7mdPCDCsYjkskqbKNWlBXoauT+1rQx2FbyXvWF03xCbn95sfCtdY lnjkwHa17oQyf03GkA8vvnp+KOvM4uJgn/R1hmuJwpxzErXrev1nPFNiKc5INNRiLipOBAB8 3DiA7QIAAA== Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Simplifies memory managament of ce_state. Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/ce.c | 37 ++++++++++++--------------------- drivers/net/wireless/ath/ath10k/pci.h | 5 ++++- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c index 1a702e1..c8b7d21 100644 --- a/drivers/net/wireless/ath/ath10k/ce.c +++ b/drivers/net/wireless/ath/ath10k/ce.c @@ -727,7 +727,7 @@ int ath10k_ce_completed_send_next(struct ce_state *ce_state, void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id) { struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); - struct ce_state *ce_state = ar_pci->ce_id_to_state[ce_id]; + struct ce_state *ce_state = &ar_pci->ce_states[ce_id]; u32 ctrl_addr = ce_state->ctrl_addr; void *transfer_context; u32 buf; @@ -846,7 +846,7 @@ void ath10k_ce_disable_interrupts(struct ath10k *ar) ath10k_pci_wake(ar); for (ce_id = 0; ce_id < ar_pci->ce_count; ce_id++) { - struct ce_state *ce_state = ar_pci->ce_id_to_state[ce_id]; + struct ce_state *ce_state = &ar_pci->ce_states[ce_id]; u32 ctrl_addr = ce_state->ctrl_addr; ath10k_ce_copy_complete_intr_disable(ar, ctrl_addr); @@ -1081,27 +1081,17 @@ static struct ce_state *ath10k_ce_init_state(struct ath10k *ar, const struct ce_attr *attr) { struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); - struct ce_state *ce_state = NULL; + struct ce_state *ce_state = &ar_pci->ce_states[ce_id]; u32 ctrl_addr = ath10k_ce_base_address(ce_id); spin_lock_bh(&ar_pci->ce_lock); - if (!ar_pci->ce_id_to_state[ce_id]) { - ce_state = kzalloc(sizeof(*ce_state), GFP_ATOMIC); - if (ce_state == NULL) { - spin_unlock_bh(&ar_pci->ce_lock); - return NULL; - } - - ar_pci->ce_id_to_state[ce_id] = ce_state; - ce_state->ar = ar; - ce_state->id = ce_id; - ce_state->ctrl_addr = ctrl_addr; - ce_state->state = CE_RUNNING; - /* Save attribute flags */ - ce_state->attr_flags = attr->flags; - ce_state->src_sz_max = attr->src_sz_max; - } + ce_state->ar = ar; + ce_state->id = ce_id; + ce_state->ctrl_addr = ctrl_addr; + ce_state->state = CE_RUNNING; + ce_state->attr_flags = attr->flags; + ce_state->src_sz_max = attr->src_sz_max; spin_unlock_bh(&ar_pci->ce_lock); @@ -1159,13 +1149,9 @@ struct ce_state *ath10k_ce_init(struct ath10k *ar, void ath10k_ce_deinit(struct ce_state *ce_state) { - unsigned int ce_id = ce_state->id; struct ath10k *ar = ce_state->ar; struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); - ce_state->state = CE_UNUSED; - ar_pci->ce_id_to_state[ce_id] = NULL; - if (ce_state->src_ring) { kfree(ce_state->src_ring->shadow_base_unaligned); pci_free_consistent(ar_pci->pdev, @@ -1186,5 +1172,8 @@ void ath10k_ce_deinit(struct ce_state *ce_state) ce_state->dest_ring->base_addr_ce_space); kfree(ce_state->dest_ring); } - kfree(ce_state); + + ce_state->state = CE_UNUSED; + ce_state->src_ring = NULL; + ce_state->dest_ring = NULL; } diff --git a/drivers/net/wireless/ath/ath10k/pci.h b/drivers/net/wireless/ath/ath10k/pci.h index 153ae28..64fcef5 100644 --- a/drivers/net/wireless/ath/ath10k/pci.h +++ b/drivers/net/wireless/ath/ath10k/pci.h @@ -233,7 +233,10 @@ struct ath10k_pci { spinlock_t ce_lock; /* Map CE id to ce_state */ - struct ce_state *ce_id_to_state[CE_COUNT_MAX]; + struct ce_state ce_states[CE_COUNT_MAX]; + + /* makes sure that dummy reads are atomic */ + spinlock_t hw_v1_workaround_lock; }; static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar)