All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] mmc/dw_mmc: Allocate the correct amount of descriptors
@ 2013-07-26 14:18 Mischa Jonker
  2013-07-26 14:18 ` [U-Boot] [PATCH 2/2] Add parentheses to ALLOC_ALIGN_BUFFER macro's Mischa Jonker
  0 siblings, 1 reply; 2+ messages in thread
From: Mischa Jonker @ 2013-07-26 14:18 UTC (permalink / raw)
  To: u-boot

This fixes two issues:
 * a descriptor was allocated for every block, while a descriptor can
   take 8 blocks
 * there was an off-by-one error in the descriptor preparation: there
   were two last descriptors, one with length==0

Signed-off-by: Mischa Jonker <mjonker@synopsys.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Andy Fleming <afleming@gmail.com>
---
 drivers/mmc/dw_mmc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
index 796a811..9a803a0 100644
--- a/drivers/mmc/dw_mmc.c
+++ b/drivers/mmc/dw_mmc.c
@@ -72,7 +72,7 @@ static void dwmci_prepare_data(struct dwmci_host *host,
 		dwmci_set_idma_desc(cur_idmac, flags, cnt,
 				start_addr + (i * PAGE_SIZE));
 
-		if(blk_cnt < 8)
+		if (blk_cnt <= 8)
 			break;
 		blk_cnt -= 8;
 		cur_idmac++;
@@ -111,7 +111,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 {
 	struct dwmci_host *host = (struct dwmci_host *)mmc->priv;
 	ALLOC_CACHE_ALIGN_BUFFER(struct dwmci_idmac, cur_idmac,
-				 data ? data->blocks : 0);
+				 data ? DIV_ROUND_UP(data->blocks, 8) : 0);
 	int flags = 0, i;
 	unsigned int timeout = 100000;
 	u32 retry = 10000;
-- 
1.7.9.5

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

* [U-Boot] [PATCH 2/2] Add parentheses to ALLOC_ALIGN_BUFFER macro's
  2013-07-26 14:18 [U-Boot] [PATCH 1/2] mmc/dw_mmc: Allocate the correct amount of descriptors Mischa Jonker
@ 2013-07-26 14:18 ` Mischa Jonker
  0 siblings, 0 replies; 2+ messages in thread
From: Mischa Jonker @ 2013-07-26 14:18 UTC (permalink / raw)
  To: u-boot

Without those it's very easy to make mistakes when for instance
the 'size' field is more than just a constant.

Signed-off-by: Mischa Jonker <mjonker@synopsys.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Anton Staaf <robotboy@chromium.org>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
---
 include/common.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/common.h b/include/common.h
index 8addf43..cc7454a 100644
--- a/include/common.h
+++ b/include/common.h
@@ -1015,10 +1015,10 @@ static inline phys_addr_t map_to_sysmem(void *ptr)
  * of a function scoped static buffer.  It can not be used to create a cache
  * line aligned global buffer.
  */
-#define PAD_COUNT(s, pad) ((s - 1) / pad + 1)
+#define PAD_COUNT(s, pad) (((s) - 1) / (pad) + 1)
 #define PAD_SIZE(s, pad) (PAD_COUNT(s, pad) * pad)
 #define ALLOC_ALIGN_BUFFER_PAD(type, name, size, align, pad)		\
-	char __##name[ROUND(PAD_SIZE(size * sizeof(type), pad), align)  \
+	char __##name[ROUND(PAD_SIZE((size) * sizeof(type), pad), align)  \
 		      + (align - 1)];					\
 									\
 	type *name = (type *) ALIGN((uintptr_t)__##name, align)
-- 
1.7.9.5

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

end of thread, other threads:[~2013-07-26 14:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-26 14:18 [U-Boot] [PATCH 1/2] mmc/dw_mmc: Allocate the correct amount of descriptors Mischa Jonker
2013-07-26 14:18 ` [U-Boot] [PATCH 2/2] Add parentheses to ALLOC_ALIGN_BUFFER macro's Mischa Jonker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.