From patchwork Thu Apr 2 15:29:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 6149831 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5C2AEBF4A6 for ; Thu, 2 Apr 2015 15:32:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7AC75203AB for ; Thu, 2 Apr 2015 15:32:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A0A50203AF for ; Thu, 2 Apr 2015 15:32:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 757366EA7C; Thu, 2 Apr 2015 08:31:05 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [92.198.50.35]) by gabe.freedesktop.org (Postfix) with ESMTP id ACFD66EA40 for ; Thu, 2 Apr 2015 08:30:58 -0700 (PDT) Received: from dude.hi.4.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Ydh58-0005OD-0O; Thu, 02 Apr 2015 17:30:58 +0200 From: Lucas Stach To: dri-devel@lists.freedesktop.org Subject: [PATCH RFC 047/111] staging: etnaviv: publish and use mmu geometry Date: Thu, 2 Apr 2015 17:29:49 +0200 Message-Id: <1427988653-754-48-git-send-email-l.stach@pengutronix.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427988653-754-1-git-send-email-l.stach@pengutronix.de> References: <1427988653-754-1-git-send-email-l.stach@pengutronix.de> X-SA-Exim-Connect-IP: 10.1.0.7 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org Cc: Russell King , kernel@pengutronix.de X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Russell King We model the GPU MMU using the iommu layer, which supports exporting the iommu domain geometry. Use this feature to publish the size of the MMU window, and initialise the MMU drm_mm object according to the available MMU window size. As we only allocate a MMU page table which covers 256MB, yet we initialised the drm_mm object to cover 1GB, this fixes an overflow of the MMU page table array. Signed-off-by: Russell King --- drivers/staging/etnaviv/etnaviv_iommu.c | 2 ++ drivers/staging/etnaviv/etnaviv_mmu.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/etnaviv/etnaviv_iommu.c b/drivers/staging/etnaviv/etnaviv_iommu.c index 6aa91bcf1893..d8ac05aa2cd3 100644 --- a/drivers/staging/etnaviv/etnaviv_iommu.c +++ b/drivers/staging/etnaviv/etnaviv_iommu.c @@ -166,6 +166,8 @@ struct iommu_domain *etnaviv_iommu_domain_alloc(struct etnaviv_gpu *gpu) return NULL; domain->ops = &etnaviv_iommu_ops; + domain->geometry.aperture_start = GPU_MEM_START; + domain->geometry.aperture_end = GPU_MEM_START + PT_ENTRIES * SZ_4K; ret = domain->ops->domain_init(domain); if (ret) diff --git a/drivers/staging/etnaviv/etnaviv_mmu.c b/drivers/staging/etnaviv/etnaviv_mmu.c index 48a0818a3788..51d91e3d30ed 100644 --- a/drivers/staging/etnaviv/etnaviv_mmu.c +++ b/drivers/staging/etnaviv/etnaviv_mmu.c @@ -109,7 +109,9 @@ struct etnaviv_iommu *etnaviv_iommu_new(struct drm_device *dev, mmu->domain = domain; mmu->dev = dev; - drm_mm_init(&mmu->mm, 0x80000000, SZ_1G); + drm_mm_init(&mmu->mm, domain->geometry.aperture_start, + domain->geometry.aperture_end - + domain->geometry.aperture_start + 1); iommu_set_fault_handler(domain, etnaviv_fault_handler, dev);