From patchwork Wed Feb 13 01:55:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Dangaard Brouer X-Patchwork-Id: 158182 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4515430jaa; Tue, 12 Feb 2019 17:55:50 -0800 (PST) X-Google-Smtp-Source: AHgI3IaUMRfRftSf1OmJ6W2ZwutO2GXprCPJZeIdAOvno72g9rvoyxiKfBdGXxq8snH1QKswK4CP X-Received: by 2002:a63:1624:: with SMTP id w36mr5559553pgl.264.1550022950731; Tue, 12 Feb 2019 17:55:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550022950; cv=none; d=google.com; s=arc-20160816; b=05OKlcvPpWSOurbJXP4dOlIHXLD0/+F4bxkW1yGYF83+7bzbfQwyMy8kNPJpJvUkYu OPIsFdsMEq7a6FlImzz5TA+7AyfGgfiXd/shmAGXECDTc4nMkbdH/PIcXbn+gk4UUlx6 i7lltEsFcItppCLvsS07UkJhCacRJEBFNaExNCHjfdRbvB4EuwAyTAFp3c8xD73uB6LV 3+MtgCzZ8LLlyOe6yoi9P1IopyydHQoeOqrqwPhbBbDFMk8QkfVsOUHG2Akvd7hnRn5I UbgEeTfa7wCO0fbMxfkJdb9mNHqH87j0Ps0vOAc1UkbFnY688YVVA42N6f+0XIimHr6n OG+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject; bh=xWUNDSgRU80m19aFrocMMhwrjGCARtWhKL6OErSaSMc=; b=X8JtjTPO2uJJlT34wtVojl6hspyP1NKUzR60NTZac9k1lbnMPGD5l/lrUdCl40BEWN q8VBq8wQji+K1lYTxvgZFzIl22Cb6Ih7HtCU3MDnWSi92zsyPFxKwsYIqzJcJa3PgHcO zAzTjrFPMnkTydPxwbAvZ+jOvTSpfpn9qpq+6Gx201aDuPL4dBXWc3Sla3LdQDwq6OYU 23nxk9amSb851cjM5K+3FxekjJnTd+4RndB5Hp/bfMEjlChJ3IQSosQ1x1wwQaFwl6nH NeEmJDEkggB1YFi6eLG3+qUtPulY1YhvYDxHrZZU8+MlAv4KV9QVWRYRsdkn+ezUdOQB w4zA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f124si15730795pfa.1.2019.02.12.17.55.50; Tue, 12 Feb 2019 17:55:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728964AbfBMBzs (ORCPT + 10 others); Tue, 12 Feb 2019 20:55:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38038 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729322AbfBMBzq (ORCPT ); Tue, 12 Feb 2019 20:55:46 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 620E77F406; Wed, 13 Feb 2019 01:55:46 +0000 (UTC) Received: from firesoul.localdomain (ovpn-200-20.brq.redhat.com [10.40.200.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BB785C635; Wed, 13 Feb 2019 01:55:46 +0000 (UTC) Received: from [10.1.2.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 32FE5306665E6; Wed, 13 Feb 2019 02:55:45 +0100 (CET) Subject: [net-next PATCH V3 2/3] net: page_pool: don't use page->private to store dma_addr_t From: Jesper Dangaard Brouer To: netdev@vger.kernel.org, linux-mm@kvack.org Cc: Toke =?utf-8?q?H=C3=B8iland-J=C3=B8rgensen?= , Ilias Apalodimas , willy@infradead.org, Saeed Mahameed , Alexander Duyck , Jesper Dangaard Brouer , Andrew Morton , mgorman@techsingularity.net, "David S. Miller" , Tariq Toukan Date: Wed, 13 Feb 2019 02:55:45 +0100 Message-ID: <155002294514.5597.2532233956628457927.stgit@firesoul> In-Reply-To: <155002290134.5597.6544755780651689517.stgit@firesoul> References: <155002290134.5597.6544755780651689517.stgit@firesoul> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 13 Feb 2019 01:55:46 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ilias Apalodimas As pointed out by David Miller the current page_pool implementation stores dma_addr_t in page->private. This won't work on 32-bit platforms with 64-bit DMA addresses since the page->private is an unsigned long and the dma_addr_t a u64. A previous patch is adding dma_addr_t on struct page to accommodate this. This patch adapts the page_pool related functions to use the newly added struct for storing and retrieving DMA addresses from network drivers. Signed-off-by: Ilias Apalodimas Signed-off-by: Jesper Dangaard Brouer --- net/core/page_pool.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 43a932cb609b..897a69a1477e 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -136,7 +136,9 @@ static struct page *__page_pool_alloc_pages_slow(struct page_pool *pool, if (!(pool->p.flags & PP_FLAG_DMA_MAP)) goto skip_dma_map; - /* Setup DMA mapping: use page->private for DMA-addr + /* Setup DMA mapping: use 'struct page' area for storing DMA-addr + * since dma_addr_t can be either 32 or 64 bits and does not always fit + * into page private data (i.e 32bit cpu with 64bit DMA caps) * This mapping is kept for lifetime of page, until leaving pool. */ dma = dma_map_page(pool->p.dev, page, 0, @@ -146,7 +148,7 @@ static struct page *__page_pool_alloc_pages_slow(struct page_pool *pool, put_page(page); return NULL; } - set_page_private(page, dma); /* page->private = dma; */ + page->dma_addr = dma; skip_dma_map: /* When page just alloc'ed is should/must have refcnt 1. */ @@ -175,13 +177,16 @@ EXPORT_SYMBOL(page_pool_alloc_pages); static void __page_pool_clean_page(struct page_pool *pool, struct page *page) { + dma_addr_t dma; + if (!(pool->p.flags & PP_FLAG_DMA_MAP)) return; + dma = page->dma_addr; /* DMA unmap */ - dma_unmap_page(pool->p.dev, page_private(page), + dma_unmap_page(pool->p.dev, dma, PAGE_SIZE << pool->p.order, pool->p.dma_dir); - set_page_private(page, 0); + page->dma_addr = 0; } /* Return a page to the page allocator, cleaning up our state */