Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/721705/?format=api
{ "id": 721705, "url": "http://patchwork.ozlabs.org/api/patches/721705/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1485808177-6333-5-git-send-email-bimmy.pujari@intel.com/", "project": { "id": 46, "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api", "name": "Intel Wired Ethernet development", "link_name": "intel-wired-lan", "list_id": "intel-wired-lan.osuosl.org", "list_email": "intel-wired-lan@osuosl.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1485808177-6333-5-git-send-email-bimmy.pujari@intel.com>", "list_archive_url": null, "date": "2017-01-30T20:29:35", "name": "[next,S59,4/6] i40e/i40evf: Add support for mapping pages with DMA attributes", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "8a0695d02018441e510e3847f8ef381e95715495", "submitter": { "id": 68919, "url": "http://patchwork.ozlabs.org/api/people/68919/?format=api", "name": "Pujari, Bimmy", "email": "bimmy.pujari@intel.com" }, "delegate": { "id": 68, "url": "http://patchwork.ozlabs.org/api/users/68/?format=api", "username": "jtkirshe", "first_name": "Jeff", "last_name": "Kirsher", "email": "jeffrey.t.kirsher@intel.com" }, "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1485808177-6333-5-git-send-email-bimmy.pujari@intel.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/721705/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/721705/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<intel-wired-lan-bounces@lists.osuosl.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Received": [ "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3vBzzT0s55z9sQw\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 31 Jan 2017 06:31:49 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 23CEE30B08;\n\tMon, 30 Jan 2017 19:31:47 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id T9tIkkb3sMEA; Mon, 30 Jan 2017 19:31:41 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 3031930AD3;\n\tMon, 30 Jan 2017 19:31:40 +0000 (UTC)", "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\tby ash.osuosl.org (Postfix) with ESMTP id 4E9551BFC94\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tMon, 30 Jan 2017 19:31:38 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 4818E8A5B9\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tMon, 30 Jan 2017 19:31:38 +0000 (UTC)", "from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 8BcaLaGUboPK for <intel-wired-lan@lists.osuosl.org>;\n\tMon, 30 Jan 2017 19:31:37 +0000 (UTC)", "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby hemlock.osuosl.org (Postfix) with ESMTPS id E3AE68A5C0\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tMon, 30 Jan 2017 19:31:36 +0000 (UTC)", "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby orsmga102.jf.intel.com with ESMTP; 30 Jan 2017 11:31:35 -0800", "from bimmy.jf.intel.com (HELO bimmy.linux1.jf.intel.com)\n\t([134.134.2.167])\n\tby orsmga003.jf.intel.com with ESMTP; 30 Jan 2017 11:31:35 -0800" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.33,312,1477983600\"; d=\"scan'208\";a=\"928284950\"", "From": "Bimmy Pujari <bimmy.pujari@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Mon, 30 Jan 2017 12:29:35 -0800", "Message-Id": "<1485808177-6333-5-git-send-email-bimmy.pujari@intel.com>", "X-Mailer": "git-send-email 2.4.11", "In-Reply-To": "<1485808177-6333-1-git-send-email-bimmy.pujari@intel.com>", "References": "<1485808177-6333-1-git-send-email-bimmy.pujari@intel.com>", "Subject": "[Intel-wired-lan] [next PATCH S59 4/6] i40e/i40evf: Add support for\n\tmapping pages with DMA attributes", "X-BeenThere": "intel-wired-lan@lists.osuosl.org", "X-Mailman-Version": "2.1.18-1", "Precedence": "list", "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.lists.osuosl.org>", "List-Unsubscribe": "<http://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=unsubscribe>", "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>", "List-Post": "<mailto:intel-wired-lan@lists.osuosl.org>", "List-Help": "<mailto:intel-wired-lan-request@lists.osuosl.org?subject=help>", "List-Subscribe": "<http://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "intel-wired-lan-bounces@lists.osuosl.org", "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@lists.osuosl.org>" }, "content": "From: Alexander Duyck <alexander.h.duyck@intel.com>\n\nThis patch adds support for DMA_ATTR_SKIP_CPU_SYNC and\nDMA_ATTR_WEAK_ORDERING. By enabling both of these for the Rx path we \nare able to see performance improvements on architectures that implement \neither one due to the fact that page mapping and unmapping only has to \nsync what is actually being used instead of the entire buffer. In addition \nby enabling the weak ordering attribute enables a performance improvement \nfor architectures that can associate a memory ordering with a DMA buffer \nsuch as Sparc.\n\nSigned-off-by: Alexander Duyck <alexander.h.duyck@intel.com>\nChange-ID: If176824e8231c5b24b8a5d55b339a6026738fc75\n---\nTesting Hints: Changes would only be visible with SPARC platforms or\n systems with swiotlb=force enabled. Even then the actual\n effect should be minimal. Mainly we just need to verify\n that on kernels 4.10 and newer we are still able to\n receive traffic without any issues.\n\n drivers/net/ethernet/intel/i40e/i40e_txrx.c | 31 ++++++++++++++++++++++-----\n drivers/net/ethernet/intel/i40e/i40e_txrx.h | 3 +++\n drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 31 ++++++++++++++++++++++-----\n drivers/net/ethernet/intel/i40evf/i40e_txrx.h | 3 +++\n 4 files changed, 58 insertions(+), 10 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c\nindex d1583ee..012c157 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c\n@@ -1105,7 +1105,6 @@ int i40e_setup_tx_descriptors(struct i40e_ring *tx_ring)\n **/\n void i40e_clean_rx_ring(struct i40e_ring *rx_ring)\n {\n-\tstruct device *dev = rx_ring->dev;\n \tunsigned long bi_size;\n \tu16 i;\n \tstruct bpf_prog *old_prog;\n@@ -1126,7 +1125,20 @@ void i40e_clean_rx_ring(struct i40e_ring *rx_ring)\n \t\tif (!rx_bi->page)\n \t\t\tcontinue;\n \n-\t\tdma_unmap_page(dev, rx_bi->dma, PAGE_SIZE, DMA_FROM_DEVICE);\n+\t\t/* Invalidate cache lines that may have been written to by\n+\t\t * device so that we avoid corrupting memory.\n+\t\t */\n+\t\tdma_sync_single_range_for_cpu(rx_ring->dev,\n+\t\t\t\t\t rx_bi->dma,\n+\t\t\t\t\t rx_bi->page_offset,\n+\t\t\t\t\t I40E_RXBUFFER_2048,\n+\t\t\t\t\t DMA_FROM_DEVICE);\n+\n+\t\t/* free resources associated with mapping */\n+\t\tdma_unmap_page_attrs(rx_ring->dev, rx_bi->dma,\n+\t\t\t\t PAGE_SIZE,\n+\t\t\t\t DMA_FROM_DEVICE,\n+\t\t\t\t I40E_RX_DMA_ATTR);\n \t\t__free_pages(rx_bi->page, 0);\n \n \t\trx_bi->page = NULL;\n@@ -1260,7 +1272,10 @@ static bool i40e_alloc_mapped_page(struct i40e_ring *rx_ring,\n \t}\n \n \t/* map page for use */\n-\tdma = dma_map_page(rx_ring->dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE);\n+\tdma = dma_map_page_attrs(rx_ring->dev, page, 0,\n+\t\t\t\t PAGE_SIZE,\n+\t\t\t\t DMA_FROM_DEVICE,\n+\t\t\t\t I40E_RX_DMA_ATTR);\n \n \t/* if mapping failed free memory back to system since\n \t * there isn't much point in holding memory we can't use\n@@ -1369,6 +1384,12 @@ bool i40e_alloc_rx_buffers(struct i40e_ring *rx_ring, u16 cleaned_count)\n \t\tif (!i40e_alloc_mapped_page(rx_ring, bi))\n \t\t\tgoto no_buffers;\n \n+\t\t/* sync the buffer for use by the device */\n+\t\tdma_sync_single_range_for_device(rx_ring->dev, bi->dma,\n+\t\t\t\t\t\t bi->page_offset,\n+\t\t\t\t\t\t I40E_RXBUFFER_2048,\n+\t\t\t\t\t\t DMA_FROM_DEVICE);\n+\n \t\t/* Refresh the desc even if buffer_addrs didn't change\n \t\t * because each write-back erases this info.\n \t\t */\n@@ -2011,8 +2032,8 @@ struct sk_buff *i40e_fetch_rx_buffer(struct i40e_ring *rx_ring,\n \t\trx_ring->rx_stats.page_reuse_count++;\n \t} else {\n \t\t/* we are not reusing the buffer so unmap it */\n-\t\tdma_unmap_page(rx_ring->dev, rx_buffer->dma, PAGE_SIZE,\n-\t\t\t DMA_FROM_DEVICE);\n+\t\tdma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma, PAGE_SIZE,\n+\t\t\t\t DMA_FROM_DEVICE, I40E_RX_DMA_ATTR);\n \t}\n \n \t/* clear contents of buffer_info */\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.h b/drivers/net/ethernet/intel/i40e/i40e_txrx.h\nindex 5e24aef..34fd1e7 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.h\n@@ -133,6 +133,9 @@ enum i40e_dyn_idx_t {\n #define I40E_RX_HDR_SIZE I40E_RXBUFFER_256\n #define i40e_rx_desc i40e_32byte_rx_desc\n \n+#define I40E_RX_DMA_ATTR \\\n+\t(DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING)\n+\n /**\n * i40e_test_staterr - tests bits in Rx descriptor status and error fields\n * @rx_desc: pointer to receive descriptor (in le64 format)\ndiff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c\nindex cd0e28f..7edb4a8 100644\n--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c\n+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c\n@@ -493,7 +493,6 @@ int i40evf_setup_tx_descriptors(struct i40e_ring *tx_ring)\n **/\n void i40evf_clean_rx_ring(struct i40e_ring *rx_ring)\n {\n-\tstruct device *dev = rx_ring->dev;\n \tunsigned long bi_size;\n \tu16 i;\n \n@@ -513,7 +512,20 @@ void i40evf_clean_rx_ring(struct i40e_ring *rx_ring)\n \t\tif (!rx_bi->page)\n \t\t\tcontinue;\n \n-\t\tdma_unmap_page(dev, rx_bi->dma, PAGE_SIZE, DMA_FROM_DEVICE);\n+\t\t/* Invalidate cache lines that may have been written to by\n+\t\t * device so that we avoid corrupting memory.\n+\t\t */\n+\t\tdma_sync_single_range_for_cpu(rx_ring->dev,\n+\t\t\t\t\t rx_bi->dma,\n+\t\t\t\t\t rx_bi->page_offset,\n+\t\t\t\t\t I40E_RXBUFFER_2048,\n+\t\t\t\t\t DMA_FROM_DEVICE);\n+\n+\t\t/* free resources associated with mapping */\n+\t\tdma_unmap_page_attrs(rx_ring->dev, rx_bi->dma,\n+\t\t\t\t PAGE_SIZE,\n+\t\t\t\t DMA_FROM_DEVICE,\n+\t\t\t\t I40E_RX_DMA_ATTR);\n \t\t__free_pages(rx_bi->page, 0);\n \n \t\trx_bi->page = NULL;\n@@ -642,7 +654,10 @@ static bool i40e_alloc_mapped_page(struct i40e_ring *rx_ring,\n \t}\n \n \t/* map page for use */\n-\tdma = dma_map_page(rx_ring->dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE);\n+\tdma = dma_map_page_attrs(rx_ring->dev, page, 0,\n+\t\t\t\t PAGE_SIZE,\n+\t\t\t\t DMA_FROM_DEVICE,\n+\t\t\t\t I40E_RX_DMA_ATTR);\n \n \t/* if mapping failed free memory back to system since\n \t * there isn't much point in holding memory we can't use\n@@ -702,6 +717,12 @@ bool i40evf_alloc_rx_buffers(struct i40e_ring *rx_ring, u16 cleaned_count)\n \t\tif (!i40e_alloc_mapped_page(rx_ring, bi))\n \t\t\tgoto no_buffers;\n \n+\t\t/* sync the buffer for use by the device */\n+\t\tdma_sync_single_range_for_device(rx_ring->dev, bi->dma,\n+\t\t\t\t\t\t bi->page_offset,\n+\t\t\t\t\t\t I40E_RXBUFFER_2048,\n+\t\t\t\t\t\t DMA_FROM_DEVICE);\n+\n \t\t/* Refresh the desc even if buffer_addrs didn't change\n \t\t * because each write-back erases this info.\n \t\t */\n@@ -1158,8 +1179,8 @@ struct sk_buff *i40evf_fetch_rx_buffer(struct i40e_ring *rx_ring,\n \t\trx_ring->rx_stats.page_reuse_count++;\n \t} else {\n \t\t/* we are not reusing the buffer so unmap it */\n-\t\tdma_unmap_page(rx_ring->dev, rx_buffer->dma, PAGE_SIZE,\n-\t\t\t DMA_FROM_DEVICE);\n+\t\tdma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma, PAGE_SIZE,\n+\t\t\t\t DMA_FROM_DEVICE, I40E_RX_DMA_ATTR);\n \t}\n \n \t/* clear contents of buffer_info */\ndiff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.h b/drivers/net/ethernet/intel/i40evf/i40e_txrx.h\nindex 8274ba6..0135121 100644\n--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.h\n+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.h\n@@ -120,6 +120,9 @@ enum i40e_dyn_idx_t {\n #define I40E_RX_HDR_SIZE I40E_RXBUFFER_256\n #define i40e_rx_desc i40e_32byte_rx_desc\n \n+#define I40E_RX_DMA_ATTR \\\n+\t(DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING)\n+\n /**\n * i40e_test_staterr - tests bits in Rx descriptor status and error fields\n * @rx_desc: pointer to receive descriptor (in le64 format)\n", "prefixes": [ "next", "S59", "4/6" ] }