From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C81133E7 for ; Wed, 13 May 2026 07:50:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778658631; cv=none; b=o2CLW10TpRgLHdvfVscXp0yNSJTkaYDZROEUWJ7F/UbvpNgZMtMA0Gg+qOea6CAKTwIsfzG3j2YGwbMrfgEHf2ZYAx4rOm3ujvh52acSB3DtBC66ElJXtf/UuIXw0aH+IJlTrReNaWb6bu8mfo5Y/OXZwYp9cstFiYokEI7ULvQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778658631; c=relaxed/simple; bh=nvDZxTsfOZ5pRR41/vZxK26Ud4ScS5tbuPWl2dxoYBA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=IiCtZKB3cFB01F4MfL4WrZ91uBuwvIDvtdCVx6sqnC7lq/aOO/jV1q4SS+IgwhOkWg6UyooQRBuRaBndOMOSb/apHSEs3Ft0ckCR/xdjUkoxo2wzHISHmBakxTqUUAT3k1lcSddSl6/lrLZCUSijBpnaz6AYf7dGJCl990AJMwU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=AKl0Z6BQ; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=CIVx21oV; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="AKl0Z6BQ"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="CIVx21oV" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64D4pX1t2653257 for ; Wed, 13 May 2026 07:50:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= yU+sWMY7S+KNwCSbEBbx/+Ty1vfbwm0p7xv6HhHcxmg=; b=AKl0Z6BQe+jHCTs3 lvXaIYC1/Tyh3N5Lxuxvk0Rl03ewLe18jeFys5B9lZiNpFZV39XOkce/2xj/FhID nfrVrdXHINeoix0LeiGuVNi5zl81Wm4O8baA/cmwmkS4/xC8HEMh2UqQwnlZlpHx dJ7hH/xxdqyiz9YU+1K2CW2CRYWRpcM6Q4VXirSKq8KaYBaXDTBX77kKhv4fkVRO tocIEUKQBvousZygnLxIO+VIl7AnNrDliV9OLjG/Wt8fAqMwAwPJSx4mo4eD1OrM K1r0+gW4NRj1jnTDMLT1IOT21AcpecWPwsU3UUX0/10ryNl8sXvi7IbJodcRobSQ jmPq5w== Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e45avkm3e-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 13 May 2026 07:50:28 +0000 (GMT) Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-2ee34588671so8985944eec.0 for ; Wed, 13 May 2026 00:50:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1778658627; x=1779263427; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=yU+sWMY7S+KNwCSbEBbx/+Ty1vfbwm0p7xv6HhHcxmg=; b=CIVx21oV/ERu/Jw1DR0EuIOK5AP53k4MzMuB27u5hZWvGDewAaNqx92ftdjql1fbFF 5n3t4PBKpkGjStWcVHKLU5wQc/d4nh3XODwNXUI/50kAtMrDHf7gY2w1h2nj6mTnQUVq gngdGiU7bvMwrpYpjQ3PpQl3GEETWEofjSfbuAdeQrKerRXhpc3qr7pPPWlSq3EOyetV JfFCEU+yWhJowtFtYjggtV7sruKPvewRcSVE5bklxdUQjC/rB/B7TZSJykL46GH51+gH V17KBk0wHNsQljbSlpRphMCMq6Nj4rPmwDi/JiLN5m6pqaUMI3q1yf0yCN8DWZgtl5Px yuWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778658627; x=1779263427; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yU+sWMY7S+KNwCSbEBbx/+Ty1vfbwm0p7xv6HhHcxmg=; b=dIzT8iZP04C+rdEWy97iL8qlXU9ZQkxMvPWcqoyQ7KHZOTlewX4jmpra1boJx9tZwO xMT6gVBx5tNMmzodWnMZ5GUVhvOztytG8Oq7dHTnBCi5issRaAOXpT+9ty5OsxgSue0C Rgk86lOtVGrM0dQLj2sAfDE/XB0Xe5WJZa6K48LAoBTi6FTU8sG4uUX/h6YwWQzULdGr 8qQ1wGy07wOeeZifZx64XngvJqbdGZKPcBj1xc18DBunSQ/PzLcxSW2ia7JIwAesnzUV w5zjgi3K7NrAmKyqCZuFhydUHm2pRsOcfeM5S6lTDetG5Z/iGGbioBQPQS9Q3lTOz5o/ zEwA== X-Forwarded-Encrypted: i=1; AFNElJ8mrlfoiR9mnI+mM2jFD4YeIJiZq605tsHdk47znc0OIDIs9HIQK2RtyZEr1olu+eszmiziVej15ZHIjtw=@vger.kernel.org X-Gm-Message-State: AOJu0YzjmdjfIBunLiBYPakOcTFxYRLSpHF3B/tik5S1j+c1ZdL5n0uL 29CM6TzRzt2Ld2CPypBqFqWqY6y+5SfjlxPakdj2uhpjw3kkac2Qh1uZyfisnElpNpP8z5gXj1e HVDHfLvYZeVoK+8gqZkII4fsgb/IzD0BznN43BTkEl8m22+lEPVHCcK+Ua2/LA2LjkEU= X-Gm-Gg: Acq92OGJZI3vOTY+agEUOMvuLn6nuoUiOXcZMkDAaEF9uATczb+J2WXhip34x7XBYjs pytdttK/xFntbMzWEV7qj6DjbZUvPjq25oYPVtPdFxF7tFu+xQDalWIO8xHml0Xy9KR1obllNXV RwzeN8IRWHLjSJU5g9hr17XjsBrTojpAiQOoJFglyuKlisagzOt5+utuJWuF0nkTPOVOlRixHBN mYEzaHs2w3M13pbg7M4b5ymlZO0AfwkSa88VYt2714nRjrsLK8SKJqa9K77Mv4BPh7gwRN6TEMS Uy6/jRZ2rAP3k0sQylSLBqh2CAR+0v4ciS/UnFf/yBYp9LIkUrgNyGZ71Nr7LhukmfSw5cEfJTD MwaiGgJ3V7qSpYYxzcCDp2e8BxrQwfNgikUkSE3+pF2nfky4vTa3045x6vmx1Qs6ylO9GJX5NoK NI X-Received: by 2002:a05:7300:d706:b0:2ed:935:aa33 with SMTP id 5a478bee46e88-30116e95062mr1378604eec.5.1778658627451; Wed, 13 May 2026 00:50:27 -0700 (PDT) X-Received: by 2002:a05:7300:d706:b0:2ed:935:aa33 with SMTP id 5a478bee46e88-30116e95062mr1378579eec.5.1778658626791; Wed, 13 May 2026 00:50:26 -0700 (PDT) Received: from [10.110.35.32] (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2f88847506fsm25796777eec.18.2026.05.13.00.50.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 May 2026 00:50:26 -0700 (PDT) Message-ID: <1a38fcd6-a990-4560-8a0d-5219854f3819@oss.qualcomm.com> Date: Wed, 13 May 2026 15:50:20 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] Bluetooth: btusb: Allow firmware re-download when version matches To: Luiz Augusto von Dentz Cc: Marcel Holtmann , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, cheng.jiang@oss.qualcomm.com, quic_chezhou@quicinc.com, wei.deng@oss.qualcomm.com, jinwang.li@oss.qualcomm.com, mengshi.wu@oss.qualcomm.com References: <20260429121207.1306526-1-shuai.zhang@oss.qualcomm.com> Content-Language: en-US From: Shuai Zhang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-GUID: 923AGfoq7HCoxz38OxNCQG0ZlMWAIRBn X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEzMDA3OCBTYWx0ZWRfX+wjG4HfOQVHw QxR7yliVchO5r+BOoyCNQomKKIcbmEQKv2ufHxAjLWlmZHYkApD4HCtoMCTkXdjlpn3OoN+87MS VBbwOGb424b73rwzOFau/kb+l2AZ3YFnyFqFTeZuoV2CRzD5cmQvo9Mtbscc2XU4Yy+un6QH1G7 Qy97QvqoExuA0VcPIB8GZN5D3KKsUhGhSC20kC/nwS9AeITM9/38EQfIvDJcLIzy2FkObWiAisV b9lWB0o8UR0UTmtv/xUtOXdtY3pFekp16DYTUVYWEQ2KJ1OfPczoYrJgHV53NjZgXSkzcS1e1N9 tH4NJC69sYmXCzKtVeWtUAqvzs9hQ5qPvMiGUo+mfvbLLXPAz0q9gm2mqPFAnQYoG8KT4Hyandx oYTgTiPB9yVJtsgaNLo5Px+3hSBXd1qLVtHem7N8E2ZkgVxMCrNGX4a2e0ITAOAiEvZQ55IJeGn yIGHxhEUv5zcyrJzpMg== X-Authority-Analysis: v=2.4 cv=bOwm5v+Z c=1 sm=1 tr=0 ts=6a042d44 cx=c_pps a=Uww141gWH0fZj/3QKPojxA==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=qqokX6KkybRntjKqjosA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=PxkB5W3o20Ba91AHUih5:22 X-Proofpoint-ORIG-GUID: 923AGfoq7HCoxz38OxNCQG0ZlMWAIRBn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-11_05,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 spamscore=0 malwarescore=0 clxscore=1015 adultscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605130078 Hi Luiz On 4/29/2026 11:17 PM, Luiz Augusto von Dentz wrote: > Hi Shuai, > > On Wed, Apr 29, 2026 at 8:12 AM Shuai Zhang > wrote: >> The Bluetooth host decides whether to download firmware by reading the >> controller firmware download completion flag and firmware version >> information. >> >> If a USB error occurs during the firmware download process (for example >> due to a USB disconnect), the download is aborted immediately. An >> incomplete firmware transfer does not cause the controller to set the >> download completion flag, but the firmware version information may be >> updated at an early stage of the download process. > Hold on, if the download has been aborted then the version should be > reverted, or rather just update once the firmware loading is complete, > so this indicates there is a bug somewhere that needs fixing, not > worked around. > >> In this case, after USB reconnection, the host attempts to re-download >> the firmware because the download completion flag is not set. However, >> since the controller reports the same firmware version as the target >> firmware, the download is skipped. This ultimately results in the >> firmware not being properly updated on the controller. >> >> This change removes the restriction that skips firmware download when >> the versions are equal. It covers scenarios where the USB connection >> can be disconnected at any time and ensures that firmware download can >> be retriggered after USB reconnection, allowing the Bluetooth firmware >> to be correctly and completely updated. >> >> Signed-off-by: Shuai Zhang >> --- >> Changes v2: >> - Update code comments and commit message to reflect the correct logic. >> - Align the commit title with upstream conventions. >> - Link v1 >> https://lore.kernel.org/all/20260108074353.1027877-1-shuai.zhang@oss.qualcomm.com/ >> --- >> drivers/bluetooth/btusb.c | 8 +++++++- >> 1 file changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c >> index 572091e60..70abbabea 100644 >> --- a/drivers/bluetooth/btusb.c >> +++ b/drivers/bluetooth/btusb.c >> @@ -3550,7 +3550,13 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, >> "firmware rome 0x%x build 0x%x", >> rver_rom, rver_patch, ver_rom, ver_patch); >> >> - if (rver_rom != ver_rom || rver_patch <= ver_patch) { >> + /* Allow rampatch when the patch version equals the firmware version. >> + * A firmware download may be aborted by a transient USB error (e.g. >> + * disconnect) after the controller updates version info but before >> + * completion. >> + * Allowing equal versions enables re-flashing during recovery. >> + */ >> + if (rver_rom != ver_rom || rver_patch < ver_patch) { > As I said above, this sounds more like a workaround. That said, I > wonder why it would print an error if the version matches, it sounds > to be that if the version matches it should just skip and consider it > has been loaded already in case the actual problem is fixed by setting > the new version only when loading has been completed. Correct, we cannot reliably detect if the download was aborted mid-flight, so the version information may not always be accurate. However, we only force a reload in cases where the firmware integrity cannot be guaranteed. If the firmware download has completed successfully, even if a USB disconnect happens afterward, we will not reload it, as the controller already contains a complete and valid firmware. >> bt_dev_err(hdev, "rampatch file version did not match with firmware"); >> err = -EINVAL; >> goto done; >> -- >> 2.34.1 >> >