Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2032063imm; Thu, 21 Jun 2018 06:15:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIWdvUhLuyBJCUZ1yUFSTXmBsAn10gx3c6Aqw778kff+rNoeFcTyqGaGueUxIEb/jnT9K6V X-Received: by 2002:a62:9513:: with SMTP id p19-v6mr27406408pfd.239.1529586930252; Thu, 21 Jun 2018 06:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529586930; cv=none; d=google.com; s=arc-20160816; b=f3kLYUJvwnJ9621uKeOUgUc5Mriuwdux+ps/CNyaj2dPvBgvvlQMVajfZHjsVmVZbI NNAjsTirvKt3klwvgBpi7T0Oxt2dSgG0o3XTiS1VR/NYudztzaIFySD3Aeu6sG4kNntp s1aTbE1qrZUs9F2zXzYhqMqJcJ7tIXi8+yFwglUZIlEawthqDOCOrMMIWJXwtOPt5c9c ADYT8DVa7F9wtnmjm1ZXY5NW3WQWwV0uKi/x50tICayMZ7DAaDqEJ5oJsEwz9wlpSGnz v3aH2mxzdOE82sAWFKtpDKY8vDsLhgHpMixBP7VB7DzBJc2oSzY1MkIeyp+MMLy7cv2u mr1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:mime-version :message-id:date:subject:reply-to:to:from:dkim-signature :arc-authentication-results; bh=QSlaXvpSDZrfapJV1rd7r2xhrfeE+VTyKda6v//mtUg=; b=ZCMqbeM2iQ0WoqwqlRqrY/ORQtSk+w6J5Mke/xeN+J0X32Dxu9pQx5hdwxD2zol/JY rcmjKUuzWW7eXK0tOzKqt9btautVIp4ObaVw7zs6t2AOc3vPmZcgizLpVwuRPw2tKn1e 0w0cR3s5SHRzHMI/13YsaNvtjpI6nYdVio2l+tvSo2XBoVWoRCJqxLoh8vdQNYZIU4K/ KqjJYwX7FiEz3b24OMRh84+FWJQh8273EDfkkUDw64qodKCTuVmkqgq/UyebeRT9cJuH L9GLOe0+r8EBecuO6wDj46by1s54Ksz8DogYc2Jb9OfTvAcN0tN77DxBDu0MjcmAa+gj Ka6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cern.onmicrosoft.com header.s=selector1-cern-ch header.b="TXmNEK2/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x66-v6si5082559pfx.67.2018.06.21.06.15.16; Thu, 21 Jun 2018 06:15:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cern.onmicrosoft.com header.s=selector1-cern-ch header.b="TXmNEK2/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933268AbeFUNOJ (ORCPT + 99 others); Thu, 21 Jun 2018 09:14:09 -0400 Received: from mail-ve1eur01on0082.outbound.protection.outlook.com ([104.47.1.82]:43294 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932695AbeFUNOG (ORCPT ); Thu, 21 Jun 2018 09:14:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cern.onmicrosoft.com; s=selector1-cern-ch; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QSlaXvpSDZrfapJV1rd7r2xhrfeE+VTyKda6v//mtUg=; b=TXmNEK2/m0/K3gHMFvGWcLWA1VawlSEuppLErb5PraJOouEUlbaaxNKsa+pAZcjVwTUvyk2M/8me0h2Mp8o4VPOAJQ4+LOS20x6JQt5WpR9khAoXd6JwbC92eYwy1xIaJDPknA+TGNDqZO3iUpo9TiHv/NOpfuG41tJycZ0To3c= Received: from AM6PR06CA0032.eurprd06.prod.outlook.com (2603:10a6:20b:14::45) by VI1PR0602MB3376.eurprd06.prod.outlook.com (2603:10a6:803:9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.17; Thu, 21 Jun 2018 13:14:04 +0000 Received: from AM5EUR02FT040.eop-EUR02.prod.protection.outlook.com (2a01:111:f400:7e1e::206) by AM6PR06CA0032.outlook.office365.com (2603:10a6:20b:14::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.863.19 via Frontend Transport; Thu, 21 Jun 2018 13:14:04 +0000 Authentication-Results: spf=pass (sender IP is 188.184.36.50) smtp.mailfrom=cern.ch; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=bestguesspass action=none header.from=cern.ch; Received-SPF: Pass (protection.outlook.com: domain of cern.ch designates 188.184.36.50 as permitted sender) receiver=protection.outlook.com; client-ip=188.184.36.50; helo=cernmxgwlb4.cern.ch; Received: from cernmxgwlb4.cern.ch (188.184.36.50) by AM5EUR02FT040.mail.protection.outlook.com (10.152.9.8) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.884.17 via Frontend Transport; Thu, 21 Jun 2018 13:14:03 +0000 Received: from cernfe05.cern.ch (188.184.36.45) by cernmxgwlb4.cern.ch (188.184.36.50) with Microsoft SMTP Server (TLS) id 14.3.399.0; Thu, 21 Jun 2018 15:13:42 +0200 Received: from pcbe13614.localnet (2001:1458:202:121::100:40) by smtp.cern.ch (2001:1458:201:66::100:14) with Microsoft SMTP Server (TLS) id 14.3.399.0; Thu, 21 Jun 2018 15:13:41 +0200 From: Federico Vaga To: Alan Tull , Moritz Fischer , , Reply-To: Subject: fpga: fpga_mgr_get() buggy ? Date: Thu, 21 Jun 2018 15:13:41 +0200 Message-ID: <4617134.5euanDEBgJ@pcbe13614> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Originating-IP: [2001:1458:202:121::100:40] X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:188.184.36.50;IPV:NLI;CTRY:CH;EFV:NLI;SFV:NSPM;SFS:(10009020)(39860400002)(39380400002)(396003)(346002)(376002)(2980300002)(438002)(189003)(199004)(47776003)(230700001)(33716001)(3450700001)(46406003)(478600001)(6116002)(5660300001)(336012)(23726003)(16526019)(186003)(126002)(7636002)(7736002)(356003)(2201001)(43066004)(476003)(86362001)(106002)(74482002)(9686003)(426003)(9576002)(786003)(305945005)(106466001)(44832011)(316002)(8676002)(8936002)(33896004)(26005)(2906002)(110136005)(97756001)(50466002)(486006)(246002)(39026011);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0602MB3376;H:cernmxgwlb4.cern.ch;FPR:;SPF:Pass;LANG:en;PTR:cernmx11.cern.ch;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 10436b7a-4360-418d-c81b-08d5d778dc88 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(4608076)(2017052603328)(7153060)(7193020);SRVR:VI1PR0602MB3376; X-MS-TrafficTypeDiagnostic: VI1PR0602MB3376: X-Microsoft-Exchange-Diagnostics: 1;VI1PR0602MB3376;20:wrSpZ33tRCLs/IF1DYF4pRLi7QBACWWWYsOpR8/soH9O+DEJgrTs+e81OVbPs2mmAo/Gq0g0UnXRd/BpbMRQ22ITlTHIp6P8bv+y9wIOrzS1AZA/zRjW9vXxEAtw8/Ne1m646fZAUWU8M3I2+37ZsYGOC5szQyFNA1320X0+6dKZUAoamgtnqzc67CMC71zMR1BU17zhsm/Sb7mhXF23En/4a9k4Wg6ZrHRyp1ZlD2c/j0Mo5wiGAyWZspa4e7yfI+P7urcruASk7NDRw+pY2KK1xT0qo5ZGV/cnEr9WlCimzXBnwJnX4KRjqAtgT1R/V6aZyj76Ee3ZhMNP3KFcETpqeNtih62xEeJqEjquoEZYRUWpqHmfcY49rSF3kceRup6JjYe+o9j4Sm9BJs0bKm27Kyw2cct1EPpPpgV6/HW29gR1+I3I/XpO5V3cZ6X8Yar0faIJC13eBT0CuJug6XciBCsREbm22os/DJKxaH3wiuP2hQCalr84QkX1zOR+;4:9pVcleHGu+lFH9TDLy+ozji+DsWZIylPz7XCa4NtWUFQz3m1+ZoCr6VwYzdjmY/LfU3AswxRxTb27LMpRgl04JPLBDSYzw9SEGn04gc0chHwPuuJSpDE8GsGujmY3Em04S3T3qXuSFUfZj3z6JFlgX76YZ7RdJRQWWNsdy5lesTLnCPgr7R54rMjHjeUYpGXZYmM6GH8bTqcqNrUelLYPCRsS+nOIgpNP68LIOPL/ceeacQhBhMpr8sdmBbnBWVa7ivNFXEUAlizR3GiSoyUHA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231254)(944501410)(52105095)(93006095)(93004095)(3002001)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281529075)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:VI1PR0602MB3376;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0602MB3376; X-Forefront-PRVS: 07106EF9B9 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR0602MB3376;23:5vYq6kw3xIzbihlH77faZm8U1LXF7V/A7w8LTKa?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VmThq2v84qTErZ9/8+ZERVy3bph8KGP3AWknQW+jHQU0ikoVubJDW2FzzJ/lJDQ49LfdBNUTbEww==;5:uAnyhYlhsIy8xcWG+59OjO64abERFZAuznGlu923hcykXn9SK9MlHq1JDeqg1de7AizaXXqG34/UCoCOxUUgWIlISy73CLCKATk7DjIRKU8eKnv9QTi9xXH0+/mh0xgucBmPJGoMkz7l8KSp2R18FQt4iiuCuHHAXtL+DQEWIuU=;24:l9vyKu8tQpZFNBoGlLjYcjcpCTQCbRTUGsmgJuhTDC14VRWXU3qUzL17GiPqwxm7CxkoiZ/WuRZH8yf7IRZS7CzeULvrbdZhY75HGBGLVk8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;VI1PR0602MB3376;7:JO2xQPB44W9Zgo2QkfBh4BwAJG+TJfEIN1BfsdV/C+Rip0/E2yntrJmCUbnpLirIxfvCi2Qv3tTQBRUDWeiApS0dJOf+wXQCfGDg0iJgpLNxTFmXj7uK5id/Tcds/KMxP7hnAkgc+VJIACNHUhYT6GEMiHeu1IBfHbCNd9HF1jFCOs2mFMtWNlB4M2rRcEhxon0Pr+TKB42tgKGIM8rEJcWE+zuNptje881Nmx64rNG7oLTMbR8Mq6EIulb6Mvi8 X-OriginatorOrg: cern.ch X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2018 13:14:03.6448 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10436b7a-4360-418d-c81b-08d5d778dc88 X-MS-Exchange-CrossTenant-Id: c80d3499-4a40-4a8c-986e-abce017d6b19 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c80d3499-4a40-4a8c-986e-abce017d6b19;Ip=[188.184.36.50];Helo=[cernmxgwlb4.cern.ch] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0602MB3376 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, I believe that this patch fpga: manager: change api, don't use drvdata 7085e2a94f7df5f419e3cfb2fe809ce6564e9629 is incomplete and buggy. I completely agree that drvdata should not be used by the FPGA manager or any other subsystem like that. What is buggy is the function fpga_mgr_get(). That patch has been done to allow multiple FPGA manager instances to be linked to the same device (PCI it says). But function fpga_mgr_get() will return only the first found: what about the others? Then, all load kernel-doc comments says: "This code assumes the caller got the mgr pointer from of_fpga_mgr_get() or fpga_mgr_get()" but that function does not allow me to get, for instance, the second FPGA manager on my card. Since, thanks to this patch I'm actually the creator of the fpga_manager structure, I do not need to use fpga_mgr_get() to retrieve that data structure. Despite this, I believe we still need to increment the module reference counter (which is done by fpga_mgr_get()). We can fix this function by just replacing the argument from 'device' to 'fpga_manager' (the one returned by create() ). Alternatively, we can add an 'owner' field in "struct fpga_manager_ops" and 'get' it when we use it. Or again, just an 'owner' argument in the create() function. I'm proposing these alternatives because I'm not sure that this is correct: if (!try_module_get(dev->parent->driver->owner)) What if the device does not have a driver? Do we consider the following a valid use case? probe(struct device *dev) { struct device *mydev; mydev->parent = dev; device_register(mydev); fpga_mrg_create(mydev, ....); } thanks :)