From patchwork Wed Feb 21 22:59:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10234259 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 14CBE602A0 for ; Wed, 21 Feb 2018 22:59:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0628428534 for ; Wed, 21 Feb 2018 22:59:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECE272856B; Wed, 21 Feb 2018 22:59:57 +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=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 70AD928534 for ; Wed, 21 Feb 2018 22:59:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 205CA6EACD; Wed, 21 Feb 2018 22:59:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) by gabe.freedesktop.org (Postfix) with ESMTPS id D948E6EABC; Wed, 21 Feb 2018 22:59:44 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 882E9610D5; Wed, 21 Feb 2018 22:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519253984; bh=Oi0SFTcyUXO8iPEOQ3rxqFbsutoUfQxTlA4t3by2vq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o8uN67EkcTwaU8ZtwTO+AIyDWOBvZmcMX6K8p/LCkybPBAHPCytKQH4cBIlDbG2+O 39/Zr6lgVtwxduGhSpQQhDMj5cj8RphBH73Jwc/UMvlBkqh8+qRJAzGIjH9i5e8wFD ti/xhkZcoRT0ijR2j0RATvbgRTkXQIHLIeWFf4SI= Received: from jcrouse-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id C89A460FF0; Wed, 21 Feb 2018 22:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519253981; bh=Oi0SFTcyUXO8iPEOQ3rxqFbsutoUfQxTlA4t3by2vq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QUQWkZ1flndBTZJQx8RBbc5USH9/STelda9frP3paLhU3/1oDpwU8mKCS9TB6DoVo pilMlIsRzq+W4tanQRjUhgcGqttDbsgTt0A/Mdi2V8dm40BeWuvjWYE0COys0qdWHe YJwq//4YDbH+ct7fcJ6iHIHvNPX2I7YWTzhoTxbI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C89A460FF0 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org From: Jordan Crouse To: freedreno@lists.freedesktop.org Subject: [PATCH 06/14] iommu: arm-smmu: Add side-band function to specific pasid callbacks Date: Wed, 21 Feb 2018 15:59:16 -0700 Message-Id: <20180221225924.30737-7-jcrouse@codeaurora.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180221225924.30737-1-jcrouse@codeaurora.org> References: <20180221225924.30737-1-jcrouse@codeaurora.org> 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: jean-philippe.brucker@arm.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, tfiga@chromium.org, iommu@lists.linux-foundation.org, vivek.gautam@codeaurora.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Just allowing a client driver to create and manage a a software pasid isn't interesting if the client driver doesn't have enough information about the pagetable to be able to use it. Add a side band function for arm-smmu that lets the client device register pasid operations to pass the relevant pagetable information to the client driver whenever a new pasid is created or destroyed Signed-off-by: Jordan Crouse --- drivers/iommu/arm-smmu.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/linux/arm-smmu.h | 18 ++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 include/linux/arm-smmu.h diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 42f5bfa3e26e..81c781705e22 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -50,6 +50,7 @@ #include #include #include +#include #include @@ -253,6 +254,8 @@ struct arm_smmu_domain { spinlock_t pasid_lock; struct list_head pasid_list; + const struct arm_smmu_pasid_ops *pasid_ops; + void *pasid_data; }; struct arm_smmu_option_prop { @@ -294,6 +297,10 @@ static void arm_smmu_pasid_free(struct iommu_domain *domain, int pasid) struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); struct arm_smmu_pasid *node, *obj = NULL; + if (smmu_domain->pasid_ops && smmu_domain->pasid_ops->remove_pasid) + smmu_domain->pasid_ops->remove_pasid(pasid, + smmu_domain->pasid_data); + spin_lock(&smmu_domain->pasid_lock); list_for_each_entry(node, &smmu_domain->pasid_list, node) { if (node->pasid == pasid) { @@ -386,6 +393,26 @@ static int arm_smmu_pasid_alloc(struct iommu_domain *domain, struct device *dev, obj->domain = domain; obj->pasid = pasid; + if (smmu_domain->pasid_ops && smmu_domain->pasid_ops->install_pasid) { + int ret; + u64 ttbr; + + if (smmu_domain->cfg.fmt == ARM_SMMU_CTX_FMT_AARCH32_S) + ttbr = pgtbl_cfg.arm_v7s_cfg.ttbr[0]; + else + ttbr = pgtbl_cfg.arm_lpae_s1_cfg.ttbr[0]; + + ret = smmu_domain->pasid_ops->install_pasid(pasid, ttbr, + smmu_domain->cfg.asid, smmu_domain->pasid_data); + + if (ret) { + free_io_pgtable_ops(obj->pgtbl_ops); + kfree(obj); + + return ret; + } + } + spin_lock(&smmu_domain->pasid_lock); list_add_tail(&obj->node, &smmu_domain->pasid_list); spin_unlock(&smmu_domain->pasid_lock); @@ -2046,6 +2073,19 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu) return 0; } +void arm_smmu_add_pasid_ops(struct iommu_domain *domain, + const struct arm_smmu_pasid_ops *ops, void *data) +{ + struct arm_smmu_domain *smmu_domain; + + if (domain) { + smmu_domain = to_smmu_domain(domain); + smmu_domain->pasid_ops = ops; + smmu_domain->pasid_data = data; + } +} +EXPORT_SYMBOL_GPL(arm_smmu_add_pasid_ops); + struct arm_smmu_match_data { enum arm_smmu_arch_version version; enum arm_smmu_implementation model; diff --git a/include/linux/arm-smmu.h b/include/linux/arm-smmu.h new file mode 100644 index 000000000000..c14ca52231bf --- /dev/null +++ b/include/linux/arm-smmu.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2018, The Linux Foundation. All rights reserved. */ + +#ifndef ARM_SMMU_H_ +#define ARM_SMMU_H_ + +struct iommu_domain; + +struct arm_smmu_pasid_ops { + int (*install_pasid)(int pasid, u64 ttbr, u32 asid, void *data); + void (*remove_pasid)(int pasid, void *data); +}; + + +void arm_smmu_add_pasid_ops(struct iommu_domain *domain, + const struct arm_smmu_pasid_ops *ops, void *data); + +#endif