<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Serverphorums.com - Linux Kernel</title>
        <description>Linux is a clone of the operating system Unix, written from scratch by Linus Torvalds with assistance from a loosely-knit team of hackers across the Net. It aims towards POSIX and Single UNIX Specification compliance. This is the archive of the linux kernel mailinglist. Archive started at 2009/09/01.</description>
        <link>http://www.serverphorums.com/list.php?12</link>
        <lastBuildDate>Fri, 24 May 2013 08:09:48 +0200</lastBuildDate>
        <generator>Phorum 5.2.18</generator>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712301,712301#msg-712301</guid>
            <title>BUG_ON in virtio-ring.c (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712301,712301#msg-712301</link>
            <description><![CDATA[ Hi Rusty,<br />
<br />
current virtio-ring.c has a BUG_ON in virtqueue_add that checks<br />
total_sg &gt; vg-&gt;vring.num, however I'm not sure it really is 100%<br />
correct.<br />
<br />
If I have an indirect ring and I'm adding sgs to it and the host is<br />
delayed (say I've got a thread consuming things from the vring and its<br />
off doing something interesting),<br />
I'd really like to get ENOSPC back from virtqueue_add. However if the<br />
indirect addition fails due to free_sg being 0, we hit the BUG_ON<br />
before we ever get to the ENOSPC check.<br />
<br />
the BUG_ON is quite valid in the no indirect case, but when we have<br />
indirect buffers it doesn't seem like it always makes sense.<br />
<br />
Not sure best way to fix it, I'm just a virtio newbie :)<br />
<br />
Dave.<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Dave Airlie</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Fri, 24 May 2013 05:50:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712288,712288#msg-712288</guid>
            <title>[PATCH] usb/xhci: unify parameter of xhci_msi_irq (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712288,712288#msg-712288</link>
            <description><![CDATA[ Ops, I just find a old patch left on my laptop. and it still works on latest<br />
Linus tree. I don't remember there is a reasonable excuse to reject this patch.<br />
<br />
So, anyone like to pick it up?<br />
<br />
------<br />
From 6ae1b9e71f9b14be5774ae9c1b4cf57cd4e747ac Mon Sep 17 00:00:00 2001<br />
From: Alex Shi &lt;alex.shi@intel.com&gt;<br />
Date: Mon, 11 Jun 2012 15:10:18 +0800<br />
Subject: [PATCH] usb/xhci: unify parameter of xhci_msi_irq<br />
<br />
According to Felipe and Alan's comments the second parameter of irq<br />
handler should be 'void *' not a specific structure pointer.<br />
So change it.<br />
<br />
Signed-off-by: Alex Shi &lt;alex.shi@intel.com&gt;<br />
Acked-by: Felipe Balbi &lt;balbi@ti.com&gt;<br />
---<br />
 drivers/usb/host/xhci-ring.c |    2 +-<br />
 drivers/usb/host/xhci.c      |    4 ++--<br />
 drivers/usb/host/xhci.h      |    2 +-<br />
 3 files changed, 4 insertions(+), 4 deletions(-)<br />
<br />
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c<br />
index 23b4aef..cc8a52f 100644<br />
--- a/drivers/usb/host/xhci-ring.c<br />
+++ b/drivers/usb/host/xhci-ring.c<br />
@@ -2479,7 +2479,7 @@ hw_died:<br />
 	return IRQ_HANDLED;<br />
 }<br />
 <br />
-irqreturn_t xhci_msi_irq(int irq, struct usb_hcd *hcd)<br />
+irqreturn_t xhci_msi_irq(int irq, void *hcd)<br />
 {<br />
 	return xhci_irq(hcd);<br />
 }<br />
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c<br />
index afdc73e..f7d40c1 100644<br />
--- a/drivers/usb/host/xhci.c<br />
+++ b/drivers/usb/host/xhci.c<br />
@@ -215,7 +215,7 @@ static int xhci_setup_msi(struct xhci_hcd *xhci)<br />
 		return ret;<br />
 	}<br />
 <br />
-	ret = request_irq(pdev-&gt;irq, (irq_handler_t)xhci_msi_irq,<br />
+	ret = request_irq(pdev-&gt;irq, xhci_msi_irq,<br />
 				0, &quot;xhci_hcd&quot;, xhci_to_hcd(xhci));<br />
 	if (ret) {<br />
 		xhci_dbg(xhci, &quot;disable MSI interrupt\n&quot;);<br />
@@ -287,7 +287,7 @@ static int xhci_setup_msix(struct xhci_hcd *xhci)<br />
 <br />
 	for (i = 0; i &lt; xhci-&gt;msix_count; i++) {<br />
 		ret = request_irq(xhci-&gt;msix_entries<i>.vector,<br />
-				(irq_handler_t)xhci_msi_irq,<br />
+				xhci_msi_irq,<br />
 				0, &quot;xhci_hcd&quot;, xhci_to_hcd(xhci));<br />
 		if (ret)<br />
 			goto disable_msix;<br />
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h<br />
index de3d6e3..737ef54 100644<br />
--- a/drivers/usb/host/xhci.h<br />
+++ b/drivers/usb/host/xhci.h<br />
@@ -1710,7 +1710,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated);<br />
 <br />
 int xhci_get_frame(struct usb_hcd *hcd);<br />
 irqreturn_t xhci_irq(struct usb_hcd *hcd);<br />
-irqreturn_t xhci_msi_irq(int irq, struct usb_hcd *hcd);<br />
+irqreturn_t xhci_msi_irq(int irq, void *hcd);<br />
 int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev);<br />
 void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev);<br />
 int xhci_alloc_tt_info(struct xhci_hcd *xhci,<br />
-- <br />
1.7.5.4<br />
<br />
-- <br />
Thanks<br />
    Alex<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a></i>]]></description>
            <dc:creator>Alex Shi</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Fri, 24 May 2013 05:00:03 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712285,712285#msg-712285</guid>
            <title>[PATCH 3.9-stable] staging:iio:light:tsl2x7x: fix the error handling in tsl2x7x_probe() (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712285,712285#msg-712285</link>
            <description><![CDATA[ This patch looks like it should be in the 3.9-stable tree, should we apply<br />
it?<br />
<br />
------------------<br />
<br />
From: &quot;Wei Yongjun &lt;yongjun_wei@trendmicro.com.cn&gt;&quot;<br />
<br />
commit 3b813798aa7030f1beef638c75f8b0008f737a82 upstream<br />
<br />
Fix to return -EINVAL in the i2c device found error handling<br />
case instead of 0, as done elsewhere in this function.<br />
And also correct the fail1 and fail2 lable to do the right thing.<br />
<br />
Signed-off-by: Wei Yongjun &lt;yongjun_wei@trendmicro.com.cn&gt;<br />
Signed-off-by: Jonathan Cameron &lt;jic23@kernel.org&gt;<br />
Signed-off-by: Jonghwan Choi &lt;jhbird.choi@samsung.com&gt;<br />
---<br />
 drivers/staging/iio/light/tsl2x7x_core.c |    9 +++++----<br />
 1 file changed, 5 insertions(+), 4 deletions(-)<br />
<br />
diff --git a/drivers/staging/iio/light/tsl2x7x_core.c<br />
b/drivers/staging/iio/light/tsl2x7x_core.c<br />
index a58731e..2d40c03 100644<br />
--- a/drivers/staging/iio/light/tsl2x7x_core.c<br />
+++ b/drivers/staging/iio/light/tsl2x7x_core.c<br />
@@ -1869,6 +1869,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,<br />
 		dev_info(&amp;chip-&gt;client-&gt;dev,<br />
 				&quot;%s: i2c device found does not match<br />
expected id\n&quot;,<br />
 				__func__);<br />
+		ret = -EINVAL;<br />
 		goto fail1;<br />
 	}<br />
 <br />
@@ -1907,7 +1908,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,<br />
 		if (ret) {<br />
 			dev_err(&amp;clientp-&gt;dev,<br />
 				&quot;%s: irq request failed&quot;, __func__);<br />
-			goto fail2;<br />
+			goto fail1;<br />
 		}<br />
 	}<br />
 <br />
@@ -1920,17 +1921,17 @@ static int tsl2x7x_probe(struct i2c_client *clientp,<br />
 	if (ret) {<br />
 		dev_err(&amp;clientp-&gt;dev,<br />
 			&quot;%s: iio registration failed\n&quot;, __func__);<br />
-		goto fail1;<br />
+		goto fail2;<br />
 	}<br />
 <br />
 	dev_info(&amp;clientp-&gt;dev, &quot;%s Light sensor found.\n&quot;, id-&gt;name);<br />
 <br />
 	return 0;<br />
 <br />
-fail1:<br />
+fail2:<br />
 	if (clientp-&gt;irq)<br />
 		free_irq(clientp-&gt;irq, indio_dev);<br />
-fail2:<br />
+fail1:<br />
 	iio_device_free(indio_dev);<br />
 <br />
 	return ret;<br />
-- <br />
1.7.9.5<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Jonghwan Choi</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Fri, 24 May 2013 04:50:03 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712284,712284#msg-712284</guid>
            <title>[PATCH 3.9-stable] staging/iio/mxs-lradc: fix preenable for multiple (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712284,712284#msg-712284</link>
            <description><![CDATA[ This patch looks like it should be in the 3.9-stable tree, should we apply<br />
it?<br />
<br />
------------------<br />
<br />
From: &quot;Michał Mirosław &lt;mirq-linux@rere.qmqm.pl&gt;&quot;<br />
<br />
commit c80712c793febdf1b13ad0e1c71a051e071b3fd8 upstream<br />
<br />
This fixes 'preenable failed: -EINVAL' error when using this driver.<br />
<br />
Signed-off-by: Michał Mirosław &lt;mirq-linux@rere.qmqm.pl&gt;&quot;<br />
Signed-off-by: Jonathan Cameron &lt;jic23@kernel.org&gt;<br />
Signed-off-by: Jonghwan Choi &lt;jhbird.choi@samsung.com&gt;<br />
---<br />
 drivers/staging/iio/adc/mxs-lradc.c |    5 ++---<br />
 1 file changed, 2 insertions(+), 3 deletions(-)<br />
<br />
diff --git a/drivers/staging/iio/adc/mxs-lradc.c<br />
b/drivers/staging/iio/adc/mxs-lradc.c<br />
index 55a459b..f5e9e55 100644<br />
--- a/drivers/staging/iio/adc/mxs-lradc.c<br />
+++ b/drivers/staging/iio/adc/mxs-lradc.c<br />
@@ -693,7 +693,6 @@ static void mxs_lradc_trigger_remove(struct iio_dev<br />
*iio)<br />
 static int mxs_lradc_buffer_preenable(struct iio_dev *iio)<br />
 {<br />
 	struct mxs_lradc *lradc = iio_priv(iio);<br />
-	struct iio_buffer *buffer = iio-&gt;buffer;<br />
 	int ret = 0, chan, ofs = 0;<br />
 	unsigned long enable = 0;<br />
 	uint32_t ctrl4_set = 0;<br />
@@ -701,7 +700,7 @@ static int mxs_lradc_buffer_preenable(struct iio_dev<br />
*iio)<br />
 	uint32_t ctrl1_irq = 0;<br />
 	const uint32_t chan_value = LRADC_CH_ACCUMULATE |<br />
 		((LRADC_DELAY_TIMER_LOOP - 1) &lt;&lt;<br />
LRADC_CH_NUM_SAMPLES_OFFSET);<br />
-	const int len = bitmap_weight(buffer-&gt;scan_mask,<br />
LRADC_MAX_TOTAL_CHANS);<br />
+	const int len = bitmap_weight(iio-&gt;active_scan_mask,<br />
LRADC_MAX_TOTAL_CHANS);<br />
 <br />
 	if (!len)<br />
 		return -EINVAL;<br />
@@ -728,7 +727,7 @@ static int mxs_lradc_buffer_preenable(struct iio_dev<br />
*iio)<br />
 		lradc-&gt;base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR);<br />
 	writel(0xff, lradc-&gt;base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR);<br />
 <br />
-	for_each_set_bit(chan, buffer-&gt;scan_mask, LRADC_MAX_TOTAL_CHANS) {<br />
+	for_each_set_bit(chan, iio-&gt;active_scan_mask, LRADC_MAX_TOTAL_CHANS)<br />
{<br />
 		ctrl4_set |= chan &lt;&lt; LRADC_CTRL4_LRADCSELECT_OFFSET(ofs);<br />
 		ctrl4_clr |= LRADC_CTRL4_LRADCSELECT_MASK(ofs);<br />
 		ctrl1_irq |= LRADC_CTRL1_LRADC_IRQ_EN(ofs);<br />
-- <br />
1.7.9.5<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Jonghwan Choi</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Fri, 24 May 2013 04:50:03 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712281,712281#msg-712281</guid>
            <title>[PATCH] scsi: megaraid: check kzalloc (1 reply)</title>
            <link>http://www.serverphorums.com/read.php?12,712281,712281#msg-712281</link>
            <description><![CDATA[ we should check kzalloc, avoid to hit oops<br />
<br />
Signed-off-by: Libo Chen &lt;libo.chen@huawei.com&gt;<br />
---<br />
 drivers/scsi/megaraid.c |    4 ++++<br />
 1 files changed, 4 insertions(+), 0 deletions(-)<br />
<br />
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c<br />
index 846f475..195b095 100644<br />
--- a/drivers/scsi/megaraid.c<br />
+++ b/drivers/scsi/megaraid.c<br />
@@ -4162,6 +4162,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)<br />
<br />
 	sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);<br />
 	scmd-&gt;device = sdev;<br />
+	if (!scmd-&gt;device) {<br />
+		scsi_free_command(GFP_KERNEL, scmd);<br />
+		return -ENOMEM;<br />
+	}<br />
<br />
 	memset(adapter-&gt;int_cdb, 0, sizeof(adapter-&gt;int_cdb));<br />
 	scmd-&gt;cmnd = adapter-&gt;int_cdb;<br />
-- <br />
1.7.1<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Libo Chen</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Fri, 24 May 2013 05:30:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712278,712278#msg-712278</guid>
            <title>[PATCH] x86: Have debug/nmi restore the IDT it replaced (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712278,712278#msg-712278</link>
            <description><![CDATA[ I've sent this out before, and I'm sending it out again.<br />
<br />
<a href="https://patchwork.kernel.org/patch/2082571/" target="_blank"  rel="nofollow">https://patchwork.kernel.org/patch/2082571/</a><br />
<br />
It was ignored because I signed it with &quot;Not-yet-signed-off-by&quot;. This<br />
time I'm signing it off with a real full signed off by, as this will<br />
help with Seiji's patch set to do the IDT swap to enable tracing of<br />
interrupt vectors.<br />
<br />
-----<br />
I've been playing with Seiji's patches:<br />
<br />
<a href="https://lkml.org/lkml/2013/1/21/573" target="_blank"  rel="nofollow">https://lkml.org/lkml/2013/1/21/573</a><br />
<br />
Which add tracing to the x86 interrupt vectors. But to keep tracing<br />
overhead down to zero when tracing is inactive, it uses a swap of the<br />
IDT to replace the irq vectors with versions that have tracepoints in<br />
them, when tracing is enabled. Even though tracepoints have &quot;nops&quot;, we<br />
do this to keep even that overhead eliminated.<br />
<br />
These seemed to work, until I ran the following command with trace-cmd:<br />
<br />
<br />
 trace-cmd start -p function_graph -g &quot;smp_trace_apic_timer_interrupt&quot; \<br />
   -g &quot;smp_apic_timer_interrupt&quot; -e irq_vectors<br />
<br />
<br />
What trace-cmd does above, is not only enables the irq_vectors, but also<br />
produces the call graphs of the two interrupt vector functions:<br />
smp_trace_apic_timer_interrupt and smp_apic_timer_interrupt<br />
<br />
The result was rather surprising. It showed only<br />
smp_apic_timer_interrupt being called, and not the trace version.<br />
Obviously, the tracepoints for the vectors were also not there.<br />
<br />
When starting without the function graph tracer, it worked fine, but I<br />
wanted to see the trace versions being called to be sure, which required<br />
one of the function tracers.<br />
<br />
Investigating, I found the problem. It's with the NMI and breakpoint IDT<br />
handling. I wont explain it too much here, but see:<br />
<br />
commit f8988175f &quot;x86: Allow nesting of the debug stack IDT setting&quot;<br />
commit 42181186a &quot;x86: Add counter when debug stack is used with<br />
interrupts enabled&quot;<br />
commit 228bdaa95 &quot;x86: Keep current stack in NMI breakpoints&quot;<br />
<br />
The basic gist of the above commits is that on NMI or DEBUG trap<br />
entering, it needs to modify the IDT so that the stack pointer doesn't<br />
get reset to the top of the stack again. On boot up, two IDT tables are<br />
created. One for normal operations and one for this NMI/DEBUG case.<br />
<br />
The issue is that it just toggles between the two IDT tables. But if<br />
this happens when Seiji's swap had already happened, it replaces the<br />
trace IDT table back to the normal table, and tracing stops, which sorta<br />
defeats the purpose.<br />
<br />
<br />
To solve this, I've added a 'hold_idt_descr' per cpu variable that<br />
stores the IDT that was loaded and will use that to replace it. If the<br />
DEBUG/NMI came in when the IDT was normal, it would replace it back with<br />
the normal IDT, and if it came in when it was the trace IDT, it would<br />
put back the trace IDT.<br />
<br />
I've run a few tests so far on this code, but I need to run more<br />
stressful ones. Meanwhile, until I find any bugs, I'm posting this patch<br />
for your enjoyment. I think I got all the cases, as NMIs causes the<br />
store/restore functions to be re-entrent without any locks.<br />
<br />
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;<br />
<br />
Index: linux-trace.git/arch/x86/kernel/cpu/common.c<br />
===================================================================<br />
--- linux-trace.git.orig/arch/x86/kernel/cpu/common.c<br />
+++ linux-trace.git/arch/x86/kernel/cpu/common.c<br />
@@ -1148,10 +1148,54 @@ int is_debug_stack(unsigned long addr)<br />
 }<br />
 <br />
 static DEFINE_PER_CPU(u32, debug_stack_use_ctr);<br />
+static DEFINE_PER_CPU(struct desc_ptr, hold_idt_descr);<br />
+static DEFINE_PER_CPU(struct desc_ptr, copy_idt_descr);<br />
 <br />
+/*<br />
+ * Debug traps and NMIs will swap the IDT to have the debug<br />
+ * trap not modify the stack (nmi_idt_descr). But as both the<br />
+ * debug and NMIs share this, they need to be re-entrant. A debug<br />
+ * trap could be doing the swap and after it incs the debug_stack_use_ctr,<br />
+ * an NMI could come in. It too would need to do the swap, and it would<br />
+ * need to swap every time.<br />
+ *<br />
+ * But, the IDT can be changed by other users, and this must restore<br />
+ * that as well.<br />
+ *<br />
+ * Luckily, as interrupts are disabled from the set_zero to reset,<br />
+ * we do not need to worry about the IDT changing underneath us<br />
+ * from other users.<br />
+ */<br />
 void debug_stack_set_zero(void)<br />
 {<br />
+       /*<br />
+        * Writing to the IDT is atomic. If an NMI were to come<br />
+        * in after we did the compare but before the store_idt(),<br />
+        * it too would see the address == 0 and do the store itself.<br />
+        */<br />
+       if (this_cpu_read(hold_idt_descr.address) == 0)<br />
+               store_idt(this_cpu_ptr(&amp;hold_idt_descr));<br />
+<br />
+       /*<br />
+        * If an NMI were to come in now, it would not set hold_idt_descr,<br />
+        * but on exit, it would restore the IDT because the counter is<br />
+        * still zero here. Then it would set the .address back to zero too.<br />
+        */<br />
+<br />
        this_cpu_inc(debug_stack_use_ctr);<br />
+<br />
+       /*<br />
+        * NMI's coming in now are not an issue as we set the .address<br />
+        * and also incremented the ctr. But, if an NMI came in before<br />
+        * the counter was incremented, and after the .address was set,<br />
+        * the NMI would set the .address back to zero, and would have<br />
+        * restored the IDT. We need to check if that happened.<br />
+        * If it did, then the .address would be zero here again.<br />
+        */<br />
+       if (unlikely(this_cpu_read(hold_idt_descr.address) == 0))<br />
+               store_idt(this_cpu_ptr(&amp;hold_idt_descr));<br />
+<br />
+       /* On enter, we always want to use the nmi_idt_descr */<br />
        load_idt((const struct desc_ptr *)&amp;nmi_idt_descr);<br />
 }<br />
 <br />
@@ -1159,8 +1203,39 @@ void debug_stack_reset(void)<br />
 {<br />
        if (WARN_ON(!this_cpu_read(debug_stack_use_ctr)))<br />
                return;<br />
-       if (this_cpu_dec_return(debug_stack_use_ctr) == 0)<br />
-               load_idt((const struct desc_ptr *)&amp;idt_descr);<br />
+<br />
+       if (WARN_ON(!this_cpu_read(hold_idt_descr.address)))<br />
+               return;<br />
+<br />
+       /*<br />
+        * This is the tricky part. We need to restore the old<br />
+        * IDT to what it was before we entered, but an NMI could<br />
+        * come in at any point, and do the same.<br />
+        *<br />
+        * If the count is 1, then we are the first to enter and<br />
+        * we need to update the IDT. But, we must do that after<br />
+        * we decrement the counter, in which case, if an NMI<br />
+        * comes in, it too will see the 1. To get around this,<br />
+        * we update a copy first.<br />
+        *<br />
+        * The copy will always contain what we want to load the<br />
+        * IDT with.<br />
+        */<br />
+       if (this_cpu_read(debug_stack_use_ctr) == 1)<br />
+               *this_cpu_ptr(&amp;copy_idt_descr) = *this_cpu_ptr(&amp;hold_idt_descr);<br />
+<br />
+       if (this_cpu_dec_return(debug_stack_use_ctr) == 0) {<br />
+               /*<br />
+                * We use the copy to save to the IDT, as it will always contain<br />
+                * what we want to restore the IDT to.<br />
+                */<br />
+               load_idt(this_cpu_ptr(&amp;copy_idt_descr));<br />
+               /*<br />
+                * Now clear out the hold_idt_descr.address, to let all new<br />
+                * users restore it from the IDT.<br />
+                */<br />
+               this_cpu_write(hold_idt_descr.address, 0);<br />
+       }<br />
 }<br />
 <br />
 #else  /* CONFIG_X86_64 */<br />
<br />
<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Steven Rostedt</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Fri, 24 May 2013 04:00:03 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712267,712267#msg-712267</guid>
            <title>[PATCH] dma: use platform_{get,set}_drvdata() (1 reply)</title>
            <link>http://www.serverphorums.com/read.php?12,712267,712267#msg-712267</link>
            <description><![CDATA[ Use the wrapper functions for getting and setting the driver data using<br />
platform_device instead of using dev_{get,set}_drvdata() with &amp;pdev-&gt;dev,<br />
so we can directly pass a struct platform_device.<br />
<br />
Also, unnecessary dev_set_drvdata() is removed, because the driver core<br />
clears the driver data to NULL after device_release or on probe failure.<br />
<br />
Signed-off-by: Jingoo Han &lt;jg1.han@samsung.com&gt;<br />
---<br />
 drivers/dma/fsldma.c      |    5 ++---<br />
 drivers/dma/ppc4xx/adma.c |    5 ++---<br />
 2 files changed, 4 insertions(+), 6 deletions(-)<br />
<br />
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c<br />
index 4fc2980..49e8fbd 100644<br />
--- a/drivers/dma/fsldma.c<br />
+++ b/drivers/dma/fsldma.c<br />
@@ -1368,7 +1368,7 @@ static int fsldma_of_probe(struct platform_device *op)<br />
 <br />
 	dma_set_mask(&amp;(op-&gt;dev), DMA_BIT_MASK(36));<br />
 <br />
-	dev_set_drvdata(&amp;op-&gt;dev, fdev);<br />
+	platform_set_drvdata(op, fdev);<br />
 <br />
 	/*<br />
 	 * We cannot use of_platform_bus_probe() because there is no<br />
@@ -1417,7 +1417,7 @@ static int fsldma_of_remove(struct platform_device *op)<br />
 	struct fsldma_device *fdev;<br />
 	unsigned int i;<br />
 <br />
-	fdev = dev_get_drvdata(&amp;op-&gt;dev);<br />
+	fdev = platform_get_drvdata(op);<br />
 	dma_async_device_unregister(&amp;fdev-&gt;common);<br />
 <br />
 	fsldma_free_irqs(fdev);<br />
@@ -1428,7 +1428,6 @@ static int fsldma_of_remove(struct platform_device *op)<br />
 	}<br />
 <br />
 	iounmap(fdev-&gt;regs);<br />
-	dev_set_drvdata(&amp;op-&gt;dev, NULL);<br />
 	kfree(fdev);<br />
 <br />
 	return 0;<br />
diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c<br />
index 5d3d955..e68c51d 100644<br />
--- a/drivers/dma/ppc4xx/adma.c<br />
+++ b/drivers/dma/ppc4xx/adma.c<br />
@@ -4481,7 +4481,7 @@ static int ppc440spe_adma_probe(struct platform_device *ofdev)<br />
 	adev-&gt;dev = &amp;ofdev-&gt;dev;<br />
 	adev-&gt;common.dev = &amp;ofdev-&gt;dev;<br />
 	INIT_LIST_HEAD(&amp;adev-&gt;common.channels);<br />
-	dev_set_drvdata(&amp;ofdev-&gt;dev, adev);<br />
+	platform_set_drvdata(ofdev, adev);<br />
 <br />
 	/* create a channel */<br />
 	chan = kzalloc(sizeof(*chan), GFP_KERNEL);<br />
@@ -4594,14 +4594,13 @@ out:<br />
  */<br />
 static int ppc440spe_adma_remove(struct platform_device *ofdev)<br />
 {<br />
-	struct ppc440spe_adma_device *adev = dev_get_drvdata(&amp;ofdev-&gt;dev);<br />
+	struct ppc440spe_adma_device *adev = platform_get_drvdata(ofdev);<br />
 	struct device_node *np = ofdev-&gt;dev.of_node;<br />
 	struct resource res;<br />
 	struct dma_chan *chan, *_chan;<br />
 	struct ppc_dma_chan_ref *ref, *_ref;<br />
 	struct ppc440spe_adma_chan *ppc440spe_chan;<br />
 <br />
-	dev_set_drvdata(&amp;ofdev-&gt;dev, NULL);<br />
 	if (adev-&gt;id &lt; PPC440SPE_ADMA_ENGINES_NUM)<br />
 		ppc440spe_adma_devices[adev-&gt;id] = -1;<br />
 <br />
-- <br />
1.7.10.4<br />
<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Jingoo Han</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Fri, 24 May 2013 08:00:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712265,712265#msg-712265</guid>
            <title>Kernel Oops on xfrm_output_resume (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712265,712265#msg-712265</link>
            <description><![CDATA[ Hello,<br />
<br />
I don't know how to handle this, not a lkml subscriber, just reporting <br />
this bug to the devs.<br />
All 3.9.y kernels crash after about 6 to 9 hours running without error <br />
messages before the Oops. I'm running 3.8.13 kernel so far without problem.<br />
<br />
Even tried 3.10-rc2, same issue.<br />
<br />
Context : two machines running with drbd block devices mirrored over <br />
ipsec. No Oops with kernels &lt; 3.9.y<br />
<br />
[29545.764401] BUG: unable to handle kernel NULL pointer dereference at <br />
0000000000000020<br />
[29545.764419] IP: [&lt;ffffffff815cb873&gt;] xfrm_output_resume+0x293/0x380<br />
[29545.764433] PGD 0<br />
[29545.764439] Oops: 0000 [#1] SMP<br />
[29545.764446] Modules linked in: authenc esp4 xfrm4_mode_transport <br />
xt_sctp ip6t_REJECT nf_conntrack_ipv6 ip6table_raw ip6table_mangle <br />
ip6table_filter ip6_tables xt_TCPMSS act_police cls_basic cls_flow <br />
cls_fw cls_u32 sch_tbf sch_prio sch_htb sch_hfsc sch_ingress sch_sfq <br />
bridge stp llc xt_statistic xt_CT xt_LOG xt_time xt_connlimit xt_realm <br />
xt_addrtype iptable_raw xt_comment xt_recent xt_policy xt_nat ipt_ULOG <br />
ipt_REJECT ipt_MASQUERADE ipt_ECN ipt_CLUSTERIP ipt_ah xt_set ip_set <br />
nf_nat_tftp nf_nat_snmp_basic nf_conntrack_snmp nf_nat_sip nf_nat_pptp <br />
nf_nat_proto_gre nf_nat_irc nf_nat_h323 nf_nat_ftp nf_nat_amanda ts_kmp <br />
nf_conntrack_amanda nf_conntrack_sane nf_conntrack_tftp nf_conntrack_sip <br />
nf_conntrack_proto_udplite nf_conntrack_proto_sctp nf_conntrack_pptp <br />
nf_conntrack_proto_gre nf_conntrack_netlink nf_conntrack_netbios_ns <br />
nf_conntrack_broadcast nf_conntrack_irc nf_conntrack_h323 <br />
nf_conntrack_ftp xt_TPROXY nf_defrag_ipv6 nf_tproxy_core xt_tcpmss <br />
xt_pkttype xt_physdev xt_owner xt_NF<br />
QUEUE xt_NFLOG nfnetlink_log xt_multiport xt_mark xt_mac xt_limit <br />
xt_length xt_iprange xt_helper xt_hashlimit xt_DSCP xt_dscp xt_dccp <br />
xt_conntrack xt_connmark xt_CLASSIFY xt_AUDIT xt_tcpudp xt_state <br />
iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 <br />
nf_conntrack iptable_mangle nfnetlink iptable_filter ip_tables x_tables <br />
deflate ctr twofish_generic twofish_avx_x86_64 twofish_x86_64_3way <br />
twofish_x86_64 twofish_common camellia_generic camellia_aesni_avx_x86_64 <br />
camellia_x86_64 cast5_avx_x86_64 cast5_generic cast_common des_generic <br />
xcbc rmd160 crypto_null af_key xfrm_algo ipv6 drbd lru_cache btrfs xor <br />
zlib_deflate raid6_pq libcrc32c crc32_pclmul crc32c_intel <br />
ghash_clmulni_intel<br />
[29545.765130] CPU 3<br />
[29545.765135] Pid: 3245, comm: drbd_r_bdata Not tainted 3.9.3-051922 <br />
#14                  /DH67BL<br />
[29545.765182] RIP: 0010:[&lt;ffffffff815cb873&gt;]  [&lt;ffffffff815cb873&gt;] <br />
xfrm_output_resume+0x293/0x380<br />
[29545.765220] RSP: 0018:ffff8803faa21af0  EFLAGS: 00010246<br />
[29545.765240] RAX: 0000000000000000 RBX: ffff8804071258f8 RCX: <br />
0000000000000770<br />
[29545.765263] RDX: 000000000000076f RSI: ffff8803fe126000 RDI: <br />
ffff8804071258f8<br />
[29545.765285] RBP: ffff8803faa21b18 R08: 000000000001a8f0 R09: <br />
ffffffffa0298313<br />
[29545.765308] R10: ffffea000ff84980 R11: ffff88040e801300 R12: <br />
0000000000000000<br />
[29545.765330] R13: ffff88040728b400 R14: ffff88040728b43c R15: <br />
0000000000000000<br />
[29545.765353] FS:  0000000000000000(0000) GS:ffff88041f380000(0000) <br />
knlGS:0000000000000000<br />
[29545.765388] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033<br />
[29545.765409] CR2: 0000000000000020 CR3: 00000000017d2000 CR4: <br />
00000000000407e0<br />
[29545.765432] DR0: 0000000000000000 DR1: 0000000000000000 DR2: <br />
0000000000000000<br />
[29545.765454] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: <br />
0000000000000400<br />
[29545.765477] Process drbd_r_bdata (pid: 3245, threadinfo <br />
ffff8803faa20000, task ffff880403791000)<br />
[29545.765513] Stack:<br />
[29545.765527]  0000000000000000 ffff8804071258f8 ffff8804071258f8 <br />
ffff8804077cc89c<br />
[29545.765563]  ffff88040751ec00 ffff8803faa21b28 ffffffff815cb96e <br />
ffff8803faa21b50<br />
[29545.765599]  ffffffff815cb9a6 ffff8804071258f8 ffff8804071258f8 <br />
ffffffff815c0aa0<br />
[29545.765635] Call Trace:<br />
[29545.765652]  [&lt;ffffffff815cb96e&gt;] xfrm_output2+0xe/0x10<br />
[29545.765673]  [&lt;ffffffff815cb9a6&gt;] xfrm_output+0x36/0xe0<br />
[29545.765694]  [&lt;ffffffff815c0aa0&gt;] ? xfrm4_extract_output+0xd0/0xd0<br />
[29545.765717]  [&lt;ffffffff815c0ac2&gt;] xfrm4_output_finish+0x22/0x40<br />
[29545.765738]  [&lt;ffffffff815c0b26&gt;] xfrm4_output+0x46/0x80<br />
[29545.765760]  [&lt;ffffffff81575100&gt;] ip_local_out+0x20/0x30<br />
[29545.765780]  [&lt;ffffffff8157526a&gt;] ip_queue_xmit+0x15a/0x3d0<br />
[29545.765803]  [&lt;ffffffff8158d636&gt;] tcp_transmit_skb+0x406/0x920<br />
[29545.765824]  [&lt;ffffffff8158dd89&gt;] tcp_write_xmit+0x189/0xaa0<br />
[29545.765847]  [&lt;ffffffff81534ae7&gt;] ? __kmalloc_reserve.isra.53+0x37/0xa0<br />
[29545.765870]  [&lt;ffffffff8158e6f9&gt;] __tcp_push_pending_frames+0x29/0x90<br />
[29545.765892]  [&lt;ffffffff8158f36a&gt;] tcp_send_fin+0x6a/0x190<br />
[29545.765913]  [&lt;ffffffff8157de2e&gt;] tcp_shutdown+0x5e/0x70<br />
[29545.765934]  [&lt;ffffffff815a7602&gt;] inet_shutdown+0x92/0x130<br />
[29545.765955]  [&lt;ffffffff81529f6b&gt;] kernel_sock_shutdown+0xb/0x10<br />
[29545.765983]  [&lt;ffffffffa015c89d&gt;] drbd_free_sock+0x7d/0xb0 [drbd]<br />
[29545.766008]  [&lt;ffffffffa016f2b3&gt;] conn_disconnect.part.48+0x49/0x444 <br />
[drbd]<br />
[29545.766035]  [&lt;ffffffffa016f0f3&gt;] ? conn_request_state+0x53/0x80 [drbd]<br />
[29545.766061]  [&lt;ffffffffa0151705&gt;] drbdd_init+0x225/0x230 [drbd]<br />
[29545.766087]  [&lt;ffffffffa0158ae8&gt;] drbd_thread_setup+0x58/0x130 [drbd]<br />
[29545.766112]  [&lt;ffffffffa0158a90&gt;] ? drbd_open+0xa0/0xa0 [drbd]<br />
[29545.766135]  [&lt;ffffffff810a2f5b&gt;] kthread+0xbb/0xc0<br />
[29545.766155]  [&lt;ffffffff810a2ea0&gt;] ? kthread_create_on_node+0x120/0x120<br />
[29545.766178]  [&lt;ffffffff81606f3c&gt;] ret_from_fork+0x7c/0xb0<br />
[29545.766199]  [&lt;ffffffff810a2ea0&gt;] ? kthread_create_on_node+0x120/0x120<br />
[29545.766221] Code: 00 48 85 ff 74 0f f0 ff 0f 0f 94 c0 84 c0 74 05 e8 <br />
43 f7 b7 ff 48 8b 43 58 48 89 df 48 c7 83 98 00 00 00 00 00 00 00 48 83 <br />
e0 fe &lt;48&gt; 8b 40 20 ff 50 60 83 f8 01 41 89 c4 0f 85 13 fe ff ff 48 8b<br />
[29545.766324] RIP  [&lt;ffffffff815cb873&gt;] xfrm_output_resume+0x293/0x380<br />
[29545.766346]  RSP &lt;ffff8803faa21af0&gt;<br />
[29545.766363] CR2: 0000000000000020<br />
[29545.766407] ---[ end trace 75eb563333dd96e1 ]---<br />
[29545.991903] BUG: unable to handle kernel NULL pointer dereference at <br />
0000000000000020<br />
[29545.991964] IP: [&lt;ffffffff815cb873&gt;] xfrm_output_resume+0x293/0x380<br />
[29545.991993] PGD 0<br />
[29545.992014] Oops: 0000 [#2] SMP<br />
[29545.992040] Modules linked in: authenc esp4 xfrm4_mode_transport <br />
xt_sctp ip6t_REJECT nf_conntrack_ipv6 ip6table_raw ip6table_mangle <br />
ip6table_filter ip6_tables xt_TCPMSS act_police cls_basic cls_flow <br />
cls_fw cls_u32 sch_tbf sch_prio sch_htb sch_hfsc sch_ingress sch_sfq <br />
bridge stp llc xt_statistic xt_CT xt_LOG xt_time xt_connlimit xt_realm <br />
xt_addrtype iptable_raw xt_comment xt_recent xt_policy xt_nat ipt_ULOG <br />
ipt_REJECT ipt_MASQUERADE ipt_ECN ipt_CLUSTERIP ipt_ah xt_set ip_set <br />
nf_nat_tftp nf_nat_snmp_basic nf_conntrack_snmp nf_nat_sip nf_nat_pptp <br />
nf_nat_proto_gre nf_nat_irc nf_nat_h323 nf_nat_ftp nf_nat_amanda ts_kmp <br />
nf_conntrack_amanda nf_conntrack_sane nf_conntrack_tftp nf_conntrack_sip <br />
nf_conntrack_proto_udplite nf_conntrack_proto_sctp nf_conntrack_pptp <br />
nf_conntrack_proto_gre nf_conntrack_netlink nf_conntrack_netbios_ns <br />
nf_conntrack_broadcast nf_conntrack_irc nf_conntrack_h323 <br />
nf_conntrack_ftp xt_TPROXY nf_defrag_ipv6 nf_tproxy_core xt_tcpmss <br />
xt_pkttype xt_physdev xt_owner xt_NF<br />
QUEUE xt_NFLOG nfnetlink_log xt_multiport xt_mark xt_mac xt_limit <br />
xt_length xt_iprange xt_helper xt_hashlimit xt_DSCP xt_dscp xt_dccp <br />
xt_conntrack xt_connmark xt_CLASSIFY xt_AUDIT xt_tcpudp xt_state <br />
iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 <br />
nf_conntrack iptable_mangle nfnetlink iptable_filter ip_tables x_tables <br />
deflate ctr twofish_generic twofish_avx_x86_64 twofish_x86_64_3way <br />
twofish_x86_64 twofish_common camellia_generic camellia_aesni_avx_x86_64 <br />
camellia_x86_64 cast5_avx_x86_64 cast5_generic cast_common des_generic <br />
xcbc rmd160 crypto_null af_key xfrm_algo ipv6 drbd lru_cache btrfs xor <br />
zlib_deflate raid6_pq libcrc32c crc32_pclmul crc32c_intel <br />
ghash_clmulni_intel<br />
[29545.992974] CPU 0<br />
[29545.992981] Pid: 3290, comm: drbd_a_build Tainted: G      D <br />
3.9.3-051922 #14                  /DH67BL<br />
[29545.993035] RIP: 0010:[&lt;ffffffff815cb873&gt;]  [&lt;ffffffff815cb873&gt;] <br />
xfrm_output_resume+0x293/0x380<br />
[29545.993078] RSP: 0018:ffff8803faa0b810  EFLAGS: 00010246<br />
[29545.993101] RAX: 0000000000000000 RBX: ffff8803faa4d8f8 RCX: <br />
00000001801c0006<br />
[29545.993126] RDX: 00000001801c0007 RSI: 00000000801c0006 RDI: <br />
ffff8803faa4d8f8<br />
[29545.993152] RBP: ffff8803faa0b838 R08: 0000000000000000 R09: <br />
0000000000000001<br />
[29545.993177] R10: ffffea000ff61300 R11: ffff88040e801300 R12: <br />
0000000000000000<br />
[29545.993202] R13: ffff88040728b400 R14: ffff88040728b43c R15: <br />
0000000000000000<br />
[29545.993228] FS:  0000000000000000(0000) GS:ffff88041f200000(0000) <br />
knlGS:0000000000000000<br />
[29545.993266] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033<br />
[29545.993289] CR2: 0000000000000020 CR3: 00000000017d2000 CR4: <br />
00000000000407f0<br />
[29545.993315] DR0: 0000000000000000 DR1: 0000000000000000 DR2: <br />
0000000000000000<br />
[29545.993340] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: <br />
0000000000000400<br />
[29545.993366] Process drbd_a_build (pid: 3290, threadinfo <br />
ffff8803faa0a000, task ffff8803fab02000)<br />
[29545.993404] Stack:<br />
[29545.993421]  0000000000000000 ffff8803faa4d8f8 ffff8803faa4d8f8 <br />
ffff88040410709c<br />
[29545.993470]  ffff8804074a6800 ffff8803faa0b848 ffffffff815cb96e <br />
ffff8803faa0b870<br />
[29545.993519]  ffffffff815cb9a6 ffff8803faa4d8f8 ffff8803faa4d8f8 <br />
ffffffff815c0aa0<br />
[29545.993569] Call Trace:<br />
[29545.993588]  [&lt;ffffffff815cb96e&gt;] xfrm_output2+0xe/0x10<br />
[29545.993611]  [&lt;ffffffff815cb9a6&gt;] xfrm_output+0x36/0xe0<br />
[29545.993635]  [&lt;ffffffff815c0aa0&gt;] ? xfrm4_extract_output+0xd0/0xd0<br />
[29545.993660]  [&lt;ffffffff815c0ac2&gt;] xfrm4_output_finish+0x22/0x40<br />
[29545.993684]  [&lt;ffffffff815c0b26&gt;] xfrm4_output+0x46/0x80<br />
[29545.993708]  [&lt;ffffffff81575100&gt;] ip_local_out+0x20/0x30<br />
[29545.993731]  [&lt;ffffffff8157526a&gt;] ip_queue_xmit+0x15a/0x3d0<br />
[29545.993755]  [&lt;ffffffff8158d636&gt;] tcp_transmit_skb+0x406/0x920<br />
[29545.993779]  [&lt;ffffffff8158dd89&gt;] tcp_write_xmit+0x189/0xaa0<br />
[29545.993804]  [&lt;ffffffff8158e6f9&gt;] __tcp_push_pending_frames+0x29/0x90<br />
[29545.993829]  [&lt;ffffffff8157f3f6&gt;] tcp_sendmsg+0x116/0xdc0<br />
[29545.993853]  [&lt;ffffffff8160358e&gt;] ? schedule_timeout+0x12e/0x1b0<br />
[29545.993877]  [&lt;ffffffff815a7dde&gt;] inet_sendmsg+0x5e/0xa0<br />
[29545.993901]  [&lt;ffffffff81530259&gt;] ? release_sock+0x119/0x170<br />
[29545.993925]  [&lt;ffffffff8152bc6b&gt;] sock_sendmsg+0xab/0xe0<br />
[29545.993948]  [&lt;ffffffff8158144e&gt;] ? tcp_recvmsg+0x75e/0xcd0<br />
[29545.993973]  [&lt;ffffffff8152c06b&gt;] kernel_sendmsg+0x3b/0x50<br />
[29545.994001]  [&lt;ffffffffa0159de5&gt;] drbd_send+0x85/0x1b0 [drbd]<br />
[29545.994029]  [&lt;ffffffffa0159f1d&gt;] drbd_send_all+0xd/0x30 [drbd]<br />
[29545.994057]  [&lt;ffffffffa0159fee&gt;] __send_command.isra.32+0xae/0x170 <br />
[drbd]<br />
[29545.994086]  [&lt;ffffffffa015a0e6&gt;] conn_send_command+0x36/0x50 [drbd]<br />
[29545.994115]  [&lt;ffffffffa015a33f&gt;] drbd_send_ping+0x3f/0x60 [drbd]<br />
[29545.994143]  [&lt;ffffffffa0151ac8&gt;] drbd_asender+0x3b8/0x6f0 [drbd]<br />
[29545.994168]  [&lt;ffffffff813c8729&gt;] ? snprintf+0x39/0x40<br />
[29545.994195]  [&lt;ffffffffa0158a90&gt;] ? drbd_open+0xa0/0xa0 [drbd]<br />
[29545.994223]  [&lt;ffffffffa0158ae8&gt;] drbd_thread_setup+0x58/0x130 [drbd]<br />
[29545.994251]  [&lt;ffffffffa0158a90&gt;] ? drbd_open+0xa0/0xa0 [drbd]<br />
[29545.994275]  [&lt;ffffffff810a2f5b&gt;] kthread+0xbb/0xc0<br />
[29545.994298]  [&lt;ffffffff810a2ea0&gt;] ? kthread_create_on_node+0x120/0x120<br />
[29545.994324]  [&lt;ffffffff81606f3c&gt;] ret_from_fork+0x7c/0xb0<br />
[29545.994347]  [&lt;ffffffff810a2ea0&gt;] ? kthread_create_on_node+0x120/0x120<br />
[29545.994372] Code: 00 48 85 ff 74 0f f0 ff 0f 0f 94 c0 84 c0 74 05 e8 <br />
43 f7 b7 ff 48 8b 43 58 48 89 df 48 c7 83 98 00 00 00 00 00 00 00 48 83 <br />
e0 fe &lt;48&gt; 8b 40 20 ff 50 60 83 f8 01 41 89 c4 0f 85 13 fe ff ff 48 8b<br />
[29545.994653] RIP  [&lt;ffffffff815cb873&gt;] xfrm_output_resume+0x293/0x380<br />
[29545.994681]  RSP &lt;ffff8803faa0b810&gt;<br />
[29545.994701] CR2: 0000000000000020<br />
[29545.994721] ---[ end trace 75eb563333dd96e2 ]---<br />
[29546.502319] BUG: unable to handle kernel NULL pointer dereference at <br />
0000000000000808<br />
[29546.502364] IP: [&lt;ffffffff8105ed79&gt;] __ticket_spin_lock+0x9/0x30<br />
[29546.502393] PGD 0<br />
[29546.502416] Oops: 0002 [#3] SMP<br />
[29546.502442] Modules linked in: authenc esp4 xfrm4_mode_transport <br />
xt_sctp ip6t_REJECT nf_conntrack_ipv6 ip6table_raw ip6table_mangle <br />
ip6table_filter ip6_tables xt_TCPMSS act_police cls_basic cls_flow <br />
cls_fw cls_u32 sch_tbf sch_prio sch_htb sch_hfsc sch_ingress sch_sfq <br />
bridge stp llc xt_statistic xt_CT xt_LOG xt_time xt_connlimit xt_realm <br />
xt_addrtype iptable_raw xt_comment xt_recent xt_policy xt_nat ipt_ULOG <br />
ipt_REJECT ipt_MASQUERADE ipt_ECN ipt_CLUSTERIP ipt_ah xt_set ip_set <br />
nf_nat_tftp nf_nat_snmp_basic nf_conntrack_snmp nf_nat_sip nf_nat_pptp <br />
nf_nat_proto_gre nf_nat_irc nf_nat_h323 nf_nat_ftp nf_nat_amanda ts_kmp <br />
nf_conntrack_amanda nf_conntrack_sane nf_conntrack_tftp nf_conntrack_sip <br />
nf_conntrack_proto_udplite nf_conntrack_proto_sctp nf_conntrack_pptp <br />
nf_conntrack_proto_gre nf_conntrack_netlink nf_conntrack_netbios_ns <br />
nf_conntrack_broadcast nf_conntrack_irc nf_conntrack_h323 <br />
nf_conntrack_ftp xt_TPROXY nf_defrag_ipv6 nf_tproxy_core xt_tcpmss <br />
xt_pkttype xt_physdev xt_owner xt_NF<br />
QUEUE xt_NFLOG nfnetlink_log xt_multiport xt_mark xt_mac xt_limit <br />
xt_length xt_iprange xt_helper xt_hashlimit xt_DSCP xt_dscp xt_dccp <br />
xt_conntrack xt_connmark xt_CLASSIFY xt_AUDIT xt_tcpudp xt_state <br />
iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 <br />
nf_conntrack iptable_mangle nfnetlink iptable_filter ip_tables x_tables <br />
deflate ctr twofish_generic twofish_avx_x86_64 twofish_x86_64_3way <br />
twofish_x86_64 twofish_common camellia_generic camellia_aesni_avx_x86_64 <br />
camellia_x86_64 cast5_avx_x86_64 cast5_generic cast_common des_generic <br />
xcbc rmd160 crypto_null af_key xfrm_algo ipv6 drbd lru_cache btrfs xor <br />
zlib_deflate raid6_pq libcrc32c crc32_pclmul crc32c_intel <br />
ghash_clmulni_intel<br />
[29546.503389] CPU 3<br />
[29546.503397] Pid: 3251, comm: drbd_r_build Tainted: G      D <br />
3.9.3-051922 #14                  /DH67BL<br />
[29546.503450] RIP: 0010:[&lt;ffffffff8105ed79&gt;]  [&lt;ffffffff8105ed79&gt;] <br />
__ticket_spin_lock+0x9/0x30<br />
[29546.503493] RSP: 0018:ffff8803faa4fcf0  EFLAGS: 00010082<br />
[29546.503516] RAX: 0000000000000100 RBX: 0000000000000082 RCX: <br />
0000000000000001<br />
[29546.503541] RDX: ffff8803fab02000 RSI: 0000000000000082 RDI: <br />
0000000000000808<br />
[29546.503566] RBP: ffff8803faa4fcf0 R08: 0000000000000000 R09: <br />
0000000000000000<br />
[29546.503591] R10: 000000000000055f R11: 0000000000000000 R12: <br />
0000000000000002<br />
[29546.503617] R13: 0000000000000000 R14: 0000000000000001 R15: <br />
0000000000000001<br />
[29546.503643] FS:  0000000000000000(0000) GS:ffff88041f380000(0000) <br />
knlGS:0000000000000000<br />
[29546.503680] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033<br />
[29546.503704] CR2: 0000000000000808 CR3: 00000000017d2000 CR4: <br />
00000000000407e0<br />
[29546.503729] DR0: 0000000000000000 DR1: 0000000000000000 DR2: <br />
0000000000000000<br />
[29546.503754] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: <br />
0000000000000400<br />
[29546.503780] Process drbd_r_build (pid: 3251, threadinfo <br />
ffff8803faa4e000, task ffff88040784a000)<br />
[29546.503818] Stack:<br />
[29546.503836]  ffff8803faa4fd00 ffffffff8105ee29 ffff8803faa4fd20 <br />
ffffffff81606529<br />
[29546.503885]  ffff8803fab02000 0000000000000002 ffff8803faa4fd58 <br />
ffffffff81095238<br />
[29546.503935]  ffff8803fe188b98 0000000000000002 0000000000000000 <br />
0000000000000001<br />
[29546.503984] Call Trace:<br />
[29546.504004]  [&lt;ffffffff8105ee29&gt;] default_spin_lock_flags+0x9/0x10<br />
[29546.504029]  [&lt;ffffffff81606529&gt;] _raw_spin_lock_irqsave+0x29/0x40<br />
[29546.504055]  [&lt;ffffffff81095238&gt;] force_sig_info+0x38/0x100<br />
[29546.504079]  [&lt;ffffffff81095311&gt;] force_sig+0x11/0x20<br />
[29546.504106]  [&lt;ffffffffa01596b3&gt;] _drbd_thread_stop+0x93/0x100 [drbd]<br />
[29546.504134]  [&lt;ffffffffa016f2aa&gt;] conn_disconnect.part.48+0x40/0x444 <br />
[drbd]<br />
[29546.504164]  [&lt;ffffffffa016f0f3&gt;] ? conn_request_state+0x53/0x80 [drbd]<br />
[29546.504193]  [&lt;ffffffffa0151705&gt;] drbdd_init+0x225/0x230 [drbd]<br />
[29546.504221]  [&lt;ffffffffa0158a90&gt;] ? drbd_open+0xa0/0xa0 [drbd]<br />
[29546.504249]  [&lt;ffffffffa0158ae8&gt;] drbd_thread_setup+0x58/0x130 [drbd]<br />
[29546.504277]  [&lt;ffffffffa0158a90&gt;] ? drbd_open+0xa0/0xa0 [drbd]<br />
[29546.504301]  [&lt;ffffffff810a2f5b&gt;] kthread+0xbb/0xc0<br />
[29546.504325]  [&lt;ffffffff810a2ea0&gt;] ? kthread_create_on_node+0x120/0x120<br />
[29546.504350]  [&lt;ffffffff81606f3c&gt;] ret_from_fork+0x7c/0xb0<br />
[29546.504374]  [&lt;ffffffff810a2ea0&gt;] ? kthread_create_on_node+0x120/0x120<br />
[29546.504398] Code: 00 00 48 c7 c1 91 eb 05 81 48 c7 c2 8e eb 05 81 e9 <br />
dd fe ff ff 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 55 b8 00 01 00 00 48 <br />
89 e5 &lt;f0&gt; 66 0f c1 07 0f b6 d4 38 c2 74 0c 0f 1f 00 f3 90 0f b6 07 38<br />
[29546.504683] RIP  [&lt;ffffffff8105ed79&gt;] __ticket_spin_lock+0x9/0x30<br />
[29546.504711]  RSP &lt;ffff8803faa4fcf0&gt;<br />
[29546.504730] CR2: 0000000000000808<br />
[29546.504750] ---[ end trace 75eb563333dd96e3 ]---<br />
<br />
Cheers<br />
-- <br />
Laurent<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Anonymous User</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Fri, 24 May 2013 03:00:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712259,712259#msg-712259</guid>
            <title>[PATCH 1/1] x86/iommu: fix dma pte address size error (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712259,712259#msg-712259</link>
            <description><![CDATA[ In Intel Vt-D specs, Chapter 9.3 Page-Table Entry,<br />
The size of ADDR(address) field is 12:51, but the function dma_pte_addr<br />
 treats it as 12:63.<br />
<br />
Signed-off-by: Li, Zhen-Hua &lt;zhen-hual@hp.com&gt;<br />
---<br />
 drivers/iommu/intel-iommu.c   |    4 ++--<br />
 include/linux/dma_remapping.h |    2 ++<br />
 2 files changed, 4 insertions(+), 2 deletions(-)<br />
<br />
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c<br />
index b4f0e28..c6d2847 100644<br />
--- a/drivers/iommu/intel-iommu.c<br />
+++ b/drivers/iommu/intel-iommu.c<br />
@@ -311,10 +311,10 @@ static inline void dma_set_pte_prot(struct dma_pte *pte, unsigned long prot)<br />
 static inline u64 dma_pte_addr(struct dma_pte *pte)<br />
 {<br />
 #ifdef CONFIG_64BIT<br />
-	return pte-&gt;val &amp; VTD_PAGE_MASK;<br />
+	return pte-&gt;val &amp; DMA_PTE_MASK;<br />
 #else<br />
 	/* Must have a full atomic 64-bit read */<br />
-	return  __cmpxchg64(&amp;pte-&gt;val, 0ULL, 0ULL) &amp; VTD_PAGE_MASK;<br />
+	return  __cmpxchg64(&amp;pte-&gt;val, 0ULL, 0ULL) &amp; DMA_PTE_MASK;<br />
 #endif<br />
 }<br />
 <br />
diff --git a/include/linux/dma_remapping.h b/include/linux/dma_remapping.h<br />
index 57c9a8a..7a1e212 100644<br />
--- a/include/linux/dma_remapping.h<br />
+++ b/include/linux/dma_remapping.h<br />
@@ -16,6 +16,8 @@<br />
 #define DMA_PTE_WRITE (2)<br />
 #define DMA_PTE_LARGE_PAGE (1 &lt;&lt; 7)<br />
 #define DMA_PTE_SNP (1 &lt;&lt; 11)<br />
+#define DMA_PTE_ADD_LENGTH (40)<br />
+#define DMA_PTE_MASK	((((u64)1 &lt;&lt; DMA_PTE_ADD_LENGTH) - 1) &lt;&lt; VTD_PAGE_SHIFT)<br />
 <br />
 #define CONTEXT_TT_MULTI_LEVEL	0<br />
 #define CONTEXT_TT_DEV_IOTLB	1<br />
-- <br />
1.7.10.4<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Li, Zhen-Hua</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Fri, 24 May 2013 02:40:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712257,712257#msg-712257</guid>
            <title>[PATCH 1/1] x86/iommu: use bit structures for context_entry (2 replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712257,712257#msg-712257</link>
            <description><![CDATA[ There is a structure named context_entry used by intel iommu, and there<br />
are some bit operations on it. Use bit structure may make these operations<br />
easy.<br />
<br />
Signed-off-by: Li, Zhen-Hua &lt;zhen-hual@hp.com&gt;<br />
---<br />
 drivers/iommu/intel-iommu.c |   88 +++++++++++++++----------------------------<br />
 1 file changed, 31 insertions(+), 57 deletions(-)<br />
<br />
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c<br />
index b4f0e28..ae10471 100644<br />
--- a/drivers/iommu/intel-iommu.c<br />
+++ b/drivers/iommu/intel-iommu.c<br />
@@ -221,55 +221,28 @@ get_context_addr_from_root(struct root_entry *root)<br />
  * 8-23: domain id<br />
  */<br />
 struct context_entry {<br />
-	u64 lo;<br />
-	u64 hi;<br />
+	union {<br />
+		struct {<br />
+			u64	present:1,<br />
+				fpd:1,<br />
+				translation_type:2,<br />
+				reserved_l:8,<br />
+				asr:52;<br />
+		};<br />
+		u64 lo;<br />
+	};<br />
+	union {<br />
+		struct {<br />
+			u64	aw:3,<br />
+				avail:4,<br />
+				reserved_h1:1,<br />
+				did:16,<br />
+				reserved_h2:40;<br />
+		};<br />
+		u64 hi;<br />
+	};<br />
 };<br />
 <br />
-static inline bool context_present(struct context_entry *context)<br />
-{<br />
-	return (context-&gt;lo &amp; 1);<br />
-}<br />
-static inline void context_set_present(struct context_entry *context)<br />
-{<br />
-	context-&gt;lo |= 1;<br />
-}<br />
-<br />
-static inline void context_set_fault_enable(struct context_entry *context)<br />
-{<br />
-	context-&gt;lo &amp;= (((u64)-1) &lt;&lt; 2) | 1;<br />
-}<br />
-<br />
-static inline void context_set_translation_type(struct context_entry *context,<br />
-						unsigned long value)<br />
-{<br />
-	context-&gt;lo &amp;= (((u64)-1) &lt;&lt; 4) | 3;<br />
-	context-&gt;lo |= (value &amp; 3) &lt;&lt; 2;<br />
-}<br />
-<br />
-static inline void context_set_address_root(struct context_entry *context,<br />
-					    unsigned long value)<br />
-{<br />
-	context-&gt;lo |= value &amp; VTD_PAGE_MASK;<br />
-}<br />
-<br />
-static inline void context_set_address_width(struct context_entry *context,<br />
-					     unsigned long value)<br />
-{<br />
-	context-&gt;hi |= value &amp; 7;<br />
-}<br />
-<br />
-static inline void context_set_domain_id(struct context_entry *context,<br />
-					 unsigned long value)<br />
-{<br />
-	context-&gt;hi |= (value &amp; ((1 &lt;&lt; 16) - 1)) &lt;&lt; 8;<br />
-}<br />
-<br />
-static inline void context_clear_entry(struct context_entry *context)<br />
-{<br />
-	context-&gt;lo = 0;<br />
-	context-&gt;hi = 0;<br />
-}<br />
-<br />
 /*<br />
  * 0: readable<br />
  * 1: writable<br />
@@ -727,7 +700,7 @@ static int device_context_mapped(struct intel_iommu *iommu, u8 bus, u8 devfn)<br />
 		ret = 0;<br />
 		goto out;<br />
 	}<br />
-	ret = context_present(&amp;context[devfn]);<br />
+	ret = context-&gt;present;<br />
 out:<br />
 	spin_unlock_irqrestore(&amp;iommu-&gt;lock, flags);<br />
 	return ret;<br />
@@ -743,7 +716,8 @@ static void clear_context_table(struct intel_iommu *iommu, u8 bus, u8 devfn)<br />
 	root = &amp;iommu-&gt;root_entry[bus];<br />
 	context = get_context_addr_from_root(root);<br />
 	if (context) {<br />
-		context_clear_entry(&amp;context[devfn]);<br />
+		context[devfn].lo = 0;<br />
+		context[devfn].hi = 0;<br />
 		__iommu_flush_cache(iommu, &amp;context[devfn], \<br />
 			sizeof(*context));<br />
 	}<br />
@@ -1573,7 +1547,7 @@ static int domain_context_mapping_one(struct dmar_domain *domain, int segment,<br />
 	if (!context)<br />
 		return -ENOMEM;<br />
 	spin_lock_irqsave(&amp;iommu-&gt;lock, flags);<br />
-	if (context_present(context)) {<br />
+	if (context-&gt;present) {<br />
 		spin_unlock_irqrestore(&amp;iommu-&gt;lock, flags);<br />
 		return 0;<br />
 	}<br />
@@ -1623,7 +1597,7 @@ static int domain_context_mapping_one(struct dmar_domain *domain, int segment,<br />
 		}<br />
 	}<br />
 <br />
-	context_set_domain_id(context, id);<br />
+	context-&gt;did = id;<br />
 <br />
 	if (translation != CONTEXT_TT_PASS_THROUGH) {<br />
 		info = iommu_support_dev_iotlb(domain, segment, bus, devfn);<br />
@@ -1635,15 +1609,15 @@ static int domain_context_mapping_one(struct dmar_domain *domain, int segment,<br />
 	 * AGAW value supported by hardware. And ASR is ignored by hardware.<br />
 	 */<br />
 	if (unlikely(translation == CONTEXT_TT_PASS_THROUGH))<br />
-		context_set_address_width(context, iommu-&gt;msagaw);<br />
+		context-&gt;aw = iommu-&gt;msagaw;<br />
 	else {<br />
-		context_set_address_root(context, virt_to_phys(pgd));<br />
-		context_set_address_width(context, iommu-&gt;agaw);<br />
+		context-&gt;asr = virt_to_phys(pgd) &gt;&gt; VTD_PAGE_SHIFT;<br />
+		context-&gt;aw  = iommu-&gt;agaw;<br />
 	}<br />
 <br />
-	context_set_translation_type(context, translation);<br />
-	context_set_fault_enable(context);<br />
-	context_set_present(context);<br />
+	context-&gt;translation_type = translation;<br />
+	context-&gt;fpd = 0;<br />
+	context-&gt;present = 1;<br />
 	domain_flush_cache(domain, context, sizeof(*context));<br />
 <br />
 	/*<br />
-- <br />
1.7.10.4<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Li, Zhen-Hua</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Fri, 24 May 2013 02:50:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712254,712254#msg-712254</guid>
            <title>[PATCH] mutex: do not unnecessarily deal with waiters (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712254,712254#msg-712254</link>
            <description><![CDATA[ From: Davidlohr Bueso &lt;davidlohr.bueso@hp.com&gt;<br />
<br />
Upon entering the slowpath, we immediately attempt to acquire the lock<br />
by checking if it is already unlocked. If we are lucky enough that this<br />
is the case, then we don't need to deal with any waiter related logic.<br />
<br />
Furthermore any checks for an empty wait_list are unnecessary as we<br />
already know that count is non-negative and hence no one is waiting for<br />
the lock.<br />
<br />
Move the count check and xchg calls to be done before any waiters are<br />
setup - including waiter debugging. Upon failure to acquire the lock,<br />
the xchg sets the counter to 0, instead of -1 as it was originally.<br />
This can be done here since we set it back to -1 right at the beginning<br />
of the loop so other waiters are woken up when the lock is released.<br />
<br />
When tested on a 8-socket (80 core) system against a vanilla 3.10-rc1<br />
kernel, this patch provides some small performance benefits (+2-6%).<br />
While it could be considered in the noise level, the average percentages<br />
were stable across multiple runs and no performance regressions were seen.<br />
Two big winners, for small amounts of users (10-100), were the short and<br />
compute workloads had a +19.36% and +%15.76% in jobs per minute.<br />
  <br />
Signed-off-by: Davidlohr Bueso &lt;davidlohr.bueso@hp.com&gt;<br />
---<br />
 kernel/mutex.c | 26 ++++++++++++++------------<br />
 1 file changed, 14 insertions(+), 12 deletions(-)<br />
<br />
diff --git a/kernel/mutex.c b/kernel/mutex.c<br />
index ad53a66..a8cd741 100644<br />
--- a/kernel/mutex.c<br />
+++ b/kernel/mutex.c<br />
@@ -306,7 +306,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,<br />
 		owner = ACCESS_ONCE(lock-&gt;owner);<br />
 		if (owner &amp;&amp; !mutex_spin_on_owner(lock, owner)) {<br />
 			mspin_unlock(MLOCK(lock), &amp;node);<br />
-			break;<br />
+			goto slowpath;<br />
 		}<br />
 <br />
 		if ((atomic_read(&amp;lock-&gt;count) == 1) &amp;&amp;<br />
@@ -314,8 +314,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,<br />
 			lock_acquired(&amp;lock-&gt;dep_map, ip);<br />
 			mutex_set_owner(lock);<br />
 			mspin_unlock(MLOCK(lock), &amp;node);<br />
-			preempt_enable();<br />
-			return 0;<br />
+			goto done;<br />
 		}<br />
 		mspin_unlock(MLOCK(lock), &amp;node);<br />
 <br />
@@ -326,7 +325,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,<br />
 		 * the owner complete.<br />
 		 */<br />
 		if (!owner &amp;&amp; (need_resched() || rt_task(task)))<br />
-			break;<br />
+			goto slowpath;<br />
 <br />
 		/*<br />
 		 * The cpu_relax() call is a compiler barrier which forces<br />
@@ -340,6 +339,14 @@ slowpath:<br />
 #endif<br />
 	spin_lock_mutex(&amp;lock-&gt;wait_lock, flags);<br />
 <br />
+	/* once more, can we acquire the lock? */<br />
+	if (MUTEX_SHOW_NO_WAITER(lock) &amp;&amp; (atomic_xchg(&amp;lock-&gt;count, 0) == 1)) {<br />
+		lock_acquired(&amp;lock-&gt;dep_map, ip);<br />
+		mutex_set_owner(lock);<br />
+		spin_unlock_mutex(&amp;lock-&gt;wait_lock, flags);<br />
+		goto done;<br />
+	}<br />
+<br />
 	debug_mutex_lock_common(lock, &amp;waiter);<br />
 	debug_mutex_add_waiter(lock, &amp;waiter, task_thread_info(task));<br />
 <br />
@@ -347,9 +354,6 @@ slowpath:<br />
 	list_add_tail(&amp;waiter.list, &amp;lock-&gt;wait_list);<br />
 	waiter.task = task;<br />
 <br />
-	if (MUTEX_SHOW_NO_WAITER(lock) &amp;&amp; (atomic_xchg(&amp;lock-&gt;count, -1) == 1))<br />
-		goto done;<br />
-<br />
 	lock_contended(&amp;lock-&gt;dep_map, ip);<br />
 <br />
 	for (;;) {<br />
@@ -363,7 +367,7 @@ slowpath:<br />
 		 * other waiters:<br />
 		 */<br />
 		if (MUTEX_SHOW_NO_WAITER(lock) &amp;&amp;<br />
-		   (atomic_xchg(&amp;lock-&gt;count, -1) == 1))<br />
+		    (atomic_xchg(&amp;lock-&gt;count, -1) == 1))<br />
 			break;<br />
 <br />
 		/*<br />
@@ -388,9 +392,8 @@ slowpath:<br />
 		spin_lock_mutex(&amp;lock-&gt;wait_lock, flags);<br />
 	}<br />
 <br />
-done:<br />
+	/* got the lock - cleanup and rejoice! */<br />
 	lock_acquired(&amp;lock-&gt;dep_map, ip);<br />
-	/* got the lock - rejoice! */<br />
 	mutex_remove_waiter(lock, &amp;waiter, current_thread_info());<br />
 	mutex_set_owner(lock);<br />
 <br />
@@ -399,10 +402,9 @@ done:<br />
 		atomic_set(&amp;lock-&gt;count, 0);<br />
 <br />
 	spin_unlock_mutex(&amp;lock-&gt;wait_lock, flags);<br />
-<br />
 	debug_mutex_free_waiter(&amp;waiter);<br />
+done:<br />
 	preempt_enable();<br />
-<br />
 	return 0;<br />
 }<br />
 <br />
-- <br />
1.7.11.7<br />
<br />
<br />
<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Davidlohr Bueso</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Fri, 24 May 2013 02:00:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712223,712223#msg-712223</guid>
            <title>[PATCH] fs: ecryptfs: fixed msync to flush data (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712223,712223#msg-712223</link>
            <description><![CDATA[ When msync is called on a memory mapped file, that<br />
data is not flushed to the disk.<br />
<br />
In Linux, msync calls fsync for the file. For ecryptfs,<br />
fsync just calls the lower level file system's fsync.<br />
Changed the ecryptfs fsync code to call filemap_write_and_wait<br />
before calling the lower level fsync.<br />
<br />
Addresses the problem described in <a href="http://crbug.com/239536" target="_blank"  rel="nofollow">http://crbug.com/239536</a><br />
<br />
Signed-off-by: Paul Taysom &lt;taysom@chromium.org&gt;<br />
---<br />
 fs/ecryptfs/file.c | 1 +<br />
 1 file changed, 1 insertion(+)<br />
<br />
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c<br />
index 201f0a0..16f509d 100644<br />
--- a/fs/ecryptfs/file.c<br />
+++ b/fs/ecryptfs/file.c<br />
@@ -295,6 +295,7 @@ static int ecryptfs_release(struct inode *inode, struct file *file)<br />
 static int<br />
 ecryptfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)<br />
 {<br />
+	filemap_write_and_wait(file-&gt;f_mapping);<br />
 	return vfs_fsync(ecryptfs_file_to_lower(file), datasync);<br />
 }<br />
 <br />
-- <br />
1.8.2.1<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Paul Taysom</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 23:40:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712220,712220#msg-712220</guid>
            <title>[GIT PULL] GPIO fixes for v3.10 (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712220,712220#msg-712220</link>
            <description><![CDATA[ Hi Linus,<br />
<br />
here are some GPIO fixes I've collected for the v3.10 series.<br />
Detailed info in the signed tag.<br />
<br />
It's all been in -next and it's all been build tested, yes.<br />
<br />
Yours,<br />
Linus Walleij<br />
<br />
<br />
The following changes since commit f722406faae2d073cc1d01063d1123c35425939e:<br />
<br />
  Linux 3.10-rc1 (2013-05-11 17:14:08 -0700)<br />
<br />
are available in the git repository at:<br />
<br />
  git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git<br />
tags/gpio-fixes-v3.10-1<br />
<br />
for you to fetch changes up to cfb10898efe1bc1f3eb8d8f37f164d9e2ac8b43a:<br />
<br />
  gpio: Don't override the error code in probe error handling<br />
(2013-05-20 20:27:30 +0200)<br />
<br />
----------------------------------------------------------------<br />
GPIO fixes for the v3.10 series:<br />
- An OMAP fix that makes ethernet work again.<br />
- Fix for build problem when building the MCP23S08 driver<br />
  as module.<br />
- IRQ conflicts in the Langwell driver.<br />
- Fix IRQ coherency issues in the MXS driver.<br />
- Return correct errorcode on errorpath when removing<br />
  GPIO chips.<br />
<br />
----------------------------------------------------------------<br />
Axel Lin (2):<br />
      gpio: mcp23s08: Fix build error when CONFIG_SPI_MASTER=y &amp;&amp; CONFIG_I2C=m<br />
      gpio: Don't override the error code in probe error handling<br />
<br />
David Cohen (1):<br />
      gpio-langwell: fix irq conflicts when DT is not used<br />
<br />
Jon Hunter (1):<br />
      gpio/omap: ensure gpio context is initialised<br />
<br />
Maxime Ripard (1):<br />
      gpio: mxs: Use set and clear capabilities of the gpio controller<br />
<br />
 drivers/gpio/Kconfig           |  2 +-<br />
 drivers/gpio/gpio-langwell.c   | 17 +++++++++------<br />
 drivers/gpio/gpio-ml-ioh.c     |  3 +--<br />
 drivers/gpio/gpio-mxs.c        |  3 ++-<br />
 drivers/gpio/gpio-omap.c       | 48 +++++++++++++++++++++++++++++++++++++++---<br />
 drivers/gpio/gpio-pch.c        |  3 +--<br />
 drivers/gpio/gpio-sch.c        |  6 ++----<br />
 drivers/gpio/gpio-viperboard.c |  3 ++-<br />
 8 files changed, 64 insertions(+), 21 deletions(-)<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Linus Walleij</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 23:30:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712216,712216#msg-712216</guid>
            <title>[PATCH] mtip32xx: dynamically allocate buffer in debugfs functions (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712216,712216#msg-712216</link>
            <description><![CDATA[ Dynamically allocate buf to prevent warnings:<br />
<br />
drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_device_status’:<br />
drivers/block/mtip32xx/mtip32xx.c:2823: warning: the frame size of 1056 bytes is larger than 1024 bytes<br />
drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_registers’:<br />
drivers/block/mtip32xx/mtip32xx.c:2894: warning: the frame size of 1056 bytes is larger than 1024 bytes<br />
drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_flags’:<br />
drivers/block/mtip32xx/mtip32xx.c:2917: warning: the frame size of 1056 bytes is larger than 1024 bytes<br />
<br />
Signed-off-by: David Milburn &lt;dmilburn@redhat.com&gt;<br />
---<br />
 drivers/block/mtip32xx/mtip32xx.c |   47 +++++++++++++++++++++++++++++--------<br />
 1 files changed, 37 insertions(+), 10 deletions(-)<br />
<br />
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c<br />
index 847107e..baa0996 100644<br />
--- a/drivers/block/mtip32xx/mtip32xx.c<br />
+++ b/drivers/block/mtip32xx/mtip32xx.c<br />
@@ -2806,34 +2806,51 @@ static ssize_t show_device_status(struct device_driver *drv, char *buf)<br />
 static ssize_t mtip_hw_read_device_status(struct file *f, char __user *ubuf,<br />
 						size_t len, loff_t *offset)<br />
 {<br />
+	struct driver_data *dd =  (struct driver_data *)f-&gt;private_data;<br />
 	int size = *offset;<br />
-	char buf[MTIP_DFS_MAX_BUF_SIZE];<br />
+	char *buf;<br />
+	int rv = 0;<br />
 <br />
 	if (!len || *offset)<br />
 		return 0;<br />
 <br />
+	buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);<br />
+	if (!buf) {<br />
+		dev_err(&amp;dd-&gt;pdev-&gt;dev,<br />
+			&quot;Memory allocation: status buffer\n&quot;);<br />
+		return -ENOMEM;<br />
+	}<br />
+<br />
 	size += show_device_status(NULL, buf);<br />
 <br />
 	*offset = size &lt;= len ? size : len;<br />
 	size = copy_to_user(ubuf, buf, *offset);<br />
 	if (size)<br />
-		return -EFAULT;<br />
+		rv = -EFAULT;<br />
 <br />
-	return *offset;<br />
+	kfree(buf);<br />
+	return rv ? rv : *offset;<br />
 }<br />
 <br />
 static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,<br />
 				  size_t len, loff_t *offset)<br />
 {<br />
 	struct driver_data *dd =  (struct driver_data *)f-&gt;private_data;<br />
-	char buf[MTIP_DFS_MAX_BUF_SIZE];<br />
+	char *buf;<br />
 	u32 group_allocated;<br />
 	int size = *offset;<br />
-	int n;<br />
+	int n, rv = 0;<br />
 <br />
 	if (!len || size)<br />
 		return 0;<br />
 <br />
+	buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);<br />
+	if (!buf) {<br />
+		dev_err(&amp;dd-&gt;pdev-&gt;dev,<br />
+			&quot;Memory allocation: register buffer\n&quot;);<br />
+		return -ENOMEM;<br />
+	}<br />
+<br />
 	size += sprintf(&amp;buf, &quot;H/ S ACTive      : [ 0x&quot;);<br />
 <br />
 	for (n = dd-&gt;slot_groups-1; n &gt;= 0; n--)<br />
@@ -2888,21 +2905,30 @@ static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,<br />
 	*offset = size &lt;= len ? size : len;<br />
 	size = copy_to_user(ubuf, buf, *offset);<br />
 	if (size)<br />
-		return -EFAULT;<br />
+		rv = -EFAULT;<br />
 <br />
-	return *offset;<br />
+	kfree(buf);<br />
+	return rv ? rv : *offset;<br />
 }<br />
 <br />
 static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,<br />
 				  size_t len, loff_t *offset)<br />
 {<br />
 	struct driver_data *dd =  (struct driver_data *)f-&gt;private_data;<br />
-	char buf[MTIP_DFS_MAX_BUF_SIZE];<br />
+	char *buf;<br />
 	int size = *offset;<br />
+	int rv = 0;<br />
 <br />
 	if (!len || size)<br />
 		return 0;<br />
 <br />
+	buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);<br />
+	if (!buf) {<br />
+		dev_err(&amp;dd-&gt;pdev-&gt;dev,<br />
+			&quot;Memory allocation: flag buffer\n&quot;);<br />
+		return -ENOMEM;<br />
+	}<br />
+<br />
 	size += sprintf(&amp;buf, &quot;Flag-port : [ %08lX ]\n&quot;,<br />
 							dd-&gt;port-&gt;flags);<br />
 	size += sprintf(&amp;buf, &quot;Flag-dd   : [ %08lX ]\n&quot;,<br />
@@ -2911,9 +2937,10 @@ static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,<br />
 	*offset = size &lt;= len ? size : len;<br />
 	size = copy_to_user(ubuf, buf, *offset);<br />
 	if (size)<br />
-		return -EFAULT;<br />
+		rv = -EFAULT;<br />
 <br />
-	return *offset;<br />
+	kfree(buf);<br />
+	return rv ? rv : *offset;<br />
 }<br />
 <br />
 static const struct file_operations mtip_device_status_fops = {<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>David Milburn</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 23:20:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712204,712204#msg-712204</guid>
            <title>[PATCH 1/7] staging/silicom/bypasslib: Reformat comments (7 replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712204,712204#msg-712204</link>
            <description><![CDATA[ Resolved the C99 comment style issue by reformatting existing comments <br />
to meet kernel coding standards in bp_ioctl.h<br />
<br />
Signed-off-by: Lisa Nguyen &lt;lisa@xenapiadmin.com&gt;<br />
---<br />
 drivers/staging/silicom/bypasslib/bp_ioctl.h | 64 ++++++++++++++--------------<br />
 1 file changed, 32 insertions(+), 32 deletions(-)<br />
<br />
diff --git a/drivers/staging/silicom/bypasslib/bp_ioctl.h b/drivers/staging/silicom/bypasslib/bp_ioctl.h<br />
index 040c6fa..2d1ef53 100644<br />
--- a/drivers/staging/silicom/bypasslib/bp_ioctl.h<br />
+++ b/drivers/staging/silicom/bypasslib/bp_ioctl.h<br />
@@ -14,41 +14,41 @@<br />
 #ifndef BP_IOCTL_H<br />
 #define BP_IOCTL_H<br />
 <br />
-#define BP_CAP                   0x01	//BIT_0<br />
-#define BP_STATUS_CAP            0x02	//BIT_1<br />
-#define BP_STATUS_CHANGE_CAP     0x04	//BIT_2<br />
-#define SW_CTL_CAP               0x08	//BIT_3<br />
-#define BP_DIS_CAP               0x10	//BIT_4<br />
-#define BP_DIS_STATUS_CAP        0x20	//BIT_5<br />
-#define STD_NIC_CAP              0x40	//BIT_6<br />
-#define BP_PWOFF_ON_CAP          0x80	//BIT_7<br />
-#define BP_PWOFF_OFF_CAP         0x0100	//BIT_8<br />
-#define BP_PWOFF_CTL_CAP         0x0200	//BIT_9<br />
-#define BP_PWUP_ON_CAP           0x0400	//BIT_10<br />
-#define BP_PWUP_OFF_CAP          0x0800	//BIT_11<br />
-#define BP_PWUP_CTL_CAP          0x1000	//BIT_12<br />
-#define WD_CTL_CAP               0x2000	//BIT_13<br />
-#define WD_STATUS_CAP            0x4000	//BIT_14<br />
-#define WD_TIMEOUT_CAP           0x8000	//BIT_15<br />
-#define TX_CTL_CAP               0x10000	//BIT_16<br />
-#define TX_STATUS_CAP            0x20000	//BIT_17<br />
-#define TAP_CAP                  0x40000	//BIT_18<br />
-#define TAP_STATUS_CAP           0x80000	//BIT_19<br />
-#define TAP_STATUS_CHANGE_CAP    0x100000	//BIT_20<br />
-#define TAP_DIS_CAP              0x200000	//BIT_21<br />
-#define TAP_DIS_STATUS_CAP       0x400000	//BIT_22<br />
-#define TAP_PWUP_ON_CAP          0x800000	//BIT_23<br />
-#define TAP_PWUP_OFF_CAP         0x1000000	//BIT 24<br />
-#define TAP_PWUP_CTL_CAP         0x2000000	//BIT 25<br />
-#define NIC_CAP_NEG              0x4000000	//BIT 26<br />
-#define TPL_CAP                  0x8000000	//BIT 27<br />
-#define DISC_CAP                 0x10000000	//BIT 28<br />
-#define DISC_DIS_CAP             0x20000000	//BIT 29<br />
-#define DISC_PWUP_CTL_CAP        0x40000000	//BIT 30<br />
+#define BP_CAP                   0x01	/* BIT_0 */<br />
+#define BP_STATUS_CAP            0x02	/* BIT_1 */<br />
+#define BP_STATUS_CHANGE_CAP     0x04	/* BIT_2 */<br />
+#define SW_CTL_CAP               0x08	/* BIT_3 */<br />
+#define BP_DIS_CAP               0x10	/* BIT_4 */<br />
+#define BP_DIS_STATUS_CAP        0x20	/* BIT_5 */<br />
+#define STD_NIC_CAP              0x40	/* BIT_6 */<br />
+#define BP_PWOFF_ON_CAP          0x80	/* BIT_7 */<br />
+#define BP_PWOFF_OFF_CAP         0x0100	/* BIT_8 */<br />
+#define BP_PWOFF_CTL_CAP         0x0200	/* BIT_9 */<br />
+#define BP_PWUP_ON_CAP           0x0400	/* BIT_10 */<br />
+#define BP_PWUP_OFF_CAP          0x0800	/* BIT_11 */<br />
+#define BP_PWUP_CTL_CAP          0x1000	/* BIT_12 */<br />
+#define WD_CTL_CAP               0x2000	/* BIT_13 */<br />
+#define WD_STATUS_CAP            0x4000	/* BIT_14 */<br />
+#define WD_TIMEOUT_CAP           0x8000	/* BIT_15 */<br />
+#define TX_CTL_CAP               0x10000	/* BIT_16 */<br />
+#define TX_STATUS_CAP            0x20000	/* BIT_17 */<br />
+#define TAP_CAP                  0x40000	/* BIT_18 */<br />
+#define TAP_STATUS_CAP           0x80000	/* BIT_19 */<br />
+#define TAP_STATUS_CHANGE_CAP    0x100000	/* BIT_20 */<br />
+#define TAP_DIS_CAP              0x200000	/* BIT_21 */<br />
+#define TAP_DIS_STATUS_CAP       0x400000	/* BIT_22 */<br />
+#define TAP_PWUP_ON_CAP          0x800000	/* BIT_23 */<br />
+#define TAP_PWUP_OFF_CAP         0x1000000	/* BIT 24 */<br />
+#define TAP_PWUP_CTL_CAP         0x2000000	/* BIT 25 */<br />
+#define NIC_CAP_NEG              0x4000000	/* BIT 26 */<br />
+#define TPL_CAP                  0x8000000	/* BIT 27 */<br />
+#define DISC_CAP                 0x10000000	/* BIT 28 */<br />
+#define DISC_DIS_CAP             0x20000000	/* BIT 29 */<br />
+#define DISC_PWUP_CTL_CAP        0x40000000	/* BIT 30 */<br />
 <br />
 #define WD_MIN_TIME_MASK(val)      (val &amp; 0xf)<br />
 #define WD_STEP_COUNT_MASK(val)    ((val &amp; 0xf) &lt;&lt; 5)<br />
-#define WDT_STEP_TIME              0x10	//BIT_4<br />
+#define WDT_STEP_TIME              0x10	/* BIT_4 */<br />
 <br />
 #define WD_MIN_TIME_GET(desc)   (desc &amp; 0xf)<br />
 #define WD_STEP_COUNT_GET(desc) (desc&gt;&gt;5) &amp; 0xf<br />
-- <br />
1.8.1.2<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Lisa Nguyen</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Fri, 24 May 2013 00:50:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712203,712203#msg-712203</guid>
            <title>Nonblocking buffered AIO from userspace (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712203,712203#msg-712203</link>
            <description><![CDATA[ Hi gang,<br />
<br />
I need some advice on the best way to accomplish non-blocking buffered<br />
disk IO from my user space application. Unlike some of the other<br />
database systems I'm trying to outsource as much work to the kernel as<br />
possible. I would prefer to avoid having to resolve to O_DIRECT and<br />
io_submit to fetch the data and having to reimplement the page /<br />
buffer cache &amp; read ahead.<br />
<br />
The application is read heavy with occasional long running write jobs.<br />
Since I'm not too concerned about the performance on the write path I<br />
am able to run that work in threads and block.<br />
<br />
Current I'm mmaping the files, and the make the read path quite simple<br />
and is great for disk scans when my data set is stored in memory. When<br />
the data is not cached the performance becomes more unpredictable,<br />
esp. when I'm doing an indexed read (giant bitmap indexes). Here's how<br />
my IO path looks like:<br />
<br />
application &lt;--&gt; fscache (SSD) &lt;--&gt; cephfs &lt;--&gt; ceph cluster<br />
<br />
Ultimately what I'd like is a way to do non-blocking scatter gather IO<br />
from disk or page cache into my application. I'd like to be<br />
non-blocking because it often happens that I can do something useful<br />
while waiting on IO like uncompress indexes for another request that<br />
is waiting, process network IO., etc.<br />
<br />
With mmap my blocking is unpredictable and mlock() blocks and only<br />
lets me lock a range and not a vector of page ranges.<br />
<br />
If I was doing this in the kernel life would be simple; there are all<br />
sorts of APIs for doing async IO even when my VFS is stack as in above<br />
diagram. Is there any way for me to take advantage of it in user<br />
space... even if it's in units of page.<br />
<br />
It's entirely possible that I'm missing something and there's a good<br />
way of doing this that I haven't though of.<br />
<br />
Thanks,<br />
- Milosz<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Milosz Tanski</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 23:00:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712196,712196#msg-712196</guid>
            <title>[PATCH 0/6] Convert JZ4740 to dmaengine (1 reply)</title>
            <link>http://www.serverphorums.com/read.php?12,712196,712196#msg-712196</link>
            <description><![CDATA[ Hi,<br />
<br />
This series replaces the custom JZ4740 DMA API with a dmaengine driver. This is<br />
done in 3 steps:<br />
	1) Add a dmaengine driver which wraps the custom JZ4740 DMA API<br />
	2) Update all users of the JZ4740 DMA API to use dmaengine instead<br />
	3) Remove the custom API and move all direct hardware access to the<br />
	   dmaengine driver.<br />
<br />
The first two patches in the series also make sure that the clock of the DMA<br />
core is enabled.<br />
<br />
Since the patches in this series depend on each other I'd prefer if they could<br />
all go through the DMA tree.<br />
<br />
- Lars<br />
<br />
Lars-Peter Clausen (4):<br />
  dma: Add a jz4740 dmaengine driver<br />
  MIPS: jz4740: Register jz4740 DMA device<br />
  ASoC: jz4740: Use the generic dmaengine PCM driver<br />
  MIPS: jz4740: Remove custom DMA API<br />
<br />
Maarten ter Huurne (2):<br />
  MIPS: jz4740: Correct clock gate bit for DMA controller<br />
  MIPS: jz4740: Acquire and enable DMA controller clock<br />
<br />
 arch/mips/include/asm/mach-jz4740/dma.h      |  56 ---<br />
 arch/mips/include/asm/mach-jz4740/platform.h |   1 +<br />
 arch/mips/jz4740/Makefile                    |   2 +-<br />
 arch/mips/jz4740/board-qi_lb60.c             |   1 +<br />
 arch/mips/jz4740/clock.c                     |   2 +-<br />
 arch/mips/jz4740/dma.c                       | 287 -------------<br />
 arch/mips/jz4740/platform.c                  |  21 +<br />
 drivers/dma/Kconfig                          |   6 +<br />
 drivers/dma/Makefile                         |   1 +<br />
 drivers/dma/dma-jz4740.c                     | 616 +++++++++++++++++++++++++++<br />
 sound/soc/jz4740/Kconfig                     |   1 +<br />
 sound/soc/jz4740/jz4740-i2s.c                |  48 +--<br />
 sound/soc/jz4740/jz4740-pcm.c                | 310 +-------------<br />
 sound/soc/jz4740/jz4740-pcm.h                |  20 -<br />
 14 files changed, 675 insertions(+), 697 deletions(-)<br />
 delete mode 100644 arch/mips/jz4740/dma.c<br />
 create mode 100644 drivers/dma/dma-jz4740.c<br />
 delete mode 100644 sound/soc/jz4740/jz4740-pcm.h<br />
<br />
-- <br />
1.8.2.1<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Lars-Peter Clausen</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 22:40:03 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712195,712195#msg-712195</guid>
            <title>[PATCH 3/6] dma: Add a jz4740 dmaengine driver (2 replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712195,712195#msg-712195</link>
            <description><![CDATA[ This patch adds dmaengine support for the JZ4740 DMA controller. For now the<br />
driver will be a wrapper around the custom JZ4740 DMA API. Once all users of the<br />
custom JZ4740 DMA API have been converted to the dmaengine API the custom API<br />
will be removed and direct hardware access will be added to the dmaengine<br />
driver.<br />
<br />
Signed-off-by: Lars-Peter Clausen &lt;lars@metafoo.de&gt;<br />
---<br />
 drivers/dma/Kconfig      |   6 +<br />
 drivers/dma/Makefile     |   1 +<br />
 drivers/dma/dma-jz4740.c | 428 +++++++++++++++++++++++++++++++++++++++++++++++<br />
 3 files changed, 435 insertions(+)<br />
 create mode 100644 drivers/dma/dma-jz4740.c<br />
<br />
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig<br />
index e992489..b3e8952 100644<br />
--- a/drivers/dma/Kconfig<br />
+++ b/drivers/dma/Kconfig<br />
@@ -312,6 +312,12 @@ config MMP_PDMA<br />
 	help<br />
 	  Support the MMP PDMA engine for PXA and MMP platfrom.<br />
 <br />
+config DMA_JZ4740<br />
+	tristate &quot;JZ4740 DMA support&quot;<br />
+	depends on MACH_JZ4740<br />
+	select DMA_ENGINE<br />
+	select DMA_VIRTUAL_CHANNELS<br />
+<br />
 config DMA_ENGINE<br />
 	bool<br />
 <br />
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile<br />
index a2b0df5..6127a61 100644<br />
--- a/drivers/dma/Makefile<br />
+++ b/drivers/dma/Makefile<br />
@@ -38,3 +38,4 @@ obj-$(CONFIG_DMA_SA11X0) += sa11x0-dma.o<br />
 obj-$(CONFIG_MMP_TDMA) += mmp_tdma.o<br />
 obj-$(CONFIG_DMA_OMAP) += omap-dma.o<br />
 obj-$(CONFIG_MMP_PDMA) += mmp_pdma.o<br />
+obj-$(CONFIG_DMA_JZ4740) += dma-jz4740.o<br />
diff --git a/drivers/dma/dma-jz4740.c b/drivers/dma/dma-jz4740.c<br />
new file mode 100644<br />
index 0000000..210bac0<br />
--- /dev/null<br />
+++ b/drivers/dma/dma-jz4740.c<br />
@@ -0,0 +1,428 @@<br />
+/*<br />
+ *  Copyright (C) 2013, Lars-Peter Clausen &lt;lars@metafoo.de&gt;<br />
+ *  JZ4740 DMAC support<br />
+ *<br />
+ *  This program is free software; you can redistribute it and/or modify it<br />
+ *  under  the terms of the GNU General	 Public License as published by the<br />
+ *  Free Software Foundation;  either version 2 of the License, or (at your<br />
+ *  option) any later version.<br />
+ *<br />
+ *  You should have received a copy of the GNU General Public License along<br />
+ *  with this program; if not, write to the Free Software Foundation, Inc.,<br />
+ *  675 Mass Ave, Cambridge, MA 02139, USA.<br />
+ *<br />
+ */<br />
+<br />
+#include &lt;linux/dmaengine.h&gt;<br />
+#include &lt;linux/dma-mapping.h&gt;<br />
+#include &lt;linux/err.h&gt;<br />
+#include &lt;linux/init.h&gt;<br />
+#include &lt;linux/list.h&gt;<br />
+#include &lt;linux/module.h&gt;<br />
+#include &lt;linux/platform_device.h&gt;<br />
+#include &lt;linux/slab.h&gt;<br />
+#include &lt;linux/spinlock.h&gt;<br />
+<br />
+#include &lt;asm/mach-jz4740/dma.h&gt;<br />
+<br />
+#include &quot;virt-dma.h&quot;<br />
+<br />
+struct jz4740_dma_sg {<br />
+	dma_addr_t addr;<br />
+	unsigned int len;<br />
+};<br />
+<br />
+struct jz4740_dma_desc {<br />
+	struct virt_dma_desc vdesc;<br />
+<br />
+	enum dma_transfer_direction direction;<br />
+	bool cyclic;<br />
+<br />
+	unsigned int num_sgs;<br />
+	struct jz4740_dma_sg sg[];<br />
+};<br />
+<br />
+struct jz4740_dmaengine_chan {<br />
+	struct virt_dma_chan vchan;<br />
+	struct jz4740_dma_chan *jz_chan;<br />
+<br />
+	struct dma_slave_config config;<br />
+<br />
+	struct jz4740_dma_desc *desc;<br />
+	unsigned int next_sg;<br />
+};<br />
+<br />
+struct jz4740_dma_dev {<br />
+	struct dma_device ddev;<br />
+<br />
+	struct jz4740_dmaengine_chan chan[6];<br />
+};<br />
+<br />
+static struct jz4740_dmaengine_chan *to_jz4740_dma_chan(struct dma_chan *c)<br />
+{<br />
+	return container_of(c, struct jz4740_dmaengine_chan, vchan.chan);<br />
+}<br />
+<br />
+static struct jz4740_dma_desc *to_jz4740_dma_desc(struct virt_dma_desc *vdesc)<br />
+{<br />
+	return container_of(vdesc, struct jz4740_dma_desc, vdesc);<br />
+}<br />
+<br />
+static struct jz4740_dma_desc *jz4740_dma_alloc_desc(unsigned int num_sgs)<br />
+{<br />
+	return kzalloc(sizeof(struct jz4740_dma_desc) +<br />
+		sizeof(struct jz4740_dma_sg) * num_sgs, GFP_ATOMIC);<br />
+}<br />
+<br />
+static enum jz4740_dma_width jz4740_dma_width(enum dma_slave_buswidth width)<br />
+{<br />
+	switch (width) {<br />
+	case DMA_SLAVE_BUSWIDTH_1_BYTE:<br />
+		return JZ4740_DMA_WIDTH_8BIT;<br />
+	case DMA_SLAVE_BUSWIDTH_2_BYTES:<br />
+		return JZ4740_DMA_WIDTH_16BIT;<br />
+	case DMA_SLAVE_BUSWIDTH_4_BYTES:<br />
+		return JZ4740_DMA_WIDTH_32BIT;<br />
+	default:<br />
+		return JZ4740_DMA_WIDTH_32BIT;<br />
+	}<br />
+}<br />
+<br />
+static enum jz4740_dma_transfer_size jz4740_dma_maxburst(u32 maxburst)<br />
+{<br />
+	if (maxburst &lt;= 1)<br />
+		return JZ4740_DMA_TRANSFER_SIZE_1BYTE;<br />
+	else if (maxburst &lt;= 3)<br />
+		return JZ4740_DMA_TRANSFER_SIZE_2BYTE;<br />
+	else if (maxburst &lt;= 15)<br />
+		return JZ4740_DMA_TRANSFER_SIZE_4BYTE;<br />
+	else if (maxburst &lt;= 31)<br />
+		return JZ4740_DMA_TRANSFER_SIZE_16BYTE;<br />
+<br />
+	return JZ4740_DMA_TRANSFER_SIZE_32BYTE;<br />
+}<br />
+<br />
+static int jz4740_dma_slave_config(struct dma_chan *c,<br />
+	const struct dma_slave_config *config)<br />
+{<br />
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);<br />
+	struct jz4740_dma_config jzcfg;<br />
+<br />
+	switch (config-&gt;direction) {<br />
+	case DMA_MEM_TO_DEV:<br />
+		jzcfg.flags = JZ4740_DMA_SRC_AUTOINC;<br />
+		jzcfg.transfer_size = jz4740_dma_maxburst(config-&gt;dst_maxburst);<br />
+		break;<br />
+	case DMA_DEV_TO_MEM:<br />
+		jzcfg.flags = JZ4740_DMA_DST_AUTOINC;<br />
+		jzcfg.transfer_size = jz4740_dma_maxburst(config-&gt;src_maxburst);<br />
+		break;<br />
+	default:<br />
+		return -EINVAL;<br />
+	}<br />
+<br />
+<br />
+	jzcfg.src_width = jz4740_dma_width(config-&gt;src_addr_width);<br />
+	jzcfg.dst_width = jz4740_dma_width(config-&gt;dst_addr_width);<br />
+	jzcfg.mode = JZ4740_DMA_MODE_SINGLE;<br />
+	jzcfg.request_type = config-&gt;slave_id;<br />
+<br />
+	chan-&gt;config = *config;<br />
+<br />
+	jz4740_dma_configure(chan-&gt;jz_chan, &amp;jzcfg);<br />
+<br />
+	return 0;<br />
+}<br />
+<br />
+static int jz4740_dma_terminate_all(struct dma_chan *c)<br />
+{<br />
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);<br />
+	unsigned long flags;<br />
+	LIST_HEAD(head);<br />
+<br />
+	spin_lock_irqsave(&amp;chan-&gt;vchan.lock, flags);<br />
+	jz4740_dma_disable(chan-&gt;jz_chan);<br />
+	chan-&gt;desc = NULL;<br />
+	vchan_get_all_descriptors(&amp;chan-&gt;vchan, &amp;head);<br />
+	spin_unlock_irqrestore(&amp;chan-&gt;vchan.lock, flags);<br />
+<br />
+	vchan_dma_desc_free_list(&amp;chan-&gt;vchan, &amp;head);<br />
+<br />
+	return 0;<br />
+}<br />
+<br />
+static int jz4740_dma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,<br />
+	unsigned long arg)<br />
+{<br />
+	struct dma_slave_config *config = (struct dma_slave_config *)arg;<br />
+<br />
+	switch (cmd) {<br />
+	case DMA_SLAVE_CONFIG:<br />
+		return jz4740_dma_slave_config(chan, config);<br />
+	case DMA_TERMINATE_ALL:<br />
+		return jz4740_dma_terminate_all(chan);<br />
+	default:<br />
+		return -EINVAL;<br />
+	}<br />
+}<br />
+<br />
+static int jz4740_dma_start_transfer(struct jz4740_dmaengine_chan *chan)<br />
+{<br />
+	struct virt_dma_desc *vdesc;<br />
+	struct jz4740_dma_sg *sg;<br />
+<br />
+	jz4740_dma_disable(chan-&gt;jz_chan);<br />
+<br />
+	if (!chan-&gt;desc) {<br />
+		vdesc = vchan_next_desc(&amp;chan-&gt;vchan);<br />
+		if (!vdesc)<br />
+			return 0;<br />
+		chan-&gt;desc = to_jz4740_dma_desc(vdesc);<br />
+		chan-&gt;next_sg = 0;<br />
+	}<br />
+<br />
+	if (chan-&gt;next_sg == chan-&gt;desc-&gt;num_sgs)<br />
+		chan-&gt;next_sg = 0;<br />
+<br />
+	sg = &amp;chan-&gt;desc-&gt;sg[chan-&gt;next_sg];<br />
+<br />
+	if (chan-&gt;desc-&gt;direction == DMA_MEM_TO_DEV) {<br />
+		jz4740_dma_set_src_addr(chan-&gt;jz_chan, sg-&gt;addr);<br />
+		jz4740_dma_set_dst_addr(chan-&gt;jz_chan, chan-&gt;config.dst_addr);<br />
+	} else {<br />
+		jz4740_dma_set_src_addr(chan-&gt;jz_chan, chan-&gt;config.src_addr);<br />
+		jz4740_dma_set_dst_addr(chan-&gt;jz_chan, sg-&gt;addr);<br />
+	}<br />
+	jz4740_dma_set_transfer_count(chan-&gt;jz_chan, sg-&gt;len);<br />
+<br />
+	chan-&gt;next_sg++;<br />
+<br />
+	jz4740_dma_enable(chan-&gt;jz_chan);<br />
+<br />
+	return 0;<br />
+}<br />
+<br />
+static void jz4740_dma_complete_cb(struct jz4740_dma_chan *jz_chan, int error,<br />
+	void *devid)<br />
+{<br />
+	struct jz4740_dmaengine_chan *chan = devid;<br />
+<br />
+	spin_lock(&amp;chan-&gt;vchan.lock);<br />
+	if (chan-&gt;desc) {<br />
+		if (chan-&gt;desc &amp;&amp; chan-&gt;desc-&gt;cyclic) {<br />
+			vchan_cyclic_callback(&amp;chan-&gt;desc-&gt;vdesc);<br />
+		} else {<br />
+			if (chan-&gt;next_sg == chan-&gt;desc-&gt;num_sgs) {<br />
+				chan-&gt;desc = NULL;<br />
+				vchan_cookie_complete(&amp;chan-&gt;desc-&gt;vdesc);<br />
+			}<br />
+		}<br />
+	}<br />
+	jz4740_dma_start_transfer(chan);<br />
+	spin_unlock(&amp;chan-&gt;vchan.lock);<br />
+}<br />
+<br />
+static void jz4740_dma_issue_pending(struct dma_chan *c)<br />
+{<br />
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);<br />
+	unsigned long flags;<br />
+<br />
+	spin_lock_irqsave(&amp;chan-&gt;vchan.lock, flags);<br />
+	if (vchan_issue_pending(&amp;chan-&gt;vchan) &amp;&amp; !chan-&gt;desc)<br />
+		jz4740_dma_start_transfer(chan);<br />
+	spin_unlock_irqrestore(&amp;chan-&gt;vchan.lock, flags);<br />
+}<br />
+<br />
+static struct dma_async_tx_descriptor *jz4740_dma_prep_slave_sg(<br />
+	struct dma_chan *c, struct scatterlist *sgl,<br />
+	unsigned int sg_len, enum dma_transfer_direction direction,<br />
+	unsigned long flags, void *context)<br />
+{<br />
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);<br />
+	struct jz4740_dma_desc *desc;<br />
+	struct scatterlist *sg;<br />
+	unsigned int i;<br />
+<br />
+	desc = jz4740_dma_alloc_desc(sg_len);<br />
+	if (!desc)<br />
+		return NULL;<br />
+<br />
+	for_each_sg(sgl, sg, sg_len, i) {<br />
+		desc-&gt;sg<i>.addr = sg_dma_address(sg);<br />
+		desc-&gt;sg<i>.len = sg_dma_len(sg);<br />
+	}<br />
+<br />
+	desc-&gt;num_sgs = sg_len;<br />
+	desc-&gt;direction = direction;<br />
+	desc-&gt;cyclic = false;<br />
+<br />
+	return vchan_tx_prep(&amp;chan-&gt;vchan, &amp;desc-&gt;vdesc, flags);<br />
+}<br />
+<br />
+static struct dma_async_tx_descriptor *jz4740_dma_prep_dma_cyclic(<br />
+	struct dma_chan *c, dma_addr_t buf_addr, size_t buf_len,<br />
+	size_t period_len, enum dma_transfer_direction direction,<br />
+	unsigned long flags, void *context)<br />
+{<br />
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);<br />
+	struct jz4740_dma_desc *desc;<br />
+	unsigned int num_periods, i;<br />
+<br />
+	if (buf_len % period_len)<br />
+		return NULL;<br />
+<br />
+	num_periods = buf_len / period_len;<br />
+<br />
+	desc = jz4740_dma_alloc_desc(num_periods);<br />
+	if (!desc)<br />
+		return NULL;<br />
+<br />
+	for (i = 0; i &lt; num_periods; i++) {<br />
+		desc-&gt;sg<i>.addr = buf_addr;<br />
+		desc-&gt;sg<i>.len = period_len;<br />
+		buf_addr += period_len;<br />
+	}<br />
+<br />
+	desc-&gt;num_sgs = num_periods;<br />
+	desc-&gt;direction = direction;<br />
+	desc-&gt;cyclic = true;<br />
+<br />
+	return vchan_tx_prep(&amp;chan-&gt;vchan, &amp;desc-&gt;vdesc, flags);<br />
+}<br />
+<br />
+static size_t jz4740_dma_desc_residue(struct jz4740_dmaengine_chan *chan,<br />
+	struct jz4740_dma_desc *desc, unsigned int next_sg)<br />
+{<br />
+	size_t residue = 0;<br />
+	unsigned int i;<br />
+<br />
+	residue = 0;<br />
+<br />
+	for (i = next_sg; i &lt; desc-&gt;num_sgs; i++)<br />
+		residue += desc-&gt;sg<i>.len;<br />
+<br />
+	if (next_sg != 0)<br />
+		residue += jz4740_dma_get_residue(chan-&gt;jz_chan);<br />
+<br />
+	return residue;<br />
+}<br />
+<br />
+static enum dma_status jz4740_dma_tx_status(struct dma_chan *c,<br />
+	dma_cookie_t cookie, struct dma_tx_state *state)<br />
+{<br />
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);<br />
+	struct virt_dma_desc *vdesc;<br />
+	enum dma_status status;<br />
+	unsigned long flags;<br />
+<br />
+	status = dma_cookie_status(c, cookie, state);<br />
+	if (status == DMA_SUCCESS || !state)<br />
+		return status;<br />
+<br />
+	spin_lock_irqsave(&amp;chan-&gt;vchan.lock, flags);<br />
+	vdesc = vchan_find_desc(&amp;chan-&gt;vchan, cookie);<br />
+	if (cookie == chan-&gt;desc-&gt;vdesc.tx.cookie) {<br />
+		state-&gt;residue = jz4740_dma_desc_residue(chan, chan-&gt;desc,<br />
+				chan-&gt;next_sg);<br />
+	} else if (vdesc) {<br />
+		state-&gt;residue = jz4740_dma_desc_residue(chan,<br />
+				to_jz4740_dma_desc(vdesc), 0);<br />
+	} else {<br />
+		state-&gt;residue = 0;<br />
+	}<br />
+	spin_unlock_irqrestore(&amp;chan-&gt;vchan.lock, flags);<br />
+<br />
+	return status;<br />
+}<br />
+<br />
+static int jz4740_dma_alloc_chan_resources(struct dma_chan *c)<br />
+{<br />
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);<br />
+<br />
+	chan-&gt;jz_chan = jz4740_dma_request(chan, NULL);<br />
+	if (!chan-&gt;jz_chan)<br />
+		return -EBUSY;<br />
+<br />
+	jz4740_dma_set_complete_cb(chan-&gt;jz_chan, jz4740_dma_complete_cb);<br />
+<br />
+	return 0;<br />
+}<br />
+<br />
+static void jz4740_dma_free_chan_resources(struct dma_chan *c)<br />
+{<br />
+	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);<br />
+<br />
+	vchan_free_chan_resources(&amp;chan-&gt;vchan);<br />
+	jz4740_dma_free(chan-&gt;jz_chan);<br />
+	chan-&gt;jz_chan = NULL;<br />
+}<br />
+<br />
+static void jz4740_dma_desc_free(struct virt_dma_desc *vdesc)<br />
+{<br />
+	kfree(container_of(vdesc, struct jz4740_dma_desc, vdesc));<br />
+}<br />
+<br />
+static int jz4740_dma_probe(struct platform_device *pdev)<br />
+{<br />
+	struct jz4740_dmaengine_chan *chan;<br />
+	struct jz4740_dma_dev *dmadev;<br />
+	struct dma_device *dd;<br />
+	unsigned int i;<br />
+	int ret;<br />
+<br />
+	dmadev = devm_kzalloc(&amp;pdev-&gt;dev, sizeof(*dmadev), GFP_KERNEL);<br />
+	if (!dmadev)<br />
+		return -EINVAL;<br />
+<br />
+	dd = &amp;dmadev-&gt;ddev;<br />
+<br />
+	dma_cap_set(DMA_SLAVE, dd-&gt;cap_mask);<br />
+	dma_cap_set(DMA_CYCLIC, dd-&gt;cap_mask);<br />
+	dd-&gt;device_alloc_chan_resources = jz4740_dma_alloc_chan_resources;<br />
+	dd-&gt;device_free_chan_resources = jz4740_dma_free_chan_resources;<br />
+	dd-&gt;device_tx_status = jz4740_dma_tx_status;<br />
+	dd-&gt;device_issue_pending = jz4740_dma_issue_pending;<br />
+	dd-&gt;device_prep_slave_sg = jz4740_dma_prep_slave_sg;<br />
+	dd-&gt;device_prep_dma_cyclic = jz4740_dma_prep_dma_cyclic;<br />
+	dd-&gt;device_control = jz4740_dma_control;<br />
+	dd-&gt;dev = &amp;pdev-&gt;dev;<br />
+	dd-&gt;chancnt = 6;<br />
+	INIT_LIST_HEAD(&amp;dd-&gt;channels);<br />
+<br />
+	for (i = 0; i &lt; dd-&gt;chancnt; i++) {<br />
+		chan = &amp;dmadev-&gt;chan<i>;<br />
+		chan-&gt;vchan.desc_free = jz4740_dma_desc_free;<br />
+		vchan_init(&amp;chan-&gt;vchan, dd);<br />
+	}<br />
+<br />
+	ret = dma_async_device_register(dd);<br />
+	if (ret)<br />
+		return ret;<br />
+<br />
+	platform_set_drvdata(pdev, dmadev);<br />
+<br />
+	return 0;<br />
+}<br />
+<br />
+static int jz4740_dma_remove(struct platform_device *pdev)<br />
+{<br />
+	struct jz4740_dma_dev *dmadev = platform_get_drvdata(pdev);<br />
+<br />
+	dma_async_device_unregister(&amp;dmadev-&gt;ddev);<br />
+<br />
+	return 0;<br />
+}<br />
+<br />
+static struct platform_driver jz4740_dma_driver = {<br />
+	.probe = jz4740_dma_probe,<br />
+	.remove = jz4740_dma_remove,<br />
+	.driver = {<br />
+		.name = &quot;jz4740-dma&quot;,<br />
+		.owner = THIS_MODULE,<br />
+	},<br />
+};<br />
+module_platform_driver(jz4740_dma_driver);<br />
+<br />
+MODULE_AUTHOR(&quot;Lars-Peter Clausen &lt;lars@metafoo.de&gt;&quot;);<br />
+MODULE_DESCRIPTION(&quot;JZ4740 DMA driver&quot;);<br />
+MODULE_LICENSE(&quot;GPLv2&quot;);<br />
-- <br />
1.8.2.1<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a></i></i></i></i></i></i>]]></description>
            <dc:creator>Lars-Peter Clausen</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Fri, 24 May 2013 08:00:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712194,712194#msg-712194</guid>
            <title>[PATCH 5/6] ASoC: jz4740: Use the generic dmaengine PCM driver (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712194,712194#msg-712194</link>
            <description><![CDATA[ Since there is a dmaengine driver for the jz4740 DMA controller now we can use<br />
the generic dmaengine PCM driver instead of a custom one.<br />
<br />
Signed-off-by: Lars-Peter Clausen &lt;lars@metafoo.de&gt;<br />
---<br />
 sound/soc/jz4740/Kconfig      |   1 +<br />
 sound/soc/jz4740/jz4740-i2s.c |  48 +++----<br />
 sound/soc/jz4740/jz4740-pcm.c | 310 ++----------------------------------------<br />
 sound/soc/jz4740/jz4740-pcm.h |  20 ---<br />
 4 files changed, 27 insertions(+), 352 deletions(-)<br />
 delete mode 100644 sound/soc/jz4740/jz4740-pcm.h<br />
<br />
diff --git a/sound/soc/jz4740/Kconfig b/sound/soc/jz4740/Kconfig<br />
index 5351cba..29f76af 100644<br />
--- a/sound/soc/jz4740/Kconfig<br />
+++ b/sound/soc/jz4740/Kconfig<br />
@@ -1,6 +1,7 @@<br />
 config SND_JZ4740_SOC<br />
 	tristate &quot;SoC Audio for Ingenic JZ4740 SoC&quot;<br />
 	depends on MACH_JZ4740 &amp;&amp; SND_SOC<br />
+	select SND_SOC_GENERIC_DMAENGINE_PCM<br />
 	help<br />
 	  Say Y or M if you want to add support for codecs attached to<br />
 	  the JZ4740 I2S interface. You will also need to select the audio<br />
diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c<br />
index 4c849a4..47d3b4c 100644<br />
--- a/sound/soc/jz4740/jz4740-i2s.c<br />
+++ b/sound/soc/jz4740/jz4740-i2s.c<br />
@@ -29,9 +29,12 @@<br />
 #include &lt;sound/pcm_params.h&gt;<br />
 #include &lt;sound/soc.h&gt;<br />
 #include &lt;sound/initval.h&gt;<br />
+#include &lt;sound/dmaengine_pcm.h&gt;<br />
+<br />
+#include &lt;asm/mach-jz4740/dma.h&gt;<br />
 <br />
 #include &quot;jz4740-i2s.h&quot;<br />
-#include &quot;jz4740-pcm.h&quot;<br />
+<br />
 <br />
 #define JZ_REG_AIC_CONF		0x00<br />
 #define JZ_REG_AIC_CTRL		0x04<br />
@@ -89,8 +92,8 @@ struct jz4740_i2s {<br />
 	struct clk *clk_aic;<br />
 	struct clk *clk_i2s;<br />
 <br />
-	struct jz4740_pcm_config pcm_config_playback;<br />
-	struct jz4740_pcm_config pcm_config_capture;<br />
+	struct snd_dmaengine_dai_dma_data playback_dma_data;<br />
+	struct snd_dmaengine_dai_dma_data capture_dma_data;<br />
 };<br />
 <br />
 static inline uint32_t jz4740_i2s_read(const struct jz4740_i2s *i2s,<br />
@@ -233,8 +236,6 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream,<br />
 	struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)<br />
 {<br />
 	struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);<br />
-	enum jz4740_dma_width dma_width;<br />
-	struct jz4740_pcm_config *pcm_config;<br />
 	unsigned int sample_size;<br />
 	uint32_t ctrl;<br />
 <br />
@@ -243,11 +244,9 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream,<br />
 	switch (params_format(params)) {<br />
 	case SNDRV_PCM_FORMAT_S8:<br />
 		sample_size = 0;<br />
-		dma_width = JZ4740_DMA_WIDTH_8BIT;<br />
 		break;<br />
 	case SNDRV_PCM_FORMAT_S16:<br />
 		sample_size = 1;<br />
-		dma_width = JZ4740_DMA_WIDTH_16BIT;<br />
 		break;<br />
 	default:<br />
 		return -EINVAL;<br />
@@ -260,22 +259,13 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream,<br />
 			ctrl |= JZ_AIC_CTRL_MONO_TO_STEREO;<br />
 		else<br />
 			ctrl &amp;= ~JZ_AIC_CTRL_MONO_TO_STEREO;<br />
-<br />
-		pcm_config = &amp;i2s-&gt;pcm_config_playback;<br />
-		pcm_config-&gt;dma_config.dst_width = dma_width;<br />
-<br />
 	} else {<br />
 		ctrl &amp;= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK;<br />
 		ctrl |= sample_size &lt;&lt; JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET;<br />
-<br />
-		pcm_config = &amp;i2s-&gt;pcm_config_capture;<br />
-		pcm_config-&gt;dma_config.src_width = dma_width;<br />
 	}<br />
 <br />
 	jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl);<br />
 <br />
-	snd_soc_dai_set_dma_data(dai, substream, pcm_config);<br />
-<br />
 	return 0;<br />
 }<br />
 <br />
@@ -342,25 +332,19 @@ static int jz4740_i2s_resume(struct snd_soc_dai *dai)<br />
 <br />
 static void jz4740_i2c_init_pcm_config(struct jz4740_i2s *i2s)<br />
 {<br />
-	struct jz4740_dma_config *dma_config;<br />
+	struct snd_dmaengine_dai_dma_data *dma_data;<br />
 <br />
 	/* Playback */<br />
-	dma_config = &amp;i2s-&gt;pcm_config_playback.dma_config;<br />
-	dma_config-&gt;src_width = JZ4740_DMA_WIDTH_32BIT;<br />
-	dma_config-&gt;transfer_size = JZ4740_DMA_TRANSFER_SIZE_16BYTE;<br />
-	dma_config-&gt;request_type = JZ4740_DMA_TYPE_AIC_TRANSMIT;<br />
-	dma_config-&gt;flags = JZ4740_DMA_SRC_AUTOINC;<br />
-	dma_config-&gt;mode = JZ4740_DMA_MODE_SINGLE;<br />
-	i2s-&gt;pcm_config_playback.fifo_addr = i2s-&gt;phys_base + JZ_REG_AIC_FIFO;<br />
+	dma_data = &amp;i2s-&gt;playback_dma_data;<br />
+	dma_data-&gt;maxburst = 16;<br />
+	dma_data-&gt;slave_id = JZ4740_DMA_TYPE_AIC_TRANSMIT;<br />
+	dma_data-&gt;addr = i2s-&gt;phys_base + JZ_REG_AIC_FIFO;<br />
 <br />
 	/* Capture */<br />
-	dma_config = &amp;i2s-&gt;pcm_config_capture.dma_config;<br />
-	dma_config-&gt;dst_width = JZ4740_DMA_WIDTH_32BIT;<br />
-	dma_config-&gt;transfer_size = JZ4740_DMA_TRANSFER_SIZE_16BYTE;<br />
-	dma_config-&gt;request_type = JZ4740_DMA_TYPE_AIC_RECEIVE;<br />
-	dma_config-&gt;flags = JZ4740_DMA_DST_AUTOINC;<br />
-	dma_config-&gt;mode = JZ4740_DMA_MODE_SINGLE;<br />
-	i2s-&gt;pcm_config_capture.fifo_addr = i2s-&gt;phys_base + JZ_REG_AIC_FIFO;<br />
+	dma_data = &amp;i2s-&gt;capture_dma_data;<br />
+	dma_data-&gt;maxburst = 16;<br />
+	dma_data-&gt;slave_id = JZ4740_DMA_TYPE_AIC_RECEIVE;<br />
+	dma_data-&gt;addr = i2s-&gt;phys_base + JZ_REG_AIC_FIFO;<br />
 }<br />
 <br />
 static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai)<br />
@@ -371,6 +355,8 @@ static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai)<br />
 	clk_prepare_enable(i2s-&gt;clk_aic);<br />
 <br />
 	jz4740_i2c_init_pcm_config(i2s);<br />
+	dai-&gt;playback_dma_data = &amp;i2s-&gt;playback_dma_data;<br />
+	dai-&gt;capture_dma_data = &amp;i2s-&gt;capture_dma_data;<br />
 <br />
 	conf = (7 &lt;&lt; JZ_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET) |<br />
 		(8 &lt;&lt; JZ_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET) |<br />
diff --git a/sound/soc/jz4740/jz4740-pcm.c b/sound/soc/jz4740/jz4740-pcm.c<br />
index 7100592..79fcade 100644<br />
--- a/sound/soc/jz4740/jz4740-pcm.c<br />
+++ b/sound/soc/jz4740/jz4740-pcm.c<br />
@@ -19,38 +19,14 @@<br />
 #include &lt;linux/platform_device.h&gt;<br />
 #include &lt;linux/slab.h&gt;<br />
 <br />
-#include &lt;linux/dma-mapping.h&gt;<br />
+#include &lt;sound/dmaengine_pcm.h&gt;<br />
 <br />
-#include &lt;sound/core.h&gt;<br />
-#include &lt;sound/pcm.h&gt;<br />
-#include &lt;sound/pcm_params.h&gt;<br />
-#include &lt;sound/soc.h&gt;<br />
-<br />
-#include &lt;asm/mach-jz4740/dma.h&gt;<br />
-#include &quot;jz4740-pcm.h&quot;<br />
-<br />
-struct jz4740_runtime_data {<br />
-	unsigned long dma_period;<br />
-	dma_addr_t dma_start;<br />
-	dma_addr_t dma_pos;<br />
-	dma_addr_t dma_end;<br />
-<br />
-	struct jz4740_dma_chan *dma;<br />
-<br />
-	dma_addr_t fifo_addr;<br />
-};<br />
-<br />
-/* identify hardware playback capabilities */<br />
 static const struct snd_pcm_hardware jz4740_pcm_hardware = {<br />
 	.info = SNDRV_PCM_INFO_MMAP |<br />
 		SNDRV_PCM_INFO_MMAP_VALID |<br />
 		SNDRV_PCM_INFO_INTERLEAVED |<br />
 		SNDRV_PCM_INFO_BLOCK_TRANSFER,<br />
 	.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8,<br />
-<br />
-	.rates			= SNDRV_PCM_RATE_8000_48000,<br />
-	.channels_min		= 1,<br />
-	.channels_max		= 2,<br />
 	.period_bytes_min	= 16,<br />
 	.period_bytes_max	= 2 * PAGE_SIZE,<br />
 	.periods_min		= 2,<br />
@@ -59,290 +35,22 @@ static const struct snd_pcm_hardware jz4740_pcm_hardware = {<br />
 	.fifo_size		= 32,<br />
 };<br />
 <br />
-static void jz4740_pcm_start_transfer(struct jz4740_runtime_data *prtd,<br />
-	struct snd_pcm_substream *substream)<br />
-{<br />
-	unsigned long count;<br />
-<br />
-	if (prtd-&gt;dma_pos == prtd-&gt;dma_end)<br />
-		prtd-&gt;dma_pos = prtd-&gt;dma_start;<br />
-<br />
-	if (prtd-&gt;dma_pos + prtd-&gt;dma_period &gt; prtd-&gt;dma_end)<br />
-		count = prtd-&gt;dma_end - prtd-&gt;dma_pos;<br />
-	else<br />
-		count = prtd-&gt;dma_period;<br />
-<br />
-	jz4740_dma_disable(prtd-&gt;dma);<br />
-<br />
-	if (substream-&gt;stream == SNDRV_PCM_STREAM_PLAYBACK) {<br />
-		jz4740_dma_set_src_addr(prtd-&gt;dma, prtd-&gt;dma_pos);<br />
-		jz4740_dma_set_dst_addr(prtd-&gt;dma, prtd-&gt;fifo_addr);<br />
-	} else {<br />
-		jz4740_dma_set_src_addr(prtd-&gt;dma, prtd-&gt;fifo_addr);<br />
-		jz4740_dma_set_dst_addr(prtd-&gt;dma, prtd-&gt;dma_pos);<br />
-	}<br />
-<br />
-	jz4740_dma_set_transfer_count(prtd-&gt;dma, count);<br />
-<br />
-	prtd-&gt;dma_pos += count;<br />
-<br />
-	jz4740_dma_enable(prtd-&gt;dma);<br />
-}<br />
-<br />
-static void jz4740_pcm_dma_transfer_done(struct jz4740_dma_chan *dma, int err,<br />
-	void *dev_id)<br />
-{<br />
-	struct snd_pcm_substream *substream = dev_id;<br />
-	struct snd_pcm_runtime *runtime = substream-&gt;runtime;<br />
-	struct jz4740_runtime_data *prtd = runtime-&gt;private_data;<br />
-<br />
-	snd_pcm_period_elapsed(substream);<br />
-<br />
-	jz4740_pcm_start_transfer(prtd, substream);<br />
-}<br />
-<br />
-static int jz4740_pcm_hw_params(struct snd_pcm_substream *substream,<br />
-	struct snd_pcm_hw_params *params)<br />
-{<br />
-	struct snd_pcm_runtime *runtime = substream-&gt;runtime;<br />
-	struct jz4740_runtime_data *prtd = runtime-&gt;private_data;<br />
-	struct snd_soc_pcm_runtime *rtd = substream-&gt;private_data;<br />
-	struct jz4740_pcm_config *config;<br />
-<br />
-	config = snd_soc_dai_get_dma_data(rtd-&gt;cpu_dai, substream);<br />
-<br />
-	if (!config)<br />
-		return 0;<br />
-<br />
-	if (!prtd-&gt;dma) {<br />
-		if (substream-&gt;stream == SNDRV_PCM_STREAM_CAPTURE)<br />
-			prtd-&gt;dma = jz4740_dma_request(substream, &quot;PCM Capture&quot;);<br />
-		else<br />
-			prtd-&gt;dma = jz4740_dma_request(substream, &quot;PCM Playback&quot;);<br />
-	}<br />
-<br />
-	if (!prtd-&gt;dma)<br />
-		return -EBUSY;<br />
-<br />
-	jz4740_dma_configure(prtd-&gt;dma, &amp;config-&gt;dma_config);<br />
-	prtd-&gt;fifo_addr = config-&gt;fifo_addr;<br />
-<br />
-	jz4740_dma_set_complete_cb(prtd-&gt;dma, jz4740_pcm_dma_transfer_done);<br />
-<br />
-	snd_pcm_set_runtime_buffer(substream, &amp;substream-&gt;dma_buffer);<br />
-	runtime-&gt;dma_bytes = params_buffer_bytes(params);<br />
-<br />
-	prtd-&gt;dma_period = params_period_bytes(params);<br />
-	prtd-&gt;dma_start = runtime-&gt;dma_addr;<br />
-	prtd-&gt;dma_pos = prtd-&gt;dma_start;<br />
-	prtd-&gt;dma_end = prtd-&gt;dma_start + runtime-&gt;dma_bytes;<br />
-<br />
-	return 0;<br />
-}<br />
-<br />
-static int jz4740_pcm_hw_free(struct snd_pcm_substream *substream)<br />
-{<br />
-	struct jz4740_runtime_data *prtd = substream-&gt;runtime-&gt;private_data;<br />
-<br />
-	snd_pcm_set_runtime_buffer(substream, NULL);<br />
-	if (prtd-&gt;dma) {<br />
-		jz4740_dma_free(prtd-&gt;dma);<br />
-		prtd-&gt;dma = NULL;<br />
-	}<br />
-<br />
-	return 0;<br />
-}<br />
-<br />
-static int jz4740_pcm_prepare(struct snd_pcm_substream *substream)<br />
-{<br />
-	struct jz4740_runtime_data *prtd = substream-&gt;runtime-&gt;private_data;<br />
-<br />
-	if (!prtd-&gt;dma)<br />
-		return -EBUSY;<br />
-<br />
-	prtd-&gt;dma_pos = prtd-&gt;dma_start;<br />
-<br />
-	return 0;<br />
-}<br />
-<br />
-static int jz4740_pcm_trigger(struct snd_pcm_substream *substream, int cmd)<br />
-{<br />
-	struct snd_pcm_runtime *runtime = substream-&gt;runtime;<br />
-	struct jz4740_runtime_data *prtd = runtime-&gt;private_data;<br />
-<br />
-	switch (cmd) {<br />
-	case SNDRV_PCM_TRIGGER_START:<br />
-	case SNDRV_PCM_TRIGGER_RESUME:<br />
-	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:<br />
-		jz4740_pcm_start_transfer(prtd, substream);<br />
-		break;<br />
-	case SNDRV_PCM_TRIGGER_STOP:<br />
-	case SNDRV_PCM_TRIGGER_SUSPEND:<br />
-	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:<br />
-		jz4740_dma_disable(prtd-&gt;dma);<br />
-		break;<br />
-	default:<br />
-		break;<br />
-	}<br />
-<br />
-	return 0;<br />
-}<br />
-<br />
-static snd_pcm_uframes_t jz4740_pcm_pointer(struct snd_pcm_substream *substream)<br />
-{<br />
-	struct snd_pcm_runtime *runtime = substream-&gt;runtime;<br />
-	struct jz4740_runtime_data *prtd = runtime-&gt;private_data;<br />
-	unsigned long byte_offset;<br />
-	snd_pcm_uframes_t offset;<br />
-	struct jz4740_dma_chan *dma = prtd-&gt;dma;<br />
-<br />
-	/* prtd-&gt;dma_pos points to the end of the current transfer. So by<br />
-	 * subtracting prdt-&gt;dma_start we get the offset to the end of the<br />
-	 * current period in bytes. By subtracting the residue of the transfer<br />
-	 * we get the current offset in bytes. */<br />
-	byte_offset = prtd-&gt;dma_pos - prtd-&gt;dma_start;<br />
-	byte_offset -= jz4740_dma_get_residue(dma);<br />
-<br />
-	offset = bytes_to_frames(runtime, byte_offset);<br />
-	if (offset &gt;= runtime-&gt;buffer_size)<br />
-		offset = 0;<br />
-<br />
-	return offset;<br />
-}<br />
-<br />
-static int jz4740_pcm_open(struct snd_pcm_substream *substream)<br />
-{<br />
-	struct snd_pcm_runtime *runtime = substream-&gt;runtime;<br />
-	struct jz4740_runtime_data *prtd;<br />
-<br />
-	prtd = kzalloc(sizeof(*prtd), GFP_KERNEL);<br />
-	if (prtd == NULL)<br />
-		return -ENOMEM;<br />
-<br />
-	snd_soc_set_runtime_hwparams(substream, &amp;jz4740_pcm_hardware);<br />
-<br />
-	runtime-&gt;private_data = prtd;<br />
-<br />
-	return 0;<br />
-}<br />
-<br />
-static int jz4740_pcm_close(struct snd_pcm_substream *substream)<br />
-{<br />
-	struct snd_pcm_runtime *runtime = substream-&gt;runtime;<br />
-	struct jz4740_runtime_data *prtd = runtime-&gt;private_data;<br />
-<br />
-	kfree(prtd);<br />
-<br />
-	return 0;<br />
-}<br />
-<br />
-static int jz4740_pcm_mmap(struct snd_pcm_substream *substream,<br />
-	struct vm_area_struct *vma)<br />
-{<br />
-	return remap_pfn_range(vma, vma-&gt;vm_start,<br />
-			substream-&gt;dma_buffer.addr &gt;&gt; PAGE_SHIFT,<br />
-			vma-&gt;vm_end - vma-&gt;vm_start, vma-&gt;vm_page_prot);<br />
-}<br />
-<br />
-static struct snd_pcm_ops jz4740_pcm_ops = {<br />
-	.open		= jz4740_pcm_open,<br />
-	.close		= jz4740_pcm_close,<br />
-	.ioctl		= snd_pcm_lib_ioctl,<br />
-	.hw_params	= jz4740_pcm_hw_params,<br />
-	.hw_free	= jz4740_pcm_hw_free,<br />
-	.prepare	= jz4740_pcm_prepare,<br />
-	.trigger	= jz4740_pcm_trigger,<br />
-	.pointer	= jz4740_pcm_pointer,<br />
-	.mmap		= jz4740_pcm_mmap,<br />
-};<br />
-<br />
-static int jz4740_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)<br />
-{<br />
-	struct snd_pcm_substream *substream = pcm-&gt;streams[stream].substream;<br />
-	struct snd_dma_buffer *buf = &amp;substream-&gt;dma_buffer;<br />
-	size_t size = jz4740_pcm_hardware.buffer_bytes_max;<br />
-<br />
-	buf-&gt;dev.type = SNDRV_DMA_TYPE_DEV;<br />
-	buf-&gt;dev.dev = pcm-&gt;card-&gt;dev;<br />
-	buf-&gt;private_data = NULL;<br />
-<br />
-	buf-&gt;area = dma_alloc_noncoherent(pcm-&gt;card-&gt;dev, size,<br />
-					  &amp;buf-&gt;addr, GFP_KERNEL);<br />
-	if (!buf-&gt;area)<br />
-		return -ENOMEM;<br />
-<br />
-	buf-&gt;bytes = size;<br />
-<br />
-	return 0;<br />
-}<br />
-<br />
-static void jz4740_pcm_free(struct snd_pcm *pcm)<br />
-{<br />
-	struct snd_pcm_substream *substream;<br />
-	struct snd_dma_buffer *buf;<br />
-	int stream;<br />
-<br />
-	for (stream = 0; stream &lt; SNDRV_PCM_STREAM_LAST; ++stream) {<br />
-		substream = pcm-&gt;streams[stream].substream;<br />
-		if (!substream)<br />
-			continue;<br />
-<br />
-		buf = &amp;substream-&gt;dma_buffer;<br />
-		if (!buf-&gt;area)<br />
-			continue;<br />
-<br />
-		dma_free_noncoherent(pcm-&gt;card-&gt;dev, buf-&gt;bytes, buf-&gt;area,<br />
-				buf-&gt;addr);<br />
-		buf-&gt;area = NULL;<br />
-	}<br />
-}<br />
-<br />
-static u64 jz4740_pcm_dmamask = DMA_BIT_MASK(32);<br />
-<br />
-static int jz4740_pcm_new(struct snd_soc_pcm_runtime *rtd)<br />
-{<br />
-	struct snd_card *card = rtd-&gt;card-&gt;snd_card;<br />
-	struct snd_pcm *pcm = rtd-&gt;pcm;<br />
-	int ret = 0;<br />
-<br />
-	if (!card-&gt;dev-&gt;dma_mask)<br />
-		card-&gt;dev-&gt;dma_mask = &amp;jz4740_pcm_dmamask;<br />
-<br />
-	if (!card-&gt;dev-&gt;coherent_dma_mask)<br />
-		card-&gt;dev-&gt;coherent_dma_mask = DMA_BIT_MASK(32);<br />
-<br />
-	if (pcm-&gt;streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {<br />
-		ret = jz4740_pcm_preallocate_dma_buffer(pcm,<br />
-			SNDRV_PCM_STREAM_PLAYBACK);<br />
-		if (ret)<br />
-			goto err;<br />
-	}<br />
-<br />
-	if (pcm-&gt;streams[SNDRV_PCM_STREAM_CAPTURE].substream) {<br />
-		ret = jz4740_pcm_preallocate_dma_buffer(pcm,<br />
-			SNDRV_PCM_STREAM_CAPTURE);<br />
-		if (ret)<br />
-			goto err;<br />
-	}<br />
-<br />
-err:<br />
-	return ret;<br />
-}<br />
-<br />
-static struct snd_soc_platform_driver jz4740_soc_platform = {<br />
-		.ops		= &amp;jz4740_pcm_ops,<br />
-		.pcm_new	= jz4740_pcm_new,<br />
-		.pcm_free	= jz4740_pcm_free,<br />
+static const struct snd_dmaengine_pcm_config jz4740_dmaengine_pcm_config = {<br />
+	.prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,<br />
+	.pcm_hardware = &amp;jz4740_pcm_hardware,<br />
+	.prealloc_buffer_size = 256 * PAGE_SIZE,<br />
 };<br />
 <br />
 static int jz4740_pcm_probe(struct platform_device *pdev)<br />
 {<br />
-	return snd_soc_register_platform(&amp;pdev-&gt;dev, &amp;jz4740_soc_platform);<br />
+	return snd_dmaengine_pcm_register(&amp;pdev-&gt;dev,<br />
+		&amp;jz4740_dmaengine_pcm_config,<br />
+		SND_DMAENGINE_PCM_FLAG_COMPAT);<br />
 }<br />
 <br />
 static int jz4740_pcm_remove(struct platform_device *pdev)<br />
 {<br />
-	snd_soc_unregister_platform(&amp;pdev-&gt;dev);<br />
+	snd_dmaengine_pcm_unregister(&amp;pdev-&gt;dev);<br />
 	return 0;<br />
 }<br />
 <br />
diff --git a/sound/soc/jz4740/jz4740-pcm.h b/sound/soc/jz4740/jz4740-pcm.h<br />
deleted file mode 100644<br />
index 1220cbb..0000000<br />
--- a/sound/soc/jz4740/jz4740-pcm.h<br />
+++ /dev/null<br />
@@ -1,20 +0,0 @@<br />
-/*<br />
- *<br />
- * This program is free software; you can redistribute it and/or modify<br />
- * it under the terms of the GNU General Public License version 2 as<br />
- * published by the Free Software Foundation.<br />
- */<br />
-<br />
-#ifndef _JZ4740_PCM_H<br />
-#define _JZ4740_PCM_H<br />
-<br />
-#include &lt;linux/dma-mapping.h&gt;<br />
-#include &lt;asm/mach-jz4740/dma.h&gt;<br />
-<br />
-<br />
-struct jz4740_pcm_config {<br />
-	struct jz4740_dma_config dma_config;<br />
-	phys_addr_t fifo_addr;<br />
-};<br />
-<br />
-#endif<br />
-- <br />
1.8.2.1<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Lars-Peter Clausen</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 22:40:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712193,712193#msg-712193</guid>
            <title>[PATCH 1/6] MIPS: jz4740: Correct clock gate bit for DMA controller (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712193,712193#msg-712193</link>
            <description><![CDATA[ From: Maarten ter Huurne &lt;maarten@treewalker.org&gt;<br />
<br />
Signed-off-by: Maarten ter Huurne &lt;maarten@treewalker.org&gt;<br />
Signed-off-by: Lars-Peter Clausen &lt;lars@metafoo.de&gt;<br />
---<br />
 arch/mips/jz4740/clock.c | 2 +-<br />
 1 file changed, 1 insertion(+), 1 deletion(-)<br />
<br />
diff --git a/arch/mips/jz4740/clock.c b/arch/mips/jz4740/clock.c<br />
index 484d38a..1b5f554 100644<br />
--- a/arch/mips/jz4740/clock.c<br />
+++ b/arch/mips/jz4740/clock.c<br />
@@ -687,7 +687,7 @@ static struct clk jz4740_clock_simple_clks[] = {<br />
 	[3] = {<br />
 		.name = &quot;dma&quot;,<br />
 		.parent = &amp;jz_clk_high_speed_peripheral.clk,<br />
-		.gate_bit = JZ_CLOCK_GATE_UART0,<br />
+		.gate_bit = JZ_CLOCK_GATE_DMAC,<br />
 		.ops = &amp;jz_clk_simple_ops,<br />
 	},<br />
 	[4] = {<br />
-- <br />
1.8.2.1<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Lars-Peter Clausen</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 22:40:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712192,712192#msg-712192</guid>
            <title>[PATCH 6/6] MIPS: jz4740: Remove custom DMA API (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712192,712192#msg-712192</link>
            <description><![CDATA[ Now that all users of the custom jz4740 DMA API have been converted to use<br />
the dmaengine API instead we can remove the custom API and move all the code<br />
talking to the hardware to the dmaengine driver.<br />
<br />
Signed-off-by: Lars-Peter Clausen &lt;lars@metafoo.de&gt;<br />
---<br />
 arch/mips/include/asm/mach-jz4740/dma.h |  56 ------<br />
 arch/mips/jz4740/Makefile               |   2 +-<br />
 arch/mips/jz4740/dma.c                  | 307 --------------------------------<br />
 drivers/dma/dma-jz4740.c                | 268 +++++++++++++++++++++++-----<br />
 4 files changed, 229 insertions(+), 404 deletions(-)<br />
 delete mode 100644 arch/mips/jz4740/dma.c<br />
<br />
diff --git a/arch/mips/include/asm/mach-jz4740/dma.h b/arch/mips/include/asm/mach-jz4740/dma.h<br />
index 98b4e7c..509cd58 100644<br />
--- a/arch/mips/include/asm/mach-jz4740/dma.h<br />
+++ b/arch/mips/include/asm/mach-jz4740/dma.h<br />
@@ -16,8 +16,6 @@<br />
 #ifndef __ASM_MACH_JZ4740_DMA_H__<br />
 #define __ASM_MACH_JZ4740_DMA_H__<br />
 <br />
-struct jz4740_dma_chan;<br />
-<br />
 enum jz4740_dma_request_type {<br />
 	JZ4740_DMA_TYPE_AUTO_REQUEST	= 8,<br />
 	JZ4740_DMA_TYPE_UART_TRANSMIT	= 20,<br />
@@ -33,58 +31,4 @@ enum jz4740_dma_request_type {<br />
 	JZ4740_DMA_TYPE_SLCD		= 30,<br />
 };<br />
 <br />
-enum jz4740_dma_width {<br />
-	JZ4740_DMA_WIDTH_32BIT	= 0,<br />
-	JZ4740_DMA_WIDTH_8BIT	= 1,<br />
-	JZ4740_DMA_WIDTH_16BIT	= 2,<br />
-};<br />
-<br />
-enum jz4740_dma_transfer_size {<br />
-	JZ4740_DMA_TRANSFER_SIZE_4BYTE	= 0,<br />
-	JZ4740_DMA_TRANSFER_SIZE_1BYTE	= 1,<br />
-	JZ4740_DMA_TRANSFER_SIZE_2BYTE	= 2,<br />
-	JZ4740_DMA_TRANSFER_SIZE_16BYTE = 3,<br />
-	JZ4740_DMA_TRANSFER_SIZE_32BYTE = 4,<br />
-};<br />
-<br />
-enum jz4740_dma_flags {<br />
-	JZ4740_DMA_SRC_AUTOINC = 0x2,<br />
-	JZ4740_DMA_DST_AUTOINC = 0x1,<br />
-};<br />
-<br />
-enum jz4740_dma_mode {<br />
-	JZ4740_DMA_MODE_SINGLE	= 0,<br />
-	JZ4740_DMA_MODE_BLOCK	= 1,<br />
-};<br />
-<br />
-struct jz4740_dma_config {<br />
-	enum jz4740_dma_width src_width;<br />
-	enum jz4740_dma_width dst_width;<br />
-	enum jz4740_dma_transfer_size transfer_size;<br />
-	enum jz4740_dma_request_type request_type;<br />
-	enum jz4740_dma_flags flags;<br />
-	enum jz4740_dma_mode mode;<br />
-};<br />
-<br />
-typedef void (*jz4740_dma_complete_callback_t)(struct jz4740_dma_chan *, int, void *);<br />
-<br />
-struct jz4740_dma_chan *jz4740_dma_request(void *dev, const char *name);<br />
-void jz4740_dma_free(struct jz4740_dma_chan *dma);<br />
-<br />
-void jz4740_dma_configure(struct jz4740_dma_chan *dma,<br />
-	const struct jz4740_dma_config *config);<br />
-<br />
-<br />
-void jz4740_dma_enable(struct jz4740_dma_chan *dma);<br />
-void jz4740_dma_disable(struct jz4740_dma_chan *dma);<br />
-<br />
-void jz4740_dma_set_src_addr(struct jz4740_dma_chan *dma, dma_addr_t src);<br />
-void jz4740_dma_set_dst_addr(struct jz4740_dma_chan *dma, dma_addr_t dst);<br />
-void jz4740_dma_set_transfer_count(struct jz4740_dma_chan *dma, uint32_t count);<br />
-<br />
-uint32_t jz4740_dma_get_residue(const struct jz4740_dma_chan *dma);<br />
-<br />
-void jz4740_dma_set_complete_cb(struct jz4740_dma_chan *dma,<br />
-	jz4740_dma_complete_callback_t cb);<br />
-<br />
 #endif	/* __ASM_JZ4740_DMA_H__ */<br />
diff --git a/arch/mips/jz4740/Makefile b/arch/mips/jz4740/Makefile<br />
index 63bad0e..28e5535 100644<br />
--- a/arch/mips/jz4740/Makefile<br />
+++ b/arch/mips/jz4740/Makefile<br />
@@ -4,7 +4,7 @@<br />
 <br />
 # Object file lists.<br />
 <br />
-obj-y += prom.o irq.o time.o reset.o setup.o dma.o \<br />
+obj-y += prom.o irq.o time.o reset.o setup.o \<br />
 	gpio.o clock.o platform.o timer.o serial.o<br />
 <br />
 obj-$(CONFIG_DEBUG_FS) += clock-debugfs.o<br />
diff --git a/arch/mips/jz4740/dma.c b/arch/mips/jz4740/dma.c<br />
deleted file mode 100644<br />
index 0e34b97..0000000<br />
--- a/arch/mips/jz4740/dma.c<br />
+++ /dev/null<br />
@@ -1,307 +0,0 @@<br />
-/*<br />
- *  Copyright (C) 2010, Lars-Peter Clausen &lt;lars@metafoo.de&gt;<br />
- *  JZ4740 SoC DMA support<br />
- *<br />
- *  This program is free software; you can redistribute it and/or modify it<br />
- *  under  the terms of the GNU General	 Public License as published by the<br />
- *  Free Software Foundation;  either version 2 of the License, or (at your<br />
- *  option) any later version.<br />
- *<br />
- *  You should have received a copy of the GNU General Public License along<br />
- *  with this program; if not, write to the Free Software Foundation, Inc.,<br />
- *  675 Mass Ave, Cambridge, MA 02139, USA.<br />
- *<br />
- */<br />
-<br />
-#include &lt;linux/kernel.h&gt;<br />
-#include &lt;linux/module.h&gt;<br />
-#include &lt;linux/spinlock.h&gt;<br />
-#include &lt;linux/clk.h&gt;<br />
-#include &lt;linux/interrupt.h&gt;<br />
-<br />
-#include &lt;linux/dma-mapping.h&gt;<br />
-#include &lt;asm/mach-jz4740/dma.h&gt;<br />
-#include &lt;asm/mach-jz4740/base.h&gt;<br />
-<br />
-#define JZ_REG_DMA_SRC_ADDR(x)		(0x00 + (x) * 0x20)<br />
-#define JZ_REG_DMA_DST_ADDR(x)		(0x04 + (x) * 0x20)<br />
-#define JZ_REG_DMA_TRANSFER_COUNT(x)	(0x08 + (x) * 0x20)<br />
-#define JZ_REG_DMA_REQ_TYPE(x)		(0x0C + (x) * 0x20)<br />
-#define JZ_REG_DMA_STATUS_CTRL(x)	(0x10 + (x) * 0x20)<br />
-#define JZ_REG_DMA_CMD(x)		(0x14 + (x) * 0x20)<br />
-#define JZ_REG_DMA_DESC_ADDR(x)		(0x18 + (x) * 0x20)<br />
-<br />
-#define JZ_REG_DMA_CTRL			0x300<br />
-#define JZ_REG_DMA_IRQ			0x304<br />
-#define JZ_REG_DMA_DOORBELL		0x308<br />
-#define JZ_REG_DMA_DOORBELL_SET		0x30C<br />
-<br />
-#define JZ_DMA_STATUS_CTRL_NO_DESC		BIT(31)<br />
-#define JZ_DMA_STATUS_CTRL_DESC_INV		BIT(6)<br />
-#define JZ_DMA_STATUS_CTRL_ADDR_ERR		BIT(4)<br />
-#define JZ_DMA_STATUS_CTRL_TRANSFER_DONE	BIT(3)<br />
-#define JZ_DMA_STATUS_CTRL_HALT			BIT(2)<br />
-#define JZ_DMA_STATUS_CTRL_COUNT_TERMINATE	BIT(1)<br />
-#define JZ_DMA_STATUS_CTRL_ENABLE		BIT(0)<br />
-<br />
-#define JZ_DMA_CMD_SRC_INC			BIT(23)<br />
-#define JZ_DMA_CMD_DST_INC			BIT(22)<br />
-#define JZ_DMA_CMD_RDIL_MASK			(0xf &lt;&lt; 16)<br />
-#define JZ_DMA_CMD_SRC_WIDTH_MASK		(0x3 &lt;&lt; 14)<br />
-#define JZ_DMA_CMD_DST_WIDTH_MASK		(0x3 &lt;&lt; 12)<br />
-#define JZ_DMA_CMD_INTERVAL_LENGTH_MASK		(0x7 &lt;&lt; 8)<br />
-#define JZ_DMA_CMD_BLOCK_MODE			BIT(7)<br />
-#define JZ_DMA_CMD_DESC_VALID			BIT(4)<br />
-#define JZ_DMA_CMD_DESC_VALID_MODE		BIT(3)<br />
-#define JZ_DMA_CMD_VALID_IRQ_ENABLE		BIT(2)<br />
-#define JZ_DMA_CMD_TRANSFER_IRQ_ENABLE		BIT(1)<br />
-#define JZ_DMA_CMD_LINK_ENABLE			BIT(0)<br />
-<br />
-#define JZ_DMA_CMD_FLAGS_OFFSET 22<br />
-#define JZ_DMA_CMD_RDIL_OFFSET 16<br />
-#define JZ_DMA_CMD_SRC_WIDTH_OFFSET 14<br />
-#define JZ_DMA_CMD_DST_WIDTH_OFFSET 12<br />
-#define JZ_DMA_CMD_TRANSFER_SIZE_OFFSET 8<br />
-#define JZ_DMA_CMD_MODE_OFFSET 7<br />
-<br />
-#define JZ_DMA_CTRL_PRIORITY_MASK	(0x3 &lt;&lt; 8)<br />
-#define JZ_DMA_CTRL_HALT		BIT(3)<br />
-#define JZ_DMA_CTRL_ADDRESS_ERROR	BIT(2)<br />
-#define JZ_DMA_CTRL_ENABLE		BIT(0)<br />
-<br />
-<br />
-static void __iomem *jz4740_dma_base;<br />
-static spinlock_t jz4740_dma_lock;<br />
-<br />
-static inline uint32_t jz4740_dma_read(size_t reg)<br />
-{<br />
-	return readl(jz4740_dma_base + reg);<br />
-}<br />
-<br />
-static inline void jz4740_dma_write(size_t reg, uint32_t val)<br />
-{<br />
-	writel(val, jz4740_dma_base + reg);<br />
-}<br />
-<br />
-static inline void jz4740_dma_write_mask(size_t reg, uint32_t val, uint32_t mask)<br />
-{<br />
-	uint32_t val2;<br />
-	val2 = jz4740_dma_read(reg);<br />
-	val2 &amp;= ~mask;<br />
-	val2 |= val;<br />
-	jz4740_dma_write(reg, val2);<br />
-}<br />
-<br />
-struct jz4740_dma_chan {<br />
-	unsigned int id;<br />
-	void *dev;<br />
-	const char *name;<br />
-<br />
-	enum jz4740_dma_flags flags;<br />
-	uint32_t transfer_shift;<br />
-<br />
-	jz4740_dma_complete_callback_t complete_cb;<br />
-<br />
-	unsigned used:1;<br />
-};<br />
-<br />
-#define JZ4740_DMA_CHANNEL(_id) { .id = _id }<br />
-<br />
-struct jz4740_dma_chan jz4740_dma_channels[] = {<br />
-	JZ4740_DMA_CHANNEL(0),<br />
-	JZ4740_DMA_CHANNEL(1),<br />
-	JZ4740_DMA_CHANNEL(2),<br />
-	JZ4740_DMA_CHANNEL(3),<br />
-	JZ4740_DMA_CHANNEL(4),<br />
-	JZ4740_DMA_CHANNEL(5),<br />
-};<br />
-<br />
-struct jz4740_dma_chan *jz4740_dma_request(void *dev, const char *name)<br />
-{<br />
-	unsigned int i;<br />
-	struct jz4740_dma_chan *dma = NULL;<br />
-<br />
-	spin_lock(&amp;jz4740_dma_lock);<br />
-<br />
-	for (i = 0; i &lt; ARRAY_SIZE(jz4740_dma_channels); ++i) {<br />
-		if (!jz4740_dma_channels<i>.used) {<br />
-			dma = &amp;jz4740_dma_channels<i>;<br />
-			dma-&gt;used = 1;<br />
-			break;<br />
-		}<br />
-	}<br />
-<br />
-	spin_unlock(&amp;jz4740_dma_lock);<br />
-<br />
-	if (!dma)<br />
-		return NULL;<br />
-<br />
-	dma-&gt;dev = dev;<br />
-	dma-&gt;name = name;<br />
-<br />
-	return dma;<br />
-}<br />
-EXPORT_SYMBOL_GPL(jz4740_dma_request);<br />
-<br />
-void jz4740_dma_configure(struct jz4740_dma_chan *dma,<br />
-	const struct jz4740_dma_config *config)<br />
-{<br />
-	uint32_t cmd;<br />
-<br />
-	switch (config-&gt;transfer_size) {<br />
-	case JZ4740_DMA_TRANSFER_SIZE_2BYTE:<br />
-		dma-&gt;transfer_shift = 1;<br />
-		break;<br />
-	case JZ4740_DMA_TRANSFER_SIZE_4BYTE:<br />
-		dma-&gt;transfer_shift = 2;<br />
-		break;<br />
-	case JZ4740_DMA_TRANSFER_SIZE_16BYTE:<br />
-		dma-&gt;transfer_shift = 4;<br />
-		break;<br />
-	case JZ4740_DMA_TRANSFER_SIZE_32BYTE:<br />
-		dma-&gt;transfer_shift = 5;<br />
-		break;<br />
-	default:<br />
-		dma-&gt;transfer_shift = 0;<br />
-		break;<br />
-	}<br />
-<br />
-	cmd = config-&gt;flags &lt;&lt; JZ_DMA_CMD_FLAGS_OFFSET;<br />
-	cmd |= config-&gt;src_width &lt;&lt; JZ_DMA_CMD_SRC_WIDTH_OFFSET;<br />
-	cmd |= config-&gt;dst_width &lt;&lt; JZ_DMA_CMD_DST_WIDTH_OFFSET;<br />
-	cmd |= config-&gt;transfer_size &lt;&lt; JZ_DMA_CMD_TRANSFER_SIZE_OFFSET;<br />
-	cmd |= config-&gt;mode &lt;&lt; JZ_DMA_CMD_MODE_OFFSET;<br />
-	cmd |= JZ_DMA_CMD_TRANSFER_IRQ_ENABLE;<br />
-<br />
-	jz4740_dma_write(JZ_REG_DMA_CMD(dma-&gt;id), cmd);<br />
-	jz4740_dma_write(JZ_REG_DMA_STATUS_CTRL(dma-&gt;id), 0);<br />
-	jz4740_dma_write(JZ_REG_DMA_REQ_TYPE(dma-&gt;id), config-&gt;request_type);<br />
-}<br />
-EXPORT_SYMBOL_GPL(jz4740_dma_configure);<br />
-<br />
-void jz4740_dma_set_src_addr(struct jz4740_dma_chan *dma, dma_addr_t src)<br />
-{<br />
-	jz4740_dma_write(JZ_REG_DMA_SRC_ADDR(dma-&gt;id), src);<br />
-}<br />
-EXPORT_SYMBOL_GPL(jz4740_dma_set_src_addr);<br />
-<br />
-void jz4740_dma_set_dst_addr(struct jz4740_dma_chan *dma, dma_addr_t dst)<br />
-{<br />
-	jz4740_dma_write(JZ_REG_DMA_DST_ADDR(dma-&gt;id), dst);<br />
-}<br />
-EXPORT_SYMBOL_GPL(jz4740_dma_set_dst_addr);<br />
-<br />
-void jz4740_dma_set_transfer_count(struct jz4740_dma_chan *dma, uint32_t count)<br />
-{<br />
-	count &gt;&gt;= dma-&gt;transfer_shift;<br />
-	jz4740_dma_write(JZ_REG_DMA_TRANSFER_COUNT(dma-&gt;id), count);<br />
-}<br />
-EXPORT_SYMBOL_GPL(jz4740_dma_set_transfer_count);<br />
-<br />
-void jz4740_dma_set_complete_cb(struct jz4740_dma_chan *dma,<br />
-	jz4740_dma_complete_callback_t cb)<br />
-{<br />
-	dma-&gt;complete_cb = cb;<br />
-}<br />
-EXPORT_SYMBOL_GPL(jz4740_dma_set_complete_cb);<br />
-<br />
-void jz4740_dma_free(struct jz4740_dma_chan *dma)<br />
-{<br />
-	dma-&gt;dev = NULL;<br />
-	dma-&gt;complete_cb = NULL;<br />
-	dma-&gt;used = 0;<br />
-}<br />
-EXPORT_SYMBOL_GPL(jz4740_dma_free);<br />
-<br />
-void jz4740_dma_enable(struct jz4740_dma_chan *dma)<br />
-{<br />
-	jz4740_dma_write_mask(JZ_REG_DMA_STATUS_CTRL(dma-&gt;id),<br />
-			JZ_DMA_STATUS_CTRL_NO_DESC | JZ_DMA_STATUS_CTRL_ENABLE,<br />
-			JZ_DMA_STATUS_CTRL_HALT | JZ_DMA_STATUS_CTRL_NO_DESC |<br />
-			JZ_DMA_STATUS_CTRL_ENABLE);<br />
-<br />
-	jz4740_dma_write_mask(JZ_REG_DMA_CTRL,<br />
-			JZ_DMA_CTRL_ENABLE,<br />
-			JZ_DMA_CTRL_HALT | JZ_DMA_CTRL_ENABLE);<br />
-}<br />
-EXPORT_SYMBOL_GPL(jz4740_dma_enable);<br />
-<br />
-void jz4740_dma_disable(struct jz4740_dma_chan *dma)<br />
-{<br />
-	jz4740_dma_write_mask(JZ_REG_DMA_STATUS_CTRL(dma-&gt;id), 0,<br />
-			JZ_DMA_STATUS_CTRL_ENABLE);<br />
-}<br />
-EXPORT_SYMBOL_GPL(jz4740_dma_disable);<br />
-<br />
-uint32_t jz4740_dma_get_residue(const struct jz4740_dma_chan *dma)<br />
-{<br />
-	uint32_t residue;<br />
-	residue = jz4740_dma_read(JZ_REG_DMA_TRANSFER_COUNT(dma-&gt;id));<br />
-	return residue &lt;&lt; dma-&gt;transfer_shift;<br />
-}<br />
-EXPORT_SYMBOL_GPL(jz4740_dma_get_residue);<br />
-<br />
-static void jz4740_dma_chan_irq(struct jz4740_dma_chan *dma)<br />
-{<br />
-	(void) jz4740_dma_read(JZ_REG_DMA_STATUS_CTRL(dma-&gt;id));<br />
-<br />
-	jz4740_dma_write_mask(JZ_REG_DMA_STATUS_CTRL(dma-&gt;id), 0,<br />
-		JZ_DMA_STATUS_CTRL_ENABLE | JZ_DMA_STATUS_CTRL_TRANSFER_DONE);<br />
-<br />
-	if (dma-&gt;complete_cb)<br />
-		dma-&gt;complete_cb(dma, 0, dma-&gt;dev);<br />
-}<br />
-<br />
-static irqreturn_t jz4740_dma_irq(int irq, void *dev_id)<br />
-{<br />
-	uint32_t irq_status;<br />
-	unsigned int i;<br />
-<br />
-	irq_status = readl(jz4740_dma_base + JZ_REG_DMA_IRQ);<br />
-<br />
-	for (i = 0; i &lt; 6; ++i) {<br />
-		if (irq_status &amp; (1 &lt;&lt; i))<br />
-			jz4740_dma_chan_irq(&amp;jz4740_dma_channels<i>);<br />
-	}<br />
-<br />
-	return IRQ_HANDLED;<br />
-}<br />
-<br />
-static int jz4740_dma_init(void)<br />
-{<br />
-	struct clk *clk;<br />
-	unsigned int ret;<br />
-<br />
-	jz4740_dma_base = ioremap(JZ4740_DMAC_BASE_ADDR, 0x400);<br />
-<br />
-	if (!jz4740_dma_base)<br />
-		return -EBUSY;<br />
-<br />
-	spin_lock_init(&amp;jz4740_dma_lock);<br />
-<br />
-	clk = clk_get(NULL, &quot;dma&quot;);<br />
-	if (IS_ERR(clk)) {<br />
-		ret = PTR_ERR(clk);<br />
-		printk(KERN_ERR &quot;JZ4740 DMA: Failed to request clock: %d\n&quot;,<br />
-				ret);<br />
-		goto err_iounmap;<br />
-	}<br />
-<br />
-	ret = request_irq(JZ4740_IRQ_DMAC, jz4740_dma_irq, 0, &quot;DMA&quot;, NULL);<br />
-	if (ret) {<br />
-		printk(KERN_ERR &quot;JZ4740 DMA: Failed to request irq: %d\n&quot;, ret);<br />
-		goto err_clkput;<br />
-	}<br />
-<br />
-	clk_prepare_enable(clk);<br />
-<br />
-	return 0;<br />
-<br />
-err_clkput:<br />
-	clk_put(clk);<br />
-<br />
-err_iounmap:<br />
-	iounmap(jz4740_dma_base);<br />
-	return ret;<br />
-}<br />
-arch_initcall(jz4740_dma_init);<br />
diff --git a/drivers/dma/dma-jz4740.c b/drivers/dma/dma-jz4740.c<br />
index 210bac0..a57cfdc 100644<br />
--- a/drivers/dma/dma-jz4740.c<br />
+++ b/drivers/dma/dma-jz4740.c<br />
@@ -22,11 +22,83 @@<br />
 #include &lt;linux/platform_device.h&gt;<br />
 #include &lt;linux/slab.h&gt;<br />
 #include &lt;linux/spinlock.h&gt;<br />
+#include &lt;linux/irq.h&gt;<br />
+#include &lt;linux/clk.h&gt;<br />
 <br />
 #include &lt;asm/mach-jz4740/dma.h&gt;<br />
 <br />
 #include &quot;virt-dma.h&quot;<br />
 <br />
+#define JZ_REG_DMA_SRC_ADDR(x)		(0x00 + (x) * 0x20)<br />
+#define JZ_REG_DMA_DST_ADDR(x)		(0x04 + (x) * 0x20)<br />
+#define JZ_REG_DMA_TRANSFER_COUNT(x)	(0x08 + (x) * 0x20)<br />
+#define JZ_REG_DMA_REQ_TYPE(x)		(0x0C + (x) * 0x20)<br />
+#define JZ_REG_DMA_STATUS_CTRL(x)	(0x10 + (x) * 0x20)<br />
+#define JZ_REG_DMA_CMD(x)		(0x14 + (x) * 0x20)<br />
+#define JZ_REG_DMA_DESC_ADDR(x)		(0x18 + (x) * 0x20)<br />
+<br />
+#define JZ_REG_DMA_CTRL			0x300<br />
+#define JZ_REG_DMA_IRQ			0x304<br />
+#define JZ_REG_DMA_DOORBELL		0x308<br />
+#define JZ_REG_DMA_DOORBELL_SET		0x30C<br />
+<br />
+#define JZ_DMA_STATUS_CTRL_NO_DESC		BIT(31)<br />
+#define JZ_DMA_STATUS_CTRL_DESC_INV		BIT(6)<br />
+#define JZ_DMA_STATUS_CTRL_ADDR_ERR		BIT(4)<br />
+#define JZ_DMA_STATUS_CTRL_TRANSFER_DONE	BIT(3)<br />
+#define JZ_DMA_STATUS_CTRL_HALT			BIT(2)<br />
+#define JZ_DMA_STATUS_CTRL_COUNT_TERMINATE	BIT(1)<br />
+#define JZ_DMA_STATUS_CTRL_ENABLE		BIT(0)<br />
+<br />
+#define JZ_DMA_CMD_SRC_INC			BIT(23)<br />
+#define JZ_DMA_CMD_DST_INC			BIT(22)<br />
+#define JZ_DMA_CMD_RDIL_MASK			(0xf &lt;&lt; 16)<br />
+#define JZ_DMA_CMD_SRC_WIDTH_MASK		(0x3 &lt;&lt; 14)<br />
+#define JZ_DMA_CMD_DST_WIDTH_MASK		(0x3 &lt;&lt; 12)<br />
+#define JZ_DMA_CMD_INTERVAL_LENGTH_MASK		(0x7 &lt;&lt; 8)<br />
+#define JZ_DMA_CMD_BLOCK_MODE			BIT(7)<br />
+#define JZ_DMA_CMD_DESC_VALID			BIT(4)<br />
+#define JZ_DMA_CMD_DESC_VALID_MODE		BIT(3)<br />
+#define JZ_DMA_CMD_VALID_IRQ_ENABLE		BIT(2)<br />
+#define JZ_DMA_CMD_TRANSFER_IRQ_ENABLE		BIT(1)<br />
+#define JZ_DMA_CMD_LINK_ENABLE			BIT(0)<br />
+<br />
+#define JZ_DMA_CMD_FLAGS_OFFSET 22<br />
+#define JZ_DMA_CMD_RDIL_OFFSET 16<br />
+#define JZ_DMA_CMD_SRC_WIDTH_OFFSET 14<br />
+#define JZ_DMA_CMD_DST_WIDTH_OFFSET 12<br />
+#define JZ_DMA_CMD_TRANSFER_SIZE_OFFSET 8<br />
+#define JZ_DMA_CMD_MODE_OFFSET 7<br />
+<br />
+#define JZ_DMA_CTRL_PRIORITY_MASK		(0x3 &lt;&lt; 8)<br />
+#define JZ_DMA_CTRL_HALT			BIT(3)<br />
+#define JZ_DMA_CTRL_ADDRESS_ERROR		BIT(2)<br />
+#define JZ_DMA_CTRL_ENABLE			BIT(0)<br />
+<br />
+enum jz4740_dma_width {<br />
+	JZ4740_DMA_WIDTH_32BIT	= 0,<br />
+	JZ4740_DMA_WIDTH_8BIT	= 1,<br />
+	JZ4740_DMA_WIDTH_16BIT	= 2,<br />
+};<br />
+<br />
+enum jz4740_dma_transfer_size {<br />
+	JZ4740_DMA_TRANSFER_SIZE_4BYTE	= 0,<br />
+	JZ4740_DMA_TRANSFER_SIZE_1BYTE	= 1,<br />
+	JZ4740_DMA_TRANSFER_SIZE_2BYTE	= 2,<br />
+	JZ4740_DMA_TRANSFER_SIZE_16BYTE = 3,<br />
+	JZ4740_DMA_TRANSFER_SIZE_32BYTE = 4,<br />
+};<br />
+<br />
+enum jz4740_dma_flags {<br />
+	JZ4740_DMA_SRC_AUTOINC = 0x2,<br />
+	JZ4740_DMA_DST_AUTOINC = 0x1,<br />
+};<br />
+<br />
+enum jz4740_dma_mode {<br />
+	JZ4740_DMA_MODE_SINGLE	= 0,<br />
+	JZ4740_DMA_MODE_BLOCK	= 1,<br />
+};<br />
+<br />
 struct jz4740_dma_sg {<br />
 	dma_addr_t addr;<br />
 	unsigned int len;<br />
@@ -44,9 +116,10 @@ struct jz4740_dma_desc {<br />
 <br />
 struct jz4740_dmaengine_chan {<br />
 	struct virt_dma_chan vchan;<br />
-	struct jz4740_dma_chan *jz_chan;<br />
+	unsigned int id;<br />
 <br />
 	struct dma_slave_config config;<br />
+	unsigned int transfer_shift;<br />
 <br />
 	struct jz4740_dma_desc *desc;<br />
 	unsigned int next_sg;<br />
@@ -54,10 +127,19 @@ struct jz4740_dmaengine_chan {<br />
 <br />
 struct jz4740_dma_dev {<br />
 	struct dma_device ddev;<br />
+	void __iomem *base;<br />
+	struct clk *clk;<br />
 <br />
 	struct jz4740_dmaengine_chan chan[6];<br />
 };<br />
 <br />
+static struct jz4740_dma_dev *jz4740_dma_chan_get_dev(<br />
+	struct jz4740_dmaengine_chan *chan)<br />
+{<br />
+	return container_of(chan-&gt;vchan.chan.device, struct jz4740_dma_dev,<br />
+		ddev);<br />
+}<br />
+<br />
 static struct jz4740_dmaengine_chan *to_jz4740_dma_chan(struct dma_chan *c)<br />
 {<br />
 	return container_of(c, struct jz4740_dmaengine_chan, vchan.chan);<br />
@@ -68,6 +150,29 @@ static struct jz4740_dma_desc *to_jz4740_dma_desc(struct virt_dma_desc *vdesc)<br />
 	return container_of(vdesc, struct jz4740_dma_desc, vdesc);<br />
 }<br />
 <br />
+static inline uint32_t jz4740_dma_read(struct jz4740_dma_dev *dmadev,<br />
+	unsigned int reg)<br />
+{<br />
+	return readl(dmadev-&gt;base + reg);<br />
+}<br />
+<br />
+static inline void jz4740_dma_write(struct jz4740_dma_dev *dmadev,<br />
+	unsigned reg, uint32_t val)<br />
+{<br />
+	writel(val, dmadev-&gt;base + reg);<br />
+}<br />
+<br />
+static inline void jz4740_dma_write_mask(struct jz4740_dma_dev *dmadev,<br />
+	unsigned int reg, uint32_t val, uint32_t mask)<br />
+{<br />
+	uint32_t tmp;<br />
+<br />
+	tmp = jz4740_dma_read(dmadev, reg);<br />
+	tmp &amp;= ~mask;<br />
+	tmp |= val;<br />
+	jz4740_dma_write(dmadev, reg, tmp);<br />
+}<br />
+<br />
 static struct jz4740_dma_desc *jz4740_dma_alloc_desc(unsigned int num_sgs)<br />
 {<br />
 	return kzalloc(sizeof(struct jz4740_dma_desc) +<br />
@@ -106,30 +211,60 @@ static int jz4740_dma_slave_config(struct dma_chan *c,<br />
 	const struct dma_slave_config *config)<br />
 {<br />
 	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);<br />
-	struct jz4740_dma_config jzcfg;<br />
+	struct jz4740_dma_dev *dmadev = jz4740_dma_chan_get_dev(chan);<br />
+	enum jz4740_dma_width src_width;<br />
+	enum jz4740_dma_width dst_width;<br />
+	enum jz4740_dma_transfer_size transfer_size;<br />
+	enum jz4740_dma_flags flags;<br />
+	uint32_t cmd;<br />
 <br />
 	switch (config-&gt;direction) {<br />
 	case DMA_MEM_TO_DEV:<br />
-		jzcfg.flags = JZ4740_DMA_SRC_AUTOINC;<br />
-		jzcfg.transfer_size = jz4740_dma_maxburst(config-&gt;dst_maxburst);<br />
+		flags = JZ4740_DMA_SRC_AUTOINC;<br />
+		transfer_size = jz4740_dma_maxburst(config-&gt;dst_maxburst);<br />
 		break;<br />
 	case DMA_DEV_TO_MEM:<br />
-		jzcfg.flags = JZ4740_DMA_DST_AUTOINC;<br />
-		jzcfg.transfer_size = jz4740_dma_maxburst(config-&gt;src_maxburst);<br />
+		flags = JZ4740_DMA_DST_AUTOINC;<br />
+		transfer_size = jz4740_dma_maxburst(config-&gt;src_maxburst);<br />
 		break;<br />
 	default:<br />
 		return -EINVAL;<br />
 	}<br />
 <br />
-<br />
-	jzcfg.src_width = jz4740_dma_width(config-&gt;src_addr_width);<br />
-	jzcfg.dst_width = jz4740_dma_width(config-&gt;dst_addr_width);<br />
-	jzcfg.mode = JZ4740_DMA_MODE_SINGLE;<br />
-	jzcfg.request_type = config-&gt;slave_id;<br />
+	src_width = jz4740_dma_width(config-&gt;src_addr_width);<br />
+	dst_width = jz4740_dma_width(config-&gt;dst_addr_width);<br />
 <br />
 	chan-&gt;config = *config;<br />
 <br />
-	jz4740_dma_configure(chan-&gt;jz_chan, &amp;jzcfg);<br />
+	switch (transfer_size) {<br />
+	case JZ4740_DMA_TRANSFER_SIZE_2BYTE:<br />
+		chan-&gt;transfer_shift = 1;<br />
+		break;<br />
+	case JZ4740_DMA_TRANSFER_SIZE_4BYTE:<br />
+		chan-&gt;transfer_shift = 2;<br />
+		break;<br />
+	case JZ4740_DMA_TRANSFER_SIZE_16BYTE:<br />
+		chan-&gt;transfer_shift = 4;<br />
+		break;<br />
+	case JZ4740_DMA_TRANSFER_SIZE_32BYTE:<br />
+		chan-&gt;transfer_shift = 5;<br />
+		break;<br />
+	default:<br />
+		chan-&gt;transfer_shift = 0;<br />
+		break;<br />
+	}<br />
+<br />
+	cmd = flags &lt;&lt; JZ_DMA_CMD_FLAGS_OFFSET;<br />
+	cmd |= src_width &lt;&lt; JZ_DMA_CMD_SRC_WIDTH_OFFSET;<br />
+	cmd |= dst_width &lt;&lt; JZ_DMA_CMD_DST_WIDTH_OFFSET;<br />
+	cmd |= transfer_size &lt;&lt; JZ_DMA_CMD_TRANSFER_SIZE_OFFSET;<br />
+	cmd |= JZ4740_DMA_MODE_SINGLE &lt;&lt; JZ_DMA_CMD_MODE_OFFSET;<br />
+	cmd |= JZ_DMA_CMD_TRANSFER_IRQ_ENABLE;<br />
+<br />
+	jz4740_dma_write(dmadev, JZ_REG_DMA_CMD(chan-&gt;id), cmd);<br />
+	jz4740_dma_write(dmadev, JZ_REG_DMA_STATUS_CTRL(chan-&gt;id), 0);<br />
+	jz4740_dma_write(dmadev, JZ_REG_DMA_REQ_TYPE(chan-&gt;id),<br />
+		config-&gt;slave_id);<br />
 <br />
 	return 0;<br />
 }<br />
@@ -137,11 +272,13 @@ static int jz4740_dma_slave_config(struct dma_chan *c,<br />
 static int jz4740_dma_terminate_all(struct dma_chan *c)<br />
 {<br />
 	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);<br />
+	struct jz4740_dma_dev *dmadev = jz4740_dma_chan_get_dev(chan);<br />
 	unsigned long flags;<br />
 	LIST_HEAD(head);<br />
 <br />
 	spin_lock_irqsave(&amp;chan-&gt;vchan.lock, flags);<br />
-	jz4740_dma_disable(chan-&gt;jz_chan);<br />
+	jz4740_dma_write_mask(dmadev, JZ_REG_DMA_STATUS_CTRL(chan-&gt;id), 0,<br />
+			JZ_DMA_STATUS_CTRL_ENABLE);<br />
 	chan-&gt;desc = NULL;<br />
 	vchan_get_all_descriptors(&amp;chan-&gt;vchan, &amp;head);<br />
 	spin_unlock_irqrestore(&amp;chan-&gt;vchan.lock, flags);<br />
@@ -168,10 +305,12 @@ static int jz4740_dma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,<br />
 <br />
 static int jz4740_dma_start_transfer(struct jz4740_dmaengine_chan *chan)<br />
 {<br />
+	struct jz4740_dma_dev *dmadev = jz4740_dma_chan_get_dev(chan);<br />
 	struct virt_dma_desc *vdesc;<br />
 	struct jz4740_dma_sg *sg;<br />
 <br />
-	jz4740_dma_disable(chan-&gt;jz_chan);<br />
+	jz4740_dma_write_mask(dmadev, JZ_REG_DMA_STATUS_CTRL(chan-&gt;id), 0,<br />
+			JZ_DMA_STATUS_CTRL_ENABLE);<br />
 <br />
 	if (!chan-&gt;desc) {<br />
 		vdesc = vchan_next_desc(&amp;chan-&gt;vchan);<br />
@@ -187,26 +326,35 @@ static int jz4740_dma_start_transfer(struct jz4740_dmaengine_chan *chan)<br />
 	sg = &amp;chan-&gt;desc-&gt;sg[chan-&gt;next_sg];<br />
 <br />
 	if (chan-&gt;desc-&gt;direction == DMA_MEM_TO_DEV) {<br />
-		jz4740_dma_set_src_addr(chan-&gt;jz_chan, sg-&gt;addr);<br />
-		jz4740_dma_set_dst_addr(chan-&gt;jz_chan, chan-&gt;config.dst_addr);<br />
+		jz4740_dma_write(dmadev, JZ_REG_DMA_SRC_ADDR(chan-&gt;id),<br />
+			sg-&gt;addr);<br />
+		jz4740_dma_write(dmadev, JZ_REG_DMA_DST_ADDR(chan-&gt;id),<br />
+			chan-&gt;config.dst_addr);<br />
 	} else {<br />
-		jz4740_dma_set_src_addr(chan-&gt;jz_chan, chan-&gt;config.src_addr);<br />
-		jz4740_dma_set_dst_addr(chan-&gt;jz_chan, sg-&gt;addr);<br />
+		jz4740_dma_write(dmadev, JZ_REG_DMA_SRC_ADDR(chan-&gt;id),<br />
+			chan-&gt;config.src_addr);<br />
+		jz4740_dma_write(dmadev, JZ_REG_DMA_DST_ADDR(chan-&gt;id),<br />
+			sg-&gt;addr);<br />
 	}<br />
-	jz4740_dma_set_transfer_count(chan-&gt;jz_chan, sg-&gt;len);<br />
+	jz4740_dma_write(dmadev, JZ_REG_DMA_TRANSFER_COUNT(chan-&gt;id),<br />
+			sg-&gt;len &gt;&gt; chan-&gt;transfer_shift);<br />
 <br />
 	chan-&gt;next_sg++;<br />
 <br />
-	jz4740_dma_enable(chan-&gt;jz_chan);<br />
+	jz4740_dma_write_mask(dmadev, JZ_REG_DMA_STATUS_CTRL(chan-&gt;id),<br />
+			JZ_DMA_STATUS_CTRL_NO_DESC | JZ_DMA_STATUS_CTRL_ENABLE,<br />
+			JZ_DMA_STATUS_CTRL_HALT | JZ_DMA_STATUS_CTRL_NO_DESC |<br />
+			JZ_DMA_STATUS_CTRL_ENABLE);<br />
+<br />
+	jz4740_dma_write_mask(dmadev, JZ_REG_DMA_CTRL,<br />
+			JZ_DMA_CTRL_ENABLE,<br />
+			JZ_DMA_CTRL_HALT | JZ_DMA_CTRL_ENABLE);<br />
 <br />
 	return 0;<br />
 }<br />
 <br />
-static void jz4740_dma_complete_cb(struct jz4740_dma_chan *jz_chan, int error,<br />
-	void *devid)<br />
+static void jz4740_dma_chan_irq(struct jz4740_dmaengine_chan *chan)<br />
 {<br />
-	struct jz4740_dmaengine_chan *chan = devid;<br />
-<br />
 	spin_lock(&amp;chan-&gt;vchan.lock);<br />
 	if (chan-&gt;desc) {<br />
 		if (chan-&gt;desc &amp;&amp; chan-&gt;desc-&gt;cyclic) {<br />
@@ -222,6 +370,28 @@ static void jz4740_dma_complete_cb(struct jz4740_dma_chan *jz_chan, int error,<br />
 	spin_unlock(&amp;chan-&gt;vchan.lock);<br />
 }<br />
 <br />
+static irqreturn_t jz4740_dma_irq(int irq, void *devid)<br />
+{<br />
+	struct jz4740_dma_dev *dmadev = devid;<br />
+	uint32_t irq_status;<br />
+	unsigned int i;<br />
+<br />
+	irq_status = readl(dmadev-&gt;base + JZ_REG_DMA_IRQ);<br />
+<br />
+	for (i = 0; i &lt; 6; ++i) {<br />
+		if (irq_status &amp; (1 &lt;&lt; i)) {<br />
+			jz4740_dma_write_mask(dmadev,<br />
+				JZ_REG_DMA_STATUS_CTRL(i), 0,<br />
+				JZ_DMA_STATUS_CTRL_ENABLE |<br />
+				JZ_DMA_STATUS_CTRL_TRANSFER_DONE);<br />
+<br />
+			jz4740_dma_chan_irq(&amp;dmadev-&gt;chan<i>);<br />
+		}<br />
+	}<br />
+<br />
+	return IRQ_HANDLED;<br />
+}<br />
+<br />
 static void jz4740_dma_issue_pending(struct dma_chan *c)<br />
 {<br />
 	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);<br />
@@ -293,7 +463,8 @@ static struct dma_async_tx_descriptor *jz4740_dma_prep_dma_cyclic(<br />
 static size_t jz4740_dma_desc_residue(struct jz4740_dmaengine_chan *chan,<br />
 	struct jz4740_dma_desc *desc, unsigned int next_sg)<br />
 {<br />
-	size_t residue = 0;<br />
+	struct jz4740_dma_dev *dmadev = jz4740_dma_chan_get_dev(chan);<br />
+	unsigned int residue, count;<br />
 	unsigned int i;<br />
 <br />
 	residue = 0;<br />
@@ -301,8 +472,11 @@ static size_t jz4740_dma_desc_residue(struct jz4740_dmaengine_chan *chan,<br />
 	for (i = next_sg; i &lt; desc-&gt;num_sgs; i++)<br />
 		residue += desc-&gt;sg<i>.len;<br />
 <br />
-	if (next_sg != 0)<br />
-		residue += jz4740_dma_get_residue(chan-&gt;jz_chan);<br />
+	if (next_sg != 0) {<br />
+		count = jz4740_dma_read(dmadev,<br />
+			JZ_REG_DMA_TRANSFER_COUNT(chan-&gt;id));<br />
+		residue += count &lt;&lt; chan-&gt;transfer_shift;<br />
+	}<br />
 <br />
 	return residue;<br />
 }<br />
@@ -337,24 +511,12 @@ static enum dma_status jz4740_dma_tx_status(struct dma_chan *c,<br />
 <br />
 static int jz4740_dma_alloc_chan_resources(struct dma_chan *c)<br />
 {<br />
-	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);<br />
-<br />
-	chan-&gt;jz_chan = jz4740_dma_request(chan, NULL);<br />
-	if (!chan-&gt;jz_chan)<br />
-		return -EBUSY;<br />
-<br />
-	jz4740_dma_set_complete_cb(chan-&gt;jz_chan, jz4740_dma_complete_cb);<br />
-<br />
 	return 0;<br />
 }<br />
 <br />
 static void jz4740_dma_free_chan_resources(struct dma_chan *c)<br />
 {<br />
-	struct jz4740_dmaengine_chan *chan = to_jz4740_dma_chan(c);<br />
-<br />
-	vchan_free_chan_resources(&amp;chan-&gt;vchan);<br />
-	jz4740_dma_free(chan-&gt;jz_chan);<br />
-	chan-&gt;jz_chan = NULL;<br />
+	vchan_free_chan_resources(to_virt_chan(c));<br />
 }<br />
 <br />
 static void jz4740_dma_desc_free(struct virt_dma_desc *vdesc)<br />
@@ -368,7 +530,9 @@ static int jz4740_dma_probe(struct platform_device *pdev)<br />
 	struct jz4740_dma_dev *dmadev;<br />
 	struct dma_device *dd;<br />
 	unsigned int i;<br />
+	struct resource *res;<br />
 	int ret;<br />
+	int irq;<br />
 <br />
 	dmadev = devm_kzalloc(&amp;pdev-&gt;dev, sizeof(*dmadev), GFP_KERNEL);<br />
 	if (!dmadev)<br />
@@ -376,6 +540,17 @@ static int jz4740_dma_probe(struct platform_device *pdev)<br />
 <br />
 	dd = &amp;dmadev-&gt;ddev;<br />
 <br />
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);<br />
+	dmadev-&gt;base = devm_ioremap_resource(&amp;pdev-&gt;dev, res);<br />
+	if (IS_ERR(dmadev-&gt;base))<br />
+		return PTR_ERR(dmadev-&gt;base);<br />
+<br />
+	dmadev-&gt;clk = clk_get(&amp;pdev-&gt;dev, &quot;dma&quot;);<br />
+	if (IS_ERR(dmadev-&gt;clk))<br />
+		return PTR_ERR(dmadev-&gt;clk);<br />
+<br />
+	clk_prepare_enable(dmadev-&gt;clk);<br />
+<br />
 	dma_cap_set(DMA_SLAVE, dd-&gt;cap_mask);<br />
 	dma_cap_set(DMA_CYCLIC, dd-&gt;cap_mask);<br />
 	dd-&gt;device_alloc_chan_resources = jz4740_dma_alloc_chan_resources;<br />
@@ -391,6 +566,7 @@ static int jz4740_dma_probe(struct platform_device *pdev)<br />
 <br />
 	for (i = 0; i &lt; dd-&gt;chancnt; i++) {<br />
 		chan = &amp;dmadev-&gt;chan<i>;<br />
+		chan-&gt;id = i;<br />
 		chan-&gt;vchan.desc_free = jz4740_dma_desc_free;<br />
 		vchan_init(&amp;chan-&gt;vchan, dd);<br />
 	}<br />
@@ -399,16 +575,28 @@ static int jz4740_dma_probe(struct platform_device *pdev)<br />
 	if (ret)<br />
 		return ret;<br />
 <br />
+	irq = platform_get_irq(pdev, 0);<br />
+	ret = request_irq(irq, jz4740_dma_irq, 0, dev_name(&amp;pdev-&gt;dev), dmadev);<br />
+	if (ret)<br />
+		goto err_unregister;<br />
+<br />
 	platform_set_drvdata(pdev, dmadev);<br />
 <br />
 	return 0;<br />
+<br />
+err_unregister:<br />
+	dma_async_device_unregister(dd);<br />
+	return ret;<br />
 }<br />
 <br />
 static int jz4740_dma_remove(struct platform_device *pdev)<br />
 {<br />
 	struct jz4740_dma_dev *dmadev = platform_get_drvdata(pdev);<br />
+	int irq = platform_get_irq(pdev, 0);<br />
 <br />
+	free_irq(irq, dmadev);<br />
 	dma_async_device_unregister(&amp;dmadev-&gt;ddev);<br />
+	clk_disable_unprepare(dmadev-&gt;clk);<br />
 <br />
 	return 0;<br />
 }<br />
-- <br />
1.8.2.1<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a></i></i></i></i></i></i>]]></description>
            <dc:creator>Lars-Peter Clausen</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 22:40:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712191,712191#msg-712191</guid>
            <title>[PATCH 2/6] MIPS: jz4740: Acquire and enable DMA controller clock (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712191,712191#msg-712191</link>
            <description><![CDATA[ From: Maarten ter Huurne &lt;maarten@treewalker.org&gt;<br />
<br />
Previously, it was assumed that the DMA controller clock is not gated<br />
when the kernel starts running. While that is the power-on state, it is<br />
safer to not rely on that.<br />
<br />
Signed-off-by: Maarten ter Huurne &lt;maarten@treewalker.org&gt;<br />
Signed-off-by: Lars-Peter Clausen &lt;lars@metafoo.de&gt;<br />
---<br />
 arch/mips/jz4740/dma.c | 24 ++++++++++++++++++++++--<br />
 1 file changed, 22 insertions(+), 2 deletions(-)<br />
<br />
diff --git a/arch/mips/jz4740/dma.c b/arch/mips/jz4740/dma.c<br />
index 317ec6f..0e34b97 100644<br />
--- a/arch/mips/jz4740/dma.c<br />
+++ b/arch/mips/jz4740/dma.c<br />
@@ -16,6 +16,7 @@<br />
 #include &lt;linux/kernel.h&gt;<br />
 #include &lt;linux/module.h&gt;<br />
 #include &lt;linux/spinlock.h&gt;<br />
+#include &lt;linux/clk.h&gt;<br />
 #include &lt;linux/interrupt.h&gt;<br />
 <br />
 #include &lt;linux/dma-mapping.h&gt;<br />
@@ -268,6 +269,7 @@ static irqreturn_t jz4740_dma_irq(int irq, void *dev_id)<br />
 <br />
 static int jz4740_dma_init(void)<br />
 {<br />
+	struct clk *clk;<br />
 	unsigned int ret;<br />
 <br />
 	jz4740_dma_base = ioremap(JZ4740_DMAC_BASE_ADDR, 0x400);<br />
@@ -277,11 +279,29 @@ static int jz4740_dma_init(void)<br />
 <br />
 	spin_lock_init(&amp;jz4740_dma_lock);<br />
 <br />
-	ret = request_irq(JZ4740_IRQ_DMAC, jz4740_dma_irq, 0, &quot;DMA&quot;, NULL);<br />
+	clk = clk_get(NULL, &quot;dma&quot;);<br />
+	if (IS_ERR(clk)) {<br />
+		ret = PTR_ERR(clk);<br />
+		printk(KERN_ERR &quot;JZ4740 DMA: Failed to request clock: %d\n&quot;,<br />
+				ret);<br />
+		goto err_iounmap;<br />
+	}<br />
 <br />
-	if (ret)<br />
+	ret = request_irq(JZ4740_IRQ_DMAC, jz4740_dma_irq, 0, &quot;DMA&quot;, NULL);<br />
+	if (ret) {<br />
 		printk(KERN_ERR &quot;JZ4740 DMA: Failed to request irq: %d\n&quot;, ret);<br />
+		goto err_clkput;<br />
+	}<br />
+<br />
+	clk_prepare_enable(clk);<br />
+<br />
+	return 0;<br />
+<br />
+err_clkput:<br />
+	clk_put(clk);<br />
 <br />
+err_iounmap:<br />
+	iounmap(jz4740_dma_base);<br />
 	return ret;<br />
 }<br />
 arch_initcall(jz4740_dma_init);<br />
-- <br />
1.8.2.1<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Lars-Peter Clausen</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 22:40:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712182,712182#msg-712182</guid>
            <title>[PATCH] firmware: move EXPORT_SYMBOL annotations (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712182,712182#msg-712182</link>
            <description><![CDATA[ Move EXPORT_SYMBOL annotations so they follow immediately after the<br />
closing function brace line.<br />
<br />
Signed-off-by: Daniel Mack &lt;zonque@gmail.com&gt;<br />
---<br />
 drivers/base/firmware_class.c | 11 +++++------<br />
 1 file changed, 5 insertions(+), 6 deletions(-)<br />
<br />
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c<br />
index 4b1f926..4d9643f 100644<br />
--- a/drivers/base/firmware_class.c<br />
+++ b/drivers/base/firmware_class.c<br />
@@ -1079,6 +1079,7 @@ request_firmware(const struct firmware **firmware_p, const char *name,<br />
 {<br />
 	return _request_firmware(firmware_p, name, device, true, false);<br />
 }<br />
+EXPORT_SYMBOL(request_firmware);<br />
 <br />
 /**<br />
  * release_firmware: - release the resource associated with a firmware image<br />
@@ -1092,6 +1093,7 @@ void release_firmware(const struct firmware *fw)<br />
 		kfree(fw);<br />
 	}<br />
 }<br />
+EXPORT_SYMBOL(release_firmware);<br />
 <br />
 /* Async support */<br />
 struct firmware_work {<br />
@@ -1172,6 +1174,7 @@ request_firmware_nowait(<br />
 	schedule_work(&amp;fw_work-&gt;work);<br />
 	return 0;<br />
 }<br />
+EXPORT_SYMBOL(request_firmware_nowait);<br />
 <br />
 /**<br />
  * cache_firmware - cache one firmware image in kernel memory space<br />
@@ -1202,6 +1205,7 @@ int cache_firmware(const char *fw_name)<br />
 <br />
 	return ret;<br />
 }<br />
+EXPORT_SYMBOL_GPL(cache_firmware);<br />
 <br />
 /**<br />
  * uncache_firmware - remove one cached firmware image<br />
@@ -1232,6 +1236,7 @@ int uncache_firmware(const char *fw_name)<br />
 <br />
 	return -EINVAL;<br />
 }<br />
+EXPORT_SYMBOL_GPL(uncache_firmware);<br />
 <br />
 #ifdef CONFIG_PM_SLEEP<br />
 static ASYNC_DOMAIN_EXCLUSIVE(fw_cache_domain);<br />
@@ -1536,9 +1541,3 @@ static void __exit firmware_class_exit(void)<br />
 <br />
 fs_initcall(firmware_class_init);<br />
 module_exit(firmware_class_exit);<br />
-<br />
-EXPORT_SYMBOL(release_firmware);<br />
-EXPORT_SYMBOL(request_firmware);<br />
-EXPORT_SYMBOL(request_firmware_nowait);<br />
-EXPORT_SYMBOL_GPL(cache_firmware);<br />
-EXPORT_SYMBOL_GPL(uncache_firmware);<br />
-- <br />
1.8.1.4<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Daniel Mack</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 22:20:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712178,712178#msg-712178</guid>
            <title>[GIT PULL] PCI updates for v3.10 (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712178,712178#msg-712178</link>
            <description><![CDATA[ Hi Linus,<br />
<br />
Here are some more fixes for v3.10.  The Moorestown update broke Intel<br />
Medfield devices, so I reverted it.  The acpiphp change fixes a regression:<br />
we broke hotplug notifications to host bridges when we split acpiphp into<br />
the host-bridge related part and the endpoint-related part.<br />
<br />
Bjorn<br />
<br />
<br />
The following changes since commit f722406faae2d073cc1d01063d1123c35425939e:<br />
<br />
  Linux 3.10-rc1 (2013-05-11 17:14:08 -0700)<br />
<br />
are available in the git repository at:<br />
<br />
  git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git tags/pci-v3.10-fixes-2<br />
<br />
for you to fetch changes up to f3f011750a18abc389ef1b0d504fbeeacf641919:<br />
<br />
  Revert &quot;x86/pci/mrst: Use configuration mechanism 1 for 00:00.0, 00:02.0, 00:03.0&quot; (2013-05-20 10:20:21 -0600)<br />
<br />
----------------------------------------------------------------<br />
PCI updates for v3.10:<br />
<br />
  Moorestown<br />
      Revert &quot;x86/pci/mrst: Use configuration mechanism 1 for 00:00.0, 00:02.0, 00:03.0&quot;<br />
  Hotplug<br />
      PCI: acpiphp: Re-enumerate devices when host bridge receives Bus Check<br />
<br />
----------------------------------------------------------------<br />
Bjorn Helgaas (1):<br />
      Revert &quot;x86/pci/mrst: Use configuration mechanism 1 for 00:00.0, 00:02.0, 00:03.0&quot;<br />
<br />
Yinghai Lu (1):<br />
      PCI: acpiphp: Re-enumerate devices when host bridge receives Bus Check<br />
<br />
 arch/x86/pci/mrst.c                | 10 ++++------<br />
 drivers/acpi/pci_root.c            |  4 +++-<br />
 drivers/pci/hotplug/acpiphp_glue.c | 14 ++++++++++++++<br />
 include/linux/pci-acpi.h           |  2 ++<br />
 4 files changed, 23 insertions(+), 7 deletions(-)<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Bjorn Helgaas</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 22:10:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712177,712177#msg-712177</guid>
            <title>Exotic architecture fixes (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712177,712177#msg-712177</link>
            <description><![CDATA[ I created a branch where I collected several exotic architecture fixes<br />
(and a few<br />
other trivial fixes):<br />
<br />
  git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k.git<br />
exotic-arch-fixes<br />
<br />
Several of these have been ack'ed (cfr. *-indicators below).<br />
If you reject any of the commits, please scream.<br />
If you want to take any of them yourself, please do so.<br />
<br />
I intend to merge this into my for-next branch after the release of v3.10-rc4,<br />
and ask Linus to pull after the release of v3.10-rc5.<br />
This branch may be rebased.<br />
<br />
Thanks!<br />
<br />
Geert Uytterhoeven (32):<br />
    * avr32: atmel_default_console_device depends on CONFIG_SERIAL_ATMEL<br />
    * c6x: Wire up asm-generic/xor.h<br />
      cris/kgdb: Properly split long lines in asm<br />
      cris/kgdb: Remove unused static int do_printk<br />
      cris/kgdb: Kill forward declarations for static functions<br />
      cris/kgdb: Use #ifdef PROCESS_SUPPORT where needed<br />
      cris/kgb: Make symbols used from asm global<br />
      cris/kgdb: Remove obsolete USED*() macros<br />
      cris/kgdb: Fix buffer overflow in getpacket()<br />
      cris/kgdb: Remove sections protected by #ifdef PROCESS_SUPPORT<br />
      cris: Provide &lt;asm/kvm_para.h&gt;<br />
      cris: Provide inb_p() and outb_p()<br />
    * cris: Switch to asm-generic/linkage.h<br />
    * cris: Wire up asm-generic/xor.h<br />
      cris: Switch cris to drivers/Kconfig<br />
      console: Disable VGA text console support on cris<br />
      parport: disable PC-style parallel port support on cris<br />
      cris: Wire up asm-generic/vga.h<br />
      frv: head.S - Remove commented-out initialization code<br />
      h8300: Hardcode symbol prefixes in asm sources<br />
    * h8300: Fix &lt;asm/tlb.h&gt;<br />
      h8300: Fill the system call table using a CALL() macro<br />
      h8300: Wire up asm-generic/xor.h<br />
      h8300: Limit timer channel ranges in Kconfig<br />
      h8300: Switch h8300 to drivers/Kconfig<br />
      h8300: Mark H83002 and H83048 CPU support broken<br />
      openrisc: Wire up asm-generic/xor.h<br />
      score: Remove unneeded &lt;asm/dma-mapping.h&gt;<br />
      score: Wire up asm-generic/xor.h<br />
    * console/font: Refactor font support code selection logic<br />
    * ntp: Remove unused variable flags in __hardpps<br />
    * input: cros_ec_keyb_clear_keyboard() depends on CONFIG_PM_SLEEP<br />
<br />
Jiang Liu (1):<br />
      h8300: add missing definition for read_barries_depends()<br />
<br />
 arch/avr32/mach-at32ap/at32ap700x.c              |    2 +<br />
 arch/c6x/include/asm/Kbuild                      |    1 +<br />
 arch/cris/Kconfig                                |   32 +-<br />
 arch/cris/arch-v10/kernel/kgdb.c                 |  870 +++++++---------------<br />
 arch/cris/arch-v32/drivers/Kconfig               |    7 -<br />
 arch/cris/include/asm/Kbuild                     |    4 +<br />
 arch/cris/include/asm/io.h                       |    3 +<br />
 arch/cris/include/asm/linkage.h                  |    6 -<br />
 arch/frv/kernel/head.S                           |    5 -<br />
 arch/h8300/Kconfig                               |  118 +---<br />
 arch/h8300/Kconfig.cpu                           |    4 +<br />
 arch/h8300/include/asm/Kbuild                    |    2 +<br />
 arch/h8300/include/asm/barrier.h                 |    2 +<br />
 arch/h8300/include/asm/linkage.h                 |    6 -<br />
 arch/h8300/include/asm/tlb.h                     |   15 -<br />
 arch/h8300/kernel/entry.S                        |  118 ++--<br />
 arch/h8300/kernel/syscalls.S                     |  648 ++++++++--------<br />
 arch/h8300/lib/abs.S                             |    4 +-<br />
 arch/h8300/lib/memcpy.S                          |    4 +-<br />
 arch/h8300/lib/memset.S                          |    4 +-<br />
 arch/h8300/platform/h8300h/aki3068net/crt0_ram.S |   16 +-<br />
 arch/h8300/platform/h8300h/generic/crt0_ram.S    |   14 +-<br />
 arch/h8300/platform/h8300h/generic/crt0_rom.S    |   14 +-<br />
 arch/h8300/platform/h8300h/h8max/crt0_ram.S      |   16 +-<br />
 arch/h8300/platform/h8s/edosk2674/crt0_ram.S     |   16 +-<br />
 arch/h8300/platform/h8s/edosk2674/crt0_rom.S     |   14 +-<br />
 arch/h8300/platform/h8s/generic/crt0_ram.S       |   16 +-<br />
 arch/h8300/platform/h8s/generic/crt0_rom.S       |   12 +-<br />
 arch/openrisc/include/asm/Kbuild                 |    1 +<br />
 arch/score/include/asm/Kbuild                    |    1 +<br />
 arch/score/include/asm/dma-mapping.h             |    6 -<br />
 drivers/input/keyboard/cros_ec_keyb.c            |   54 +-<br />
 drivers/media/platform/Kconfig                   |    2 +-<br />
 drivers/parport/Kconfig                          |    4 +-<br />
 drivers/staging/media/solo6x10/Kconfig           |    2 +<br />
 drivers/usb/misc/sisusbvga/Kconfig               |    1 +<br />
 drivers/video/console/Kconfig                    |   16 +-<br />
 drivers/video/console/Makefile                   |   14 +-<br />
 kernel/time/ntp.c                                |    1 -<br />
 39 files changed, 789 insertions(+), 1286 deletions(-)<br />
 delete mode 100644 arch/cris/include/asm/linkage.h<br />
 delete mode 100644 arch/h8300/include/asm/linkage.h<br />
 delete mode 100644 arch/score/include/asm/dma-mapping.h<br />
<br />
Gr{oetje,eeting}s,<br />
<br />
                        Geert<br />
<br />
--<br />
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- <a href="mailto:&#103;&#101;&#101;&#114;&#116;&#64;&#108;&#105;&#110;&#117;&#120;&#45;&#109;&#54;&#56;&#107;&#46;&#111;&#114;&#103;">&#103;&#101;&#101;&#114;&#116;&#64;&#108;&#105;&#110;&#117;&#120;&#45;&#109;&#54;&#56;&#107;&#46;&#111;&#114;&#103;</a><br />
<br />
In personal conversations with technical people, I call myself a hacker. But<br />
when I'm talking to journalists I just say &quot;programmer&quot; or something like that.<br />
                                -- Linus Torvalds<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Geert Uytterhoeven</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 22:10:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712158,712158#msg-712158</guid>
            <title>[PATCH 0/3] kdump: Allow ELF header creation in new kernel (1 reply)</title>
            <link>http://www.serverphorums.com/read.php?12,712158,712158#msg-712158</link>
            <description><![CDATA[ Hello Vivek,<br />
<br />
Here, as discussed, the 3nd version of the patch set.<br />
<br />
ChangeLog<br />
=========<br />
v2 =&gt; v3)<br />
- Get rid of ELFCORE_ADDR_NEWMEM<br />
- Make read_from_crash_header() only read from kernel<br />
- Move read_from_crash_header() to weak function arch_read_from_crash_header()<br />
- Implement read_from_crash_header() strong function for s390<br />
- Set elfcorehdr_addr to address of new ELF header<br />
<br />
v1 =&gt; v2)<br />
<br />
- Rebase 3.10-rc2 + vmcore mmap patches<br />
- Introduced arch_get/free_crash_header() and ELFCORE_ADDR_NEWMEM<br />
<br />
Feature Description<br />
===================<br />
For s390 we want to use /proc/vmcore for our SCSI stand-alone<br />
dump (zfcpdump). We have support where the first HSA_SIZE bytes are<br />
saved into a hypervisor owned memory area (HSA) before the kdump<br />
kernel is booted. When the kdump kernel starts, it is restricted<br />
to use only HSA_SIZE bytes.<br />
<br />
The advantages of this mechanism are:<br />
<br />
* No crashkernel memory has to be defined in the old kernel.<br />
* Early boot problems (before kexec_load has been done) can be dumped <br />
* Non-Linux systems can be dumped.<br />
<br />
We modify the s390 copy_oldmem_page() function to read from the HSA memory<br />
if memory below HSA_SIZE bytes is requested.<br />
<br />
Since we cannot use the kexec tool to load the kernel in this scenario,<br />
we have to build the ELF header in the 2nd (kdump/new) kernel.<br />
<br />
So with the following patch set we would like to introduce the new<br />
function that the ELF header for /proc/vmcore can be created in the 2nd<br />
kernel memory.<br />
<br />
The following steps are done during zfcpdump execution:<br />
<br />
1.  Production system crashes<br />
2.  User boots a SCSI disk that has been prepared with the zfcpdump tool<br />
3.  Hypervisor saves CPU state of boot CPU and HSA_SIZE bytes of memory into HSA<br />
4.  Boot loader loads kernel into low memory area<br />
5.  Kernel boots and uses only HSA_SIZE bytes of memory<br />
6.  Kernel saves registers of non-boot CPUs<br />
7.  Kernel does memory detection for dump memory map<br />
8.  Kernel creates ELF header for /proc/vmcore<br />
9.  /proc/vmcore uses this header for initialization<br />
10. The zfcpdump user space reads /proc/vmcore to write dump to SCSI disk<br />
    - copy_oldmem_page() copies from HSA for memory below HSA_SIZE<br />
    - copy_oldmem_page() copies from real memory for memory above HSA_SIZE<br />
<br />
Jan Willeke (1):<br />
  s390/kdump: Use vmcore for zfcpdump<br />
<br />
Michael Holzheu (2):<br />
  kdump: Introduce ELF header in new memory feature<br />
  s390/kdump: Use ELF header in new memory feature<br />
<br />
 arch/s390/Kconfig             |   3 +-<br />
 arch/s390/include/asm/sclp.h  |   1 +<br />
 arch/s390/kernel/crash_dump.c | 138 +++++++++++++++++++++++++++++++-----------<br />
 drivers/s390/char/zcore.c     |   6 +-<br />
 fs/proc/vmcore.c              |  65 ++++++++++++++------<br />
 include/linux/crash_dump.h    |   4 ++<br />
 6 files changed, 161 insertions(+), 56 deletions(-)<br />
<br />
-- <br />
1.8.1.6<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Michael Holzheu</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 21:00:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712157,712157#msg-712157</guid>
            <title>[PATCH v3 1/3] kdump: Introduce ELF header in new memory feature (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712157,712157#msg-712157</link>
            <description><![CDATA[ Currently for s390 we create the ELF core header in the 2nd kernel<br />
with a small trick. We relocate the addresses in the ELF header in<br />
a way that for the /proc/vmcore code it seems to be in the 1st kernel<br />
(old) memory and the read_from_oldmem() returns the correct data.<br />
This allows the /proc/vmcore code to use the ELF header in the<br />
2nd kernel.<br />
<br />
This patch now exchanges the old mechanism with the new and much<br />
cleaner function call override feature that now offcially allows to<br />
create the ELF core header in the 2nd kernel.<br />
<br />
To use the new feature the following has to be done by the architecture<br />
backend code:<br />
<br />
 * Override arch_get_crash_header() to return the address of the ELF<br />
   header in new memory<br />
 * Override arch_free_crash_header() to free the memory of the ELF<br />
   header in new memory<br />
 * Override arch_read_from_crash_header() to read from the ELF header<br />
   in new memory<br />
 * Set elfcorehdr_addr to the address of ELF header in new memory<br />
<br />
Signed-off-by: Michael Holzheu &lt;holzheu@linux.vnet.ibm.com&gt;<br />
---<br />
 fs/proc/vmcore.c           | 65 +++++++++++++++++++++++++++++++++-------------<br />
 include/linux/crash_dump.h |  4 +++<br />
 2 files changed, 51 insertions(+), 18 deletions(-)<br />
<br />
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c<br />
index 6ba32f8..a9e1b65 100644<br />
--- a/fs/proc/vmcore.c<br />
+++ b/fs/proc/vmcore.c<br />
@@ -123,6 +123,28 @@ static ssize_t read_from_oldmem(char *buf, size_t count,<br />
 	return read;<br />
 }<br />
 <br />
+/*<br />
+ * Architetures may override this function to read header data<br />
+ */<br />
+ssize_t __weak arch_read_from_crash_header(char *buf, size_t count, u64 *ppos)<br />
+{<br />
+	return read_from_oldmem(buf, count, ppos, 0);<br />
+}<br />
+<br />
+/*<br />
+ * Architetures may override this function to get header address<br />
+ */<br />
+unsigned long long __weak arch_get_crash_header(void)<br />
+{<br />
+	return elfcorehdr_addr;<br />
+}<br />
+<br />
+/*<br />
+ * Architetures may override this function to free header<br />
+ */<br />
+void __weak arch_free_crash_header(void)<br />
+{}<br />
+<br />
 /* Read from the ELF header and then the crash dump. On error, negative value is<br />
  * returned otherwise number of bytes read are returned.<br />
  */<br />
@@ -356,7 +378,8 @@ static int __init get_note_number_and_size_elf64(const Elf64_Ehdr *ehdr_ptr,<br />
 		notes_section = kmalloc(max_sz, GFP_KERNEL);<br />
 		if (!notes_section)<br />
 			return -ENOMEM;<br />
-		rc = read_from_oldmem(notes_section, max_sz, &amp;offset, 0);<br />
+		rc = arch_read_from_crash_header(notes_section, max_sz,<br />
+						 &amp;offset);<br />
 		if (rc &lt; 0) {<br />
 			kfree(notes_section);<br />
 			return rc;<br />
@@ -412,7 +435,8 @@ static int __init copy_notes_elf64(const Elf64_Ehdr *ehdr_ptr, char *notes_buf)<br />
 		notes_section = kmalloc(max_sz, GFP_KERNEL);<br />
 		if (!notes_section)<br />
 			return -ENOMEM;<br />
-		rc = read_from_oldmem(notes_section, max_sz, &amp;offset, 0);<br />
+		rc = arch_read_from_crash_header(notes_section, max_sz,<br />
+						 &amp;offset);<br />
 		if (rc &lt; 0) {<br />
 			kfree(notes_section);<br />
 			return rc;<br />
@@ -428,8 +452,8 @@ static int __init copy_notes_elf64(const Elf64_Ehdr *ehdr_ptr, char *notes_buf)<br />
 			nhdr_ptr = (Elf64_Nhdr*)((char*)nhdr_ptr + sz);<br />
 		}<br />
 		offset = phdr_ptr-&gt;p_offset;<br />
-		rc = read_from_oldmem(notes_buf + phdr_sz, real_sz,<br />
-				      &amp;offset, 0);<br />
+		rc = arch_read_from_crash_header(notes_buf + phdr_sz, real_sz,<br />
+						 &amp;offset);<br />
 		if (rc &lt; 0) {<br />
 			kfree(notes_section);<br />
 			return rc;<br />
@@ -533,7 +557,8 @@ static int __init get_note_number_and_size_elf32(const Elf32_Ehdr *ehdr_ptr,<br />
 		notes_section = kmalloc(max_sz, GFP_KERNEL);<br />
 		if (!notes_section)<br />
 			return -ENOMEM;<br />
-		rc = read_from_oldmem(notes_section, max_sz, &amp;offset, 0);<br />
+		rc = arch_read_from_crash_header(notes_section, max_sz,<br />
+						 &amp;offset);<br />
 		if (rc &lt; 0) {<br />
 			kfree(notes_section);<br />
 			return rc;<br />
@@ -589,7 +614,8 @@ static int __init copy_notes_elf32(const Elf32_Ehdr *ehdr_ptr, char *notes_buf)<br />
 		notes_section = kmalloc(max_sz, GFP_KERNEL);<br />
 		if (!notes_section)<br />
 			return -ENOMEM;<br />
-		rc = read_from_oldmem(notes_section, max_sz, &amp;offset, 0);<br />
+		rc = arch_read_from_crash_header(notes_section, max_sz,<br />
+						 &amp;offset);<br />
 		if (rc &lt; 0) {<br />
 			kfree(notes_section);<br />
 			return rc;<br />
@@ -605,8 +631,8 @@ static int __init copy_notes_elf32(const Elf32_Ehdr *ehdr_ptr, char *notes_buf)<br />
 			nhdr_ptr = (Elf32_Nhdr*)((char*)nhdr_ptr + sz);<br />
 		}<br />
 		offset = phdr_ptr-&gt;p_offset;<br />
-		rc = read_from_oldmem(notes_buf + phdr_sz, real_sz,<br />
-				      &amp;offset, 0);<br />
+		rc = arch_read_from_crash_header(notes_buf + phdr_sz, real_sz,<br />
+						 &amp;offset);<br />
 		if (rc &lt; 0) {<br />
 			kfree(notes_section);<br />
 			return rc;<br />
@@ -804,10 +830,11 @@ static int __init parse_crash_elf64_headers(void)<br />
 	Elf64_Ehdr ehdr;<br />
 	u64 addr;<br />
 <br />
-	addr = elfcorehdr_addr;<br />
+	addr = arch_get_crash_header();<br />
 <br />
 	/* Read Elf header */<br />
-	rc = read_from_oldmem((char*)&amp;ehdr, sizeof(Elf64_Ehdr), &amp;addr, 0);<br />
+	rc = arch_read_from_crash_header((char *)&amp;ehdr, sizeof(Elf64_Ehdr),<br />
+					 &amp;addr);<br />
 	if (rc &lt; 0)<br />
 		return rc;<br />
 <br />
@@ -832,8 +859,8 @@ static int __init parse_crash_elf64_headers(void)<br />
 					       get_order(elfcorebuf_sz_orig));<br />
 	if (!elfcorebuf)<br />
 		return -ENOMEM;<br />
-	addr = elfcorehdr_addr;<br />
-	rc = read_from_oldmem(elfcorebuf, elfcorebuf_sz_orig, &amp;addr, 0);<br />
+	addr = arch_get_crash_header();<br />
+	rc = arch_read_from_crash_header(elfcorebuf, elfcorebuf_sz_orig, &amp;addr);<br />
 	if (rc &lt; 0) {<br />
 		free_pages((unsigned long)elfcorebuf,<br />
 			   get_order(elfcorebuf_sz_orig));<br />
@@ -867,10 +894,11 @@ static int __init parse_crash_elf32_headers(void)<br />
 	Elf32_Ehdr ehdr;<br />
 	u64 addr;<br />
 <br />
-	addr = elfcorehdr_addr;<br />
+	addr = arch_get_crash_header();<br />
 <br />
 	/* Read Elf header */<br />
-	rc = read_from_oldmem((char*)&amp;ehdr, sizeof(Elf32_Ehdr), &amp;addr, 0);<br />
+	rc = arch_read_from_crash_header((char *)&amp;ehdr, sizeof(Elf32_Ehdr),<br />
+					 &amp;addr);<br />
 	if (rc &lt; 0)<br />
 		return rc;<br />
 <br />
@@ -895,8 +923,8 @@ static int __init parse_crash_elf32_headers(void)<br />
 					       get_order(elfcorebuf_sz_orig));<br />
 	if (!elfcorebuf)<br />
 		return -ENOMEM;<br />
-	addr = elfcorehdr_addr;<br />
-	rc = read_from_oldmem(elfcorebuf, elfcorebuf_sz_orig, &amp;addr, 0);<br />
+	addr = arch_get_crash_header();<br />
+	rc = arch_read_from_crash_header(elfcorebuf, elfcorebuf_sz_orig, &amp;addr);<br />
 	if (rc &lt; 0) {<br />
 		free_pages((unsigned long)elfcorebuf,<br />
 			   get_order(elfcorebuf_sz_orig));<br />
@@ -930,8 +958,8 @@ static int __init parse_crash_elf_headers(void)<br />
 	u64 addr;<br />
 	int rc=0;<br />
 <br />
-	addr = elfcorehdr_addr;<br />
-	rc = read_from_oldmem(e_ident, EI_NIDENT, &amp;addr, 0);<br />
+	addr = arch_get_crash_header();<br />
+	rc = arch_read_from_crash_header(e_ident, EI_NIDENT, &amp;addr);<br />
 	if (rc &lt; 0)<br />
 		return rc;<br />
 	if (memcmp(e_ident, ELFMAG, SELFMAG) != 0) {<br />
@@ -961,6 +989,7 @@ static int __init parse_crash_elf_headers(void)<br />
 		pr_warn(&quot;Warning: Core image elf header is not sane\n&quot;);<br />
 		return -EINVAL;<br />
 	}<br />
+	arch_free_crash_header();<br />
 	return 0;<br />
 }<br />
 <br />
diff --git a/include/linux/crash_dump.h b/include/linux/crash_dump.h<br />
index 37e4f8d..c66da41 100644<br />
--- a/include/linux/crash_dump.h<br />
+++ b/include/linux/crash_dump.h<br />
@@ -14,6 +14,10 @@ extern unsigned long long elfcorehdr_size;<br />
 <br />
 extern ssize_t copy_oldmem_page(unsigned long, char *, size_t,<br />
 						unsigned long, int);<br />
+extern unsigned long long __weak arch_get_crash_header(void);<br />
+extern void __weak arch_free_crash_header(void);<br />
+extern ssize_t __weak arch_read_from_crash_header(char *buf, size_t count,<br />
+						  u64 *ppos);<br />
 <br />
 /* Architecture code defines this if there are other possible ELF<br />
  * machine types, e.g. on bi-arch capable hardware. */<br />
-- <br />
1.8.1.6<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Michael Holzheu</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 21:00:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712156,712156#msg-712156</guid>
            <title>[PATCH v3 3/3] s390/kdump: Use vmcore for zfcpdump (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712156,712156#msg-712156</link>
            <description><![CDATA[ From: Jan Willeke &lt;willeke@de.ibm.com&gt;<br />
<br />
This patch modifies the s390 copy_oldmem_page() function for zfcpdump<br />
to read from the HSA memory if memory below HSA_SIZE bytes is requested.<br />
Otherwise from real memory is read.<br />
<br />
Signed-off-by: Jan Willeke &lt;willeke@de.ibm.com&gt;<br />
Signed-off-by: Michael Holzheu &lt;holzheu@linux.vnet.ibm.com&gt;<br />
---<br />
 arch/s390/Kconfig             |  3 +-<br />
 arch/s390/include/asm/sclp.h  |  1 +<br />
 arch/s390/kernel/crash_dump.c | 74 ++++++++++++++++++++++++++++++++++---------<br />
 drivers/s390/char/zcore.c     |  6 ++--<br />
 4 files changed, 65 insertions(+), 19 deletions(-)<br />
<br />
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig<br />
index 2c9789d..a0d78f1 100644<br />
--- a/arch/s390/Kconfig<br />
+++ b/arch/s390/Kconfig<br />
@@ -516,6 +516,7 @@ config CRASH_DUMP<br />
 	bool &quot;kernel crash dumps&quot;<br />
 	depends on 64BIT &amp;&amp; SMP<br />
 	select KEXEC<br />
+	select ZFCPDUMP<br />
 	help<br />
 	  Generate crash dump after being started by kexec.<br />
 	  Crash dump kernels are loaded in the main kernel with kexec-tools<br />
@@ -526,7 +527,7 @@ config CRASH_DUMP<br />
 config ZFCPDUMP<br />
 	def_bool n<br />
 	prompt &quot;zfcpdump support&quot;<br />
-	select SMP<br />
+	depends on SMP<br />
 	help<br />
 	  Select this option if you want to build an zfcpdump enabled kernel.<br />
 	  Refer to &lt;file:Documentation/s390/zfcpdump.txt&gt; for more details on this.<br />
diff --git a/arch/s390/include/asm/sclp.h b/arch/s390/include/asm/sclp.h<br />
index 06a1361..7dc7f9c 100644<br />
--- a/arch/s390/include/asm/sclp.h<br />
+++ b/arch/s390/include/asm/sclp.h<br />
@@ -56,5 +56,6 @@ bool sclp_has_linemode(void);<br />
 bool sclp_has_vt220(void);<br />
 int sclp_pci_configure(u32 fid);<br />
 int sclp_pci_deconfigure(u32 fid);<br />
+int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode);<br />
 <br />
 #endif /* _ASM_S390_SCLP_H */<br />
diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c<br />
index aeb1207..fd0dc60 100644<br />
--- a/arch/s390/kernel/crash_dump.c<br />
+++ b/arch/s390/kernel/crash_dump.c<br />
@@ -16,6 +16,7 @@<br />
 #include &lt;asm/os_info.h&gt;<br />
 #include &lt;asm/elf.h&gt;<br />
 #include &lt;asm/ipl.h&gt;<br />
+#include &lt;asm/sclp.h&gt;<br />
 <br />
 #define PTR_ADD(x, y) (((char *) (x)) + ((unsigned long) (y)))<br />
 #define PTR_SUB(x, y) (((char *) (x)) - ((unsigned long) (y)))<br />
@@ -24,6 +25,25 @@<br />
 static size_t elfcorebuf_sz;<br />
 static char *elfcorebuf;<br />
 <br />
+/* For pages below ZFCPDUMP_HSA_SIZE memory from the HSA is copied. Otherwise<br />
+ * real memory copy is used.<br />
+ */<br />
+static ssize_t copy_oldmem_page_zfcpdump(char *buf, size_t csize,<br />
+					 unsigned long src, int userbuf)<br />
+{<br />
+	if (src &lt; ZFCPDUMP_HSA_SIZE) {<br />
+		if (memcpy_hsa(buf, src, csize, userbuf) &lt; 0)<br />
+			return -EINVAL;<br />
+	} else {<br />
+		if (userbuf)<br />
+			copy_to_user_real((void __force __user *) buf,<br />
+					  (void *) src, csize);<br />
+		else<br />
+			memcpy_real(buf, (void *) src, csize);<br />
+	}<br />
+	return csize;<br />
+}<br />
+<br />
 /*<br />
  * Copy one page from &quot;oldmem&quot;<br />
  *<br />
@@ -31,15 +51,10 @@ static char *elfcorebuf;<br />
  *  - [OLDMEM_BASE - OLDMEM_BASE + OLDMEM_SIZE] is mapped to [0 - OLDMEM_SIZE].<br />
  *  - [0 - OLDMEM_SIZE] is mapped to [OLDMEM_BASE - OLDMEM_BASE + OLDMEM_SIZE]<br />
  */<br />
-ssize_t copy_oldmem_page(unsigned long pfn, char *buf,<br />
-			 size_t csize, unsigned long offset, int userbuf)<br />
-{<br />
-	unsigned long src;<br />
+static ssize_t copy_oldmem_page_kdump(char *buf, size_t csize,<br />
+				      unsigned long src, int userbuf)<br />
 <br />
-	if (!csize)<br />
-		return 0;<br />
-<br />
-	src = (pfn &lt;&lt; PAGE_SHIFT) + offset;<br />
+{<br />
 	if (src &lt; OLDMEM_SIZE)<br />
 		src += OLDMEM_BASE;<br />
 	else if (src &gt; OLDMEM_BASE &amp;&amp;<br />
@@ -54,6 +69,23 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,<br />
 }<br />
 <br />
 /*<br />
+ * Copy one page from &quot;oldmem&quot;<br />
+ */<br />
+ssize_t copy_oldmem_page(unsigned long pfn, char *buf, size_t csize,<br />
+			 unsigned long offset, int userbuf)<br />
+{<br />
+	unsigned long src;<br />
+	if (!csize)<br />
+		return 0;<br />
+	src = (pfn &lt;&lt; PAGE_SHIFT) + offset;<br />
+<br />
+	if (OLDMEM_BASE)<br />
+		return copy_oldmem_page_kdump(buf, csize, src, userbuf);<br />
+	else<br />
+		return copy_oldmem_page_zfcpdump(buf, csize, src, userbuf);<br />
+}<br />
+<br />
+/*<br />
  * Copy memory from old kernel<br />
  */<br />
 int copy_from_oldmem(void *dest, void *src, size_t count)<br />
@@ -61,11 +93,21 @@ int copy_from_oldmem(void *dest, void *src, size_t count)<br />
 	unsigned long copied = 0;<br />
 	int rc;<br />
 <br />
-	if ((unsigned long) src &lt; OLDMEM_SIZE) {<br />
-		copied = min(count, OLDMEM_SIZE - (unsigned long) src);<br />
-		rc = memcpy_real(dest, src + OLDMEM_BASE, copied);<br />
-		if (rc)<br />
-			return rc;<br />
+	if (OLDMEM_BASE) {<br />
+		if ((unsigned long) src &lt; OLDMEM_SIZE) {<br />
+			copied = min(count, OLDMEM_SIZE - (unsigned long) src);<br />
+			rc = memcpy_real(dest, src + OLDMEM_BASE, copied);<br />
+			if (rc)<br />
+				return rc;<br />
+		}<br />
+	} else {<br />
+		if ((unsigned long) src &lt; ZFCPDUMP_HSA_SIZE) {<br />
+			copied = min(count,<br />
+				     ZFCPDUMP_HSA_SIZE - (unsigned long) src);<br />
+			rc = memcpy_hsa(dest, (unsigned long) src, copied, 0);<br />
+			if (rc)<br />
+				return rc;<br />
+		}<br />
 	}<br />
 	return memcpy_real(dest + copied, src + copied, count - copied);<br />
 }<br />
@@ -458,7 +500,9 @@ ssize_t arch_read_from_crash_header(char *buf, size_t count, u64 *ppos)<br />
  */<br />
 static int setup_kdump_elfcorehdr(void)<br />
 {<br />
-	if (!OLDMEM_BASE || is_kdump_kernel())<br />
+	if (!OLDMEM_BASE &amp;&amp; (ipl_info.type != IPL_TYPE_FCP_DUMP))<br />
+		return -EINVAL;<br />
+	if (is_kdump_kernel())<br />
 		return -EINVAL;<br />
 	s390_elf_corehdr_create(&amp;elfcorebuf, &amp;elfcorebuf_sz);<br />
 	elfcorehdr_addr = __pa(elfcorebuf);<br />
@@ -466,4 +510,4 @@ static int setup_kdump_elfcorehdr(void)<br />
 	return 0;<br />
 }<br />
 <br />
-subsys_initcall(setup_kdump_elfcorehdr);<br />
+subsys_initcall_sync(setup_kdump_elfcorehdr);<br />
diff --git a/drivers/s390/char/zcore.c b/drivers/s390/char/zcore.c<br />
index 9e5e146..794820a 100644<br />
--- a/drivers/s390/char/zcore.c<br />
+++ b/drivers/s390/char/zcore.c<br />
@@ -30,8 +30,8 @@<br />
 <br />
 #define TRACE(x...) debug_sprintf_event(zcore_dbf, 1, x)<br />
 <br />
-#define TO_USER		0<br />
-#define TO_KERNEL	1<br />
+#define TO_USER		1<br />
+#define TO_KERNEL	0<br />
 #define CHUNK_INFO_SIZE	34 /* 2 16-byte char, each followed by blank */<br />
 <br />
 enum arch_id {<br />
@@ -73,7 +73,7 @@ static struct ipl_parameter_block *ipl_block;<br />
  * @count: Size of buffer, which should be copied<br />
  * @mode:  Either TO_KERNEL or TO_USER<br />
  */<br />
-static int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode)<br />
+int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode)<br />
 {<br />
 	int offs, blk_num;<br />
 	static char buf[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));<br />
-- <br />
1.8.1.6<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Michael Holzheu</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 21:00:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712154,712154#msg-712154</guid>
            <title>NULL pointer deref after vmalloc() failure in fill_files_note() (no replies)</title>
            <link>http://www.serverphorums.com/read.php?12,712154,712154#msg-712154</link>
            <description><![CDATA[ Hello,<br />
<br />
Noticed while fuzzing with trinity, that if the vmalloc() in<br />
fill_files_note() fails, we Oops.<br />
<br />
I can easily reproduce the bug with this applied:<br />
<br />
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c<br />
index f8a0b0e..11b444f 100644<br />
--- a/fs/binfmt_elf.c<br />
+++ b/fs/binfmt_elf.c<br />
@@ -1432,7 +1432,7 @@ static void fill_files_note(struct memelfnote *note)<br />
        if (size &gt;= MAX_FILE_NOTE_SIZE) /* paranoia check */<br />
                goto err;<br />
        size = round_up(size, PAGE_SIZE);<br />
-       data = vmalloc(size);<br />
+       data = NULL;<br />
        if (!data)<br />
                goto err;<br />
<br />
<br />
Tommi<br />
<br />
[   69.144390] BUG: unable to handle kernel NULL pointer dereference<br />
at 0000000000000246<br />
[   69.145015] IP: [&lt;ffffffff814d22f0&gt;] strim+0x80/0x80<br />
[   69.145015] PGD b7ceb067 PUD b7df7067 PMD 0<br />
[   69.145015] Oops: 0000 [#1] SMP DEBUG_PAGEALLOC<br />
[   69.145015] CPU: 0 PID: 3412 Comm: cat Not tainted 3.10.0-rc2+ #20<br />
[   69.145015] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011<br />
[   69.145015] task: ffff8800b6a00000 ti: ffff8800b7d78000 task.ti:<br />
ffff8800b7d78000<br />
[   69.145015] RIP: 0010:[&lt;ffffffff814d22f0&gt;]  [&lt;ffffffff814d22f0&gt;]<br />
strim+0x80/0x80<br />
[   69.145015] RSP: 0018:ffff8800b7d799b0  EFLAGS: 00010206<br />
[   69.145015] RAX: 0000000000000144 RBX: 0000000000000000 RCX: ffff8800b44c0000<br />
[   69.145015] RDX: ffff8800b7d79b20 RSI: 0000000000000000 RDI: 0000000000000246<br />
[   69.145015] RBP: ffff8800b7d799c0 R08: 0000000000000000 R09: 0000000000000000<br />
[   69.145015] R10: 0000000000000001 R11: 0000000000000001 R12: ffff8800b7d79b88<br />
[   69.145015] R13: 00007ffffffff000 R14: 00007fffbf94cee6 R15: ffffffff8241fde8<br />
[   69.145015] FS:  00007fa54cb2d700(0000) GS:ffff8800bf600000(0000)<br />
knlGS:0000000000000000<br />
[   69.145015] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b<br />
[   69.145015] CR2: 0000000000000246 CR3: 00000000b7e41000 CR4: 00000000000006f0<br />
[   69.145015] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000<br />
[   69.145015] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400<br />
[   69.145015] Stack:<br />
[   69.145015]  ffffffff8128784c 00000000000003d8 ffff8800b7d79a70<br />
ffffffff81289490<br />
[   69.145015]  ffffffff812891e7 0000000000000246 0000000000000000<br />
ffff8800b6a00000<br />
[   69.145015]  ffff8800b7d79e78 ffff8800b6bea410 ffff8800b7d79fd8<br />
ffff8800b7d79fd8<br />
[   69.145015] Call Trace:<br />
[   69.145015]  [&lt;ffffffff8128784c&gt;] ? notesize.isra.6+0xc/0x30<br />
[   69.145015]  [&lt;ffffffff81289490&gt;] fill_note_info.isra.8+0xc60/0xcc0<br />
[   69.145015]  [&lt;ffffffff812891e7&gt;] ? fill_note_info.isra.8+0x9b7/0xcc0<br />
[   69.145015]  [&lt;ffffffff812895a8&gt;] elf_core_dump+0xb8/0x960<br />
[   69.145015]  [&lt;ffffffff81173028&gt;] ? trace_hardirqs_off_caller+0x28/0xe0<br />
[   69.145015]  [&lt;ffffffff811730ed&gt;] ? trace_hardirqs_off+0xd/0x10<br />
[   69.145015]  [&lt;ffffffff8228892f&gt;] ? __slab_free+0x1a1/0x380<br />
[   69.145015]  [&lt;ffffffff81172f55&gt;] ? trace_hardirqs_on_caller+0x185/0x220<br />
[   69.145015]  [&lt;ffffffff814dfb7c&gt;] ? debug_check_no_obj_freed+0x16c/0x220<br />
[   69.145015]  [&lt;ffffffff814c959a&gt;] ? argv_free+0x1a/0x20<br />
[   69.145015]  [&lt;ffffffff81225226&gt;] ? kfree+0x256/0x2c0<br />
[   69.145015]  [&lt;ffffffff8128fb9b&gt;] do_coredump+0x8db/0xcd0<br />
[   69.145015]  [&lt;ffffffff81173028&gt;] ? trace_hardirqs_off_caller+0x28/0xe0<br />
[   69.145015]  [&lt;ffffffff81172f55&gt;] ? trace_hardirqs_on_caller+0x185/0x220<br />
[   69.145015]  [&lt;ffffffff8112a65a&gt;] get_signal_to_deliver+0x81a/0x920<br />
[   69.145015]  [&lt;ffffffff8106f4e9&gt;] ? sched_clock+0x9/0x10<br />
[   69.145015]  [&lt;ffffffff810673e2&gt;] do_signal+0x52/0x590<br />
[   69.145015]  [&lt;ffffffff81172f55&gt;] ? trace_hardirqs_on_caller+0x185/0x220<br />
[   69.145015]  [&lt;ffffffff822a1858&gt;] ? retint_swapgs+0x13/0x1b<br />
[   69.145015]  [&lt;ffffffff8159e3d7&gt;] ? tty_ldisc_deref+0x67/0xc0<br />
[   69.145015]  [&lt;ffffffff81594a86&gt;] ? tty_read+0xa6/0x120<br />
[   69.145015]  [&lt;ffffffff822a2231&gt;] ? sysret_signal+0x5/0x4e<br />
[   69.145015]  [&lt;ffffffff81067947&gt;] do_notify_resume+0x27/0x70<br />
[   69.145015]  [&lt;ffffffff822a24e2&gt;] int_signal+0x12/0x17<br />
[   69.145015] Code: 20 74 18 0f 1f 84 00 00 00 00 00 48 83 c0 01 0f<br />
b6 10 f6 82 40 00 48 82 20 75 f0 5d c3 66 66 66 66 66 2e 0f 1f 84 00<br />
00 00 00 00 &lt;80&gt; 3f 00 55 48 89 e5 74 15 48 89 f8 0f 1f 40 00 48 83 c0<br />
01 80<br />
[   69.145015] RIP  [&lt;ffffffff814d22f0&gt;] strim+0x80/0x80<br />
[   69.145015]  RSP &lt;ffff8800b7d799b0&gt;<br />
[   69.145015] CR2: 0000000000000246<br />
[   69.225239] ---[ end trace 5d63690e960d7c7c ]---<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Tommi Rantala</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 21:00:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?12,712147,712147#msg-712147</guid>
            <title>[PATCH] Print the actual UEFI error name, not just the error code. (1 reply)</title>
            <link>http://www.serverphorums.com/read.php?12,712147,712147#msg-712147</link>
            <description><![CDATA[ EFI error numbers are useful, but symbol names are way easier to<br />
understand when you're reading bug reports.  And since, for the most<br />
part, we know the names, we should show them.<br />
<br />
Signed-off-by: Peter Jones &lt;pjones@redhat.com&gt;<br />
Reviewed-by: Adam Jackson &lt;ajax@redhat.com&gt;<br />
---<br />
 drivers/firmware/efivars.c | 19 +++++-------<br />
 include/linux/efi.h        | 75 +++++++++++++++++++++++++++++++++++++++-------<br />
 2 files changed, 71 insertions(+), 23 deletions(-)<br />
<br />
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c<br />
index 182ce94..6dc0676 100644<br />
--- a/drivers/firmware/efivars.c<br />
+++ b/drivers/firmware/efivars.c<br />
@@ -382,8 +382,7 @@ get_var_data(struct efivars *efivars, struct efi_variable *var)<br />
 	spin_unlock_irqrestore(&amp;efivars-&gt;lock, flags);<br />
 <br />
 	if (status != EFI_SUCCESS) {<br />
-		printk(KERN_WARNING &quot;efivars: get_variable() failed 0x%lx!\n&quot;,<br />
-			status);<br />
+		efi_pr_warn(status, &quot;efivars: get_variable() failed&quot;);<br />
 	}<br />
 	return status;<br />
 }<br />
@@ -549,8 +548,7 @@ efivar_store_raw(struct efivar_entry *entry, const char *buf, size_t count)<br />
 	spin_unlock_irq(&amp;efivars-&gt;lock);<br />
 <br />
 	if (status != EFI_SUCCESS) {<br />
-		printk(KERN_WARNING &quot;efivars: set_variable() failed: status=%lx\n&quot;,<br />
-			status);<br />
+		efi_pr_warn(status, &quot;efivars: set_variable() failed&quot;);<br />
 		return -EIO;<br />
 	}<br />
 <br />
@@ -802,8 +800,8 @@ static ssize_t efivarfs_file_write(struct file *file,<br />
 <br />
 	} else {<br />
 		spin_unlock_irq(&amp;efivars-&gt;lock);<br />
-		pr_warn(&quot;efivarfs: inconsistent EFI variable implementation? &quot;<br />
-				&quot;status = %lx\n&quot;, status);<br />
+		efi_pr_warn(status,<br />
+			&quot;efivarfs: inconsistent EFI variable implementation? &quot;);<br />
 	}<br />
 <br />
 out:<br />
@@ -1549,8 +1547,7 @@ static ssize_t efivar_create(struct file *filp, struct kobject *kobj,<br />
 					    new_var-&gt;Data);<br />
 <br />
 	if (status != EFI_SUCCESS) {<br />
-		printk(KERN_WARNING &quot;efivars: set_variable() failed: status=%lx\n&quot;,<br />
-			status);<br />
+		efi_pr_warn(status, &quot;efivars: set_variable() failed&quot;);<br />
 		spin_unlock_irq(&amp;efivars-&gt;lock);<br />
 		return -EIO;<br />
 	}<br />
@@ -1614,8 +1611,7 @@ static ssize_t efivar_delete(struct file *filp, struct kobject *kobj,<br />
 					    del_var-&gt;Data);<br />
 <br />
 	if (status != EFI_SUCCESS) {<br />
-		printk(KERN_WARNING &quot;efivars: set_variable() failed: status=%lx\n&quot;,<br />
-			status);<br />
+		efi_pr_warn(status, &quot;efivars: set_variable() failed&quot;);<br />
 		spin_unlock_irq(&amp;efivars-&gt;lock);<br />
 		return -EIO;<br />
 	}<br />
@@ -2023,8 +2019,7 @@ int register_efivars(struct efivars *efivars,<br />
 		case EFI_NOT_FOUND:<br />
 			break;<br />
 		default:<br />
-			printk(KERN_WARNING &quot;efivars: get_next_variable: status=%lx\n&quot;,<br />
-				status);<br />
+			efi_pr_warn(status, &quot;efivars: get_next_variable&quot;);<br />
 			status = EFI_NOT_FOUND;<br />
 			break;<br />
 		}<br />
diff --git a/include/linux/efi.h b/include/linux/efi.h<br />
index 3d7df3d..9f3ed60 100644<br />
--- a/include/linux/efi.h<br />
+++ b/include/linux/efi.h<br />
@@ -23,18 +23,71 @@<br />
 <br />
 #include &lt;asm/page.h&gt;<br />
 <br />
+#define EFI_ERROR(x)		((x) | (1UL &lt;&lt; (BITS_PER_LONG-1)))<br />
+#define EFI_REVERSE_ERROR(x)	((x) &amp; ~(1UL &lt;&lt; (BITS_PER_LONG-1)))<br />
+<br />
 #define EFI_SUCCESS		0<br />
-#define EFI_LOAD_ERROR          ( 1 | (1UL &lt;&lt; (BITS_PER_LONG-1)))<br />
-#define EFI_INVALID_PARAMETER	( 2 | (1UL &lt;&lt; (BITS_PER_LONG-1)))<br />
-#define EFI_UNSUPPORTED		( 3 | (1UL &lt;&lt; (BITS_PER_LONG-1)))<br />
-#define EFI_BAD_BUFFER_SIZE     ( 4 | (1UL &lt;&lt; (BITS_PER_LONG-1)))<br />
-#define EFI_BUFFER_TOO_SMALL	( 5 | (1UL &lt;&lt; (BITS_PER_LONG-1)))<br />
-#define EFI_NOT_READY		( 6 | (1UL &lt;&lt; (BITS_PER_LONG-1)))<br />
-#define EFI_DEVICE_ERROR	( 7 | (1UL &lt;&lt; (BITS_PER_LONG-1)))<br />
-#define EFI_WRITE_PROTECTED	( 8 | (1UL &lt;&lt; (BITS_PER_LONG-1)))<br />
-#define EFI_OUT_OF_RESOURCES	( 9 | (1UL &lt;&lt; (BITS_PER_LONG-1)))<br />
-#define EFI_NOT_FOUND		(14 | (1UL &lt;&lt; (BITS_PER_LONG-1)))<br />
-#define EFI_SECURITY_VIOLATION	(26 | (1UL &lt;&lt; (BITS_PER_LONG-1)))<br />
+#define EFI_LOAD_ERROR		EFI_ERROR(1)<br />
+#define EFI_INVALID_PARAMETER	EFI_ERROR(2)<br />
+#define EFI_UNSUPPORTED		EFI_ERROR(3)<br />
+#define EFI_BAD_BUFFER_SIZE	EFI_ERROR(4)<br />
+#define EFI_BUFFER_TOO_SMALL	EFI_ERROR(5)<br />
+#define EFI_NOT_READY		EFI_ERROR(6)<br />
+#define EFI_DEVICE_ERROR	EFI_ERROR(7)<br />
+#define EFI_WRITE_PROTECTED	EFI_ERROR(8)<br />
+#define EFI_OUT_OF_RESOURCES	EFI_ERROR(9)<br />
+#define EFI_NOT_FOUND		EFI_ERROR(14)<br />
+#define EFI_SECURITY_VIOLATION	EFI_ERROR(26)<br />
+#define EFI_COMPROMISED_DATA	EFI_ERROR(33)<br />
+<br />
+#define EFI_MAX_ERROR	EFI_COMPROMISED_DATA<br />
+<br />
+static char const *efi_error_strings[] = {<br />
+	&quot;Success&quot;,<br />
+	&quot;Load Error&quot;,<br />
+	&quot;Invalid Parameter&quot;,<br />
+	&quot;Unsupported&quot;,<br />
+	&quot;Bad Buffer Size&quot;,<br />
+	&quot;Buffer Too Small&quot;,<br />
+	&quot;Not Ready&quot;,<br />
+	&quot;Device Error&quot;,<br />
+	&quot;Write Protected&quot;,<br />
+	&quot;Out Of Resources&quot;,<br />
+	&quot;Volume Corrupted&quot;,<br />
+	&quot;Volume Full&quot;,<br />
+	&quot;No Media&quot;,<br />
+	&quot;Media Changed&quot;,<br />
+	&quot;Not Found&quot;,<br />
+	&quot;Access Denied&quot;,<br />
+	&quot;No Response&quot;,<br />
+	&quot;No Mapping&quot;,<br />
+	&quot;Timeout&quot;,<br />
+	&quot;Not Started&quot;,<br />
+	&quot;Already Started&quot;,<br />
+	&quot;Aborted&quot;,<br />
+	&quot;ICMP Error&quot;,<br />
+	&quot;TFTP Error&quot;,<br />
+	&quot;Protocol Error&quot;,<br />
+	&quot;Incompatible Version&quot;,<br />
+	&quot;Security Violation&quot;,<br />
+	&quot;CRC Error&quot;,<br />
+	&quot;End of Media&quot;,<br />
+	&quot;29&quot;,<br />
+	&quot;30&quot;,<br />
+	&quot;End of File&quot;,<br />
+	&quot;Invalid Language&quot;,<br />
+	&quot;Compromised Data&quot;<br />
+};<br />
+<br />
+#define efi_pr_warn(status, fmt, ...) ({				\<br />
+		typeof(status) __status = EFI_REVERSE_ERROR(status);	\<br />
+		if (__status &gt;= 0 &amp;&amp;					\<br />
+				__status &lt;= EFI_REVERSE_ERROR(EFI_MAX_ERROR))\<br />
+			pr_warn(fmt &quot;: %s (0x%lx)\n&quot;, ## __VA_ARGS__,	\<br />
+				efi_error_strings[__status], __status);	\<br />
+		else							\<br />
+			pr_warn(fmt &quot;: 0x%lx\n&quot;, ## __VA_ARGS__, __status);\<br />
+	})<br />
 <br />
 typedef unsigned long efi_status_t;<br />
 typedef u8 efi_bool_t;<br />
-- <br />
1.8.2.1<br />
<br />
--<br />
To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br />
the body of a message to <a href="mailto:&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;">&#109;&#97;&#106;&#111;&#114;&#100;&#111;&#109;&#111;&#64;&#118;&#103;&#101;&#114;&#46;&#107;&#101;&#114;&#110;&#101;&#108;&#46;&#111;&#114;&#103;</a><br />
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank"  rel="nofollow">http://vger.kernel.org/majordomo-info.html</a><br />
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank"  rel="nofollow">http://www.tux.org/lkml/</a>]]></description>
            <dc:creator>Peter Jones</dc:creator>
            <category>Linux Kernel</category>
            <pubDate>Thu, 23 May 2013 21:10:02 +0200</pubDate>
        </item>
    </channel>
</rss>
