Message ID | 20241014105912.3207374-24-ryan.roberts@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98642D1624E for <linux-arm-kernel@archiver.kernel.org>; Mon, 14 Oct 2024 11:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2nn418B1fZ6U0bhmNO3CvxvB05kOVNrCxzyBbdDTXlE=; b=LqTu2DW95GtQS9oUqR7F/nM3VF Px3HXYtM9s+xa6ErNwUDxsny+EhS5fpo/Eo5vRlp626baezVV7HvOB4khoGdbKtclZOAylMo44hzH 18I1vsUN/o0XBtxvEBIvqvgPF3CUlYDz3/ppI1tEt7BIuhzHxVVw0UP9oI3AkpTTUzcEEZqOsYoLL 0yJij1I76oaSs+Um824rQEzue8bh4IeuhVLiqFIRWEZG/oq2Fb6SPcFidqnTClo1HDjC7B/JbW5XV 1Xw4l2SsQsLtEIfNqJ3bAXfOQLyvCi7p7Zz6kEh8PosxYgc57t73Cx5JxO6AMx0LysaHuJJB4CmM7 tkotyX0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0Jhc-000000050Pv-0jAZ; Mon, 14 Oct 2024 11:57:32 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0Ioc-00000004nxF-2OSV for linux-arm-kernel@lists.infradead.org; Mon, 14 Oct 2024 11:00:45 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B723A168F; Mon, 14 Oct 2024 04:01:11 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D51813F51B; Mon, 14 Oct 2024 04:00:38 -0700 (PDT) From: Ryan Roberts <ryan.roberts@arm.com> To: "David S. Miller" <davem@davemloft.net>, Andrew Morton <akpm@linux-foundation.org>, Anshuman Khandual <anshuman.khandual@arm.com>, Ard Biesheuvel <ardb@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, David Hildenbrand <david@redhat.com>, Eric Dumazet <edumazet@google.com>, Greg Marsden <greg.marsden@oracle.com>, Ivan Ivanov <ivan.ivanov@suse.com>, Jakub Kicinski <kuba@kernel.org>, Kalesh Singh <kaleshsingh@google.com>, Marc Zyngier <maz@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Matthias Brugger <mbrugger@suse.com>, Miroslav Benes <mbenes@suse.cz>, Paolo Abeni <pabeni@redhat.com>, Wei Fang <wei.fang@nxp.com>, Will Deacon <will@kernel.org> Cc: Ryan Roberts <ryan.roberts@arm.com>, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org Subject: [RFC PATCH v1 24/57] net: fec: Remove PAGE_SIZE compile-time constant assumption Date: Mon, 14 Oct 2024 11:58:31 +0100 Message-ID: <20241014105912.3207374-24-ryan.roberts@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014105912.3207374-1-ryan.roberts@arm.com> References: <20241014105514.3206191-1-ryan.roberts@arm.com> <20241014105912.3207374-1-ryan.roberts@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_040042_712401_6659A0C1 X-CRM114-Status: GOOD ( 14.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
Boot-time page size selection for arm64
|
expand
|
diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index a19cb2a786fd2..afc8b3f360555 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -571,7 +571,6 @@ struct fec_enet_priv_tx_q { struct fec_enet_priv_rx_q { struct bufdesc_prop bd; - struct fec_enet_priv_txrx_info rx_skb_info[RX_RING_SIZE]; /* page_pool */ struct page_pool *page_pool; @@ -580,6 +579,8 @@ struct fec_enet_priv_rx_q { /* rx queue number, in the range 0-7 */ u8 id; + + struct fec_enet_priv_txrx_info rx_skb_info[]; }; struct fec_stop_mode_gpr { diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index a923cb95cdc62..b9214c12d537e 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3339,6 +3339,8 @@ static int fec_enet_alloc_queue(struct net_device *ndev) int i; int ret = 0; struct fec_enet_priv_tx_q *txq; + size_t rxq_sz = struct_size(fep->rx_queue[0], rx_skb_info, RX_RING_SIZE); + for (i = 0; i < fep->num_tx_queues; i++) { txq = kzalloc(sizeof(*txq), GFP_KERNEL); @@ -3364,8 +3366,7 @@ static int fec_enet_alloc_queue(struct net_device *ndev) } for (i = 0; i < fep->num_rx_queues; i++) { - fep->rx_queue[i] = kzalloc(sizeof(*fep->rx_queue[i]), - GFP_KERNEL); + fep->rx_queue[i] = kzalloc(rxq_sz, GFP_KERNEL); if (!fep->rx_queue[i]) { ret = -ENOMEM; goto alloc_failed;
To prepare for supporting boot-time page size selection, refactor code to remove assumptions about PAGE_SIZE being compile-time constant. Code intended to be equivalent when compile-time page size is active. Refactored "struct fec_enet_priv_rx_q" to use a flexible array member for "rx_skb_info", since its length depends on PAGE_SIZE. Signed-off-by: Ryan Roberts <ryan.roberts@arm.com> --- ***NOTE*** Any confused maintainers may want to read the cover note here for context: https://lore.kernel.org/all/20241014105514.3206191-1-ryan.roberts@arm.com/ drivers/net/ethernet/freescale/fec.h | 3 ++- drivers/net/ethernet/freescale/fec_main.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)