From patchwork Wed Jan 11 04:22:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13095979 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 DA90AC46467 for ; Wed, 11 Jan 2023 04:22:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58585900005; Tue, 10 Jan 2023 23:22:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FD15900004; Tue, 10 Jan 2023 23:22:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BBDD8E0006; Tue, 10 Jan 2023 23:22:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E7C6A8E0001 for ; Tue, 10 Jan 2023 23:22:13 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BA3BF160306 for ; Wed, 11 Jan 2023 04:22:13 +0000 (UTC) X-FDA: 80341220946.28.A2CC0E9 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id E68351C0007 for ; Wed, 11 Jan 2023 04:22:11 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=OLOZYsZt; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673410932; 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:dkim-signature; bh=X98r58MbAgZPQ4+1bekghvQ632iWN8JTQMfdSkUSkNQ=; b=TjTpP6KlPkG+9DjJsKaSaBGw2ZKE/I1CcosPY4DS1ik64eNEYfPjVM/UnegGokNQ1WOTXb CPTPDIwcQ7fvvG7zZbPfH81uEfTOk7LH6Ol0gn0HC/Xk8JfAIVJCEzMN9vKyzf16ElA8Yx sv6e8IHKqXu0CPqMRHy/lY3mKkOiWXM= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=OLOZYsZt; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673410932; a=rsa-sha256; cv=none; b=QMrc2wkjhKixrriXjgEn1SizKkV+fuFT3x9GJXUNs3/xyL6aH8Fj5KTj3u4Ver6Ww/Qa85 J/si7T527nOEeYYROBVjBdHq3DovjY7sfoTvL4kOBNIbKuXS98uDtsr5CiGydXQPhBBGgu 6kHtDFIhBrCW9P6fiLlt2rMSBNXH1Ag= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=X98r58MbAgZPQ4+1bekghvQ632iWN8JTQMfdSkUSkNQ=; b=OLOZYsZtuOdqFm6rh9vApicxj0 YxilqtkFg9Oh9hVGvdjGPAkPwtg4tAD4191gQ0FFNvHAdZ8D2XHfJ6nJKRaRMvGX9/z0/B7g6CiuB az34Nlwn8x88CPEvBaFmpfp5RAKZavkYXw2fzPbniaDcv7rPqRS16OQ9XTWya5w3QhoCPL5dQ1K4a h3o5Lx/F3vdVmKlJkPkrcQbxKozqoxXwCwxulplEzCamliGZNoNpqpVWdx6MGYCASYobcsUs6gRnK LEWmQdjZTnBWjx7eBp+ML3uT/eHQsbSqAiyFiO6/LRRsLXNP+aRLHOYD78Q//HFE4JfkoQIWT6cJ2 0ShX1ejA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFSd0-003nzY-LT; Wed, 11 Jan 2023 04:22:18 +0000 From: "Matthew Wilcox (Oracle)" To: Jesper Dangaard Brouer , Ilias Apalodimas Cc: "Matthew Wilcox (Oracle)" , netdev@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt Subject: [PATCH v3 26/26] hns3: Convert to netmem Date: Wed, 11 Jan 2023 04:22:14 +0000 Message-Id: <20230111042214.907030-27-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230111042214.907030-1-willy@infradead.org> References: <20230111042214.907030-1-willy@infradead.org> MIME-Version: 1.0 X-Stat-Signature: sqshodsf3o9afy9wuo79im9c5tueperc X-Rspam-User: X-Rspamd-Queue-Id: E68351C0007 X-Rspamd-Server: rspam06 X-HE-Tag: 1673410931-645960 X-HE-Meta: U2FsdGVkX1/6ie/lYZDu6412EnFZYUe11juGpHIn5wSra2epJXHzV+Rb5xZIwjaMGjla27suU5ZCBI0K+9wWzDhQoj13K+2Di95qyy7nwP93aBM1MH7F6Do5LPujfSK/unT3hhmmKDtzvJUSN4bdmuvxCGrNznM5kBxw2Y0rarMMVVc1qb2hAaGAPcUWmUftEKND5n7GLr7XCl0TEr6dODQtPIWMvS2l6wp5qXlPZfN+FbjafaYd0OGmzpCp3meRSfV0xWxl1ANhT2TImzrYjCnjwUm6RCMo+94qHbrDNa4vBdTLyv+Q41b/r3XohWRvJoWLnL2Eqj+WRNQajWPqdtVibJEf77fRJXdhmhwG1evGUr/rLz5sqWdxBhbGKlCx7aY9MUMyZwmfTE4EmcHrWf9eHqj+S6Bkd7jaLfc+R25xbg69siwZ2bPTWnHopXKT7ZsmW28K+GPJ+fJqf2Uipyn5Ft+sj2Q6bmKh/2B6eaEKNx0QkGbGUm02cTjV7LxbRVDMnid0+YlEqe/M4WqU1RhqpbaUohZcthfUcZLeMPpE8ShpKr4J7neJ9QV1Tga/fGeMUcJuFuzuJLQe9TPZhdbu2EpFm8n4nVPdhZVCIK5ujb+dpqxD1yEhIqY8qUnilqeXi8cLasjl/W8qONaTLfdS/E2gjuAmFFyVD7h4BXR69t3+ItTaAxOuX4YpuRGvNaO28hWgeYa2jtwskxS7uETyrvsTFF1xfbe/QQd1l538NSBFzXgHr2Tlsn00bS8bnkglkr9nGPFLr+9N8lm/aouANsHcsCTSBgw3lnWdbsE6ie0fxVmEewzg2qdc45oCQ1dzPXOAPPQeUW+yqXKquhaOsKZIlMovDq6yQ0QU1oUdWwAGtBrYukVnnmk3dL9I 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: Use the new netmem APIs in the hns3 driver. Convert page_pool_dev_alloc_frag() to return a netmem as this is the only user of the API. Signed-off-by: Matthew Wilcox (Oracle) --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 16 ++++++++-------- include/net/page_pool.h | 7 +++---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index b4c4fb873568..ca0dc201bd47 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -3355,15 +3355,15 @@ static int hns3_alloc_buffer(struct hns3_enet_ring *ring, struct page *p; if (ring->page_pool) { - p = page_pool_dev_alloc_frag(ring->page_pool, + struct netmem *nmem = page_pool_dev_alloc_frag(ring->page_pool, &cb->page_offset, hns3_buf_size(ring)); - if (unlikely(!p)) + if (unlikely(!nmem)) return -ENOMEM; - cb->priv = p; - cb->buf = page_address(p); - cb->dma = page_pool_get_dma_addr(p); + cb->priv = nmem; + cb->buf = netmem_address(nmem); + cb->dma = netmem_get_dma_addr(nmem); cb->type = DESC_TYPE_PP_FRAG; cb->reuse_flag = 0; return 0; @@ -3395,7 +3395,7 @@ static void hns3_free_buffer(struct hns3_enet_ring *ring, if (cb->type & DESC_TYPE_PAGE && cb->pagecnt_bias) __page_frag_cache_drain(cb->priv, cb->pagecnt_bias); else if (cb->type & DESC_TYPE_PP_FRAG) - page_pool_put_full_page(ring->page_pool, cb->priv, + page_pool_put_full_netmem(ring->page_pool, cb->priv, false); } memset(cb, 0, sizeof(*cb)); @@ -4043,8 +4043,8 @@ static int hns3_alloc_skb(struct hns3_enet_ring *ring, unsigned int length, if (dev_page_is_reusable(desc_cb->priv)) desc_cb->reuse_flag = 1; else if (desc_cb->type & DESC_TYPE_PP_FRAG) - page_pool_put_full_page(ring->page_pool, desc_cb->priv, - false); + page_pool_put_full_netmem(ring->page_pool, + desc_cb->priv, false); else /* This page cannot be reused so discard it */ __page_frag_cache_drain(desc_cb->priv, desc_cb->pagecnt_bias); diff --git a/include/net/page_pool.h b/include/net/page_pool.h index af8ba8a0dd05..0a2588e6a0f3 100644 --- a/include/net/page_pool.h +++ b/include/net/page_pool.h @@ -334,13 +334,12 @@ static inline struct page *page_pool_dev_alloc_pages(struct page_pool *pool) struct netmem *page_pool_alloc_frag(struct page_pool *pool, unsigned int *offset, unsigned int size, gfp_t gfp); -static inline struct page *page_pool_dev_alloc_frag(struct page_pool *pool, - unsigned int *offset, - unsigned int size) +static inline struct netmem *page_pool_dev_alloc_frag(struct page_pool *pool, + unsigned int *offset, unsigned int size) { gfp_t gfp = (GFP_ATOMIC | __GFP_NOWARN); - return netmem_page(page_pool_alloc_frag(pool, offset, size, gfp)); + return page_pool_alloc_frag(pool, offset, size, gfp); } /* get the stored dma direction. A driver might decide to treat this locally and