iwlwifi: pcie: properly configure the debug buffer size for 8000
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Tue, 5 Jan 2016 13:25:43 +0000 (15:25 +0200)
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Thu, 7 Jan 2016 17:01:33 +0000 (19:01 +0200)
8000 device family has a new debug engine that needs to be
configured differently than 7000's.
The debug engine's DMA works in chunks of memory and the
size of the buffer really means the start of the last
chunk. Since one chunk is 256-byte long, we should
configure the device to write to buffer_size - 256.
This fixes a situation were the device would write to
memory it is not allowed to access.

CC: <stable@vger.kernel.org> [4.1+]
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
drivers/net/wireless/intel/iwlwifi/pcie/trans.c

index 3a4310917978edb6f3aac9eddd398c1134f43582..d60a467a983c6f220384b701953eb42d2cc4c1ae 100644 (file)
@@ -7,6 +7,7 @@
  *
  * Copyright(c) 2007 - 2015 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
+ * Copyright(c) 2016 Intel Deutschland GmbH
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -33,6 +34,7 @@
  *
  * Copyright(c) 2005 - 2015 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
+ * Copyright(c) 2016 Intel Deutschland GmbH
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -924,9 +926,16 @@ monitor:
        if (dest->monitor_mode == EXTERNAL_MODE && trans_pcie->fw_mon_size) {
                iwl_write_prph(trans, le32_to_cpu(dest->base_reg),
                               trans_pcie->fw_mon_phys >> dest->base_shift);
-               iwl_write_prph(trans, le32_to_cpu(dest->end_reg),
-                              (trans_pcie->fw_mon_phys +
-                               trans_pcie->fw_mon_size) >> dest->end_shift);
+               if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000)
+                       iwl_write_prph(trans, le32_to_cpu(dest->end_reg),
+                                      (trans_pcie->fw_mon_phys +
+                                       trans_pcie->fw_mon_size - 256) >>
+                                               dest->end_shift);
+               else
+                       iwl_write_prph(trans, le32_to_cpu(dest->end_reg),
+                                      (trans_pcie->fw_mon_phys +
+                                       trans_pcie->fw_mon_size) >>
+                                               dest->end_shift);
        }
 }