mmc: atmel-mci: fix burst/chunk size modification
PATCH 1/1 mmc: atmel-mci: fix burst/chunk size modification
This patch requires the following set of patches from slave-dma/next:
1dd1ea8 dmaengine: at_hdmac: take maxburst from slave configuration b409ebf dmaengine: at_hdmac: remove ATC_DEFAULT_CTRLA constant b89a9cb dmaengine: at_hdmac: remove some at_dma_slave comments
Regards
Ludovic
PATCH 1/1 mmc: atmel-mci: fix burst/chunk size modification
From: Nicolas Ferre <[email protected]>
The use of DMA slave config operation requires that the burst size (aka chunk size) is specified through this interface. Modify atmel-mci slave driver to use this specification on its side.
--- drivers/mmc/host/atmel-mci-regs.h | 14 ++++++++++++++ drivers/mmc/host/atmel-mci.c | 7 +++++-- 2 files changed, 19 insertions(+), 2 deletions(-)
drivers/mmc/host/atmel-mci-regs.h +14 -0
@@ -140,4 +140,18 @@#define atmci_writel (port,reg,value) \ __raw_writel((value), (port)->regs + reg) +/* +* Fix sconfig's burst size according to atmel MCI. We need to convert them as: +* 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3. +* +* This can be done by finding most significant bit set. +*/ +static inline unsigned int atmci_convert_chksize (unsigned int maxburst) +{ +if (maxburst >1 ) +return fls (maxburst) -2 ; +else +return 0 ; +} +#endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */
drivers/mmc/host/atmel-mci.c +5 -2
@@ -834,6 +834,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)enum dma_data_direction direction;enum dma_transfer_direction slave_dirn;unsigned int sglen; +u32 maxburst;u32 iflags; data->error = -EINPROGRESS ;
@@ -867,16 +868,18 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)if (!chan)return -ENODEV ; -atmci_writel (host,ATMCI_DMA ,ATMCI_DMA_CHKSIZE (3 ) |ATMCI_DMAEN ); -if (data->flags &MMC_DATA_READ ) { direction =DMA_FROM_DEVICE ; host->dma_conf.direction = slave_dirn =DMA_DEV_TO_MEM ; + maxburst =atmci_convert_chksize (host->dma_conf.src_maxburst); }else { direction =DMA_TO_DEVICE ; host->dma_conf.direction = slave_dirn =DMA_MEM_TO_DEV ; + maxburst =atmci_convert_chksize (host->dma_conf.dst_maxburst); } +atmci_writel (host,ATMCI_DMA ,ATMCI_DMA_CHKSIZE (maxburst) |ATMCI_DMAEN ); + sglen =dma_map_sg (chan->device->dev, data->sg, data->sg_len, direction);
Signature · 1 line
1.7.5.4
PATCH 1/1 mmc: atmel-mci: fix burst/chunk size modification
Hi Chris,
I was doing some tests on mmc-next and I had issues with atmel-mci and DMA because this patch was missing.
Can you pull it?
Thanks.
Regards.
Ludovic
Le 05/16/2012 04:00 PM, ludovic.desroches at atmel.com a ?crit :
Quoted 69 lines
From: Nicolas Ferre<[email protected]>
The use of DMA slave config operation requires that the burst size (aka chunk size) is specified through this interface. Modify atmel-mci slave driver to use this specification on its side.
Signed-off-by Nicolas Ferre<[email protected]>Signed-off-by Ludovic Desroches<[email protected]>--- drivers/mmc/host/atmel-mci-regs.h | 14 ++++++++++++++ drivers/mmc/host/atmel-mci.c | 7 +++++-- 2 files changed, 19 insertions(+), 2 deletions(-)drivers/mmc/host/atmel-mci-regs.h +14
-0@@ -140,4 +140,18 @@#define atmci_writel (port,reg,value) \ __raw_writel((value), (port)->regs + reg) +/* +* Fix sconfig's burst size according to atmel MCI. We need to convert them as: +* 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3. +* +* This can be done by finding most significant bit set. +*/ +static inline unsigned int atmci_convert_chksize (unsigned int maxburst) +{ +if (maxburst>1 ) +return fls (maxburst) -2 ; +else +return 0 ; +} +#endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */ drivers/mmc/host/atmel-mci.c +5
-2@@ -834,6 +834,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)enum dma_data_direction direction;enum dma_transfer_direction slave_dirn;unsigned int sglen; +u32 maxburst;u32 iflags; data->error = -EINPROGRESS ;@@ -867,16 +868,18 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)if (!chan)return -ENODEV ; -atmci_writel (host,ATMCI_DMA ,ATMCI_DMA_CHKSIZE (3 ) |ATMCI_DMAEN ); -if (data->flags&MMC_DATA_READ ) { direction =DMA_FROM_DEVICE ; host->dma_conf.direction = slave_dirn =DMA_DEV_TO_MEM ; + maxburst =atmci_convert_chksize (host->dma_conf.src_maxburst); }else { direction =DMA_TO_DEVICE ; host->dma_conf.direction = slave_dirn =DMA_MEM_TO_DEV ; + maxburst =atmci_convert_chksize (host->dma_conf.dst_maxburst); } +atmci_writel (host,ATMCI_DMA ,ATMCI_DMA_CHKSIZE (maxburst) |ATMCI_DMAEN ); + sglen =dma_map_sg (chan->device->dev, data->sg, data->sg_len, direction);
PATCH 1/1 mmc: atmel-mci: fix burst/chunk size modification
In reply to ludovic.desroches at atmel.comHi,
Quoted 6 lines · ludovic.desroches at atmel.com
From: Nicolas Ferre <[email protected]>
The use of DMA slave config operation requires that the burst size (aka chunk size) is specified through this interface. Modify atmel-mci slave driver to use this specification on its side.
Quoted 6 lines
Signed-off-by Nicolas Ferre <[email protected]>Signed-off-by Ludovic Desroches <[email protected]>--- drivers/mmc/host/atmel-mci-regs.h | 14 ++++++++++++++ drivers/mmc/host/atmel-mci.c | 7 +++++-- 2 files changed, 19 insertions(+), 2 deletions(-)
This doesn't apply:
Quoted 36 lines
drivers/mmc/host/atmel-mci-regs.h +14
-0@@ -140,4 +140,18 @@#define atmci_writel (port,reg,value) \ __raw_writel((value), (port)->regs + reg) +/* +* Fix sconfig's burst size according to atmel MCI. We need to convert them as: +* 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3. +* +* This can be done by finding most significant bit set. +*/ +static inline unsigned int atmci_convert_chksize (unsigned int maxburst) +{ +if (maxburst >1 ) +return fls (maxburst) -2 ; +else +return 0 ; +} +#endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */ drivers/mmc/host/atmel-mci.c +1
-0@@ -834,6 +834,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)enum dma_data_direction direction;enum dma_transfer_direction slave_dirn;unsigned int sglen; +u32 maxburst;u32 iflags; data->error = -EINPROGRESS ;
drivers/mmc/host/atmel-mci.c atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) · line 871
Quoted 5 lines
drivers/mmc/host/atmel-mci.c +0
-2@@ -867,16 +868,18 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)if (!chan)return -ENODEV ; -atmci_writel (host,ATMCI_DMA ,ATMCI_DMA_CHKSIZE (3 ) |ATMCI_DMAEN ); -
.. because mainline actually looks like:
if (host->caps.has_dma) atmci_writel(host, ATMCI_DMA, ATMCI_DMA_CHKSIZE(3) | ATMCI_DMAEN);
and has done since 2011-08-11. Maybe this was created against the wrong kernel version -- want to resend?
Quoted 4 lines
drivers/mmc/host/atmel-mci.c +1
-0if (data->flags &MMC_DATA_READ ) { direction =DMA_FROM_DEVICE ; host->dma_conf.direction = slave_dirn =DMA_DEV_TO_MEM ; + maxburst =atmci_convert_chksize (host->dma_conf.src_maxburst);
drivers/mmc/host/atmel-mci.c atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) · line 884
Quoted 10 lines
drivers/mmc/host/atmel-mci.c +3
-0}else { direction =DMA_TO_DEVICE ; host->dma_conf.direction = slave_dirn =DMA_MEM_TO_DEV ; + maxburst =atmci_convert_chksize (host->dma_conf.dst_maxburst); } +atmci_writel (host,ATMCI_DMA ,ATMCI_DMA_CHKSIZE (maxburst) |ATMCI_DMAEN ); + sglen =dma_map_sg (chan->device->dev, data->sg, data->sg_len, direction);
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
PATCH 1/1 mmc: atmel-mci: fix burst/chunk size modification
From: Nicolas Ferre <[email protected]>
The use of DMA slave config operation requires that the burst size (aka chunk size) is specified through this interface. Modify atmel-mci slave driver to use this specification on its side.
---
Hi Chris,
Sorry for this trouble, this patch should apply well on 3.5-rc1.
Thanks
Regards
Ludovic
drivers/mmc/host/atmel-mci-regs.h | 14 ++++++++++++++ drivers/mmc/host/atmel-mci.c | 8 +++++--- 2 files changed, 19 insertions(+), 3 deletions(-)
drivers/mmc/host/atmel-mci-regs.h +14 -0
@@ -140,4 +140,18 @@#define atmci_writel (port,reg,value) \ __raw_writel((value), (port)->regs + reg) +/* +* Fix sconfig's burst size according to atmel MCI. We need to convert them as: +* 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3. +* +* This can be done by finding most significant bit set. +*/ +static inline unsigned int atmci_convert_chksize (unsigned int maxburst) +{ +if (maxburst >1 ) +return fls (maxburst) -2 ; +else +return 0 ; +} +#endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */
drivers/mmc/host/atmel-mci.c +5 -3
@@ -910,6 +910,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)enum dma_data_direction direction;enum dma_transfer_direction slave_dirn;unsigned int sglen; +u32 maxburst;u32 iflags; data->error = -EINPROGRESS ;
@@ -943,17 +944,18 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)if (!chan)return -ENODEV ; -if (host->caps.has_dma) -atmci_writel (host,ATMCI_DMA ,ATMCI_DMA_CHKSIZE (3 ) |ATMCI_DMAEN ); -if (data->flags &MMC_DATA_READ ) { direction =DMA_FROM_DEVICE ; host->dma_conf.direction = slave_dirn =DMA_DEV_TO_MEM ; + maxburst =atmci_convert_chksize (host->dma_conf.src_maxburst); }else { direction =DMA_TO_DEVICE ; host->dma_conf.direction = slave_dirn =DMA_MEM_TO_DEV ; + maxburst =atmci_convert_chksize (host->dma_conf.dst_maxburst); } +atmci_writel (host,ATMCI_DMA ,ATMCI_DMA_CHKSIZE (maxburst) |ATMCI_DMAEN ); + sglen =dma_map_sg (chan->device->dev, data->sg, data->sg_len, direction);
Signature · 1 line
1.7.5.4
PATCH 1/1 mmc: atmel-mci: fix burst/chunk size modification
Hi,
Quoted 6 lines · ludovic.desroches at atmel.com
From: Nicolas Ferre <[email protected]>
The use of DMA slave config operation requires that the burst size (aka chunk size) is specified through this interface. Modify atmel-mci slave driver to use this specification on its side.
Quoted 6 lines
Signed-off-by Nicolas Ferre <[email protected]>Signed-off-by Ludovic Desroches <[email protected]>---
Hi Chris,Sorry for this trouble, this patch should apply well on 3.5-rc1.
Thanks, pushed to mmc-next for 3.5.
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child