Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1420659pxk; Fri, 4 Sep 2020 08:59:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCrnn0bU8aDopxO9FY0JR2vGO7wLTqWPSoUqXUc4fSt9/Vo+MxFLvdTXw9s7unm6nLAMKw X-Received: by 2002:a17:906:2704:: with SMTP id z4mr7841958ejc.350.1599235165007; Fri, 04 Sep 2020 08:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599235165; cv=none; d=google.com; s=arc-20160816; b=q0KutVYsCvhLPSIreT7keOhWYgcPIKoq6WeL8ptCZYLj0gYOP/SXg10SkTndDg8Zt/ B/g0lwWY8OklKCe9+Zpnxs9mDe2sRvsGRNZEZzbjmlN3f6F4dfKEUKStWGvGRiiu967+ 5RxGUeGd0VmopWNzANw9pY5OGH9WEb/LzLWvuqJpX7Yz+pjpyu6iK6JefZixKBy5Hdk1 /IRGS8IG0RchlCxKr+naD6xzLH0xRKGNCmk4jdMDCs5CikIw5qFXM9FSUx5pqmfPtwhe CbeBv4+lt6WedlxdzDQg7ubcfuH++5J8sPrFGsXPuT4DJyWZP1IAMJiPX3k+DsTLaQn4 VQBQ== 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:date:subject:cc:to:from :dkim-signature; bh=I9v8itQxrG/5qOmlIkuGPstFjTonnbsCxHmLWx5pBPk=; b=ZomzHsKxHZaXnLpjJu31WzydXeTvvVCM2IxJSdgIhULzNPePs+iyCHNtxJRy0NjwzU paCgr9fJXm/nQzefc7C6dZhbcRD1goawbfLZp3f3vltn3b45rp/pnpmbZaG2EZ32yg1s cXmdYyJ2H2D8OLHOtV3vCt4Jfhbdygw1zkjLqJFRg9WWIJYHtluupvKxL798Vw9cXPs/ r9R2g7eJHHQJ4x4AqNp0lPt34KRj6OkxQLw3e6eyLr0YBJw2nQO3VORIdsKfJ4U90wUC G60n1tuv0/aMyG462cZRNfzLfS9DSW21Lx0HkUL1ShTQW5/tVKpfPuSz7+JFKukXy4UW VBzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fH/8s/Vs"; 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 g2si4336045eji.132.2020.09.04.08.59.01; Fri, 04 Sep 2020 08:59:24 -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="fH/8s/Vs"; 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 S1726971AbgIDPzt (ORCPT + 99 others); Fri, 4 Sep 2020 11:55:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726984AbgIDPz0 (ORCPT ); Fri, 4 Sep 2020 11:55:26 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4262BC061247 for ; Fri, 4 Sep 2020 08:55:24 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id x7so3235306qvi.5 for ; Fri, 04 Sep 2020 08:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I9v8itQxrG/5qOmlIkuGPstFjTonnbsCxHmLWx5pBPk=; b=fH/8s/VsjUJd9NSfQnY9KSqjr01isFkiTOEHv966Pm+qJr0SntP+xw7DkVPurY+FVA TGhOoJlnm9Ues2qE+3G7rkDWz7QaZWbR3ioFcET9S2eEFANNMRSLMlEwWT+67pEu3h/J gtFEX/W6HDjTk/bNacLk+NKv/yYQfcg4gHrZ8cvLLQd7heB4VMYFsmq5HuYBHzojcJzM jvbXrNuQYord9V5/QeTX2bg15dsqvN7uIXH2fypYBVmveFk3IlBSq5h0rr0SsYd92wbL r3AXp+pONiHH4M+LMJeGIBSd2WYLFWvUSPInCsoZgV6fJqA9+OEe5uEsFaU2oP25C6v1 PfpQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=I9v8itQxrG/5qOmlIkuGPstFjTonnbsCxHmLWx5pBPk=; b=Opyomir3Dt1ZBlpZluIEAyxNtFGGwQq0B5jESti2/D/qswfPjNe78R/IRINYXoCFME IjbZ7CNsomIEngTzRMORFVLbUyqlI3uQ5jqI60EcKZPJoi/YCn07XtyjalFGNHVsRW/z 4KhXzJD4FCO45GMhPWzi1ODuJsHscUXkb682Ij7OI4+gKbhbOfhya9W606Vxt8oWAozJ qA0ESoNdWI1RS3+NjP+AjBOv/L31A4ipSpu4CAkS8iSAle9+4dBU762iG/F41I7S26Um wBSXXbncINwlQaiAp8tz07Z4Jzam7Q7BOx4Xn7qrznJ0ag/uk2fmE6BAo77+p8P0WbJQ 6A0Q== X-Gm-Message-State: AOAM5320l9GORbDN4Xeug0RhqSOql6dZdtM0fQu7j8r1XbCI4yuATsbI PkgTi7PjbrL2KDhjHKErDZoczw== X-Received: by 2002:a0c:c988:: with SMTP id b8mr7690156qvk.192.1599234922927; Fri, 04 Sep 2020 08:55:22 -0700 (PDT) Received: from localhost.localdomain (ec2-34-197-84-77.compute-1.amazonaws.com. [34.197.84.77]) by smtp.gmail.com with ESMTPSA id v18sm4724473qtq.15.2020.09.04.08.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 08:55:22 -0700 (PDT) From: Bjorn Andersson To: Will Deacon , Robin Murphy , Joerg Roedel , Bjorn Andersson , Sai Prakash Ranjan , Jordan Crouse , Rob Clark Cc: Sibi Sankar , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v3 7/8] iommu/arm-smmu: Provide helper for allocating identity domain Date: Fri, 4 Sep 2020 15:55:12 +0000 Message-Id: <20200904155513.282067-8-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904155513.282067-1-bjorn.andersson@linaro.org> References: <20200904155513.282067-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some platform implementations needs to be able to allocate a domain for emulating identity mappings using a context bank without translation. Provide a helper function to allocate such a domain. Signed-off-by: Bjorn Andersson --- Changes since v2: - Extracted from previous arm_smmu_setup_identity() implementation drivers/iommu/arm/arm-smmu/arm-smmu.c | 25 +++++++++++++++++++++++++ drivers/iommu/arm/arm-smmu/arm-smmu.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 4c4d302cd747..3c06146dfdb9 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -1924,6 +1924,31 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu) return 0; } +struct iommu_domain *arm_smmu_alloc_identity_domain(struct arm_smmu_device *smmu) +{ + struct iommu_domain *identity; + int ret; + + /* Create a IDENTITY domain to use for all inherited streams */ + identity = arm_smmu_domain_alloc(IOMMU_DOMAIN_IDENTITY); + if (!identity) { + dev_err(smmu->dev, "failed to create identity domain\n"); + return ERR_PTR(-ENOMEM); + } + + identity->pgsize_bitmap = smmu->pgsize_bitmap; + identity->type = IOMMU_DOMAIN_IDENTITY; + identity->ops = &arm_smmu_ops; + + ret = arm_smmu_init_domain_context(identity, smmu, NULL); + if (ret < 0) { + dev_err(smmu->dev, "failed to initialize identity domain: %d\n", ret); + return ERR_PTR(ret); + } + + return identity; +} + struct arm_smmu_match_data { enum arm_smmu_arch_version version; enum arm_smmu_implementation model; diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h index f58164976e74..fbdf3d7ca70d 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h @@ -537,4 +537,6 @@ struct arm_smmu_device *qcom_adreno_smmu_impl_init(struct arm_smmu_device *smmu) void arm_smmu_write_context_bank(struct arm_smmu_device *smmu, int idx); int arm_mmu500_reset(struct arm_smmu_device *smmu); +struct iommu_domain *arm_smmu_alloc_identity_domain(struct arm_smmu_device *smmu); + #endif /* _ARM_SMMU_H */ -- 2.28.0