Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4044643pxj; Tue, 15 Jun 2021 14:15:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4fjTJl1EtaQOnudhL120m6j9vaqqrIRQ6iHZrPr2Eo1Hh4p0Nhf8kZKQGsdeAG52ffk31 X-Received: by 2002:a50:eb92:: with SMTP id y18mr147974edr.249.1623791709700; Tue, 15 Jun 2021 14:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623791709; cv=none; d=google.com; s=arc-20160816; b=cbTmGr5V7+9Gtty3YjEcQ8ArQZT3+W3ly4an59uCGBUUCDg8QTRDxsOJ1eLo1BgQS6 B2z7sPYsNqADiezDw48+34uoQtHj7BidN14DkWZufNz6hq4KTkL3gH8VPSxVlGo/UdZP mJ6nezpeV/7DUvrWTxufdFEPLjQPrd9xe+BtlBOr3PHen4PlCqtsgu+fHQOOa4TWGTlB 4mbgq3sEk2wV5wzoeCq/UOZRf2ZykT8kauJGhSPPWSJDHYQaT2Li6svyS+u5C2FaeBE4 ftozHfTOMH7KQorjVMXNlvJ6qD0f5Ha9rkHRBoVYBLmkhGaOpBBzSZSGseKFfbbIuSB5 dYKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:sender:dkim-signature; bh=MOt636ofN8t5xouPWoG4NqIqn35fkz0R4kJ8Lg490h8=; b=JIDhpGOx/d2YgoG3D8ZNhCJibc79r6D7cgPBNilQTLdf1Cw9erbeWEv22hM0b7PJPg yTeT7dy5rDCVQb7nXmxzw55d5Szohhv5MBxMAd51zBa1x0qBJjEB8mtJn4Xh11I2oEVE oNJAjutg0bB89kkhHLBaxjF1J7ywm+qGEkDB13XtWNJ9Bt7NEDnHqdiIHMObLIokevQG 8VpRkQgHjFrzTJ3vEXQ8zB+4irftFG96P87PAF2dfjfcWqGcbDsMMVghRfiadzLu60qt suAz+RLIvKWIyHZM8iMTPzKakNJ9WPqEYGHeMOaA2pnJ8uNHpY6UeBmSUfGX4xyNPzpm nFEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=peAc4BuC; 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 n16si9683387edw.182.2021.06.15.14.14.47; Tue, 15 Jun 2021 14:15:09 -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=pass header.i=@mg.codeaurora.org header.s=smtp header.b=peAc4BuC; 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 S231272AbhFOVQh (ORCPT + 99 others); Tue, 15 Jun 2021 17:16:37 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:40679 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229992AbhFOVQh (ORCPT ); Tue, 15 Jun 2021 17:16:37 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1623791672; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=MOt636ofN8t5xouPWoG4NqIqn35fkz0R4kJ8Lg490h8=; b=peAc4BuCokrx+aRs6ZEIaJHiTB2N3iS9Z6AjPUH+c2JOyxYXkVQk1wzk4WKkTCeAc2WMjkuu QJmkADOm1wYs5WLNT0k5MBmVYLqpJ4ogwFLnZBZuY2QA+M9bosH8QvANf3xgPDrhPBWXk9oA 9qpAsHMBuPgHxmDc8/RfRRQ37i0= X-Mailgun-Sending-Ip: 69.72.43.7 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 smtp-out-n03.prod.us-east-1.postgun.com with SMTP id 60c91838e27c0cc77fe0f04e (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 15 Jun 2021 21:14:31 GMT Sender: jouni=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 411FEC4338A; Tue, 15 Jun 2021 21:14:31 +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=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from jouni.codeaurora.org (85-76-78-13-nat.elisa-mobile.fi [85.76.78.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jouni) by smtp.codeaurora.org (Postfix) with ESMTPSA id D87F6C4323A; Tue, 15 Jun 2021 21:14:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D87F6C4323A 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=fail smtp.mailfrom=jouni@codeaurora.org From: Jouni Malinen To: Kalle Valo Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, P Praneesh , Pradeep Kumar Chitrapu , Sriram R , Jouni Malinen Subject: [PATCH 02/12] ath11k: allocate dst ring descriptors from cacheable memory Date: Wed, 16 Jun 2021 00:13:57 +0300 Message-Id: <20210615211407.92233-3-jouni@codeaurora.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210615211407.92233-1-jouni@codeaurora.org> References: <20210615211407.92233-1-jouni@codeaurora.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: P Praneesh tcl_data and reo_dst rings are currently being allocated using dma_allocate_coherent() which is non cachable. Allocating ring memory from cacheable memory area allows cached descriptor access and prefetch next descriptors to optimize CPU usage during descriptor processing on NAPI. Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.4.0.1.r2-00012-QCAHKSWPL_SILICONZ-1 Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-01695-QCAHKSWPL_SILICONZ-1 Co-developed-by: Pradeep Kumar Chitrapu Signed-off-by: Pradeep Kumar Chitrapu Co-developed-by: Sriram R Signed-off-by: Sriram R Signed-off-by: P Praneesh Signed-off-by: Jouni Malinen --- drivers/net/wireless/ath/ath11k/dp.c | 34 +++++++++++++++++++++++---- drivers/net/wireless/ath/ath11k/dp.h | 1 + drivers/net/wireless/ath/ath11k/hal.c | 25 ++++++++++++++++++-- drivers/net/wireless/ath/ath11k/hal.h | 1 + 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp.c b/drivers/net/wireless/ath/ath11k/dp.c index b0c8f6290099..cf869ebc209a 100644 --- a/drivers/net/wireless/ath/ath11k/dp.c +++ b/drivers/net/wireless/ath/ath11k/dp.c @@ -101,8 +101,11 @@ void ath11k_dp_srng_cleanup(struct ath11k_base *ab, struct dp_srng *ring) if (!ring->vaddr_unaligned) return; - dma_free_coherent(ab->dev, ring->size, ring->vaddr_unaligned, - ring->paddr_unaligned); + if (ring->cached) + kfree(ring->vaddr_unaligned); + else + dma_free_coherent(ab->dev, ring->size, ring->vaddr_unaligned, + ring->paddr_unaligned); ring->vaddr_unaligned = NULL; } @@ -222,6 +225,7 @@ int ath11k_dp_srng_setup(struct ath11k_base *ab, struct dp_srng *ring, int entry_sz = ath11k_hal_srng_get_entrysize(ab, type); int max_entries = ath11k_hal_srng_get_max_entries(ab, type); int ret; + bool cached; if (max_entries < 0 || entry_sz < 0) return -EINVAL; @@ -229,10 +233,25 @@ int ath11k_dp_srng_setup(struct ath11k_base *ab, struct dp_srng *ring, if (num_entries > max_entries) num_entries = max_entries; + /* Allocate the reo dst and tx completion rings from cacheable memory */ + switch (type) { + case HAL_REO_DST: + cached = true; + default: + cached = false; + } + ring->size = (num_entries * entry_sz) + HAL_RING_BASE_ALIGN - 1; - ring->vaddr_unaligned = dma_alloc_coherent(ab->dev, ring->size, - &ring->paddr_unaligned, - GFP_KERNEL); + + if (cached) { + ring->vaddr_unaligned = kzalloc(ring->size, GFP_KERNEL); + ring->paddr_unaligned = virt_to_phys(ring->vaddr_unaligned); + } else { + ring->vaddr_unaligned = dma_alloc_coherent(ab->dev, ring->size, + &ring->paddr_unaligned, + GFP_KERNEL); + } + if (!ring->vaddr_unaligned) return -ENOMEM; @@ -292,6 +311,11 @@ int ath11k_dp_srng_setup(struct ath11k_base *ab, struct dp_srng *ring, return -EINVAL; } + if (cached) { + params.flags |= HAL_SRNG_FLAGS_CACHED; + ring->cached = 1; + } + ret = ath11k_hal_srng_setup(ab, type, ring_num, mac_id, ¶ms); if (ret < 0) { ath11k_warn(ab, "failed to setup srng: %d ring_id %d\n", diff --git a/drivers/net/wireless/ath/ath11k/dp.h b/drivers/net/wireless/ath/ath11k/dp.h index ee768ccce46e..e6591488a28c 100644 --- a/drivers/net/wireless/ath/ath11k/dp.h +++ b/drivers/net/wireless/ath/ath11k/dp.h @@ -64,6 +64,7 @@ struct dp_srng { dma_addr_t paddr; int size; u32 ring_id; + u8 cached; }; struct dp_rxdma_ring { diff --git a/drivers/net/wireless/ath/ath11k/hal.c b/drivers/net/wireless/ath/ath11k/hal.c index eaa0edca5576..a58e86e42b5b 100644 --- a/drivers/net/wireless/ath/ath11k/hal.c +++ b/drivers/net/wireless/ath/ath11k/hal.c @@ -627,6 +627,21 @@ u32 *ath11k_hal_srng_dst_peek(struct ath11k_base *ab, struct hal_srng *srng) return NULL; } +static void ath11k_hal_srng_prefetch_desc(struct ath11k_base *ab, + struct hal_srng *srng) +{ + u32 *desc; + + /* prefetch only if desc is available */ + desc = ath11k_hal_srng_dst_peek(ab, srng); + if (likely(desc)) { + dma_sync_single_for_cpu(ab->dev, virt_to_phys(desc), + (srng->entry_size * sizeof(u32)), + DMA_FROM_DEVICE); + prefetch(desc); + } +} + u32 *ath11k_hal_srng_dst_get_next_entry(struct ath11k_base *ab, struct hal_srng *srng) { @@ -642,6 +657,10 @@ u32 *ath11k_hal_srng_dst_get_next_entry(struct ath11k_base *ab, srng->u.dst_ring.tp = (srng->u.dst_ring.tp + srng->entry_size) % srng->ring_size; + /* Try to prefetch the next descriptor in the ring */ + if (srng->flags & HAL_SRNG_FLAGS_CACHED) + ath11k_hal_srng_prefetch_desc(ab, srng); + return desc; } @@ -775,11 +794,13 @@ void ath11k_hal_srng_access_begin(struct ath11k_base *ab, struct hal_srng *srng) { lockdep_assert_held(&srng->lock); - if (srng->ring_dir == HAL_SRNG_DIR_SRC) + if (srng->ring_dir == HAL_SRNG_DIR_SRC) { srng->u.src_ring.cached_tp = *(volatile u32 *)srng->u.src_ring.tp_addr; - else + } else { srng->u.dst_ring.cached_hp = *srng->u.dst_ring.hp_addr; + ath11k_hal_srng_prefetch_desc(ab, srng); + } } /* Update cached ring head/tail pointers to HW. ath11k_hal_srng_access_begin() diff --git a/drivers/net/wireless/ath/ath11k/hal.h b/drivers/net/wireless/ath/ath11k/hal.h index 35ed3a14e200..0f4f9ce74354 100644 --- a/drivers/net/wireless/ath/ath11k/hal.h +++ b/drivers/net/wireless/ath/ath11k/hal.h @@ -513,6 +513,7 @@ enum hal_srng_dir { #define HAL_SRNG_FLAGS_DATA_TLV_SWAP 0x00000020 #define HAL_SRNG_FLAGS_LOW_THRESH_INTR_EN 0x00010000 #define HAL_SRNG_FLAGS_MSI_INTR 0x00020000 +#define HAL_SRNG_FLAGS_CACHED 0x20000000 #define HAL_SRNG_FLAGS_LMAC_RING 0x80000000 #define HAL_SRNG_TLV_HDR_TAG GENMASK(9, 1) -- 2.25.1