Thread (37 messages) 37 messages, 4 authors, 2012-01-06
STALE5279d
Revisions (3)
  1. v1 [diff vs current]
  2. v1 [diff vs current]
  3. v1 current

[PATCH 2/9] arm/tegra: use APB DMA for accessing APB devices

From: Olof Johansson <hidden>
Date: 2012-01-04 23:39:20
Also in: linux-tegra

On Wed, Jan 4, 2012 at 2:08 PM, Stephen Warren [off-list ref] wrote:
Olof Johansson wrote at Thursday, December 22, 2011 5:18 PM:
quoted
Tegra2 hangs if APB registers are accessed from the cpu during an
apb dma operation. The workaround is to use apb dma to read/write the
registers instead.
...
quoted
diff --git a/arch/arm/mach-tegra/apbio.c b/arch/arm/mach-tegra/apbio.c
...
quoted
+bool tegra_apb_init(void)
+{
...
quoted
+out:
+ ? ? mutex_unlock(&tegra_apb_dma_lock);
+ ? ? return true;
+
+out_fail:
+ ? ? mutex_unlock(&tegra_apb_dma_lock);
+ ? ? return true;
Presumably that should be "return false".
Yes, my bad. There's an accidental chunk in a later patch that swaps
it back to false that got squashed with the wrong patch.
quoted
+u32 tegra_apb_readl(unsigned long offset)
+{
+ ? ? struct tegra_dma_req req;
+ ? ? int ret;
+
+ ? ? if (!tegra_apb_dma && !tegra_apb_init())
+ ? ? ? ? ? ? return readl(IO_TO_VIRT(offset));
+
+ ? ? mutex_lock(&tegra_apb_dma_lock);
+ ? ? req.complete = apb_dma_complete;
+ ? ? req.to_memory = 1;
+ ? ? req.dest_addr = tegra_apb_bb_phys;
+ ? ? req.dest_bus_width = 32;
+ ? ? req.dest_wrap = 1;
+ ? ? req.source_addr = offset;
+ ? ? req.source_bus_width = 32;
+ ? ? req.source_wrap = 4;
+ ? ? req.req_sel = 0;
Should that be TEGRA_DMA_REQ_SEL_CNTR instead of 0? Although I'm not
sure what "CNTR" means, and the documentation doesn't seem to say.
Sure, will update.
quoted
+ ? ? req.size = 4;
+
+ ? ? INIT_COMPLETION(tegra_apb_wait);
+
+ ? ? tegra_dma_enqueue_req(tegra_apb_dma, &req);
+
+ ? ? ret = wait_for_completion_timeout(&tegra_apb_wait,
+ ? ? ? ? ? ? msecs_to_jiffies(50));
+
+ ? ? if (WARN(ret == 0, "apb read dma timed out"))
+ ? ? ? ? ? ? *(u32 *)tegra_apb_bb = 0;
On failure, you should probably call tegra_dma_dequeue_req() to cancel
the DMA request, otherwise (a) it'll wake up and trash some future
transfer, or (b) it'll be in the queue forever, and prevent any future
DMA requests from being programmed into HW.

Those two comments repeated from tegra_apb_writel().
Good point, will update.


-Olof
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help