Re: 2.6.7-mm7

Andrew Morton
2004-07-09T23:37:55Z

James Bottomley <James.Bottomley@SteelEye.com> 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);
}
}
}