From patchwork Thu Nov 3 19:51:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13030939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF863C4332F for ; Thu, 3 Nov 2022 19:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2IlI5GPxiCB3h8ULHibvqx+L5I+Tm4DbyQ5L+8q/IfY=; b=r4184f2Ifb5Iap zk26sE+JSuTP1oe+A6V/FIbU5t14BUPsHNBVXbDEDtRuO21lOluK4Ry4MqpP+m/BaFTh5Oeye99ml 00saNKB3e2YPAbIReJKO8VzcgewCKMG/GcrIN5Cv1+trYDoAkcXbNKvb9VV4F7sFlwl+Wn/I2T+NC V555kaTiCZtSrYxYLdj79o9dryFwkp/qUFsREYwCxtfr9IazJ+z2GFPuEFcV6E4CSD9UuR6BJGieT aR6tiIIeClOyfXzYQ+7UyEq6BlvhUP9auEDnlNCUotUjWaE3CVNTgVL+fceB+qpu5WtBQb31N7AC6 SASGYZeTsuhfVeT05vOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqgGQ-001T2N-Oo; Thu, 03 Nov 2022 19:52:34 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqgFw-001Ss9-MA for linux-arm-kernel@lists.infradead.org; Thu, 03 Nov 2022 19:52:09 +0000 Received: by mail-ed1-x52f.google.com with SMTP id z18so4668985edb.9 for ; Thu, 03 Nov 2022 12:52:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aXCO9a7x2xoJr3hX2LIdzuSb2rVW3qJQzBsWlbB8ZK0=; b=nQGsSI60wh19jmS5rh2BuaBTcb5URMCprPZR1Qt20h8IGzb8IM4pplEyq6DQ3Q+n0C h5qaEV3zI/t4vLs0Je8PEyDomt+aBsAELhfOyIdRwQBWKObdhTH3xshRT9xXWpIwrTjW l5TryGbITzNYIzK155TRxE63/dj/a/V9XNmyzurtcNFQs5g6emh1Mp2+GdixLYxcuJNU hrOdEkVQM6OG83HiAUYRvmpIgGmU8Msf9q5a6Kti8Fnah1eeJ5JWaQgmgO+n2dgM1PIP Uq2NJ6bEBBQFVVXElJ10vvwkVK4BE96g5CeDj+Ro58KWu7BsrOA/CqM/hHL9mbNNkYTP cJkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aXCO9a7x2xoJr3hX2LIdzuSb2rVW3qJQzBsWlbB8ZK0=; b=YFATUQRHwP6ycxqrZfn9P2M6iZFHo/p2OpSx2d62oIqjn35pimEmSoKj3tkRxmF43L AHm+scZTFCA3tJOdpjmSJDVWSSehpM6RpCW99iJWzA4YhM9tSVTNUBz3Gnis9EmmqFBV UWhf+tlF1wDKSDUeLmisPBgPacf8PSpw78EzSo7d6oJht6yFka3cle/X3sh6SEbE6Yya uJRkOz+7C/Es7+sdMrAHqRafVHZ6pCOsrLonvsAOp1xcp5jpN7XdGIsfl83Ep44+0B2V eb+o9x/4Pgp9l/lMS2JwBiP87280gnBjZu3GXJdPkQVwmpc73B9qQEUv1p5YGIN3tF1d vlCA== X-Gm-Message-State: ACrzQf1d0rLKw6dfo204Nz92IXronEW13p3rHDQnBE2bXraoWQKv3E7n mIlIm1+Zq+Amz33ximV4UT2B7Q== X-Google-Smtp-Source: AMsMyM6GuGLXLDhRmMnsQt0YiPv3zTLETFhVFIZP2Bap/XDV65f5mB5C1KHbKH7MNTJRJt+lwpbmlA== X-Received: by 2002:a05:6402:440f:b0:45d:297b:c70a with SMTP id y15-20020a056402440f00b0045d297bc70amr31990965eda.187.1667505121017; Thu, 03 Nov 2022 12:52:01 -0700 (PDT) Received: from localhost (cgw.msart-bajzova4.ke.cust.o2bs.sk. [90.176.4.227]) by smtp.gmail.com with ESMTPSA id g16-20020a170906539000b007ad98918743sm880137ejo.1.2022.11.03.12.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 12:52:00 -0700 (PDT) From: Sam Protsenko To: Marek Szyprowski , Krzysztof Kozlowski Cc: Joerg Roedel , Will Deacon , Robin Murphy , Sumit Semwal , Alim Akhtar , Janghyuck Kim , Cho KyongHo , Daniel Mentz , David Virag , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH v2 3/6] iommu/exynos: Modularize the driver Date: Thu, 3 Nov 2022 20:51:51 +0100 Message-Id: <20221103195154.21495-4-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221103195154.21495-1-semen.protsenko@linaro.org> References: <20221103195154.21495-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221103_125206_411736_5C0E1B27 X-CRM114-Status: GOOD ( 18.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rework the driver so it can be built as a loadable module. That can be useful as not all ARM64 platforms need it. And that's ok for it to be a module because it's not a critical driver (platform can work when it's disabled). Remove method and module exit function are not implemented, as the removal of IOMMUs cannot be done reliably. As Robin Murphy mentioned in [1]: ...it's better not to even pretend that removing an IOMMU's driver while other drivers are using it (usually via DMA ops without even realising) is going to have anything other than catastrophic results. [1] https://lore.kernel.org/lkml/20220702213724.3949-2-semen.protsenko@linaro.org/T/#md7e1e3f5b2c9e7fa5bc28fe33e818b6aa4a7237c Signed-off-by: Sam Protsenko Acked-by: Krzysztof Kozlowski --- Changes in v2: - Add MODULE_DEVICE_TABLE(of, ...) to support hot-plug loading - Add MODULE_ALIAS() line - Extracted "shutdown" driver method adding into a separate patch drivers/iommu/Kconfig | 2 +- drivers/iommu/exynos-iommu.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index dc5f7a156ff5..6f7055606679 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -259,7 +259,7 @@ config TEGRA_IOMMU_SMMU SoCs (Tegra30 up to Tegra210). config EXYNOS_IOMMU - bool "Exynos IOMMU Support" + tristate "Exynos IOMMU Support" depends on ARCH_EXYNOS || COMPILE_TEST depends on !CPU_BIG_ENDIAN # revisit driver if we can enable big-endian ptes select IOMMU_API diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 0d150b383d04..aad845677bda 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -798,8 +799,9 @@ static const struct of_device_id sysmmu_of_match[] = { { .compatible = "samsung,exynos-sysmmu", }, { }, }; +MODULE_DEVICE_TABLE(of, sysmmu_of_match); -static struct platform_driver exynos_sysmmu_driver __refdata = { +static struct platform_driver exynos_sysmmu_driver = { .probe = exynos_sysmmu_probe, .driver = { .name = "exynos-sysmmu", @@ -1404,6 +1406,7 @@ static const struct iommu_ops exynos_iommu_ops = { .release_device = exynos_iommu_release_device, .pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE, .of_xlate = exynos_iommu_of_xlate, + .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = exynos_iommu_attach_device, .detach_dev = exynos_iommu_detach_device, @@ -1454,3 +1457,7 @@ static int __init exynos_iommu_init(void) return ret; } core_initcall(exynos_iommu_init); + +MODULE_DESCRIPTION("IOMMU driver for Exynos SoCs"); +MODULE_ALIAS("platform:exynos-sysmmu"); +MODULE_LICENSE("GPL");