* [PATCH] firewire: fw-ohci: use dma_alloc_coherent for ar_buffer
@ 2008-03-12 21:43 Jarod Wilson
2008-03-12 23:30 ` Stefan Richter
0 siblings, 1 reply; 5+ messages in thread
From: Jarod Wilson @ 2008-03-12 21:43 UTC (permalink / raw)
To: linux1394-devel; +Cc: linux-kernel
Currently, we do nothing to guarantee we have a consistent DMA buffer for
asynchronous receive packets. Rather than doing several sync's following a
dma_map_single() to get consistent buffers, just switch to using
dma_alloc_coherent().
Resolves constant buffer failures on my own x86_64 laptop w/4GB of RAM and
likely to fix a number of other failures witnessed on x86_64 systems with
4GB of RAM or more.
Signed-off-by: Jarod Wilson <jwilson@redhat.com>
---
drivers/firewire/fw-ohci.c | 18 +++++-------------
1 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index 28ea78c..081a434 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -284,16 +284,10 @@ static int ar_context_add_page(struct ar_context *ctx)
dma_addr_t ab_bus;
size_t offset;
- ab = (struct ar_buffer *) __get_free_page(GFP_ATOMIC);
+ ab = dma_alloc_coherent(dev, PAGE_SIZE, &ab_bus, GFP_ATOMIC);
if (ab == NULL)
return -ENOMEM;
- ab_bus = dma_map_single(dev, ab, PAGE_SIZE, DMA_BIDIRECTIONAL);
- if (dma_mapping_error(ab_bus)) {
- free_page((unsigned long) ab);
- return -ENOMEM;
- }
-
memset(&ab->descriptor, 0, sizeof(ab->descriptor));
ab->descriptor.control = cpu_to_le16(DESCRIPTOR_INPUT_MORE |
DESCRIPTOR_STATUS |
@@ -304,8 +298,6 @@ static int ar_context_add_page(struct ar_context *ctx)
ab->descriptor.res_count = cpu_to_le16(PAGE_SIZE - offset);
ab->descriptor.branch_address = 0;
- dma_sync_single_for_device(dev, ab_bus, PAGE_SIZE, DMA_BIDIRECTIONAL);
-
ctx->last_buffer->descriptor.branch_address = cpu_to_le32(ab_bus | 1);
ctx->last_buffer->next = ab;
ctx->last_buffer = ab;
@@ -409,6 +401,7 @@ static void ar_context_tasklet(unsigned long data)
if (d->res_count == 0) {
size_t size, rest, offset;
+ dma_addr_t buffer_bus;
/*
* This descriptor is finished and we may have a
@@ -417,9 +410,7 @@ static void ar_context_tasklet(unsigned long data)
*/
offset = offsetof(struct ar_buffer, data);
- dma_unmap_single(ohci->card.device,
- le32_to_cpu(ab->descriptor.data_address) - offset,
- PAGE_SIZE, DMA_BIDIRECTIONAL);
+ buffer_bus = le32_to_cpu(ab->descriptor.data_address) - offset;
buffer = ab;
ab = ab->next;
@@ -435,7 +426,8 @@ static void ar_context_tasklet(unsigned long data)
while (buffer < end)
buffer = handle_ar_packet(ctx, buffer);
- free_page((unsigned long)buffer);
+ dma_free_coherent(ohci->card.device, PAGE_SIZE,
+ buffer, buffer_bus);
ar_context_add_page(ctx);
} else {
buffer = ctx->pointer;
--
Jarod Wilson
jwilson@redhat.com
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] firewire: fw-ohci: use dma_alloc_coherent for ar_buffer
2008-03-12 21:43 [PATCH] firewire: fw-ohci: use dma_alloc_coherent for ar_buffer Jarod Wilson
@ 2008-03-12 23:30 ` Stefan Richter
2008-03-13 23:27 ` [PATCH update] firewire: fw-ohci: shut up false compiler warning on PPC32 Stefan Richter
2008-03-14 1:22 ` [PATCH] firewire: fw-ohci: use dma_alloc_coherent for ar_buffer Stefan Richter
0 siblings, 2 replies; 5+ messages in thread
From: Stefan Richter @ 2008-03-12 23:30 UTC (permalink / raw)
To: Jarod Wilson; +Cc: linux1394-devel, linux-kernel, Kristian Høgsberg
Jarod Wilson wrote:
> Currently, we do nothing to guarantee we have a consistent DMA buffer for
> asynchronous receive packets. Rather than doing several sync's following a
> dma_map_single() to get consistent buffers, just switch to using
> dma_alloc_coherent().
>
> Resolves constant buffer failures on my own x86_64 laptop w/4GB of RAM and
> likely to fix a number of other failures witnessed on x86_64 systems with
> 4GB of RAM or more.
>
> Signed-off-by: Jarod Wilson <jwilson@redhat.com>
Looks good at first glance. Alas my PCs aren't affected, so I can only
test it for lack of regressions.
I'm tempted to push this to Linus later this week. Unless e.g. Kristian
has reservations.
>
> ---
>
> drivers/firewire/fw-ohci.c | 18 +++++-------------
> 1 files changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
> index 28ea78c..081a434 100644
> --- a/drivers/firewire/fw-ohci.c
> +++ b/drivers/firewire/fw-ohci.c
> @@ -284,16 +284,10 @@ static int ar_context_add_page(struct ar_context *ctx)
> dma_addr_t ab_bus;
> size_t offset;
>
> - ab = (struct ar_buffer *) __get_free_page(GFP_ATOMIC);
> + ab = dma_alloc_coherent(dev, PAGE_SIZE, &ab_bus, GFP_ATOMIC);
> if (ab == NULL)
> return -ENOMEM;
>
> - ab_bus = dma_map_single(dev, ab, PAGE_SIZE, DMA_BIDIRECTIONAL);
> - if (dma_mapping_error(ab_bus)) {
> - free_page((unsigned long) ab);
> - return -ENOMEM;
> - }
> -
> memset(&ab->descriptor, 0, sizeof(ab->descriptor));
> ab->descriptor.control = cpu_to_le16(DESCRIPTOR_INPUT_MORE |
> DESCRIPTOR_STATUS |
> @@ -304,8 +298,6 @@ static int ar_context_add_page(struct ar_context *ctx)
> ab->descriptor.res_count = cpu_to_le16(PAGE_SIZE - offset);
> ab->descriptor.branch_address = 0;
>
> - dma_sync_single_for_device(dev, ab_bus, PAGE_SIZE, DMA_BIDIRECTIONAL);
> -
> ctx->last_buffer->descriptor.branch_address = cpu_to_le32(ab_bus | 1);
> ctx->last_buffer->next = ab;
> ctx->last_buffer = ab;
> @@ -409,6 +401,7 @@ static void ar_context_tasklet(unsigned long data)
>
> if (d->res_count == 0) {
> size_t size, rest, offset;
> + dma_addr_t buffer_bus;
>
> /*
> * This descriptor is finished and we may have a
> @@ -417,9 +410,7 @@ static void ar_context_tasklet(unsigned long data)
> */
>
> offset = offsetof(struct ar_buffer, data);
> - dma_unmap_single(ohci->card.device,
> - le32_to_cpu(ab->descriptor.data_address) - offset,
> - PAGE_SIZE, DMA_BIDIRECTIONAL);
> + buffer_bus = le32_to_cpu(ab->descriptor.data_address) - offset;
>
> buffer = ab;
> ab = ab->next;
> @@ -435,7 +426,8 @@ static void ar_context_tasklet(unsigned long data)
> while (buffer < end)
> buffer = handle_ar_packet(ctx, buffer);
>
> - free_page((unsigned long)buffer);
> + dma_free_coherent(ohci->card.device, PAGE_SIZE,
> + buffer, buffer_bus);
> ar_context_add_page(ctx);
> } else {
> buffer = ctx->pointer;
>
--
Stefan Richter
-=====-==--- --== -==-=
http://arcgraph.de/sr/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH update] firewire: fw-ohci: shut up false compiler warning on PPC32
2008-03-12 23:30 ` Stefan Richter
@ 2008-03-13 23:27 ` Stefan Richter
2008-03-15 1:55 ` Jarod Wilson
2008-03-14 1:22 ` [PATCH] firewire: fw-ohci: use dma_alloc_coherent for ar_buffer Stefan Richter
1 sibling, 1 reply; 5+ messages in thread
From: Stefan Richter @ 2008-03-13 23:27 UTC (permalink / raw)
To: linux1394-devel; +Cc: linux-kernel, Jarod Wilson
Shut up "may be used uninitialised in this function" warnings due to
PPC32's implementation of dma_alloc_coherent().
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
updated to be enqueued after patch
"firewire: fw-ohci: use dma_alloc_coherent for ar_buffer"
drivers/firewire/fw-ohci.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: linux/drivers/firewire/fw-ohci.c
===================================================================
--- linux.orig/drivers/firewire/fw-ohci.c
+++ linux/drivers/firewire/fw-ohci.c
@@ -281,7 +281,7 @@ static int ar_context_add_page(struct ar
{
struct device *dev = ctx->ohci->card.device;
struct ar_buffer *ab;
- dma_addr_t ab_bus;
+ dma_addr_t uninitialized_var(ab_bus);
size_t offset;
ab = dma_alloc_coherent(dev, PAGE_SIZE, &ab_bus, GFP_ATOMIC);
@@ -536,7 +536,7 @@ static int
context_add_buffer(struct context *ctx)
{
struct descriptor_buffer *desc;
- dma_addr_t bus_addr;
+ dma_addr_t uninitialized_var(bus_addr);
int offset;
/*
@@ -1321,7 +1321,7 @@ ohci_set_config_rom(struct fw_card *card
unsigned long flags;
int retval = -EBUSY;
__be32 *next_config_rom;
- dma_addr_t next_config_rom_bus;
+ dma_addr_t uninitialized_var(next_config_rom_bus);
ohci = fw_ohci(card);
--
Stefan Richter
-=====-==--- --== -===-
http://arcgraph.de/sr/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] firewire: fw-ohci: use dma_alloc_coherent for ar_buffer
2008-03-12 23:30 ` Stefan Richter
2008-03-13 23:27 ` [PATCH update] firewire: fw-ohci: shut up false compiler warning on PPC32 Stefan Richter
@ 2008-03-14 1:22 ` Stefan Richter
1 sibling, 0 replies; 5+ messages in thread
From: Stefan Richter @ 2008-03-14 1:22 UTC (permalink / raw)
To: Jarod Wilson; +Cc: linux1394-devel, linux-kernel, Kristian Høgsberg
I wrote:
> Jarod Wilson wrote:
>> Resolves constant buffer failures on my own x86_64 laptop w/4GB of RAM and
>> likely to fix a number of other failures witnessed on x86_64 systems with
>> 4GB of RAM or more.
>>
>> Signed-off-by: Jarod Wilson <jwilson@redhat.com>
>
> Looks good at first glance. Alas my PCs aren't affected, so I can only
> test it for lack of regressions.
>
> I'm tempted to push this to Linus later this week.
I tested it on a 2GB EM64T machine, on PPC32, and i686. I used the
latter for stress-tests with SBP-2, DV, and IIDC traffic on two buses
with 3 devices each, all active at once.
I had one lock-up during the stress-tests which I suspect is the
handle_at_packet panic, http://bugzilla.kernel.org/show_bug.cgi?id=9617
which is unrelated to this patch.
I committed your patch to linux1394-2.6.git, whose shortlog and diff
from origin..for-linus looks now like this:
Jarod Wilson (2):
firewire: fw-sbp2: set single-phase retry_limit
firewire: fw-ohci: use dma_alloc_coherent for ar_buffer
Stefan Richter (9):
firewire: endianess fix
firewire: endianess annotations
firewire: fw-ohci: PPC PMac platform code
firewire: fw-ohci: Apple UniNorth 1st generation support
firewire: warn on fatal condition in topology code
firewire: update Kconfig help text
firewire: fw-sbp2: fix for SYM13FW500 bridge (Datafab disk)
ieee1394: sbp2: fix for SYM13FW500 bridge (Datafab disk)
firewire: fw-ohci: shut up false compiler warning on PPC32
drivers/firewire/Kconfig | 50 +++++--------
drivers/firewire/fw-ohci.c | 108 +++++++++++++++++++++-------
drivers/firewire/fw-sbp2.c | 36 +++++++++-
drivers/firewire/fw-topology.c | 3 +-
drivers/firewire/fw-transaction.c | 2 +-
drivers/firewire/fw-transaction.h | 6 +-
drivers/ieee1394/sbp2.c | 5 ++
7 files changed, 143 insertions(+), 67 deletions(-)
I'd like to submit this to Linus later today (Friday). It all looks
like a bit too much for such a late -rc phase; but half of fw-ohci's
diffstat is actually just the added PMac code which has already proven
itself in ohci1394.
There are also some small new commits to linux1394-2.6.git master, whose
history is once again somewhat obfuscated by my pulling 'origin' and
'for-linus' into master, so that vice versa master can be cleanly pulled
into descendants of Linus' tree.
http://me.in-berlin.de/~s5r6/linux1394/updates/2.6.25-rc5/patches/series
gives a better picture of what is currently in the pipeline than git log
would give.
--
Stefan Richter
-=====-==--- --== -===-
http://arcgraph.de/sr/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH update] firewire: fw-ohci: shut up false compiler warning on PPC32
2008-03-13 23:27 ` [PATCH update] firewire: fw-ohci: shut up false compiler warning on PPC32 Stefan Richter
@ 2008-03-15 1:55 ` Jarod Wilson
0 siblings, 0 replies; 5+ messages in thread
From: Jarod Wilson @ 2008-03-15 1:55 UTC (permalink / raw)
To: Stefan Richter; +Cc: linux1394-devel, linux-kernel
On Thursday 13 March 2008 07:27:49 pm Stefan Richter wrote:
> Shut up "may be used uninitialised in this function" warnings due to
> PPC32's implementation of dma_alloc_coherent().
>
> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
> ---
>
> updated to be enqueued after patch
> "firewire: fw-ohci: use dma_alloc_coherent for ar_buffer"
Signed-off-by: Jarod Wilson <jwilson@redhat.com>
--
Jarod Wilson
jwilson@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-03-15 2:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-12 21:43 [PATCH] firewire: fw-ohci: use dma_alloc_coherent for ar_buffer Jarod Wilson
2008-03-12 23:30 ` Stefan Richter
2008-03-13 23:27 ` [PATCH update] firewire: fw-ohci: shut up false compiler warning on PPC32 Stefan Richter
2008-03-15 1:55 ` Jarod Wilson
2008-03-14 1:22 ` [PATCH] firewire: fw-ohci: use dma_alloc_coherent for ar_buffer Stefan Richter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox