Skip to contentSkip to conversation

generic device DMA implementation

PATCH Adam J. Richter 2 participants 2 messages Dec 28, 2002

lore
Share & tools
lore
#0 lore raw
Quoted 4 lines · David Brownell
Quoted 3 lines · Adam J. Richter
Quoted 1 line · David Brownell

Isn't the goal to make sure that for every kind of "struct device *"

                                        ^^^^^
Quoted 11 lines
Quoted 9 lines
Quoted 2 lines

it should be possible to use those dma_*() calls, without BUGging out.

	No.
Quoted 1 line

If that's not true ... then why were they defined?

So that other memory mapped busses such as ISA and sbus
can use them.

That sounds like a "yes", not a "no" ... except for devices on busses

^^^^^^
Then it's not "every", which was your question. I guess I need
to understand better how to interpret your questions.

Quoted 2 lines

that don't have do memory mapped I/O. It's what I described: dma_*() calls being used with struct device, without BUGging out.

	Let's see if we agree.  The behavior I expect is:

	addr = dma_malloc(&some_usb_device->dev,size, &dma_addr,DMA_CONSISTENT)
	     ===> BUG()

	addr = dma_malloc(host_dev(some_usb_device), &dma_addr, DMA_CONSISTENT)
	     ===> some consistent memory (or NULL).

where host_dev would be something like:

struct device *host_dev(struct usb_device *usbdev)

{
	struct usb_hcd *hcd = usbdev->bus->hcpriv;
	return &hcd->pdev->device; /* actually, this would become &hcd->dev */
}
Quoted 5 lines
Quoted 3 lines

USB devices should do DMA operations with respect to their USB
host adapters, typically a PCI device. For example, imagine a machine with two USB controllers on different bus instances.

USB already does that ... you write as if it didn't.

I wasn't aware of it. I've looked up the code now. Thanks
for the pointer. With generic DMA operations, we can delete most of drivers/bus/usb/core/buffer.c, specifically hcd_buffer_{alloc,free,{,un}map{,_sg},dmasync,sync_sg}, and their method pointers in struct usb_operations in drivers/usb/core/hcd.[ch] without introducing PCI dependency.

I hope this clarifies things. Please let me know if you think
we still disagree on something.

Adam J. Richter     __     ______________   575 Oroville Road
[email protected]     \ /                  Milpitas, California 95035
+1 408 309-6081         | g g d r a s i l   United States of America

"Free Software For The Rest Of Us."

#1 lore raw

Hi,

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Isn't the goal to make sure that for every kind of "struct device *"

                                        ^^^^^
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

it should be possible to use those dma_*() calls, without BUGging out.

That sounds like a "yes", not a "no" ... except for devices on busses

^^^^^^
Then it's not "every", which was your question. I guess I need
to understand better how to interpret your questions.

My bad ... I meant "every" kind of device doing memory mapped I/O, which is all that had been mentioned so far. This needs to work on more than just the "platform bus"; "layered busses" shouldn't need special casing, they are just as common. You had mentioned SCSI busses; USB, FireWire, and others also exist. (Though I confess I still don't like BUG() as a way to fail much of anything!)

That's likely a better way to present one of my points: if it's "generic", then it must work on more than just the lowest level platform bus.

Quoted 8 lines
Quoted 2 lines

that don't have do memory mapped I/O. It's what I described: dma_*() calls being used with struct device, without BUGging out.

	Let's see if we agree.  The behavior I expect is:

	addr = dma_malloc(&some_usb_device->dev,size, &dma_addr,DMA_CONSISTENT)
	     ===> BUG()

That's not consistent with what I thought what you said. USB devices use memory mapped I/O, so this should work. (And using BUG instead of returning null still seems wrong...)

However, we could agree that some kind of dma_malloc() should exist !!

Quoted 10 lines
	addr = dma_malloc(host_dev(some_usb_device), &dma_addr, DMA_CONSISTENT)
	     ===> some consistent memory (or NULL).

where host_dev would be something like:

struct device *host_dev(struct usb_device *usbdev)

{
	struct usb_hcd *hcd = usbdev->bus->hcpriv;
	return &hcd->pdev->device; /* actually, this would become &hcd->dev */
}

Please look at the 2.5.53 tree with my "usbcore dma updates (and doc)" patch, which Greg has now merged and submitted to Linus.

The pre-existing USB DMA API syntax did not change, so it looks only "something" like what you wrote there.

- Dave