Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4864179imb; Thu, 7 Mar 2019 02:18:15 -0800 (PST) X-Google-Smtp-Source: APXvYqygCLgBPmcUlF5iZA7Qkz/krI2C0PyHLAQsilFcLWWUWYwe1B1KCWXGkDzsVq6OOS+8thjV X-Received: by 2002:a65:6149:: with SMTP id o9mr10651865pgv.315.1551953895494; Thu, 07 Mar 2019 02:18:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551953895; cv=none; d=google.com; s=arc-20160816; b=elfPaPJ/IDFRvJIFRsFncUd0Kf2ErQSqwOE5jFK67/Pi82K9TuL38YFi4JFokIDbsv NwUgtBztN+3ZsPrNhq/KeC0X25kFrDPUOHuc8FWwlEu6P8lNeuMdKtrZ1CCRKzxlnNtP whg1ty0bYESBIztQwsNkGTGdZgcf7FMIz7DCDn14tJKLoUfu7kzGLwkmSYxSSIMW2IYi 0R39+o3slmHdSA8R3OGr8dUooTRZjRVttmLRF8d/EjIXlS3eoEs0vNO6vvtFYWVgTECf NBoGYmDYSL/x2KbGm77QCPu676MHTvQgF10Z9CNKb1LMB9iXXkVSo0fWQvhDDAhqZCId ukjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dmarc-filter:dkim-signature :dkim-signature; bh=/wcheHLDadAb6guTqspcjcyCZpDjD/THRkmsE6IPOh4=; b=isWr8TJLAGhbjgNn99aNadae9WZjvGpf5WMnvtBm6L1uV7X044WmKgjzZw2Xxr5Mxv hoIB3slFCi0c6t1sYDUsCmelav/UdfS5YNlB080Y4MFccfaiUUaqv3Sn6B+jBGDymoxW IFDTCNk4uU8M2Eg9Sb6d/pcMrOzpEgfRSMHNJaBKbBE136534aqnSqmBFN1eExvkZ5kT yhBWFgJXaDt0U7H5sOOIP+gXYHLcxJER9P61od5estTLBz/zgUxU7cChnYqOZTgKDW51 JOenAi3+H+ZBxZfT/upOZpcZewgk34abiD+AKDQtRbNcw0d/GWhUNvECv3NEOsPwOfdF g2EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=SbDsk+98; dkim=pass header.i=@codeaurora.org header.s=default header.b=oFBS0GUN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si3745351pll.18.2019.03.07.02.17.59; Thu, 07 Mar 2019 02:18:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=SbDsk+98; dkim=pass header.i=@codeaurora.org header.s=default header.b=oFBS0GUN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726166AbfCGKRg (ORCPT + 99 others); Thu, 7 Mar 2019 05:17:36 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:35148 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726015AbfCGKRg (ORCPT ); Thu, 7 Mar 2019 05:17:36 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id DF0FF609D4; Thu, 7 Mar 2019 10:17:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1551953855; bh=5z0OXUGHDdPqXwfCPrD15+Akap4RvFoJCp8G/dhl0RQ=; h=From:To:Cc:Subject:Date:From; b=SbDsk+98qBZlxYlTH4AGluTLOVNsr7+Zqy9+eNgK8uaYPbJG8BMzaHDbmeBZtJuzY OdUO4P7KZtFo6pl/x6cm1RUiMrsXZTxH/SjwP81qppfq7T+Vth/xkh9QYxM0hifzhp W7nn6/huLb/BFzsgT8K+PS1Z0rZK3PQjGOs2P3fI= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from bgodavar-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: bgodavar@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 33A9A606DB; Thu, 7 Mar 2019 10:17:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1551953853; bh=5z0OXUGHDdPqXwfCPrD15+Akap4RvFoJCp8G/dhl0RQ=; h=From:To:Cc:Subject:Date:From; b=oFBS0GUNzdmGAIAhefZq5a/6qXoVfA3QTwTBBbTZY0h4Tx6iCB4g3UzlN9If/Rdf3 /v1cdZjJ1hh2UZ6Ky/zRi1vLSMAM+mbiGSqIyGGOoccj4FDjO4ipyy/TzWhTKelXzt NjBPciWic3p2FHbPYUXPi5Qq0rYLO/+G6NEjI3l4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 33A9A606DB Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=bgodavar@codeaurora.org From: Balakrishna Godavarthi To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, rjliao@codeaurora.org, Balakrishna Godavarthi Subject: [PATCH v1] Bluetooth: hci_qca: Enable the ldisc for ROME for x86 platforms. Date: Thu, 7 Mar 2019 15:47:22 +0530 Message-Id: <20190307101722.25871-1-bgodavar@codeaurora.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When using btattach to setup Rome over ldisc we observed a crash in qca_setup as it will try to access the serdev which is not available in the ldisc proto. This patch will fix the crash by support both the ldisc and serdev way in the qca hci_uart driver. Signed-off-by: Balakrishna Godavarthi --- drivers/bluetooth/hci_qca.c | 47 ++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 237aea34b69f..0a5c98d46864 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -963,7 +963,7 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate) { struct hci_uart *hu = hci_get_drvdata(hdev); struct qca_data *qca = hu->priv; - struct qca_serdev *qcadev; + struct qca_serdev *qcadev = NULL; struct sk_buff *skb; u8 cmd[] = { 0x01, 0x48, 0xFC, 0x01, 0x00 }; @@ -985,18 +985,19 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate) skb_queue_tail(&qca->txq, skb); hci_uart_tx_wakeup(hu); - qcadev = serdev_device_get_drvdata(hu->serdev); + if (hu->serdev) + qcadev = serdev_device_get_drvdata(hu->serdev); /* Wait for the baudrate change request to be sent */ - while (!skb_queue_empty(&qca->txq)) usleep_range(100, 200); - serdev_device_wait_until_sent(hu->serdev, - msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS)); + if (hu->serdev) + serdev_device_wait_until_sent(hu->serdev, + msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS)); /* Give the controller time to process the request */ - if (qcadev->btsoc_type == QCA_WCN3990) + if (qcadev && qcadev->btsoc_type == QCA_WCN3990) msleep(10); else msleep(300); @@ -1072,10 +1073,12 @@ static unsigned int qca_get_speed(struct hci_uart *hu, static int qca_check_speeds(struct hci_uart *hu) { - struct qca_serdev *qcadev; + struct qca_serdev *qcadev = NULL; - qcadev = serdev_device_get_drvdata(hu->serdev); - if (qcadev->btsoc_type == QCA_WCN3990) { + if (hu->serdev) + qcadev = serdev_device_get_drvdata(hu->serdev); + + if (qcadev && qcadev->btsoc_type == QCA_WCN3990) { if (!qca_get_speed(hu, QCA_INIT_SPEED) && !qca_get_speed(hu, QCA_OPER_SPEED)) return -EINVAL; @@ -1091,7 +1094,7 @@ static int qca_check_speeds(struct hci_uart *hu) static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) { unsigned int speed, qca_baudrate; - struct qca_serdev *qcadev; + struct qca_serdev *qcadev = NULL; int ret = 0; if (speed_type == QCA_INIT_SPEED) { @@ -1106,8 +1109,10 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) /* Disable flow control for wcn3990 to deassert RTS while * changing the baudrate of chip and host. */ - qcadev = serdev_device_get_drvdata(hu->serdev); - if (qcadev->btsoc_type == QCA_WCN3990) + if (hu->serdev) + qcadev = serdev_device_get_drvdata(hu->serdev); + + if (qcadev && qcadev->btsoc_type == QCA_WCN3990) hci_uart_set_flow_control(hu, true); qca_baudrate = qca_get_baudrate_value(speed); @@ -1119,7 +1124,7 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) host_set_baudrate(hu, speed); error: - if (qcadev->btsoc_type == QCA_WCN3990) + if (qcadev && qcadev->btsoc_type == QCA_WCN3990) hci_uart_set_flow_control(hu, false); } @@ -1181,11 +1186,15 @@ static int qca_setup(struct hci_uart *hu) struct hci_dev *hdev = hu->hdev; struct qca_data *qca = hu->priv; unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200; - struct qca_serdev *qcadev; + struct qca_serdev *qcadev = NULL; int ret; int soc_ver = 0; + enum qca_btsoc_type btsoc_type = QCA_ROME; - qcadev = serdev_device_get_drvdata(hu->serdev); + if (hu->serdev) { + qcadev = serdev_device_get_drvdata(hu->serdev); + btsoc_type = qcadev->btsoc_type; + } ret = qca_check_speeds(hu); if (ret) @@ -1194,7 +1203,7 @@ static int qca_setup(struct hci_uart *hu) /* Patch downloading has to be done without IBS mode */ clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags); - if (qcadev->btsoc_type == QCA_WCN3990) { + if (qcadev && btsoc_type == QCA_WCN3990) { bt_dev_info(hdev, "setting up wcn3990"); /* Enable NON_PERSISTENT_SETUP QUIRK to ensure to execute @@ -1225,7 +1234,7 @@ static int qca_setup(struct hci_uart *hu) qca_baudrate = qca_get_baudrate_value(speed); } - if (qcadev->btsoc_type != QCA_WCN3990) { + if (btsoc_type != QCA_WCN3990) { /* Get QCA version information */ ret = qca_read_soc_version(hdev, &soc_ver); if (ret) @@ -1234,7 +1243,7 @@ static int qca_setup(struct hci_uart *hu) bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver); /* Setup patch / NVM configurations */ - ret = qca_uart_setup(hdev, qca_baudrate, qcadev->btsoc_type, soc_ver); + ret = qca_uart_setup(hdev, qca_baudrate, btsoc_type, soc_ver); if (!ret) { set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags); qca_debugfs_init(hdev); @@ -1250,7 +1259,7 @@ static int qca_setup(struct hci_uart *hu) } /* Setup bdaddr */ - if (qcadev->btsoc_type == QCA_WCN3990) + if (btsoc_type == QCA_WCN3990) hu->hdev->set_bdaddr = qca_set_bdaddr; else hu->hdev->set_bdaddr = qca_set_bdaddr_rome; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project