From patchwork Tue Jun 21 04:34:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 9189403 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9AE6060756 for ; Tue, 21 Jun 2016 04:37:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88A2A27F9A for ; Tue, 21 Jun 2016 04:37:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D8D227F9E; Tue, 21 Jun 2016 04:37:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 40A6827F9A for ; Tue, 21 Jun 2016 04:37:48 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bFDQG-0001x8-BP; Tue, 21 Jun 2016 04:36:24 +0000 Received: from mail-pa0-x233.google.com ([2607:f8b0:400e:c03::233]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bFDPT-00019v-23 for linux-arm-kernel@lists.infradead.org; Tue, 21 Jun 2016 04:35:35 +0000 Received: by mail-pa0-x233.google.com with SMTP id hl6so2199727pac.2 for ; Mon, 20 Jun 2016 21:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9z9JV/8IH5sm5WCzDhj1UpdpxHCOFiOlHvam9Lx+ynI=; b=iY2b2VtwiiubLuBUTM3LM1eOnnrb5zeLOWF1tJ4piH4G05eqmtON5q2Q7q/8ACVN8h sALVpd/DfCU+vo/Rv77vmpJ5Hv1yzVp/ylZgj3ypVB2Bw+U7cefE0U72FeTNvEDnHH+L EtqXN4MMrri8hfm3TvKClnfGAno2nUO3gHYUM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9z9JV/8IH5sm5WCzDhj1UpdpxHCOFiOlHvam9Lx+ynI=; b=L7tKLeHLn354qQBdwH77q8cQM7JQjOvfVbhmXBsaV/5PuKiHscoQ894QvD70qtjI9P JXVEJHtY5wUTgeaF9gNIeYzDiYYDMX2ZAJ7iU/XtcDOpIF0II02y7ySBw6of66H+pqoe ANTlp5lSDUimycdBFpFbBweOVilCR4BH2LMxsbZQE0qH56eFVBgU0spVrS2k9DvE/fBY QkqdN1E6c1Amna8CLpR8+X0rBwe56tHXJroqfNd6p6xon5f4s8f8ffuPl/IjqbHcn7/O RC8q8w7jxRGsu/lgHqdafQoynb+U8yJcTcB59IP2h8xXDLM06CQFINiTi+CyjWM8XOmC 0jtA== X-Gm-Message-State: ALyK8tIBMk/ys/hrl4JSWohU1VJhP8vsbZN7sD6BISGVZk20T1xRjf1PMIZiRqO7okOJX2Ru X-Received: by 10.66.171.173 with SMTP id av13mr26155945pac.117.1466483714820; Mon, 20 Jun 2016 21:35:14 -0700 (PDT) Received: from basement.tok.corp.google.com ([100.103.3.207]) by smtp.gmail.com with ESMTPSA id s3sm24500160pfb.87.2016.06.20.21.35.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Jun 2016 21:35:14 -0700 (PDT) From: Tomasz Figa To: iommu@lists.linux-foundation.org, dri-devel@lists.freedesktop.org Subject: [PATCH v4 5/8] iommu/rockchip: Prepare to support generic DMA mapping Date: Tue, 21 Jun 2016 13:34:38 +0900 Message-Id: <1466483681-36110-6-git-send-email-tfiga@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1466483681-36110-1-git-send-email-tfiga@chromium.org> References: <1466483681-36110-1-git-send-email-tfiga@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160620_213535_213474_E11D72BA X-CRM114-Status: GOOD ( 13.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , David Airlie , Joerg Roedel , linux-kernel@vger.kernel.org, Daniel Kurtz , Tomasz Figa , linux-rockchip@lists.infradead.org, Marek Szyprowski , Shunqian Zheng , linux-arm-kernel@lists.infradead.org, Mark Yao MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shunqian Zheng Set geometry for allocated domains and fix .domain_alloc() callback to work with IOMMU_DOMAIN_DMA domain type, which is used for implicit domains on ARM64. Signed-off-by: Shunqian Zheng Signed-off-by: Tomasz Figa --- drivers/iommu/rockchip-iommu.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 0551146..d5fd074 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -888,7 +888,7 @@ static struct iommu_domain *rk_iommu_domain_alloc(unsigned type) struct platform_device *pdev; struct device *iommu_dev; - if (type != IOMMU_DOMAIN_UNMANAGED) + if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA) return NULL; /* Register a pdev per domain, so DMA API can base on this *dev @@ -905,8 +905,8 @@ static struct iommu_domain *rk_iommu_domain_alloc(unsigned type) rk_domain->pdev = pdev; - /* To init the iovad which is required by iommu_dma_init_domain() */ - if (iommu_get_dma_cookie(&rk_domain->domain)) + if (type == IOMMU_DOMAIN_DMA && + iommu_get_dma_cookie(&rk_domain->domain)) goto err_unreg_pdev; /* @@ -932,12 +932,17 @@ static struct iommu_domain *rk_iommu_domain_alloc(unsigned type) spin_lock_init(&rk_domain->dt_lock); INIT_LIST_HEAD(&rk_domain->iommus); + rk_domain->domain.geometry.aperture_start = 0; + rk_domain->domain.geometry.aperture_end = DMA_BIT_MASK(32); + rk_domain->domain.geometry.force_aperture = true; + return &rk_domain->domain; err_free_dt: free_page((unsigned long)rk_domain->dt); err_put_cookie: - iommu_put_dma_cookie(&rk_domain->domain); + if (type == IOMMU_DOMAIN_DMA) + iommu_put_dma_cookie(&rk_domain->domain); err_unreg_pdev: platform_device_unregister(pdev); @@ -966,7 +971,8 @@ static void rk_iommu_domain_free(struct iommu_domain *domain) SPAGE_SIZE, DMA_TO_DEVICE); free_page((unsigned long)rk_domain->dt); - iommu_put_dma_cookie(&rk_domain->domain); + if (domain->type == IOMMU_DOMAIN_DMA) + iommu_put_dma_cookie(&rk_domain->domain); platform_device_unregister(rk_domain->pdev); }