Thread (28 messages) 28 messages, 6 authors, 2012-10-11

Re: [PATCH] powerpc-powernv: added tce_get callback for powernv platform

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2012-09-05 00:32:11

On Wed, 2012-09-05 at 10:19 +1000, Alexey Kardashevskiy wrote:
quoted
quoted
+static unsigned long pnv_tce_get(struct iommu_table *tbl, long
index)
quoted
quoted
+{
+    return ((u64 *)tbl->it_base)[index - tbl->it_offset] &
IOMMU_PAGE_MASK;
quoted
quoted
+}
Why the masking here ?

Oops. No reason. Will remove.
Right. The caller wants to know both whether the low bits are set and
whether there's an address up.

On the H_PUT_TCE path, you want to make sure:

 - If any of the low bit is set, set the TCE entry & get_page()
 - If none, then clear the whole entry (ignore the high bits passed by
the guest) and maybe put_page() the old page

IE the TCE either contains a valid page address + low bit(s) or all 0

That way, on the cleanup path, you can check the low bits only to decide
whether to cleanup, and if any is set, you know both your direction
(writeable vs. read only) and whether something was there at all.

You do not want to ever compare the high bits (address) to 0. While we
never do it in practice I suspect, there's no fundamental reason why a
physical address of 0 is incorrect in a TCE.

Cheers,
Ben.
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help