All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Rosin <peda@axentia.se>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Ludovic Desroches <ludovic.desroches@microchip.com>,
	Tudor Ambarus <tudor.ambarus@linaro.org>,
	Vinod Koul <vkoul@kernel.org>,
	Nicolas Ferre <nicolas.ferre@microchip.com>,
	linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org
Subject: [PATCH 1/2] dmaengine: at_hdmac: Repair bitfield macros for peripheral ID handling
Date: Tue, 23 May 2023 14:42:46 +0200	[thread overview]
Message-ID: <68b70631-07b0-f4b2-463c-b8d3c7b9dac3@axentia.se> (raw)
In-Reply-To: <dc4834cb-fadf-17a5-fbc7-cf500db88f20@axentia.se>

The MSB part of the peripheral IDs need to go into the ATC_SRC_PER_MSB
and ATC_DST_PER_MSB fields. Not the LSB part.

This fixes a severe regression for TSE-850 devices (compatible
axentia,tse850v3) where output to the audio I2S codec (the main
purpose of the device) simply do not work.

While at it, rewrite the macros as inline functions to evade checkpatch
warnings about argument reuse.

Fixes: d8840a7edcf0 ("dmaengine: at_hdmac: Use bitfield access macros")
Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/dma/at_hdmac.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 8858470246e1..6f352160bc3b 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -153,8 +153,6 @@
 #define ATC_AUTO		BIT(31)		/* Auto multiple buffer tx enable */
 
 /* Bitfields in CFG */
-#define ATC_PER_MSB(h)	((0x30U & (h)) >> 4)	/* Extract most significant bits of a handshaking identifier */
-
 #define ATC_SRC_PER		GENMASK(3, 0)	/* Channel src rq associated with periph handshaking ifc h */
 #define ATC_DST_PER		GENMASK(7, 4)	/* Channel dst rq associated with periph handshaking ifc h */
 #define ATC_SRC_REP		BIT(8)		/* Source Replay Mod */
@@ -181,10 +179,7 @@
 #define ATC_DPIP_HOLE		GENMASK(15, 0)
 #define ATC_DPIP_BOUNDARY	GENMASK(25, 16)
 
-#define ATC_SRC_PER_ID(id)	(FIELD_PREP(ATC_SRC_PER_MSB, (id)) |	\
-				 FIELD_PREP(ATC_SRC_PER, (id)))
-#define ATC_DST_PER_ID(id)	(FIELD_PREP(ATC_DST_PER_MSB, (id)) |	\
-				 FIELD_PREP(ATC_DST_PER, (id)))
+#define ATC_PER_MSB		GENMASK(5, 4)	/* Extract MSBs of a handshaking identifier */
 
 
 
@@ -1780,6 +1775,32 @@ static bool at_dma_filter(struct dma_chan *chan, void *slave)
 	}
 }
 
+/**
+ * atc_src_per_id - prepare the source peripheral fields of the CFG
+ * register for the given peripheral handshaking id.
+ *
+ * @per_id: the peripheral id
+ */
+static inline u32 atc_src_per_id(unsigned int per_id)
+{
+	return FIELD_PREP(ATC_SRC_PER_MSB,
+			  FIELD_GET(ATC_PER_MSB, per_id)) |
+		FIELD_PREP(ATC_SRC_PER, per_id);
+}
+
+/**
+ * atc_dst_per_id - prepare the destination peripheral fields of the CFG
+ * register for the given peripheral handshaking id.
+ *
+ * @per_id: the peripheral id
+ */
+static inline u32 atc_dst_per_id(unsigned int per_id)
+{
+	return FIELD_PREP(ATC_DST_PER_MSB,
+			  FIELD_GET(ATC_PER_MSB, per_id)) |
+		FIELD_PREP(ATC_DST_PER, per_id);
+}
+
 static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec,
 				     struct of_dma *of_dma)
 {
@@ -1812,7 +1833,7 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec,
 	 * ignored depending on DMA transfer direction.
 	 */
 	per_id = dma_spec->args[1] & AT91_DMA_CFG_PER_ID_MASK;
-	atslave->cfg |= ATC_DST_PER_ID(per_id) |  ATC_SRC_PER_ID(per_id);
+	atslave->cfg |= atc_dst_per_id(per_id) | atc_src_per_id(per_id);
 	/*
 	 * We have to translate the value we get from the device tree since
 	 * the half FIFO configuration value had to be 0 to keep backward
-- 
2.20.1


WARNING: multiple messages have this Message-ID (diff)
From: Peter Rosin <peda@axentia.se>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Tudor Ambarus <tudor.ambarus@linaro.org>,
	Ludovic Desroches <ludovic.desroches@microchip.com>,
	Vinod Koul <vkoul@kernel.org>,
	dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] dmaengine: at_hdmac: Repair bitfield macros for peripheral ID handling
Date: Tue, 23 May 2023 14:42:46 +0200	[thread overview]
Message-ID: <68b70631-07b0-f4b2-463c-b8d3c7b9dac3@axentia.se> (raw)
In-Reply-To: <dc4834cb-fadf-17a5-fbc7-cf500db88f20@axentia.se>

The MSB part of the peripheral IDs need to go into the ATC_SRC_PER_MSB
and ATC_DST_PER_MSB fields. Not the LSB part.

This fixes a severe regression for TSE-850 devices (compatible
axentia,tse850v3) where output to the audio I2S codec (the main
purpose of the device) simply do not work.

While at it, rewrite the macros as inline functions to evade checkpatch
warnings about argument reuse.

Fixes: d8840a7edcf0 ("dmaengine: at_hdmac: Use bitfield access macros")
Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/dma/at_hdmac.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 8858470246e1..6f352160bc3b 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -153,8 +153,6 @@
 #define ATC_AUTO		BIT(31)		/* Auto multiple buffer tx enable */
 
 /* Bitfields in CFG */
-#define ATC_PER_MSB(h)	((0x30U & (h)) >> 4)	/* Extract most significant bits of a handshaking identifier */
-
 #define ATC_SRC_PER		GENMASK(3, 0)	/* Channel src rq associated with periph handshaking ifc h */
 #define ATC_DST_PER		GENMASK(7, 4)	/* Channel dst rq associated with periph handshaking ifc h */
 #define ATC_SRC_REP		BIT(8)		/* Source Replay Mod */
@@ -181,10 +179,7 @@
 #define ATC_DPIP_HOLE		GENMASK(15, 0)
 #define ATC_DPIP_BOUNDARY	GENMASK(25, 16)
 
-#define ATC_SRC_PER_ID(id)	(FIELD_PREP(ATC_SRC_PER_MSB, (id)) |	\
-				 FIELD_PREP(ATC_SRC_PER, (id)))
-#define ATC_DST_PER_ID(id)	(FIELD_PREP(ATC_DST_PER_MSB, (id)) |	\
-				 FIELD_PREP(ATC_DST_PER, (id)))
+#define ATC_PER_MSB		GENMASK(5, 4)	/* Extract MSBs of a handshaking identifier */
 
 
 
@@ -1780,6 +1775,32 @@ static bool at_dma_filter(struct dma_chan *chan, void *slave)
 	}
 }
 
+/**
+ * atc_src_per_id - prepare the source peripheral fields of the CFG
+ * register for the given peripheral handshaking id.
+ *
+ * @per_id: the peripheral id
+ */
+static inline u32 atc_src_per_id(unsigned int per_id)
+{
+	return FIELD_PREP(ATC_SRC_PER_MSB,
+			  FIELD_GET(ATC_PER_MSB, per_id)) |
+		FIELD_PREP(ATC_SRC_PER, per_id);
+}
+
+/**
+ * atc_dst_per_id - prepare the destination peripheral fields of the CFG
+ * register for the given peripheral handshaking id.
+ *
+ * @per_id: the peripheral id
+ */
+static inline u32 atc_dst_per_id(unsigned int per_id)
+{
+	return FIELD_PREP(ATC_DST_PER_MSB,
+			  FIELD_GET(ATC_PER_MSB, per_id)) |
+		FIELD_PREP(ATC_DST_PER, per_id);
+}
+
 static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec,
 				     struct of_dma *of_dma)
 {
@@ -1812,7 +1833,7 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec,
 	 * ignored depending on DMA transfer direction.
 	 */
 	per_id = dma_spec->args[1] & AT91_DMA_CFG_PER_ID_MASK;
-	atslave->cfg |= ATC_DST_PER_ID(per_id) |  ATC_SRC_PER_ID(per_id);
+	atslave->cfg |= atc_dst_per_id(per_id) | atc_src_per_id(per_id);
 	/*
 	 * We have to translate the value we get from the device tree since
 	 * the half FIFO configuration value had to be 0 to keep backward
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-05-23 12:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23 12:42 [PATCH 0/2] dmaengine: at_hdmac: Regression fix and cleanup Peter Rosin
2023-05-23 12:42 ` Peter Rosin
2023-05-23 12:42 ` Peter Rosin [this message]
2023-05-23 12:42   ` [PATCH 1/2] dmaengine: at_hdmac: Repair bitfield macros for peripheral ID handling Peter Rosin
2023-05-23 15:15   ` Tudor Ambarus
2023-05-23 15:15     ` Tudor Ambarus
2023-05-23 12:42 ` [PATCH 2/2] dmaengine: at_hdmac: Remove unused field values that do not fit Peter Rosin
2023-05-23 12:42   ` Peter Rosin
2023-05-23 14:04   ` Tudor Ambarus
2023-05-23 14:04     ` Tudor Ambarus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=68b70631-07b0-f4b2-463c-b8d3c7b9dac3@axentia.se \
    --to=peda@axentia.se \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ludovic.desroches@microchip.com \
    --cc=nicolas.ferre@microchip.com \
    --cc=tudor.ambarus@linaro.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.