From patchwork Wed Apr 11 18:55:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10336441 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 11CB86053B for ; Wed, 11 Apr 2018 18:55:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFBE7205FC for ; Wed, 11 Apr 2018 18:55:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E485A27E63; Wed, 11 Apr 2018 18:55:24 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,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 99FE5205FC for ; Wed, 11 Apr 2018 18:55:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 67E716E6F3; Wed, 11 Apr 2018 18:55:21 +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 5BC6F6E6F1; Wed, 11 Apr 2018 18:55:19 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 0E6E960FEA; Wed, 11 Apr 2018 18:55:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523472919; bh=XQNJqCBtl/6Uj/KdimKX+0Bd3/O6yV2nWfDoh0rjqXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H+J9Ttk2cRUfwuq+clsfh0d3RXMxm1aDRDBLYrHMykAIeQf1lqrehiukiryC3v4OM lQvsTQ2blMfdM3b7LEeLhAnAZ6sgD2ENhGg1FyhuVMqxbL/K+qpUmuoyzoyVEPaG2G rtLdbBYsBHACq7lIkigAZmfnxhvn1gPJtFBFdhEY= 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 4AB5C60F78; Wed, 11 Apr 2018 18:55:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523472918; bh=XQNJqCBtl/6Uj/KdimKX+0Bd3/O6yV2nWfDoh0rjqXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CqDF6AYKbSvS+tuE9A/2rBjaWlbdOd2jKsq9ApvV4JHZSeGtTm2IabjFjPekuSCPD LFSfDar2yJ0cGbNNQQchF7nD49tjG/oX1byZBgfuB4Mj3SfFaNgMnHfk/89plDahE+ 7XRMsHDQTmMKUVW63EWXwTBr2oYsLk0OiZqzOZek= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4AB5C60F78 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: will.deacon@arm.com, robin.murphy@arm.com Subject: [PATCH 2/2] iommu/arm-smmu: Add list of devices to opt out of DMA domains Date: Wed, 11 Apr 2018 12:55:10 -0600 Message-Id: <20180411185510.11594-3-jcrouse@codeaurora.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180411185510.11594-1-jcrouse@codeaurora.org> References: <20180411185510.11594-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: linux-arm-msm@vger.kernel.org, iommu@lists.linux-foundation.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.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 Add a list of compatible strings for devices that wish to opt out of attaching to a DMA domain. This is for devices that prefer to manage their own IOMMU space for any number of reasons. Returning ENOTSUPP for attach device will filter down and force arch_setup_dma_ops() to not set up the iommu DMA ops. Later the client device in question can set up and attach their own domain. Signed-off-by: Jordan Crouse --- drivers/iommu/arm-smmu.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 69e7c60792a8..09fa03a15f4f 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1187,6 +1187,15 @@ static int arm_smmu_domain_add_master(struct arm_smmu_domain *smmu_domain, return 0; } +/* + * This is a list of compatible strings for devices that wish to manage their + * own IOMMU space instead of the DMA IOMMU ops. Devices on this list will not + * allow themselves to be attached to a IOMMU_DOMAIN_DMA domain + */ +static const char * const arm_smmu_dma_blacklist[] = { + "qcom,adreno", +}; + static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) { int ret; @@ -1209,6 +1218,20 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) if (!fwspec->iommu_priv) return -ENODEV; + /* + * If this is the dfeault DMA domain, check to see if the device is on + * the blacklist and reject if so + */ + if (domain->type == IOMMU_DOMAIN_DMA && dev->of_node) { + int i; + + for (i = 0; i < ARRAY_SIZE(arm_smmu_dma_blacklist); i++) { + if (of_device_is_compatible(dev->of_node, + arm_smmu_dma_blacklist[i])) + return -ENOTSUPP; + } + } + smmu = fwspec_smmu(fwspec); /* Ensure that the domain is finalised */ ret = arm_smmu_init_domain_context(domain, smmu);