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: 10336455 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 7B7E660540 for ; Wed, 11 Apr 2018 18:55:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AF8E279E0 for ; Wed, 11 Apr 2018 18:55:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F70127F85; Wed, 11 Apr 2018 18:55:47 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable 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 BDEC2279E0 for ; Wed, 11 Apr 2018 18:55:46 +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=d1SNA5wMxZcl4AX+bJ9j+c4766lxpQjmpdVUnpPZbT4=; b=JhA0/3M/FXrQzyvDSAUZRlOo2P Xv+K52kDzyRyAi+GCQadVTtJ42UCpVZ4Wdf7CIEyigSU/vak+3OxxE6ACAVcX3M1tKitFAbaIRejx idfMldgdZ/DEYNfdQAJs0jsHt7/avFPEGl7q828nGzxl9EuLN/KB/3kq8kk3yKYPGrgYrExPVkGQE HGhM/lXb4dNbMwIB/xyG8fBvidM/CEkcTXcI00Y7e/hBvD0jTaP0MHMzFGkFKFaxFmsC28/BntmJb 38VcNXGK9WyviZXiedJDzghs/mWcWiP6nqWiYUCchlNySzY4ILbbJUNbxXU7uuC5THoPGQhUr579T h5bSmUpA==; 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 1f6Ku3-000364-FU; Wed, 11 Apr 2018 18:55:31 +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 1f6Ku0-0002tG-0B for linux-arm-kernel@lists.infradead.org; Wed, 11 Apr 2018 18:55:30 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id CA4CC60FEC; 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=1523472920; bh=XQNJqCBtl/6Uj/KdimKX+0Bd3/O6yV2nWfDoh0rjqXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n+VS4tIzCcsgw2s8IUUYOq002wm018W/e0wKyjzaWHhgCI3ABoGGMlWDtXezLjGXe 036yltJEbbvVl6Qv4mRslQrval9pyfNbiGUXv3ntasIxNHmzBNuuIHHxs4RHeSw6AZ KjmXO5+pUalHXoD4xhFO/kSNIVIODYWcbLr175ow= 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180411_115528_135672_E6E3EF88 X-CRM114-Status: GOOD ( 18.17 ) 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: linux-arm-msm@vger.kernel.org, iommu@lists.linux-foundation.org, dri-devel@lists.freedesktop.org, robdclark@gmail.com, freedreno@lists.freedesktop.org, 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 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);