From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=5.75.144.95 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796322702; b=H3xqueU9cupqdxHxn6KrqaDli8lUOT5ONQlcdKTEbSJMpKUjbHCT2eEMnOqwIDWk4WeI 7mKzhIej1RiqTokU8kmAlCjJY98DpxHgop8gD9u7Z+aW0rxGRI28s3xaKrO6uwPbpxvn9 it6EtwByatsBrx6oWRiGIKmiJtulitbwxywVyHBEIfJdX6LuHBRatzPMTjJC/WV+CJ5Bo XpqzCiQrNEoAOvdlUAX8RppL43p/aqzGhC28A2iYa7hmdBsuJ2VYaiTTN2FPvHnD+i1sY 2LDG7O5N1mj87gtPI+nvigilOAeWru4jscYel7oum1tQxYLqrx1oOh0Tsxoz8JXOPUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796322702; h=DMARC-Filter:DKIM-Signature:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=jcaxpjlxbYjTKqKjGJUG0ngL8sxlL/1VO6AG4BK4Luw=; b=fa/cSkYy2SPDbBWAMC8M9mQIW5XQXNzwIrdGGV2CwfT10Ckst8u+O3beepyEMKTxfh7D 0SQTWyNEd79dTypixpII0NXXUGwI1D0RSrRrQjmEhQHPIhE00wBi2nIpZ9GyiXoyEcqz4 tm3p3iQvkKnXltMBoTV1rKSs0YHoRe8BKdFEBUyujEEdfvXEM6c3JqqlKkeiGqPNaTnVc DxxOlbS7w3lGE2GT9YLYKT2rDsCFcamPWtSFhfs/coImxDBNopeGC7Pmx4VWH6H9xgRFS cTuwECIIL/yWDEiANIY76oOEedaOJeGFK792057UIYyb7FUKZfHHjKd0cTFsyPfbrTA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=mainlining.org; spf=pass smtp.mailfrom=mainlining.org; dkim=pass header.d=mainlining.org header.i=@mainlining.org header.a=rsa-sha256 header.s=202507r header.b=J6O7s6hW; dkim=pass header.d=mainlining.org header.i=@mainlining.org header.a=ed25519-sha256 header.s=202507e header.b=qFz2IBhx; arc=none smtp.remote-ip=5.75.144.95 Received: from mail.mainlining.org (mail.mainlining.org [5.75.144.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D676C606A332; Thu, 3 Dec 2026 18:31:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D676C606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mainlining.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mainlining.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mainlining.org header.i=@mainlining.org header.a=rsa-sha256 header.s=202507r header.b=J6O7s6hW; dkim=pass header.d=mainlining.org header.i=@mainlining.org header.a=ed25519-sha256 header.s=202507e header.b=qFz2IBhx DKIM-Signature: v=1; a=rsa-sha256; s=202507r; d=mainlining.org; c=relaxed/relaxed; h=From:To:Subject:Date:Message-ID; t=1796322700; bh=jcaxpjlxbYjTKqKjGJUG0ng L8sxlL/1VO6AG4BK4Luw=; b=J6O7s6hWVoJgke0lUF/uFV+K8IYX4K6rBTIbceGzt/fO84q0iU bE8bbwLP/CHz4vYGg+lQ4zrxKnATsaKaMh/p/JcLNwCOIFnP1IND5sCCXFIk3Tn6SUrhpBWqJo2 65LogmDTYKXmpeaq+MRlMmWUdDh9WOtf2NDm9847N8b/zrAPLNAbFLPzRq6TsWA1xHOwmQeKhPN hEx5I8yr9rtdQR9LQEp+xUhteoug6Z2tZB7euO/1CYJ5w6xlIOkNfsiE//AMj00Ao57hlqj6v0G /F3NH+fPfDBYhWXl2vxXI3L1NG+WXI84PNZHKdrEvfvbyWGarh0ctBnQvvvkHHEFYTg==; DKIM-Signature: v=1; a=ed25519-sha256; s=202507e; d=mainlining.org; c=relaxed/relaxed; h=From:To:Subject:Date:Message-ID; t=1796322700; bh=jcaxpjlxbYjTKqKjGJUG0ng L8sxlL/1VO6AG4BK4Luw=; b=qFz2IBhxGv58iN9WOkHmrDO60hI3Rc9Ipw8tpedzVRyCbkMJEM 2UvFznhLe6veFa7mQUPa2uP0yju8C1RF8bBA==; Message-ID: Date: Thu, 3 Dec 2026 21:31:39 +0300 X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] dmaengine: qcom: bam_dma: Report the residue of packet To: Vinod Koul , Frank Li Cc: linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261116-qcom-bam-dma-metadata-v2-1-aade3a42fcb4@mainlining.org> Content-Language: ru-RU, en-US From: Nickolay Goppen In-Reply-To: <20261116-qcom-bam-dma-metadata-v2-1-aade3a42fcb4@mainlining.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 16.11.2026 16:49, Nickolay Goppen пишет: > The BAM writes back the number of bytes actually received into the > descriptor that ended an RX transfer. Report this through the standard > dmaengine_result (residue = length - transferred) so clients get the > packet length from callback_result(). > > Assisted-by: LLM > Signed-off-by: Nickolay Goppen > --- > IPA v2.x uses BAM to send and receive IP packets, to and from the AP. > However, unlike its predecessor BAM-DMUX, it doesn't send information > about the packet length, but ipa2 driver will need that. To find the > length of the packet, one must instead read the difference between > packet length and residue. > --- > Changes in v2: > - Fixed residues of old patch (sashiko) > - changed readl_relaxed to readl for offset reading in proccess_channel_irqs (sashiko) > - Link to v1: https://patch.msgid.link/20261115-qcom-bam-dma-metadata-v1-1-52e4de54ffd3@mainlining.org > > To: Vinod Koul > To: Frank Li > Cc: linux-arm-msm@vger.kernel.org > Cc: dmaengine@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > --- > drivers/dma/qcom/bam_dma.c | 33 ++++++++++++++++++++++++++++++++- > 1 file changed, 32 insertions(+), 1 deletion(-) > > diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c > index e62e411dc8f8..bf0c25d7c111 100644 > --- a/drivers/dma/qcom/bam_dma.c > +++ b/drivers/dma/qcom/bam_dma.c > @@ -65,6 +65,7 @@ struct bam_async_desc { > > u32 num_desc; > u32 xfer_len; > + size_t transferred; > > /* transaction flags, EOT|EOB|NWD */ > u16 flags; > @@ -447,6 +448,31 @@ static inline void __iomem *bam_addr(struct bam_device *bdev, u32 pipe, > r.ee_mult * bdev->ee; > } > > +/** > + * bam_fifo_xfer_len - bytes transferred for a completed descriptor chunk > + * @bchan: BAM channel the chunk was queued on > + * @async_desc: BAM async descriptor owning the chunk > + * > + * For RX pipes the BAM overwrites the size field of the descriptor that > + * ended the transfer with the number of bytes actually written to memory, > + * which can be less than the buffer size (e.g. an IPA packet). Those > + * values live in the FIFO copy, not in async_desc->desc[]. > + */ > + > +static u32 bam_fifo_xfer_len(struct bam_chan *bchan, > + const struct bam_async_desc *async_desc) > +{ > + struct bam_desc_hw *fifo = PTR_ALIGN(bchan->fifo_virt, > + sizeof(struct bam_desc_hw)); > + u32 len = 0; > + unsigned int i; > + > + for (i = bchan->head; i < bchan->head + async_desc->xfer_len; i++) > + len += le16_to_cpu(fifo[i % MAX_DESCRIPTORS].size); > + > + return len; > +} > + > /** > * bam_reset() - reset and initialize BAM registers > * @bdev: bam device > @@ -865,7 +891,7 @@ static u32 process_channel_irqs(struct bam_device *bdev) > > guard(spinlock_irqsave)(&bchan->vc.lock); > > - offset = readl_relaxed(bam_addr(bdev, i, BAM_P_SW_OFSTS)) & > + offset = readl(bam_addr(bdev, i, BAM_P_SW_OFSTS)) & > P_SW_OFSTS_MASK; > offset /= sizeof(struct bam_desc_hw); > > @@ -881,6 +907,11 @@ static u32 process_channel_irqs(struct bam_device *bdev) > if (avail < async_desc->xfer_len) > break; > > + async_desc->transferred += > + bam_fifo_xfer_len(bchan, async_desc); > + async_desc->vd.tx_result.residue = > + async_desc->length - async_desc->transferred; > + > /* manage FIFO */ > bchan->head += async_desc->xfer_len; > bchan->head %= MAX_DESCRIPTORS; > > --- > base-commit: 2cc223d6ffadd48e25eff0c8a03108a5d7a61c41 > change-id: 20261115-qcom-bam-dma-metadata-f34e592d400c > > Best regards, > -- > Nickolay Goppen Can someone take a look at this? -- Best regards, Nickolay