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: 13834855 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 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 65ADDD1624D for ; Mon, 14 Oct 2024 11:59:09 +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=PSUHqjoRyP5Y2BnZxqoD+IML1c1ukTJ/pQox4PTBxLQ=; b=kvjQRoj+LNnHHXqSN3qEoh686/ WChSVUxJpcNiT7b0T32YsEbzHsdXSV4gXVu8KlrjkJZ61rAy7b5YU5+2/OAq5qCdCny53qx3i9S5D 4/IWjP+hCu3/VGL5oPRgFA48WbRM/uhYJgfQqJBaWl1Gi0iIMPzG5XoKRoEUnyS+0yDL9YU67asTp s8SRWTIj7qTZ/zZFWGz0T0oA4KcaHkhEa/+KsHWdoEwcliIK0gy0jalXRFCptLlztHFqHFNliFsZB DZS0EHktA//IIXBFUt3JgGpnfyJPgS4DSmzVy9RAjUi6XGux2XzNJZ5v9coBeG4sGPzqlu7BSW9PW +YaOsBZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0Jiz-000000050gb-0bkp; Mon, 14 Oct 2024 11:58:57 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0Iog-00000004nzN-0MQ3 for linux-arm-kernel@lists.infradead.org; Mon, 14 Oct 2024 11:00:48 +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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_040046_289607_EE48A01A X-CRM114-Status: GOOD ( 14.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 {