Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp978873pxf; Thu, 25 Mar 2021 20:25:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7Mhpfu70cC7FW4oWSYcPDcXRd9HOKQkhZZ6jyozpRkzxmEUUq3a44Y4WUd7jQWvSbtBpj X-Received: by 2002:a17:906:314f:: with SMTP id e15mr12983675eje.30.1616729122019; Thu, 25 Mar 2021 20:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616729122; cv=none; d=google.com; s=arc-20160816; b=btH59VKajilITD6jplbOlY5bBCBklV1EZYQYAUMcm9FYxkEaF3lCiWf/ppY+dXCRmV Fz8oAIRV3sBZ/uTRdjBgH+XPc3BnYp8OmwDa0lTmuWD46gKP4RKUvcyfZP/sq9crOUKb mXduPWcMZ3gw0N4zebz/nxNmc+saL9b1dbZc94Q8OM2bLNhw5g7w7YdyZX8yQa8KJRQm Z/b89bqsuvP20jAmIV3wn9qJT7w0/x4BvhUoXUdonWEyVCLxxSgwEtfuIW9n8ZsWG83m UZRwVQljJxnDVRtDD0EuBR3OAsXnNhvEox9ZzlxUbucxenfx3F/t4W7FGiLRYzfZmxAR pUhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Y3Ws5SEmnlhTq7Q67/k0yuQU3MsXSCy5jyz6EyxVocM=; b=AUrwYWlEdm7sgzcoQVCp48qn5CXKSJqeAC9ZQjbvAXebkJNqIw6+Ea6nnXR7kiba+Q EnRFON/bMbNry5k3ki7jp65wyHLUWSLpps4pTfLaftik/m9sL1PIfagIrkNd4PZBv6XP ZuQpXMLmLQwsIiLcnBwO4YUwUkl8Gxn46h0XY79psL1CAHAKP47wlwDfkLCCwJ7ZeD+1 14Kkooane8WRbQq71VE4HY3Pag0FEQY87p5qFjlXibfpT2cbRKjuYCwVgPfu6+MhyBkz nKGIqcAccriU0utCudiZshmwoWGBrJOC4+FvQz7hRjtW3+6U5PJirPZgoY4VagxAqAxw F86g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h19si5394547edb.134.2021.03.25.20.24.59; Thu, 25 Mar 2021 20:25:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230266AbhCZDYU (ORCPT + 99 others); Thu, 25 Mar 2021 23:24:20 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:48847 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230247AbhCZDX7 (ORCPT ); Thu, 25 Mar 2021 23:23:59 -0400 X-UUID: e82e9daa0a1d4db4acd0e4cdf021b3b5-20210326 X-UUID: e82e9daa0a1d4db4acd0e4cdf021b3b5-20210326 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1999521497; Fri, 26 Mar 2021 11:23:56 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 26 Mar 2021 11:23:55 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 26 Mar 2021 11:23:54 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Will Deacon CC: Robin Murphy , Tomasz Figa , , , , , , Krzysztof Kozlowski , , , Nicolas Boichat , , Subject: [PATCH v2 2/2] iommu/mediatek: Allow building as module Date: Fri, 26 Mar 2021 11:23:37 +0800 Message-ID: <20210326032337.24578-2-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210326032337.24578-1-yong.wu@mediatek.com> References: <20210326032337.24578-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The IOMMU in many SoC depends on the MM clocks and power-domain which are device_initcall normally, thus the subsys_init here is not helpful. This patch switches it to module_platform_driver which also allow the driver built as module. Correspondingly switch the config to tristate, and update the iommu_ops's owner. Signed-off-by: Yong Wu --- drivers/iommu/Kconfig | 2 +- drivers/iommu/mtk_iommu.c | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index bc93da48bed0..74f3e15edc14 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -349,7 +349,7 @@ config S390_AP_IOMMU is not implemented as it is not necessary for VFIO. config MTK_IOMMU - bool "MTK IOMMU Support" + tristate "MediaTek IOMMU Support" depends on ARCH_MEDIATEK || COMPILE_TEST select ARM_DMA_USE_IOMMU select IOMMU_API diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 6ecc007f07cd..75375935f301 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -683,6 +684,7 @@ static const struct iommu_ops mtk_iommu_ops = { .get_resv_regions = mtk_iommu_get_resv_regions, .put_resv_regions = generic_iommu_put_resv_regions, .pgsize_bitmap = SZ_4K | SZ_64K | SZ_1M | SZ_16M, + .owner = THIS_MODULE, }; static int mtk_iommu_hw_init(const struct mtk_iommu_data *data) @@ -1079,16 +1081,7 @@ static struct platform_driver mtk_iommu_driver = { .pm = &mtk_iommu_pm_ops, } }; +module_platform_driver(mtk_iommu_driver); -static int __init mtk_iommu_init(void) -{ - int ret; - - ret = platform_driver_register(&mtk_iommu_driver); - if (ret != 0) - pr_err("Failed to register MTK IOMMU driver\n"); - - return ret; -} - -subsys_initcall(mtk_iommu_init) +MODULE_DESCRIPTION("IOMMU API for MediaTek M4U implementations"); +MODULE_LICENSE("GPL v2"); -- 2.18.0