From patchwork Mon Aug 5 21:25:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mina Almasry X-Patchwork-Id: 13754146 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 4DC2EC3DA4A for ; Mon, 5 Aug 2024 21:25:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B8C910E2C4; Mon, 5 Aug 2024 21:25:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="DdoUryfL"; dkim-atps=neutral Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by gabe.freedesktop.org (Postfix) with ESMTPS id B48C010E2BB for ; Mon, 5 Aug 2024 21:25:48 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e035f7b5976so539944276.0 for ; Mon, 05 Aug 2024 14:25:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722893148; x=1723497948; darn=lists.freedesktop.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QW6znr6cHM2mLazuqMq5oZLiE4imdB81XfOOoj9JCCA=; b=DdoUryfLMrmR8eF79HrsZEPNVhGsV7prmvLa8DiEDpSC8xQTSGe+j4U9AvN95dSGcy 2bb3wnZ1IcR5aZCWDaznAOvDVrUe+E3nI7b39l+QHrqcO7St/FGoQWHj3LTjo2ulS6+q qiOKDl63WikFS2AgyrBrjPmF3HY7A0u2+ItBEvMXXLt6dz8GTokSRfToRgoTNPW8Xjf2 jr6JPRk1kSM9FbbPo1zYunp3TKsWp2W2V0SAmegCujPTzMCCxE++gdQ2OeG1nPyjMgH4 eyJ91Stc5NEM1dDjcUwSJK9lnbDn6zzGiMMG4fsyrZYlpSTiqwOtVF5H2x0VC3cr4MC2 Zmew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722893148; x=1723497948; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QW6znr6cHM2mLazuqMq5oZLiE4imdB81XfOOoj9JCCA=; b=SBrLyCyR6y1iUDdUrmBfnTr6wKu9u6tTVcADyiODcg+wVErAx8wjui9a3rvOGqA1mU t4Y8CZXIqo/S8HdbTGGf7RBTRMO2Ioa1jwlrOZT2x1NiY/7uu+W4ifJZOXxLnhbYJIA1 DEIfQCfO4kavKPYCqhZz9jcHIWJuScRL4IJ+KaUHHq55xt7N446owSoYGrcYgjLRg+Ss Ge2v7Y47toe5POI0+ZzNtLhg/UDCF78eLZjprCERvAz7ksp17fsXwIDf0zFij9bumyuM IdWqkil0qu4VCawczNcI+gmbrnvB2QGw8b61kEy8a8dMys54+xslEn4s0+PryTh6k/ne 5PCw== X-Forwarded-Encrypted: i=1; AJvYcCVXcGKSVsdX+uzobFP7uppK3f9E1BRfoTXmCGjTD9HmoHu8477E8S6P97GFJEA/7pXX1e3rO/EGvblHcjSH+M+1NwIU9EIm0vFTVrf5HWOr X-Gm-Message-State: AOJu0YyM4geSp2cFdIgB4t5DhAYRj0nXMWZ7bn4rXdO2cMV5y5mixAWJ FyoTZvyS3YQL2BruJVSTd9Pl0IRgC9pL6/uYoABzIvASs0oLHyqLA1G/8fMnpGKG9hqa76hsy9f upQ2p+BuT7BFnxYV8eApHPg== X-Google-Smtp-Source: AGHT+IGM0VQldIgmGiiNcNzkJRa+4J5mNVfUsyPhF6k6J1KRuCnYcR6TSrWhZH6dNRSaQlr0Wgsdage9M4NVq4x2xw== X-Received: from almasrymina.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:4bc5]) (user=almasrymina job=sendgmr) by 2002:a05:6902:154e:b0:e0b:acc7:b1fd with SMTP id 3f1490d57ef6-e0bdeb3e00bmr340566276.4.1722893147755; Mon, 05 Aug 2024 14:25:47 -0700 (PDT) Date: Mon, 5 Aug 2024 21:25:18 +0000 In-Reply-To: <20240805212536.2172174-1-almasrymina@google.com> Mime-Version: 1.0 References: <20240805212536.2172174-1-almasrymina@google.com> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog Message-ID: <20240805212536.2172174-6-almasrymina@google.com> Subject: [PATCH net-next v18 05/14] page_pool: move dmaddr helpers to .c file From: Mina Almasry To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Mina Almasry , Donald Hunter , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Andreas Larsson , Jesper Dangaard Brouer , Ilias Apalodimas , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Arnd Bergmann , Steffen Klassert , Herbert Xu , David Ahern , Willem de Bruijn , Shuah Khan , Sumit Semwal , " =?utf-8?q?Christian_K=C3=B6nig?= " , Bagas Sanjaya , Christoph Hellwig , Nikolay Aleksandrov , Taehee Yoo , Pavel Begunkov , David Wei , Jason Gunthorpe , Yunsheng Lin , Shailend Chand , Harshitha Ramamurthy , Shakeel Butt , Jeroen de Borst , Praveen Kaligineedi X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" These helpers are used for setup and init of buffers, and their implementation need not be static inline in the header file. Moving the implementation to the .c file allows us to hide netmem implementation details in internal header files rather than the public file. Signed-off-by: Mina Almasry --- include/net/page_pool/helpers.h | 30 ++---------------------------- net/core/page_pool.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helpers.h index 2b43a893c619d..8f27ecc00bb16 100644 --- a/include/net/page_pool/helpers.h +++ b/include/net/page_pool/helpers.h @@ -399,17 +399,7 @@ static inline void page_pool_free_va(struct page_pool *pool, void *va, page_pool_put_page(pool, virt_to_head_page(va), -1, allow_direct); } -static inline dma_addr_t page_pool_get_dma_addr_netmem(netmem_ref netmem) -{ - struct page *page = netmem_to_page(netmem); - - dma_addr_t ret = page->dma_addr; - - if (PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA) - ret <<= PAGE_SHIFT; - - return ret; -} +dma_addr_t page_pool_get_dma_addr_netmem(netmem_ref netmem); /** * page_pool_get_dma_addr() - Retrieve the stored DMA address. @@ -423,23 +413,7 @@ static inline dma_addr_t page_pool_get_dma_addr(const struct page *page) return page_pool_get_dma_addr_netmem(page_to_netmem((struct page *)page)); } -static inline bool page_pool_set_dma_addr_netmem(netmem_ref netmem, - dma_addr_t addr) -{ - struct page *page = netmem_to_page(netmem); - - if (PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA) { - page->dma_addr = addr >> PAGE_SHIFT; - - /* We assume page alignment to shave off bottom bits, - * if this "compression" doesn't work we need to drop. - */ - return addr != (dma_addr_t)page->dma_addr << PAGE_SHIFT; - } - - page->dma_addr = addr; - return false; -} +bool page_pool_set_dma_addr_netmem(netmem_ref netmem, dma_addr_t addr); /** * page_pool_dma_sync_for_cpu - sync Rx page for CPU after it's written by HW diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 2abe6e919224d..a032f731d4146 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -1099,3 +1099,34 @@ void page_pool_update_nid(struct page_pool *pool, int new_nid) } } EXPORT_SYMBOL(page_pool_update_nid); + +dma_addr_t page_pool_get_dma_addr_netmem(netmem_ref netmem) +{ + struct page *page = netmem_to_page(netmem); + + dma_addr_t ret = page->dma_addr; + + if (PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA) + ret <<= PAGE_SHIFT; + + return ret; +} +EXPORT_SYMBOL(page_pool_get_dma_addr_netmem); + +bool page_pool_set_dma_addr_netmem(netmem_ref netmem, dma_addr_t addr) +{ + struct page *page = netmem_to_page(netmem); + + if (PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA) { + page->dma_addr = addr >> PAGE_SHIFT; + + /* We assume page alignment to shave off bottom bits, + * if this "compression" doesn't work we need to drop. + */ + return addr != (dma_addr_t)page->dma_addr << PAGE_SHIFT; + } + + page->dma_addr = addr; + return false; +} +EXPORT_SYMBOL(page_pool_set_dma_addr_netmem);