Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp603063lqh; Thu, 28 Mar 2024 10:35:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWqtT9pPEkuoGCUuAaD0ZGAEr3nHX3Z9poGZZ4D6ODov2HgGSv5LRSSGLI4CQJs3Dj38eZjFuN3cV6N06p2os7EQlXEUTLOQHnIYmSjtQ== X-Google-Smtp-Source: AGHT+IGpI9NFKPuN5A1KT5SurujXD2h6s7kUaKFfBa2vVP1tji1/TuJTDPQdLeaTKlP5VndQOjEJ X-Received: by 2002:a17:902:f54e:b0:1e0:a2cf:62f2 with SMTP id h14-20020a170902f54e00b001e0a2cf62f2mr124978plf.23.1711647356823; Thu, 28 Mar 2024 10:35:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711647356; cv=pass; d=google.com; s=arc-20160816; b=FdMiz53Wd9So4fB4MPEzj1oHKIncBdkzCmSAiRPO5JE/kbdFn8I5K8MviWJC0xuUTu CuE0zCe68Gd1F16HceRSP7ILle7Ebz99IorAiVHXoq1+7ICi9uIpCGpRmm3VjRYRAR0+ oZpAgYjnDK/0PHq2uOB/sTFnWhMzjTT4atDQjEGwPArFCQPY621DrddTKAps0W872FZN H9Se/2WzbQOVS0H8unJ0mI1049YF36m5+1sHRgoX6DPEzG4FvZ85X+RoIN9HaybJ4844 +kPDMxMTwnLqGZ2WCsa5cO+DHkqm7uDmMqB7XCoxMO2fP3qF3ZIo6Jdof3OHK/BaOBsM 7x0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date:dkim-signature; bh=0CJOZ3ipQzY8eI2ddGkfWeZdEy2CPgF1yeUX6fvIZcI=; fh=WIb2YirK2kAoBkkWdCJ/KaF6nXeKMT+FdVw42jCw8xw=; b=HywNO7Ks6GDWeg/4TK9QoMJZolCFD8wey2zMbsv+w2m25A6051MT81Kun2kwKzIcb7 KS4pJ6FlxpmO0LdGGmGpx4lvGsZ4ak7CxmGT5+Vu4IWSG3DsjcuedaxX2IhYW1JC06Ew zgwhsD/TVnA6qSIShpcBjjqGuc37AcOYbXoiEPLmEpufclSpAaGt47BuupjGtcgz6kJT Ol9TVe4nO2LRMRzCKQr1J3XM9rbSxAQcBh9nFfmyWckFNiW1NBARX9tf+ATJuAf94kXj 247Q1SL4Nvz3HlKN8HJkDzu5Pemnu99qE0MW4ozrK7PR8HqHhtCVH4FPS7ay+WpwsDpQ RUuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XfU0jKmZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-bluetooth+bounces-2923-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2923-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y2-20020a17090322c200b001dd8b3a397esi1924349plg.55.2024.03.28.10.35.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 10:35:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-2923-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XfU0jKmZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-bluetooth+bounces-2923-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2923-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5A54DB25A86 for ; Thu, 28 Mar 2024 17:10:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6948F129E86; Thu, 28 Mar 2024 17:08:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XfU0jKmZ" X-Original-To: linux-bluetooth@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CDC385BADB for ; Thu, 28 Mar 2024 17:08:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711645713; cv=none; b=atJ56poyUM0B1jqZJw0eg7ZnuwSXmdEhJfolNKDGQG0guuwRzVtgPafAkOnEzCfvX2NEB9co1IFRlMX7pyv6dZbStrQF8UmlehCMPnwju1NMjHB71c4Jgbp9prdt/2D/NXpLHuJQ65B2DO5GGWA4+Uiwijzpxg1zoYQF50mN16o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711645713; c=relaxed/simple; bh=Rh3IW5rU3PVv5IFrd5c61y98olbgKxP6Ang6BwVP4sk=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=NGYPv5B6vhzAHlSL60ZE0S5ELxB/rM7f6qBRQSxujX5xLe1A95Kwo1vlNBPNUjvlCR7BJuWQODzA5VYn/z3hrEcAJTQsCjIqDzwvM/ntgR7Os/amRz+a6hFf4kULlzr4uegN6qKguFaS49xjxC4ekZeu8ZX+URyxQMMUR1TVclQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XfU0jKmZ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38E77C433F1; Thu, 28 Mar 2024 17:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711645713; bh=Rh3IW5rU3PVv5IFrd5c61y98olbgKxP6Ang6BwVP4sk=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=XfU0jKmZ5/DwK/e0JJoj3+r36+1vGwjN5Dd8Gm36y1XMg8f38w1JI2VVeWNAlUFtN IoJkypHMkICMYJnBBfa6AUsCV13/2Htz1Uh2XoGFCpYrz4vvXGO4tCd5lZpEk2UI/H adS6spLh3jWOD72aFEp4AibF5zal/mHZ1FSYPHzd+kN3DvT8Mre6GRD3cRi/pZfZrw rkfPAo23VtQvdcgFzKOmdRMmHhVzaI2PiRXk5lrfVlu2eTh2FbRe/bpdP4bD5CL1Rd IKG5VW7QzAmqdpt18D8qC2auEm6hKVrCpiuat4cYCo5xwt7rnaxF29JoIwvoZx7edF HYo7utAwV0//Q== Date: Thu, 28 Mar 2024 12:08:31 -0500 From: Bjorn Helgaas To: Kiran K Cc: linux-bluetooth@vger.kernel.org, ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, Chandrashekar Subject: Re: [PATCH v1 3/3] Bluetooth: btintel_pcie: Add *setup* function to download firmware Message-ID: <20240328170831.GA1570559@bhelgaas> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240328111904.992068-3-kiran.k@intel.com> On Thu, Mar 28, 2024 at 04:49:04PM +0530, Kiran K wrote: > Add to support to download firmware. s/Add to/Add/ > +static void btintel_pcie_prepare_tx(struct txq *txq, u16 tfd_index, > + struct sk_buff *skb) > +{ > + struct data_buf *buf; > + struct tfd *tfd; > + > + tfd = &txq->tfds[tfd_index]; > + memset(tfd, 0, sizeof(*tfd)); > + > + /* Get the buffer of the tfd index for DMA */ s/tfd/TFD/ for consistency. > +static int btintel_pcie_hci_send_frame(struct hci_dev *hdev, > + struct sk_buff *skb) > +{ > + struct btintel_pcie_data *data = hci_get_drvdata(hdev); > + int ret; > + u32 type; > + > + /* Due to the fw limitation, the type header of the packet should be > + * 4 bytes unlikely 1 byte for UART. In UART, the firmware can reads > + * the first byte to get the packet type and redirect the rest of data > + * packet to the right handler. But for PCIe, THF(Transfer Flow Handler) > + * fetches the 4 bytes of data from DMA memory and by the time it reads > + * the first 4 bytes, it already consumes some part of packet. Thus > + * the packet type indicator for iBT PCIe is 4 bytes. > + * Luckily, when HCI core creates the skb, it allocated 8 bytes of > + * head room for profile and driver use, and before sending the data > + * to the device, append the iBT PCIe packet type in the front. s/unlikely/unlike/ s/can reads/can read/ s/it already consumes/it has already consumed/ Add blank line between paragraphs. > + */ > + switch (hci_skb_pkt_type(skb)) { > + case HCI_COMMAND_PKT: > + type = BTINTEL_PCIE_HCI_CMD_PKT; > + if (btintel_test_flag(hdev, INTEL_BOOTLOADER)) { > + struct hci_command_hdr *cmd = (void *)skb->data; > + __u16 opcode = le16_to_cpu(cmd->opcode); > + > + /* When the 0xfc01 command is issued to boot into > + * the operational firmware, it will actually not > + * send a command complete event. To keep the flow > + * control working inject that event here. > + */ > + if (opcode == 0xfc01) > + btintel_pcie_inject_cmd_complete(hdev, opcode); > + } > + hdev->stat.cmd_tx++; > + break; > + case HCI_ACLDATA_PKT: > + type = BTINTEL_PCIE_HCI_ACL_PKT; > + hdev->stat.acl_tx++; > + break; > + case HCI_SCODATA_PKT: > + type = BTINTEL_PCIE_HCI_SCO_PKT; > + hdev->stat.sco_tx++; > + break; > + default: > + bt_dev_err(hdev, "Unknown HCI packet type"); > + ret = -EILSEQ; > + goto exit_error; > + } > + memcpy(skb_push(skb, BTINTEL_PCIE_HCI_TYPE_LEN), &type, > + BTINTEL_PCIE_HCI_TYPE_LEN); > + > + ret = btintel_pcie_send_sync(data, skb); > + if (ret) { > + hdev->stat.err_tx++; > + bt_dev_err(hdev, "Failed to send frame (%d)", ret); > + goto exit_error; > + } else { > + hdev->stat.byte_tx += skb->len; > + kfree_skb(skb); > + } > + > +exit_error: > + > + return ret; There's no cleanup here, so it would be simpler to omit "ret" completely and return directly above instead of using the goto. > +}