Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp870243imm; Wed, 8 Aug 2018 07:08:18 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzMdTqyBMHtunIyxXy0LcFdhyi+nsev9Dvb+X7hHBpm04C8FQZsxjZ+1S1fJfUAVR3UV2tH X-Received: by 2002:a17:902:4401:: with SMTP id k1-v6mr2722084pld.97.1533737298479; Wed, 08 Aug 2018 07:08:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533737298; cv=none; d=google.com; s=arc-20160816; b=kluPlzZviysKcRiIIpdNRORitS0Syz62j+MteaIfOX1sRlMmEB2ATDESUTB6m3UY/s YXDnFE7c/nLdGGrEc6fBEl+sz327euVR7QRtPIhruK+vdQYZY49+kj9uBiMcINqRVFOr +oW/dr2MwO8p/SjTo6fRCvMqHoBFvGI2hu3zYUAZCTiG8f5ijvWZHHFM95VdoHg6DWoO 13DgboHL1wZDFZbQKT8ayfV9EWKN0d/ohkRwt0Q+kECRl1YQacORN8arOgkWYi5M4fK5 yyY4EcLY85GCqYtOPV4iphQrjltymt953yyxLOb2Q2cGlen+M89EgxWpW4jmodvHt8mH 1tsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:arc-authentication-results; bh=apePj/VczNY/hhCHcCLsqDiYQF48Bk1ZsJQquyrwurM=; b=Y2H2FZnSFEV9FYvkcBCOilJezKGz+dgkb1K5IAhghiIonxHS5gfKuqpQ+CpAjy8xPx +gfeJq+XjMPC92mIHpI/867uU6JfGZZ6TxrWka8iw/rpOC4gaSPE7VNbE7eMb/FoqVsi pFMKJVjXQlRKfUDzn/jxe0NBmBzDE8TgSAX/nyBMaM6RsRZtKmJFnNRqsyTWUe/AGvG3 68cRehuCySdixqvma4B3X+T0tHjAVK39w1hfGtRB6i65r7bImjSQxWB9s5IStcsiRkIy YwvTbJLv17JXSrjdcmQacA/yTNClLKeD9lAIfsrKnU0jRy9uQRBd/jap7GWhdh120M0S Yxbg== ARC-Authentication-Results: i=1; mx.google.com; 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 s2-v6si3453775pgc.447.2018.08.08.07.08.03; Wed, 08 Aug 2018 07:08:18 -0700 (PDT) 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; 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 S1727316AbeHHQ1C convert rfc822-to-8bit (ORCPT + 99 others); Wed, 8 Aug 2018 12:27:02 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:48799 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726971AbeHHQ1C (ORCPT ); Wed, 8 Aug 2018 12:27:02 -0400 Received: from marcel-macpro.fritz.box (p4FEFCC41.dip0.t-ipconnect.de [79.239.204.65]) by mail.holtmann.org (Postfix) with ESMTPSA id E1EC1CF2B8; Wed, 8 Aug 2018 16:14:10 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: [PATCH v7 2/3] Bluetooth: mediatek: Add protocol support for MediaTek serial devices From: Marcel Holtmann In-Reply-To: <1533715447.3472.251.camel@mtkswgap22> Date: Wed, 8 Aug 2018 16:07:08 +0200 Cc: Mark Rutland , devicetree , Johan Hedberg , Linux Kernel Mailing List , "open list:BLUETOOTH DRIVERS" , Rob Herring , linux-mediatek@lists.infradead.org, linux-arm-kernel Content-Transfer-Encoding: 8BIT Message-Id: <78F5F65C-F155-473A-BC94-809683FB9BDA@holtmann.org> References: <1707FFA1-A294-4A95-A3BF-0910CE455232@holtmann.org> <1533192799.3472.122.camel@mtkswgap22> <1533199720.3472.136.camel@mtkswgap22> <9526E5D9-50BA-4D57-80F5-083DB7D28AFE@holtmann.org> <1533205495.3472.144.camel@mtkswgap22> <1533303749.3472.160.camel@mtkswgap22> <1533319214.3472.187.camel@mtkswgap22> <7A3537C5-5940-45AD-AB80-77418CCFE130@holtmann.org> <1533652445.3472.230.camel@mtkswgap22> <8AF72CFC-4978-42AD-8ECC-752EB137DD2A@holtmann.org> <1533715447.3472.251.camel@mtkswgap22> To: Sean Wang X-Mailer: Apple Mail (2.3445.9.1) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sean, >>>>>> this is even more hackish since the __hci_cmd_sync_ev command is really meant to get a cmd status first before waiting for that event. >>>>>> >>>>> >>>>> Understood. >>>>> >>>>> I've stopped the hack in v8. could we merge v8 first ? and then I will a fix up with __hci_raw_sync_ev that uses the hdev->raw_q instead of __hci_cmd_sync_ev in TODO. >>>> >>>> so I looked into this a bit more. We actually added __hci_cmd_send for a Qualcomm firmware loader that was doing something similar. So instead of trying to add a yet another command to the core, I actually used that and implemented the wait for vendor event in the driver. >>>> >>>> You will see my v9 on the mailing list. I also did a bunch of cosmetic minor cleanup and spelling correction. Please test this version. I also make __le16 dlen instead of dlen1 + dlen2 since I think that is what your hardware does. >>> >>> Only one thing needs to be corrected in v9. that is __be16 is required instead of dlen1 + dlen2. I will fix it up in v10 and the other changes all look good to me. >>> >>>> If this version of the driver works for you then I am happy to merge it. You can then add support for hdev->set_bdaddr and hdev->set_diag in later patches. I also like to clean up the STP receive handler since it can be done a lot simpler and smaller, but that has to wait. >>>> >>> >>> hopefully v10 also can be merged :) >> >> send me a v10 and I can merge it. >> >>> I will investigate more about how to add ->set_bdaddr, ->set_diag and STP receive enhancement in later patches. >>> >>> but so far I have not much idea about how to make STP multiplexer be a independent driver. >>> >>> my thought is that it would be really better and cleaner a chain of serdev is be used as the base of mtkbtuart. something like >>> >>> 8250 serial bus <----> STP multiplexer serdev <----> mtkbtuart serdev >>> >>> however, STP multiplexer serdev is not a real device, that doesn't no request any resource. I think it should not be allowed to be added in a device tree and even in dt-binding document. >> >> Before we do that, lets get a cleaner parser for it. I just don’t have enough time to wrap my head around this one yet. >> >>>>>> Are all Mediatek vendor commands this way? Or just the ones for loading the firmware? So only the WMT ones? >>>>>> >>>>> >>>>> Only the WMT ones, WMT commands/events are usually used in system controlling, for example, global function on/off, firmware download, reset and so on. most only appear on device initialization >>>> >>>> Since you never checked the result of the vendor event, I opted for just signaling that it arrived. If they can report success or failure, we need to add some extra code for that. >>>> >>> >>> I will consider more WMT event status when I add more Bluetooth devices such as MT7668U usb based Bluetooth which I plan to add the support in later patches in the next weeks >> >> Are the USB ones also using STP or are they H:2 based like all the others. What are prominent MT7668U based ones that I could buy? >> > 1. > USB ones don't use any STP framing, which is totally dedicated to the > serial based device. > > I don't exactly know what the term H:2 means you mentioned here. I only > know the btusb driver can be reused for M7668U and just only one weird > thing to solve in btusb driver. That is HCI WMT event coming through > control in pipe, not through interrupt pipe :( > > And as for the others generic hci/acl/sco data, they all work well as > btusb usually work. I will show you the code to let you exactly know > what I'm meaning instead of just talking :) Bluetooth USB transport was originally section H:2 in the specification (and UART was section H:4) that is where this naming comes wrong. The btusb.c driver is implementing H:2 transport. How does /sys/kernel/debug/usb/devices look for these devices? And I don’t recall that there is a control in pipe. That concept doesn’t really exist in USB. > 2. > Another thing is I think it's better if the core layer can support > __hci_raw_sync_ev-like APIs to allow each transport driver not to care > the details about cmd/event synchronization. If it can be done in this > way, that helps to help WMT cmd/event handling can be put into a > commonplace to allow btmtkuart and btusb for mtk port to have the same > codeshare. Such a core API will not help you. The btusb.c driver has already bunch of examples where it has to fix up things. Qualcomm/Atheros have done there fun way of firmware download and Intel also has done fun stuff with event over bulk endpoints. > 3. > MT7668U should always be bundled with CE product, I am not really sure > whether it is easy to get from the retailer. Or you really like to want > a sample, maybe I can try to contact with internal people to make it > happen. If it is some NGFF mPCI card that I can plug into an adapter card and attach it to USB, or if you have some dev board, that would be interesting. Regards Marcel