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: 6549 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp555131wrr; Fri, 21 Oct 2022 01:03:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4pkS0IdIKnWbEX0AEiJVOaUcs2KJnlmuCFcqY0XgPLU1A6Slu0ng2sUrfD19x8lQVVWaHj X-Received: by 2002:a17:902:f0d4:b0:17f:72bd:74f3 with SMTP id v20-20020a170902f0d400b0017f72bd74f3mr18656309pla.109.1666339401268; Fri, 21 Oct 2022 01:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666339401; cv=none; d=google.com; s=arc-20160816; b=BNweO+J1l/bIb8CB0yQnFhYk2K3hnSovHG9paF10ZVxPOab2QT021abA8O17ewHkZY vRHszQHwmB32c7VBPVv03qMdvK8lplO1usrZKUiFnPiO9i1CvFpYQApLmXY99k+fRC31 zC9fj2gpP1HsVKt2/5jHd5pYwaUGwmUqYgRBQVPN9glc+TKkKAuH+aDol1ao2hLbDUWi JsBGyXhKzRjyhAAMhCa6ht1SQleeIGWKjZ+PVPOXZa9ex+e1KPk6kCyDzK/nJY2TDLZI se91Fc0npdexUrWKLfA5lU37M1HKLU5E5hLdGnUNQOPW4zJETSFQP6wH8KrW0owUymta 1zLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=GQpiZwUW3au5g/HB9/ft8xnzROXqpcSmgkp+tMrAa3Q=; b=KpJYEurAd2RJtifnNeLfrA2DLsVI/d++h8cp7rN2iP5iu0NkThWjCVKmhEM6pYDN7+ CKnAEDIUoYuMHmHeKOrNsR4fcNaq+M6SWj4ysNb0WDyoBVhJ19lb6r4GZ9iYcpkFrVTy +qwJzdp8sr0Tn6quV6kiJhEgPAi/Fmwbn3jXbKhmNfv7Er/lI/4nD99+TYDdWOC+1hCq /4AJJP1sq7tfSOduPUYGhc7fSqWBdffjEVjH68pQhu7ORUkKkEgr9Fmy8RSZaWmfzWb1 8UGW4/J9aFbM7kKAMbD7UO2rLYJVOBQkgMzi6uNxXshPX+OScCpMJROf3XIy7JOTPfpb 1d0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lM4zWjvR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a170903028300b0017f97fe774fsi30057648plr.445.2022.10.21.01.03.08; Fri, 21 Oct 2022 01:03:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lM4zWjvR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230008AbiJUHx3 (ORCPT + 99 others); Fri, 21 Oct 2022 03:53:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229956AbiJUHxX (ORCPT ); Fri, 21 Oct 2022 03:53:23 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 644BA248CA9 for ; Fri, 21 Oct 2022 00:53:22 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id g7so3731683lfv.5 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=ZjvOCcKF/9IOV1jfKr49aS0QY2EYE9BYs91lzku2MYfy+tcQnZ2+zJeoPd33ED2F1i fwLMNgPB4eoF+zRki0t9NTfan270UnqjCYMJyKdQcjqR7RUOawXLZXGVL2/ljaLbdqiw JtYzvdMDsBnb11AIaNTSKjpsFgRbgsRB1vqwarZssq8+FS9a2O9FuBAAAhUsyiuKVcKu zpTGYgMh08HDkf4NGozv51Mvf5odpvAYAx0OEpN1nXzwR+59mVXjIeOLDmbXCpCZAtjG tcM/rabVMz0H765CiCOGHUBYxKLRTx1fSIWiEv/V4+3eKDToG+Nil6oc4H4UtlSMrgAW J8pA== X-Gm-Message-State: ACrzQf1y8CwhG5ZCC40/fFwV3OnlwOoWwJ1lH26II2LW2jdPVYfKR5fm CltEgtNd/ZV+yxFNrhG+GG8led7rT/j62A== 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747283504300009399?= X-GMAIL-MSGID: =?utf-8?q?1747283504300009399?= 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 ");