From patchwork Mon Oct 14 10:58:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13834693 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 EBD68D1A43B for ; Mon, 14 Oct 2024 11:00:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 841846B00AC; Mon, 14 Oct 2024 07:00:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F0076B00AD; Mon, 14 Oct 2024 07:00:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68F556B00AE; Mon, 14 Oct 2024 07:00:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 475CC6B00AC for ; Mon, 14 Oct 2024 07:00:48 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A4098160D33 for ; Mon, 14 Oct 2024 11:00:39 +0000 (UTC) X-FDA: 82671914766.25.725BE1A Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf02.hostedemail.com (Postfix) with ESMTP id B74E380015 for ; Mon, 14 Oct 2024 11:00:34 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.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=1728903458; 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=PSUHqjoRyP5Y2BnZxqoD+IML1c1ukTJ/pQox4PTBxLQ=; b=Ai8L1KCAMuZ/F6KeXxqIvI84gUgK2LXGOu6vlCmRy/B/JjkwYQ6CcW3iIqW3xeFqJaMFJ5 Zop1eWu859kUJpcslxRu2DiA9R2gHG3eRjYsXxcntJmuLuvVaSLte2DUFwOE/MzeL20Q40 9ONUJ3VCqpNQpIzRKFUbaaR7zy7fQn4= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.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=1728903458; a=rsa-sha256; cv=none; b=tZB7f3lnrtAKi9hDq/b3GmWIGJybddk8STGMlNkwwifGemD/xumoIlK1JOfEEIRl/8xotB QBsWQKuRM5+g7q26nEbXbVdqWIzlzCAG7gkkfCVkyYsiCW561mcdySYrW65FCculhQ5eyk TuNqTMl45tGWxXIURx7kremgnjTg/A8= 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 2C1911692; Mon, 14 Oct 2024 04:01:15 -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 68E4F3F51B; Mon, 14 Oct 2024 04:00:42 -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 , Marcin Wojtas , Mark Rutland , Matthias Brugger , Miroslav Benes , Paolo Abeni , Will Deacon Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org Subject: [RFC PATCH v1 25/57] net: marvell: Remove PAGE_SIZE compile-time constant assumption Date: Mon, 14 Oct 2024 11:58:32 +0100 Message-ID: <20241014105912.3207374-25-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-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B74E380015 X-Stat-Signature: p9uri78ccfoxdbeih73fst3fk551xnkx X-Rspam-User: X-HE-Tag: 1728903634-17164 X-HE-Meta: U2FsdGVkX1+N2om6pwe9a78ESpk93emJ5FPHknlzvQ6avPC88sW+QrCb27sXtcPskJ7hQnTEsfUBNYexmhhSnKoA0pmS4CiYSyFmlHCusLWo0SzScvdtU3Qhsp8e4Q7Jj/3Bx4gBcUSrjOO6SJoG9o7fL9HDUbzg+Hea46nPtkAHjgXZI+Y3ROHuczcJbp9zty7W6bwRakK0vmktA5KB2TH3U9noWtHlDC7S2UtCJY6MMGwgGTVD7r5rza1Wx9fHHwDJ8FhckF9F/HbRkh+6pcqIzUrmDEWw+c6Cck9Izgnl9n4WDomoN95TsO1mRzOZis5/Q5D2LxYDYYrWMvBVSC1xJXiuPjcmqW93k+Gxy8MygapFCiyiU+35cDXsWFH8GFy5l0Ap3SCPSENBDoGpN/Aem0M3DyOf6kLa95GZbYz22hHGP2QWBspqnHrBO9qctNEb8gRuPTVabSFEt+22uFhHMuMYgdiE8Z6RPqrIdobSDvVqphGuS8106LFLCmpTwhumqxdWTGb2J1Re0F/zfv/xMCINpopaRp6floDGOmiGRFvV0oobAfkvdg6fQNxPtC1I8qAHUoQPRTyLJoFgDSRPcMHurUFvnrVrpDQts1ONcbvGpZwPdMq3fMwGzEPvTFUbQosQvYpjUQuS0Z6UlfIzUgItk8ZA/NxijzDks/DbE9tkU42iQIXHWbruMNOwHe+kISfuyhvKI/gyzwEqF+fs7EWJ4+7Ky8U3UlRhxFOWyWab5GxbE2DvhZHQOzDCgIfe8d0I8LJwwXdV2UuseWVBQ0N0kFSFzjwVqrrYbFL23oALckYPb7cg74aJYWHGnVb6mG+W9PaOXkmQ5jF5aIx1usfx8ibIuJJJQeDxMP/V2y/9/liTlJdi48CJeq8DYXvdxK8vKJ50LJg/Bhav9dv1ouaBX0cUydxAAAE4KjNvqhpjUozhmwrD2q1m/HXHJmg08lThqU4jAr7QUtk zDjWxmTq 9ZdYEOU09RZOxZEgnV7CQNmplGyWBqFFLpMVd/kQAhMXvUW2THZWLqzcFmYq1Hb9aYkTAnYhN6MxwpOw+DO3l+AV1HNaAFKYKAXQ7a6onZ9uowTMZGl16cIoA02a1CgsUH8eh7Rk9EzLJh3Nd69+JC7pCLbmBrC2rnExuYy8iiYIol4DYCBtnBzPRBYmeiyw0zbiBiPrFdBpZjRINOwq80yHsYsv1SYGX+NscOCb7ULSij98c7Nl0SA6/Wv4wpkSN+Zyt5CthXQP95bnTmxN+ySyl+bIra44HC356pgp0Jt2JRw4= 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. Updated sky2 "struct rx_ring_info" member frag_addr[] to contain enough entries for the smallest supported page size. Updated mvneta "struct mvneta_tx_queue" members tso_hdrs[] and tso_hdrs_phys[] to contain enough entries for the smallest supported 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/marvell/mvneta.c | 9 ++++++--- drivers/net/ethernet/marvell/sky2.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index 41894834fb53c..f3ac371d8f3a7 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -346,12 +346,15 @@ /* The size of a TSO header page */ #define MVNETA_TSO_PAGE_SIZE (2 * PAGE_SIZE) +#define MVNETA_TSO_PAGE_SIZE_MIN (2 * PAGE_SIZE_MIN) /* Number of TSO headers per page. This should be a power of 2 */ #define MVNETA_TSO_PER_PAGE (MVNETA_TSO_PAGE_SIZE / TSO_HEADER_SIZE) +#define MVNETA_TSO_PER_PAGE_MIN (MVNETA_TSO_PAGE_SIZE_MIN / TSO_HEADER_SIZE) /* Maximum number of TSO header pages */ #define MVNETA_MAX_TSO_PAGES (MVNETA_MAX_TXD / MVNETA_TSO_PER_PAGE) +#define MVNETA_MAX_TSO_PAGES_MAX (MVNETA_MAX_TXD / MVNETA_TSO_PER_PAGE_MIN) /* descriptor aligned size */ #define MVNETA_DESC_ALIGNED_SIZE 32 @@ -696,10 +699,10 @@ struct mvneta_tx_queue { int next_desc_to_proc; /* DMA buffers for TSO headers */ - char *tso_hdrs[MVNETA_MAX_TSO_PAGES]; + char *tso_hdrs[MVNETA_MAX_TSO_PAGES_MAX]; /* DMA address of TSO headers */ - dma_addr_t tso_hdrs_phys[MVNETA_MAX_TSO_PAGES]; + dma_addr_t tso_hdrs_phys[MVNETA_MAX_TSO_PAGES_MAX]; /* Affinity mask for CPUs*/ cpumask_t affinity_mask; @@ -5895,7 +5898,7 @@ static int __init mvneta_driver_init(void) { int ret; - BUILD_BUG_ON_NOT_POWER_OF_2(MVNETA_TSO_PER_PAGE); + BUILD_BUG_ON_NOT_POWER_OF_2(MVNETA_TSO_PER_PAGE_MIN); ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, "net/mvneta:online", mvneta_cpu_online, diff --git a/drivers/net/ethernet/marvell/sky2.h b/drivers/net/ethernet/marvell/sky2.h index 8d0bacf4e49cc..8ee73ae087dfc 100644 --- a/drivers/net/ethernet/marvell/sky2.h +++ b/drivers/net/ethernet/marvell/sky2.h @@ -2195,7 +2195,7 @@ struct rx_ring_info { struct sk_buff *skb; dma_addr_t data_addr; DEFINE_DMA_UNMAP_LEN(data_size); - dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT ?: 1]; + dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT_MIN ?: 1]; }; enum flow_control {