Re: PCI DMA to small buffers on cache-incoherent arch

Roland Dreier
2002-06-09T00:52:54Z

>>>>> "Anton" == Anton Blanchard <anton@samba.org> writes:

Anton> I just checked 2.5 and noticed the scsi code is _still_
Anton> DMAing to the stack! Maybe it would be worth having a debug
Anton> option for x86 where it uses vmalloc for kernel stack
Anton> allocation :)

Good catches, just a few comments on the patch.

Anton> Anyway attached is a patch from Todd Inglett that I updated
Anton> for 2.5.

===== drivers/scsi/scsi_scan.c 1.13 vs edited =====
- /* Make sure we have something that is valid for DMA purposes */
- scsi_result = ((!shpnt->unchecked_isa_dma)
- ? &scsi_result0[0] : kmalloc(512, GFP_DMA));
+ scsi_result = kmalloc(512, GFP_DMA);

I don't think you should always use GFP_DMA here... probably better to
do:

scsi_result = kmalloc(512,
shpnt->unchecked_isa_dma ? GFP_DMA : GFP_ATOMIC);

And similarly this:

===== drivers/scsi/sr_ioctl.c 1.13 vs edited =====
+ unsigned char *buffer = kmalloc(512, GFP_DMA);

should probably use GFP_KERNEL (or possibly a check of
unchecked_isa_dma as above, though this doesn't seem to be needed
based on the existing code).

Best,
Roland