Skip to contentSkip to conversation

dmaengine: dma_request_chan*() amendments

PATCH Applied Andy Shevchenko 2 participants 6 messages Feb 5, 2025 – Feb 10, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover dmaengine: dma_request_chan*() amendments

Reduce the scope of the use of some rarely used DMA request channel APIs in order to make the step of their removal or making static in the future. No functional changes intended.

In v3:
- rebased on top of v6.14-rc1

In v2:
- updated the commit messages (Frank)

Andy Shevchenko (4):
dmaengine: Replace dma_request_slave_channel() by dma_request_chan()
dmaengine: Use dma_request_channel() instead of

    __dma_request_channel()

dmaengine: Add a comment on why it's okay when kasprintf() fails
dmaengine: Unify checks in dma_request_chan()

 drivers/dma/dmaengine.c   | 16 ++++++++--------
 drivers/dma/imx-sdma.c    |  5 ++---
 include/linux/dmaengine.h |  6 +++---
 3 files changed, 13 insertions(+), 14 deletions(-)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#1 lore raw

PATCH v3 1/4 dmaengine: Replace dma_request_slave_channel() by dma_request_chan()

Replace dma_request_slave_channel() by dma_request_chan() as suggested since the former is deprecated.

---
 drivers/dma/imx-sdma.c    | 5 ++---
 include/linux/dmaengine.h | 4 ++--
 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/dma/imx-sdma.c +2 -3
index 3449006cd14b..02a85d6f1bea 100644
@@ -1459,9 +1459,8 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan)
 	 * dmatest, thus create 'struct imx_dma_data mem_data' for this case.
 	 * Please note in any other slave case, you have to setup chan->private
 	 * with 'struct imx_dma_data' in your own filter function if you want to
-	 * request dma channel by dma_request_channel() rather than
-	 * dma_request_slave_channel(). Othwise, 'MEMCPY in case?' will appear
-	 * to warn you to correct your filter function.
+	 * request DMA channel by dma_request_channel(), otherwise, 'MEMCPY in
+	 * case?' will appear to warn you to correct your filter function.
 	 */
 	if (!data) {
 		dev_dbg(sdmac->sdma->dev, "MEMCPY in case?\n");
include/linux/dmaengine.h +2 -2
index 346251bf1026..83cbf7197a76 100644
@@ -1639,8 +1639,8 @@ static inline struct dma_chan
 {
 	struct dma_chan *chan;
 
-	chan = dma_request_slave_channel(dev, name);
-	if (chan)
+	chan = dma_request_chan(dev, name);
+	if (!IS_ERR(chan))
 		return chan;
 
 	if (!fn || !fn_param)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#2 lore raw

PATCH v3 2/4 dmaengine: Use dma_request_channel() instead of __dma_request_channel()

In reply to Andy Shevchenko

Reduce use of internal __dma_request_channel() function in public dmaengine.h.

---
 include/linux/dmaengine.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/dmaengine.h +1 -1
index 83cbf7197a76..a360e0330436 100644
@@ -1646,7 +1646,7 @@ static inline struct dma_chan
 	if (!fn || !fn_param)
 		return NULL;
 
-	return __dma_request_channel(&mask, fn, fn_param, NULL);
+	return dma_request_channel(mask, fn, fn_param);
 }
 
 static inline char *
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#3 lore raw

PATCH v3 3/4 dmaengine: Add a comment on why it's okay when kasprintf() fails

In reply to Andy Shevchenko

Add a comment in dma_request_chan() to clarify kasprintf() missing return value check and it is correct functionality.

---
 drivers/dma/dmaengine.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/dmaengine.c +2 -2
index c1357d7f3dc6..dd4224d90f07 100644
@@ -854,8 +854,8 @@ struct dma_chan *dma_request_chan(struct device *dev, const char *name)
 
 found:
 #ifdef CONFIG_DEBUG_FS
-	chan->dbg_client_name = kasprintf(GFP_KERNEL, "%s:%s", dev_name(dev),
-					  name);
+	chan->dbg_client_name = kasprintf(GFP_KERNEL, "%s:%s", dev_name(dev), name);
+	/* No functional issue if it fails, users are supposed to test before use */
 #endif
 
 	chan->name = kasprintf(GFP_KERNEL, "dma:%s", name);
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#4 lore raw

PATCH v3 4/4 dmaengine: Unify checks in dma_request_chan()

In reply to Andy Shevchenko

Use dev_fwnode() to simplify the check logic for Device Tree and ACPI in dma_request_chan().

---
 drivers/dma/dmaengine.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/dma/dmaengine.c +6 -6
index dd4224d90f07..758fcd0546d8 100644
@@ -40,6 +40,8 @@
 #include <linux/dmaengine.h>
 #include <linux/hardirq.h>
 #include <linux/spinlock.h>
+#include <linux/of.h>
+#include <linux/property.h>
 #include <linux/percpu.h>
 #include <linux/rcupdate.h>
 #include <linux/mutex.h>
@@ -812,15 +814,13 @@ static const struct dma_slave_map *dma_filter_match(struct dma_device *device,
  */
 struct dma_chan *dma_request_chan(struct device *dev, const char *name)
 {
+	struct fwnode_handle *fwnode = dev_fwnode(dev);
 	struct dma_device *d, *_d;
 	struct dma_chan *chan = NULL;
 
-	/* If device-tree is present get slave info from here */
-	if (dev->of_node)
-		chan = of_dma_request_slave_channel(dev->of_node, name);
-
-	/* If device was enumerated by ACPI get slave info from here */
-	if (has_acpi_companion(dev) && !chan)
+	if (is_of_node(fwnode))
+		chan = of_dma_request_slave_channel(to_of_node(fwnode), name);
+	else if (is_acpi_device_node(fwnode))
 		chan = acpi_dma_request_slave_chan_by_name(dev, name);
 
 	if (PTR_ERR(chan) == -EPROBE_DEFER)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
maintainer Applied
#5 lore raw
In reply to Andy Shevchenko
Quoted 8 lines · Andy Shevchenko

Reduce the scope of the use of some rarely used DMA request channel APIs in order to make the step of their removal or making static in the future. No functional changes intended.

In v3:
- rebased on top of v6.14-rc1

[...]

Applied, thanks!

[1/4] dmaengine: Replace dma_request_slave_channel() by dma_request_chan()

      commit: 31d43141d13aa63587f140884b1f667800ce4e1d
[2/4] dmaengine: Use dma_request_channel() instead of __dma_request_channel()
      commit: 1c83d3dfa0905590408595560629627cba4f9261
[3/4] dmaengine: Add a comment on why it's okay when kasprintf() fails
      commit: 1722fb4a1307748f983c1345c4c24178d8e0be47
[4/4] dmaengine: Unify checks in dma_request_chan()
      commit: 91d8560c15918c7d44e4f665fac829ba8057a2f3

Best regards,

Signature · 1 line
~Vinod