* [PATCH 1/2] dmatest: implement two helpers to unmap dma memory
@ 2012-12-10 11:37 Andy Shevchenko
2012-12-10 11:37 ` [PATCH 2/2] dmatest: check for dma mapping error Andy Shevchenko
2012-12-10 14:38 ` [PATCH 1/2] dmatest: implement two helpers to unmap dma memory Viresh Kumar
0 siblings, 2 replies; 8+ messages in thread
From: Andy Shevchenko @ 2012-12-10 11:37 UTC (permalink / raw)
To: linux-kernel, Viresh Kumar, Vinod Koul; +Cc: Andy Shevchenko
The unmap_src() and unmap_dst() will be used later as well.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/dma/dmatest.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 3e777d2..b515343 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -236,6 +236,20 @@ static unsigned int min_odd(unsigned int x, unsigned int y)
return val % 2 ? val : val - 1;
}
+static inline void unmap_src(struct device *dev, dma_addr_t *addr, size_t len,
+ unsigned int count)
+{
+ while (count--)
+ dma_unmap_single(dev, addr[count], len, DMA_TO_DEVICE);
+}
+
+static inline void unmap_dst(struct device *dev, dma_addr_t *addr, size_t len,
+ unsigned int count)
+{
+ while (count--)
+ dma_unmap_single(dev, addr[count], len, DMA_BIDIRECTIONAL);
+}
+
/*
* This function repeatedly tests DMA transfers of various lengths and
* offsets for a given operation type until it is told to exit by
@@ -394,13 +408,8 @@ static int dmatest_func(void *data)
}
if (!tx) {
- for (i = 0; i < src_cnt; i++)
- dma_unmap_single(dev->dev, dma_srcs[i], len,
- DMA_TO_DEVICE);
- for (i = 0; i < dst_cnt; i++)
- dma_unmap_single(dev->dev, dma_dsts[i],
- test_buf_size,
- DMA_BIDIRECTIONAL);
+ unmap_src(dev->dev, dma_srcs, len, src_cnt);
+ unmap_dst(dev->dev, dma_dsts, test_buf_size, dst_cnt);
pr_warning("%s: #%u: prep error with src_off=0x%x "
"dst_off=0x%x len=0x%x\n",
thread_name, total_tests - 1,
@@ -454,9 +463,7 @@ static int dmatest_func(void *data)
}
/* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */
- for (i = 0; i < dst_cnt; i++)
- dma_unmap_single(dev->dev, dma_dsts[i], test_buf_size,
- DMA_BIDIRECTIONAL);
+ unmap_dst(dev->dev, dma_dsts, test_buf_size, dst_cnt);
error_count = 0;
--
1.7.10.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] dmatest: check for dma mapping error
2012-12-10 11:37 [PATCH 1/2] dmatest: implement two helpers to unmap dma memory Andy Shevchenko
@ 2012-12-10 11:37 ` Andy Shevchenko
2012-12-10 14:46 ` Viresh Kumar
2012-12-13 23:34 ` Andrew Morton
2012-12-10 14:38 ` [PATCH 1/2] dmatest: implement two helpers to unmap dma memory Viresh Kumar
1 sibling, 2 replies; 8+ messages in thread
From: Andy Shevchenko @ 2012-12-10 11:37 UTC (permalink / raw)
To: linux-kernel, Viresh Kumar, Vinod Koul; +Cc: Andy Shevchenko
We get a warning if CONFIG_DMA_API_DEBUG=y
[ 28.150631] WARNING: at lib/dma-debug.c:933 check_unmap+0x5d6/0x6ac()
[ 28.157058] dw_dmac dw_dmac.0: DMA-API: device driver failed to check map error[device address=0x0000000035698305] [size=14365 bytes] [mapped as single]
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/dma/dmatest.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index b515343..7be60f1 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -378,15 +378,35 @@ static int dmatest_func(void *data)
dma_srcs[i] = dma_map_single(dev->dev, buf, len,
DMA_TO_DEVICE);
+ ret = dma_mapping_error(dev->dev, dma_srcs[i]);
+ if (ret) {
+ unmap_src(dev->dev, dma_srcs, len, i);
+ pr_warn("%s: #%u: mapping error %d with "
+ "src_off=0x%x len=0x%x\n",
+ thread_name, total_tests - 1, ret,
+ src_off, len);
+ failed_tests++;
+ continue;
+ }
}
/* map with DMA_BIDIRECTIONAL to force writeback/invalidate */
for (i = 0; i < dst_cnt; i++) {
dma_dsts[i] = dma_map_single(dev->dev, thread->dsts[i],
test_buf_size,
DMA_BIDIRECTIONAL);
+ ret = dma_mapping_error(dev->dev, dma_dsts[i]);
+ if (ret) {
+ unmap_src(dev->dev, dma_srcs, len, src_cnt);
+ unmap_dst(dev->dev, dma_dsts, test_buf_size, i);
+ pr_warn("%s: #%u: mapping error %d with "
+ "dst_off=0x%x len=0x%x\n",
+ thread_name, total_tests - 1, ret,
+ dst_off, test_buf_size);
+ failed_tests++;
+ continue;
+ }
}
-
if (thread->type == DMA_MEMCPY)
tx = dev->device_prep_dma_memcpy(chan,
dma_dsts[0] + dst_off,
--
1.7.10.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] dmatest: implement two helpers to unmap dma memory
2012-12-10 11:37 [PATCH 1/2] dmatest: implement two helpers to unmap dma memory Andy Shevchenko
2012-12-10 11:37 ` [PATCH 2/2] dmatest: check for dma mapping error Andy Shevchenko
@ 2012-12-10 14:38 ` Viresh Kumar
1 sibling, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2012-12-10 14:38 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-kernel, Vinod Koul
On 10 December 2012 17:07, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> The unmap_src() and unmap_dst() will be used later as well.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/dma/dmatest.c | 27 +++++++++++++++++----------
> 1 file changed, 17 insertions(+), 10 deletions(-)
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] dmatest: check for dma mapping error
2012-12-10 11:37 ` [PATCH 2/2] dmatest: check for dma mapping error Andy Shevchenko
@ 2012-12-10 14:46 ` Viresh Kumar
2012-12-13 23:34 ` Andrew Morton
1 sibling, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2012-12-10 14:46 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-kernel, Vinod Koul
On 10 December 2012 17:07, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> We get a warning if CONFIG_DMA_API_DEBUG=y
>
> [ 28.150631] WARNING: at lib/dma-debug.c:933 check_unmap+0x5d6/0x6ac()
> [ 28.157058] dw_dmac dw_dmac.0: DMA-API: device driver failed to check map error[device address=0x0000000035698305] [size=14365 bytes] [mapped as single]
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] dmatest: check for dma mapping error
2012-12-10 11:37 ` [PATCH 2/2] dmatest: check for dma mapping error Andy Shevchenko
2012-12-10 14:46 ` Viresh Kumar
@ 2012-12-13 23:34 ` Andrew Morton
2012-12-14 7:06 ` Andy Shevchenko
1 sibling, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2012-12-13 23:34 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-kernel, Viresh Kumar, Vinod Koul
On Mon, 10 Dec 2012 13:37:44 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> We get a warning if CONFIG_DMA_API_DEBUG=y
>
> [ 28.150631] WARNING: at lib/dma-debug.c:933 check_unmap+0x5d6/0x6ac()
> [ 28.157058] dw_dmac dw_dmac.0: DMA-API: device driver failed to check map error[device address=0x0000000035698305] [size=14365 bytes] [mapped as single]
>
> ...
>
> --- a/drivers/dma/dmatest.c
> +++ b/drivers/dma/dmatest.c
> @@ -378,15 +378,35 @@ static int dmatest_func(void *data)
>
> dma_srcs[i] = dma_map_single(dev->dev, buf, len,
> DMA_TO_DEVICE);
> + ret = dma_mapping_error(dev->dev, dma_srcs[i]);
> + if (ret) {
> + unmap_src(dev->dev, dma_srcs, len, i);
> + pr_warn("%s: #%u: mapping error %d with "
> + "src_off=0x%x len=0x%x\n",
> + thread_name, total_tests - 1, ret,
> + src_off, len);
> + failed_tests++;
> + continue;
> + }
The changelog and the code don't match. Which one is out of date?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] dmatest: check for dma mapping error
2012-12-13 23:34 ` Andrew Morton
@ 2012-12-14 7:06 ` Andy Shevchenko
2012-12-14 8:33 ` Andrew Morton
0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2012-12-14 7:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: Andy Shevchenko, linux-kernel, Viresh Kumar, Vinod Koul
On Fri, Dec 14, 2012 at 1:34 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Mon, 10 Dec 2012 13:37:44 +0200
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
>> We get a warning if CONFIG_DMA_API_DEBUG=y
>>
>> [ 28.150631] WARNING: at lib/dma-debug.c:933 check_unmap+0x5d6/0x6ac()
>> [ 28.157058] dw_dmac dw_dmac.0: DMA-API: device driver failed to check map error[device address=0x0000000035698305] [size=14365 bytes] [mapped as single]
>> --- a/drivers/dma/dmatest.c
>> +++ b/drivers/dma/dmatest.c
>> @@ -378,15 +378,35 @@ static int dmatest_func(void *data)
>>
>> dma_srcs[i] = dma_map_single(dev->dev, buf, len,
>> DMA_TO_DEVICE);
>> + ret = dma_mapping_error(dev->dev, dma_srcs[i]);
>> + if (ret) {
>> + unmap_src(dev->dev, dma_srcs, len, i);
>> + pr_warn("%s: #%u: mapping error %d with "
>> + "src_off=0x%x len=0x%x\n",
>> + thread_name, total_tests - 1, ret,
>> + src_off, len);
>> + failed_tests++;
>> + continue;
>> + }
>
> The changelog and the code don't match. Which one is out of date?
I'm afraid I didn't get what is wrong.
dmatest maps memory via dma_map_single() call. And it asks dmaengine
(at the end the DMA controller driver) to unmap them after usage.
Exactly at that time user gets a warning. And this warning is
independent of DMA controller in use.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] dmatest: check for dma mapping error
2012-12-14 7:06 ` Andy Shevchenko
@ 2012-12-14 8:33 ` Andrew Morton
2012-12-14 9:19 ` Andy Shevchenko
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2012-12-14 8:33 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Andy Shevchenko, linux-kernel, Viresh Kumar, Vinod Koul
On Fri, 14 Dec 2012 09:06:03 +0200 Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Fri, Dec 14, 2012 at 1:34 AM, Andrew Morton
> <akpm@linux-foundation.org> wrote:
> > On Mon, 10 Dec 2012 13:37:44 +0200
> > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> >
> >> We get a warning if CONFIG_DMA_API_DEBUG=y
> >>
> >> [ 28.150631] WARNING: at lib/dma-debug.c:933 check_unmap+0x5d6/0x6ac()
> >> [ 28.157058] dw_dmac dw_dmac.0: DMA-API: device driver failed to check map error[device address=0x0000000035698305] [size=14365 bytes] [mapped as single]
>
> >> --- a/drivers/dma/dmatest.c
> >> +++ b/drivers/dma/dmatest.c
> >> @@ -378,15 +378,35 @@ static int dmatest_func(void *data)
> >>
> >> dma_srcs[i] = dma_map_single(dev->dev, buf, len,
> >> DMA_TO_DEVICE);
> >> + ret = dma_mapping_error(dev->dev, dma_srcs[i]);
> >> + if (ret) {
> >> + unmap_src(dev->dev, dma_srcs, len, i);
> >> + pr_warn("%s: #%u: mapping error %d with "
> >> + "src_off=0x%x len=0x%x\n",
> >> + thread_name, total_tests - 1, ret,
> >> + src_off, len);
> >> + failed_tests++;
> >> + continue;
> >> + }
> >
> > The changelog and the code don't match. Which one is out of date?
>
> I'm afraid I didn't get what is wrong.
>
The above code will not emit the string "dw_dmac dw_dmac.0: DMA-API:
device driver failed to check map error[device
address=0x0000000035698305] [size=14365 bytes] [mapped as single]".
Oh I see what you did. That string is emitted by the kernel at
present, and the patch prevents this. And it also emits a new warning
if the mapping attempt failed, and that new warning wasn't described.
I updated the changelog:
: The kernel emits a warning if CONFIG_DMA_API_DEBUG=y:
:
: [ 28.150631] WARNING: at lib/dma-debug.c:933 check_unmap+0x5d6/0x6ac()
: [ 28.157058] dw_dmac dw_dmac.0: DMA-API: device driver failed to check map error[device address=0x0000000035698305] [size=14365 bytes] [mapped as single]
:
: Fix this by adding the required checking of the dma_map_single() return
: value.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] dmatest: check for dma mapping error
2012-12-14 8:33 ` Andrew Morton
@ 2012-12-14 9:19 ` Andy Shevchenko
0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2012-12-14 9:19 UTC (permalink / raw)
To: Andrew Morton; +Cc: Andy Shevchenko, linux-kernel, Viresh Kumar, Vinod Koul
On Fri, 2012-12-14 at 00:33 -0800, Andrew Morton wrote:
> On Fri, 14 Dec 2012 09:06:03 +0200 Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>
> > On Fri, Dec 14, 2012 at 1:34 AM, Andrew Morton
> > <akpm@linux-foundation.org> wrote:
> > > On Mon, 10 Dec 2012 13:37:44 +0200
> > > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > >> We get a warning if CONFIG_DMA_API_DEBUG=y
> > >>
> > >> [ 28.150631] WARNING: at lib/dma-debug.c:933 check_unmap+0x5d6/0x6ac()
> > >> [ 28.157058] dw_dmac dw_dmac.0: DMA-API: device driver failed to check map error[device address=0x0000000035698305] [size=14365 bytes] [mapped as single]
> >
> > >> --- a/drivers/dma/dmatest.c
> > >> +++ b/drivers/dma/dmatest.c
> > >> @@ -378,15 +378,35 @@ static int dmatest_func(void *data)
> > >>
> > >> dma_srcs[i] = dma_map_single(dev->dev, buf, len,
> > >> DMA_TO_DEVICE);
> > >> + ret = dma_mapping_error(dev->dev, dma_srcs[i]);
> > >> + if (ret) {
> > >> + unmap_src(dev->dev, dma_srcs, len, i);
> > >> + pr_warn("%s: #%u: mapping error %d with "
> > >> + "src_off=0x%x len=0x%x\n",
> > >> + thread_name, total_tests - 1, ret,
> > >> + src_off, len);
> > >> + failed_tests++;
> > >> + continue;
> > >> + }
> > >
> > > The changelog and the code don't match. Which one is out of date?
> >
> > I'm afraid I didn't get what is wrong.
> >
>
> The above code will not emit the string "dw_dmac dw_dmac.0: DMA-API:
> device driver failed to check map error[device
> address=0x0000000035698305] [size=14365 bytes] [mapped as single]".
>
> Oh I see what you did. That string is emitted by the kernel at
> present, and the patch prevents this. And it also emits a new warning
> if the mapping attempt failed, and that new warning wasn't described.
Ah, okay, thank you.
> I updated the changelog:
Yes, you right, the changelog in my case describes only part of the
problem.
> : The kernel emits a warning if CONFIG_DMA_API_DEBUG=y:
> :
> : [ 28.150631] WARNING: at lib/dma-debug.c:933 check_unmap+0x5d6/0x6ac()
> : [ 28.157058] dw_dmac dw_dmac.0: DMA-API: device driver failed to check map error[device address=0x0000000035698305] [size=14365 bytes] [mapped as single]
> :
> : Fix this by adding the required checking of the dma_map_single() return
> : value.
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-12-14 9:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-10 11:37 [PATCH 1/2] dmatest: implement two helpers to unmap dma memory Andy Shevchenko
2012-12-10 11:37 ` [PATCH 2/2] dmatest: check for dma mapping error Andy Shevchenko
2012-12-10 14:46 ` Viresh Kumar
2012-12-13 23:34 ` Andrew Morton
2012-12-14 7:06 ` Andy Shevchenko
2012-12-14 8:33 ` Andrew Morton
2012-12-14 9:19 ` Andy Shevchenko
2012-12-10 14:38 ` [PATCH 1/2] dmatest: implement two helpers to unmap dma memory Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome