[PATCH] drivers/net/3c505.c

Paul (set@pobox.com)
Thu, 2 Aug 2001 21:06:18 -0400


Alan Cox <alan@lxorguk.ukuu.org.uk>, on Thu Aug 02, 2001 [03:19:56 PM] said:
> > Well, I have tracked down my problem. We see a comparison
> > like this to determine whether to use a bounce buffer:
> >
> > if ( virt_to_bus(addr+buflen) >= MAX_DMA_ADDRESS) {
> > ...(use a bounce buffer 'cause that addr is not dma-able)...
> >
> > This is not working, because MAX_DMA_ADDRESS is defined
> > so:
> >
> > ./include/asm-i386/dma.h:
> > #define MAX_DMA_ADDRESS (PAGE_OFFSET+0x1000000)
>
> MAX_DMA_ADDRESS is intended for checking virtual addresses not bus
> addresses.
>
> Alan

Dear Alan;

Here are two alternate patches to 3c505.c . They both
enable the card to 'work' on my 486 machine with > 16meg. Is
either a correct fix?

Paul
set@pobox.com

--- 2.4.7/drivers/net/3c505.c Wed Aug 1 23:48:44 2001
+++ 2.4.7.3c505.hack/drivers/net/3c505.c Thu Aug 2 20:35:02 2001
@@ -607,7 +607,7 @@

skb_reserve(skb, 2);
target = skb_put(skb, rlen);
- if (virt_to_bus(target + rlen) >= MAX_DMA_ADDRESS) {
+ if ((unsigned long)(target + rlen) >= MAX_DMA_ADDRESS) {
adapter->current_dma.target = target;
target = adapter->dma_buffer;
} else {
@@ -1027,11 +1027,13 @@
adapter->current_dma.direction = 1;
adapter->current_dma.start_time = jiffies;

- target = virt_to_bus(skb->data);
- if ((target + nlen) >= MAX_DMA_ADDRESS) {
+ if ((unsigned long)(skb->data + nlen) >= MAX_DMA_ADDRESS) {
memcpy(adapter->dma_buffer, skb->data, nlen);
target = virt_to_bus(adapter->dma_buffer);
}
+ else {
+ target = virt_to_bus(skb->data);
+ }
adapter->current_dma.skb = skb;

flags=claim_dma_lock();

-=-=-=-=-=-=-=-=-=- (as seen in some scsi drivers)

--- 2.4.7/drivers/net/3c505.c Wed Aug 1 23:48:44 2001
+++ 2.4.7.3c505.hack/drivers/net/3c505.c Thu Aug 2 20:45:16 2001
@@ -106,6 +106,7 @@
#include <asm/bitops.h>
#include <asm/io.h>
#include <asm/dma.h>
+#include <asm/scatterlist.h>

#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -607,7 +608,7 @@

skb_reserve(skb, 2);
target = skb_put(skb, rlen);
- if (virt_to_bus(target + rlen) >= MAX_DMA_ADDRESS) {
+ if (virt_to_phys(target + rlen -1) > ISA_DMA_THRESHOLD) {
adapter->current_dma.target = target;
target = adapter->dma_buffer;
} else {
@@ -1027,11 +1028,13 @@
adapter->current_dma.direction = 1;
adapter->current_dma.start_time = jiffies;

- target = virt_to_bus(skb->data);
- if ((target + nlen) >= MAX_DMA_ADDRESS) {
+ if (virt_to_phys(skb->data + nlen -1) > ISA_DMA_THRESHOLD) {
memcpy(adapter->dma_buffer, skb->data, nlen);
target = virt_to_bus(adapter->dma_buffer);
}
+ else {
+ target = virt_to_bus(skb->data);
+ }
adapter->current_dma.skb = skb;

flags=claim_dma_lock();
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/