[added to the 3.18 stable tree] dmaengine: omap-dma: Fix memory leak when terminating running transfer

2015-04-23 Thread Sasha Levin
From: Peter Ujfalusi peter.ujfal...@ti.com

This patch has been added to the 3.18 stable tree. If you have any
objections, please let us know.

===

[ Upstream commit 02d88b735f5a60f04dbf6d051b76e1877a0d0844 ]

In omap_dma_start_desc the vdesc-node is removed from the virt-dma
framework managed lists (to be precise from the desc_issued list).
If a terminate_all comes before the transfer finishes the omap_desc will
not be freed up because it is not in any of the lists and we stopped the
DMA channel so the transfer will not going to complete.
There is no special sequence for leaking memory when using cyclic (audio)
transfer: with every start and stop of a cyclic transfer the driver leaks
struct omap_desc worth of memory.

Free up the allocated memory directly in omap_dma_terminate_all() since the
framework will not going to do that for us.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
CC: sta...@vger.kernel.org
CC: linux-omap@vger.kernel.org
Signed-off-by: Vinod Koul vinod.k...@intel.com
Signed-off-by: Sasha Levin sasha.le...@oracle.com
---
 drivers/dma/omap-dma.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index bbea824..f477f3b 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -978,6 +978,7 @@ static int omap_dma_terminate_all(struct omap_chan *c)
 * c-desc is NULL and exit.)
 */
if (c-desc) {
+   omap_dma_desc_free(c-desc-vd);
c-desc = NULL;
/* Avoid stopping the dma twice */
if (!c-paused)
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[added to the 3.18 stable tree] dmaengine: edma: fix memory leak when terminating running transfers

2015-04-23 Thread Sasha Levin
From: Petr Kulhavy p...@barix.com

This patch has been added to the 3.18 stable tree. If you have any
objections, please let us know.

===

[ Upstream commit 5ca9e7ce6eebec53362ff779264143860ccf68cd ]

If edma_terminate_all() was called while a transfer was running (i.e. after
edma_execute() but before edma_callback()) the echan-edesc was not freed.

This was due to the fact that a running transfer is on none of the
vchan lists: desc_submitted, desc_issued, desc_completed (edma_execute()
removes it from the desc_issued list), so the vchan_dma_desc_free_list()
called at the end of edma_terminate_all() didn't find it and didn't free it.

This bug was found on an AM1808 based hardware (very similar to da850evm,
however using the second MMC/SD controller), where intense operations on the SD
card wasted the device 128MB RAM within a couple of days.

Peter Ujfalusi:
The issue is even more severe since it affects cyclic (audio) transfers as
well. In this case starting/stopping audio will results memory leak.

Signed-off-by: Petr Kulhavy p...@barix.com
Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
CC: sta...@vger.kernel.org
CC: linux-omap@vger.kernel.org
Signed-off-by: Vinod Koul vinod.k...@intel.com
Signed-off-by: Sasha Levin sasha.le...@oracle.com
---
 drivers/dma/edma.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index 4cfaaa5..abff66c 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -258,6 +258,13 @@ static int edma_terminate_all(struct edma_chan *echan)
 */
if (echan-edesc) {
int cyclic = echan-edesc-cyclic;
+
+   /*
+* free the running request descriptor
+* since it is not in any of the vdesc lists
+*/
+   edma_desc_free(echan-edesc-vdesc);
+
echan-edesc = NULL;
edma_stop(echan-ch_num);
/* Move the cyclic channel back to default queue */
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mmc: omap_hsmmc: correct precedence of operators

2012-12-20 Thread Sasha Levin
With the current code, the condition in the if() doesn't make much sense due to
precedence of operators.

Signed-off-by: Sasha Levin sasha.le...@oracle.com
---
 drivers/mmc/host/omap_hsmmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index bc58078..3ee2664 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -611,7 +611,7 @@ static int omap_hsmmc_context_restore(struct 
omap_hsmmc_host *host)
if (host-context_loss == context_loss)
return 1;
 
-   if (!OMAP_HSMMC_READ(host-base, SYSSTATUS)  RESETDONE)
+   if (!(OMAP_HSMMC_READ(host-base, SYSSTATUS)  RESETDONE))
return 1;
 
if (host-pdata-controller_flags  OMAP_HSMMC_SUPPORTS_DUAL_VOLT) {
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ARM: OMAP1: use BUG_ON where possible

2012-11-08 Thread Sasha Levin
Just use BUG_ON() instead of constructions such as:

if (...)
BUG()

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression e;
@@
- if (e) BUG();
+ BUG_ON(e);
// /smpl

Signed-off-by: Sasha Levin sasha.le...@oracle.com
---
 arch/arm/mach-omap1/board-fsample.c  |3 +--
 arch/arm/mach-omap1/board-h2.c   |3 +--
 arch/arm/mach-omap1/board-h3.c   |3 +--
 arch/arm/mach-omap1/board-perseus2.c |3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap1/board-fsample.c 
b/arch/arm/mach-omap1/board-fsample.c
index 8b5800a..7ca6cc4 100644
--- a/arch/arm/mach-omap1/board-fsample.c
+++ b/arch/arm/mach-omap1/board-fsample.c
@@ -307,8 +307,7 @@ static void __init omap_fsample_init(void)
 
fsample_init_smc91x();
 
-   if (gpio_request(FSAMPLE_NAND_RB_GPIO_PIN, NAND ready)  0)
-   BUG();
+   BUG_ON(gpio_request(FSAMPLE_NAND_RB_GPIO_PIN, NAND ready)  0);
gpio_direction_input(FSAMPLE_NAND_RB_GPIO_PIN);
 
omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index 9134b64..4953cf7 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -412,8 +412,7 @@ static void __init h2_init(void)
 
h2_nand_resource.end = h2_nand_resource.start = OMAP_CS2B_PHYS;
h2_nand_resource.end += SZ_4K - 1;
-   if (gpio_request(H2_NAND_RB_GPIO_PIN, NAND ready)  0)
-   BUG();
+   BUG_ON(gpio_request(H2_NAND_RB_GPIO_PIN, NAND ready)  0);
gpio_direction_input(H2_NAND_RB_GPIO_PIN);
 
omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index bf213d1..563ba16 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -406,8 +406,7 @@ static void __init h3_init(void)
 
nand_resource.end = nand_resource.start = OMAP_CS2B_PHYS;
nand_resource.end += SZ_4K - 1;
-   if (gpio_request(H3_NAND_RB_GPIO_PIN, NAND ready)  0)
-   BUG();
+   BUG_ON(gpio_request(H3_NAND_RB_GPIO_PIN, NAND ready)  0);
gpio_direction_input(H3_NAND_RB_GPIO_PIN);
 
/* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */
diff --git a/arch/arm/mach-omap1/board-perseus2.c 
b/arch/arm/mach-omap1/board-perseus2.c
index 030bd48..67c2612 100644
--- a/arch/arm/mach-omap1/board-perseus2.c
+++ b/arch/arm/mach-omap1/board-perseus2.c
@@ -275,8 +275,7 @@ static void __init omap_perseus2_init(void)
 
perseus2_init_smc91x();
 
-   if (gpio_request(P2_NAND_RB_GPIO_PIN, NAND ready)  0)
-   BUG();
+   BUG_ON(gpio_request(P2_NAND_RB_GPIO_PIN, NAND ready)  0);
gpio_direction_input(P2_NAND_RB_GPIO_PIN);
 
omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC 7/8] drivers: introduce rpmsg, a remote-processor messaging bus

2011-06-21 Thread Sasha Levin
On Wed, 2011-06-22 at 12:12 +0930, Rusty Russell wrote:
  +#define VIRTIO_ID_RPMSG10 /* virtio remote processor messaging 
  */
 
 I think you want 6.  Plan 9 jumped ahead to grab 9 :)

Maybe it's worth adding an appendix to the virtio spec as part of this
(and really any) patch series which takes a virtio ID.

Also, I understand that virtio itself as an idea isn't Linux specific,
but maybe it's worth including the spec (or at least a variation of it)
as part of the kernel documentation.

-- 

Sasha.


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html