From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Soalt-00089F-BE for qemu-devel@nongnu.org; Tue, 10 Jul 2012 09:46:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Soaln-00013w-44 for qemu-devel@nongnu.org; Tue, 10 Jul 2012 09:46:32 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:38986) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Soalm-00013i-UT for qemu-devel@nongnu.org; Tue, 10 Jul 2012 09:46:27 -0400 Received: by pbbro12 with SMTP id ro12so335087pbb.4 for ; Tue, 10 Jul 2012 06:46:24 -0700 (PDT) From: Alexey Kardashevskiy Date: Tue, 10 Jul 2012 23:46:08 +1000 Message-Id: <1341927973-5615-1-git-send-email-aik@ozlabs.ru> In-Reply-To: References: Subject: [Qemu-devel] [PATCH] pseries iommu: h_put_tce split to support more IOMMUs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , qemu-devel@nongnu.org, agraf@suse.de, qemu-ppc@nongnu.org, David Gibson sPAPR IOMMU RTAS handler is split to common h_put_tce() part and emulated IOMMU implementation called put_tce_emu(). Further patches will extend h_put_tce() with put_tce_vfio() in order to support other types of IOMMU such as VFIO. Signed-off-by: Alexey Kardashevskiy --- hw/spapr_iommu.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/hw/spapr_iommu.c b/hw/spapr_iommu.c index 388ffa4..3021bfe 100644 --- a/hw/spapr_iommu.c +++ b/hw/spapr_iommu.c @@ -162,21 +162,25 @@ void spapr_tce_free(DMAContext *dma) } } -static target_ulong put_tce_emu(sPAPRTCETable *tcet, target_ulong ioba, - target_ulong tce) +static int put_tce_emu(target_ulong liobn, target_ulong ioba, target_ulong tce) { + sPAPRTCETable *tcet = spapr_tce_find_by_liobn(liobn); sPAPRTCE *tcep; + if (!tcet) { + return 1; + } + if (ioba >= tcet->window_size) { hcall_dprintf("spapr_vio_put_tce on out-of-boards IOBA 0x" TARGET_FMT_lx "\n", ioba); - return H_PARAMETER; + return -1; } tcep = tcet->table + (ioba >> SPAPR_TCE_PAGE_SHIFT); tcep->tce = tce; - return H_SUCCESS; + return 0; } static target_ulong h_put_tce(CPUPPCState *env, sPAPREnvironment *spapr, @@ -185,7 +189,7 @@ static target_ulong h_put_tce(CPUPPCState *env, sPAPREnvironment *spapr, target_ulong liobn = args[0]; target_ulong ioba = args[1]; target_ulong tce = args[2]; - sPAPRTCETable *tcet = spapr_tce_find_by_liobn(liobn); + int ret; if (liobn & 0xFFFFFFFF00000000ULL) { hcall_dprintf("spapr_vio_put_tce on out-of-boundsw LIOBN " @@ -195,13 +199,14 @@ static target_ulong h_put_tce(CPUPPCState *env, sPAPREnvironment *spapr, ioba &= ~(SPAPR_TCE_PAGE_SIZE - 1); - if (tcet) { - return put_tce_emu(tcet, ioba, tce); + ret = put_tce_emu(liobn, ioba, tce); + if (0 >= ret) { + return ret ? H_PARAMETER : H_SUCCESS; } #ifdef DEBUG_TCE - fprintf(stderr, "%s on liobn=" TARGET_FMT_lx /*%s*/ - " ioba 0x" TARGET_FMT_lx " TCE 0x" TARGET_FMT_lx "\n", - __func__, liobn, /*dev->qdev.id, */ioba, tce); + fprintf(stderr, "%s on liobn=" TARGET_FMT_lx + " ioba 0x" TARGET_FMT_lx " TCE 0x" TARGET_FMT_lx " ret=%d\n", + __func__, liobn, ioba, tce, ret); #endif return H_PARAMETER; -- 1.7.10