2002-02-27 01:47:31

by Jean Tourrilhes

[permalink] [raw]
Subject: [PATCH 2.5.5] Conversion of hp100 to new PCI interface

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


2002-02-27 01:54:33

by Jean Tourrilhes

[permalink] [raw]
Subject: Re: [PATCH 2.5.5] Conversion of hp100 to new PCI interface

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...


Attachments:
(No filename) (599.00 B)
hp100.vb.diff (6.95 kB)
Download all attachments

2002-02-27 02:11:35

by Jeff Garzik

[permalink] [raw]
Subject: Re: [PATCH 2.5.5] Conversion of hp100 to new PCI interface

>
> + /* 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 |

2002-02-27 02:24:27

by Jean Tourrilhes

[permalink] [raw]
Subject: Re: [PATCH 2.5.5] Conversion of hp100 to new PCI interface

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

2002-02-27 03:03:29

by Jeff Garzik

[permalink] [raw]
Subject: Re: [PATCH 2.5.5] Conversion of hp100 to new PCI interface

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 |

2002-03-04 20:07:12

by Jean Tourrilhes

[permalink] [raw]
Subject: Re: [PATCH 2.5.5] Conversion of hp100 to new PCI interface

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


Attachments:
(No filename) (371.00 B)
hp100.vb2.diff (7.40 kB)
Download all attachments