Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
* [PATCH] mmc: omap_hsmmc: Initialize dma_slave_config to avoid random data
@ 2016-09-14 10:10 Peter Ujfalusi
  2016-09-14 10:23 ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Ujfalusi @ 2016-09-14 10:10 UTC (permalink / raw)
  To: ulf.hansson; +Cc: tony, kishon, linux-omap, linux-mmc, linux-kernel

It is wrong to not initialize the dma_slave_config struct as the DMAengine
driver might look at non initialized (random data) fields and tries to
interpret it.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
Hi,

would it be possible to send this patch for 4.8? I have omap-dma DMAengine
driver changes pending, but they break the MMC/SD because of the uninitialized
fields in dma_slave_config.

Thanks,
Peter

 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 24ebc9a8de89..0a5640156159 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1409,7 +1409,7 @@ static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host,
 static int omap_hsmmc_setup_dma_transfer(struct omap_hsmmc_host *host,
 					struct mmc_request *req)
 {
-	struct dma_slave_config cfg;
+	struct dma_slave_config cfg = {};
 	struct dma_async_tx_descriptor *tx;
 	int ret = 0, i;
 	struct mmc_data *data = req->data;
--
2.10.0


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

* Re: [PATCH] mmc: omap_hsmmc: Initialize dma_slave_config to avoid random data
  2016-09-14 10:10 [PATCH] mmc: omap_hsmmc: Initialize dma_slave_config to avoid random data Peter Ujfalusi
@ 2016-09-14 10:23 ` Arnd Bergmann
  2016-09-14 10:52   ` Ulf Hansson
  2016-09-14 10:59   ` Peter Ujfalusi
  0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2016-09-14 10:23 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: ulf.hansson, tony, kishon, linux-omap, linux-mmc, linux-kernel

On Wednesday, September 14, 2016 1:10:48 PM CEST Peter Ujfalusi wrote:
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 24ebc9a8de89..0a5640156159 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -1409,7 +1409,7 @@ static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host,
>  static int omap_hsmmc_setup_dma_transfer(struct omap_hsmmc_host *host,
>                                         struct mmc_request *req)
>  {
> -       struct dma_slave_config cfg;
> +       struct dma_slave_config cfg = {};
>         struct dma_async_tx_descriptor *tx;
>         int ret = 0, i;
>         struct mmc_data *data = req->data;
> 

This change looks correct and is certainly the simplest solution if you want to
get it into v4.8, but generally speaking, I think it would be nicer to combine
it with the initialization of the fields:

	struct dma_slave_config cfg = {
		  .src_addr = host->mapbase + OMAP_HSMMC_DATA;
        .dst_addr = host->mapbase + OMAP_HSMMC_DATA;
        .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
        .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
        .src_maxburst = data->blksz / 4;
        .dst_maxburst = data->blksz / 4;
	};

	Arnd

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

* Re: [PATCH] mmc: omap_hsmmc: Initialize dma_slave_config to avoid random data
  2016-09-14 10:23 ` Arnd Bergmann
@ 2016-09-14 10:52   ` Ulf Hansson
  2016-09-14 10:59   ` Peter Ujfalusi
  1 sibling, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2016-09-14 10:52 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Peter Ujfalusi, Tony Lindgren, Kishon, linux-omap, linux-mmc,
	linux-kernel@vger.kernel.org

On 14 September 2016 at 12:23, Arnd Bergmann <arnd@arndb.de> wrote:
> On Wednesday, September 14, 2016 1:10:48 PM CEST Peter Ujfalusi wrote:
>> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
>> index 24ebc9a8de89..0a5640156159 100644
>> --- a/drivers/mmc/host/omap_hsmmc.c
>> +++ b/drivers/mmc/host/omap_hsmmc.c
>> @@ -1409,7 +1409,7 @@ static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host,
>>  static int omap_hsmmc_setup_dma_transfer(struct omap_hsmmc_host *host,
>>                                         struct mmc_request *req)
>>  {
>> -       struct dma_slave_config cfg;
>> +       struct dma_slave_config cfg = {};
>>         struct dma_async_tx_descriptor *tx;
>>         int ret = 0, i;
>>         struct mmc_data *data = req->data;
>>
>
> This change looks correct and is certainly the simplest solution if you want to
> get it into v4.8, but generally speaking, I think it would be nicer to combine
> it with the initialization of the fields:
>
>         struct dma_slave_config cfg = {
>                   .src_addr = host->mapbase + OMAP_HSMMC_DATA;
>         .dst_addr = host->mapbase + OMAP_HSMMC_DATA;
>         .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
>         .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
>         .src_maxburst = data->blksz / 4;
>         .dst_maxburst = data->blksz / 4;
>         };

This seems like a small an easy change as well, so I wouldn't mind
picking up a v2 adopting this pattern instead.

Kind regards
Uffe

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

* Re: [PATCH] mmc: omap_hsmmc: Initialize dma_slave_config to avoid random data
  2016-09-14 10:23 ` Arnd Bergmann
  2016-09-14 10:52   ` Ulf Hansson
@ 2016-09-14 10:59   ` Peter Ujfalusi
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2016-09-14 10:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: ulf.hansson, tony, kishon, linux-omap, linux-mmc, linux-kernel

On 09/14/16 13:23, Arnd Bergmann wrote:
> On Wednesday, September 14, 2016 1:10:48 PM CEST Peter Ujfalusi wrote:
>> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
>> index 24ebc9a8de89..0a5640156159 100644
>> --- a/drivers/mmc/host/omap_hsmmc.c
>> +++ b/drivers/mmc/host/omap_hsmmc.c
>> @@ -1409,7 +1409,7 @@ static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host,
>>  static int omap_hsmmc_setup_dma_transfer(struct omap_hsmmc_host *host,
>>                                         struct mmc_request *req)
>>  {
>> -       struct dma_slave_config cfg;
>> +       struct dma_slave_config cfg = {};
>>         struct dma_async_tx_descriptor *tx;
>>         int ret = 0, i;
>>         struct mmc_data *data = req->data;
>>
> 
> This change looks correct and is certainly the simplest solution if you want to
> get it into v4.8, but generally speaking, I think it would be nicer to combine
> it with the initialization of the fields:
> 
> 	struct dma_slave_config cfg = {
> 		  .src_addr = host->mapbase + OMAP_HSMMC_DATA;
>         .dst_addr = host->mapbase + OMAP_HSMMC_DATA;
>         .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
>         .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
>         .src_maxburst = data->blksz / 4;
>         .dst_maxburst = data->blksz / 4;

I opted to not do this because the data->blksz is validated later in the
function (twice).

It is not a big issue, but looks a bit odd.

-- 
Péter

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

end of thread, other threads:[~2016-09-14 10:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-14 10:10 [PATCH] mmc: omap_hsmmc: Initialize dma_slave_config to avoid random data Peter Ujfalusi
2016-09-14 10:23 ` Arnd Bergmann
2016-09-14 10:52   ` Ulf Hansson
2016-09-14 10:59   ` Peter Ujfalusi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox