From patchwork Mon Apr 25 15:58:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 8930311 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EE919BF29F for ; Mon, 25 Apr 2016 16:01:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 29E6620165 for ; Mon, 25 Apr 2016 16:01:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B75B201EC for ; Mon, 25 Apr 2016 16:01:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1auivK-00060g-02; Mon, 25 Apr 2016 15:59:46 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1auiuf-0005DH-Jk for linux-arm-kernel@lists.infradead.org; Mon, 25 Apr 2016 15:59:06 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id C52FA6134B; Mon, 25 Apr 2016 15:58:46 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9203561349; Mon, 25 Apr 2016 15:58:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from blr-ubuntu-32.ap.qualcomm.com (unknown [202.46.23.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: sricharan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B261D6131D; Mon, 25 Apr 2016 15:58:42 +0000 (UTC) From: Sricharan R To: will.deacon@arm.com, robin.murphy@arm.com, joro@8bytes.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, laurent.pinchart@ideasonboard.com Subject: [RFC 7/9] drivers: iommu: Add a new add device api Date: Mon, 25 Apr 2016 21:28:12 +0530 Message-Id: <1461599894-1969-8-git-send-email-sricharan@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1461599894-1969-1-git-send-email-sricharan@codeaurora.org> References: <1461599894-1969-1-git-send-email-sricharan@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160425_085905_836453_5EB8223A X-CRM114-Status: GOOD ( 14.46 ) X-Spam-Score: -2.9 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sricharan@codeaurora.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 Associating a master with an group happens when the master is added to the bus, notified with BUS_ADD_DEVICE. But the iommu has to be ready before this using early iommu registration and also master should have been added to the iommu using xlate. So, when trying to get rid of the early registration and using late probing for iommu devices to sort out the probing order, the newly added api is meant to be called during the late probing to add the master to iommu. Signed-off-by: Sricharan R --- drivers/iommu/iommu.c | 12 ++++++++++++ include/linux/iommu.h | 1 + 2 files changed, 13 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index bfd4f7c..a0dd01f 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -900,6 +900,18 @@ static int remove_iommu_group(struct device *dev, void *data) return 0; } +int iommu_bus_add_dev(struct device *dev) +{ + const struct iommu_ops *ops = dev->bus->iommu_ops; + int ret = -ENODEV; + + if (ops->add_device) + ret = ops->add_device(dev); + + return ret; +} +EXPORT_SYMBOL_GPL(iommu_bus_add_dev); + static int iommu_bus_notifier(struct notifier_block *nb, unsigned long action, void *data) { diff --git a/include/linux/iommu.h b/include/linux/iommu.h index a5c539f..018cfc8 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -271,6 +271,7 @@ struct device *iommu_device_create(struct device *parent, void *drvdata, void iommu_device_destroy(struct device *dev); int iommu_device_link(struct device *dev, struct device *link); void iommu_device_unlink(struct device *dev, struct device *link); +int iommu_bus_add_dev(struct device *dev); /* Window handling function prototypes */ extern int iommu_domain_window_enable(struct iommu_domain *domain, u32 wnd_nr,