Skip to contentSkip to conversation

[linux-review:Balakrishna-Godavarthi/Bluetooth-hci_qca-Collect-controller-memory-dump-during-SSR/20200104-050250 1/1] drivers/bluetooth/hci_qca.c:996:26: sparse: sparse: cast to restricted __le16

DISCUSSION kbuild test robot 1 participant 2 messages Jan 4, 2020

Subsystems (2)
lore
Share & tools
lore

kbuild test robot

author build bot
#0 lore raw
tree:   https://github.com/0day-ci/linux/commits/Balakrishna-Godavarthi/Bluetooth-hci_qca-Collect-controller-memory-dump-during-SSR/20200104-050250
head:   c01ccc6a0ce1b4c2019cc116baaaaa804b477939
commit: c01ccc6a0ce1b4c2019cc116baaaaa804b477939 [1/1] Bluetooth: hci_qca: Collect controller memory dump during SSR
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-129-g341daf20-dirty
        git checkout c01ccc6a0ce1b4c2019cc116baaaaa804b477939
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag

sparse warnings: (new ones prefixed by >>)

>> drivers/bluetooth/hci_qca.c:996:26: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/hci_qca.c:997:26: sparse: sparse: cast to restricted __le16
>> drivers/bluetooth/hci_qca.c:1011:37: sparse: sparse: cast to restricted __le32
>> drivers/bluetooth/hci_qca.c:1078:5: sparse: sparse: symbol 'qca_controller_memdump_event' was not declared. Should it be static?

Please review and possibly fold the followup patch.

vim +996 drivers/bluetooth/hci_qca.c

968
969 static void qca_controller_memdump(struct work_struct *work)
970 {
971 struct qca_data *qca = container_of(work, struct qca_data,
972 ctrl_memdump_evt);
973 struct hci_uart *hu = qca->hu;
974 struct sk_buff *skb;
975 struct qca_memdump_event_hdr *cmd_hdr;
976 struct qca_memdump_data *qca_memdump = qca->qca_memdump;
977 struct qca_dump_size *dump;
978 char *memdump_buf;
979 char nullBuff[QCA_DUMP_PACKET_SIZE] = { 0 };
980 u16 opcode, seq_no;
981 u32 dump_size;
982
983 while ((skb = skb_dequeue(&qca->rx_memdump_q))) {
984
985 if (!qca_memdump) {
986 qca_memdump = kzalloc(sizeof(struct qca_memdump_data),
987 GFP_ATOMIC);
988 if (!qca_memdump)
989 return;
990
991 qca->qca_memdump = qca_memdump;
992 }
993
994 qca->memdump_state = QCA_MEMDUMP_COLLECTING;
995 cmd_hdr = (void *) skb->data;

 > 996			opcode = __le16_to_cpu(cmd_hdr->opcode);
   997			seq_no = __le16_to_cpu(cmd_hdr->seq_no);
   998			skb_pull(skb, sizeof(struct qca_memdump_event_hdr));
   999	
  1000			if (!seq_no) {
  1001	
  1002				/* This is the first frame of memdump packet from
  1003				 * the controller, Disable IBS to recevie dump
  1004				 * with out any interruption, ideally time required for
  1005				 * the controller to send the dump is 8 seconds. let us
  1006				 * start timer to handle this asynchronous activity.
  1007				 */
  1008				clear_bit(QCA_IBS_ENABLED, &qca->flags);
  1009				set_bit(QCA_MEMDUMP_COLLECTION, &qca->flags);
  1010				dump = (void *) skb->data;
> 1011				dump_size = __le32_to_cpu(dump->dump_size);
  1012				if (!(dump_size)) {
  1013					bt_dev_err(hu->hdev, "Rx invalid memdump size");
  1014					kfree_skb(skb);
  1015					return;
  1016				}
  1017	
  1018				bt_dev_info(hu->hdev, "QCA collecting dump of size:%u",
  1019					    dump_size);
  1020				mod_timer(&qca->memdump_timer, (jiffies +
  1021					  msecs_to_jiffies(MEMDUMP_TIMEOUT_MS)));
  1022	
  1023				skb_pull(skb, sizeof(dump_size));
  1024				memdump_buf = vmalloc(dump_size);
  1025				qca_memdump->memdump_buf_head = memdump_buf;
  1026				qca_memdump->memdump_buf_tail = memdump_buf;
  1027			}
  1028	
  1029			memdump_buf = qca_memdump->memdump_buf_tail;
  1030	
  1031			/* If sequence no 0 is missed then there is no point in
  1032			 * accepting the other sequences.
  1033			 */
  1034			if (!memdump_buf) {
  1035				bt_dev_err(hu->hdev, "QCA: Discarding other packets");
  1036				kfree(qca_memdump);
  1037				kfree_skb(skb);
  1038				qca->qca_memdump = NULL;
  1039				return;
  1040			}
  1041	
  1042			/* There could be chance of missing some packets from
  1043			 * the controller. In such cases let us store the dummy
  1044			 * packets in the buffer.
  1045			 */
  1046			while ((seq_no > qca_memdump->current_seq_no + 1) &&
  1047				seq_no != QCA_LAST_SEQUENCE_NUM) {
  1048				bt_dev_err(hu->hdev, "QCA controller missed packet:%d",
  1049					   qca_memdump->current_seq_no);
  1050				memcpy(memdump_buf, nullBuff, QCA_DUMP_PACKET_SIZE);
  1051				memdump_buf = memdump_buf + QCA_DUMP_PACKET_SIZE;
  1052				qca_memdump->received_dump += QCA_DUMP_PACKET_SIZE;
  1053				qca_memdump->current_seq_no++;
  1054			}
  1055	
  1056			memcpy(memdump_buf, (unsigned char *) skb->data, skb->len);
  1057			memdump_buf = memdump_buf + skb->len;
  1058			qca_memdump->memdump_buf_tail = memdump_buf;
  1059			qca_memdump->current_seq_no = seq_no + 1;
  1060			qca_memdump->received_dump += skb->len;
  1061			qca->qca_memdump = qca_memdump;
  1062			kfree_skb(skb);
  1063			if (seq_no == QCA_LAST_SEQUENCE_NUM) {
  1064				bt_dev_info(hu->hdev, "QCA writing crash dump of size %d bytes",
  1065					   qca_memdump->received_dump);
  1066				memdump_buf = qca_memdump->memdump_buf_head;
  1067				dev_coredumpv(&hu->serdev->dev, memdump_buf,
  1068					      qca_memdump->received_dump, GFP_KERNEL);
  1069				del_timer(&qca->memdump_timer);
  1070				kfree(qca->qca_memdump);
  1071				qca->qca_memdump = NULL;
  1072				qca->memdump_state = QCA_MEMDUMP_COLLECTED;
  1073			}
  1074		}
  1075	
  1076	}
  1077	
> 1078	int qca_controller_memdump_event(struct hci_dev *hdev, struct sk_buff *skb)

1079 {
1080 struct hci_uart *hu = hci_get_drvdata(hdev);
1081 struct qca_data *qca = hu->priv;
1082
1083 skb_queue_tail(&qca->rx_memdump_q, skb);
1084 queue_work(qca->workqueue, &qca->ctrl_memdump_evt);
1085
1086 return 0;
1087 }
1088

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation

author build bot
#1 lore raw

[RFC PATCH] Bluetooth: hci_qca: qca_controller_memdump_event() can be static

Fixes: c01ccc6a0ce1 ("Bluetooth: hci_qca: Collect controller memory dump during SSR")
Fixes c01ccc6a0ce1 ("Bluetooth: hci_qca: Collect controller memory dump during SSR")
---
 hci_qca.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bluetooth/hci_qca.c +1 -1
index 9392cc7f9908f..e20f37accd114 100644
@@ -1075,7 +1075,7 @@ static void qca_controller_memdump(struct work_struct *work)
 
 }
 
-int qca_controller_memdump_event(struct hci_dev *hdev, struct sk_buff *skb)
+static int qca_controller_memdump_event(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_uart *hu = hci_get_drvdata(hdev);
 	struct qca_data *qca = hu->priv;