Re: cdrom: use kmalloced buffers instead of buffers on stack

Previous thread: Fw: Re: linux-next: Tree for April 21 (SGI XPNET) by Stephen Rothwell on Monday, April 21, 2008 - 6:46 pm. (3 messages)

Next thread: [PATCH 3/3] ata: Add Intel SCH PATA support by alek du on Monday, April 21, 2008 - 7:09 pm. (1 message)
From: Jeff Garzik
Date: Monday, April 21, 2008 - 7:01 pm

Eh... AFAICS this is only really useful in two of the cases converted.

For all the other cases (<= 32 bytes), it is _far_ less complex, far 
less code to simply communicate the additional alignment requirements to 
the compiler.

What about __attribute__ __aligned__?  Was that tried?

	Jeff


--

From: David Miller
Date: Monday, April 21, 2008 - 7:03 pm

From: Jeff Garzik <jeff@garzik.org>

On some platforms the stack is virtually mapped instead of
from kmalloc or get_free_pages memory.

DMA on stack buffers is really not feasible.
--

From: Thomas Bogendoerfer
Date: Monday, April 21, 2008 - 10:48 pm

I used that while narrowing down the bug. But not only the alignment is
important, but also size needs to be a multiple of the cache line size.
Which means it needs to be 128 bytes for most SGI machines. That
and the following in DMA-mapping.txt

"This rule also means that you may use neither kernel image addresses
(items in data/text/bss segments), nor module image addresses, nor
stack addresses for DMA."

let me choose the kmalloc() solution.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]
--

From: Jens Axboe
Date: Monday, April 21, 2008 - 11:33 pm

Which is good, the patch has been due for years :-)

-- 
Jens Axboe

--

From: FUJITA Tomonori
Date: Tuesday, April 22, 2008 - 4:47 am

On Tue, 22 Apr 2008 07:48:58 +0200

Can we advertise such architecture's dma restrictions? For example, if
we can update dma_pad_mask and dma_alignment in request_queue,
blk_rq_map_kern uses a proper bounce buffer for such
architectures. Then we can avoid putting extra complexity in uppper
drivers such as cdrom.c
--

From: Jens Axboe
Date: Tuesday, April 22, 2008 - 4:55 am

That would work fine, if cdrom was then also updated to get rid of
->generic_packet() and use the regular queue transport instead. Which
would be a VERY nice thing to do anyway, so I'd welcome the effort :-)

-- 
Jens Axboe

--

From: FUJITA Tomonori
Date: Tuesday, April 22, 2008 - 4:59 am

On Tue, 22 Apr 2008 13:55:19 +0200

sr_packet calls ioctl so it works for SCSI at least?
--

From: Jens Axboe
Date: Tuesday, April 22, 2008 - 5:04 am

Yup, it'll work fine for sr currently, but not ide-cd. But we should
just get rid of ->generic_packet() and prepare a request in cdrom.c
instead.

-- 
Jens Axboe

--

From: FUJITA Tomonori
Date: Tuesday, April 22, 2008 - 5:25 am

On Tue, 22 Apr 2008 14:04:38 +0200

Ok, I'll see how things work after finishing the work to remove the
request structure on the stack.

So are you ok with a patch to make blk_rq_map_kern handle dma padding
and alignment propely?

http://marc.info/?l=linux-scsi&m=120860454709078&w=2
--

From: Jens Axboe
Date: Tuesday, April 22, 2008 - 5:30 am

I'm getting to that patch, from a cursory look it seems fine.

-- 
Jens Axboe

--

Previous thread: Fw: Re: linux-next: Tree for April 21 (SGI XPNET) by Stephen Rothwell on Monday, April 21, 2008 - 6:46 pm. (3 messages)

Next thread: [PATCH 3/3] ata: Add Intel SCH PATA support by alek du on Monday, April 21, 2008 - 7:09 pm. (1 message)