Re: 2.6.7-mm7

From: Andrew Morton
Date: Fri Jul 09 2004 - 18:40:19 EST


James Bottomley <James.Bottomley@xxxxxxxxxxxx> wrote:
>
> On Fri, 2004-07-09 at 17:14, Andrew Morton wrote:
> > btw, James, I'm unable to convince myself that
> > dma_mark_declared_memory_occupied() reserves enough pages if device_addr is
> > not page-aligned. Could you double-check that? If all callers are
> > expected to use a page-aligned address then a BUG_ON might be appropriate.
> > Or a comment.
>
> Oh, you mean when addr isn't page aligned and size causes it just to
> span a page, like addr = 0xfff, size=2?

yup.

> You're right, it doesn't. How about the attached

seems to work OK.


#define PAGE_SIZE 4096
#define PAGE_MASK ~4095
#define PAGE_SHIFT 12

main()
{
int addr, size;

for (addr = 1; addr < 8192; addr += 1024) {
for (size = -1; size < 8192; size += 1024) {
int pages;

pages = (size + (addr & ~PAGE_MASK) + PAGE_SIZE - 1) >> PAGE_SHIFT;
printf("addr:%06x size:%06x pages:%d\n",
addr, size, pages);
}
}
}

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