From patchwork Mon Feb 11 16:06:46 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: 10806185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4BB51575 for ; Mon, 11 Feb 2019 16:07:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2D7F2A930 for ; Mon, 11 Feb 2019 16:07:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6A722A955; Mon, 11 Feb 2019 16:07:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55D0B2A930 for ; Mon, 11 Feb 2019 16:07:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48F0B8E00E9; Mon, 11 Feb 2019 11:06:59 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 43C798E00F6; Mon, 11 Feb 2019 11:06:59 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 312CF8E00E9; Mon, 11 Feb 2019 11:06:59 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id 0206A8E00E9 for ; Mon, 11 Feb 2019 11:06:59 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id f24so4646064qte.4 for ; Mon, 11 Feb 2019 08:06:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=CBkJKA+YMVyNw45r/sFZzOZnj6jCaab8O3cbgYdAWq8=; b=ZQNLGdBciRE9gIJ8OQcMLR71Q++gXVJTMlJooroi6jGvBgSVYlNk1UskSsX5/3/58n 6Iq514rIkBp5zxm5qbhb4pIwOtXQ66IH34merCJO+pFTTW5WXV8Rs8otfVd7xTIg2dax ob9b7hKV2K089G/Q2v/rG8sFD50hgQpUczcZXYcjzWledYEIovXBp0vZPbdRqkIIHvnj hVzBP+fzypLGH7TrazCaWUJxAR2t5BeKHpXV3MyvXsDpOP9Am7atvtdt4Qh9fwKbQ/2v IGfjepGRpqy7LJlr0zdImPUuVFsz9Z2/J6YQhs41CmNkW6EA8D9LPbuKq1R1unUCfj9S 9EBg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of brouer@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=brouer@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AHQUAubeoZqW2tLd83+Et6xTE88yi90W5jSg+Gwud/uVw1EGmAuHsJIz pIa6Wk1Zu2E3XkgYn/QIXD0I54X4cL2WrDxcyVkQydRFQ4a9E3QSWjihHnH4aB0ZlD30ONUoAoP yCoB4Tpj/dQmzqK2mnWkOXC4r1jvUtJbkNZzljo1Kcc/rS+cRN77cy8WQi+3f9wSbcw== X-Received: by 2002:ac8:694e:: with SMTP id n14mr28299448qtr.62.1549901218763; Mon, 11 Feb 2019 08:06:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IbHT29heCS/1YuT9HdO3R5WbruCH5+Z/WPTCLr9WlPx4T9MQVaIkkISPinfaUE0oQOgaWpa X-Received: by 2002:ac8:694e:: with SMTP id n14mr28299389qtr.62.1549901218032; Mon, 11 Feb 2019 08:06:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901218; cv=none; d=google.com; s=arc-20160816; b=ahCvVDBQFnMQmDOY8O86JZrU7LKg51NkT9l2RoXB31tf6A4Ya1MzfChmnH8J6/vrz7 Z4CeSo2YxM03N22Vw58+CoygoRIoNNTSw6U82g+L8hvETbaJw0FPkOfmTDrcOrWPO6D3 dtBdrjXit/1VUdjA8jC25tzb3NulkZhOiqUUKJZc09oK8vkqeVJSXpwdmYkf8jLwGd2z RgMLzosk8JbZBWf7QIWo8Uucr4jmXh9iJMSpSsrQNLMVt3OL6p0PUo8A3A2mbLDyz4RU jHepbKRVpPGvvklGwBFF49E2vklCLlmxQmIWhUDwjGcqX67BmsKP7TNJmu5Qc+etoZ0B MLtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject; bh=CBkJKA+YMVyNw45r/sFZzOZnj6jCaab8O3cbgYdAWq8=; b=aWj0vzr72liDGPjwuPHZC4uFX+WsgQdiLOucG/huczF6RJiDgAmBuS5M0cIyTDi8Vv SF3wJBC6TOiLaAvgyFPcDzzIyhsQlQ4TndKpDUKokpYVa9me+zDtE1iBzOkJ7zoWNP3m PP10bQiUJzoauw+VgxTXoSuu9nN7i9g2HGS1GcpGhTZKPmn5v6+gu2P+HNX3r1g4mHlu 4+SmbUTBQRVy7nsVKAjVOdSaTMXkw1Vtw1hFkty9qTeaSH0dums6GrKbprUlZ88iwufk zHUWK017FYJCrUWFTcanrxAyG7gAIW0lX7H9/5Tip9+fCp+1JptFjAMXDwsKIYCdHRZz oV1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of brouer@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=brouer@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id k1si2370123qtc.181.2019.02.11.08.06.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 08:06:58 -0800 (PST) Received-SPF: pass (google.com: domain of brouer@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of brouer@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=brouer@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D0B2587648; Mon, 11 Feb 2019 16:06:56 +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 CB8DD6013E; Mon, 11 Feb 2019 16:06:47 +0000 (UTC) Received: from [10.1.2.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id DEAE931256FC7; Mon, 11 Feb 2019 17:06:46 +0100 (CET) Subject: [net-next PATCH 1/2] mm: add dma_addr_t to struct page 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 , Jesper Dangaard Brouer , Andrew Morton , mgorman@techsingularity.net, "David S. Miller" , Tariq Toukan Date: Mon, 11 Feb 2019 17:06:46 +0100 Message-ID: <154990120685.24530.15350136329514629029.stgit@firesoul> In-Reply-To: <154990116432.24530.10541030990995303432.stgit@firesoul> References: <154990116432.24530.10541030990995303432.stgit@firesoul> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 11 Feb 2019 16:06:57 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP The page_pool API is using page->private to store DMA addresses. As pointed out by David Miller we can't use that on 32-bit architectures with 64-bit DMA This patch adds a new dma_addr_t struct to allow storing DMA addresses Signed-off-by: Jesper Dangaard Brouer Signed-off-by: Ilias Apalodimas Reviewed-by: Matthew Wilcox Acked-by: Andrew Morton --- include/linux/mm_types.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 2c471a2c43fa..3060700752cc 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -95,6 +95,14 @@ struct page { */ unsigned long private; }; + struct { /* page_pool used by netstack */ + /** + * @dma_addr: Page_pool need to store DMA-addr, and + * cannot use @private, as DMA-mappings can be 64-bit + * even on 32-bit Architectures. + */ + dma_addr_t dma_addr; /* Shares area with @lru */ + }; struct { /* slab, slob and slub */ union { struct list_head slab_list; /* uses lru */ From patchwork Mon Feb 11 16:06:51 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: 10806187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C80D1575 for ; Mon, 11 Feb 2019 16:07:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79A462A930 for ; Mon, 11 Feb 2019 16:07:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DAA62A955; Mon, 11 Feb 2019 16:07:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2AC02A930 for ; Mon, 11 Feb 2019 16:07:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7EAEB8E00F7; Mon, 11 Feb 2019 11:07:01 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 798218E00F6; Mon, 11 Feb 2019 11:07:01 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 612A08E00F7; Mon, 11 Feb 2019 11:07:01 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 35EAC8E00F6 for ; Mon, 11 Feb 2019 11:07:01 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id e31so7363068qtb.22 for ; Mon, 11 Feb 2019 08:07:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=xWUNDSgRU80m19aFrocMMhwrjGCARtWhKL6OErSaSMc=; b=rzG7L3qDRbFsotjX9EHzEiLy764yfn55EXTqBewHkaIGFd4XrB0nmMdsVoCEb+8umW Z0C2MFwF1yxW4cBfl6z4hoc2sjV7jQCVDBapDB/K7HrIBy9+FkLi0LJ6QBlYGRSuDaDG J/Hgfo6PE7e+j3JAbg9p0v2nBRlDFN3PBP9EqwKCybBWTyFxRVKIbPk8oVBm9U/L9Zfa 4BuTKEa8+tGdW6Klld5+ceKqRW72wMnlx+toLT70Ryq2pwAh1ZvJR1L6qwUqQ81fUe0O HXEv2U3MIh+Pke/s9JSJMkDvl1JOjVh4pLXMX4LfiJ3S8VFXi3MWa5BOMmBD1GNpxXoa 2pOQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of brouer@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=brouer@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AHQUAuaGP5BgZ/6AhKjoYUEkfjr5mO8uXqVo+vJ5biIpGtHKw8xRGrPt FeaLDNZa5KIZ4WZKw+bfBoazrPqbxC6NwFuXo7gNTY2pSV4Xx+T+Ba0wCrPRGtgKP1yrr2mX/jl HOEOPp+Ruuq3Dn7VYQhh+w2msLKdnXYlQmowIVJqizJIpa7b+u/lu1eCOberoaZUhgA== X-Received: by 2002:aed:3eac:: with SMTP id n41mr4263257qtf.362.1549901220928; Mon, 11 Feb 2019 08:07:00 -0800 (PST) X-Google-Smtp-Source: AHgI3IZQ6aYuhK1zohp0B2d593AWJl1FPGjzSYe8Tj5uuXSj06KXr76RW4Yq77McdBWjpGs8gmSb X-Received: by 2002:aed:3eac:: with SMTP id n41mr4263212qtf.362.1549901220328; Mon, 11 Feb 2019 08:07:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901220; cv=none; d=google.com; s=arc-20160816; b=cGVj6wdsE7LXenNWk7y1MsXWFo7GIifM5Wt3XtaKHRI6kVamPIQYMvIarHTjLYaWHu J4jri4Mfe2WG6h8/Z6xNIPrZY27evDuSp9ftFQqqP4IJt8R2/k8nhuoSqfaEaUlp8zer MTcF2aQCcKtLwVrnicGI2AeyadNt138bZQZuOKnIPU3RXRqcTyJuNFG40rmfuQWWQQRB AhNdiE0Zt32LBhE+ytVbbj5Fz2KLHjw5rz7lEUrn8oEwxuQAHPq7IoFG8duHsbwNocRJ 94OMi5ACMCeNa6XkpnmIK6PJ9bSjh5yzsZIqZYOXRon10pxBjwsGRxw3+oEtgFx8ZQKZ AcPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject; bh=xWUNDSgRU80m19aFrocMMhwrjGCARtWhKL6OErSaSMc=; b=wR1oXcgb8gDOMW1GLCa2ZDZ9XDtedL7Rsk3H1+ED1tx/4jwNV2s6XNHsqoxHTl2YiJ uPYrOcfRR4A2KUFVHYWrXAMN33pI1sNTPNUA/+QkesfUts/XacHesgrkU1hVZ2T9agMF rPd3t3PcbT42FaitkatsA54KVi2ADKUhnjltB/y3rQash4hA5uVUDuJ0cT7RdZaKhLSK B/bpDCcOPTmuR8PSMsDxHAgImMGwu06gF7s83Fznp9qXh78zwh6iMiNOPfuTY3MJ0A+G 63BlB9tfXKDcwT0S8ib6xT+rzlvgZA1ABQ1I5XKNdcJZkOC8DXspGcuzC4VxKxEy8L+2 5DWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of brouer@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=brouer@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id g67si69752qkc.228.2019.02.11.08.07.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 08:07:00 -0800 (PST) Received-SPF: pass (google.com: domain of brouer@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of brouer@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=brouer@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6BAF9804E0; Mon, 11 Feb 2019 16:06:58 +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 C7869608C2; Mon, 11 Feb 2019 16:06:52 +0000 (UTC) Received: from [10.1.2.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id F007730C2C6B3; Mon, 11 Feb 2019 17:06:51 +0100 (CET) Subject: [net-next PATCH 2/2] 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 , Jesper Dangaard Brouer , Andrew Morton , mgorman@techsingularity.net, "David S. Miller" , Tariq Toukan Date: Mon, 11 Feb 2019 17:06:51 +0100 Message-ID: <154990121192.24530.11128024662816211563.stgit@firesoul> In-Reply-To: <154990116432.24530.10541030990995303432.stgit@firesoul> References: <154990116432.24530.10541030990995303432.stgit@firesoul> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 11 Feb 2019 16:06:59 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP 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 */