Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4025119pxb; Tue, 2 Nov 2021 02:44:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMqYXon5MABak3z8Inu0p09oN5uCeTiz6zhtyeQhQvjYaLBQuKs/FPwvdAJythimmaXoav X-Received: by 2002:a17:906:2599:: with SMTP id m25mr44988046ejb.302.1635846275617; Tue, 02 Nov 2021 02:44:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635846275; cv=none; d=google.com; s=arc-20160816; b=AxxG3eEr9RnS8YE64o4TkAEX/BAmXZWFVZ6Q4SiQzeOk2hM5/F5W179g0PbKcJxgJw o4vZkF4lXZKZSdLFDttAYe4TqmfkyXW1x9qtkzfjOgh6ubSTXRyFBzZIgXh99JWyShit bWvvbrT8CT+1fa+HfiBWALfuooUFBOqv/14YP3pka3BKgHTwBUYk5ow5gM77AKLUpmWE zQtw4RNkT9LLoLx61/FtYZCY4BgSSQldjrQV90H0UbbypPREhGnQRjYJVNoVYTm0Gbb/ Y7IfSRAdNT7deSXzgHjsBh4K1JEGH5SKNfoF3kg4ueL6W2xh1mvzje8K7ki9vr4vVvlZ LuDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dmarc-filter:sender:dkim-signature; bh=TllKEW0btc/5B/OVbNlObTA7MdLt/HYXiwco3XZVI6A=; b=KEdr3sg5I3oPnwyRnoJ7nsapLBs4J0aqSsX4ofISLLyUaadjrt6kJNdBWEn4enQR68 Pp8MJveLndha/hAGfqgo4Dq3V1X+JHBYQYggrjFNgLZNly+vX+mcK7mBv0iYJ2uVvQqQ Fyks4nSegEHhMcPW1x4fxGu8R9w1eQybvFPazGTAspmrisTu0dobV6MbfORQEEqZN6Me /R2EJXJhU5w5Jsm1wxM41tMQhJZ8vk2on3zc2R37HQPAljXeRkB3ynuB4rHBiWlgzNPQ bkVAfslduB4GcYuWhCbgRAbeJ20qfHm+cSD4bAzkwgd0PwoOlT5UU46cKgCTnR9CPnyF 5rbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=EXPaiEzT; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw22si14604680ejc.184.2021.11.02.02.43.57; Tue, 02 Nov 2021 02:44:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=EXPaiEzT; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbhKBJpP (ORCPT + 99 others); Tue, 2 Nov 2021 05:45:15 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:57924 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbhKBJpO (ORCPT ); Tue, 2 Nov 2021 05:45:14 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1635846160; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=TllKEW0btc/5B/OVbNlObTA7MdLt/HYXiwco3XZVI6A=; b=EXPaiEzTmZxAFSWgtY6YA1/3FnfVthlEf04tgV1DnSB5CHRGGS1CHMNiGGWQEZFjPcdpqz5Y ZHnwsBoVuqELbTWwGvGNdUU4XFtv4umZBuj9pnv6uUGyJnM90aaD5sxK7oblbCHhWB4yae1S dFbLPQn893frvZ3X0jizkP2N5bU= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI2MTA3ZSIsICJsaW51eC1ibHVldG9vdGhAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n02.prod.us-east-1.postgun.com with SMTP id 618108082e144ac4d3b8bfb6 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 02 Nov 2021 09:42:32 GMT Sender: zijuhu=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 9064AC43617; Tue, 2 Nov 2021 09:42:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from [192.168.0.104] (unknown [183.195.15.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: zijuhu) by smtp.codeaurora.org (Postfix) with ESMTPSA id 0827FC4338F; Tue, 2 Nov 2021 09:42:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org 0827FC4338F Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=codeaurora.org Subject: Re: [PATCH v1 3/3] Bluetooth: hci_qca: Add support for QTI bluetooth MAPLE To: Marcel Holtmann Cc: Greg KH , Johan Hedberg , Linux Kernel Mailing List , linux-bluetooth , MSM , Balakrishna Godavarthi , c-hbandi@codeaurora.org, Hemantg , Matthias Kaehlcke , Rocky Liao , Zijun Hu References: <1635837177-1341-1-git-send-email-zijuhu@codeaurora.org> <4f6aee28-4d86-116c-6c47-bfce5de6551b@codeaurora.org> <432B905E-5263-47A6-95AA-7F43715BE196@holtmann.org> <18e1cb9d-39e5-3953-6f32-faea6b2dee47@codeaurora.org> <24F36C9D-6219-4A0B-A798-029ED4EEAB06@holtmann.org> From: Zijun Hu Message-ID: <250a87bd-2012-201f-8f53-a229cc641c15@codeaurora.org> Date: Tue, 2 Nov 2021 17:42:24 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <24F36C9D-6219-4A0B-A798-029ED4EEAB06@holtmann.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On 11/2/2021 5:22 PM, Marcel Holtmann wrote: > Hi Zijun, > >>>>>>> Add support for MAPLE integrated within SOC, it is mounted on >>>>>>> a virtual tty port and powered on/off via relevant IOCTL, neither >>>>>>> IBS nor RAMPATCH downloading is not required. >>>>>>> >>>>>>> Signed-off-by: Zijun Hu >>>>>>> --- >>>>>>> drivers/bluetooth/btqca.c | 13 ++++++++++++- >>>>>>> drivers/bluetooth/btqca.h | 13 +++++++++++++ >>>>>>> drivers/bluetooth/hci_qca.c | 47 ++++++++++++++++++++++++++++++++++++++++++++- >>>>>>> 3 files changed, 71 insertions(+), 2 deletions(-) >>>>>>> >>>>>>> diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c >>>>>>> index be04d74037d2..b83d2ecefe5d 100644 >>>>>>> --- a/drivers/bluetooth/btqca.c >>>>>>> +++ b/drivers/bluetooth/btqca.c >>>>>>> @@ -255,6 +255,8 @@ static void qca_tlv_check_data(struct hci_dev *hdev, >>>>>>> BT_DBG("TLV Type\t\t : 0x%x", type_len & 0x000000ff); >>>>>>> BT_DBG("Length\t\t : %d bytes", length); >>>>>>> >>>>>>> + if (qca_is_maple(soc_type)) >>>>>>> + break; >>>>>>> idx = 0; >>>>>>> data = tlv->data; >>>>>>> while (idx < length) { >>>>>>> @@ -552,6 +554,9 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, >>>>>>> rom_ver = ((soc_ver & 0x00000f00) >> 0x04) | (soc_ver & 0x0000000f); >>>>>>> >>>>>>> /* Download rampatch file */ >>>>>>> + if (qca_is_maple(soc_type)) >>>>>>> + goto download_nvm; >>>>>>> + >>>>>>> config.type = TLV_TYPE_PATCH; >>>>>>> if (qca_is_wcn399x(soc_type)) { >>>>>>> snprintf(config.fwname, sizeof(config.fwname), >>>>>>> @@ -580,6 +585,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, >>>>>>> /* Give the controller some time to get ready to receive the NVM */ >>>>>>> msleep(10); >>>>>>> >>>>>>> +download_nvm: >>>>>>> /* Download NVM configuration */ >>>>>>> config.type = TLV_TYPE_NVM; >>>>>>> if (firmware_name) >>>>>>> @@ -597,6 +603,9 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, >>>>>>> else if (soc_type == QCA_QCA6390) >>>>>>> snprintf(config.fwname, sizeof(config.fwname), >>>>>>> "qca/htnv%02x.bin", rom_ver); >>>>>>> + else if (qca_is_maple(soc_type)) >>>>>>> + snprintf(config.fwname, sizeof(config.fwname), >>>>>>> + "qca/mpnv%02x.bin", rom_ver); >>>>>>> else if (soc_type == QCA_WCN6750) >>>>>>> snprintf(config.fwname, sizeof(config.fwname), >>>>>>> "qca/msnv%02x.bin", rom_ver); >>>>>>> @@ -609,6 +618,8 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, >>>>>>> bt_dev_err(hdev, "QCA Failed to download NVM (%d)", err); >>>>>>> return err; >>>>>>> } >>>>>>> + if (qca_is_maple(soc_type)) >>>>>>> + msleep(MAPLE_NVM_READY_DELAY_MS); >>>>>>> >>>>>>> if (soc_type >= QCA_WCN3991) { >>>>>>> err = qca_disable_soc_logging(hdev); >>>>>>> @@ -637,7 +648,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, >>>>>>> return err; >>>>>>> } >>>>>>> >>>>>>> - if (soc_type == QCA_WCN3991 || soc_type == QCA_WCN6750) { >>>>>>> + if (soc_type == QCA_WCN3991 || soc_type == QCA_WCN6750 || qca_is_maple(soc_type)) { >>>>>>> /* get fw build info */ >>>>>>> err = qca_read_fw_build_info(hdev); >>>>>>> if (err < 0) >>>>>>> diff --git a/drivers/bluetooth/btqca.h b/drivers/bluetooth/btqca.h >>>>>>> index 30afa7703afd..0a5a7d1daa71 100644 >>>>>>> --- a/drivers/bluetooth/btqca.h >>>>>>> +++ b/drivers/bluetooth/btqca.h >>>>>>> @@ -46,6 +46,8 @@ >>>>>>> >>>>>>> #define QCA_FW_BUILD_VER_LEN 255 >>>>>>> >>>>>>> +#define MAPLE_NVM_READY_DELAY_MS 1500 >>>>>>> +#define MAPLE_POWER_CONTROL_DELAY_MS 50 >>>>>>> >>>>>>> enum qca_baudrate { >>>>>>> QCA_BAUDRATE_115200 = 0, >>>>>>> @@ -145,6 +147,7 @@ enum qca_btsoc_type { >>>>>>> QCA_WCN3991, >>>>>>> QCA_QCA6390, >>>>>>> QCA_WCN6750, >>>>>>> + QCA_MAPLE, >>>>>>> }; >>>>>>> >>>>>>> #if IS_ENABLED(CONFIG_BT_QCA) >>>>>>> @@ -167,6 +170,11 @@ static inline bool qca_is_wcn6750(enum qca_btsoc_type soc_type) >>>>>>> return soc_type == QCA_WCN6750; >>>>>>> } >>>>>>> >>>>>>> +static inline bool qca_is_maple(enum qca_btsoc_type soc_type) >>>>>>> +{ >>>>>>> + return soc_type == QCA_MAPLE; >>>>>>> +} >>>>>>> + >>>>>>> #else >>>>>>> >>>>>>> static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) >>>>>>> @@ -204,6 +212,11 @@ static inline bool qca_is_wcn6750(enum qca_btsoc_type soc_type) >>>>>>> return false; >>>>>>> } >>>>>>> >>>>>>> +static inline bool qca_is_maple(enum qca_btsoc_type soc_type) >>>>>>> +{ >>>>>>> + return false; >>>>>>> +} >>>>>>> + >>>>>>> static inline int qca_send_pre_shutdown_cmd(struct hci_dev *hdev) >>>>>>> { >>>>>>> return -EOPNOTSUPP; >>>>>>> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c >>>>>>> index dd768a8ed7cb..f1d9670719c4 100644 >>>>>>> --- a/drivers/bluetooth/hci_qca.c >>>>>>> +++ b/drivers/bluetooth/hci_qca.c >>>>>>> @@ -70,6 +70,10 @@ >>>>>>> #define QCA_CRASHBYTE_PACKET_LEN 1096 >>>>>>> #define QCA_MEMDUMP_BYTE 0xFB >>>>>>> >>>>>>> +#ifndef IOCTL_IPC_BOOT >>>>>>> +#define IOCTL_IPC_BOOT 0xBE >>>>>>> +#endif >>>>>> >>>>>> You send this command, but never use it. Where is the driver code that >>>>>> uses this command? >>>>>> >>>>> qca_maple_power_control() will use it. this driver depends on bt_tty kernel module >>>>> https://source.codeaurora.org/quic/qsdk/oss/kernel/linux-ipq-5.4/tree/drivers/soc/qcom/bt_tty.c?h=NHSS.QSDK.11.5.0.5.r2 >>>> >>>> You can not add code to the kernel that is not used by the kernel >>>> itself. That driver needs to be in the tree as well, why is it not >>>> submitted now too? >>>> >>>>>> And why not tabs? >>>>>> >>>>>> And why is this patch series not properly threaded so tools can pick it >>>>>> up and find them? >>>>>> >>>>>> And why the odd named ioctl that is different from other ones in this >>>>>> file? >>>>>> >>>>> that IOCTL name is defined by that module. >>>>> https://source.codeaurora.org/quic/qsdk/oss/kernel/linux-ipq-5.4/tree/include/linux/bt.h?h=NHSS.QSDK.11.5.0.5.r2 >>>> >>>> Again, it needs to be in the tree. >>>> >>>>>> And why not just use normal power management hooks for doing things like >>>>>> turning on and off the hardware like all other drivers? >>>>>> >>>>> this device is special. >>>> >>>> All drivers and devices are special and unique. Just like all of them :) >>>> >>>> What is so odd about this device that it can not work with the existing >>>> infrastructure that the kernel has for all of the hundreds of thousands >>>> of other devices it supports? >>>> >>>>> it seems BT maintainer decides to drop this patch. >>>> >>>> Of course, at the very least because there is no in-kernel user, why >>>> would you accept such a patch if you were the maintainer? >>>> >>>> Please submit your driver first. >>> >>> this power on via ioctl is nasty business. I am so happy that we got rid of >>> the crucks when we finally landed serdev. >>> >>> Some people are working on power sequence support and alike. This needs to >>> use proper infrastructure or extend existing infrastructure. To fit the >>> needs. >>> >>> I am just 100% certain, that booting an IPC via an ioctl isn’t it. We >>> really suffered through it in the 2.4 kernel days. The hardware needs to >>> be described properly in device tree and the kernel needs to take all >>> the appropriate actions if a Bluetooth device is powered on via its >>> standard power on procedure. And that is through bluetoothd (or if you >>> use some other Bluetooth userspace) via the exposed API from the kernel. >>> >> thank you. the IOCTL purpose is to bootup the special bluetooth controller. >> i have verified this change. >> i will submit this change to linux-ipq-5.4 firstly even if need to pick up many changes firstly. > > I am not sure this is fully understood yet. Do _not_ use an ioctl to boot the Bluetooth > controller. Power on/off of Bluetooth hardware happens via the standard interface used > by bluetoothd. The Bluetooth transport driver (in your case hci_qca) has to do everything > needed when a) serdev->probe is called and b) hdev->open is called. Any other path to > power your hardware is (bluntly put) wrong. > for all the other present controllers supported by hci_qca, ALL the finial initialization job is Done driver itself(hci_qca) via hdev->setup which call qca_setup(), the initialization includes power control, clock control, driver BT enable pin, download F/W. > Regards > > Marcel >