Re: SCSI tape buffer allocation hitting memory allocation

Douglas Gilbert (dgilbert@interlog.com)
Sat, 13 Feb 1999 18:00:56 -0500


> On Fri, 12 Feb 1999, Simon Kirby wrote:
>
> > Hmm...it makes obvious sense that some sort of transfer from a device to
> > physical memory wouldn't be able to go through the page translation on the
> > CPU unless the CPU was doing the transfer, so it makes sense that
> > vmalloc()ed pages wouldn't work. I wonder what the floppy driver does,
> > then...
>
> Okay, now that I've realized my first idea is really dumb, I'd like to
> confirm that DMA to an onboard/PCI device does actually work addressing
> physical memory > 64MB. Is this true? I changed scsi_init_malloc() to
> remove the GFP_DMA flag iff the first allocation w/GFP_DMA fails...it
> seems to now work (but obviously it will blow up for ISA cards). Is
> GFP_DMA is used anywhere else other than to tell __get_free_pages() to
> only allocate in areas < 64MB)? I'm assuming this should be safe (for the
> case of this one machine w/no ISA SCSI controllers) if not.

The SCSI mid-level takes a pessimistic view and assumes one of your
SCSI controllers is ISA. According to Rubini there is another issue.
That
GFP_DMA flag also guarantees that when you get more than PAGE_SIZE bytes
(32Kbytes for instance) then seen from the DMA chip's memory space it is
contiguous. So when you drop that flag, I believe you need to "walk"
the returned buffer and check it.

Perhaps people could comment on whether the following code is
appropriate
for that:

static int chk_cont(char * bvp, int sz)
{
int k;
unsigned long bus_addr = virt_to_bus(bvp);

for (k = PAGE_SIZE; k < sz; k += PAGE_SIZE) {
bus_addr += PAGE_SIZE;
bvp += PAGE_SIZE;
if (bus_addr != virt_to_bus(bvp))
break;
}
return (k >= sz) ? sz : k;
/* return (sz < PAGE_SIZE) ? sz : PAGE_SIZE; <<< testing */
}

Will non-contiguous allocation every occur on the i386 architecture?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/