Skip to contentSkip to conversation

Bluetooth: btmrvl: remove extra newline character

PATCH In review Amitkumar Karwar 3 participants 5 messages Nov 24, 2014 – Dec 12, 2014 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Bluetooth: btmrvl: remove extra newline character

BT_INFO/BT_DBG etc. already takes care of adding a newline An extra newline character inside message is removed in this patch.

---
 drivers/bluetooth/btmrvl_main.c | 14 +++++++-------
 drivers/bluetooth/btmrvl_sdio.c |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/bluetooth/btmrvl_main.c +7 -7
index bb0d2c2..10973ac 100644
@@ -42,7 +42,7 @@ void btmrvl_interrupt(struct btmrvl_private *priv)
 	priv->adapter->int_count++;
 
 	if (priv->adapter->hs_state == HS_ACTIVATED) {
-		BT_DBG("BT: HS DEACTIVATED in ISR!\n");
+		BT_DBG("BT: HS DEACTIVATED in ISR!");
 		priv->adapter->hs_state = HS_DEACTIVATED;
 	}
 
@@ -214,7 +214,7 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, u8 subcmd)
 
 	ret = btmrvl_send_sync_cmd(priv, BT_CMD_MODULE_CFG_REQ, &subcmd, 1);
 	if (ret)
-		BT_ERR("module_cfg_cmd(%x) failed\n", subcmd);
+		BT_ERR("module_cfg_cmd(%x) failed", subcmd);
 
 	return ret;
 }
@@ -250,7 +250,7 @@ int btmrvl_send_hscfg_cmd(struct btmrvl_private *priv)
 
 	ret = btmrvl_send_sync_cmd(priv, BT_CMD_HOST_SLEEP_CONFIG, param, 2);
 	if (ret)
-		BT_ERR("HSCFG command failed\n");
+		BT_ERR("HSCFG command failed");
 
 	return ret;
 }
@@ -268,7 +268,7 @@ int btmrvl_enable_ps(struct btmrvl_private *priv)
 
 	ret = btmrvl_send_sync_cmd(priv, BT_CMD_AUTO_SLEEP_MODE, &param, 1);
 	if (ret)
-		BT_ERR("PSMODE command failed\n");
+		BT_ERR("PSMODE command failed");
 
 	return 0;
 }
@@ -281,7 +281,7 @@ int btmrvl_enable_hs(struct btmrvl_private *priv)
 
 	ret = btmrvl_send_sync_cmd(priv, BT_CMD_HOST_SLEEP_ENABLE, NULL, 0);
 	if (ret) {
-		BT_ERR("Host sleep enable command failed\n");
+		BT_ERR("Host sleep enable command failed");
 		return ret;
 	}
 
@@ -328,7 +328,7 @@ int btmrvl_prepare_command(struct btmrvl_private *priv)
 		} else {
 			ret = priv->hw_wakeup_firmware(priv);
 			priv->adapter->hs_state = HS_DEACTIVATED;
-			BT_DBG("BT: HS DEACTIVATED due to host activity!\n");
+			BT_DBG("BT: HS DEACTIVATED due to host activity!");
 		}
 	}
 
@@ -493,7 +493,7 @@ static int btmrvl_download_cal_data(struct btmrvl_private *priv,
 	ret = btmrvl_send_sync_cmd(priv, BT_CMD_LOAD_CONFIG_DATA, data,
 				   BT_CAL_HDR_LEN + len);
 	if (ret)
-		BT_ERR("Failed to download caibration data\n");
+		BT_ERR("Failed to download caibration data");
 
 	return 0;
 }
drivers/bluetooth/btmrvl_sdio.c +2 -2
index 550bce0..416d792 100644
@@ -764,8 +764,8 @@ static void btmrvl_sdio_interrupt(struct sdio_func *func)
 
 	card = sdio_get_drvdata(func);
 	if (!card || !card->priv) {
-		BT_ERR("sbi_interrupt(%p) card or priv is "
-				"NULL, card=%p\n", func, card);
+		BT_ERR("sbi_interrupt(%p) card or priv is NULL, card=%p",
+		       func, card);
 		return;
 	}
 
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH v4 2/2 Bluetooth: btmrvl add firmware dump support

From: Xinming Hu <[email protected]>

This patch adds firmware dump support for marvell bluetooth chipset. Currently only SD8897 is supported. This is implemented based on dev_coredump, a new mechnism introduced in kernel 3.18rc3

Firmware dump can be trigger by
echo 1 > /sys/kernel/debug/bluetooth/hci*/config/fw_dump and when the dump operation is completed, data can be read by cat /sys/class/devcoredump/devcd*/data

We have prepared following script to divide fw memory dump data into multiple files based on memory type.

[root]# cat btmrvl_split_dump_data.sh #!/bin/bash
# usage: ./btmrvl_split_dump_data.sh dump_data

fw_dump_data=$1

mem_type="ITCM DTCM SQRAM APU CIU ICU MAC EXT7 EXT8 EXT9 EXT10 EXT11 EXT12 EXT13 EXTLAST"

for name in ${mem_type[@]}
do
sed -n "/Start dump $name/,/End dump/p" $fw_dump_data > tmp.$name.log if [ ! -s tmp.$name.log ]
then
rm -rf tmp.$name.log
else
# Remove the describle info "Start dump" and "End dump" sed '1d' tmp.$name.log | sed '$d' > /data/$name.log if [ -s /data/$name.log ]
then
echo "generate /data/$name.log"
else
sed '1d' tmp.$name.log | sed '$d' > /var/$name.log echo "generate /var/$name.log"
fi
rm -rf tmp.$name.log
fi
done

---
v4: Change if/else check to improve readability
Move "#include <linux/devcoredump.h>" to btmrvl_sdio.c file. Don't expose debugfs entry by showing an error when the callback is not defined.
BT_ERR/BT_INFO already takes care of newline. Remove extra "\n" in the message.
v3: Change fw_dump debugfs file permissions to write only
Replace kstrtol with strtobool
v2: Add "select WANT_DEV_COREDUMP" in Kconfig
Use write debugfs command instead of read to trigger dump operation.

---
 drivers/bluetooth/Kconfig          |   1 +
 drivers/bluetooth/btmrvl_debugfs.c |  31 ++++
 drivers/bluetooth/btmrvl_drv.h     |  20 +++
 drivers/bluetooth/btmrvl_main.c    |   7 +
 drivers/bluetooth/btmrvl_sdio.c    | 300 +++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/btmrvl_sdio.h    |   5 +
 6 files changed, 364 insertions(+)
drivers/bluetooth/Kconfig +1 -0
index 4547dc2..364f080 100644
@@ -210,6 +210,7 @@ config BT_MRVL_SDIO
 	tristate "Marvell BT-over-SDIO driver"
 	depends on BT_MRVL && MMC
 	select FW_LOADER
+	select WANT_DEV_COREDUMP
 	help
 	  The driver for Marvell Bluetooth chipsets with SDIO interface.
 
drivers/bluetooth/btmrvl_debugfs.c +31 -0
index 023d35e..1828ed8 100644
@@ -167,6 +167,35 @@ static const struct file_operations btmrvl_hscmd_fops = {
 	.llseek = default_llseek,
 };
 
+static ssize_t btmrvl_fwdump_write(struct file *file, const char __user *ubuf,
+				   size_t count, loff_t *ppos)
+{
+	struct btmrvl_private *priv = file->private_data;
+	char buf[16];
+	bool result;
+
+	memset(buf, 0, sizeof(buf));
+
+	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+		return -EFAULT;
+
+	if (strtobool(buf, &result))
+		return -EINVAL;
+
+	if (!result)
+		return -EINVAL;
+
+	btmrvl_firmware_dump(priv);
+
+	return count;
+}
+
+static const struct file_operations btmrvl_fwdump_fops = {
+	.write	= btmrvl_fwdump_write,
+	.open	= simple_open,
+	.llseek = default_llseek,
+};
+
 void btmrvl_debugfs_init(struct hci_dev *hdev)
 {
 	struct btmrvl_private *priv = hci_get_drvdata(hdev);
@@ -197,6 +226,8 @@ void btmrvl_debugfs_init(struct hci_dev *hdev)
 			    priv, &btmrvl_hscmd_fops);
 	debugfs_create_file("hscfgcmd", 0644, dbg->config_dir,
 			    priv, &btmrvl_hscfgcmd_fops);
+	debugfs_create_file("fw_dump", 0200, dbg->config_dir,
+			    priv, &btmrvl_fwdump_fops);
 
 	dbg->status_dir = debugfs_create_dir("status", hdev->debugfs);
 	debugfs_create_u8("curpsmode", 0444, dbg->status_dir,
drivers/bluetooth/btmrvl_drv.h +20 -0
index 38ad662..330f8f8 100644
@@ -32,6 +32,24 @@
 /* Time to wait for command response in millisecond */
 #define WAIT_UNTIL_CMD_RESP		5000
 
+enum rdwr_status {
+	RDWR_STATUS_SUCCESS = 0,
+	RDWR_STATUS_FAILURE = 1,
+	RDWR_STATUS_DONE = 2
+};
+
+#define FW_DUMP_MAX_NAME_LEN    8
+#define FW_DUMP_HOST_READY      0xEE
+#define FW_DUMP_DONE            0xFF
+#define FW_DUMP_READ_DONE       0xFE
+
+struct memory_type_mapping {
+	u8 mem_name[FW_DUMP_MAX_NAME_LEN];
+	u8 *mem_ptr;
+	u32 mem_size;
+	u8 done_flag;
+};
+
 struct btmrvl_thread {
 	struct task_struct *task;
 	wait_queue_head_t wait_q;
@@ -81,6 +99,7 @@ struct btmrvl_private {
 				u8 *payload, u16 nb);
 	int (*hw_wakeup_firmware) (struct btmrvl_private *priv);
 	int (*hw_process_int_status) (struct btmrvl_private *priv);
+	void (*firmware_dump)(struct btmrvl_private *priv);
 	spinlock_t driver_lock;		/* spinlock used by driver */
 #ifdef CONFIG_DEBUG_FS
 	void *debugfs_data;
@@ -151,6 +170,7 @@ int btmrvl_send_hscfg_cmd(struct btmrvl_private *priv);
 int btmrvl_enable_ps(struct btmrvl_private *priv);
 int btmrvl_prepare_command(struct btmrvl_private *priv);
 int btmrvl_enable_hs(struct btmrvl_private *priv);
+void btmrvl_firmware_dump(struct btmrvl_private *priv);
 
 #ifdef CONFIG_DEBUG_FS
 void btmrvl_debugfs_init(struct hci_dev *hdev);
drivers/bluetooth/btmrvl_main.c +7 -0
index 10973ac..30939c9 100644
@@ -22,6 +22,7 @@
 #include <linux/of.h>
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
+#include <linux/mmc/sdio_func.h>
 
 #include "btmrvl_drv.h"
 #include "btmrvl_sdio.h"
@@ -335,6 +336,12 @@ int btmrvl_prepare_command(struct btmrvl_private *priv)
 	return ret;
 }
 
+void btmrvl_firmware_dump(struct btmrvl_private *priv)
+{
+	if (priv->firmware_dump)
+		priv->firmware_dump(priv);
+}
+
 static int btmrvl_tx_pkt(struct btmrvl_private *priv, struct sk_buff *skb)
 {
 	int ret = 0;
drivers/bluetooth/btmrvl_sdio.c +300 -0

366 lines not on this page · raw message

drivers/bluetooth/btmrvl_sdio.h +5 -0
index 453559f..1a3bd06 100644
@@ -81,6 +81,9 @@ struct btmrvl_sdio_card_reg {
 	bool int_read_to_clear;
 	u8 host_int_rsr;
 	u8 card_misc_cfg;
+	u8 fw_dump_ctrl;
+	u8 fw_dump_start;
+	u8 fw_dump_end;
 };
 
 struct btmrvl_sdio_card {
@@ -90,6 +93,7 @@ struct btmrvl_sdio_card {
 	const char *firmware;
 	const struct btmrvl_sdio_card_reg *reg;
 	bool support_pscan_win_report;
+	bool supports_fw_dump;
 	u16 sd_blksz_fw_dl;
 	u8 rx_unit;
 	struct btmrvl_private *priv;
@@ -101,6 +105,7 @@ struct btmrvl_sdio_device {
 	const struct btmrvl_sdio_card_reg *reg;
 	const bool support_pscan_win_report;
 	u16 sd_blksz_fw_dl;
+	bool supports_fw_dump;
 };
 
 
Signature · 1 line
1.8.1.4
maintainer
#4 lore raw
In reply to Amitkumar Karwar

Hi Amitkumar,

Quoted 9 lines

BT_INFO/BT_DBG etc. already takes care of adding a newline An extra newline character inside message is removed in this patch.

---
drivers/bluetooth/btmrvl_main.c | 14 +++++++------- drivers/bluetooth/btmrvl_sdio.c | 4 ++--

2 files changed, 9 insertions(+), 9 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

maintainer
#2 lore raw

Re: [PATCH v4 2/2] Bluetooth: btmrvl add firmware dump support

In reply to Amitkumar Karwar

Hi Amitkumar,

Quoted 59 lines

This patch adds firmware dump support for marvell bluetooth chipset. Currently only SD8897 is supported. This is implemented based on dev_coredump, a new mechnism introduced in kernel 3.18rc3

Firmware dump can be trigger by
echo 1 > /sys/kernel/debug/bluetooth/hci*/config/fw_dump and when the dump operation is completed, data can be read by cat /sys/class/devcoredump/devcd*/data

We have prepared following script to divide fw memory dump data into multiple files based on memory type.

[root]# cat btmrvl_split_dump_data.sh #!/bin/bash
# usage: ./btmrvl_split_dump_data.sh dump_data

fw_dump_data=$1

mem_type="ITCM DTCM SQRAM APU CIU ICU MAC EXT7 EXT8 EXT9 EXT10 EXT11 EXT12 EXT13 EXTLAST"

for name in ${mem_type[@]}
do
sed -n "/Start dump $name/,/End dump/p" $fw_dump_data > tmp.$name.log if [ ! -s tmp.$name.log ]
then
rm -rf tmp.$name.log
else
# Remove the describle info "Start dump" and "End dump" sed '1d' tmp.$name.log | sed '$d' > /data/$name.log if [ -s /data/$name.log ]
then
echo "generate /data/$name.log"
else
sed '1d' tmp.$name.log | sed '$d' > /var/$name.log echo "generate /var/$name.log"
fi
rm -rf tmp.$name.log
fi
done

---
v4: Change if/else check to improve readability
Move "#include <linux/devcoredump.h>" to btmrvl_sdio.c file. Don't expose debugfs entry by showing an error when the callback is not defined.
BT_ERR/BT_INFO already takes care of newline. Remove extra "\n" in the message.
v3: Change fw_dump debugfs file permissions to write only
Replace kstrtol with strtobool
v2: Add "select WANT_DEV_COREDUMP" in Kconfig
Use write debugfs command instead of read to trigger dump operation.
---

Quoted 7 lines
drivers/bluetooth/Kconfig          |   1 +
drivers/bluetooth/btmrvl_debugfs.c |  31 ++++
drivers/bluetooth/btmrvl_drv.h     |  20 +++
drivers/bluetooth/btmrvl_main.c    |   7 +
drivers/bluetooth/btmrvl_sdio.c    | 300 +++++++++++++++++++++++++++++++++++++
drivers/bluetooth/btmrvl_sdio.h    |   5 +
6 files changed, 364 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel

#3 lore raw

Re: [PATCH v4 2/2] Bluetooth: btmrvl add firmware dump support

In reply to Amitkumar Karwar
Quoted 11 lines · Amitkumar Karwar

From: Xinming Hu <[email protected]>

This patch adds firmware dump support for marvell bluetooth chipset. Currently only SD8897 is supported. This is implemented based on dev_coredump, a new mechnism introduced in kernel 3.18rc3

Firmware dump can be trigger by
echo 1 > /sys/kernel/debug/bluetooth/hci*/config/fw_dump and when the dump operation is completed, data can be read by cat /sys/class/devcoredump/devcd*/data

If anyone still cares - this looks fine to me from devcoredump usage.

Personally I would've picked a binary format, but the devcoredump framework is intentionally payload agnostic.

johannes