Browse Source

qcacmn: Adjust buffer size for fw dump

qcacld-2.0 to qcacmn propagation

In platform using usb interface, when fw assert, buffer alloc for fw
dump is smaller than the actual fw dump size, so adjust the buffer size.

Change-Id: I4706c57e8c1b684bfe164b23fc0902c376d4d80a
CRs-Fixed: 1043805
Kai Liu 8 years ago
parent
commit
af427fe54c
2 changed files with 14 additions and 2 deletions
  1. 11 2
      hif/src/usb/if_usb.c
  2. 3 0
      hif/src/usb/if_usb.h

+ 11 - 2
hif/src/usb/if_usb.c

@@ -575,6 +575,10 @@ void hif_fw_assert_ramdump_pattern(struct hif_usb_softc *sc)
 	uint8_t *data;
 	uint8_t *ram_ptr = NULL;
 	char *fw_ram_seg_name[FW_RAM_SEG_CNT] = {"DRAM", "IRAM", "AXI"};
+	size_t fw_ram_reg_size[FW_RAM_SEG_CNT] = {
+				  FW_RAMDUMP_DRAMSIZE,
+				  FW_RAMDUMP_IRAMSIZE,
+				  FW_RAMDUMP_AXISIZE };
 
 	data = sc->fw_data;
 	len = sc->fw_data_len;
@@ -588,7 +592,7 @@ void hif_fw_assert_ramdump_pattern(struct hif_usb_softc *sc)
 		HIF_ERROR("Firmware %s dump:\n", fw_ram_seg_name[i]);
 		sc->ramdump[i] =
 			qdf_mem_malloc(sizeof(struct fw_ramdump) +
-					FW_RAMDUMP_SEG_SIZE);
+					fw_ram_reg_size[i]);
 		if (!sc->ramdump[i]) {
 			pr_err("Fail to allocate memory for ram dump");
 			QDF_BUG(0);
@@ -606,7 +610,12 @@ void hif_fw_assert_ramdump_pattern(struct hif_usb_softc *sc)
 	reg++;
 	ram_ptr = (sc->ramdump[i])->mem + (sc->ramdump[i])->length;
 	(sc->ramdump[i])->length += (len - 8);
-	qdf_mem_copy(ram_ptr, (A_UINT8 *) reg, len - 8);
+	if (sc->ramdump[i]->length <= fw_ram_reg_size[i]) {
+		qdf_mem_copy(ram_ptr, (A_UINT8 *) reg, len - 8);
+	} else {
+		HIF_ERROR("memory copy overlap\n");
+		QDF_BUG(0);
+	}
 
 	if (pattern == FW_RAMDUMP_END_PATTERN) {
 		HIF_ERROR("%s memory size = %d\n", fw_ram_seg_name[i],

+ 3 - 0
hif/src/usb/if_usb.h

@@ -61,6 +61,9 @@
 #define FW_RAMDUMP_PATTERN      0x0000f600
 #define FW_RAMDUMP_END_PATTERN  0x0000f601
 #define FW_RAMDUMP_PATTERN_MASK 0xfffffff0
+#define FW_RAMDUMP_DRAMSIZE     0x00098000
+#define FW_RAMDUMP_IRAMSIZE     0x000C0000
+#define FW_RAMDUMP_AXISIZE      0x00020000
 
 /* FW RAM segments (Rome USB) */
 enum {