Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp360500pxa; Wed, 19 Aug 2020 03:29:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEEL9hYGEC1lQvTWtguwBCzDV/pkUHlTE4ndiRfrEfAk4kKLoWZ49q3k/0HNCj6DqPqvWH X-Received: by 2002:a17:906:328d:: with SMTP id 13mr25241178ejw.71.1597832981437; Wed, 19 Aug 2020 03:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597832981; cv=none; d=google.com; s=arc-20160816; b=a1SEqqrQrcT4zT0FDSQyT4Qurtf5BN0ibqHzAyQtQxP3c0v67tQKkwdRCWkP4xqJB5 3hnQr5etV9QQUE+4YmM1g1mKoh+59Rm9asz41t68gVDKUwOwv9YApiKFi/9Q0OhiFTAE acw/iKMT/yNZhVPbksEFDeGTqhbZhu0Z0KT0/D91SK2kepuWsk9UZgUsK0XT4PLArpo1 hwSnIbX4WU+prTnaWVDxzB7cGKQtnXui1+97oUdQugUevj31OPAiQlY6sueI9yo7DPsP ClByHmXj1i7ArDoSSVl5p6CPMbef8bv5IzedaK4XikD/c/DVhRr18aZHgddMstPEwFfF 1VZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=joHK0x4p3O4/e8a4EHcHVJx5ouWppSaax3jsHh1YJ/w=; b=lzmMI4E3HKrb79ty3XvsD5wZ4j8DCgWktTNMy2ewJ5aC4C2GqOKLtn5+f2ncmLECyx t4ly7+vwZcLv3gqPuzOv1FxY9EdNm7Y2NlM0cZTs3Nwsc4lz7dRoUlfBKbqHhpF3odmt 9vDQY5COqM0GRobE2RhRhMC79hPew+oPCtCaESsgMxiMHvYGeGNliQ5IcevT+6B65evi JYc+rmmsYrpfGr3Jb6TAWsGEU8wjexIBfKh8C7NjEF+w3rfZ1jiKdIHRHrJrCu0Boyvq fXrMMfxhf4bg20T/4BSd8L21f4sjawD7is+AshsdKuPjh0gTO3A9vGhRBDa5z7t1zWu7 L96g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z+nBJDT9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r25si14190018edw.333.2020.08.19.03.29.16; Wed, 19 Aug 2020 03:29:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z+nBJDT9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727098AbgHSK2k (ORCPT + 99 others); Wed, 19 Aug 2020 06:28:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:50140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbgHSK2j (ORCPT ); Wed, 19 Aug 2020 06:28:39 -0400 Received: from coco.lan (ip5f5ad5a3.dynamic.kabel-deutschland.de [95.90.213.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B2C02072D; Wed, 19 Aug 2020 10:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597832918; bh=ToWcC1fxg1trjzBqdQ1AZ/Au9BYW3af1OWhvBcf2eQA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Z+nBJDT9QcofaSVIzSl136xTiji62s1yQ3bk5kBtrdMjrrP51TPCH4lO7fid+wazi 7M2aAIJtEGNbLSw+arJawsoGoC2GMvf2fOviMctcIydMHMANCyuYFk0+Wh3UJ3yNTs DANPDoBh4Pky/Hod9KgSN9Lphpj3L5//uG+E3CZY= Date: Wed, 19 Aug 2020 12:28:32 +0200 From: Mauro Carvalho Chehab To: John Stultz , Robin Murphy Cc: Greg Kroah-Hartman , driverdevel , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Joerg Roedel , Manivannan Sadhasivam , Chenfeng , linuxarm@huawei.com, Wei Xu , lkml , iommu@lists.linux-foundation.org, Rob Herring , mauro.chehab@huawei.com, Suzhuangluan , linux-arm-kernel Subject: Re: [PATCH 00/16] IOMMU driver for Kirin 960/970 Message-ID: <20200819122832.3cd5f834@coco.lan> In-Reply-To: References: <5c7918b6-c506-680b-cb0f-9e5f6a7038d9@arm.com> <20200818172909.71f5243a@coco.lan> <79f40595-7769-aa6a-fbba-53adcffca327@arm.com> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, 18 Aug 2020 15:02:54 -0700 John Stultz escreveu: > On Tue, Aug 18, 2020 at 9:26 AM Robin Murphy wrote: > > On 2020-08-18 16:29, Mauro Carvalho Chehab wrote: > > > Em Tue, 18 Aug 2020 15:47:55 +0100 > > > Basically, the DT binding has this, for IOMMU: > > > > > > > > > smmu_lpae { > > > compatible = "hisilicon,smmu-lpae"; > > > }; > > > > > > ... > > > dpe: dpe@e8600000 { > > > compatible = "hisilicon,kirin970-dpe"; > > > memory-region = <&drm_dma_reserved>; > > > ... > > > iommu_info { > > > start-addr = <0x8000>; > > > size = <0xbfff8000>; > > > }; > > > } > > > > > > This is used by kirin9xx_drm_dss.c in order to enable and use > > > the iommu: > > > > > > > > > static int dss_enable_iommu(struct platform_device *pdev, struct dss_hw_ctx *ctx) > > > { > > > struct device *dev = NULL; > > > > > > dev = &pdev->dev; > > > > > > /* create iommu domain */ > > > ctx->mmu_domain = iommu_domain_alloc(dev->bus); > > > if (!ctx->mmu_domain) { > > > pr_err("iommu_domain_alloc failed!\n"); > > > return -EINVAL; > > > } > > > > > > iommu_attach_device(ctx->mmu_domain, dev); > > > > > > return 0; > > > } > > > > > > The only place where the IOMMU domain is used is on this part of the > > > code(error part simplified here) [1]: > > > > > > void hisi_dss_smmu_on(struct dss_hw_ctx *ctx) > > > { > > > uint64_t fama_phy_pgd_base; > > > uint32_t phy_pgd_base; > > > ... > > > fama_phy_pgd_base = iommu_iova_to_phys(ctx->mmu_domain, 0); > > > phy_pgd_base = (uint32_t)fama_phy_pgd_base; > > > if (WARN_ON(!phy_pgd_base)) > > > return; > > > > > > set_reg(smmu_base + SMMU_CB_TTBR0, phy_pgd_base, 32, 0); > > > } > > > > > > [1] https://github.com/mchehab/linux/commit/36da105e719b47bbe9d6cb7e5619b30c7f3eb1bd > > > > > > In other words, the driver needs to get the physical address of the frame > > > buffer (mapped via iommu) in order to set some DRM-specific register. > > > > > > Yeah, the above code is somewhat hackish. I would love to replace > > > this part by a more standard approach. > > > > OK, so from a quick look at that, my impression is that your display > > controller has its own MMU and you don't need to pretend to use the > > IOMMU API at all. Just have the DRM driver use io-pgtable directly to > > run its own set of ARM_32_LPAE_S1 pagetables - see Panfrost for an > > example (but try to ignore the wacky "Mali LPAE" format). > > Yea. For the HiKey960, there was originally a similar patch series but > it was refactored out and the (still out of tree) DRM driver I'm > carrying doesn't seem to need it (though looking we still have the > iommu_info subnode in the dts that maybe needs to be cleaned up). Funny... while the Hikey 970 DRM driver has such IOMMU code, it doesn't actually use it! The driver has a function called hisi_dss_smmu_config() with sets the registers on a different way in order to use IOMMU or not, at the hisi_fb_pan_display() function. It can also use a mode called "afbcd". Well, this function sets both to false: bool afbcd = false; bool mmu_enable = false; I ended commenting out the code which depends at the iommu driver and everything is working as before. So, I'll just forget about this iommu driver, as we can live without that. For now, I'll keep the mmu code there commented out, as it could be useful on a future port for it to use io-pgtable. - Robin, Can the Panfrost driver use io-pgtable while the KMS driver won't be using it? Or this would cause it to not work? My end goal here is to be able to test the Panfrost driver ;-) Thanks, Mauro