Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6748235ybl; Wed, 15 Jan 2020 09:33:45 -0800 (PST) X-Google-Smtp-Source: APXvYqw6R5rt76LYbSyuY0wzxK+thIkbLoSFq0KSoWrelsTRLHlqAqMaGQACosVvzt5Rrn4oc3mc X-Received: by 2002:aca:5487:: with SMTP id i129mr678140oib.167.1579109625664; Wed, 15 Jan 2020 09:33:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579109625; cv=none; d=google.com; s=arc-20160816; b=iKZlgKd2yzTfxsAUPmZJ6oVcS6d3YuPfHWqDNSr9PV7hXUsElqh31ZYLEyDyVMNLmD WUv0DnD5chn1XY5AhKy0UFk5TfG6Yju2EmbLKfj6j6ITPB7izA62jr672GjBz/BSo2NX 9Y0TzB+27zxKBC6KPXefEee1+qK6CQ+3GnZjfiBc4loMqSphayY8Ei0apEe6FXG1FaAT SvJ6wHXf0lbBLICnn5j1VtXPG9ccBIbd5D1GM4DAvBg91BGYwaIH4lfkKDDPf/i6gHic wSh60zxhnj+D6S2uAwzW++e2T420zwM81urCs5izKz7VVNS2wGnV0JkoAVIexY1mKb/+ wmeA== 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=wSehoxvwgPJ3qRcy4KOjaQ2g1YFkKXYLIvCDj5Tb0pc=; b=0FgeWBO7reQcP66OrfSZCk9bRFhi6UVRptUavUQFLsvaxClrTJrMrA0+7G/IUcZb0I 6XGthlAZsgZBh/OBexZIwQifc6dmo9DOgU0l+++CTKfX6GhuxNgMyAHqwdbvNnYMjfJ6 qG37B3Gmhb8G9l37tewQ4M8OeCM1DLKUlzmXU7yd/SI5SwbnyDEokKFgV/gLVt5ZHdz4 JzViVKLPSj30X8zZLRx3LKXY5Oj84mhIoZtI12k9eCebRMljjgabQTohyS7wSar0LzzS J0saS5yUBluL8FBkuATpxarzhzKh2koMQqpwaVP+jP2Nm2GF93wZJ7r/n+dxEOZK/rz8 Y6Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hJrBS8oG; 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 k10si12922770otf.237.2020.01.15.09.33.32; Wed, 15 Jan 2020 09:33:45 -0800 (PST) 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=hJrBS8oG; 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 S1729010AbgAORdS (ORCPT + 99 others); Wed, 15 Jan 2020 12:33:18 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:51836 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728992AbgAORdS (ORCPT ); Wed, 15 Jan 2020 12:33:18 -0500 Received: by mail-pj1-f68.google.com with SMTP id d15so234764pjw.1 for ; Wed, 15 Jan 2020 09:33:17 -0800 (PST) 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=wSehoxvwgPJ3qRcy4KOjaQ2g1YFkKXYLIvCDj5Tb0pc=; b=hJrBS8oGKaygMrG8r9UuJikZzYcublFntoivenmN00d1aDSkXeIVb8yvmE2J9kIOdp r6eEUQoeIUJ/9Amzhc3zgwwyx6+n0gGKyxx1rfr16BHudcW9/d3f+ZXApQaArzn8G0SD UpdrZ8d9SefG5vShZAVKNKTNsVVbeFeNpFSG8= 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=wSehoxvwgPJ3qRcy4KOjaQ2g1YFkKXYLIvCDj5Tb0pc=; b=ZWvFP2ehoy9lb99NB0a2YJxvooRvCMG3x1epo8TCebcGZkeCLhQ0DS3sSFg9SzNnBL FwDbMJO9N9+smCV1c9Xbq5smrgyCHS6GHZezIMAzqJsJzzRns/N4H9BIljL3Oy8XOJcm KtsJs9oxNOS3zcbb9GAt7F95MCwM2ThUpNzG2ytzebZPaGLNKcREqTFvbWwrfw9dPtwD oI+gmSuk6BYCrrEP6U96hS35eqFgYODj5YB/rvnXRr3QxI5X6n2G1M0bUI9MidnnmVIp OHhcwDR35l/XLhcTsmBPoPyqKyisLyYvTM4g+8HxliLcVyiImfq/fBvfWBI59rrR6ul1 d2iw== X-Gm-Message-State: APjAAAWCUTDOnxyQzwjcl44dHu1xr4Xo77Onm4TVGB0YjyUfwS81ro4V /cQhTN0inA2FSFmnT1ostUQWPE4mhqQ= X-Received: by 2002:a17:902:ab91:: with SMTP id f17mr33113263plr.172.1579109597426; Wed, 15 Jan 2020 09:33:17 -0800 (PST) Received: from localhost ([2620:15c:202:1:4fff:7a6b:a335:8fde]) by smtp.gmail.com with ESMTPSA id f43sm402960pje.23.2020.01.15.09.33.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Jan 2020 09:33:16 -0800 (PST) Date: Wed, 15 Jan 2020 09:33:15 -0800 From: Matthias Kaehlcke To: Rocky Liao Cc: marcel@holtmann.org, johan.hedberg@gmail.com, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, hemantg@codeaurora.org Subject: Re: [PATCH v4 2/3] Bluetooth: hci_qca: Retry btsoc initialize when it fails Message-ID: <20200115173315.GN89495@google.com> References: <20191225060317.5258-1-rjliao@codeaurora.org> <20200115085552.11483-1-rjliao@codeaurora.org> <20200115085552.11483-2-rjliao@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200115085552.11483-2-rjliao@codeaurora.org> 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 Wed, Jan 15, 2020 at 04:55:51PM +0800, Rocky Liao wrote: > This patch adds the retry of btsoc initialization when it fails. There are > reports that the btsoc initialization may fail on some platforms but the > repro ratio is very low. The symptoms is the firmware downloading failed > due to the UART write timed out. The failure may be caused by UART, > platform HW or the btsoc itself but it's very difficlut to root cause, > given the repro ratio is very low. Add a retry for the btsoc initialization > can work around most of the failures and make Bluetooth finally works. > > Signed-off-by: Rocky Liao > --- > > Changes in v2: None > Changes in v3: None > Changes in v4: > -rebased the patch with latet code > -refined macro and variable name > -updated commit message > > drivers/bluetooth/hci_qca.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c > index ecb74965be10..1139142e8eed 100644 > --- a/drivers/bluetooth/hci_qca.c > +++ b/drivers/bluetooth/hci_qca.c > @@ -55,6 +55,9 @@ > /* Controller debug log header */ > #define QCA_DEBUG_HANDLE 0x2EDC > > +/* max retry count when init fails */ > +#define MAX_INIT_RETRIES 3 > + > /* Controller dump header */ > #define QCA_SSR_DUMP_HANDLE 0x0108 > #define QCA_DUMP_PACKET_SIZE 255 > @@ -1539,6 +1542,7 @@ 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; > + unsigned int retries = 0; > enum qca_btsoc_type soc_type = qca_soc_type(hu); > const char *firmware_name = qca_get_firmware_name(hu); > int ret; > @@ -1559,6 +1563,7 @@ static int qca_setup(struct hci_uart *hu) > bt_dev_info(hdev, "setting up %s", > qca_is_wcn399x(soc_type) ? "wcn399x" : "ROME"); > > +retry: > ret = qca_power_on(hdev); > if (ret) > return ret; > @@ -1613,6 +1618,20 @@ static int qca_setup(struct hci_uart *hu) > * patch/nvm-config is found, so run with original fw/config. > */ > ret = 0; > + } else { > + if (retries < MAX_INIT_RETRIES) { > + qca_power_shutdown(hu); > + if (hu->serdev) { > + serdev_device_close(hu->serdev); > + ret = serdev_device_open(hu->serdev); > + if (ret) { > + bt_dev_err(hdev, "failed to open port"); > + return ret; > + } > + } > + retries++; > + goto retry; > + } > } > > /* Setup bdaddr */ > -- Assuming that this is really a rare condition: Reviewed-by: Matthias Kaehlcke