From nobody Fri Jan 17 16:13:24 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YZPsx0X8Jz5l91w; Fri, 17 Jan 2025 16:13:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YZPsw6vTMz3Bwq; Fri, 17 Jan 2025 16:13:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737130405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KNyX8D/3OjG4WlPiIhDKm9WK18bfTGs8NbNpinDQ858=; b=w3ktP0qb95ZfKeZniPMDc9xSCSWpF3tW24U4S1DtmaOWzBn2faDNaIz2Et3OYmdCVpVcLS bJgqUPoEfcNObOK/hmWJG7YxCO7fv7RHzQJbxK3cJWltl+Lt0Cx+58mUT+710qEHCFphTe bCtaYwIBYjboUmUqqxekhOEILZPvy5lyHmE16TNpLhKGqkXgFs3y2kgHeG72KdZfsRYh7T uwoxFVmY/A2i/PUPng7blPT3JD58dzclWj5uO/6bQ9ciHL6wJxV0bLRaSY0ziILz+L+Epg 4ugvriQ6Ko3zQoncCHLfgFJBN+7HWQadlPyYFT2cs8CT2lasRsaG9qbknHgF5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737130405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KNyX8D/3OjG4WlPiIhDKm9WK18bfTGs8NbNpinDQ858=; b=ZGVexUFoPQ8dml5HBUkHJYoUyKZNuVdPwqxniXutfzEoWK9GN4Y0J926kdlKjmoXgd7Ebx pZsBGyWWoFom/DANzyCn5o4H0qbOO0A8ue0utAwdJ329iywNuuFObt8VlTXytMUuiQseWW 8caLE1Vncc1mFcX4+rE5PP85vSV6VNzToIvCVM74ak4ikZGHBvMfCUomiOjhOk6Y4EM5h8 2Ht2gU0Q+tLxuYXwLo4u5DhiUihOW1yorgE951z462QY91SeJi/+u1akFE6MhPAUqmiIvK duuVYjS4jUiCCUYrcYDMcpXaO1Y1dGzD0STTXRj7qzQ8ae515Vs0osDTQx1VQw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737130405; a=rsa-sha256; cv=none; b=ZwOskscaS79p6Fln0gKD4clEn7ZiIUmzqRGd65gO6eBKcg9H2wuN6r3lARCjuRimPlZvfh 4LdGgeoISUtq+6cItl+XUE5ZU17gpMzQ1S/YeBLHOgjPRf68iZ3elm17S22tpbEEdAKwCn kOI0+ldNEqd49tRdb1CWku0IBvNPloaNbNmGRAF4DWOwC6azb1ILTNWNxXK03+0GnqsZuu wdHJV4/9qBW98FE6CBb/3Xe5NWDeRuC5PciZCczZvQjxcIW5tSn/6Ain3V8nkg2oIrUK57 3Up1vQTp0LDD8GhGadGQq7A2up/qahH+W9Bbg8ggn0mOnj5Av6ceFmFLpPrCYw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YZPsw6SH4z8n6; Fri, 17 Jan 2025 16:13:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50HGDO2v085746; Fri, 17 Jan 2025 16:13:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50HGDOmo085743; Fri, 17 Jan 2025 16:13:24 GMT (envelope-from git) Date: Fri, 17 Jan 2025 16:13:24 GMT Message-Id: <202501171613.50HGDOmo085743@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: b8cdbe1852ef - main - iwmbtfw: Check firmware exists before trying to upload it List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b8cdbe1852ef5df4ba3c7a021d9632bde2e61327 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=b8cdbe1852ef5df4ba3c7a021d9632bde2e61327 commit b8cdbe1852ef5df4ba3c7a021d9632bde2e61327 Author: Gavin Atkinson AuthorDate: 2025-01-07 00:02:20 +0000 Commit: Ed Maste CommitDate: 2025-01-17 16:11:34 +0000 iwmbtfw: Check firmware exists before trying to upload it In the case of an Intel 7260 device, the device needs to be put into something called "manufacturer mode" before the firmware is uploaded. The firmware is then upladed, and the card is taken out of this mode, at which point it disconnects and reconnects to the USB bus, and is at that point usable. However, iwmbtfw(8) puts the device into manufacturer mode before verifying that there exists a copy of the firmware to upload. As a result, in the case where there is no firmware available on disk, the device is put into manufacturer mode, the firmware can't be found so isn't uploaded, and the card is brought out of manufacturer mode, so it disconnects and reconnects to the USB bus. Enter devd(8). There are rules in /etc/devd/iwmbtfw.conf to call iwmbtfw(8) when the device appears. When there's no firmware on disk, devd will call iwmbtfw, iwmbtfw will try to do its thing and fail, the device will dis/reconnect, and devd will notice the device reappear and start the whole loop again. Fix is to verify that the firmware exists before putting the device into its special mode. The fix only changes things for the 7260 and not the other chips supported, I don't believe the issue exists with other chips as those do not need to be switched into manufacturer mode before uploading. PR: 283896 Reviewed by: emaste --- usr.sbin/bluetooth/iwmbtfw/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/usr.sbin/bluetooth/iwmbtfw/main.c b/usr.sbin/bluetooth/iwmbtfw/main.c index c2b67ce01906..9c899d374e92 100644 --- a/usr.sbin/bluetooth/iwmbtfw/main.c +++ b/usr.sbin/bluetooth/iwmbtfw/main.c @@ -518,6 +518,13 @@ main(int argc, char *argv[]) iwmbt_debug("firmware_path = %s", firmware_path); + /* Check firmware file exists before changing HW mode */ + r = access(firmware_path, R_OK); + if (r) { + perror("Failed to open firmware"); + goto shutdown; + } + /* Enter manufacturer mode */ r = iwmbt_enter_manufacturer(hdl); if (r < 0) {