Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1055623rwb; Thu, 11 Aug 2022 15:05:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR4tP+CIDJ2GEUFlJ2F0oN8ur8Bz95tWcg2Og9Ts3hCwKV9GMfWlDmnieFKlnAcvtaba79/b X-Received: by 2002:aa7:8195:0:b0:52c:7d6a:e89d with SMTP id g21-20020aa78195000000b0052c7d6ae89dmr1112358pfi.69.1660255548431; Thu, 11 Aug 2022 15:05:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660255548; cv=none; d=google.com; s=arc-20160816; b=QIanGWxHB+HT9y9pM2OYVfoOx5ebAAXRKTKwXGS87vBRXH0W/79Y6DKCCYTBNmeXav wckGxM3kWy7OiWDCj8Un5T13oPgb4LId5auBNMb2hM2TOqYh3XxG+d62Solh9Qp9thW5 /taJCVhLILQYBmJH+deRQmU++SdOta+ZMW7IO7eJj5bS1vQ/1AKoqjN3/0V4QWeAU084 Zl49l4Zo9RtayHEjKNBHc8JgCLjdu/AdsVu6rc8gkmirqACnHUI0Aqw7YWm0fMQXydBb ENdFMfIEfKxwMmiL/7BPLzmSdJIrjhQeTjbmpXIPQ5pNlg5cwjwRJq+m65kZzy2TCD8z rZUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=3JHI90ddFAY9rwCXY8u7ccK2VfYkPxy8GVOK0E00A/Y=; b=wVbAkZ8OQMj8i8XEQ8L+fLZxQq/fMm1pPyn8fZXx8tMtzP036cpvN2AF6hekjxOobk BgaWqB/AYDshJnfQ2yoG99Rus0Hh6Nhpdz5oxMspEU5w3WHWQVyjGBkFwl6th4zuoy2S 8Slp+IwacLJseidSFSr9w8tFnaa+njEIEQG7rD9lKSkhiOsJD159pdAL41P5PTAIFJkj wBOE50RiLkbyry4+dZFrC67hOCZ4W4TXBD9cYlkLKnaRYEwtFxAx6BXSK2aqA+dLfLwW pn5ANEYQfkIpxj3oxUyRxgun9kezlnKjTXke8ylZPIMEjgAlo0yy2RhZRaC6i+wb36UK EogQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RINojJs3; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ik8-20020a170902ab0800b0016d90f4b9bcsi313430plb.408.2022.08.11.15.05.13; Thu, 11 Aug 2022 15:05:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RINojJs3; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236239AbiHKWAR (ORCPT + 99 others); Thu, 11 Aug 2022 18:00:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235835AbiHKWAP (ORCPT ); Thu, 11 Aug 2022 18:00:15 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 68939A5 for ; Thu, 11 Aug 2022 15:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660255210; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3JHI90ddFAY9rwCXY8u7ccK2VfYkPxy8GVOK0E00A/Y=; b=RINojJs3bHuFxGY+cQ2kfwYW8tjYdTG56owqhbKDjO0QwKdZSX6odiD4td9WmkdOSnJgU8 CIDjJlas1xvnx0G2P8zTX4EPegeIqFHn/90Ora8p/3Bvcwn4kobG7YCBJxHiFGZ5ixTdBO MkOEclwIg/pk+myweaFjLi18/M6QpI8= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-553-L2Jct4LrORSwTCjES6cyxA-1; Thu, 11 Aug 2022 18:00:08 -0400 X-MC-Unique: L2Jct4LrORSwTCjES6cyxA-1 Received: by mail-ed1-f69.google.com with SMTP id b13-20020a056402350d00b0043dfc84c533so11511227edd.5 for ; Thu, 11 Aug 2022 15:00:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=3JHI90ddFAY9rwCXY8u7ccK2VfYkPxy8GVOK0E00A/Y=; b=hJXP1R1/BnQ3XeIV2s431SGkpsUJifWe2mf9zK8VmyP92C3k1ecZuhGF/iTuTXD07u X+ZKbNZIoMpX/sYRE2vXN4cE1Rf6kUz37YciezER0R1EJ6xfATVMz6kWXTQ7HDmjXwpI 8ZPhZ0PWT3Abf1IJAaHWZN/3l7GWcZGIyNIPh/SEItmu5sckwsLW3i/PjKtFAG2sJmFy H8fm6vdAj6IipqJ/kpOIrYXBuPyP4bi+GAXFeM+YJnqbDN68BUsV1bgLEPKUAT9wb7LY ibxGofjkEfjhA2AvZlDP9Q+AejDskG3vG1EoZ1SqzlLG37Ib2OuxVu17yKTs1KyPsiC3 qLmg== X-Gm-Message-State: ACgBeo36PrVGXvFS/tio7IK9qmIXZyxON95TTz7XT4tP434MvkwKBqWR jAYJCvxkLd0o+2oozb4f+Aa0ussLUujaJy/r5M2QVmPujAZlFnQqUnG2zci7aiJHBf5+sck+rI0 w9/E0SdeiXCDotNGhQACtEiFL2zgP X-Received: by 2002:a17:906:9c82:b0:6df:c5f0:d456 with SMTP id fj2-20020a1709069c8200b006dfc5f0d456mr730445ejc.287.1660255207345; Thu, 11 Aug 2022 15:00:07 -0700 (PDT) X-Received: by 2002:a17:906:9c82:b0:6df:c5f0:d456 with SMTP id fj2-20020a1709069c8200b006dfc5f0d456mr730438ejc.287.1660255207164; Thu, 11 Aug 2022 15:00:07 -0700 (PDT) Received: from ?IPV6:2001:1c00:c1e:bf00:d69d:5353:dba5:ee81? (2001-1c00-0c1e-bf00-d69d-5353-dba5-ee81.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:d69d:5353:dba5:ee81]) by smtp.gmail.com with ESMTPSA id ds13-20020a170907724d00b0071cef8bafc3sm131403ejc.1.2022.08.11.15.00.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Aug 2022 15:00:06 -0700 (PDT) Message-ID: <285798a1-82df-398b-ce29-3e841c2e90cd@redhat.com> Date: Fri, 12 Aug 2022 00:00:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH v2] Bluetooth: hci_event: Fix vendor (unknown) opcode status handling Content-Language: en-US To: Luiz Augusto von Dentz Cc: Marcel Holtmann , Johan Hedberg , "linux-bluetooth@vger.kernel.org" , Luiz Augusto von Dentz References: <20220811120103.47669-1-hdegoede@redhat.com> From: Hans de Goede In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Luiz, On 8/11/22 22:27, Luiz Augusto von Dentz wrote: > Hi Hans, > > On Thu, Aug 11, 2022 at 5:01 AM Hans de Goede wrote: >> >> Commit c8992cffbe74 ("Bluetooth: hci_event: Use of a function table to >> handle Command Complete") was (presumably) meant to only refactor things >> without any functional changes. >> >> But it does have one undesirable side-effect, before *status would always >> be set to skb->data[0] and it might be overridden by some of the opcode >> specific handling. While now it always set by the opcode specific handlers. >> This means that if the opcode is not known *status does not get set any >> more at all! >> >> This behavior change has broken bluetooth support for BCM4343A0 HCIs, >> the hci_bcm.c code tries to configure UART attached HCIs at a higher >> baudraute using vendor specific opcodes. The BCM4343A0 does not >> support this and this used to simply fail: >> >> [ 25.646442] Bluetooth: hci0: BCM: failed to write clock (-56) >> [ 25.646481] Bluetooth: hci0: Failed to set baudrate >> >> After which things would continue with the initial baudraute. But now >> that hci_cmd_complete_evt() no longer sets status for unknown opcodes >> *status is left at 0. This causes the hci_bcm.c code to think the baudraute >> has been changed on the HCI side and to also adjust the UART baudrate, >> after which communication with the HCI is broken, leading to: >> >> [ 28.579042] Bluetooth: hci0: command 0x0c03 tx timeout >> [ 36.961601] Bluetooth: hci0: BCM: Reset failed (-110) >> >> And non working bluetooth. Fix this by restoring the previous >> default "*status = skb->data[0]" handling for unknown opcodes. >> >> Fixes: c8992cffbe74 ("Bluetooth: hci_event: Use of a function table to handle Command Complete") >> Cc: Luiz Augusto von Dentz >> Signed-off-by: Hans de Goede >> --- >> Changes in v2: >> - Add a comment that byte 0 containing the status is not guaranteed >> by the Bluetooth specification >> --- >> net/bluetooth/hci_event.c | 20 ++++++++++++++++++++ >> 1 file changed, 20 insertions(+) >> >> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c >> index af17dfb20e01..eb43afd5549a 100644 >> --- a/net/bluetooth/hci_event.c >> +++ b/net/bluetooth/hci_event.c >> @@ -3996,6 +3996,26 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, void *data, >> break; >> } >> } >> + if (i == ARRAY_SIZE(hci_cc_table)) { >> + /* Unknown opcode, assume byte 0 contains the status, so >> + * that e.g. __hci_cmd_sync() properly returns errors >> + * for vendor specific commands send by HCI drivers. >> + * >> + * Note that the specification does not specify that >> + * byte 0 is the status: >> + * >> + * BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E >> + * page 2189: >> + * >> + * Return_Parameters: >> + * Size: Depends on command >> + * >> + * For now using byte 0 seems to work fine, but in the future >> + * this may need to be updated so that drivers using vendor >> + * commands can specify their own completion handler. >> + */ >> + *status = skb->data[0]; >> + } >> >> handle_cmd_cnt_and_timer(hdev, ev->ncmd); >> >> -- >> 2.37.1 > > Not sure why CI bot didn't respond to the list but this patch was > already applied yesterday: > > https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/commit/?id=84a0a27ea39a9caed74d80a78666a91a9ea5e12b Great, thank you. Regards, Hans