From patchwork Tue Jan 5 07:36:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Isaac J. Manjarres" X-Patchwork-Id: 11998309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31541C433E6 for ; Tue, 5 Jan 2021 08:21:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DCEB822257 for ; Tue, 5 Jan 2021 08:21:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCEB822257 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 61D456E08C; Tue, 5 Jan 2021 08:21:13 +0000 (UTC) Received: from so254-31.mailgun.net (so254-31.mailgun.net [198.61.254.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id B8FB389F73 for ; Tue, 5 Jan 2021 07:37:02 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1609832224; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=0B3zKdf9FkvtJgpXxelylee2gJybjJX9T1Q1FeVXnR0=; b=gYB93RNWnmm7Arbq4quxRDcHI/ufFQOrdsb2LTsqaNQfUOvDe0zfutZZl0J3Tr76rK/eBHjv lGIbOgXy+5nx2cBt9EbVkboREA1gB7IQ1cwoQrjp7phLqokq3li5i8H0ILrSrCvHkUMyT2oH zqW6xJZJqM8kM4E22X8Ot3Q47NY= X-Mailgun-Sending-Ip: 198.61.254.31 X-Mailgun-Sid: WyJkOTU5ZSIsICJkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n10.prod.us-east-1.postgun.com with SMTP id 5ff4171b1f36cf41dfa2be08 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 05 Jan 2021 07:36:59 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 079A2C43463; Tue, 5 Jan 2021 07:36:58 +0000 (UTC) Received: from isaacm-linux.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: isaacm) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8D8EAC433CA; Tue, 5 Jan 2021 07:36:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8D8EAC433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=isaacm@codeaurora.org From: "Isaac J. Manjarres" To: will@kernel.org, robin.murphy@arm.com, joro@8bytes.org, robdclark@gmail.com, sean@poorly.run, airlied@linux.ie, daniel@ffwll.ch, steven.price@arm.com, alyssa.rosenzweig@collabora.com, robh@kernel.org, tomeu.vizoso@collabora.com Subject: [PATCH RESEND 1/7] iommu/io-pgtable: Introduce dynamic io-pgtable format registration Date: Mon, 4 Jan 2021 23:36:39 -0800 Message-Id: <1609832205-10055-2-git-send-email-isaacm@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> References: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> X-Mailman-Approved-At: Tue, 05 Jan 2021 08:21:09 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Isaac J. Manjarres" , freedreno@lists.freedesktop.org, pdaly@codeaurora.org, pratikp@codeaurora.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, kernel-team@android.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The io-pgtable code constructs an array of init functions for each page table format at compile time. This is not ideal, as it prevents io-pgtable formats from being built as kernel modules. In preparation for modularizing the io-pgtable formats, switch to a dynamic registration scheme, where each io-pgtable format can register their init functions with the io-pgtable code at boot or module insertion time. Signed-off-by: Isaac J. Manjarres --- drivers/iommu/io-pgtable-arm-v7s.c | 33 ++++++++++++- drivers/iommu/io-pgtable-arm.c | 97 ++++++++++++++++++++++++++++---------- drivers/iommu/io-pgtable.c | 44 +++++++++++------ include/linux/io-pgtable.h | 50 ++++++++++++-------- 4 files changed, 164 insertions(+), 60 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index 1d92ac9..080881b 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -835,7 +836,7 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg, return NULL; } -struct io_pgtable_init_fns io_pgtable_arm_v7s_init_fns = { +static struct io_pgtable_init_fns io_pgtable_arm_v7s_init_fns = { .alloc = arm_v7s_alloc_pgtable, .free = arm_v7s_free_pgtable, }; @@ -982,5 +983,33 @@ static int __init arm_v7s_do_selftests(void) pr_info("self test ok\n"); return 0; } -subsys_initcall(arm_v7s_do_selftests); +#else +static int arm_v7s_do_selftests(void) +{ + return 0; +} #endif + +static int __init arm_v7s_init(void) +{ + int ret; + + ret = io_pgtable_ops_register(ARM_V7S, &io_pgtable_arm_v7s_init_fns); + if (ret < 0) { + pr_err("Failed to register ARM v7s fmt ret = %d\n", ret); + return ret; + } + + ret = arm_v7s_do_selftests(); + if (ret < 0) + io_pgtable_ops_unregister(ARM_V7S); + + return ret; +} +core_initcall(arm_v7s_init); + +static void __exit arm_v7s_exit(void) +{ + io_pgtable_ops_unregister(ARM_V7S); +} +module_exit(arm_v7s_exit); diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 87def58..e1f8d54 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -145,6 +146,11 @@ struct arm_lpae_io_pgtable { void *pgd; }; +struct arm_lpae_io_pgtable_init_fns { + enum io_pgtable_fmt fmt; + struct io_pgtable_init_fns init_fns; +}; + typedef u64 arm_lpae_iopte; static inline bool iopte_leaf(arm_lpae_iopte pte, int lvl, @@ -1043,29 +1049,32 @@ arm_mali_lpae_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) return NULL; } -struct io_pgtable_init_fns io_pgtable_arm_64_lpae_s1_init_fns = { - .alloc = arm_64_lpae_alloc_pgtable_s1, - .free = arm_lpae_free_pgtable, -}; - -struct io_pgtable_init_fns io_pgtable_arm_64_lpae_s2_init_fns = { - .alloc = arm_64_lpae_alloc_pgtable_s2, - .free = arm_lpae_free_pgtable, -}; - -struct io_pgtable_init_fns io_pgtable_arm_32_lpae_s1_init_fns = { - .alloc = arm_32_lpae_alloc_pgtable_s1, - .free = arm_lpae_free_pgtable, -}; - -struct io_pgtable_init_fns io_pgtable_arm_32_lpae_s2_init_fns = { - .alloc = arm_32_lpae_alloc_pgtable_s2, - .free = arm_lpae_free_pgtable, -}; - -struct io_pgtable_init_fns io_pgtable_arm_mali_lpae_init_fns = { - .alloc = arm_mali_lpae_alloc_pgtable, - .free = arm_lpae_free_pgtable, +static struct arm_lpae_io_pgtable_init_fns arm_lpae_init_fns_table[] = { + { + .fmt = ARM_32_LPAE_S1, + .init_fns.alloc = arm_32_lpae_alloc_pgtable_s1, + .init_fns.free = arm_lpae_free_pgtable, + }, + { + .fmt = ARM_32_LPAE_S2, + .init_fns.alloc = arm_32_lpae_alloc_pgtable_s2, + .init_fns.free = arm_lpae_free_pgtable, + }, + { + .fmt = ARM_64_LPAE_S1, + .init_fns.alloc = arm_64_lpae_alloc_pgtable_s1, + .init_fns.free = arm_lpae_free_pgtable, + }, + { + .fmt = ARM_64_LPAE_S2, + .init_fns.alloc = arm_64_lpae_alloc_pgtable_s2, + .init_fns.free = arm_lpae_free_pgtable, + }, + { + .fmt = ARM_MALI_LPAE, + .init_fns.alloc = arm_mali_lpae_alloc_pgtable, + .init_fns.free = arm_lpae_free_pgtable, + }, }; #ifdef CONFIG_IOMMU_IO_PGTABLE_LPAE_SELFTEST @@ -1250,5 +1259,45 @@ static int __init arm_lpae_do_selftests(void) pr_info("selftest: completed with %d PASS %d FAIL\n", pass, fail); return fail ? -EFAULT : 0; } -subsys_initcall(arm_lpae_do_selftests); +#else +static int __init arm_lpae_do_selftests(void) +{ + return 0; +} #endif + +static int __init arm_lpae_init(void) +{ + int ret, i; + + for (i = 0; i < ARRAY_SIZE(arm_lpae_init_fns_table); i++) { + ret = io_pgtable_ops_register(arm_lpae_init_fns_table[i].fmt, + &arm_lpae_init_fns_table[i].init_fns); + if (ret < 0) { + pr_err("Failed to register ARM LPAE fmt: %d ret: %d\n", + arm_lpae_init_fns_table[i].fmt, ret); + goto err_io_pgtable_register; + } + } + + ret = arm_lpae_do_selftests(); + if (ret < 0) + goto err_io_pgtable_register; + + return 0; + +err_io_pgtable_register: + while (i--) + io_pgtable_ops_unregister(arm_lpae_init_fns_table[i].fmt); + return ret; +} +core_initcall(arm_lpae_init); + +static void __exit arm_lpae_exit(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(arm_lpae_init_fns_table); i++) + io_pgtable_ops_unregister(arm_lpae_init_fns_table[i].fmt); +} +module_exit(arm_lpae_exit); diff --git a/drivers/iommu/io-pgtable.c b/drivers/iommu/io-pgtable.c index 94394c8..95e872d 100644 --- a/drivers/iommu/io-pgtable.c +++ b/drivers/iommu/io-pgtable.c @@ -12,26 +12,14 @@ #include #include -static const struct io_pgtable_init_fns * -io_pgtable_init_table[IO_PGTABLE_NUM_FMTS] = { -#ifdef CONFIG_IOMMU_IO_PGTABLE_LPAE - [ARM_32_LPAE_S1] = &io_pgtable_arm_32_lpae_s1_init_fns, - [ARM_32_LPAE_S2] = &io_pgtable_arm_32_lpae_s2_init_fns, - [ARM_64_LPAE_S1] = &io_pgtable_arm_64_lpae_s1_init_fns, - [ARM_64_LPAE_S2] = &io_pgtable_arm_64_lpae_s2_init_fns, - [ARM_MALI_LPAE] = &io_pgtable_arm_mali_lpae_init_fns, -#endif -#ifdef CONFIG_IOMMU_IO_PGTABLE_ARMV7S - [ARM_V7S] = &io_pgtable_arm_v7s_init_fns, -#endif -}; +static struct io_pgtable_init_fns *io_pgtable_init_table[IO_PGTABLE_NUM_FMTS]; struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt, struct io_pgtable_cfg *cfg, void *cookie) { struct io_pgtable *iop; - const struct io_pgtable_init_fns *fns; + struct io_pgtable_init_fns *fns; if (fmt >= IO_PGTABLE_NUM_FMTS) return NULL; @@ -59,12 +47,38 @@ EXPORT_SYMBOL_GPL(alloc_io_pgtable_ops); void free_io_pgtable_ops(struct io_pgtable_ops *ops) { struct io_pgtable *iop; + struct io_pgtable_init_fns *fns; if (!ops) return; iop = io_pgtable_ops_to_pgtable(ops); io_pgtable_tlb_flush_all(iop); - io_pgtable_init_table[iop->fmt]->free(iop); + fns = io_pgtable_init_table[iop->fmt]; + if (fns) + fns->free(iop); } EXPORT_SYMBOL_GPL(free_io_pgtable_ops); + +int io_pgtable_ops_register(enum io_pgtable_fmt fmt, + struct io_pgtable_init_fns *init_fns) +{ + if (fmt >= IO_PGTABLE_NUM_FMTS || !init_fns || !init_fns->alloc || + !init_fns->free) + return -EINVAL; + else if (io_pgtable_init_table[fmt]) + return -EEXIST; + + io_pgtable_init_table[fmt] = init_fns; + return 0; +} +EXPORT_SYMBOL_GPL(io_pgtable_ops_register); + +void io_pgtable_ops_unregister(enum io_pgtable_fmt fmt) +{ + if (fmt >= IO_PGTABLE_NUM_FMTS) + return; + + io_pgtable_init_table[fmt] = NULL; +} +EXPORT_SYMBOL_GPL(io_pgtable_ops_unregister); diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h index ea727eb..a460ae1 100644 --- a/include/linux/io-pgtable.h +++ b/include/linux/io-pgtable.h @@ -163,6 +163,37 @@ struct io_pgtable_ops { }; /** + * struct io_pgtable_init_fns - Alloc/free a set of page tables for a + * particular format. + * + * @alloc: Allocate a set of page tables described by cfg. + * @free: Free the page tables associated with iop. + */ +struct io_pgtable_init_fns { + struct io_pgtable *(*alloc)(struct io_pgtable_cfg *cfg, void *cookie); + void (*free)(struct io_pgtable *iop); +}; + +/** + * io_pgtable_ops_register() - Register the page table routines for a page table + * format. + * + * @fmt: The page table format for which we are registering ops for. + * @init_fns: The functions for allocating and freeing the page tables of + * a particular format. + */ +int io_pgtable_ops_register(enum io_pgtable_fmt fmt, + struct io_pgtable_init_fns *init_fns); + +/** + * io_pgtable_ops_unregister() - Unregister the page table routines for a page + * table format. + * + * @fmt: The format for which we are unregistering ops for. + */ +void io_pgtable_ops_unregister(enum io_pgtable_fmt fmt); + +/** * alloc_io_pgtable_ops() - Allocate a page table allocator for use by an IOMMU. * * @fmt: The page table format. @@ -233,23 +264,4 @@ io_pgtable_tlb_add_page(struct io_pgtable *iop, iop->cfg.tlb->tlb_add_page(gather, iova, granule, iop->cookie); } -/** - * struct io_pgtable_init_fns - Alloc/free a set of page tables for a - * particular format. - * - * @alloc: Allocate a set of page tables described by cfg. - * @free: Free the page tables associated with iop. - */ -struct io_pgtable_init_fns { - struct io_pgtable *(*alloc)(struct io_pgtable_cfg *cfg, void *cookie); - void (*free)(struct io_pgtable *iop); -}; - -extern struct io_pgtable_init_fns io_pgtable_arm_32_lpae_s1_init_fns; -extern struct io_pgtable_init_fns io_pgtable_arm_32_lpae_s2_init_fns; -extern struct io_pgtable_init_fns io_pgtable_arm_64_lpae_s1_init_fns; -extern struct io_pgtable_init_fns io_pgtable_arm_64_lpae_s2_init_fns; -extern struct io_pgtable_init_fns io_pgtable_arm_v7s_init_fns; -extern struct io_pgtable_init_fns io_pgtable_arm_mali_lpae_init_fns; - #endif /* __IO_PGTABLE_H */ From patchwork Tue Jan 5 07:36:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Isaac J. Manjarres" X-Patchwork-Id: 11998345 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51881C433E9 for ; Tue, 5 Jan 2021 08:22:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F2A5722257 for ; Tue, 5 Jan 2021 08:22:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2A5722257 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC2956E093; Tue, 5 Jan 2021 08:21:24 +0000 (UTC) Received: from so254-31.mailgun.net (so254-31.mailgun.net [198.61.254.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFB036E041 for ; Tue, 5 Jan 2021 07:37:05 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1609832228; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=0K5VBSFi9Zn+RM5dSDQee5wwyKqTX6V1so6lTB/p7kQ=; b=ZOkhe9D0lfht00IN8Kvr6LVtwvYDBXHojb89Ik7/vinkLl1HBsu4P0kZ9YwGq6KAC+1TGcDY HjaJTBg+6i3OogVmN3s8myDAQnrL/N9mv1TvXQiniboVuwIoY8I+C9YWIRdp/9UWPVgEisXZ suT0KXhcepZ17aUSx+ZSaxx/QCU= X-Mailgun-Sending-Ip: 198.61.254.31 X-Mailgun-Sid: WyJkOTU5ZSIsICJkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n09.prod.us-east-1.postgun.com with SMTP id 5ff4171c584481b01b7b8364 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 05 Jan 2021 07:37:00 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id A3906C433ED; Tue, 5 Jan 2021 07:36:59 +0000 (UTC) Received: from isaacm-linux.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: isaacm) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5E9A2C433ED; Tue, 5 Jan 2021 07:36:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5E9A2C433ED Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=isaacm@codeaurora.org From: "Isaac J. Manjarres" To: will@kernel.org, robin.murphy@arm.com, joro@8bytes.org, robdclark@gmail.com, sean@poorly.run, airlied@linux.ie, daniel@ffwll.ch, steven.price@arm.com, alyssa.rosenzweig@collabora.com, robh@kernel.org, tomeu.vizoso@collabora.com Subject: [PATCH RESEND 2/7] iommu/io-pgtable: Add refcounting for io-pgtable format modules Date: Mon, 4 Jan 2021 23:36:40 -0800 Message-Id: <1609832205-10055-3-git-send-email-isaacm@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> References: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> X-Mailman-Approved-At: Tue, 05 Jan 2021 08:21:09 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Isaac J. Manjarres" , freedreno@lists.freedesktop.org, pdaly@codeaurora.org, pratikp@codeaurora.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, kernel-team@android.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In preparation for modularizing io-pgtable formats, add support for reference counting the io-pgtable format modules to ensure that the modules are not unloaded while they are in use. Signed-off-by: Isaac J. Manjarres --- drivers/iommu/io-pgtable-arm-v7s.c | 1 + drivers/iommu/io-pgtable-arm.c | 5 +++++ drivers/iommu/io-pgtable.c | 12 ++++++++++-- include/linux/io-pgtable.h | 2 ++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index 080881b..7e81135 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c @@ -839,6 +839,7 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg, static struct io_pgtable_init_fns io_pgtable_arm_v7s_init_fns = { .alloc = arm_v7s_alloc_pgtable, .free = arm_v7s_free_pgtable, + .owner = THIS_MODULE, }; #ifdef CONFIG_IOMMU_IO_PGTABLE_ARMV7S_SELFTEST diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index e1f8d54..8ed52a0 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -1054,26 +1054,31 @@ static struct arm_lpae_io_pgtable_init_fns arm_lpae_init_fns_table[] = { .fmt = ARM_32_LPAE_S1, .init_fns.alloc = arm_32_lpae_alloc_pgtable_s1, .init_fns.free = arm_lpae_free_pgtable, + .init_fns.owner = THIS_MODULE, }, { .fmt = ARM_32_LPAE_S2, .init_fns.alloc = arm_32_lpae_alloc_pgtable_s2, .init_fns.free = arm_lpae_free_pgtable, + .init_fns.owner = THIS_MODULE, }, { .fmt = ARM_64_LPAE_S1, .init_fns.alloc = arm_64_lpae_alloc_pgtable_s1, .init_fns.free = arm_lpae_free_pgtable, + .init_fns.owner = THIS_MODULE, }, { .fmt = ARM_64_LPAE_S2, .init_fns.alloc = arm_64_lpae_alloc_pgtable_s2, .init_fns.free = arm_lpae_free_pgtable, + .init_fns.owner = THIS_MODULE, }, { .fmt = ARM_MALI_LPAE, .init_fns.alloc = arm_mali_lpae_alloc_pgtable, .init_fns.free = arm_lpae_free_pgtable, + .init_fns.owner = THIS_MODULE, }, }; diff --git a/drivers/iommu/io-pgtable.c b/drivers/iommu/io-pgtable.c index 95e872d..9792e25 100644 --- a/drivers/iommu/io-pgtable.c +++ b/drivers/iommu/io-pgtable.c @@ -10,6 +10,7 @@ #include #include #include +#include #include static struct io_pgtable_init_fns *io_pgtable_init_table[IO_PGTABLE_NUM_FMTS]; @@ -28,9 +29,14 @@ struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt, if (!fns) return NULL; + if (!try_module_get(fns->owner)) + return NULL; + iop = fns->alloc(cfg, cookie); - if (!iop) + if (!iop) { + module_put(fns->owner); return NULL; + } iop->fmt = fmt; iop->cookie = cookie; @@ -55,8 +61,10 @@ void free_io_pgtable_ops(struct io_pgtable_ops *ops) iop = io_pgtable_ops_to_pgtable(ops); io_pgtable_tlb_flush_all(iop); fns = io_pgtable_init_table[iop->fmt]; - if (fns) + if (fns) { fns->free(iop); + module_put(fns->owner); + } } EXPORT_SYMBOL_GPL(free_io_pgtable_ops); diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h index a460ae1..bdf0a01 100644 --- a/include/linux/io-pgtable.h +++ b/include/linux/io-pgtable.h @@ -168,10 +168,12 @@ struct io_pgtable_ops { * * @alloc: Allocate a set of page tables described by cfg. * @free: Free the page tables associated with iop. + * @owner: Driver module providing these ops. */ struct io_pgtable_init_fns { struct io_pgtable *(*alloc)(struct io_pgtable_cfg *cfg, void *cookie); void (*free)(struct io_pgtable *iop); + struct module *owner; }; /** From patchwork Tue Jan 5 07:36:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Isaac J. Manjarres" X-Patchwork-Id: 11998295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E5C3C433DB for ; Tue, 5 Jan 2021 08:21:21 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A60FD22240 for ; Tue, 5 Jan 2021 08:21:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A60FD22240 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F13F89CD7; Tue, 5 Jan 2021 08:21:10 +0000 (UTC) Received: from m43-15.mailgun.net (m43-15.mailgun.net [69.72.43.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 916136E056 for ; Tue, 5 Jan 2021 07:37:06 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1609832227; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=/egNfhQEhRiQ0oQC1YiS2fcI4kZV6K6eHG0Gh3v4tCQ=; b=S96n4EfxETTAvBRuriNiFuJG440QwAMMBFekznZIdXEEolrWsSjh0el5XsnOJ+Rh7/eJkPPW OSSve9rq3UDn4ErWvi0V8TlwlwuxmXpzCVPTMe+U4MAh8VCb1cAeXJ5cqkv8Tb9oGzQA65Dt /1u+RYxvc9S24MxyX7zTVLzs5zE= X-Mailgun-Sending-Ip: 69.72.43.15 X-Mailgun-Sid: WyJkOTU5ZSIsICJkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n05.prod.us-east-1.postgun.com with SMTP id 5ff4171d584481b01b7b876f (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 05 Jan 2021 07:37:01 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 366C1C43467; Tue, 5 Jan 2021 07:37:01 +0000 (UTC) Received: from isaacm-linux.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: isaacm) by smtp.codeaurora.org (Postfix) with ESMTPSA id 438FEC43464; Tue, 5 Jan 2021 07:36:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 438FEC43464 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=isaacm@codeaurora.org From: "Isaac J. Manjarres" To: will@kernel.org, robin.murphy@arm.com, joro@8bytes.org, robdclark@gmail.com, sean@poorly.run, airlied@linux.ie, daniel@ffwll.ch, steven.price@arm.com, alyssa.rosenzweig@collabora.com, robh@kernel.org, tomeu.vizoso@collabora.com Subject: [PATCH RESEND 3/7] iommu/arm-smmu: Add dependency on io-pgtable format modules Date: Mon, 4 Jan 2021 23:36:41 -0800 Message-Id: <1609832205-10055-4-git-send-email-isaacm@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> References: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> X-Mailman-Approved-At: Tue, 05 Jan 2021 08:21:09 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Isaac J. Manjarres" , freedreno@lists.freedesktop.org, pdaly@codeaurora.org, pratikp@codeaurora.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, kernel-team@android.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The SMMU driver depends on the availability of the ARM LPAE io-pgtable format code to work properly. In preparation for having the io-pgtable formats as modules, add a "pre" dependency with MODULE_SOFTDEP() to ensure that the ARM LPAE io-pgtable format module is loaded before loading the ARM SMMU driver module. Also, add a dependency on the ARMv7 short descriptor io-pgtable format, so that it can be loaded before the SMMU driver module, if available. Signed-off-by: Isaac J. Manjarres --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index d8c6bfd..a72649f 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -2351,3 +2351,4 @@ MODULE_DESCRIPTION("IOMMU API for ARM architected SMMU implementations"); MODULE_AUTHOR("Will Deacon "); MODULE_ALIAS("platform:arm-smmu"); MODULE_LICENSE("GPL v2"); +MODULE_SOFTDEP("pre: io-pgtable-arm io-pgtable-arm-v7s"); From patchwork Tue Jan 5 07:36:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Isaac J. Manjarres" X-Patchwork-Id: 11998327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC5DEC433E0 for ; Tue, 5 Jan 2021 08:21:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8915122240 for ; Tue, 5 Jan 2021 08:21:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8915122240 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 13D806E07D; Tue, 5 Jan 2021 08:21:12 +0000 (UTC) Received: from so254-31.mailgun.net (so254-31.mailgun.net [198.61.254.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE8C489F77 for ; Tue, 5 Jan 2021 07:37:04 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1609832225; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=0T+xlGHJP2wMYpgxmfrGKe+ecRzlLCw68x3Rb2S7kVs=; b=Kut1py2NYV/QgDoyGHagOPljl7UVPNRbWc2fkxqMYEf0agzA88TeEkC4dfpAplFxAOKqTZiR qqBF09lGl182yalWMcNhNBciTU+sKHT6UUzhZRwYw1Eyj6+utrZx5J0UXOMh7LdLhNRic2bt 5Ng0wGgr/wbf0T3raxt1CYe85Bw= X-Mailgun-Sending-Ip: 198.61.254.31 X-Mailgun-Sid: WyJkOTU5ZSIsICJkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n09.prod.us-east-1.postgun.com with SMTP id 5ff4171f584481b01b7b8bf9 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 05 Jan 2021 07:37:03 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id EB0F3C43464; Tue, 5 Jan 2021 07:37:02 +0000 (UTC) Received: from isaacm-linux.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: isaacm) by smtp.codeaurora.org (Postfix) with ESMTPSA id 63A46C433CA; Tue, 5 Jan 2021 07:37:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 63A46C433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=isaacm@codeaurora.org From: "Isaac J. Manjarres" To: will@kernel.org, robin.murphy@arm.com, joro@8bytes.org, robdclark@gmail.com, sean@poorly.run, airlied@linux.ie, daniel@ffwll.ch, steven.price@arm.com, alyssa.rosenzweig@collabora.com, robh@kernel.org, tomeu.vizoso@collabora.com Subject: [PATCH RESEND 4/7] iommu/arm-smmu-v3: Add dependency on io-pgtable-arm format module Date: Mon, 4 Jan 2021 23:36:42 -0800 Message-Id: <1609832205-10055-5-git-send-email-isaacm@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> References: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> X-Mailman-Approved-At: Tue, 05 Jan 2021 08:21:09 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Isaac J. Manjarres" , freedreno@lists.freedesktop.org, pdaly@codeaurora.org, pratikp@codeaurora.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, kernel-team@android.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The SMMUv3 driver depends on the availability of the ARM LPAE io-pgtable format code to work properly. In preparation for having the io-pgtable formats as modules, add a "pre" dependency with MODULE_SOFTDEP() to ensure that the io-pgtable-arm format module is loaded before loading the ARM SMMUv3 driver module. Signed-off-by: Isaac J. Manjarres --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 8ca7415..c498ac8 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3650,3 +3650,4 @@ MODULE_DESCRIPTION("IOMMU API for ARM architected SMMUv3 implementations"); MODULE_AUTHOR("Will Deacon "); MODULE_ALIAS("platform:arm-smmu-v3"); MODULE_LICENSE("GPL v2"); +MODULE_SOFTDEP("pre: io-pgtable-arm"); From patchwork Tue Jan 5 07:36:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Isaac J. Manjarres" X-Patchwork-Id: 11998303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6EBEC433E6 for ; Tue, 5 Jan 2021 08:21:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4333C22257 for ; Tue, 5 Jan 2021 08:21:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4333C22257 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B7ED6E073; Tue, 5 Jan 2021 08:21:11 +0000 (UTC) Received: from m43-15.mailgun.net (m43-15.mailgun.net [69.72.43.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4D2536E056 for ; Tue, 5 Jan 2021 07:37:08 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1609832229; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=Z0ZowGR4zaHQgcx0nXoZzCUPPTdU48hf87YrqUTmLnY=; b=XLerdPSCRuZRqtq//Tfht1I6BjWhug7xxO/eSrV4m4+u6XgR2CSWZ4jdEvtYvYIymlTnghtq myl63IZgIU7JhX7wUCNYJJjVBjCfFIDmQo9bNGeZd76hM4HiJLd1orCJR+BmtrS0MBl8RVJf qvwM5C4gRf4IP6dAhK/YVi5x4Kk= X-Mailgun-Sending-Ip: 69.72.43.15 X-Mailgun-Sid: WyJkOTU5ZSIsICJkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n08.prod.us-east-1.postgun.com with SMTP id 5ff4172200a8b472193e541a (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 05 Jan 2021 07:37:06 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 5401AC4346B; Tue, 5 Jan 2021 07:37:05 +0000 (UTC) Received: from isaacm-linux.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: isaacm) by smtp.codeaurora.org (Postfix) with ESMTPSA id A09BDC433C6; Tue, 5 Jan 2021 07:37:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A09BDC433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=isaacm@codeaurora.org From: "Isaac J. Manjarres" To: will@kernel.org, robin.murphy@arm.com, joro@8bytes.org, robdclark@gmail.com, sean@poorly.run, airlied@linux.ie, daniel@ffwll.ch, steven.price@arm.com, alyssa.rosenzweig@collabora.com, robh@kernel.org, tomeu.vizoso@collabora.com Subject: [PATCH RESEND 5/7] drm/msm: Add dependency on io-pgtable-arm format module Date: Mon, 4 Jan 2021 23:36:43 -0800 Message-Id: <1609832205-10055-6-git-send-email-isaacm@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> References: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> X-Mailman-Approved-At: Tue, 05 Jan 2021 08:21:09 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Isaac J. Manjarres" , freedreno@lists.freedesktop.org, pdaly@codeaurora.org, pratikp@codeaurora.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, kernel-team@android.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The MSM DRM driver depends on the availability of the ARM LPAE io-pgtable format code to work properly. In preparation for having the io-pgtable formats as modules, add a "pre" dependency with MODULE_SOFTDEP() to ensure that the io-pgtable-arm format module is loaded before loading the MSM DRM driver module. Signed-off-by: Isaac J. Manjarres --- drivers/gpu/drm/msm/msm_drv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 535a026..8be3506 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -1369,3 +1369,4 @@ module_exit(msm_drm_unregister); MODULE_AUTHOR("Rob Clark X-Patchwork-Id: 11998337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97A5AC433DB for ; Tue, 5 Jan 2021 08:22:02 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4E99822240 for ; Tue, 5 Jan 2021 08:22:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E99822240 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 92C6C6E098; Tue, 5 Jan 2021 08:21:14 +0000 (UTC) Received: from so254-31.mailgun.net (so254-31.mailgun.net [198.61.254.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id B54966E049 for ; Tue, 5 Jan 2021 07:37:09 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1609832231; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=uRl55kgW9XKzL1b1lRBQjM6Pzb0e5uOth9CmcyHiqfY=; b=Zc+7vBuYs9DZ1QgqDTGK8X0+4uJHFS9CBbLMS0OrYWh4O79ZS/wM74/NM2MnTZATqf1KXv+f qlsYmz2zc5QOVni3/Y/U/pbqS426lMq0xUvVHRwJ/bFrmO8p5arUJyv91ckJvUKuTj5/EucZ RlClRSOBglaIt6lPzJwWZZ4blpU= X-Mailgun-Sending-Ip: 198.61.254.31 X-Mailgun-Sid: WyJkOTU5ZSIsICJkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n05.prod.us-east-1.postgun.com with SMTP id 5ff41723584481b01b7b9584 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 05 Jan 2021 07:37:07 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id E9635C4346B; Tue, 5 Jan 2021 07:37:06 +0000 (UTC) Received: from isaacm-linux.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: isaacm) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5DCB9C4346D; Tue, 5 Jan 2021 07:37:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5DCB9C4346D Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=isaacm@codeaurora.org From: "Isaac J. Manjarres" To: will@kernel.org, robin.murphy@arm.com, joro@8bytes.org, robdclark@gmail.com, sean@poorly.run, airlied@linux.ie, daniel@ffwll.ch, steven.price@arm.com, alyssa.rosenzweig@collabora.com, robh@kernel.org, tomeu.vizoso@collabora.com Subject: [PATCH RESEND 6/7] drm/panfrost: Add dependency on io-pgtable-arm format module Date: Mon, 4 Jan 2021 23:36:44 -0800 Message-Id: <1609832205-10055-7-git-send-email-isaacm@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> References: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> X-Mailman-Approved-At: Tue, 05 Jan 2021 08:21:09 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Isaac J. Manjarres" , freedreno@lists.freedesktop.org, pdaly@codeaurora.org, pratikp@codeaurora.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, kernel-team@android.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The Panfrost DRM driver depends on the availability of the ARM LPAE io-pgtable format code to work properly. In preparation for having the io-pgtable formats as modules, add a "pre" dependency with MODULE_SOFTDEP() to ensure that the io-pgtable-arm format module is loaded before loading the Panfrost DRM driver module. Signed-off-by: Isaac J. Manjarres --- drivers/gpu/drm/panfrost/panfrost_drv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 83a461b..7294622 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -704,3 +704,4 @@ module_platform_driver(panfrost_driver); MODULE_AUTHOR("Panfrost Project Developers"); MODULE_DESCRIPTION("Panfrost DRM Driver"); MODULE_LICENSE("GPL v2"); +MODULE_SOFTDEP("pre: io-pgtable-arm"); From patchwork Tue Jan 5 07:36:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Isaac J. Manjarres" X-Patchwork-Id: 11998335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 477B7C433E6 for ; Tue, 5 Jan 2021 08:22:01 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF70E22240 for ; Tue, 5 Jan 2021 08:22:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF70E22240 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 473F76E096; Tue, 5 Jan 2021 08:21:14 +0000 (UTC) Received: from m43-15.mailgun.net (m43-15.mailgun.net [69.72.43.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id A3F556E059 for ; Tue, 5 Jan 2021 07:37:10 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1609832230; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=rpqI5hDm0c8EMztfmP5ol3o97td4NOlV5r9gOI8P84E=; b=ERxy0NEMNRaklxAZ5UxdRK3wBlFoKkzCNvmeRPZrh/jAcHwiZr9uBdhRg1yvc/+jwYceBRmb myMZUBUyxlXtRgbluXTAsTGh/loGjBGFl2Owy7aLup/L+NYphehSmjabLxCxTEVT/HCQys80 hTKTapGPVDOQyBfn+6iUSparlf4= X-Mailgun-Sending-Ip: 69.72.43.15 X-Mailgun-Sid: WyJkOTU5ZSIsICJkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n09.prod.us-east-1.postgun.com with SMTP id 5ff41725584481b01b7b99f5 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 05 Jan 2021 07:37:09 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id EA39CC43463; Tue, 5 Jan 2021 07:37:08 +0000 (UTC) Received: from isaacm-linux.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: isaacm) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3123AC433ED; Tue, 5 Jan 2021 07:37:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3123AC433ED Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=isaacm@codeaurora.org From: "Isaac J. Manjarres" To: will@kernel.org, robin.murphy@arm.com, joro@8bytes.org, robdclark@gmail.com, sean@poorly.run, airlied@linux.ie, daniel@ffwll.ch, steven.price@arm.com, alyssa.rosenzweig@collabora.com, robh@kernel.org, tomeu.vizoso@collabora.com Subject: [PATCH RESEND 7/7] iommu/io-pgtable-arm: Allow building modular io-pgtable formats Date: Mon, 4 Jan 2021 23:36:45 -0800 Message-Id: <1609832205-10055-8-git-send-email-isaacm@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> References: <1609832205-10055-1-git-send-email-isaacm@codeaurora.org> X-Mailman-Approved-At: Tue, 05 Jan 2021 08:21:09 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Isaac J. Manjarres" , freedreno@lists.freedesktop.org, pdaly@codeaurora.org, pratikp@codeaurora.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, kernel-team@android.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Now that everything is in place for modular io-pgtable formats, allow the ARM LPAE and ARMV7S io-pgtable formats to be built as modules, and allow the io-pgtable framework to be enabled, without having to explicitly enable an io-pgtable format. Signed-off-by: Isaac J. Manjarres --- drivers/iommu/Kconfig | 11 +++++++---- drivers/iommu/io-pgtable-arm-v7s.c | 2 ++ drivers/iommu/io-pgtable-arm.c | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 192ef8f..d3c4e9a 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -25,12 +25,15 @@ if IOMMU_SUPPORT menu "Generic IOMMU Pagetable Support" -# Selected by the actual pagetable implementations config IOMMU_IO_PGTABLE - bool + bool "IOMMU Pagetable support" + help + Enable support for using IOMMU pagetables. This option enables + the generic IOMMU pagetable framework for registering IOMMU + pagetable formats, as well as managing IOMMU pagetable instances. config IOMMU_IO_PGTABLE_LPAE - bool "ARMv7/v8 Long Descriptor Format" + tristate "ARMv7/v8 Long Descriptor Format" select IOMMU_IO_PGTABLE depends on ARM || ARM64 || (COMPILE_TEST && !GENERIC_ATOMIC64) help @@ -49,7 +52,7 @@ config IOMMU_IO_PGTABLE_LPAE_SELFTEST If unsure, say N here. config IOMMU_IO_PGTABLE_ARMV7S - bool "ARMv7/v8 Short Descriptor Format" + tristate "ARMv7/v8 Short Descriptor Format" select IOMMU_IO_PGTABLE depends on ARM || ARM64 || COMPILE_TEST help diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index 7e81135..69dbf86 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c @@ -1014,3 +1014,5 @@ static void __exit arm_v7s_exit(void) io_pgtable_ops_unregister(ARM_V7S); } module_exit(arm_v7s_exit); + +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 8ed52a0..8d4805f 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -1306,3 +1306,5 @@ static void __exit arm_lpae_exit(void) io_pgtable_ops_unregister(arm_lpae_init_fns_table[i].fmt); } module_exit(arm_lpae_exit); + +MODULE_LICENSE("GPL v2");