From patchwork Wed May 29 20:54:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10967683 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 610EC92A for ; Wed, 29 May 2019 20:55:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52C89288F1 for ; Wed, 29 May 2019 20:55:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46CCC289B2; Wed, 29 May 2019 20:55:13 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E3F9128965 for ; Wed, 29 May 2019 20:55:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/ujnL//4XHTRrxqh5a96Wh3KoUB78cyIomC4pX5rNDU=; b=SwfzWozeXfzPnuMnug7aaSMlg2 /2TxhS5zl5U1ggEqcB1fshs+V4rgOK3bJfIv50iWgFkMyf1jJQCbZfG7/FQ+QzikCcEWRNvwcfwZ1 5WjpBI2CqZasWrm1w9V2qu2eXCg6cnvAynLO9Prct3inpXlzd99NRChhiPar1gGoCiYuWj6PWulDz QfYdRnQGsJ8YGQTce6iMxX/hXQv8gctCv6iz2QSfSKwghknDgAfKwBbCf6q6/EkJ1b7a5ZwnunyRW Qdgd2GqVuygYnQXxlHT9HkBHDN32Dljbz6RrFGy0U5BrZ8vhi0euIu59wGRem+v8AAAxplQRnoKO1 TZXInF8Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hW5bL-0007Ej-W5; Wed, 29 May 2019 20:55:11 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hW5bI-0007Dg-Ph for linux-arm-kernel@lists.infradead.org; Wed, 29 May 2019 20:55:10 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 22FD860F38; Wed, 29 May 2019 20:55:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1559163308; bh=H1gJftayyhVU3QVkkOlFv2DhgJ/CrcDyVexTTU22x4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hjeu2/0kZjbvkGO3/IeVxpM6/31rp2Yl5IvXnFmO2WArVbb7SgyOJS1zFhZJPp3Nf sUQJ2t0R8YeoaOj9wn5hFW8ycg/DumW9EhvVQTqQvWhHWqQYh0fxgO5PgVdtKz9wu6 bSxX6ibA4dVyGQmLG0RKvFNfs7CmfzxfCOPmhVVg= Received: from jcrouse1-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 F21AB606DB; Wed, 29 May 2019 20:55:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1559163307; bh=H1gJftayyhVU3QVkkOlFv2DhgJ/CrcDyVexTTU22x4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lBBCCLNWLtMP6MTlifW0/hhWULMbqAHn8agLMArTbyVmXfLZY0mTYUbtDvXrhGJRB +rMjk9pU/Y5kmWw2na3O35JtABPJw1UFGa73g5+eW6WGZz0ZGgzD6SIKgOIL0poPBS VGANA337XjlLLCTgDmOZQgtPBQchIWcqJZaSBX0U= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org F21AB606DB 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 v3 01/16] iommu/arm-smmu: Allow client devices to select direct mapping Date: Wed, 29 May 2019 14:54:37 -0600 Message-Id: <1559163292-4792-2-git-send-email-jcrouse@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1559163292-4792-1-git-send-email-jcrouse@codeaurora.org> References: <1559163292-4792-1-git-send-email-jcrouse@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190529_135509_025445_27615C70 X-CRM114-Status: GOOD ( 12.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jean-philippe.brucker@arm.com, linux-arm-msm@vger.kernel.org, Joerg Roedel , Will Deacon , dianders@chromium.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, hoegsberg@google.com, Robin Murphy , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some client devices want to directly map the IOMMU themselves instead of using the DMA domain. Allow those devices to opt in to direct mapping by way of a list of compatible strings. v3: use iommu_request_dm_for_dev() to set up a default identity domain for a group, per Robin Signed-off-by: Jordan Crouse --- drivers/iommu/arm-smmu.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 5e54cc0..7537639 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1235,6 +1235,35 @@ static int arm_smmu_domain_add_master(struct arm_smmu_domain *smmu_domain, return 0; } +struct arm_smmu_client_match_data { + bool direct_mapping; +}; + +static const struct arm_smmu_client_match_data qcom_adreno = { + .direct_mapping = true, +}; + +static const struct arm_smmu_client_match_data qcom_mdss = { + .direct_mapping = true, +}; + +static const struct of_device_id arm_smmu_client_of_match[] = { + { .compatible = "qcom,adreno", .data = &qcom_adreno }, + { .compatible = "qcom,mdp4", .data = &qcom_mdss }, + { .compatible = "qcom,mdss", .data = &qcom_mdss }, + { .compatible = "qcom,sdm845-mdss", .data = &qcom_mdss }, + {}, +}; + +static const struct arm_smmu_client_match_data * +arm_smmu_client_data(struct device *dev) +{ + const struct of_device_id *match = + of_match_device(arm_smmu_client_of_match, dev); + + return match ? match->data : NULL; +} + static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) { int ret; @@ -1450,6 +1479,7 @@ static int arm_smmu_add_device(struct device *dev) struct arm_smmu_device *smmu; struct arm_smmu_master_cfg *cfg; struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); + const struct arm_smmu_client_match_data *client; int i, ret; if (using_legacy_binding) { @@ -1512,6 +1542,11 @@ static int arm_smmu_add_device(struct device *dev) device_link_add(dev, smmu->dev, DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_SUPPLIER); + client = arm_smmu_client_data(dev); + + if (client && client->direct_mapping) + iommu_request_dm_for_dev(dev); + return 0; out_cfg_free: