From patchwork Fri May 18 21:35:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10412329 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 6903F6031B for ; Fri, 18 May 2018 21:42:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57C3328ABD for ; Fri, 18 May 2018 21:42:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C42628AF6; Fri, 18 May 2018 21:42:38 +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 CB55828ABD for ; Fri, 18 May 2018 21:42:37 +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=zIisWIWx/26cBcesgEoqXNaV3UJTt6yj+4ymOwIYJTY=; b=LSXXd4zFbpl/DHZlaOqKNWS0zd XWEZZq1iGe970q5xw5StnV+5uhLjCt8oUJUsaBNL07Y73k6FHsr8/Sg3LyHCUZU6pUYBG348m9odl o+inmN95yCMn9tmbhcK6VtwBvmmafVHQOVFHzo5O1yaMWMfPyN2yi2s6JR6Nt7q7l94aOlfqaXm42 7jlXkjm2Wv3GoFl3zh+NcustO1HLt+tRCYTrk3P5eraMPy9mf6Th+qt78UunCqQs5DgSyRwWK9lau fCinu69KyqYy2ZUZ2TfSbYOSNfseDJhTySkO1jFHOFHRll3zpcizo3OHqOr/eVYgdfICTrAdga+R1 SE1/qSmw==; 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 1fJn8x-0005Qp-KZ; Fri, 18 May 2018 21:42:31 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJn8v-0005Lp-5y for linux-arm-kernel@bombadil.infradead.org; Fri, 18 May 2018 21:42:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=qtB+u0MGncN5fEXddIhqbhklNGg7u+6+ErZqnPmsT18=; b=MAce/0++g65dHtOlQo6ugBLgo vwcmMbhRekAkw/inHeNxkGcDy+CtOVTzwsH1A0hzzQf36Laf1yplYOGrUSOUykfxNpuVydDIr6AjK sU+1reHFwugyzQvKDI5OJ5TG19KnD5s5QgGGFuD9Py802HsytkhhaB8K4wMOQ+0bBK3c0Z3z9UJ6O LDz07oXjkErg3O209zwP5tyGrAbwxxEx9YPYU9vI8WizaJdppKR7WoWmwNVwDnN+x9U4eoFmHSkPc tUmuBTDdkwxsUTYyn4bmD2JAal68j7DNc4BcGwOw/3nIPq8qw3XbZFLZ4sNeboNSGaMZ4dypscI7W tZk8XHqzg==; Received: from smtp.codeaurora.org ([198.145.29.96]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJn2Q-0001hL-OC for linux-arm-kernel@lists.infradead.org; Fri, 18 May 2018 21:35:49 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D5A936114D; Fri, 18 May 2018 21:35:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526679332; bh=hAXSV+VdEjutpFP101q2WpDrBjq5rXUZtpxGA99gQik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e1obLfibvCHS8n5WVywCvGl8M1mL7EUaDNk+2uJSo6AUIQEE1deZ6hDIAwORclNVL LlqlulGKrV4vZWORnSGHxKXP4KjkWm83VnENJjR1A59DNOTiMeowMk2tSR+d4YmxVF UPGqKmMX8o/amcSqG0N5M+0qTpdwbE/2JgaoKeRU= 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 D86EA61134; Fri, 18 May 2018 21:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526679320; bh=hAXSV+VdEjutpFP101q2WpDrBjq5rXUZtpxGA99gQik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qo7itfdW4S37EEdd3ghE6IM8XJ0weHetWR/ZSMVPmhnQneiM5PRtfQqCI2UmTttyB 0IB9Dw0YCllMEkzhsGZ9NQi5Wg0C0ZWF63OJf1wGmHue+FTngB2YNcSQZGwd635FRg wX/ICymzLkfz9fjm5tDkScFMAByPaZCoDzLa+UgE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D86EA61134 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 16/16] iommu/arm-smmu: Add list of devices to opt out of DMA domains Date: Fri, 18 May 2018 15:35:00 -0600 Message-Id: <20180518213500.31595-17-jcrouse@codeaurora.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180518213500.31595-1-jcrouse@codeaurora.org> References: <20180518213500.31595-1-jcrouse@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180518_223547_066315_0946BB6A X-CRM114-Status: GOOD ( 18.41 ) 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, dri-devel@lists.freedesktop.org, tfiga@chromium.org, iommu@lists.linux-foundation.org, vivek.gautam@codeaurora.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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 100797a07be0..df6e4eacf727 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1080,6 +1080,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, goto out_unlock; cfg->cbndx = ret; + if (smmu->version < ARM_SMMU_V2) { cfg->irptndx = atomic_inc_return(&smmu->irptndx); cfg->irptndx %= smmu->num_context_irqs; @@ -1450,6 +1451,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 *arm_smmu_dma_blacklist[] = { + "qcom,adreno", +}; + static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) { int ret; @@ -1472,6 +1482,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);