Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp548591imm; Fri, 22 Jun 2018 00:54:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJwdJCDHdBLzYrk9cznrjXyo9mNod356eZ4osX1xWE4uUu98ZAzOFpnPuKaM3ushLaEMt0I X-Received: by 2002:a62:c296:: with SMTP id w22-v6mr614964pfk.92.1529654055039; Fri, 22 Jun 2018 00:54:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529654055; cv=none; d=google.com; s=arc-20160816; b=oJ8+4Bpv21klbZFiGcRM4i2FFF/ah2xMHre84lG6EBXqK9dfNsnwLS1ilOCH65IHgg AA2zVyli72ld5OHPihxIyXd0YqOrfUZQ1aPRJoopV8uFpGGkUaA9+GvtJAWOZyC+RRkX b9DSb2NQCsu+VXN5TglrFnYrY5zhRTp224VenZpN9G1s/5WTS1dhZMf28UKWkdE69IwO SumfAbTUX7n1SGxE2rmF3bEMpi7kVXd42gkgbHjGzUCpugYrR77UU40TGGJJ/ebNTZQe NhE8uzpjfKR1ipuBviymrtS9t23YIrmvYpgnZQGI/P8F0FIeiNrff1JP/9NVFnzApvzj Bbag== 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 :references:in-reply-to:message-id:date:subject:cc:reply-to:to:from :dkim-signature:arc-authentication-results; bh=eraXsO9h01HcS9kAYImtUFKVWNMgR1UHbcNyZGgyE2k=; b=StKt9EROHu7J9ZQ7pK3Yo+fl6w5XfdQ9sX6fjcT+XH0Y0Iv2EnazpDK1IdHWqsmvUy 8YedEGlYIo/8hvSk2S9m2sGhjWuTUBjGstlkoigvpA0d2r4MghYusp2Rlyw/BUh8BYzY U5CKHx/+Nr2EM2S508Zp+lctaUdCthKpBFH0A6iutBCIB1Q1KcAZttDODSsiliyefupO YQWv5PFYtcTaEmAb7ORscj6RU9V6awO8UkLscJP9aX4Oyej7pNwC95P/t+xo9S9eT9Tu ab3R438I+1kIthIIQvZAvvXKWZxJF+f9DxqaKgH9FyRjRGh3OiHg0DChytrfF1tr/i0i tOeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cern.onmicrosoft.com header.s=selector1-cern-ch header.b=XrH+eXB+; 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 t70-v6si5808343pgc.481.2018.06.22.00.54.00; Fri, 22 Jun 2018 00:54:15 -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=XrH+eXB+; 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 S1751263AbeFVHxU (ORCPT + 99 others); Fri, 22 Jun 2018 03:53:20 -0400 Received: from mail-he1eur01on0041.outbound.protection.outlook.com ([104.47.0.41]:60105 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750985AbeFVHxS (ORCPT ); Fri, 22 Jun 2018 03:53:18 -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=eraXsO9h01HcS9kAYImtUFKVWNMgR1UHbcNyZGgyE2k=; b=XrH+eXB+aIJ0OTriCqsJJkVxP+sVfuYjM8vhSnYV8rnAmhR4iX7XFHw8YLwUyyDdOBJrRGIpBXn73IZSGsvFxvcDsGJ0cK5AUYBOvQnW9/xUdRLL/higGSmtcHsnBVxFCSg5o6PlFrMtnr0223b1k/v+8x1YXEwP+8ngD5koDik= Received: from VI1PR0601CA0030.eurprd06.prod.outlook.com (2603:10a6:800:1e::40) by AM3PR06MB1139.eurprd06.prod.outlook.com (2a01:111:e400:5873::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.16; Fri, 22 Jun 2018 07:53:16 +0000 Received: from VE1EUR02FT033.eop-EUR02.prod.protection.outlook.com (2a01:111:f400:7e06::204) by VI1PR0601CA0030.outlook.office365.com (2603:10a6:800:1e::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.884.21 via Frontend Transport; Fri, 22 Jun 2018 07:53:15 +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 VE1EUR02FT033.mail.protection.outlook.com (10.152.12.99) 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; Fri, 22 Jun 2018 07:53:15 +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; Fri, 22 Jun 2018 09:53:07 +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; Fri, 22 Jun 2018 09:53:06 +0200 From: Federico Vaga To: Alan Tull Reply-To: CC: Moritz Fischer , , linux-kernel Subject: Re: fpga: fpga_mgr_get() buggy ? Date: Fri, 22 Jun 2018 09:53:06 +0200 Message-ID: <22840601.TEhG8FuRZq@pcbe13614> In-Reply-To: References: <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)(39380400002)(346002)(39860400002)(396003)(376002)(2980300002)(438002)(199004)(189003)(51914003)(486006)(16526019)(478600001)(46406003)(186003)(786003)(54906003)(316002)(106002)(43066004)(53546011)(966005)(11346002)(476003)(6116002)(126002)(33716001)(50466002)(336012)(446003)(26005)(47776003)(5660300001)(230700001)(44832011)(23726003)(305945005)(6246003)(356003)(106466001)(7736002)(86362001)(7636002)(229853002)(426003)(6916009)(8936002)(2906002)(97756001)(6306002)(8676002)(9686003)(33896004)(4326008)(3450700001)(74482002)(9576002)(76176011)(246002)(39026011)(422495003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM3PR06MB1139;H:cernmxgwlb4.cern.ch;FPR:;SPF:Pass;LANG:en;PTR:cernmx11.cern.ch;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d4b6988-8acc-4b20-5a36-08d5d8153656 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(4608076)(2017052603328)(7153060)(7193020);SRVR:AM3PR06MB1139; X-MS-TrafficTypeDiagnostic: AM3PR06MB1139: X-Microsoft-Exchange-Diagnostics: 1;AM3PR06MB1139;20:oIBKGk7aUsdQap+UybUflfwJjeaFMoCIOtR9uEkImNTsOroeXccAjEbzT3ddz7aWhuszdd5hrMIY/9PKyc950jgPh8VLyrSYonWxbEIBka16Sk/Ud+cQc1NkegwElrNc1mL16zMBI0+bhrDwoqb5U8Gbb+TabRWMxbTfqUKKDaHmzDMBBzvJBYNJtlbNKiVdywxje84MVEmtyU+OHKcZCMuxxJjoAmhy6b2YRGjmNHtKfqVBE8o34AEPIGlHcleeARpg61PlgxlD+fxxnkWG3MHHo9ntg3be7nzcU1p3eDF+ievxqZek0EIe0n8ijPSUsk5T6hg15Le4VpWVOrugTYMEEOeYZuu9ydYatWKomT2HYncsuSVFsgZ9sqj/N+s7AqlXkplpY0yMwMS9LUaaW2g7URANvsQaeLZoxnxwx2UEIrLSeBkk8di3KF147OmL0bUZN7ZttVegQ4voJNAJ6YtKYQWwBiRAQOqjvD7uh51DZvIWaDiNctntzujvpmtZ;4:bz6lPWekjyS7dXJNHO4aIO0a4BolKbrwbXcWnABbf4f7/htWnIQDxnT7O+sQMt0VHBmShNy0ETSPyrQvMmiGMz7MMzl3DiRYhXtmtY2K2WeiZ96Hn9ZWqZ47xgnAdaFvbh6P2xpmHN4efgf2ZJ777vVzKyyyEE2f0LhTWQ4/Iszm/Wm3x44XepwEpCdTa07kpQr2Me4Mv3Ry6cSD0lYLjnA6eHo7zsEz419DLsDscomSaRdxlIqO6Z7JEXa9DVGScZlRDLTll0m2upxscsa2q1jE0EXBlxzwIhGvG8QvkctnuQzpN/TD3bIXF1P5pI/3AaYv+FZYGwOPAi3c1EGmM8O/7epfTWOK9I2qLjyIHuc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(5213294742642); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93004095)(3002001)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281529075)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016);SRVR:AM3PR06MB1139;BCL:0;PCL:0;RULEID:;SRVR:AM3PR06MB1139; X-Forefront-PRVS: 071156160B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;AM3PR06MB1139;23:vp1HlNw6u9tKx0RHjVvYTBNjQvovUbMNlEvcD1r28?= =?us-ascii?Q?CJTU+dyFZks4xu5564yDs8En9fg9HX23CXSLplwAYnO2RNfswexFnjwFzmsK?= =?us-ascii?Q?4FfPk9CkOn5O9K8Ht7bozOOzH7uzMe5RtPBR/0H9qEuG7FheTPvH0sHZnxPK?= =?us-ascii?Q?P3sCbPMEcuMB3xk86RCHhNLQwxTUhdGZ/A4S3qQDvKLGNbiA+KgAqE99Q65M?= =?us-ascii?Q?xsie6RjXtTG4FovmzK86L8IjPpKfKaS/6xe1xj8kbsiK6+Kbum4WoF/wFiy7?= =?us-ascii?Q?ugeocKnTbP1KOulTaorr5wLJlTdk8RWJm0F2Rqjqk/FWm6fQ3v/6g02qtEb0?= =?us-ascii?Q?28KTua2+yoyc/01qxE3PVHzN4ixebBrVRos8qs0VR7io/jdP2om90jsDlezl?= =?us-ascii?Q?63DAsBVv1Gxm4yoEP1FBfxRG6bo/7ZlOU8LJDLjTfq1svOLFV88efAmkuyRL?= =?us-ascii?Q?cXY24EVgscwgqW2BWFGE+FOzV3TVXPjYHzn7Dz74D2CT/BfTLZI7DERmgFMP?= =?us-ascii?Q?SKwOxEnT8X4NCLnuzZd7DlToORwEmi4bVq4B3cP5+pXjawG+NLw5qt2acKFq?= =?us-ascii?Q?H66lUVdsmz6X7apOUuQ/lPsCWz+3/1TJHJ34rnq5tXic5i9XicPiHS94NqIX?= =?us-ascii?Q?/uyL8h8JGy40vZgVNsyiA40C4gf8D7Sro27OMW9IUackdvksDqJDFO5Xivg5?= =?us-ascii?Q?kYTJIbk4XZtOmwOo/Zg722pKK3kDP2VFKViTUSDxmogD/gnngvFy093QF/VG?= =?us-ascii?Q?189lR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CTGkWbMjDTs+cP3ZUwAiRHFKq91thZo936rh7hA74GCRiD X-OriginatorOrg: cern.ch X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2018 07:53:15.7678 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8d4b6988-8acc-4b20-5a36-08d5d8153656 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: AM3PR06MB1139 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alan, inline comments On Friday, 22 June 2018 04:07:41 CEST Alan Tull wrote: > On Thu, Jun 21, 2018 at 8:13 AM, Federico Vaga > wrote: > > Hi Federico, > > Thanks for the analysis. I'll probably not be able to look into > this very much until next week. A few notes below. > > > 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? > > I was thinking it was going to be one manager per device which makes > sense if the device corresponds to a single FPGA. But I could see > that there could be valid use cases that had more than one FPGA > such as on a PCI card. Here a practical example where we have 2 FPGAs on the same card https://www.ohwr.org/projects/svec/wiki/wiki > > 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() ). > > At first thought, that's what I'd want. > > > 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. > > It seems like we shouldn't have to do that. Why? > > 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, ....); > > > > } > > When would you want to do that? Not sure when, I'm in the middle of some other development and I stumbled into this issue. But of course I can do it ... at some point :) > Alan > > > thanks :) > > > > > > > > -- > > To unsubscribe from this list: send the line "unsubscribe > > linux-fpga" in the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html