Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp37225pxa; Tue, 18 Aug 2020 15:05:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4RuZo30rD3hNoEC/1z4rizcSVMeYoNarWR9Od0XXB2Jp8aFvIJMExtAWWNEDOQo6o/LGC X-Received: by 2002:a17:907:42cc:: with SMTP id nz20mr22763612ejb.429.1597788311414; Tue, 18 Aug 2020 15:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597788311; cv=none; d=google.com; s=arc-20160816; b=0ZmEO2JUl5dPqr4+z/CyXe3GVmxvaBTB3k7MVS6UjrIVu0XlwEzVaoWJx7tdzUasss bTpY4vBcVRzDaLCvHWpR4XCwPH9k83kF+IZNSI/+ZkPbxA0sq73yKJGRpCYtM33dfMRV MbhOxG/nXbCl5ws45rlND0lmS8bCfuQJzleYYWXTKFDGocxepwDDJqi3TrZF5+Jbuxrv stsM/SHhy65BnrWk6wgh+ffMpiJz3vCzI1WdosUQ0OjVbotrkZ1t40GYS19ozMB4dhgw DD6RqfQ7Donl2l9ZGxHfHTzXEqXu2c+KH4zmNGTIoxubWgoNa5XgmPhhIdhpHSvqrjtI SROQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=diQpwa3braoDFIWAByVDgaoQfS004fXuMypoBUCVdtk=; b=0AX3TFAcrybwgEytBewJp+HRmSd2sn+IZ/nRu/RMrdzAD/0pphDVhmmOJpyCigeRxI ssSiQfyQ05wHmnvdZlOroUzJpmILiTr7r4MK0aLLK0yA+D28JlfvaA5Fky5Fo3OhS0KR rpl4i7JwJMeBLosdAcPUu19wR3yUAKvOiujTlAGXIqxFk2rzziP9uaqqWjyK8XbyMLSg gVEeTyx/xC3a74JhjLPubCbuL0GN1VxQp5OSqApRrPJd8c/nHlXQV0eDLZPeHn06GnDv ZvNjXv9osiWE1UP+8GZX1fUykvvBExhNle27kccAknM58kUj/W2LHEyb5w9zWXqKOi1c ofdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b0VdabeT; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si14937638eju.364.2020.08.18.15.04.40; Tue, 18 Aug 2020 15:05:11 -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=@linaro.org header.s=google header.b=b0VdabeT; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726838AbgHRWDJ (ORCPT + 99 others); Tue, 18 Aug 2020 18:03:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726747AbgHRWDH (ORCPT ); Tue, 18 Aug 2020 18:03:07 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F39FC061342 for ; Tue, 18 Aug 2020 15:03:07 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id l204so19293062oib.3 for ; Tue, 18 Aug 2020 15:03:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=diQpwa3braoDFIWAByVDgaoQfS004fXuMypoBUCVdtk=; b=b0VdabeT3wDVIbsWC3+UUFu/XIeQMDjK+Xkxa9ATJN7g6hRVTbi7XDjpV5TPaXfGmT wCslWgKlUXSyClpdNtyCqXZhL8SHL1wLFyVVbHWqLxWhH354vCXo69U7GQLCdiGKgJTk qsn7lgRuF4gN2odTDj14Cj6eeH9USU6CdxJdFtpXQsbmo9fA7Bzxyr8zqr4Tho5Mlacg NNBUaVOoobOAL4BO/aK64cIbDncboXoxOXNIwdZS7zVuFJy7fVFc5rfAYnrB5O8feCmD xIq+FyJqN/khbmBqaIvmo3ds1WTecSqZPFQhBYfsn8tMHwNAklxW5j52iXCStxFayCQ8 JtwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=diQpwa3braoDFIWAByVDgaoQfS004fXuMypoBUCVdtk=; b=nIA6gwnE3Yin4XWV44jnYzHQiRVRr9zDLmKLz00WdAz7IHD+7V1aRJIetleLA+4JkM vqgvx/uvQph6xEq49KQo9DnsPLpflOx+8PdzB6dtHyhIE+ciFWm/qhObB8HaURQLZxks lsvdnh7GlFtWJSaX7DSthDQWGGYTHRe5jHG3MHWdyEcWLuMVUDpt5DW5qLm9M8eNIzkE +hREAUv5Sqz58vxmEScIHhaVOioM+XWHWC2WJLWffz7meJVsgR0uirI3PPT+h8qZixR9 zP0od+VtQm4jd+lOiOxpqW5Y+WbtY+HFtap7XV6A7TuQJzQpmqRHcyLLXKoKQybwfib8 v0TQ== X-Gm-Message-State: AOAM530g2HRIllkqroQyl6jzx8ctij5I9mTgO4P1h2oTDI1r7fTLgS1Q t8qoDLWw1FxS4e0Zq6XCi8ocAoWAkaJLrKB1hC2IUA== X-Received: by 2002:aca:dc85:: with SMTP id t127mr1404925oig.169.1597788185528; Tue, 18 Aug 2020 15:03:05 -0700 (PDT) MIME-Version: 1.0 References: <5c7918b6-c506-680b-cb0f-9e5f6a7038d9@arm.com> <20200818172909.71f5243a@coco.lan> <79f40595-7769-aa6a-fbba-53adcffca327@arm.com> In-Reply-To: <79f40595-7769-aa6a-fbba-53adcffca327@arm.com> From: John Stultz Date: Tue, 18 Aug 2020 15:02:54 -0700 Message-ID: Subject: Re: [PATCH 00/16] IOMMU driver for Kirin 960/970 To: Robin Murphy Cc: Mauro Carvalho Chehab , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). thanks -john