[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <m24nohsuz8.fsf@linux-m68k.org>
Date: Sun, 05 Aug 2012 08:39:39 +0200
From: Andreas Schwab <schwab@...ux-m68k.org>
To: Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc: Joerg Roedel <joerg.roedel@....com>,
Anton Blanchard <anton@....ibm.com>,
FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>,
linux-kernel@...r.kernel.org
Subject: Re: Is iommu_num_pages() broken ?
Benjamin Herrenschmidt <benh@...nel.crashing.org> writes:
> static inline unsigned long iommu_num_pages(unsigned long addr,
> unsigned long len,
> unsigned long io_page_size)
> {
> unsigned long size = (addr & (io_page_size - 1)) + len;
>
> return DIV_ROUND_UP(size, io_page_size);
> }
>
>
> That doesn't look right to me...
>
> The powerpc iommu code at least uses that with an addr which may not be
> page aligned (ie, result of sg_virt() which include the offset).
>
> The above code will align the start before adding the len which is wrong
addr & (io_page_size - 1) computes the offset into the page pointed to
by addr. Looks right to me.
addr & ~(io_page_size - 1) would round addr down to the start of the
page.
Andreas.
--
Andreas Schwab, schwab@...ux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists