From patchwork Sat Oct 29 07:53:56 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: 13024529 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 2818EC433FE for ; Sat, 29 Oct 2022 07:46:20 +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=1vj8UBCp+9AOg4465Ttg4viRZsnkMsVxw36L+b18hY0=; b=h0GnnepYcai+rf NWusuqGR/KmGMA1OdgdMRhf/F8ky/EbkYBdJVG/0iwqUVnThF/EnM0lZzmGOQbxFuyNBhIcLOdZcd AdegQEI5b2wFM+kuov5TjzLoqn4FpOqDhxbnzA6afem2KUnsn0QrLcQkA+c07SO1sZdO6eu5b59ml ZDH/6bffQitoI2HcS85mdxOtHDLNa5WQF04rZaXaMf7q6eNsFAefVyYDLOuveLJQ/YoOVycHu2AXi DMQ8amz1NgMKlN9xj3Qu0L0CUF5IVAK4/Zkje9zOS2CKehCjyjQHG5Ub5WDOHtO4m0sm0kaUDPAPy YEYpsX/DP/5SqoVkgUFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oogWN-005E3V-Dj; Sat, 29 Oct 2022 07:44:47 +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 1oogWJ-005E39-7m for linux-arm-kernel@lists.infradead.org; Sat, 29 Oct 2022 07:44:45 +0000 Received: by mail-lf1-x130.google.com with SMTP id d6so11694124lfs.10 for ; Sat, 29 Oct 2022 00:44:39 -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=ODsvEZSt8L9OgvY/uXP8nyDMl5NJNUX3zne8NzsJ3Zw=; b=MjBdbM+ALBCYc7vNc6UWs4mrtrCfhKXdJBhZxvKGEJQimcFUwmHBOMWpUFyuYF2wuK ptu+uk+UcfRpG0L9zV2Y1K1h04FPxLVNU2xptGl0Oq1tlECEk0N2uOWDSHV1DoR/1mnD hphYc6kNZnWa2S7fPo3d6gTPfxW/9o50sV+9r+ZrKbi3xAYBkIpUyvrxlDoiWxb1TVWQ tnLH6zuJtMnxElc+Ydm0+cQtvT+xGT3my/JgtO9+Al4FslQbvH82BLGI0CYVQ4DZ6t8x bp1kbcG2iHk+2aTUCCmOvexMov+ritTOrp1SfzJVU5V2McyIIl/yQie5WVj15hmoUP+7 EX7w== 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=ODsvEZSt8L9OgvY/uXP8nyDMl5NJNUX3zne8NzsJ3Zw=; b=ZAtkpJvKgdJrBxAKWAXUcOvc7og6iWJ1xoSqrJJtgs6Kj3CBTF356O3DiVHC5QkvOh nte8HU7FV1rgKLZW+JX/hJKHMLuiE1nRogBzZVo6GUQudK4/onVTFVQEn3IxsDdOe7dV BP8hQ4elf3tTRMMEZGg3n6GulqHPDZVMMuu+BhNMjVrUrZdQhfTmH9LYLWB+EBC3YQ42 zxoiuYUFkBjPRt+p9S2bWUSUOE51Iqaje2A93RLaaDEwXYMXK5uLj6uXcOBpmEgXRCiZ LMshOSexbF2MXHqN6s0biYJ+0ZyUTHUvkyNaZi2cGlUAKEpUbSS9Cs28I9BR6Ogj6ajW neCg== X-Gm-Message-State: ACrzQf2f5YcPMxrNQSmppcU92WTc5fN1O/u21EWaYKv34G0d5iwGfGCc /MN3aIX1LgA991VgM/itIMDB3vtS1bUSo3ll X-Google-Smtp-Source: AMsMyM5kVZWX+n6uvYMbPYCdqP59Z1ohYI0hGLBsRjnxCUDIE/5Lm7JE1GN4L9+CMJtlkWH2fbnc9A== X-Received: by 2002:a05:6512:230d:b0:4a2:fd3:9208 with SMTP id o13-20020a056512230d00b004a20fd39208mr1263691lfu.557.1667029478162; Sat, 29 Oct 2022 00:44:38 -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 202-20020a2e09d3000000b0026acfbbcb7esm121716ljj.12.2022.10.29.00.44.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 00:44:37 -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 v2] soc: ti: k3-ringacc: Allow the driver to be built as module Date: Sat, 29 Oct 2022 10:53:56 +0300 Message-Id: <20221029075356.7296-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-20221029_004444_046105_6F9142A2 X-CRM114-Status: GOOD ( 18.25 ) 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 --- Hi, Changes since v1: - Fix MODULE_LICENSE line to GPL - Use goto label in k3_ringacc_request_ring() for try_module_get error - keep suppress_bind_attrs = true Nicolas, I have not added your reviewed and tested by tag due to these changes. I would appreciate if you would spare some time to re-check the patch. Regards, Peter drivers/soc/ti/Kconfig | 2 +- drivers/soc/ti/k3-ringacc.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 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..e01e4d815230 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,9 @@ struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc, mutex_lock(&ringacc->req_lock); + if (!try_module_get(ringacc->dev->driver->owner)) + goto err_module_get; + if (id == K3_RINGACC_RING_ID_ANY) { /* Request for any general purpose ring */ struct ti_sci_resource_desc *gp_rings = @@ -380,6 +383,9 @@ struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc, return &ringacc->rings[id]; error: + module_put(ringacc->dev->driver->owner); + +err_module_get: 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,27 @@ 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"); +MODULE_DESCRIPTION("TI Ringacc driver for K3 SOCs"); +MODULE_AUTHOR("Grygorii Strashko ");