From: Alexander Graf <agraf@suse.de>
To: Alexey Kardashevskiy <aik@ozlabs.ru>, qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 8/9] spapr_iommu: Introduce page_shift in sPAPRTCETable
Date: Fri, 23 May 2014 15:39:56 +0200 [thread overview]
Message-ID: <537F4FAC.7030305@suse.de> (raw)
In-Reply-To: <1400757570-1983-9-git-send-email-aik@ozlabs.ru>
On 22.05.14 13:19, Alexey Kardashevskiy wrote:
> At the moment only 4K pages are supported by sPAPRTCETable. Since sPAPR
> spec allows other page sizes and we are going to implement them, we need
> page size to be configrable.
>
> This adds @page_shift into sPAPRTCETable and replaces SPAPR_TCE_PAGE_SHIFT
> with it whereever it is possible.
>
> This removes SPAPR_TCE_PAGE_MASK as it is no longer used.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> Changes:
> v2:
> * target_ulong for "mask" replaced with hwaddr
> * added page_mask and page_size local variables where possible
> ---
> hw/ppc/spapr_iommu.c | 66 +++++++++++++++++++++++++++++++-------------------
> hw/ppc/spapr_pci.c | 1 +
> hw/ppc/spapr_vio.c | 1 +
> include/hw/ppc/spapr.h | 3 ++-
> 4 files changed, 45 insertions(+), 26 deletions(-)
>
> diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
> index 99d1d6e..65f9a89 100644
> --- a/hw/ppc/spapr_iommu.c
> +++ b/hw/ppc/spapr_iommu.c
> @@ -70,12 +70,14 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr)
>
> if (tcet->bypass) {
> ret.perm = IOMMU_RW;
> - } else if ((addr >> SPAPR_TCE_PAGE_SHIFT) < tcet->nb_table) {
> + } else if ((addr >> tcet->page_shift) < tcet->nb_table) {
> /* Check if we are in bound */
> - tce = tcet->table[addr >> SPAPR_TCE_PAGE_SHIFT];
> - ret.iova = addr & ~SPAPR_TCE_PAGE_MASK;
> - ret.translated_addr = tce & ~SPAPR_TCE_PAGE_MASK;
> - ret.addr_mask = SPAPR_TCE_PAGE_MASK;
> + hwaddr page_mask = ~((1 << tcet->page_shift) - 1);
1ULL
> +
> + tce = tcet->table[addr >> tcet->page_shift];
> + ret.iova = addr & page_mask;
> + ret.translated_addr = tce & page_mask;
> + ret.addr_mask = ~page_mask;
> ret.perm = tce;
> }
> trace_spapr_iommu_xlate(tcet->liobn, addr, ret.iova, ret.perm,
> @@ -113,7 +115,7 @@ static int spapr_tce_table_realize(DeviceState *dev)
> if (kvm_enabled()) {
> tcet->table = kvmppc_create_spapr_tce(tcet->liobn,
> tcet->nb_table <<
> - SPAPR_TCE_PAGE_SHIFT,
> + tcet->page_shift,
> &tcet->fd);
> }
>
> @@ -133,6 +135,7 @@ static int spapr_tce_table_realize(DeviceState *dev)
> }
>
> sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn,
> + uint32_t page_shift,
> uint32_t nb_table)
> {
> sPAPRTCETable *tcet;
> @@ -149,6 +152,7 @@ sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn,
>
> tcet = SPAPR_TCE_TABLE(object_new(TYPE_SPAPR_TCE_TABLE));
> tcet->liobn = liobn;
> + tcet->page_shift = page_shift;
> tcet->nb_table = nb_table;
>
> object_property_add_child(OBJECT(owner), "tce-table", OBJECT(tcet), NULL);
> @@ -194,19 +198,20 @@ static target_ulong put_tce_emu(sPAPRTCETable *tcet, target_ulong ioba,
> target_ulong tce)
> {
> IOMMUTLBEntry entry;
> + hwaddr page_mask = ~((1 << tcet->page_shift) - 1);
...
Alex
next prev parent reply other threads:[~2014-05-23 13:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-22 11:19 [Qemu-devel] [PATCH v2 0/9] spapr_pci: Prepare for VFIO Alexey Kardashevskiy
2014-05-22 11:19 ` [Qemu-devel] [PATCH v2 1/9] spapr: Enable dynamic change of the supported hypercalls list Alexey Kardashevskiy
2014-05-22 11:19 ` [Qemu-devel] [PATCH v2 2/9] spapr_iommu: Enable multiple TCE requests Alexey Kardashevskiy
2014-05-22 11:19 ` [Qemu-devel] [PATCH v2 3/9] spapr_pci: Introduce a finish_realize() callback Alexey Kardashevskiy
2014-05-22 11:19 ` [Qemu-devel] [PATCH v2 4/9] spapr_pci: spapr_iommu: Make DMA window a subregion Alexey Kardashevskiy
2014-05-22 11:19 ` [Qemu-devel] [PATCH v2 5/9] spapr_pci: Allow multiple TCE tables per PHB Alexey Kardashevskiy
2014-05-22 11:19 ` [Qemu-devel] [PATCH v2 6/9] spapr_iommu: Convert old qdev_init_nofail() to object_property_set_bool Alexey Kardashevskiy
2014-05-22 11:19 ` [Qemu-devel] [PATCH v2 7/9] spapr_iommu: Get rid of window_size in sPAPRTCETable Alexey Kardashevskiy
2014-05-22 11:19 ` [Qemu-devel] [PATCH v2 8/9] spapr_iommu: Introduce page_shift " Alexey Kardashevskiy
2014-05-23 13:39 ` Alexander Graf [this message]
2014-05-22 11:19 ` [Qemu-devel] [PATCH v2 9/9] spapr_iommu: Introduce bus_offset " Alexey Kardashevskiy
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=537F4FAC.7030305@suse.de \
--to=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.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).