From patchwork Fri Nov 24 16:28:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 169496 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1347686vqx; Fri, 24 Nov 2023 08:29:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbY4jDg49InHvNMgtcfoVXD/BS9hpWs+mnGygMnWfyM0D+sLk1o7Esv56LVVSJuBWiEANO X-Received: by 2002:a17:90b:1e51:b0:27d:4ede:75b0 with SMTP id pi17-20020a17090b1e5100b0027d4ede75b0mr3992532pjb.16.1700843362282; Fri, 24 Nov 2023 08:29:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700843362; cv=none; d=google.com; s=arc-20160816; b=ueJiQOeLPTUKZIAp7mbHRK+jQKnLyhHOr7O1+6GMGjfjB9XwwDRrdC3cM90g5vZmCK QzDpNB6icwNRZU/v0yPjBBOncshPW7UJ2atuJjFqlT367iQvDXt3cwfwKJai7z6fFn31 Qoy3xwL7ZFPet7IaT/41TOWsxATH/N26vcT3fFq72ymULmr3z+pvmdAlKgH93MbqGV/k OQxzQ9yZk5L/YM5vq6KfmESMI6QTMcCkxJh774jQcxVLHG7TN6TC5tHGfME3m/PX7802 vP2OqmhCowowOEJDy25EJ0bDJfBPJzIBb1XpXgdle1prGL1VWij8f3ByLnx1PrsPO3u8 O8zA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=g//rHl/LxpwQpXoYOYg3bTjSPJ3DCs9GAcBjIJBfkM0=; fh=RI0mNHrSGBk/0gJ3tsBPdYn+81ROXQTqubQc1unKFUU=; b=U0Z4KT8O/xBzJcQKOQdZIqcut4D/P5aIHEuYHDWhoFu4gJUNQQGnOGfmbMiSMjFVVJ l7khZDl1k1I2DHsF6UtNtV6TCCavWI0RSjZQ14JKsqc9W4MUJdZCWm9FUtp1EDhwWqyy +Wa/1jZz/PwYUdMJQimQhB/UAcktyQt5jkOXkUUIYztFTTcQpW4i1m5tg8DqLXAGsjRe mukCoZ+vXe7HZPZ6PV7c69fheKv98SbbXCTxLTw+VX68aimhnnd1t4qePlp0gdneIOAI shyc+VKT/uKVFZLFdZ7mYLUC5WFodLdh5AvSU3cSsFCKa5cGGjCBsK6jXEDSuegK9C5j PxMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YtaAeyYz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h3-20020a17090a130300b002806cdeecc6si4414733pja.35.2023.11.24.08.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 08:29:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YtaAeyYz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9A1C080C0347; Fri, 24 Nov 2023 08:28:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231192AbjKXQ2b (ORCPT + 99 others); Fri, 24 Nov 2023 11:28:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229715AbjKXQ23 (ORCPT ); Fri, 24 Nov 2023 11:28:29 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 196E6D41 for ; Fri, 24 Nov 2023 08:28:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700843315; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g//rHl/LxpwQpXoYOYg3bTjSPJ3DCs9GAcBjIJBfkM0=; b=YtaAeyYzEveB5AO62HFun3cRg8YNwl7kTuJRwYDq9vtjAuNbddy22LquGxu+Te4Sh3L+dh WAS0ElKrYuw5edQdqjx4DBwSGvHoiNOib8OiCL813kGUa0wRJsMLejKL34MiV0IiIXiBL9 VBBMRXC/s2XXf3vODsNbAJpR+df6/Mk= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-256-yR1BhhoiMjCB5r_REKE94g-1; Fri, 24 Nov 2023 11:28:34 -0500 X-MC-Unique: yR1BhhoiMjCB5r_REKE94g-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-778915a0c73so185527385a.1 for ; Fri, 24 Nov 2023 08:28:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700843314; x=1701448114; 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=g//rHl/LxpwQpXoYOYg3bTjSPJ3DCs9GAcBjIJBfkM0=; b=JLjG/YDNtJHls4ZxeSP8+8cIdqaTPXkrrjA0Vyp3oB/u5kSwXd2K+rmcKtN10ExT13 MJTvwJxgiKq1kjXBpZ1dF0Z8tWeTdMghFc7zYUSDlVvQ2rkZ/ODniYuKhlNh8F5o2O2s tJe31y1Bh1/VzPYf21tajfdsy9nJraZmgV7o4PTfuw8hMpENBjxih7coX5SJndsteZRa KPzumU3peC8wetd4vATqObWueE2NE8IsqGf/833E/NgHMMJ6M0eVV7C6B4QA5tRaW70m WZ3qgpQ6oXib8SXfB2UO5EqyaQiCatZoSmcgHCnyC05YpMCTXimrdoHTkK006WM35atK AfGQ== X-Gm-Message-State: AOJu0YwzSMDO9HG5/JXU9ofYlSxwZ3j7ZmyjLAaRdIfthJJuNqWtFOvZ znPYp43OfpsRUxoAwdTXfEkZwF63yBilqxOUfJSYavFWQlZrN5WW18CaNsYm1k3Yu1T+rOEfFpb dL0SMqsWp6lg1HBkhFtCwwms= X-Received: by 2002:a05:620a:4711:b0:77d:855c:a6e6 with SMTP id bs17-20020a05620a471100b0077d855ca6e6mr1495287qkb.71.1700843313781; Fri, 24 Nov 2023 08:28:33 -0800 (PST) X-Received: by 2002:a05:620a:4711:b0:77d:855c:a6e6 with SMTP id bs17-20020a05620a471100b0077d855ca6e6mr1495254qkb.71.1700843313472; Fri, 24 Nov 2023 08:28:33 -0800 (PST) Received: from klayman.redhat.com (net-2-34-24-178.cust.vodafonedsl.it. [2.34.24.178]) by smtp.gmail.com with ESMTPSA id rk4-20020a05620a900400b007676f3859fasm1327608qkn.30.2023.11.24.08.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 08:28:33 -0800 (PST) From: Marco Pagani To: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , Greg Kroah-Hartman Cc: Marco Pagani , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [RFC PATCH v2 1/2] fpga: add a module owner field to fpga_manager and fpga_manager_ops Date: Fri, 24 Nov 2023 17:28:06 +0100 Message-ID: <20231124162807.238724-2-marpagan@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231124162807.238724-1-marpagan@redhat.com> References: <20231124162807.238724-1-marpagan@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 24 Nov 2023 08:28:48 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783463529033587736 X-GMAIL-MSGID: 1783463529033587736 Add a module *owner field to the fpga_manager_ops and fpga_manager structs to protect the fpga manager against the unloading of the low-level control module while someone is holding a reference to the manager device. Low-level control modules should statically set the owner field of the fpga_manager_ops struct to THIS_MODULE. Then, when the manager is registered using fpga_mgr_register(), the value is copied into the owner field of the fpga_manager struct (that contains the device context). In this way, the manager can later use it in fpga_mgr_get() to take the low-level module's refcount. To prevent races while unloading the low-level control module, fpga_mgr_get() and part of the fpga_mgr_unregister() methods are protected with a mutex. Other changes: move put_device() from __fpga_mgr_get() to fpga_mgr_get() and of_fpga_mgr_get() to improve code clarity. Fixes: 654ba4cc0f3e ("fpga manager: ensure lifetime with of_fpga_mgr_get") Signed-off-by: Marco Pagani --- drivers/fpga/fpga-mgr.c | 56 +++++++++++++++++++++++++---------- include/linux/fpga/fpga-mgr.h | 4 +++ 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 06651389c592..608605d59860 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -21,6 +21,8 @@ static DEFINE_IDA(fpga_mgr_ida); static const struct class fpga_mgr_class; +static DEFINE_MUTEX(mgr_lock); + struct fpga_mgr_devres { struct fpga_manager *mgr; }; @@ -667,17 +669,15 @@ ATTRIBUTE_GROUPS(fpga_mgr); static struct fpga_manager *__fpga_mgr_get(struct device *dev) { struct fpga_manager *mgr; + struct module *owner; mgr = to_fpga_manager(dev); + owner = mgr->owner; - if (!try_module_get(dev->parent->driver->owner)) - goto err_dev; + if (owner && !try_module_get(owner)) + mgr = ERR_PTR(-ENODEV); return mgr; - -err_dev: - put_device(dev); - return ERR_PTR(-ENODEV); } static int fpga_mgr_dev_match(struct device *dev, const void *data) @@ -693,12 +693,22 @@ static int fpga_mgr_dev_match(struct device *dev, const void *data) */ struct fpga_manager *fpga_mgr_get(struct device *dev) { - struct device *mgr_dev = class_find_device(&fpga_mgr_class, NULL, dev, - fpga_mgr_dev_match); + struct fpga_manager *mgr = ERR_PTR(-ENODEV); + struct device *mgr_dev; + + mutex_lock(&mgr_lock); + + mgr_dev = class_find_device(&fpga_mgr_class, NULL, dev, fpga_mgr_dev_match); if (!mgr_dev) - return ERR_PTR(-ENODEV); + goto out; + + mgr = __fpga_mgr_get(mgr_dev); + if (IS_ERR(mgr)) + put_device(mgr_dev); - return __fpga_mgr_get(mgr_dev); +out: + mutex_unlock(&mgr_lock); + return mgr; } EXPORT_SYMBOL_GPL(fpga_mgr_get); @@ -711,13 +721,22 @@ EXPORT_SYMBOL_GPL(fpga_mgr_get); */ struct fpga_manager *of_fpga_mgr_get(struct device_node *node) { - struct device *dev; + struct fpga_manager *mgr = ERR_PTR(-ENODEV); + struct device *mgr_dev; + + mutex_lock(&mgr_lock); + + mgr_dev = class_find_device_by_of_node(&fpga_mgr_class, node); + if (!mgr_dev) + goto out; - dev = class_find_device_by_of_node(&fpga_mgr_class, node); - if (!dev) - return ERR_PTR(-ENODEV); + mgr = __fpga_mgr_get(mgr_dev); + if (IS_ERR(mgr)) + put_device(mgr_dev); - return __fpga_mgr_get(dev); +out: + mutex_unlock(&mgr_lock); + return mgr; } EXPORT_SYMBOL_GPL(of_fpga_mgr_get); @@ -727,7 +746,7 @@ EXPORT_SYMBOL_GPL(of_fpga_mgr_get); */ void fpga_mgr_put(struct fpga_manager *mgr) { - module_put(mgr->dev.parent->driver->owner); + module_put(mgr->owner); put_device(&mgr->dev); } EXPORT_SYMBOL_GPL(fpga_mgr_put); @@ -806,6 +825,7 @@ fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *in mgr->name = info->name; mgr->mops = info->mops; + mgr->owner = info->mops->owner; mgr->priv = info->priv; mgr->compat_id = info->compat_id; @@ -888,7 +908,11 @@ void fpga_mgr_unregister(struct fpga_manager *mgr) */ fpga_mgr_fpga_remove(mgr); + mutex_lock(&mgr_lock); + device_unregister(&mgr->dev); + + mutex_unlock(&mgr_lock); } EXPORT_SYMBOL_GPL(fpga_mgr_unregister); diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index 54f63459efd6..eaf6e072dbc0 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h @@ -162,6 +162,7 @@ struct fpga_manager_info { * @write_complete: set FPGA to operating state after writing is done * @fpga_remove: optional: Set FPGA into a specific state during driver remove * @groups: optional attribute groups. + * @owner: owner module. * * fpga_manager_ops are the low level functions implemented by a specific * fpga manager driver. The optional ones are tested for NULL before being @@ -184,6 +185,7 @@ struct fpga_manager_ops { struct fpga_image_info *info); void (*fpga_remove)(struct fpga_manager *mgr); const struct attribute_group **groups; + struct module *owner; }; /* FPGA manager status: Partial/Full Reconfiguration errors */ @@ -201,6 +203,7 @@ struct fpga_manager_ops { * @state: state of fpga manager * @compat_id: FPGA manager id for compatibility check. * @mops: pointer to struct of fpga manager ops + * @owner: owner module. * @priv: low level driver private date */ struct fpga_manager { @@ -210,6 +213,7 @@ struct fpga_manager { enum fpga_mgr_states state; struct fpga_compat_id *compat_id; const struct fpga_manager_ops *mops; + struct module *owner; void *priv; }; From patchwork Fri Nov 24 16:28:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 169497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1347707vqx; Fri, 24 Nov 2023 08:29:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjeJ6GnFunarhRLbcKHgFJcwPf/yf6fcSuF3q6afYVf2HGLzQpecSyB79icMEuAbkWkvbI X-Received: by 2002:a05:6a20:c1aa:b0:188:2637:9242 with SMTP id bg42-20020a056a20c1aa00b0018826379242mr4801525pzb.47.1700843363979; Fri, 24 Nov 2023 08:29:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700843363; cv=none; d=google.com; s=arc-20160816; b=VhUN3cLGFifqWxPhzso1MzMhPMl48aflZ35s+0urPDGKa0v3zNRsMaa6Y7YlUC8Sua ejCkgXXOX/neZeR/WbhJz3G7WHj7btKXvUK0Hudvep0lvaCX8YGl7O+bbdEY5nbnnYo4 Nns/xpB8kkdROJZFZbHVNtDe915ZZqvqSBZd4vKG0Zgsy9M+1rVc75WB4uNUSwAoHym0 xqXGocDqF7bcQnKq/dGj99NTXbk/nArPuFE3ORczP9hWAB/Iiqv27MLAJBtglQMXKWlb WiDDvM0SlVZNyrwb89S1TU7yrVWOFiadgVENlxqjzTq9JhIP9Em3Oh+GRpCCQyJYU9tj kmiA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=shPFiNnieBfc+nA1jRG7H+c1jqVnxbi/cSpxWrKoPIY=; fh=RI0mNHrSGBk/0gJ3tsBPdYn+81ROXQTqubQc1unKFUU=; b=r4m9zkVyyNNGfPmvfyB2fT35oVM5facTz3ckNkgAVMTkSGEeChgEaGQX3nio5GjNWF FmxVRcK4Av+P5f6veNL0j99rf/LXHuTxhn6vIqGPtIId1xcg24OXoSwo220U4YJpgKoL Eh6Fl74Cl8dAcKDM0Lvauin6fVMJjLzYXkKsY+j+8KFNN8ENsR5IP/GF+vLEpOomIOUw MeI3bhMhLEIaxfbBdvZJLBGqvcn3hRUznlfVsdUEq6U7iVcMy0EtAWFFu1yNjzpBfMiQ 05cegFppuNjv+SH84TU6VDpqWP4VPHetYLewwSNrNwx+1fKuMzJ6tzGJZg6wSD0NSME3 /XDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NYDntzTP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l19-20020a635b53000000b005bd2713d3a1si3891362pgm.650.2023.11.24.08.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 08:29:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NYDntzTP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CCA848197EAA; Fri, 24 Nov 2023 08:28:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230155AbjKXQ2o (ORCPT + 99 others); Fri, 24 Nov 2023 11:28:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230140AbjKXQ2j (ORCPT ); Fri, 24 Nov 2023 11:28:39 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 445481BC8 for ; Fri, 24 Nov 2023 08:28:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700843323; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=shPFiNnieBfc+nA1jRG7H+c1jqVnxbi/cSpxWrKoPIY=; b=NYDntzTPDB/qLPhvFOPzSokHrau8JIeWvcUVYxCOMb+dB4ZbuwUZ3YSpI/FYNnjW4ttdaA 7VnQrbVR+8+R30vMCMl7jp1QXhDgG4awrb/MA0eM4BPrnzfVd5mifBetv+TMfVEYcGGJuL Gea700+W9+iLpZ+4Wy0KgfKBfbcutIY= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-sMc30x9pNwmmlxafpu_wWg-1; Fri, 24 Nov 2023 11:28:42 -0500 X-MC-Unique: sMc30x9pNwmmlxafpu_wWg-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-77d7b2e8623so122261285a.0 for ; Fri, 24 Nov 2023 08:28:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700843321; x=1701448121; 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=shPFiNnieBfc+nA1jRG7H+c1jqVnxbi/cSpxWrKoPIY=; b=uzR0CK7JCU9HDCQdPM9W+h0WbxT8IbW6SAsCTHwM5WTvxWZ/6r2wMoudnrms5zZbcT hcajuvpjWKBO8BvfuzALAS3Vg9Q610hlhqZMg9sqI6aP87TcXlB05hJSxKej/X7Kgn1O BcAZRCedqRDZuoyLKEcQW6l2xJOCo3Yz5wxO2FHNEUZp7bkM+k0xqQke1wqT7o8SrIVs 0VDqRHCg/t7GAYQFyttq0jOHDiyIpeNsTubWPm98a2CaoDr+27yYHq0k5ukyidAHmYsM s9WGOh2Yk6AhEghOBq3mdFYfmMJYAKVk0woAIw+/wiZI6bTER6WrQn1XVd3TPysDLJid JkNA== X-Gm-Message-State: AOJu0YyhDs65HQdwpKchnNzIgD19IAkyHVbhk7wrzaafZghqEjb5CZqN P7yNJXFk0P9sX0QsAd8vTo0NmrKaG7LCJnmd4/kSH1mbE+dEX0X2elCBPa0O4Vj/4PmfU4PZIlk EkvQA6/Wffz60ds88asx93kvPGm5FliA= X-Received: by 2002:a05:620a:2701:b0:77d:6181:7739 with SMTP id b1-20020a05620a270100b0077d61817739mr4287540qkp.37.1700843321308; Fri, 24 Nov 2023 08:28:41 -0800 (PST) X-Received: by 2002:a05:620a:2701:b0:77d:6181:7739 with SMTP id b1-20020a05620a270100b0077d61817739mr4287519qkp.37.1700843321035; Fri, 24 Nov 2023 08:28:41 -0800 (PST) Received: from klayman.redhat.com (net-2-34-24-178.cust.vodafonedsl.it. [2.34.24.178]) by smtp.gmail.com with ESMTPSA id rk4-20020a05620a900400b007676f3859fasm1327608qkn.30.2023.11.24.08.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 08:28:40 -0800 (PST) From: Marco Pagani To: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , Greg Kroah-Hartman Cc: Marco Pagani , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [RFC PATCH v2 2/2] fpga: set owner of fpga_manager_ops for existing low-level modules Date: Fri, 24 Nov 2023 17:28:07 +0100 Message-ID: <20231124162807.238724-3-marpagan@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231124162807.238724-1-marpagan@redhat.com> References: <20231124162807.238724-1-marpagan@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 24 Nov 2023 08:28:54 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783463531523713958 X-GMAIL-MSGID: 1783463531523713958 This patch tentatively set the owner field of fpga_manager_ops to THIS_MODULE for existing fpga manager low-level control modules. Signed-off-by: Marco Pagani --- drivers/fpga/altera-cvp.c | 1 + drivers/fpga/altera-pr-ip-core.c | 1 + drivers/fpga/altera-ps-spi.c | 1 + drivers/fpga/dfl-fme-mgr.c | 1 + drivers/fpga/ice40-spi.c | 1 + drivers/fpga/lattice-sysconfig.c | 1 + drivers/fpga/machxo2-spi.c | 1 + drivers/fpga/microchip-spi.c | 1 + drivers/fpga/socfpga-a10.c | 1 + drivers/fpga/socfpga.c | 1 + drivers/fpga/stratix10-soc.c | 1 + drivers/fpga/tests/fpga-mgr-test.c | 1 + drivers/fpga/tests/fpga-region-test.c | 1 + drivers/fpga/ts73xx-fpga.c | 1 + drivers/fpga/versal-fpga.c | 1 + drivers/fpga/xilinx-spi.c | 1 + drivers/fpga/zynq-fpga.c | 1 + drivers/fpga/zynqmp-fpga.c | 1 + 18 files changed, 18 insertions(+) diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c index 4ffb9da537d8..aeb913547dd8 100644 --- a/drivers/fpga/altera-cvp.c +++ b/drivers/fpga/altera-cvp.c @@ -520,6 +520,7 @@ static const struct fpga_manager_ops altera_cvp_ops = { .write_init = altera_cvp_write_init, .write = altera_cvp_write, .write_complete = altera_cvp_write_complete, + .owner = THIS_MODULE, }; static const struct cvp_priv cvp_priv_v1 = { diff --git a/drivers/fpga/altera-pr-ip-core.c b/drivers/fpga/altera-pr-ip-core.c index df8671af4a92..354221c609e6 100644 --- a/drivers/fpga/altera-pr-ip-core.c +++ b/drivers/fpga/altera-pr-ip-core.c @@ -171,6 +171,7 @@ static const struct fpga_manager_ops alt_pr_ops = { .write_init = alt_pr_fpga_write_init, .write = alt_pr_fpga_write, .write_complete = alt_pr_fpga_write_complete, + .owner = THIS_MODULE, }; int alt_pr_register(struct device *dev, void __iomem *reg_base) diff --git a/drivers/fpga/altera-ps-spi.c b/drivers/fpga/altera-ps-spi.c index 740980e7cef8..3be05796a6fc 100644 --- a/drivers/fpga/altera-ps-spi.c +++ b/drivers/fpga/altera-ps-spi.c @@ -228,6 +228,7 @@ static const struct fpga_manager_ops altera_ps_ops = { .write_init = altera_ps_write_init, .write = altera_ps_write, .write_complete = altera_ps_write_complete, + .owner = THIS_MODULE, }; static int altera_ps_probe(struct spi_device *spi) diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c index ab228d8837a0..740ce82e3ac9 100644 --- a/drivers/fpga/dfl-fme-mgr.c +++ b/drivers/fpga/dfl-fme-mgr.c @@ -264,6 +264,7 @@ static const struct fpga_manager_ops fme_mgr_ops = { .write = fme_mgr_write, .write_complete = fme_mgr_write_complete, .status = fme_mgr_status, + .owner = THIS_MODULE, }; static void fme_mgr_get_compat_id(void __iomem *fme_pr, diff --git a/drivers/fpga/ice40-spi.c b/drivers/fpga/ice40-spi.c index 7cbb3558b844..97afa6dc5d76 100644 --- a/drivers/fpga/ice40-spi.c +++ b/drivers/fpga/ice40-spi.c @@ -130,6 +130,7 @@ static const struct fpga_manager_ops ice40_fpga_ops = { .write_init = ice40_fpga_ops_write_init, .write = ice40_fpga_ops_write, .write_complete = ice40_fpga_ops_write_complete, + .owner = THIS_MODULE, }; static int ice40_fpga_probe(struct spi_device *spi) diff --git a/drivers/fpga/lattice-sysconfig.c b/drivers/fpga/lattice-sysconfig.c index ba51a60f672f..1393cdd11e49 100644 --- a/drivers/fpga/lattice-sysconfig.c +++ b/drivers/fpga/lattice-sysconfig.c @@ -348,6 +348,7 @@ static const struct fpga_manager_ops sysconfig_fpga_mgr_ops = { .write_init = sysconfig_ops_write_init, .write = sysconfig_ops_write, .write_complete = sysconfig_ops_write_complete, + .owner = THIS_MODULE, }; int sysconfig_probe(struct sysconfig_priv *priv) diff --git a/drivers/fpga/machxo2-spi.c b/drivers/fpga/machxo2-spi.c index 905607992a12..46193a47f863 100644 --- a/drivers/fpga/machxo2-spi.c +++ b/drivers/fpga/machxo2-spi.c @@ -358,6 +358,7 @@ static const struct fpga_manager_ops machxo2_ops = { .write_init = machxo2_write_init, .write = machxo2_write, .write_complete = machxo2_write_complete, + .owner = THIS_MODULE, }; static int machxo2_spi_probe(struct spi_device *spi) diff --git a/drivers/fpga/microchip-spi.c b/drivers/fpga/microchip-spi.c index 2a82c726d6e5..023ccdf2d5da 100644 --- a/drivers/fpga/microchip-spi.c +++ b/drivers/fpga/microchip-spi.c @@ -362,6 +362,7 @@ static const struct fpga_manager_ops mpf_ops = { .write_init = mpf_ops_write_init, .write = mpf_ops_write, .write_complete = mpf_ops_write_complete, + .owner = THIS_MODULE, }; static int mpf_probe(struct spi_device *spi) diff --git a/drivers/fpga/socfpga-a10.c b/drivers/fpga/socfpga-a10.c index cc4861e345c9..a8ab74b30006 100644 --- a/drivers/fpga/socfpga-a10.c +++ b/drivers/fpga/socfpga-a10.c @@ -463,6 +463,7 @@ static const struct fpga_manager_ops socfpga_a10_fpga_mgr_ops = { .write_init = socfpga_a10_fpga_write_init, .write = socfpga_a10_fpga_write, .write_complete = socfpga_a10_fpga_write_complete, + .owner = THIS_MODULE, }; static int socfpga_a10_fpga_probe(struct platform_device *pdev) diff --git a/drivers/fpga/socfpga.c b/drivers/fpga/socfpga.c index 723ea0ad3f09..87f3f4a367d0 100644 --- a/drivers/fpga/socfpga.c +++ b/drivers/fpga/socfpga.c @@ -538,6 +538,7 @@ static const struct fpga_manager_ops socfpga_fpga_ops = { .write_init = socfpga_fpga_ops_configure_init, .write = socfpga_fpga_ops_configure_write, .write_complete = socfpga_fpga_ops_configure_complete, + .owner = THIS_MODULE, }; static int socfpga_fpga_probe(struct platform_device *pdev) diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c index cacb9cc5757e..63a5a2fe4911 100644 --- a/drivers/fpga/stratix10-soc.c +++ b/drivers/fpga/stratix10-soc.c @@ -393,6 +393,7 @@ static const struct fpga_manager_ops s10_ops = { .write_init = s10_ops_write_init, .write = s10_ops_write, .write_complete = s10_ops_write_complete, + .owner = THIS_MODULE, }; static int s10_probe(struct platform_device *pdev) diff --git a/drivers/fpga/tests/fpga-mgr-test.c b/drivers/fpga/tests/fpga-mgr-test.c index 6acec55b60ce..4c2a3e98f8ad 100644 --- a/drivers/fpga/tests/fpga-mgr-test.c +++ b/drivers/fpga/tests/fpga-mgr-test.c @@ -187,6 +187,7 @@ static const struct fpga_manager_ops fake_mgr_ops = { .write = op_write, .write_sg = op_write_sg, .write_complete = op_write_complete, + .owner = THIS_MODULE, }; static void fpga_mgr_test_get(struct kunit *test) diff --git a/drivers/fpga/tests/fpga-region-test.c b/drivers/fpga/tests/fpga-region-test.c index baab07e3fc59..2705c1b33d09 100644 --- a/drivers/fpga/tests/fpga-region-test.c +++ b/drivers/fpga/tests/fpga-region-test.c @@ -52,6 +52,7 @@ static int op_write(struct fpga_manager *mgr, const char *buf, size_t count) */ static const struct fpga_manager_ops fake_mgr_ops = { .write = op_write, + .owner = THIS_MODULE, }; static int op_enable_set(struct fpga_bridge *bridge, bool enable) diff --git a/drivers/fpga/ts73xx-fpga.c b/drivers/fpga/ts73xx-fpga.c index 4e1d2a4d3df4..20b8db0d150a 100644 --- a/drivers/fpga/ts73xx-fpga.c +++ b/drivers/fpga/ts73xx-fpga.c @@ -96,6 +96,7 @@ static const struct fpga_manager_ops ts73xx_fpga_ops = { .write_init = ts73xx_fpga_write_init, .write = ts73xx_fpga_write, .write_complete = ts73xx_fpga_write_complete, + .owner = THIS_MODULE, }; static int ts73xx_fpga_probe(struct platform_device *pdev) diff --git a/drivers/fpga/versal-fpga.c b/drivers/fpga/versal-fpga.c index 3710e8f01be2..02fd8ed36ff0 100644 --- a/drivers/fpga/versal-fpga.c +++ b/drivers/fpga/versal-fpga.c @@ -40,6 +40,7 @@ static int versal_fpga_ops_write(struct fpga_manager *mgr, static const struct fpga_manager_ops versal_fpga_ops = { .write_init = versal_fpga_ops_write_init, .write = versal_fpga_ops_write, + .owner = THIS_MODULE, }; static int versal_fpga_probe(struct platform_device *pdev) diff --git a/drivers/fpga/xilinx-spi.c b/drivers/fpga/xilinx-spi.c index e1a227e7ff2a..d58cf0ccbd41 100644 --- a/drivers/fpga/xilinx-spi.c +++ b/drivers/fpga/xilinx-spi.c @@ -218,6 +218,7 @@ static const struct fpga_manager_ops xilinx_spi_ops = { .write_init = xilinx_spi_write_init, .write = xilinx_spi_write, .write_complete = xilinx_spi_write_complete, + .owner = THIS_MODULE, }; static int xilinx_spi_probe(struct spi_device *spi) diff --git a/drivers/fpga/zynq-fpga.c b/drivers/fpga/zynq-fpga.c index 96611d424a10..241e1fe48a13 100644 --- a/drivers/fpga/zynq-fpga.c +++ b/drivers/fpga/zynq-fpga.c @@ -548,6 +548,7 @@ static const struct fpga_manager_ops zynq_fpga_ops = { .write_init = zynq_fpga_ops_write_init, .write_sg = zynq_fpga_ops_write, .write_complete = zynq_fpga_ops_write_complete, + .owner = THIS_MODULE, }; static int zynq_fpga_probe(struct platform_device *pdev) diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c index f3434e2c487b..2f66400d2330 100644 --- a/drivers/fpga/zynqmp-fpga.c +++ b/drivers/fpga/zynqmp-fpga.c @@ -101,6 +101,7 @@ static const struct fpga_manager_ops zynqmp_fpga_ops = { .state = zynqmp_fpga_ops_state, .write_init = zynqmp_fpga_ops_write_init, .write = zynqmp_fpga_ops_write, + .owner = THIS_MODULE, }; static int zynqmp_fpga_probe(struct platform_device *pdev)