Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1779034ybg; Sat, 19 Oct 2019 02:19:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaVu9y2RMk9Ap3lJQL/Fls/YXetHgPjirgrmXlrKtFNwA4Z6jwiVuNkbVQa4nRBwZog9fa X-Received: by 2002:a05:6402:1547:: with SMTP id p7mr2983289edx.28.1571476777467; Sat, 19 Oct 2019 02:19:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571476777; cv=none; d=google.com; s=arc-20160816; b=yNC/XXYR2HMurkHj7soesqMa2VV3B//Su6885b4mtMwivSCbNGt4qJ3BfbdnP8PKSW bTzgTi7hZ2oie4hBppJHWiizt+r3cCXBQJoSIVyh/seISDv2A5Ufjo6AKDgrmNNGELIp NyJ5UxYl4yAuJHVcJmmi8Gu3Bfji+nwxHGN+ikcsNeZMQqPv81CYS9U7wgq+r58BS3YZ /N0mCzxx/eZCUN93DdX0ypvKXaKskTnUCZN9NRHHuYpS+/7Pv2si1YH4/xVgEltyIE44 POb3F30zed5MwKGv9/6cSCtH5QWwGXS7xpZacSSBmgPG+4h7sResOJ9uVVlPFxK8geVk mSxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=NmcUecAGXuSApRjNtgEf0ETg8ugP5bkJRtiayEQOKqA=; b=pnbTkJgtEtELLKpkAcbbwgnpYA9LbWtRjC3gX2KZwqOV1VflY3ThPP9kC30e0ap5WT NbIKo1Vx7n7ROSBZp2ZuFMihFKm0Hblm4+jSlpd8QfariBK1yQ2Utvl2Fbys1kb+13+q o1o4aVURIipwXwtdZIPSDXZsS0LX8vnuoZyow6RYyMnIFmBRN2a6ceHUUX0Jd8JJaBHj McS+u2Ai/gZZaDlfGVTbYz9ZtWO43cHliMep/ZuXr1ASroaXQEAhkelVpH9qJiUnR09T Of3dHTsZQTcxxjYg0SsM+9hXn7MwHV4GTl1gLpNKKZ3HGXHnEYUdFYC5ly8QFmT/xiv2 Zr+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Av2WRpxY; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n19si5022685edo.172.2019.10.19.02.19.11; Sat, 19 Oct 2019 02:19:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-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=@chromium.org header.s=google header.b=Av2WRpxY; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2506161AbfJRVd7 (ORCPT + 99 others); Fri, 18 Oct 2019 17:33:59 -0400 Received: from mail-pg1-f177.google.com ([209.85.215.177]:39579 "EHLO mail-pg1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2506142AbfJRVd7 (ORCPT ); Fri, 18 Oct 2019 17:33:59 -0400 Received: by mail-pg1-f177.google.com with SMTP id p12so4039907pgn.6 for ; Fri, 18 Oct 2019 14:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=NmcUecAGXuSApRjNtgEf0ETg8ugP5bkJRtiayEQOKqA=; b=Av2WRpxYgSpf7TYLUsuUGfnXAcPeN7re/m6If3FYxqB2lfkQRVhu0Tc/kVAp3WKxbM tLfjhVtLrtxb+mzef1nXTPDl1OgyoZAZsUhSh8HmY1TzHcQSRIzRiGKZzNQESk7KdST9 BGMRUD8iKjI7UUa0Q7eK7REzuRZUMI0LeMiXo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=NmcUecAGXuSApRjNtgEf0ETg8ugP5bkJRtiayEQOKqA=; b=M5QxUIb9aKIT1V4HYhdxjeMx67lAC4I+fo/Mvz1ymjOOFohcv1bj6lo5f9h7KPSL8e jyblgroeNst5i4Pc3LLzoRmYshqrbqjWw7N5HTc6srTFpCoOYo6ttDTVVQpdqQpTteFN 8o/xR7xSGgMNGAvxZQgmumx4rw06Y3KIhEZBpLKeR9JE3uLFrKkzdLipuhH3AlVA17r8 RLzwKGEH6ebyLwrA5MnY1QTyQHbciIKsFzJKmC70SEKKKFHh0hflclDy2jsXwGVuATrh /M+etcsRabDQXWBXXV9tZUkMQRqg0/v3uU94Jbg/FIxbanNBHalRVe8k1RmK0ogzkv92 rXZg== X-Gm-Message-State: APjAAAXhwm58oAaKb8tkOXfPt6hFfdZJQzWPfuXpgg1GVpKY0NYiPk75 C1Dgy4+MD9h3PZpoC1hXGrD2+gXVpoc= X-Received: by 2002:a63:f923:: with SMTP id h35mr12598461pgi.323.1571434436872; Fri, 18 Oct 2019 14:33:56 -0700 (PDT) Received: from localhost ([2620:15c:202:1:4fff:7a6b:a335:8fde]) by smtp.gmail.com with ESMTPSA id x10sm6547446pgl.53.2019.10.18.14.33.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Oct 2019 14:33:56 -0700 (PDT) Date: Fri, 18 Oct 2019 14:33:54 -0700 From: Matthias Kaehlcke To: Jeffrey Hugo Cc: marcel@holtmann.org, johan.hedberg@gmail.com, c-hbandi@codeaurora.org, bgodavar@codeaurora.org, linux-bluetooth@vger.kernel.org, MSM , lkml Subject: Re: [PATCH] Bluetooth: hci_qca: Add delay for wcn3990 stability Message-ID: <20191018213354.GC20212@google.com> References: <20191017212955.6266-1-jeffrey.l.hugo@gmail.com> <20191018180339.GQ87296@google.com> <20191018194039.GB20212@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On Fri, Oct 18, 2019 at 01:51:39PM -0600, Jeffrey Hugo wrote: > On Fri, Oct 18, 2019 at 1:40 PM Matthias Kaehlcke wrote: > > > > On Fri, Oct 18, 2019 at 12:30:09PM -0600, Jeffrey Hugo wrote: > > > On Fri, Oct 18, 2019 at 12:03 PM Matthias Kaehlcke wrote: > > > > > > > > On Thu, Oct 17, 2019 at 02:29:55PM -0700, Jeffrey Hugo wrote: > > > > > On the msm8998 mtp, the response to the baudrate change command is never > > > > > received. On the Lenovo Miix 630, the response to the baudrate change > > > > > command is corrupted - "Frame reassembly failed (-84)". > > > > > > > > > > Adding a 50ms delay before re-enabling flow to receive the baudrate change > > > > > command response from the wcn3990 addesses both issues, and allows > > > > > bluetooth to become functional. > > > > > > > > From my earlier debugging on sdm845 I don't think this is what happens. > > > > The problem is that the wcn3990 sends the response to the baudrate change > > > > command using the new baudrate, while the UART on the SoC still operates > > > > with the prior speed (for details see 2faa3f15fa2f ("Bluetooth: hci_qca: > > > > wcn3990: Drop baudrate change vendor event")) > > > > > > > > IIRC the 50ms delay causes the HCI core to discard the received data, > > > > which is why the "Frame reassembly failed" message disappears, not > > > > because the response was received. In theory commit 78e8fa2972e5 > > > > ("Bluetooth: hci_qca: Deassert RTS while baudrate change command") > > > > should have fixed those messages, do you know if CTS/RTS are connected > > > > on the Bluetooth UART of the Lenovo Miix 630? > > > > > > I was testing with 5.4-rc1 which contains the indicated RTS fix. > > > > > > Yes, CTS/RTS are connected on the Lenovo Miix 630. > > > > > > I added debug statements which indicated that data was received, > > > however it was corrupt, and the packet type did not match what was > > > expected, hence the frame reassembly errors. > > > > Do you know if any data is received during the delay? In theory that > > shouldn't be the case since RTS is deasserted, just double-checking. > > I don't think so, but I've run so many tests, I'm not 100% positive. > Let me go double check and get back to you. > > > > > What happens if you add a longer delay (e.g. 1s) before/after setting > > the host baudrate? > > Hmm, not exactly sure. I will test. > > > > > > In response to this patch, Balakrishna pointed me to a bug report > > > which indicated that some of the UART GPIO lines need to have a bias > > > applied to prevent errant data from floating lines - > > > > > > https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1391888 > > > > Yeah, that was another source of frame reassembly errors that we were > > seeing on SDM845. > > > > Balakrishna, please post these kind of replies on-list, so that > > everybody can benefit from possible solutions or contribute to the > > discussion. > > > > > It turns out this fix was never applied to msm8998. Applying the fix > > > does cause the the frame reassembly errors to go away, however then > > > the host SoC never receives the baud rate change response (I increased > > > the timeout from 2faa3f15fa2f ("Bluetooth: hci_qca: wcn3990: Drop > > > baudrate change vendor event") to 5 seconds). As of now, this patch > > > is still required. > > > > Interesting. > > > > FTR, this is the full UART pin configuration for cheza (SDM845): > > > > &qup_uart6_default { > > /* Change pinmux to all 4 pins since CTS and RTS are connected */ > > pinmux { > > pins = "gpio45", "gpio46", > > "gpio47", "gpio48"; > > }; > > > > pinconf-cts { > > /* > > * Configure a pull-down on 45 (CTS) to match the pull of > > * the Bluetooth module. > > */ > > pins = "gpio45"; > > bias-pull-down; > > }; > > > > pinconf-rts-tx { > > /* We'll drive 46 (RTS) and 47 (TX), so no pull */ > > pins = "gpio46", "gpio47"; > > drive-strength = <2>; > > bias-disable; > > }; > > > > pinconf-rx { > > /* > > * Configure a pull-up on 48 (RX). This is needed to avoid > > * garbage data when the TX pin of the Bluetooth module is > > * in tri-state (module powered off or not driving the > > * signal yet). > > */ > > pins = "gpio48"; > > bias-pull-up; > > }; > > }; > > > > Does this correspond to what you tried on the Lenovo Miix 630? > > Which GPIO maps to which pin is different - > 45 - TX > 46 - RX > 47 - CTS > 48 - RFR (RTS) > > However, accounting for that, yes that corresponds to what I used. Thanks for re-confirming. > > > I have no idea why the delay is required, and was hoping that posting > > > this patch would result in someone else providing some missing pieces > > > to determine the real root cause. I suspect that asserting RTS at the > > > wrong time may cause an issue for the wcn3990, but I have no data nor > > > documentation to support this guess. I welcome any further insights > > > you may have. > > > > Unfortunately I don't have a clear suggestion at this point, debugging > > the original problem which lead to 2faa3f15fa2f ("Bluetooth: hci_qca: > > wcn3990: Drop baudrate change vendor event") involved quite some time > > and hooking up a scope/logic analyzer ... > > > > I also suspect RTS is involved, and potentially the configuration of > > the pulls. It might be interesting to analyze the data that leads to > > the frame assembly error and determine if it is just noise (wrong > > pulls/drive strength?) or received with a non-matching baud-rate. > > I don't have a scope/logic analyzer, but since I hooked up the > blsp_bam I'm able to see the raw data from the uart before it gets to > the HCI stack or anything. As a side note, having the bam or not > seemed to have no effect on the issue. It's not exactly the same though. I suppose with the blsp_bam you only see the actual data when the UART runs at the same speed as it's counterpart. With a logic analyzer you can change the speed after data capture, which might convert apparent garbage into reasonable data. > Most of the time the data was one byte (zero), some times it was a > string of zero bytes. Rarely it would be random data. In terms of data ss there difference between a string of zero bytes and a single zero byte? From my notes the response (vendor event) to a baudrate change command on the WCN3990 is: 04 0e 04 01 00 00 00 The tail *might* be the zero(s) you are seeing, and the first part gets lost for some reason? A simplified version of the code in question: set_RTS(false) hci_set_baudrate(br) host_set_baudrate(br) msleep(50); // why is this needed??? set_RTS(true) // supposedly wcn3990 now sends vendor event using the new baudrate wait_for_vendor_event() // ok with msleep, otherwise frame reassembly error Maybe the MSM8998 UART (driver) currently needs the delay to fully switch to the new baudrate? Perhaps the pinconfig still needs tweaking of some kind? You said when you apply the full configuration used on cheza you don't receive the response to the baudrate change command. Does it work when you only configure the pull-up on the RX (host) pin?