From patchwork Mon Oct 14 10:58:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13834692 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57B84D1A43B for ; Mon, 14 Oct 2024 11:00:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E16896B0083; Mon, 14 Oct 2024 07:00:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DBEB26B009A; Mon, 14 Oct 2024 07:00:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5B1B6B00AC; Mon, 14 Oct 2024 07:00:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A37BC6B0083 for ; Mon, 14 Oct 2024 07:00:44 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0C631160D34 for ; Mon, 14 Oct 2024 11:00:36 +0000 (UTC) X-FDA: 82671914556.03.7A737A7 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf03.hostedemail.com (Postfix) with ESMTP id A983F20002 for ; Mon, 14 Oct 2024 11:00:39 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728903596; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2nn418B1fZ6U0bhmNO3CvxvB05kOVNrCxzyBbdDTXlE=; b=THoQRclw6AsZsqbxqdbzLdi5/xSGON7zkvneum8icjKZk3DZhIpUxz0LA2NdfbZ5PJTvBc wwZl25l0ot6RsLgj7oSp8gO9Fk6HQlSa4sKRAOWAslaIbkpMQvoYFlS9LBIC88hPAybm82 pj9wSIv4dy+4lmclJ7pPezSITfV/b08= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728903596; a=rsa-sha256; cv=none; b=2qzCowR2f3KmV49m9hg4IGj051ie4A+cG2ZN6ieyigfPT6AzBLv1wzBMr1RuYIZuCKTv9U 9EyL/qrDvGjy2Y4gfFFJ3QiU2AXgqU1kL4/ydEWJMES/dr7dOLCuk2JREbgkkti6UwZb2q JC5+85pKSZR5viC4kV4OBTkhmklur5o= 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 To: "David S. Miller" , Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , David Hildenbrand , Eric Dumazet , Greg Marsden , Ivan Ivanov , Jakub Kicinski , Kalesh Singh , Marc Zyngier , Mark Rutland , Matthias Brugger , Miroslav Benes , Paolo Abeni , Wei Fang , Will Deacon Cc: Ryan Roberts , 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 X-Rspam-User: X-Stat-Signature: ihnqdzgeeq9s97etjg4esg1h9cwtxezo X-Rspamd-Queue-Id: A983F20002 X-Rspamd-Server: rspam11 X-HE-Tag: 1728903639-424607 X-HE-Meta: U2FsdGVkX1/vmxjdSGe3s0jzo3jqnDK0Gu1+mqOfoGjEv/62hCnovCOcvTFxH5EJCO7207krea/S/6gn4r5XorJBRqoy3ErA5PLi+4s9A2YsYfqi4+DwOwAbSqZsywwXdqxhiCKKPmHPhEXA3yulI8hojyO+d5JXdYanedP1AA+2qFFea6nV/6ltQUJs3rRPrVt4cYFq9hJSoUk+SKdBVOlUYogr88oC161Dm3HVVPIrlMeHZTT9oCF2nOBAs9D2e7uerW5KOKwQt9fuM3OmW5kCOXz4ykZa1vXa//9/2w8HHLs4Aill9hqoqp44hw7H2gOguiAe84ENNsMjXh9ks1041mIesKRO/P/sQEsxw7tuyDJigW+MZk94rqUR/CoSEourU6ulWPWQW442JPeiDd/gFqOuExO5D8uE6kBd141R6aTWsnTGwVO9kbNuCjrDuEs2aoPnjEexTAAWfB3cOKaaVOZIcfCzK5MTxoXLh8oAlFfU4/Z8EdX41MIZ3k3Nj+mKxlcM94muFNC8zz5N3X3i4ui9lDrDcH6S3Ig/g3e2SA1P0I56X4bTFlSYatTZCHJB8Ra082N7O7nPDXQhNDNCUEqvU0NaFXY7KfkfDhaQ+MBR9079OCx1FA/PjRwNE8AT0X6JfAPd/Q2OZBFXDlnmBrb3lW581bVwHK0v/miJeq3+VINuVtsCbOFx4mewUaxaZtazPiq60zOtWiYZur15QFBzA6ryaw3iOlg4IH0bQrzZ9v+g8hC2C3K6mMxfQqfJlfQMcyCVaidQBtJT+W5r+cBlLDw85lYlS11HLyRnXsx4cM79tm4ffxpgxa6Y4S3nw+iSOCH+zCohf32jecb02IAVqpnbYFANk3WzFJMMzIZ79l7Jt9cwoyf8HKoyrQD3qb1b9y0BdUxYWvJIravlqb6zqUhf1r+lbmLHPHG4SLSyal0UVIUXsXqUa6ruPdrigRzN/tyXFePV42m uyDzZ1K5 dEovuSuAKeMjymdWuu36mc6HvrLJyD8TKlnf9B2ETr/OEA0B/nuJA74VT+Ta0sw4CKir1g5Lbltyq0khoIoilgTZh86rtYMxVICp6+PYJKVLLJ/0PIrWTMp4qQ/QU+Sa1XCA6gwAc4lnrRlUecgIuD8YU+RAogXGprbCPzjEay+krLS40fg5s+uSglGotI4YJOT41NYTNE3jf5YqSriJ7W9Kr9uzTxwGxG+Dg X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 --- ***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(-) 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;