From patchwork Fri Sep 4 15:55:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 249119 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp1530445ilg; Fri, 4 Sep 2020 08:55:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcVP9lhoDUiIVVzktwpSrcBJceuAXaNdsOgmKravyPaH5kPJGTZJSMT/GLeKXnkAxo9HV+ X-Received: by 2002:a17:906:d11a:: with SMTP id b26mr7740245ejz.191.1599234950630; Fri, 04 Sep 2020 08:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599234950; cv=none; d=google.com; s=arc-20160816; b=duYQrT6GBjVAKxjv1avEtQH+izxXNeEVIuzcEfeTGGYzCAu+Y/SIs2iO1CPJqvTPwd goH1K2o/0xCcHldlbQ+3ixZIgCegfs0rQo+nhvxY4VJ+0KNvLqqz/JWelA3YbXKmyr+K UgnB/0ZRt1yCk5BYptwRoZFTbHSv6mN/JjRm6lecTA6bdJdkiQO6cCzvi6qAGtqmjm/T sxp1GkvsfksBWS2VOh1qiqBIRMSFS0bzJHM1vTAybxWFl+qd+J29HfrQryc1nsPZTSHQ /5NS0qinoW5NbQq33GGYGbV3Wat/0IdjoYj7HgZOojK1XVkEKrVSCeyjBU4VrVdFO6Qk dzFA== 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=0v297U/cjZcENyr/KxkowsDOx7QGg9WLuceh9hh33JR6Uo31sfA28Rx4Dy8hNhHyl7 EkRH0lJ6Mn8K6L20xPLjZGnQ4qHsrlGm3P8RCvzzl0gmcIdb80PbW784OJi7Powxox59 XO78zgxoxnAuvhvONdiOp/6WSliegyMYD7YJIC6UjwI5x1vPdfyjah9Jca3/Aiic88oi Bd07rU08C4e8wlzzxxhMllQ87NCLx3lTxIAQWNVae8u4f3idtBHwkpMsxvchcohGiwc5 eVfBnU8JuKcCoIs3w0Q8N6VwOGxrmvbCl55XpeIi6U3kiRQykfxXWWRH80S82IxIWzMo k8eg== 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-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 l17si4410481ejc.226.2020.09.04.08.55.50; Fri, 04 Sep 2020 08:55:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1726947AbgIDPzt (ORCPT + 15 others); Fri, 4 Sep 2020 11:55:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726979AbgIDPz0 (ORCPT ); Fri, 4 Sep 2020 11:55:26 -0400 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3504C061262 for ; Fri, 4 Sep 2020 08:55:23 -0700 (PDT) Received: by mail-qv1-xf41.google.com with SMTP id f11so3243602qvw.3 for ; Fri, 04 Sep 2020 08:55:23 -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=cxHMezF7XWFjF+yfaZU9Vsjokttn7Xfj5bLZ8eDfFRFPpFgnjEwcEmSHqTKPEKW22v C86PRX6obUI2a+BHbqrYF5k+ZZJ9+tHIAAy0e4XOId0wms/nMdpd2XSZJyP53gMfIr/G WW5pKxU+obN5z9YWNxe28NrIysNfhNhVNVvb4dbOYNU+0WqdpnZIwjprm0YYP1aNJqOI yYiuNhMc3Odxt2Wym1QSpm4RDtO7JO0aDQdxIboh6phINBJyHUKm2EmGmYydndDp89pw xB0H081g4Xyupuo35mzPn242w0rQQB6rsV0wUmkHeaiflW3AgFesNxRDuSGF9RwgnXR/ 0Eqw== X-Gm-Message-State: AOAM530vMGAci10MPi5y94lhrB9EDTcsH0ZGjwFE7Y3JWyobcXthqkIc LC2twQH5glTSox9Y1E3Bi3G3wA== 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 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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(+) -- 2.28.0 Reviewed-by: Sai Prakash Ranjan Tested-by: Sai Prakash Ranjan 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 */