]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.28/iwlwifi-mvm-synchronize-firmware-dma-paging-memory.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.9.28 / iwlwifi-mvm-synchronize-firmware-dma-paging-memory.patch
CommitLineData
b74db2ac
GKH
1From 4b70f07686d75d1eb5d956812cc810944e0b29b2 Mon Sep 17 00:00:00 2001
2From: Sara Sharon <sara.sharon@intel.com>
3Date: Wed, 30 Nov 2016 16:49:11 +0200
4Subject: iwlwifi: mvm: synchronize firmware DMA paging memory
5
6From: Sara Sharon <sara.sharon@intel.com>
7
8commit 4b70f07686d75d1eb5d956812cc810944e0b29b2 upstream.
9
10When driver needs to access the contents of a streaming DMA buffer
11without unmapping it it should call dma_sync_single_for_cpu().
12Once the call has been made, the CPU "owns" the DMA buffer and can
13work with it as needed.
14Before the device accesses the buffer, however, ownership should be
15transferred back to it with dma_sync_single_for_device().
16Both calls weren't performed by the driver, resulting with odd paging
17errors on some platforms. Fix it.
18
19Fixes: a6c4fb4441f4 ("iwlwifi: mvm: Add FW paging mechanism for the UMAC on PCI")
20Signed-off-by: Sara Sharon <sara.sharon@intel.com>
21Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
22Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23
24---
25 drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c | 4 ++++
26 drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 23 ++++++++++++++++++++---
27 2 files changed, 24 insertions(+), 3 deletions(-)
28
29--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c
30+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c
31@@ -784,12 +784,16 @@ void iwl_mvm_fw_error_dump(struct iwl_mv
32 struct iwl_fw_error_dump_paging *paging;
33 struct page *pages =
34 mvm->fw_paging_db[i].fw_paging_block;
35+ dma_addr_t addr = mvm->fw_paging_db[i].fw_paging_phys;
36
37 dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_PAGING);
38 dump_data->len = cpu_to_le32(sizeof(*paging) +
39 PAGING_BLOCK_SIZE);
40 paging = (void *)dump_data->data;
41 paging->index = cpu_to_le32(i);
42+ dma_sync_single_for_cpu(mvm->trans->dev, addr,
43+ PAGING_BLOCK_SIZE,
44+ DMA_BIDIRECTIONAL);
45 memcpy(paging->data, page_address(pages),
46 PAGING_BLOCK_SIZE);
47 dump_data = iwl_fw_error_next_data(dump_data);
48--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
49+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
50@@ -214,6 +214,10 @@ static int iwl_fill_paging_mem(struct iw
51 memcpy(page_address(mvm->fw_paging_db[0].fw_paging_block),
52 image->sec[sec_idx].data,
53 mvm->fw_paging_db[0].fw_paging_size);
54+ dma_sync_single_for_device(mvm->trans->dev,
55+ mvm->fw_paging_db[0].fw_paging_phys,
56+ mvm->fw_paging_db[0].fw_paging_size,
57+ DMA_BIDIRECTIONAL);
58
59 IWL_DEBUG_FW(mvm,
60 "Paging: copied %d CSS bytes to first block\n",
61@@ -228,9 +232,16 @@ static int iwl_fill_paging_mem(struct iw
62 * loop stop at num_of_paging_blk since that last block is not full.
63 */
64 for (idx = 1; idx < mvm->num_of_paging_blk; idx++) {
65- memcpy(page_address(mvm->fw_paging_db[idx].fw_paging_block),
66+ struct iwl_fw_paging *block = &mvm->fw_paging_db[idx];
67+
68+ memcpy(page_address(block->fw_paging_block),
69 image->sec[sec_idx].data + offset,
70- mvm->fw_paging_db[idx].fw_paging_size);
71+ block->fw_paging_size);
72+ dma_sync_single_for_device(mvm->trans->dev,
73+ block->fw_paging_phys,
74+ block->fw_paging_size,
75+ DMA_BIDIRECTIONAL);
76+
77
78 IWL_DEBUG_FW(mvm,
79 "Paging: copied %d paging bytes to block %d\n",
80@@ -242,9 +253,15 @@ static int iwl_fill_paging_mem(struct iw
81
82 /* copy the last paging block */
83 if (mvm->num_of_pages_in_last_blk > 0) {
84- memcpy(page_address(mvm->fw_paging_db[idx].fw_paging_block),
85+ struct iwl_fw_paging *block = &mvm->fw_paging_db[idx];
86+
87+ memcpy(page_address(block->fw_paging_block),
88 image->sec[sec_idx].data + offset,
89 FW_PAGING_SIZE * mvm->num_of_pages_in_last_blk);
90+ dma_sync_single_for_device(mvm->trans->dev,
91+ block->fw_paging_phys,
92+ block->fw_paging_size,
93+ DMA_BIDIRECTIONAL);
94
95 IWL_DEBUG_FW(mvm,
96 "Paging: copied %d pages in the last block %d\n",