Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH] dmaengine: qcom: bam_dma: Fix BAM_RIVISON register handling
@ 2025-01-10  5:14 Md Sadre Alam
  2025-01-10 10:15 ` Stephan Gerhold
  0 siblings, 1 reply; 3+ messages in thread
From: Md Sadre Alam @ 2025-01-10  5:14 UTC (permalink / raw)
  To: vkoul, ulf.hansson, robin.murphy, kees, u.kleine-koenig,
	linux-arm-msm, av2082000, dmaengine, linux-kernel
  Cc: djakov, quic_mdalam, quic_varada, quic_srichara

This patch fixes a bug introduced in the previous commit where the
BAM_DESC_CNT_TRSHLD register was conditionally written based on BAM-NDP
mode. Additionally, it addresses an issue where reading the BAM_REVISION
register hangs if num-ees is not zero. A check has been added to prevent
this.

Cc: stable@vger.kernel.org
Fixes: 57a7138d0627 ("dmaengine: qcom: bam_dma: Avoid writing unavailable register")
Reported-by: Georgi Djakov <djakov@kernel.org>
Link: https://lore.kernel.org/lkml/9ef3daa8-cdb1-49f2-8d19-a72d6210ff3a@kernel.org/
Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
---
 drivers/dma/qcom/bam_dma.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index c14557efd577..2b88b27f2f91 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -445,11 +445,15 @@ static void bam_reset(struct bam_device *bdev)
 	writel_relaxed(val, bam_addr(bdev, 0, BAM_CTRL));
 
 	/* set descriptor threshold, start with 4 bytes */
-	if (in_range(bdev->bam_revision, BAM_NDP_REVISION_START,
-		     BAM_NDP_REVISION_END))
+	if (!bdev->num_ees && in_range(bdev->bam_revision, BAM_NDP_REVISION_START,
+				       BAM_NDP_REVISION_END))
 		writel_relaxed(DEFAULT_CNT_THRSHLD,
 			       bam_addr(bdev, 0, BAM_DESC_CNT_TRSHLD));
 
+	if (bdev->num_ees && !bdev->bam_revision)
+		writel_relaxed(DEFAULT_CNT_THRSHLD, bam_addr(bdev, 0,
+							     BAM_DESC_CNT_TRSHLD));
+
 	/* Enable default set of h/w workarounds, ie all except BAM_FULL_PIPE */
 	writel_relaxed(BAM_CNFG_BITS_DEFAULT, bam_addr(bdev, 0, BAM_CNFG_BITS));
 
@@ -1006,10 +1010,14 @@ static void bam_apply_new_config(struct bam_chan *bchan,
 			maxburst = bchan->slave.src_maxburst;
 		else
 			maxburst = bchan->slave.dst_maxburst;
-		if (in_range(bdev->bam_revision, BAM_NDP_REVISION_START,
-			     BAM_NDP_REVISION_END))
+		if (!bdev->num_ees && in_range(bdev->bam_revision, BAM_NDP_REVISION_START,
+					       BAM_NDP_REVISION_END))
 			writel_relaxed(maxburst,
 				       bam_addr(bdev, 0, BAM_DESC_CNT_TRSHLD));
+
+		if (bdev->num_ees && !bdev->bam_revision)
+			writel_relaxed(DEFAULT_CNT_THRSHLD, bam_addr(bdev, 0,
+								     BAM_DESC_CNT_TRSHLD));
 	}
 
 	bchan->reconfigure = 0;
@@ -1196,12 +1204,13 @@ static struct dma_chan *bam_dma_xlate(struct of_phandle_args *dma_spec,
  */
 static int bam_init(struct bam_device *bdev)
 {
-	u32 val;
+	u32 val = 0;
 
 	/* read revision and configuration information */
-	val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION));
-	if (!bdev->num_ees)
+	if (!bdev->num_ees) {
+		val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION));
 		bdev->num_ees = (val >> NUM_EES_SHIFT) & NUM_EES_MASK;
+	}
 
 	bdev->bam_revision = val & REVISION_MASK;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-10 11:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-10  5:14 [PATCH] dmaengine: qcom: bam_dma: Fix BAM_RIVISON register handling Md Sadre Alam
2025-01-10 10:15 ` Stephan Gerhold
2025-01-10 11:08   ` Md Sadre Alam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox