linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: linuxppc-dev@lists.ozlabs.org, Paul Mackerras <paulus@samba.org>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH] powerpc-powernv: added tce_get callback for powernv platform
Date: Wed, 05 Sep 2012 10:32:04 +1000	[thread overview]
Message-ID: <1346805124.2257.10.camel@pasglop> (raw)
In-Reply-To: <50469A95.7050606@ozlabs.ru>

On Wed, 2012-09-05 at 10:19 +1000, Alexey Kardashevskiy wrote:
> >> +static unsigned long pnv_tce_get(struct iommu_table *tbl, long
> index)
> >> +{
> >> +    return ((u64 *)tbl->it_base)[index - tbl->it_offset] &
> IOMMU_PAGE_MASK;
> >> +}
> >
> > 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.
 

  reply	other threads:[~2012-09-05  0:32 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20120821113534.GS29724@truffula.fritz.box>
2012-09-04  7:33 ` [PATCH] vfio: enabled and supported on power (v7) Alexey Kardashevskiy
2012-09-04  7:35   ` [PATCH] powerpc-powernv: added tce_get callback for powernv platform Alexey Kardashevskiy
2012-09-04 19:41     ` Benjamin Herrenschmidt
2012-09-04 22:35       ` David Gibson
2012-09-05  0:19       ` Alexey Kardashevskiy
2012-09-05  0:32         ` Benjamin Herrenschmidt [this message]
2012-09-04  7:36   ` [PATCH] powerpc-kvm: fixing page alignment for TCE Alexey Kardashevskiy
2012-09-20  9:01     ` Alexander Graf
2012-09-04  7:36   ` [PATCH] powerpc-powernv: align BARs to PAGE_SIZE on powernv platform Alexey Kardashevskiy
2012-09-04 19:45     ` Benjamin Herrenschmidt
2012-09-05  0:55       ` Alexey Kardashevskiy
2012-09-05  1:16         ` Benjamin Herrenschmidt
2012-09-05  4:57           ` Alex Williamson
2012-09-05  5:17             ` Benjamin Herrenschmidt
2012-09-05  5:27               ` Alexey Kardashevskiy
2012-09-10 17:06                 ` Alex Williamson
2012-09-10 16:02   ` [PATCH] vfio: enabled and supported on power (v7) Alex Williamson
2012-09-11  8:28     ` Alexey Kardashevskiy
2012-09-13 22:34       ` Alex Williamson
2012-09-13 22:41         ` Scott Wood
2012-09-13 22:55           ` Alex Williamson
2012-09-14  0:51         ` Alexey Kardashevskiy
2012-09-14  4:35           ` Alex Williamson
2012-10-11  8:19             ` Alexey Kardashevskiy
2012-10-11 18:09               ` Alex Williamson
2012-09-05  1:19 [PATCH] powerpc-powernv: added tce_get callback for powernv platform Alexey Kardashevskiy
2012-09-10  2:35 ` David Gibson
2012-09-10  5:19   ` Benjamin Herrenschmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1346805124.2257.10.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=aik@ozlabs.ru \
    --cc=david@gibson.dropbear.id.au \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).