From patchwork Tue Sep 5 22:56:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 111755 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp51464qge; Tue, 5 Sep 2017 15:56:34 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4fDNrU34CLmxiwcts3eO9CRh6wizmvoYryervK9JhUzNlKH+AWASL9FI+wqnZkAxC/8e/5 X-Received: by 10.99.106.69 with SMTP id f66mr5604110pgc.425.1504652193937; Tue, 05 Sep 2017 15:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504652193; cv=none; d=google.com; s=arc-20160816; b=edvs6zK28ShlwNdaoZ9SjFM0MqzXUDcZ+2BohPfBOwIc0HA7lI0p94liLrjNqxEKX5 1YaQqUAvM69Y0NMqfR6mHXyxGGn6XXnGcEM18JkBTMBl9QDwIUfqJM6TbTAKlnct9prB 7jSpu+11zG/YZt5F1WVBMVn5Vsk9tefvataNgGB7Sg76+mQMQh6mfvvTdHazR/TOq6cA LlhpG+oakYWwulNdQlL4S4mmoplMzOJGyIYqWKhoHf6oB++FUwE1ndAo5a4bG/RXfYOI ovBDS3Ptn6U6Qb89s6QWh/Rk5qs8EvdDMUSukv1bLTF0OzzxJF0wPWfutbGpFULPYIlN pkpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=QPTobwUBx7jueqrbwItdSUozOscCpjzg/DficLz/kA8=; b=KL/xFvx7sCMrXMwTK9Qiwg27rSSEgWCShZAO+nQ24BXq9eH5PYm3usqlJ3MbWU7E6Q nrEnp59QDz87C8Tn12LgUrDLB157Jc37qOBqdWCVyg5eRxc2hJ0Bvm8c/PJT/P2LQwIj nKaytLflwbiIe4+Y/1X/ec+xi96ZLObGX/eP74IOS9V3T9SmC/7ThQNsfxE1MSK8Hf3y 9izBXqcMHOTzYWhtl3WvkpolMP87MEiB4PRx/5kdgVEfwr6f9TzToSx8A/pJ63hrijhH pIYH2T9XPMP84bKN3Ee9N7T1oG1Y05R/YEhDEF/1aaW3glqOq6Ldg1ewT2TbH05VXB4V eUyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=Z7WHkSHa; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o10si30490pgq.600.2017.09.05.15.56.33; Tue, 05 Sep 2017 15:56:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=Z7WHkSHa; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752663AbdIEW4c (ORCPT + 3 others); Tue, 5 Sep 2017 18:56:32 -0400 Received: from lelnx193.ext.ti.com ([198.47.27.77]:55010 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752226AbdIEW4b (ORCPT ); Tue, 5 Sep 2017 18:56:31 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id v85MuK2T000465; Tue, 5 Sep 2017 17:56:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1504652180; bh=hist4CFbErixW243hXxDXXWVwWqPs3f1HmVckX/tVQE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Z7WHkSHaDGGSgbZUvJBq9F+t4GK675ppv3jAhEu0vNp/z5cZOqCDc2BeG+Jn6FL2i y8D3YP5YJdXIwC4N2RJzzZHbWv7u9hCvPWxcVbkm++mxkGG7OYWOEOF3IcLqWCY+Vl GBeusl63nIPP7x31yJeb7kwvV45Uva5JML8KtyZA= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v85MuKLF014480; Tue, 5 Sep 2017 17:56:20 -0500 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 5 Sep 2017 17:56:20 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 5 Sep 2017 17:56:20 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v85MuKgM003644; Tue, 5 Sep 2017 17:56:20 -0500 Received: from localhost (irmo.dhcp.ti.com [128.247.58.153]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id v85MuK304543; Tue, 5 Sep 2017 17:56:20 -0500 (CDT) From: Suman Anna To: Joerg Roedel CC: , Tony Lindgren , Tero Kristo , Laurent Pinchart , , , Suman Anna Subject: [PATCH v2 1/2] iommu/omap: Change the attach detection logic Date: Tue, 5 Sep 2017 17:56:17 -0500 Message-ID: <20170905225618.912-2-s-anna@ti.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170905225618.912-1-s-anna@ti.com> References: <20170905225618.912-1-s-anna@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The OMAP IOMMU driver allows only a single device (eg: a rproc device) to be attached per domain. The current attach detection logic relies on a check for an attached iommu for the respective client device. Change this logic to use the client device pointer instead in preparation for supporting multiple iommu devices to be bound to a single iommu domain, and thereby to a client device. Signed-off-by: Suman Anna --- v2: No changes drivers/iommu/omap-iommu.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) -- 2.13.1 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index bd67e1b2c64e..81ef729994ce 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -805,7 +805,7 @@ static irqreturn_t iommu_fault_handler(int irq, void *data) struct iommu_domain *domain = obj->domain; struct omap_iommu_domain *omap_domain = to_omap_domain(domain); - if (!omap_domain->iommu_dev) + if (!omap_domain->dev) return IRQ_NONE; errs = iommu_report_fault(obj, &da); @@ -1118,8 +1118,8 @@ omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev) spin_lock(&omap_domain->lock); - /* only a single device is supported per domain for now */ - if (omap_domain->iommu_dev) { + /* only a single client device can be attached to a domain */ + if (omap_domain->dev) { dev_err(dev, "iommu domain is already attached\n"); ret = -EBUSY; goto out; @@ -1148,9 +1148,14 @@ static void _omap_iommu_detach_dev(struct omap_iommu_domain *omap_domain, { struct omap_iommu *oiommu = dev_to_omap_iommu(dev); + if (!omap_domain->dev) { + dev_err(dev, "domain has no attached device\n"); + return; + } + /* only a single device is supported per domain for now */ - if (omap_domain->iommu_dev != oiommu) { - dev_err(dev, "invalid iommu device\n"); + if (omap_domain->dev != dev) { + dev_err(dev, "invalid attached device\n"); return; } @@ -1219,7 +1224,7 @@ static void omap_iommu_domain_free(struct iommu_domain *domain) * An iommu device is still attached * (currently, only one device can be attached) ? */ - if (omap_domain->iommu_dev) + if (omap_domain->dev) _omap_iommu_detach_dev(omap_domain, omap_domain->dev); kfree(omap_domain->pgtable);