From patchwork Mon May 13 14:40:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 164038 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1418297ili; Mon, 13 May 2019 07:40:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyI+y64Ysp8cBGMoHEG93kIrtFQKCet7xt3aIjKJMofFodwXMjyCjIJQ//OHQaxT2/eDx7M X-Received: by 2002:a63:5c1c:: with SMTP id q28mr31059003pgb.45.1557758417258; Mon, 13 May 2019 07:40:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557758417; cv=none; d=google.com; s=arc-20160816; b=NP5A+yQjXGHWN9hWcXofn01+xPSpiTlLBADSK9ozgJAJYYoqvia4tLUpbjZnjFQjct z8zVPiYtvKDdBB0GU2ELlhMS6nO2UGE1CAGT5BCT05T1mhSCJOVvKIFKeGfkbfzWXfQQ mBicoLniK8g/4wRNZ9aPE3+EWnalc5l+IL23Mvk5waIuMJxEZjCIoMrBU1LzCJn9MCrA lTwKOPm4Sj2e3ifWgwPModu44BcIjAF+cpTasSnuwDvSu56ZUzeOksjJoIQAxifSyDsx 5sudEnpVrTgbYGCNWq2ZRZXjag9jniQ0rqcMoivfB45PZqnVSKQfHfDrHZMMFrVgl20D aV3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :delivered-to; bh=ldnAXOAZ1K6+7gBSv3CIJPRwix1KfKl6oXgnxpRfEKQ=; b=MvO0pQTf2tvB5mwVKtdMJYvWE7Rai8rBYQidb6YKrpNA8QxtAq+Iji+GpiES/q8LCL 5tNLslw9nBORP7H0nigvXFXNC1a81JCjjF25lXbts9GW0/Yc9h71a28X61D7E+pZHVOo MIhJ3NLBh9qB12XX8BH+2IR7qlkWzMJmQUjzchbDZL5ihd0MvTeOXnr8eYeWwZvzxbS8 QQEPfnuBD7it6yjVZhaUslgejUppbO3rSNwLyhI0FC8w0tciAYBeicGjCZrsLev1QCOh mbt/SguZ83FbBTw00qkZYtFPAeHTMteblSW8pDtlfWpEJ5DdX/84nDw7RIu9ryRqSadt NQVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id 33si16741173plk.421.2019.05.13.07.40.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2019 07:40:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F87089E47; Mon, 13 May 2019 14:40:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot1-f68.google.com (mail-ot1-f68.google.com [209.85.210.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB0F189E47 for ; Mon, 13 May 2019 14:40:14 +0000 (UTC) Received: by mail-ot1-f68.google.com with SMTP id t24so3243251otl.12 for ; Mon, 13 May 2019 07:40:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4QXhGUzrbIoNUpwZknMiZhCfgmISfCPepSV3kZZrmtA=; b=Iog0AjtdBqd6vwnqiriy+UKhDAOwRDAxPg5ZjRmexCx2mR9146ADVtXeMmk4RAV7kH Otq3pdkkB7vGd+cMmCk6vqAvW7+nT5XvyFlM8QYnfjjciIOuwChdbRXIMlcRUi6IdrKs 3oo+Fro8is5bnmL+KxUz772yps/TSPT8VFx5KCWMYszQaKaKt7sE/5uUbL5FsTwh2CXC vZKEvbngYEy6I/JSeRwjc9d4lYtMiIs7qENVXnNmwMYvbE08Sn7ernd9TrrOnE9g/7DP //Y6a8nms9b6+nh2JuH/SKqMp3kDfg9nh/XJc5Gx1klOxvh26bk+fzDNJi8NNAxrM+am 2PvA== X-Gm-Message-State: APjAAAV7Wux+taA9fa/KVLkJLNodWrtpODFXjZFqdZs1fQd7nsaRUioY igqZ3K9Gm+6ol9WkGDNJw1Fxtww= X-Received: by 2002:a9d:77d6:: with SMTP id w22mr16745925otl.154.1557758413823; Mon, 13 May 2019 07:40:13 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id d5sm5513821otb.54.2019.05.13.07.40.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 13 May 2019 07:40:13 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org, Neil Armstrong Subject: [PATCH] drm/panfrost: Add AArch64 page table format support Date: Mon, 13 May 2019 09:40:12 -0500 Message-Id: <20190513144012.17243-1-robh@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Bifrost GPUs use the standard format stage 1 LPAE page tables matching the io-pgtable ARM_64_LPAE_S1 format. The one difference is the TCR or TRANSCFG register as the Mali driver calls it has its own custom layout. Signed-off-by: Rob Herring --- This and compatible strings should be enough for enabling bifrost. There's some other feature and issue differences, but I think they all either don't matter (because of differences in panfrost) or I've already handled them. This is only compile tested as I don't have h/w. Running the existing IGT tests may be sufficient to test this. We should get an error with the command stream rather than a MMU fault if this is working correctly. Rob drivers/gpu/drm/panfrost/panfrost_mmu.c | 28 +++++++++++++++++++++++- drivers/gpu/drm/panfrost/panfrost_regs.h | 3 +++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index 762b1bd2a8c2..41d184fab07f 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright 2019 Linaro, Ltd, Rob Herring */ +/* Copyright (C) 2019 Arm Ltd. */ #include #include #include @@ -111,6 +112,14 @@ void panfrost_mmu_enable(struct panfrost_device *pfdev, u32 as_nr) u64 transtab = cfg->arm_mali_lpae_cfg.transtab; u64 memattr = cfg->arm_mali_lpae_cfg.memattr; + if (panfrost_has_hw_feature(pfdev, HW_FEATURE_AARCH64_MMU)) { + transtab = cfg->arm_lpae_s1_cfg.ttbr[0]; + memattr = cfg->arm_lpae_s1_cfg.mair[0]; + } else { + transtab = cfg->arm_mali_lpae_cfg.transtab; + memattr = cfg->arm_mali_lpae_cfg.memattr; + } + mmu_write(pfdev, MMU_INT_CLEAR, ~0); mmu_write(pfdev, MMU_INT_MASK, ~0); @@ -123,6 +132,14 @@ void panfrost_mmu_enable(struct panfrost_device *pfdev, u32 as_nr) mmu_write(pfdev, AS_MEMATTR_LO(as_nr), memattr & 0xffffffffUL); mmu_write(pfdev, AS_MEMATTR_HI(as_nr), memattr >> 32); + if (panfrost_has_hw_feature(pfdev, HW_FEATURE_AARCH64_MMU)) { + /* TODO: handle system coherency */ + mmu_write(pfdev, AS_TRANSCFG_LO(as_nr), + AS_TRANSCFG_PTW_MEMATTR_WRITE_BACK | + AS_TRANSCFG_ADRMODE_AARCH64_4K); + mmu_write(pfdev, AS_TRANSCFG_HI(as_nr), 0); + } + write_cmd(pfdev, as_nr, AS_COMMAND_UPDATE); } @@ -134,6 +151,11 @@ static void mmu_disable(struct panfrost_device *pfdev, u32 as_nr) mmu_write(pfdev, AS_MEMATTR_LO(as_nr), 0); mmu_write(pfdev, AS_MEMATTR_HI(as_nr), 0); + if (panfrost_has_hw_feature(pfdev, HW_FEATURE_AARCH64_MMU)) { + mmu_write(pfdev, AS_TRANSCFG_LO(as_nr), 0); + mmu_write(pfdev, AS_TRANSCFG_HI(as_nr), 0); + } + write_cmd(pfdev, as_nr, AS_COMMAND_UPDATE); } @@ -335,6 +357,7 @@ static irqreturn_t panfrost_mmu_irq_handler(int irq, void *data) int panfrost_mmu_init(struct panfrost_device *pfdev) { struct io_pgtable_ops *pgtbl_ops; + enum io_pgtable_fmt pgt_fmt = ARM_MALI_LPAE; int err, irq; pfdev->mmu = devm_kzalloc(pfdev->dev, sizeof(*pfdev->mmu), GFP_KERNEL); @@ -365,7 +388,10 @@ int panfrost_mmu_init(struct panfrost_device *pfdev) .iommu_dev = pfdev->dev, }; - pgtbl_ops = alloc_io_pgtable_ops(ARM_MALI_LPAE, &pfdev->mmu->pgtbl_cfg, + if (panfrost_has_hw_feature(pfdev, HW_FEATURE_AARCH64_MMU)) + pgt_fmt = ARM_64_LPAE_S1; + + pgtbl_ops = alloc_io_pgtable_ops(pgt_fmt, &pfdev->mmu->pgtbl_cfg, pfdev); if (!pgtbl_ops) return -ENOMEM; diff --git a/drivers/gpu/drm/panfrost/panfrost_regs.h b/drivers/gpu/drm/panfrost/panfrost_regs.h index 578c5fc2188b..31211df83c30 100644 --- a/drivers/gpu/drm/panfrost/panfrost_regs.h +++ b/drivers/gpu/drm/panfrost/panfrost_regs.h @@ -287,6 +287,9 @@ #define AS_TRANSTAB_LPAE_READ_INNER BIT(2) #define AS_TRANSTAB_LPAE_SHARE_OUTER BIT(4) +#define AS_TRANSCFG_ADRMODE_AARCH64_4K 6 +#define AS_TRANSCFG_PTW_MEMATTR_WRITE_BACK (2 << 24) + #define AS_STATUS_AS_ACTIVE 0x01 #define AS_FAULTSTATUS_ACCESS_TYPE_MASK (0x3 << 8)