linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] dmaengine: edma/omap-dma: max_burst validity checking
@ 2017-10-03  8:35 Peter Ujfalusi
  2017-10-03  8:35 ` [PATCH v2 1/2] dmaengine: edma: Implement protection for invalid max_burst Peter Ujfalusi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2017-10-03  8:35 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams
  Cc: dmaengine, linux-kernel, linux-omap, linux-arm-kernel

Hi,

Changes since v1:
- Fixed typo in commit message
- Separated from the 'dmaengine: core/edma/omap-dma: maximum SG len reporting'
  series

Both eDMA and sDMA have limit on the maximum burst size. The two patch
implements protection against too big burst size for both driver.

Regards,
Peter
---
Peter Ujfalusi (2):
  dmaengine: edma: Implement protection for invalid max_burst
  dmaengine: omap-dma: Implement protection for invalid max_burst

 drivers/dma/edma.c     | 5 +++++
 drivers/dma/omap-dma.c | 5 +++++
 2 files changed, 10 insertions(+)

-- 
2.14.2


Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* [PATCH v2 1/2] dmaengine: edma: Implement protection for invalid max_burst
  2017-10-03  8:35 [PATCH v2 0/2] dmaengine: edma/omap-dma: max_burst validity checking Peter Ujfalusi
@ 2017-10-03  8:35 ` Peter Ujfalusi
  2017-10-03  8:35 ` [PATCH v2 2/2] dmaengine: omap-dma: " Peter Ujfalusi
  2017-10-12 16:44 ` [PATCH v2 0/2] dmaengine: edma/omap-dma: max_burst validity checking Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2017-10-03  8:35 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams
  Cc: dmaengine, linux-kernel, linux-omap, linux-arm-kernel

Set the device's max_burst to 32767 (CIDX is 16bit signed value) so clients
can take this into consideration when setting up the transfer.

During slave transfer preparation check if the requested maxburst is valid.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/dma/edma.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index a7ea20e7b8e9..9364a3ed345a 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -891,6 +891,10 @@ static int edma_slave_config(struct dma_chan *chan,
 	    cfg->dst_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES)
 		return -EINVAL;
 
+	if (cfg->src_maxburst > chan->device->max_burst ||
+	    cfg->dst_maxburst > chan->device->max_burst)
+		return -EINVAL;
+
 	memcpy(&echan->cfg, cfg, sizeof(echan->cfg));
 
 	return 0;
@@ -1868,6 +1872,7 @@ static void edma_dma_init(struct edma_cc *ecc, bool legacy_mode)
 	s_ddev->dst_addr_widths = EDMA_DMA_BUSWIDTHS;
 	s_ddev->directions |= (BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV));
 	s_ddev->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
+	s_ddev->max_burst = SZ_32K - 1; /* CIDX: 16bit signed */
 
 	s_ddev->dev = ecc->dev;
 	INIT_LIST_HEAD(&s_ddev->channels);
-- 
2.14.2


Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* [PATCH v2 2/2] dmaengine: omap-dma: Implement protection for invalid max_burst
  2017-10-03  8:35 [PATCH v2 0/2] dmaengine: edma/omap-dma: max_burst validity checking Peter Ujfalusi
  2017-10-03  8:35 ` [PATCH v2 1/2] dmaengine: edma: Implement protection for invalid max_burst Peter Ujfalusi
@ 2017-10-03  8:35 ` Peter Ujfalusi
  2017-10-12 16:44 ` [PATCH v2 0/2] dmaengine: edma/omap-dma: max_burst validity checking Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2017-10-03  8:35 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams
  Cc: dmaengine, linux-kernel, linux-omap, linux-arm-kernel, Russell King

Set the device's max_burst to 16777215 (EN is 24bit unsigned value) so
clients can take this into consideration when setting up the transfer.

During slave transfer preparation check if the requested maxburst is valid.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: Russell King <linux@armlinux.org.uk>
---
 drivers/dma/omap-dma.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index 8c1665c8fe33..f6dd849159d8 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -1288,6 +1288,10 @@ static int omap_dma_slave_config(struct dma_chan *chan, struct dma_slave_config
 	    cfg->dst_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES)
 		return -EINVAL;
 
+	if (cfg->src_maxburst > chan->device->max_burst ||
+	    cfg->dst_maxburst > chan->device->max_burst)
+		return -EINVAL;
+
 	memcpy(&c->cfg, cfg, sizeof(c->cfg));
 
 	return 0;
@@ -1482,6 +1486,7 @@ static int omap_dma_probe(struct platform_device *pdev)
 	od->ddev.dst_addr_widths = OMAP_DMA_BUSWIDTHS;
 	od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
 	od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
+	od->ddev.max_burst = SZ_16M - 1; /* CCEN: 24bit unsigned */
 	od->ddev.dev = &pdev->dev;
 	INIT_LIST_HEAD(&od->ddev.channels);
 	spin_lock_init(&od->lock);
-- 
2.14.2


Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH v2 0/2] dmaengine: edma/omap-dma: max_burst validity checking
  2017-10-03  8:35 [PATCH v2 0/2] dmaengine: edma/omap-dma: max_burst validity checking Peter Ujfalusi
  2017-10-03  8:35 ` [PATCH v2 1/2] dmaengine: edma: Implement protection for invalid max_burst Peter Ujfalusi
  2017-10-03  8:35 ` [PATCH v2 2/2] dmaengine: omap-dma: " Peter Ujfalusi
@ 2017-10-12 16:44 ` Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2017-10-12 16:44 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: dan.j.williams, dmaengine, linux-kernel, linux-omap, linux-arm-kernel

On Tue, Oct 03, 2017 at 11:35:36AM +0300, Peter Ujfalusi wrote:
> Hi,
> 
> Changes since v1:
> - Fixed typo in commit message
> - Separated from the 'dmaengine: core/edma/omap-dma: maximum SG len reporting'
>   series
> 
> Both eDMA and sDMA have limit on the maximum burst size. The two patch
> implements protection against too big burst size for both driver.

I have applied these, but had to hand fix the patches. I guess you should
use gmail or someother server to send patches

-- 
~Vinod

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

end of thread, other threads:[~2017-10-12 16:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-03  8:35 [PATCH v2 0/2] dmaengine: edma/omap-dma: max_burst validity checking Peter Ujfalusi
2017-10-03  8:35 ` [PATCH v2 1/2] dmaengine: edma: Implement protection for invalid max_burst Peter Ujfalusi
2017-10-03  8:35 ` [PATCH v2 2/2] dmaengine: omap-dma: " Peter Ujfalusi
2017-10-12 16:44 ` [PATCH v2 0/2] dmaengine: edma/omap-dma: max_burst validity checking 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).