LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v1 1/3] dmaengine: dw: Remove error message from DT parsing code
@ 2021-08-02 18:43 Andy Shevchenko
  2021-08-02 18:43 ` [PATCH v1 2/3] dmaengine: dw: Convert members to u32 in platform data Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Andy Shevchenko @ 2021-08-02 18:43 UTC (permalink / raw)
  To: Andy Shevchenko, dmaengine, linux-kernel; +Cc: Viresh Kumar, Vinod Koul

Users are a bit frightened of the harmless message that tells that
DT is missed on ACPI-based platforms. Remove it for good, it will
simplify the future conversion to fwnode and device property APIs.

Fixes: a9ddb575d6d6 ("dmaengine: dw_dmac: Enhance device tree support")
Depends-on: f5e84eae7956 ("dmaengine: dw: platform: Split OF helpers to separate module")
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199379
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dw/of.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/dma/dw/of.c b/drivers/dma/dw/of.c
index c1cf7675b9d1..4d2b89142721 100644
--- a/drivers/dma/dw/of.c
+++ b/drivers/dma/dw/of.c
@@ -54,11 +54,6 @@ struct dw_dma_platform_data *dw_dma_parse_dt(struct platform_device *pdev)
 	u32 nr_masters;
 	u32 nr_channels;
 
-	if (!np) {
-		dev_err(&pdev->dev, "Missing DT data\n");
-		return NULL;
-	}
-
 	if (of_property_read_u32(np, "dma-masters", &nr_masters))
 		return NULL;
 	if (nr_masters < 1 || nr_masters > DW_DMA_MAX_NR_MASTERS)
-- 
2.30.2


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

* [PATCH v1 2/3] dmaengine: dw: Convert members to u32 in platform data
  2021-08-02 18:43 [PATCH v1 1/3] dmaengine: dw: Remove error message from DT parsing code Andy Shevchenko
@ 2021-08-02 18:43 ` Andy Shevchenko
  2021-08-02 18:43 ` [PATCH v1 3/3] dmaengine: dw: Simplify DT property parser Andy Shevchenko
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2021-08-02 18:43 UTC (permalink / raw)
  To: Andy Shevchenko, dmaengine, linux-kernel; +Cc: Viresh Kumar, Vinod Koul

u32 is a type that is used for properties retrieval from DT.
With the type change it allows to clean up properties reading routine.

While at it, order the fields in way how they are parsed.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/platform_data/dma-dw.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/linux/platform_data/dma-dw.h b/include/linux/platform_data/dma-dw.h
index b11b0c8bc5da..860ba4bc5ead 100644
--- a/include/linux/platform_data/dma-dw.h
+++ b/include/linux/platform_data/dma-dw.h
@@ -41,11 +41,11 @@ struct dw_dma_slave {
 
 /**
  * struct dw_dma_platform_data - Controller configuration parameters
+ * @nr_masters: Number of AHB masters supported by the controller
  * @nr_channels: Number of channels supported by hardware (max 8)
  * @chan_allocation_order: Allocate channels starting from 0 or 7
  * @chan_priority: Set channel priority increasing from 0 to 7 or 7 to 0.
  * @block_size: Maximum block size supported by the controller
- * @nr_masters: Number of AHB masters supported by the controller
  * @data_width: Maximum data width supported by hardware per AHB master
  *		(in bytes, power of 2)
  * @multi_block: Multi block transfers supported by hardware per channel.
@@ -55,25 +55,25 @@ struct dw_dma_slave {
  * @quirks: Optional platform quirks.
  */
 struct dw_dma_platform_data {
-	unsigned int	nr_channels;
+	u32		nr_masters;
+	u32		nr_channels;
 #define CHAN_ALLOCATION_ASCENDING	0	/* zero to seven */
 #define CHAN_ALLOCATION_DESCENDING	1	/* seven to zero */
-	unsigned char	chan_allocation_order;
+	u32		chan_allocation_order;
 #define CHAN_PRIORITY_ASCENDING		0	/* chan0 highest */
 #define CHAN_PRIORITY_DESCENDING	1	/* chan7 highest */
-	unsigned char	chan_priority;
-	unsigned int	block_size;
-	unsigned char	nr_masters;
-	unsigned char	data_width[DW_DMA_MAX_NR_MASTERS];
-	unsigned char	multi_block[DW_DMA_MAX_NR_CHANNELS];
+	u32		chan_priority;
+	u32		block_size;
+	u32		data_width[DW_DMA_MAX_NR_MASTERS];
+	u32		multi_block[DW_DMA_MAX_NR_CHANNELS];
 	u32		max_burst[DW_DMA_MAX_NR_CHANNELS];
 #define CHAN_PROTCTL_PRIVILEGED		BIT(0)
 #define CHAN_PROTCTL_BUFFERABLE		BIT(1)
 #define CHAN_PROTCTL_CACHEABLE		BIT(2)
 #define CHAN_PROTCTL_MASK		GENMASK(2, 0)
-	unsigned char	protctl;
+	u32		protctl;
 #define DW_DMA_QUIRK_XBAR_PRESENT	BIT(0)
-	unsigned int	quirks;
+	u32		quirks;
 };
 
 #endif /* _PLATFORM_DATA_DMA_DW_H */
-- 
2.30.2


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

* [PATCH v1 3/3] dmaengine: dw: Simplify DT property parser
  2021-08-02 18:43 [PATCH v1 1/3] dmaengine: dw: Remove error message from DT parsing code Andy Shevchenko
  2021-08-02 18:43 ` [PATCH v1 2/3] dmaengine: dw: Convert members to u32 in platform data Andy Shevchenko
@ 2021-08-02 18:43 ` Andy Shevchenko
  2021-08-04  9:46 ` [PATCH v1 1/3] dmaengine: dw: Remove error message from DT parsing code Serge Semin
  2021-08-06 13:49 ` Vinod Koul
  3 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2021-08-02 18:43 UTC (permalink / raw)
  To: Andy Shevchenko, dmaengine, linux-kernel; +Cc: Viresh Kumar, Vinod Koul

Since we converted internal data types to match DT, there is no need to have
an intermediate conversion layer, hence drop a few conditionals and for loops
for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dw/of.c | 44 ++++++++++++++++----------------------------
 1 file changed, 16 insertions(+), 28 deletions(-)

diff --git a/drivers/dma/dw/of.c b/drivers/dma/dw/of.c
index 4d2b89142721..523ca806837c 100644
--- a/drivers/dma/dw/of.c
+++ b/drivers/dma/dw/of.c
@@ -50,7 +50,7 @@ struct dw_dma_platform_data *dw_dma_parse_dt(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct dw_dma_platform_data *pdata;
-	u32 tmp, arr[DW_DMA_MAX_NR_MASTERS], mb[DW_DMA_MAX_NR_CHANNELS];
+	u32 tmp, arr[DW_DMA_MAX_NR_MASTERS];
 	u32 nr_masters;
 	u32 nr_channels;
 
@@ -71,41 +71,29 @@ struct dw_dma_platform_data *dw_dma_parse_dt(struct platform_device *pdev)
 	pdata->nr_masters = nr_masters;
 	pdata->nr_channels = nr_channels;
 
-	if (!of_property_read_u32(np, "chan_allocation_order", &tmp))
-		pdata->chan_allocation_order = (unsigned char)tmp;
+	of_property_read_u32(np, "chan_allocation_order", &pdata->chan_allocation_order);
+	of_property_read_u32(np, "chan_priority", &pdata->chan_priority);
 
-	if (!of_property_read_u32(np, "chan_priority", &tmp))
-		pdata->chan_priority = tmp;
+	of_property_read_u32(np, "block_size", &pdata->block_size);
 
-	if (!of_property_read_u32(np, "block_size", &tmp))
-		pdata->block_size = tmp;
-
-	if (!of_property_read_u32_array(np, "data-width", arr, nr_masters)) {
-		for (tmp = 0; tmp < nr_masters; tmp++)
-			pdata->data_width[tmp] = arr[tmp];
-	} else if (!of_property_read_u32_array(np, "data_width", arr, nr_masters)) {
+	/* Try deprecated property first */
+	if (!of_property_read_u32_array(np, "data_width", arr, nr_masters)) {
 		for (tmp = 0; tmp < nr_masters; tmp++)
 			pdata->data_width[tmp] = BIT(arr[tmp] & 0x07);
 	}
 
-	if (!of_property_read_u32_array(np, "multi-block", mb, nr_channels)) {
-		for (tmp = 0; tmp < nr_channels; tmp++)
-			pdata->multi_block[tmp] = mb[tmp];
-	} else {
-		for (tmp = 0; tmp < nr_channels; tmp++)
-			pdata->multi_block[tmp] = 1;
-	}
+	/* If "data_width" and "data-width" both provided use the latter one */
+	of_property_read_u32_array(np, "data-width", pdata->data_width, nr_masters);
 
-	if (of_property_read_u32_array(np, "snps,max-burst-len", pdata->max_burst,
-				       nr_channels)) {
-		memset32(pdata->max_burst, DW_DMA_MAX_BURST, nr_channels);
-	}
+	memset32(pdata->multi_block, 1, nr_channels);
+	of_property_read_u32_array(np, "multi-block", pdata->multi_block, nr_channels);
 
-	if (!of_property_read_u32(np, "snps,dma-protection-control", &tmp)) {
-		if (tmp > CHAN_PROTCTL_MASK)
-			return NULL;
-		pdata->protctl = tmp;
-	}
+	memset32(pdata->max_burst, DW_DMA_MAX_BURST, nr_channels);
+	of_property_read_u32_array(np, "snps,max-burst-len", pdata->max_burst, nr_channels);
+
+	of_property_read_u32(np, "snps,dma-protection-control", &pdata->protctl);
+	if (pdata->protctl > CHAN_PROTCTL_MASK)
+		return NULL;
 
 	return pdata;
 }
-- 
2.30.2


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

* Re: [PATCH v1 1/3] dmaengine: dw: Remove error message from DT parsing code
  2021-08-02 18:43 [PATCH v1 1/3] dmaengine: dw: Remove error message from DT parsing code Andy Shevchenko
  2021-08-02 18:43 ` [PATCH v1 2/3] dmaengine: dw: Convert members to u32 in platform data Andy Shevchenko
  2021-08-02 18:43 ` [PATCH v1 3/3] dmaengine: dw: Simplify DT property parser Andy Shevchenko
@ 2021-08-04  9:46 ` Serge Semin
  2021-08-04 11:03   ` Andy Shevchenko
  2021-08-06 13:49 ` Vinod Koul
  3 siblings, 1 reply; 6+ messages in thread
From: Serge Semin @ 2021-08-04  9:46 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Serge Semin, dmaengine, linux-kernel, Viresh Kumar, Vinod Koul

Hello Andy

On Mon, Aug 02, 2021 at 09:43:53PM +0300, Andy Shevchenko wrote:
> Users are a bit frightened of the harmless message that tells that
> DT is missed on ACPI-based platforms. Remove it for good, it will
> simplify the future conversion to fwnode and device property APIs.

Thanks for the cleanup patchset. No comments from me, just the tags
for the whole series:
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Tested-by: Serge Semin <fancer.lancer@gmail.com>
[Tested on Baikal-T1 DW DMAC with 8 channels, 12 requests, 2 masters,
no multi-block support and uneven max burst length setup]

-Sergey

> 
> Fixes: a9ddb575d6d6 ("dmaengine: dw_dmac: Enhance device tree support")
> Depends-on: f5e84eae7956 ("dmaengine: dw: platform: Split OF helpers to separate module")
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199379
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/dma/dw/of.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/dma/dw/of.c b/drivers/dma/dw/of.c
> index c1cf7675b9d1..4d2b89142721 100644
> --- a/drivers/dma/dw/of.c
> +++ b/drivers/dma/dw/of.c
> @@ -54,11 +54,6 @@ struct dw_dma_platform_data *dw_dma_parse_dt(struct platform_device *pdev)
>  	u32 nr_masters;
>  	u32 nr_channels;
>  
> -	if (!np) {
> -		dev_err(&pdev->dev, "Missing DT data\n");
> -		return NULL;
> -	}
> -
>  	if (of_property_read_u32(np, "dma-masters", &nr_masters))
>  		return NULL;
>  	if (nr_masters < 1 || nr_masters > DW_DMA_MAX_NR_MASTERS)
> -- 
> 2.30.2
> 

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

* Re: [PATCH v1 1/3] dmaengine: dw: Remove error message from DT parsing code
  2021-08-04  9:46 ` [PATCH v1 1/3] dmaengine: dw: Remove error message from DT parsing code Serge Semin
@ 2021-08-04 11:03   ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2021-08-04 11:03 UTC (permalink / raw)
  To: Serge Semin
  Cc: Andy Shevchenko, Serge Semin, dmaengine,
	Linux Kernel Mailing List, Viresh Kumar, Vinod Koul

On Wed, Aug 4, 2021 at 1:50 PM Serge Semin <fancer.lancer@gmail.com> wrote:
> On Mon, Aug 02, 2021 at 09:43:53PM +0300, Andy Shevchenko wrote:
> > Users are a bit frightened of the harmless message that tells that
> > DT is missed on ACPI-based platforms. Remove it for good, it will
> > simplify the future conversion to fwnode and device property APIs.
>
> Thanks for the cleanup patchset. No comments from me, just the tags
> for the whole series:
> Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
> Tested-by: Serge Semin <fancer.lancer@gmail.com>
> [Tested on Baikal-T1 DW DMAC with 8 channels, 12 requests, 2 masters,
> no multi-block support and uneven max burst length setup]

Thank you, appreciate it!

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v1 1/3] dmaengine: dw: Remove error message from DT parsing code
  2021-08-02 18:43 [PATCH v1 1/3] dmaengine: dw: Remove error message from DT parsing code Andy Shevchenko
                   ` (2 preceding siblings ...)
  2021-08-04  9:46 ` [PATCH v1 1/3] dmaengine: dw: Remove error message from DT parsing code Serge Semin
@ 2021-08-06 13:49 ` Vinod Koul
  3 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2021-08-06 13:49 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: dmaengine, linux-kernel, Viresh Kumar

On 02-08-21, 21:43, Andy Shevchenko wrote:
> Users are a bit frightened of the harmless message that tells that
> DT is missed on ACPI-based platforms. Remove it for good, it will
> simplify the future conversion to fwnode and device property APIs.

Applied all, thanks

-- 
~Vinod

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

end of thread, other threads:[~2021-08-06 13:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 18:43 [PATCH v1 1/3] dmaengine: dw: Remove error message from DT parsing code Andy Shevchenko
2021-08-02 18:43 ` [PATCH v1 2/3] dmaengine: dw: Convert members to u32 in platform data Andy Shevchenko
2021-08-02 18:43 ` [PATCH v1 3/3] dmaengine: dw: Simplify DT property parser Andy Shevchenko
2021-08-04  9:46 ` [PATCH v1 1/3] dmaengine: dw: Remove error message from DT parsing code Serge Semin
2021-08-04 11:03   ` Andy Shevchenko
2021-08-06 13:49 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).