Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4511691rdb; Tue, 12 Dec 2023 01:15:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHp6q//8Jv4CHMha4h7LsVtYDBdz0ArOv5Ja8jPT+t/KBJyjGrVs/KAdw6Xi4K+nS67mKz4 X-Received: by 2002:a17:902:d2cc:b0:1d0:6ffd:9dff with SMTP id n12-20020a170902d2cc00b001d06ffd9dffmr6463575plc.81.1702372533366; Tue, 12 Dec 2023 01:15:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702372533; cv=none; d=google.com; s=arc-20160816; b=Wl5jyneNQvWzUDDEgNT8e71yZP4Qmz/9MxMiv2IV5eJtNZWfJnwwDnGoIka8SbP6YL 7M57zpik9dDancxlR/PGEMWWooVPWEzHaklnia9jGB+dOcS5XGgfKJ2vIzSLNtMkiTjh PNUZeaEYGNa4wSp6LraFqA6n5pwX4MWDTJ11vXLPsqI76Y1GhjysrIXfUJzSFzzoMkev 1MdmGF6dEVV6v1LvA7DWjiy5FZ4sIAOhMQr8QmkW9WGJTBpziHRZPdsqhDxndlaAfyhM pdi4sl2L/o2t+8qU7cU9lL5+CwfrYQ59dgrrCPCHupq1AelColTOlxJXVtlPYWhVUkiI KgTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=96+j9aGxQ5Y7iyfnjMiVRLE8RGTxe0kvMDjdm0h6FTQ=; fh=X2ZC6psv4/zBHH0WR9oux/AjIXf+J28PNfx273zG39c=; b=IwTKDXZZTePxEPA9JZ/E3Z/DY+eI39EC2L3Tda77SNhYxG3AX5NUKCUHzVxh+cGgsZ JvxA3/4etgQdYRPlFc1qAFlJ8bhH4vzj2GvouRhKLo/x089eF859m2v0hwGbPMz/NfS4 6FWKyvQT77aEznaA7Y2XOxxaCUSeHLEGAVdTIGTqRw+y83Hh8GeEuAMWPZ2kRqdNOp82 ghZiv5gOQw2HAx2PiRXZdqzutNv2bY3pOAMwqotJGu78p7cq6mv2Cy1HJfthezXOfcsC WzfpX3vhQGNXdIrPrXTRwsejVgwP4ppU32u76TLEdso2+ix+O/k8NfWDfjL0eCZSxbE8 2h+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NTzWB8E3; spf=pass (google.com: domain of linux-wireless+bounces-689-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-689-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h16-20020a170902ac9000b001cfdb94ee48si205346plr.376.2023.12.12.01.15.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 01:15:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-689-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NTzWB8E3; spf=pass (google.com: domain of linux-wireless+bounces-689-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-689-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4A667B20C1A for ; Tue, 12 Dec 2023 09:15:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17B615812A; Tue, 12 Dec 2023 09:15:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NTzWB8E3" X-Original-To: linux-wireless@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFCE15811B for ; Tue, 12 Dec 2023 09:15:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CEE2C433C7; Tue, 12 Dec 2023 09:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702372527; bh=FR6eSFR1DdCBefwAt+83BDLOHz5IyrhGNmJV1nYYKmw=; h=From:To:Cc:Subject:Date:From; b=NTzWB8E310b4xVRFr26JzLuPUehbe2Hi0iQ0WxAO7iQcr5mmefg7AGQ24lCCqDQmL XvLV88D9UBwOCMxTGpG/M8Yh83OMlCK9Ts4ZSkdGt4aefsUwCClKD/8ms8fVuNJ4Kp nMl4LrzxWZMrle94r0KxpBnZF3LTBGCfloRxYYfWliMXUuZ6r/bzmwHFnXoIpEoXJ1 6XB8GRqB1dXZzy10zUlXGWDvZihDTgX+VuXvetcIHT1BZNwV7zlSmkylLrvqjxShm5 sTr7OUPxNATsSQn9gOKdy3WE1jyJFwdpl3X/XSksFaNE5hCAJPE3Z9KA3cXBid0dr6 T/F2Cq6O7wrLQ== From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org Subject: [PATCH v2] wifi: mt76: set page_pool napi pointer for mmio devices Date: Tue, 12 Dec 2023 10:15:19 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In order to recycle skbs in the page_pool "hot" cache in napi_pp_put_page routine, set napi pointer for MMIO devices in mt76_create_page_pool(). Signed-off-by: Lorenzo Bianconi --- Changes since v1: - do not allocate page_pools for tx queues --- drivers/net/wireless/mediatek/mt76/mac80211.c | 10 +++++++++- drivers/net/wireless/mediatek/mt76/mt76.h | 12 ++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index 5cc608d20619..516980cf4caf 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c @@ -579,13 +579,18 @@ EXPORT_SYMBOL_GPL(mt76_unregister_phy); int mt76_create_page_pool(struct mt76_dev *dev, struct mt76_queue *q) { + bool is_qrx = mt76_queue_is_rx(dev, q); struct page_pool_params pp_params = { .order = 0, .flags = 0, .nid = NUMA_NO_NODE, .dev = dev->dma_dev, }; - int idx = q - dev->q_rx; + int idx = is_qrx ? q - dev->q_rx : -1; + + /* Allocate page_pools just for rx/wed_tx_free queues */ + if (!is_qrx && !mt76_queue_is_wed_tx_free(q)) + return 0; switch (idx) { case MT_RXQ_MAIN: @@ -604,6 +609,9 @@ int mt76_create_page_pool(struct mt76_dev *dev, struct mt76_queue *q) pp_params.dma_dir = DMA_FROM_DEVICE; pp_params.max_len = PAGE_SIZE; pp_params.offset = 0; + /* NAPI is available just for rx queues */ + if (idx >= 0 && idx < ARRAY_SIZE(dev->napi)) + pp_params.napi = &dev->napi[idx]; } q->page_pool = page_pool_create(&pp_params); diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index c7286dbeeaae..0da88f153427 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -1613,6 +1613,18 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy, struct mt76_power_limits *dest, s8 target_power); +static inline bool mt76_queue_is_rx(struct mt76_dev *dev, struct mt76_queue *q) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) { + if (q == &dev->q_rx[i]) + return true; + } + + return false; +} + static inline bool mt76_queue_is_wed_tx_free(struct mt76_queue *q) { return (q->flags & MT_QFLAG_WED) && -- 2.43.0