From patchwork Fri Oct 21 08:02:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?P=C3=A9ter_Ujfalusi?= X-Patchwork-Id: 13014364 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 1A365C4332F for ; Fri, 21 Oct 2022 07:54:26 +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: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:In-Reply-To:References: List-Owner; bh=Geqzt3wyGEo3ZRO/maBE5VmtWVLhP+zRt5m6AcvC/TE=; b=ebxPQq8CiJYUSs 5SzIsRSR84aKD8IkOPHo90xhQ9d7PLD1m3Udct7SuNXMvlUHg4k16+Ju0KtFMi1rg7V0NMAQUvqcN LmQv/twk4UEJmHcQjlHC0Ev4J1d142OncnUVgWup537INQr/tRUW05jMjtH6MX5TOoVOS+yGK7y+A 9LMDr+v+4d+0mWHrZgjJ6S0wkYddYPuWriW556q0mnEHg39p1Q5+j4MyzMpQaxNk+G8Cn/70+oSjG 5E77kUvnZ8lR8dw2skkYfs2hLC57LMfgK1ENuiUW4z6byWCDM40IY+Vfj4E4fvn1BjW9YTnqnJLyy H00uUxzjcGaS2PjyM0TA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1olmqP-0066pO-4c; Fri, 21 Oct 2022 07:53:29 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1olmqM-0066nG-9D for linux-arm-kernel@lists.infradead.org; Fri, 21 Oct 2022 07:53:27 +0000 Received: by mail-lf1-x130.google.com with SMTP id g1so3667911lfu.12 for ; Fri, 21 Oct 2022 00:53:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=GQpiZwUW3au5g/HB9/ft8xnzROXqpcSmgkp+tMrAa3Q=; b=lM4zWjvRuuIWFsM95yo/7cse+KjXX4KNSFhmPQqiEAkMJ3IJ4tvcThD/ZfIPOgbDZT VJ5rzIkz+xuGTA6D+9LohoW2iLb5Vbwe8HSSt23l1LVmIEuIrBkGEJxb6+hrqXSnP4wd TP+kTRL13hbQA2kS8aW6bUZALlKcm662ljBfT85sBFcB965dsaQ0IIvrMmIdAM8dyJK/ 35uTeuXqSlH4um+LgNd1gu4ibp2aAN5C9pOfva01fanM/66rlWeuIj5W/SeT/N3OSu+n dTwMvTcYnK87Z6DbYuuBsGoyWL5Sdj5f+0uzIKehlPQFf290pkmNKe4iOXq9zVBQWIJX 834w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GQpiZwUW3au5g/HB9/ft8xnzROXqpcSmgkp+tMrAa3Q=; b=17gVCM6fNnkqztMU7CDjzL6weILjZqdovLwB9NCsu5bfTHqDnxJGxfjo5I/viJb/LB xgy175nc7MP+0CGxqsvcPuqfsisYmwMwAtZ8AV8s9WsX22Flym5n1iW8SgG8k0NA89/m bZs3bFiWO6nH7/QQAZwBp1F77YuKpe4N1+15ll0FUe00yzyAPJsrMawdn0Yksu2KIot1 NHYQsOkdAGwP3HJLIaVqTfGJf0xH2QEHmQwdfg5F1XuSwv+suNOGbhxIr3QR2dyjlhYP aq7IGJ4tkhMf9e8S+zo0M/wiuaFLaBePbuzLr6XqyWPm0tcYP5/IBYamBjhzA/UEnEiY Rp7Q== X-Gm-Message-State: ACrzQf3BwT2khv5XIP1YdtO/QdbuhjQmC9TqW7wr7V+GHKG7mmrz99+q LTkl201PWgexeU5WbFrFY4w= X-Google-Smtp-Source: AMsMyM7FtXwqw6pVEdWV0VTfM5Mr5nGog/UFnzTGvSxNTmwWvO0noxER/k7Bw/IUc+/cAZchFJwWGg== X-Received: by 2002:ac2:5189:0:b0:4a2:3bc6:27f2 with SMTP id u9-20020ac25189000000b004a23bc627f2mr6933668lfi.73.1666338800570; Fri, 21 Oct 2022 00:53:20 -0700 (PDT) Received: from localhost.localdomain (host-185-69-38-8.kaisa-laajakaista.fi. [185.69.38.8]) by smtp.gmail.com with ESMTPSA id g15-20020a2e9ccf000000b0026e8dd02eacsm3265632ljj.16.2022.10.21.00.53.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:53:19 -0700 (PDT) From: Peter Ujfalusi To: nm@ti.com, ssantosh@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, grygorii.strashko@ti.com, khilman@baylibre.com, nfrayer@baylibre.com Subject: [PATCH] soc: ti: k3-ringacc: Allow the driver to be built as module Date: Fri, 21 Oct 2022 11:02:31 +0300 Message-Id: <20221021080231.1076-1-peter.ujfalusi@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221021_005326_355018_E3CCE80C X-CRM114-Status: GOOD ( 17.56 ) 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 The ring accelerator driver can be built as module since all depending functions are exported. Signed-off-by: Peter Ujfalusi Reviewed-by: Nicolas Frayer Tested-by: Nicolas Frayer --- drivers/soc/ti/Kconfig | 2 +- drivers/soc/ti/k3-ringacc.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/drivers/soc/ti/Kconfig b/drivers/soc/ti/Kconfig index 7e2fb1c16af1..e009d9589af4 100644 --- a/drivers/soc/ti/Kconfig +++ b/drivers/soc/ti/Kconfig @@ -63,7 +63,7 @@ config TI_SCI_PM_DOMAINS rootfs may be available. config TI_K3_RINGACC - bool "K3 Ring accelerator Sub System" + tristate "K3 Ring accelerator Sub System" depends on ARCH_K3 || COMPILE_TEST depends on TI_SCI_INTA_IRQCHIP help diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c index f7bf18b8229a..e011412f2975 100644 --- a/drivers/soc/ti/k3-ringacc.c +++ b/drivers/soc/ti/k3-ringacc.c @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include @@ -336,6 +336,11 @@ struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc, mutex_lock(&ringacc->req_lock); + if (!try_module_get(ringacc->dev->driver->owner)) { + mutex_unlock(&ringacc->req_lock); + return NULL; + } + if (id == K3_RINGACC_RING_ID_ANY) { /* Request for any general purpose ring */ struct ti_sci_resource_desc *gp_rings = @@ -380,6 +385,7 @@ struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc, return &ringacc->rings[id]; error: + module_put(ringacc->dev->driver->owner); mutex_unlock(&ringacc->req_lock); return NULL; } @@ -616,6 +622,8 @@ int k3_ringacc_ring_free(struct k3_ring *ring) no_init: clear_bit(ring->ring_id, ringacc->rings_inuse); + module_put(ringacc->dev->driver->owner); + out: mutex_unlock(&ringacc->req_lock); return 0; @@ -1450,6 +1458,7 @@ static const struct of_device_id k3_ringacc_of_match[] = { { .compatible = "ti,am654-navss-ringacc", .data = &k3_ringacc_data, }, {}, }; +MODULE_DEVICE_TABLE(of, k3_ringacc_of_match); struct k3_ringacc *k3_ringacc_dmarings_init(struct platform_device *pdev, struct k3_ringacc_init_data *data) @@ -1544,12 +1553,26 @@ static int k3_ringacc_probe(struct platform_device *pdev) return 0; } +static int k3_ringacc_remove(struct platform_device *pdev) +{ + struct k3_ringacc *ringacc = dev_get_drvdata(&pdev->dev); + + mutex_lock(&k3_ringacc_list_lock); + list_del(&ringacc->list); + mutex_unlock(&k3_ringacc_list_lock); + return 0; +} + static struct platform_driver k3_ringacc_driver = { .probe = k3_ringacc_probe, + .remove = k3_ringacc_remove, .driver = { .name = "k3-ringacc", .of_match_table = k3_ringacc_of_match, - .suppress_bind_attrs = true, }, }; -builtin_platform_driver(k3_ringacc_driver); +module_platform_driver(k3_ringacc_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("TI Ringacc driver for K3 SOCs"); +MODULE_AUTHOR("Grygorii Strashko ");