All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.5.5] Conversion of hp100 to new PCI interface
@ 2002-02-27  1:46 Jean Tourrilhes
  2002-02-27  1:53 ` Jean Tourrilhes
  0 siblings, 1 reply; 6+ messages in thread
From: Jean Tourrilhes @ 2002-02-27  1:46 UTC (permalink / raw)
  To: Jaroslav Kysela, Linux kernel mailing list, Jeff Garzik

	Hi,

	I depend on hp100, so I had to fix it and replace all those
virt_to_bus(). Only tested on a J2585B (PCI Busmaster). Other PCI and
ISA cards are *not* busmaster, so should not be affected. Some EISA
cards may be busmaster, but we would need to track down a tester...
	If the official maintainer doesn't have anything to
add, it would be nice if it could find its way in the kernel...
	Have fun...

	Jean

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2.5.5] Conversion of hp100 to new PCI interface
  2002-02-27  1:46 [PATCH 2.5.5] Conversion of hp100 to new PCI interface Jean Tourrilhes
@ 2002-02-27  1:53 ` Jean Tourrilhes
  2002-02-27  2:11   ` Jeff Garzik
  0 siblings, 1 reply; 6+ messages in thread
From: Jean Tourrilhes @ 2002-02-27  1:53 UTC (permalink / raw)
  To: Jaroslav Kysela, Linux kernel mailing list, Jeff Garzik

[-- Attachment #1: Type: text/plain, Size: 599 bytes --]

On Tue, Feb 26, 2002 at 05:46:57PM -0800, jt wrote:
> 	Hi,
> 
> 	I depend on hp100, so I had to fix it and replace all those
> virt_to_bus(). Only tested on a J2585B (PCI Busmaster). Other PCI and
> ISA cards are *not* busmaster, so should not be affected. Some EISA
> cards may be busmaster, but we would need to track down a tester...
> 	If the official maintainer doesn't have anything to
> add, it would be nice if it could find its way in the kernel...
> 	Have fun...
> 
> 	Jean

	As Jeff mention, probably better if I attach a patch !

	Jean

P.S. : Also : I've fixed basic IrDA in my tree...

[-- Attachment #2: hp100.vb.diff --]
[-- Type: text/plain, Size: 7117 bytes --]

diff -u -p linux/drivers/net/hp100_vb.c linux/drivers/net/hp100.c
--- linux/drivers/net/hp100_vb.c	Tue Feb 26 16:24:51 2002
+++ linux/drivers/net/hp100.c	Tue Feb 26 17:27:10 2002
@@ -83,8 +83,6 @@
 **
 */
 
-#error Please convert me to Documentation/DMA-mapping.txt
-
 #define HP100_DEFAULT_PRIORITY_TX 0
 
 #undef HP100_DEBUG
@@ -214,6 +212,7 @@ struct hp100_private {
 
 	u_int *page_vaddr;	/* Virtual address of allocated page */
 	u_int *page_vaddr_algn;	/* Aligned virtual address of allocated page */
+	dma_addr_t page_baddr;	/* Bus/Physical address of allocated page */
 	int rxrcommit;		/* # Rx PDLs commited to adapter */
 	int txrcommit;		/* # Tx PDLs commited to adapter */
 };
@@ -627,9 +626,20 @@ static int __init hp100_probe1(struct ne
 			local_mode = 3;
 		} else if (chip == HP100_CHIPID_LASSEN &&
 			   (lsw & (HP100_BM_WRITE | HP100_BM_READ)) == (HP100_BM_WRITE | HP100_BM_READ)) {
+			/* Conversion to new PCI API :
+			 * I don't have the doc, but I assume that the card
+			 * can map the full 32bit address space.
+			 * Also, we can have EISA Busmaster cards (not tested),
+			 * so beware !!! - Jean II */
+			if((bus == HP100_BUS_PCI) &&
+			   (pci_set_dma_mask(pci_dev, 0xffffffff))) {
+				/* Gracefully fallback to shared memory */
+				goto busmasterfail;
+			}
 			printk("hp100: %s: Busmaster mode enabled.\n", dev->name);
 			hp100_outw(HP100_MEM_EN | HP100_IO_EN | HP100_RESET_LB, OPTION_LSW);
 		} else {
+		busmasterfail:
 #ifdef HP100_DEBUG
 			printk("hp100: %s: Card not configured for BM or BM not supported with this card.\n", dev->name);
 			printk("hp100: %s: Trying shared memory mode.\n", dev->name);
@@ -773,10 +783,12 @@ static int __init hp100_probe1(struct ne
 	 * implemented/tested only with the lassen chip anyway... */
 	if (lp->mode == 1) {	/* busmaster */
 		/* Get physically continous memory for TX & RX PDLs    */
-		if ((lp->page_vaddr = kmalloc(MAX_RINGSIZE + 0x0f, GFP_KERNEL)) == NULL)
+		/* Conversion to new PCI API :
+		 * Pages are always aligned and zeroed, no need to it ourself.
+		 * Doc says should be OK for EISA bus as well - Jean II */
+		if ((lp->page_vaddr = pci_alloc_consistent(lp->pci_dev, MAX_RINGSIZE, &lp->page_baddr)) == NULL)
 			return -ENOMEM;
-		lp->page_vaddr_algn = ((u_int *) (((u_int) (lp->page_vaddr) + 0x0f) & ~0x0f));
-		memset(lp->page_vaddr, 0, MAX_RINGSIZE + 0x0f);
+		lp->page_vaddr_algn = lp->page_vaddr;
 
 #ifdef HP100_DEBUG_BM
 		printk("hp100: %s: Reserved DMA memory from 0x%x to 0x%x\n", dev->name, (u_int) lp->page_vaddr_algn, (u_int) lp->page_vaddr_algn + MAX_RINGSIZE);
@@ -1189,7 +1201,7 @@ static void hp100_init_pdls(struct net_d
 {
 	struct hp100_private *lp = (struct hp100_private *) dev->priv;
 	hp100_ring_t *ringptr;
-	u_int *pageptr;
+	u_int *pageptr;		/* Warning : increment by 4 - Jean II */
 	int i;
 
 #ifdef HP100_DEBUG_B
@@ -1245,8 +1257,12 @@ static int hp100_init_rxpdl(struct net_d
 		printk("hp100: %s: Init rxpdl: Unaligned pdlptr 0x%x.\n",
 		       dev->name, (unsigned) pdlptr);
 
+	/* Conversion to new PCI API :
+	 * The memory block we use, lp->page_vaddr, was DMA allocated via
+	 * pci_alloc_consistent(), so we just need to "retreive" the
+	 * original mapping to bus/phys address - Jean II */
 	ringptr->pdl = pdlptr + 1;
-	ringptr->pdl_paddr = virt_to_bus(pdlptr + 1);
+	ringptr->pdl_paddr = virt_to_phys(pdlptr + 1);
 	ringptr->skb = (void *) NULL;
 
 	/* 
@@ -1257,7 +1273,7 @@ static int hp100_init_rxpdl(struct net_d
 	 */
 	/* Note that pdlptr+1 and not pdlptr is the pointer to the PDH */
 
-	*(pdlptr + 2) = (u_int) virt_to_bus(pdlptr);	/* Address Frag 1 */
+	*(pdlptr + 2) = (u_int) virt_to_phys(pdlptr);	/* Address Frag 1 */
 	*(pdlptr + 3) = 4;	/* Length  Frag 1 */
 
 	return ((((MAX_RX_FRAG * 2 + 2) + 3) / 4) * 4);
@@ -1271,8 +1287,12 @@ static int hp100_init_txpdl(struct net_d
 	if (0 != (((unsigned) pdlptr) & 0xf))
 		printk("hp100: %s: Init txpdl: Unaligned pdlptr 0x%x.\n", dev->name, (unsigned) pdlptr);
 
+	/* Conversion to new PCI API :
+	 * The memory block we use, lp->page_vaddr, was DMA allocated via
+	 * pci_alloc_consistent(), so we just need to "retreive" the
+	 * original mapping to bus/phys address - Jean II */
 	ringptr->pdl = pdlptr;	/* +1; */
-	ringptr->pdl_paddr = virt_to_bus(pdlptr);	/* +1 */
+	ringptr->pdl_paddr = virt_to_phys(pdlptr);	/* +1 */
 	ringptr->skb = (void *) NULL;
 
 	return ((((MAX_TX_FRAG * 2 + 2) + 3) / 4) * 4);
@@ -1331,8 +1351,10 @@ static int hp100_build_rx_pdl(hp100_ring
 				     (unsigned int) ringptr->skb->data);
 #endif
 
+		/* Conversion to new PCI API : map skbuf data to PCI bus.
+		 * Doc says it's OK for EISA as well - Jean II */
 		ringptr->pdl[0] = 0x00020000;	/* Write PDH */
-		ringptr->pdl[3] = ((u_int) virt_to_bus(ringptr->skb->data));
+		ringptr->pdl[3] = ((u_int) pci_map_single(((struct hp100_private *) (dev->priv))->pci_dev, ringptr->skb->data, MAX_ETHER_SIZE, PCI_DMA_FROMDEVICE));
 		ringptr->pdl[4] = MAX_ETHER_SIZE;	/* Length of Data */
 
 #ifdef HP100_DEBUG_BM
@@ -1585,7 +1607,6 @@ static int hp100_start_xmit_bm(struct sk
 
 	ringptr->skb = skb;
 	ringptr->pdl[0] = ((1 << 16) | i);	/* PDH: 1 Fragment & length */
-	ringptr->pdl[1] = (u32) virt_to_bus(skb->data);	/* 1st Frag: Adr. of data */
 	if (lp->chip == HP100_CHIPID_SHASTA) {
 		/* TODO:Could someone who has the EISA card please check if this works? */
 		ringptr->pdl[2] = i;
@@ -1593,6 +1614,9 @@ static int hp100_start_xmit_bm(struct sk
 		/* In the PDL, don't use the padded size but the real packet size: */
 		ringptr->pdl[2] = skb->len;	/* 1st Frag: Length of frag */
 	}
+	/* Conversion to new PCI API : map skbuf data to PCI bus.
+	 * Doc says it's OK for EISA as well - Jean II */
+	ringptr->pdl[1] = ((u32) pci_map_single(lp->pci_dev, skb->data, ringptr->pdl[2], PCI_DMA_TODEVICE));	/* 1st Frag: Adr. of data */
 
 	/* Hand this PDL to the card. */
 	hp100_outl(ringptr->pdl_paddr, TX_PDA_L);	/* Low Prio. Queue */
@@ -1641,6 +1665,8 @@ static void hp100_clean_txring(struct ne
 				dev->name, (u_int) lp->txrhead->skb->data,
 				lp->txrcommit, hp100_inb(TX_PDL), donecount);
 #endif
+		/* Conversion to new PCI API : NOP */
+		pci_unmap_single(lp->pci_dev, (dma_addr_t) lp->txrhead->pdl[1], lp->txrhead->pdl[2], PCI_DMA_TODEVICE);
 		dev_kfree_skb_any(lp->txrhead->skb);
 		lp->txrhead->skb = (void *) NULL;
 		lp->txrhead = lp->txrhead->next;
@@ -1950,6 +1976,9 @@ static void hp100_rx_bm(struct net_devic
 		header = *(ptr->pdl - 1);
 		pkt_len = (header & HP100_PKT_LEN_MASK);
 
+		/* Conversion to new PCI API : NOP */
+		pci_unmap_single(lp->pci_dev, (dma_addr_t) ptr->pdl[3], MAX_ETHER_SIZE, PCI_DMA_FROMDEVICE);
+
 #ifdef HP100_DEBUG_BM
 		printk("hp100: %s: rx_bm: header@0x%x=0x%x length=%d, errors=0x%x, dest=0x%x\n",
 				dev->name, (u_int) (ptr->pdl - 1), (u_int) header,
@@ -2910,7 +2939,7 @@ static void release_dev(int i)
 	release_region(d->base_addr, HP100_REGION_SIZE);
 
 	if (p->mode == 1)	/* busmaster */
-		kfree(p->page_vaddr);
+		pci_free_consistent(p->pci_dev, MAX_RINGSIZE + 0x0f, p->page_vaddr, p->page_baddr);
 	if (p->mem_ptr_virt)
 		iounmap(p->mem_ptr_virt);
 	kfree(d->priv);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2.5.5] Conversion of hp100 to new PCI interface
  2002-02-27  1:53 ` Jean Tourrilhes
@ 2002-02-27  2:11   ` Jeff Garzik
  2002-02-27  2:24     ` Jean Tourrilhes
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff Garzik @ 2002-02-27  2:11 UTC (permalink / raw)
  To: jt; +Cc: Jaroslav Kysela, Linux kernel mailing list

> 
> +       /* Conversion to new PCI API :
> +        * The memory block we use, lp->page_vaddr, was DMA allocated via
> +        * pci_alloc_consistent(), so we just need to "retreive" the
> +        * original mapping to bus/phys address - Jean II */
>         ringptr->pdl = pdlptr + 1;
> -       ringptr->pdl_paddr = virt_to_bus(pdlptr + 1);
> +       ringptr->pdl_paddr = virt_to_phys(pdlptr + 1);

Nope..  You need to use the mapping value obtained from
pci_alloc_consistent...

Note for ISA (and EISA and VLB) devices, you also call
pci_alloc_consistent.  You pass NULL for the pci device.

	Jeff



-- 
Jeff Garzik      | "UNIX enhancements aren't."
Building 1024    |           -- says /usr/games/fortune
MandrakeSoft     |

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2.5.5] Conversion of hp100 to new PCI interface
  2002-02-27  2:11   ` Jeff Garzik
@ 2002-02-27  2:24     ` Jean Tourrilhes
  2002-02-27  3:03       ` Jeff Garzik
       [not found]       ` <3C7D87AD.A9A25027@mandrakesoft.com>
  0 siblings, 2 replies; 6+ messages in thread
From: Jean Tourrilhes @ 2002-02-27  2:24 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: jt, Jaroslav Kysela, Linux kernel mailing list

On Tue, Feb 26, 2002 at 09:11:15PM -0500, Jeff Garzik wrote:
> > 
> > +       /* Conversion to new PCI API :
> > +        * The memory block we use, lp->page_vaddr, was DMA allocated via
> > +        * pci_alloc_consistent(), so we just need to "retreive" the
> > +        * original mapping to bus/phys address - Jean II */
> >         ringptr->pdl = pdlptr + 1;
> > -       ringptr->pdl_paddr = virt_to_bus(pdlptr + 1);
> > +       ringptr->pdl_paddr = virt_to_phys(pdlptr + 1);
> 
> Nope..  You need to use the mapping value obtained from
> pci_alloc_consistent...

	I don't understand the objection. The memory has been declared
as DMA and the system already manages it as such. What's the catch ?
	If I can't use virt_to_phys(), can I have a function that does
exactly the same ? The new API is heavy enough, and if drivers can't
have something like this it's just messy...
	Just define something like :
------------------------------------------
static inline dma_addr_t pci_map_alloc(struct pci_dev *hwdev, void *ptr)
{
	ret virt_to_phys(ptr);
}
------------------------------------------

> Note for ISA (and EISA and VLB) devices, you also call
> pci_alloc_consistent.  You pass NULL for the pci device.

	That's what I do. But I don't claim it's tested.
	By the way, it seems weird to prefix all those functions with
"pci_" where in fact they are only loosely related to PCI stuff.
	Also, on the inconsistent side, most functions handle pci_dev
== NULL, but not all, and it's not well documented. For example, if
you pass NULL to pci_set_dma_mask(), it will kaboom !

> 	Jeff

	Jean

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2.5.5] Conversion of hp100 to new PCI interface
  2002-02-27  2:24     ` Jean Tourrilhes
@ 2002-02-27  3:03       ` Jeff Garzik
       [not found]       ` <3C7D87AD.A9A25027@mandrakesoft.com>
  1 sibling, 0 replies; 6+ messages in thread
From: Jeff Garzik @ 2002-02-27  3:03 UTC (permalink / raw)
  To: jt; +Cc: Jaroslav Kysela, Linux kernel mailing list

Jean Tourrilhes wrote:
> 
> On Tue, Feb 26, 2002 at 09:11:15PM -0500, Jeff Garzik wrote:
> > >
> > > +       /* Conversion to new PCI API :
> > > +        * The memory block we use, lp->page_vaddr, was DMA allocated via
> > > +        * pci_alloc_consistent(), so we just need to "retreive" the
> > > +        * original mapping to bus/phys address - Jean II */
> > >         ringptr->pdl = pdlptr + 1;
> > > -       ringptr->pdl_paddr = virt_to_bus(pdlptr + 1);
> > > +       ringptr->pdl_paddr = virt_to_phys(pdlptr + 1);
> >
> > Nope..  You need to use the mapping value obtained from
> > pci_alloc_consistent...
> 
>         I don't understand the objection. The memory has been declared
> as DMA and the system already manages it as such. What's the catch ?
>         If I can't use virt_to_phys(), can I have a function that does
> exactly the same ? The new API is heavy enough, and if drivers can't
> have something like this it's just messy...

It's not portable, and there's no reason to keep recalculating the value
on those platforms where it does work.  You need to store the mapping
value for later use.

Read the section "Optimizing Unmap State Space Consumption" in
Documentation/DMA-mapping.txt for some examples and information WRT
pci_map_xxx/pci_unmap_xxx too.

	Jeff



-- 
Jeff Garzik      | "UNIX enhancements aren't."
Building 1024    |           -- says /usr/games/fortune
MandrakeSoft     |

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2.5.5] Conversion of hp100 to new PCI interface
       [not found]       ` <3C7D87AD.A9A25027@mandrakesoft.com>
@ 2002-03-04 20:06         ` Jean Tourrilhes
  0 siblings, 0 replies; 6+ messages in thread
From: Jean Tourrilhes @ 2002-03-04 20:06 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Linux kernel mailing list

[-- Attachment #1: Type: text/plain, Size: 371 bytes --]

On Wed, Feb 27, 2002 at 08:28:13PM -0500, Jeff Garzik wrote:
> If you just wanted to redo the patch storing the pci_alloc_mapping
> mapping values in struct hp100_private, the patch is otherwise ok...

	Sorry, was busy. Still need to go through my IrDA patches, but
here is the hp100 patch "the right way". Patch against 2.5.6-pre1,
tested on J2585B.
	Have fun...

	Jean

[-- Attachment #2: hp100.vb2.diff --]
[-- Type: text/plain, Size: 7575 bytes --]

diff -u -p linux/drivers/net/hp100_vb.c linux/drivers/net/hp100.c
--- linux/drivers/net/hp100_vb.c	Tue Feb 26 16:24:51 2002
+++ linux/drivers/net/hp100.c	Mon Mar  4 12:03:23 2002
@@ -83,8 +83,6 @@
 **
 */
 
-#error Please convert me to Documentation/DMA-mapping.txt
-
 #define HP100_DEFAULT_PRIORITY_TX 0
 
 #undef HP100_DEBUG
@@ -212,8 +210,8 @@ struct hp100_private {
 	hp100_ring_t rxring[MAX_RX_PDL];
 	hp100_ring_t txring[MAX_TX_PDL];
 
-	u_int *page_vaddr;	/* Virtual address of allocated page */
 	u_int *page_vaddr_algn;	/* Aligned virtual address of allocated page */
+	u_long whatever_offset;	/* Offset to bus/phys/dma address */
 	int rxrcommit;		/* # Rx PDLs commited to adapter */
 	int txrcommit;		/* # Tx PDLs commited to adapter */
 };
@@ -350,6 +348,18 @@ static void hp100_clean_txring(struct ne
 static void hp100_RegisterDump(struct net_device *dev);
 #endif
 
+/* Conversion to new PCI API :
+ * Convert an address in a kernel buffer to a bus/phys/dma address.
+ * This work *only* for memory fragments part of lp->page_vaddr,
+ * because it was properly DMA allocated via pci_alloc_consistent(),
+ * so we just need to "retreive" the original mapping to bus/phys/dma
+ * address - Jean II */
+static inline dma_addr_t virt_to_whatever(struct net_device *dev, u32 * ptr)
+{
+  return ((u_long) ptr) +
+    ((struct hp100_private *) (dev->priv))->whatever_offset;
+}
+
 /* TODO: This function should not really be needed in a good design... */
 static void wait(void)
 {
@@ -627,9 +637,20 @@ static int __init hp100_probe1(struct ne
 			local_mode = 3;
 		} else if (chip == HP100_CHIPID_LASSEN &&
 			   (lsw & (HP100_BM_WRITE | HP100_BM_READ)) == (HP100_BM_WRITE | HP100_BM_READ)) {
+			/* Conversion to new PCI API :
+			 * I don't have the doc, but I assume that the card
+			 * can map the full 32bit address space.
+			 * Also, we can have EISA Busmaster cards (not tested),
+			 * so beware !!! - Jean II */
+			if((bus == HP100_BUS_PCI) &&
+			   (pci_set_dma_mask(pci_dev, 0xffffffff))) {
+				/* Gracefully fallback to shared memory */
+				goto busmasterfail;
+			}
 			printk("hp100: %s: Busmaster mode enabled.\n", dev->name);
 			hp100_outw(HP100_MEM_EN | HP100_IO_EN | HP100_RESET_LB, OPTION_LSW);
 		} else {
+		busmasterfail:
 #ifdef HP100_DEBUG
 			printk("hp100: %s: Card not configured for BM or BM not supported with this card.\n", dev->name);
 			printk("hp100: %s: Trying shared memory mode.\n", dev->name);
@@ -772,11 +793,14 @@ static int __init hp100_probe1(struct ne
 	 * in the cards shared memory area. But currently, busmaster has been
 	 * implemented/tested only with the lassen chip anyway... */
 	if (lp->mode == 1) {	/* busmaster */
+		dma_addr_t page_baddr;
 		/* Get physically continous memory for TX & RX PDLs    */
-		if ((lp->page_vaddr = kmalloc(MAX_RINGSIZE + 0x0f, GFP_KERNEL)) == NULL)
+		/* Conversion to new PCI API :
+		 * Pages are always aligned and zeroed, no need to it ourself.
+		 * Doc says should be OK for EISA bus as well - Jean II */
+		if ((lp->page_vaddr_algn = pci_alloc_consistent(lp->pci_dev, MAX_RINGSIZE, &page_baddr)) == NULL)
 			return -ENOMEM;
-		lp->page_vaddr_algn = ((u_int *) (((u_int) (lp->page_vaddr) + 0x0f) & ~0x0f));
-		memset(lp->page_vaddr, 0, MAX_RINGSIZE + 0x0f);
+		lp->whatever_offset = ((u_long) page_baddr) - ((u_long) lp->page_vaddr_algn);
 
 #ifdef HP100_DEBUG_BM
 		printk("hp100: %s: Reserved DMA memory from 0x%x to 0x%x\n", dev->name, (u_int) lp->page_vaddr_algn, (u_int) lp->page_vaddr_algn + MAX_RINGSIZE);
@@ -1189,7 +1213,7 @@ static void hp100_init_pdls(struct net_d
 {
 	struct hp100_private *lp = (struct hp100_private *) dev->priv;
 	hp100_ring_t *ringptr;
-	u_int *pageptr;
+	u_int *pageptr;		/* Warning : increment by 4 - Jean II */
 	int i;
 
 #ifdef HP100_DEBUG_B
@@ -1246,7 +1270,7 @@ static int hp100_init_rxpdl(struct net_d
 		       dev->name, (unsigned) pdlptr);
 
 	ringptr->pdl = pdlptr + 1;
-	ringptr->pdl_paddr = virt_to_bus(pdlptr + 1);
+	ringptr->pdl_paddr = virt_to_whatever(dev, pdlptr + 1);
 	ringptr->skb = (void *) NULL;
 
 	/* 
@@ -1257,7 +1281,7 @@ static int hp100_init_rxpdl(struct net_d
 	 */
 	/* Note that pdlptr+1 and not pdlptr is the pointer to the PDH */
 
-	*(pdlptr + 2) = (u_int) virt_to_bus(pdlptr);	/* Address Frag 1 */
+	*(pdlptr + 2) = (u_int) virt_to_whatever(dev, pdlptr);	/* Address Frag 1 */
 	*(pdlptr + 3) = 4;	/* Length  Frag 1 */
 
 	return ((((MAX_RX_FRAG * 2 + 2) + 3) / 4) * 4);
@@ -1272,7 +1296,7 @@ static int hp100_init_txpdl(struct net_d
 		printk("hp100: %s: Init txpdl: Unaligned pdlptr 0x%x.\n", dev->name, (unsigned) pdlptr);
 
 	ringptr->pdl = pdlptr;	/* +1; */
-	ringptr->pdl_paddr = virt_to_bus(pdlptr);	/* +1 */
+	ringptr->pdl_paddr = virt_to_whatever(dev, pdlptr);	/* +1 */
 	ringptr->skb = (void *) NULL;
 
 	return ((((MAX_TX_FRAG * 2 + 2) + 3) / 4) * 4);
@@ -1331,8 +1355,10 @@ static int hp100_build_rx_pdl(hp100_ring
 				     (unsigned int) ringptr->skb->data);
 #endif
 
+		/* Conversion to new PCI API : map skbuf data to PCI bus.
+		 * Doc says it's OK for EISA as well - Jean II */
 		ringptr->pdl[0] = 0x00020000;	/* Write PDH */
-		ringptr->pdl[3] = ((u_int) virt_to_bus(ringptr->skb->data));
+		ringptr->pdl[3] = ((u_int) pci_map_single(((struct hp100_private *) (dev->priv))->pci_dev, ringptr->skb->data, MAX_ETHER_SIZE, PCI_DMA_FROMDEVICE));
 		ringptr->pdl[4] = MAX_ETHER_SIZE;	/* Length of Data */
 
 #ifdef HP100_DEBUG_BM
@@ -1585,7 +1611,6 @@ static int hp100_start_xmit_bm(struct sk
 
 	ringptr->skb = skb;
 	ringptr->pdl[0] = ((1 << 16) | i);	/* PDH: 1 Fragment & length */
-	ringptr->pdl[1] = (u32) virt_to_bus(skb->data);	/* 1st Frag: Adr. of data */
 	if (lp->chip == HP100_CHIPID_SHASTA) {
 		/* TODO:Could someone who has the EISA card please check if this works? */
 		ringptr->pdl[2] = i;
@@ -1593,6 +1618,9 @@ static int hp100_start_xmit_bm(struct sk
 		/* In the PDL, don't use the padded size but the real packet size: */
 		ringptr->pdl[2] = skb->len;	/* 1st Frag: Length of frag */
 	}
+	/* Conversion to new PCI API : map skbuf data to PCI bus.
+	 * Doc says it's OK for EISA as well - Jean II */
+	ringptr->pdl[1] = ((u32) pci_map_single(lp->pci_dev, skb->data, ringptr->pdl[2], PCI_DMA_TODEVICE));	/* 1st Frag: Adr. of data */
 
 	/* Hand this PDL to the card. */
 	hp100_outl(ringptr->pdl_paddr, TX_PDA_L);	/* Low Prio. Queue */
@@ -1641,6 +1669,8 @@ static void hp100_clean_txring(struct ne
 				dev->name, (u_int) lp->txrhead->skb->data,
 				lp->txrcommit, hp100_inb(TX_PDL), donecount);
 #endif
+		/* Conversion to new PCI API : NOP */
+		pci_unmap_single(lp->pci_dev, (dma_addr_t) lp->txrhead->pdl[1], lp->txrhead->pdl[2], PCI_DMA_TODEVICE);
 		dev_kfree_skb_any(lp->txrhead->skb);
 		lp->txrhead->skb = (void *) NULL;
 		lp->txrhead = lp->txrhead->next;
@@ -1950,6 +1980,9 @@ static void hp100_rx_bm(struct net_devic
 		header = *(ptr->pdl - 1);
 		pkt_len = (header & HP100_PKT_LEN_MASK);
 
+		/* Conversion to new PCI API : NOP */
+		pci_unmap_single(lp->pci_dev, (dma_addr_t) ptr->pdl[3], MAX_ETHER_SIZE, PCI_DMA_FROMDEVICE);
+
 #ifdef HP100_DEBUG_BM
 		printk("hp100: %s: rx_bm: header@0x%x=0x%x length=%d, errors=0x%x, dest=0x%x\n",
 				dev->name, (u_int) (ptr->pdl - 1), (u_int) header,
@@ -2910,7 +2943,7 @@ static void release_dev(int i)
 	release_region(d->base_addr, HP100_REGION_SIZE);
 
 	if (p->mode == 1)	/* busmaster */
-		kfree(p->page_vaddr);
+		pci_free_consistent(p->pci_dev, MAX_RINGSIZE + 0x0f, p->page_vaddr_algn, virt_to_whatever(d, p->page_vaddr_algn));
 	if (p->mem_ptr_virt)
 		iounmap(p->mem_ptr_virt);
 	kfree(d->priv);

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-03-04 20:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-27  1:46 [PATCH 2.5.5] Conversion of hp100 to new PCI interface Jean Tourrilhes
2002-02-27  1:53 ` Jean Tourrilhes
2002-02-27  2:11   ` Jeff Garzik
2002-02-27  2:24     ` Jean Tourrilhes
2002-02-27  3:03       ` Jeff Garzik
     [not found]       ` <3C7D87AD.A9A25027@mandrakesoft.com>
2002-03-04 20:06         ` Jean Tourrilhes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.