Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp307012imm; Thu, 21 Jun 2018 19:09:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK80XTHguoa4Wm993y/NXnzsrZESyay0I5D3LIt8KiLSkOttz8AQtAoGS+qfDX046nHSJ8u X-Received: by 2002:a17:902:14b:: with SMTP id 69-v6mr31116236plb.184.1529633358847; Thu, 21 Jun 2018 19:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529633358; cv=none; d=google.com; s=arc-20160816; b=VJJX/yfN0HDJ3Op+bpGFstiNxEr8DrEKaDJBUCnr976l1I3GWdW46MQxdDIkHhFuBb s2Z/HkzIoZPB8VoivHisn/9FuAYRDnLB4CRiNLKDC6GcCGDz3ccKTwfPQJ/tnfQ3ZSRQ NgYm22my1He1qqLt1cznIyt1O++qCnaCIw8vBQ8+fvfS4q3KqvG01gwJT/AsbDDb6I/Z UxjRKWFE1IGvqFaTA4Wb3eSDfLzWfz0XkaIoC+T6p8X0RZS4XYd0CAem/WMpW82d+JLI 7a7EL+EEeFsMGVRyDNcz1xG3e+IprrrUmTzmwdjVKemymS2RBzP1qx++7rVRaaBeGViO ogFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=B9C+c/T1riREARF71H9qRet6gIc6O7AJcJFyIBj+UUw=; b=U/FUTncLy1JstuakavYLmoMJgbBZrW2N680v19Xwl9IgoDPaBts69WyZGOFtTOn4Nh trwoZUQoLvPo6R6ECMHzniqzwgI/j+S8/hcGukTobPpXRUsNg6pXIw89hCMmsXBJJw1t GfHF6vf7hbQHOgznjEZ5IVFAHiQKrYhf5ZQRzgABJBAaSBFn6YmRJ5+0OPdSU/3Q4ChG xP/aukwH/jIUDG3d8Bu1JSYGitZZvD8esmwyN88Qas9v/+qEQrn2GxlmIRHPVBUkRqyZ YIVAg9VEN2vk0aaumvAFUzDLaRBeXHBxT5SAPK5/5BV8A3XNfSXQ/EPFd3WeKE7T//LL Bi7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UIBCT3xZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o2-v6si5285829pgn.600.2018.06.21.19.09.04; Thu, 21 Jun 2018 19:09:18 -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=@kernel.org header.s=default header.b=UIBCT3xZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934271AbeFVCIY (ORCPT + 99 others); Thu, 21 Jun 2018 22:08:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:43218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934181AbeFVCIX (ORCPT ); Thu, 21 Jun 2018 22:08:23 -0400 Received: from mail-yw0-f169.google.com (mail-yw0-f169.google.com [209.85.161.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DA5C123C30; Fri, 22 Jun 2018 02:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529633303; bh=uqNCsLvZ4oYVeWTldEROQfN2ozzAbo55X2r86a3vvVI=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=UIBCT3xZT2e1C4UJ/aocbCedPACoYqN/p53dz8Ib3cNpDOmzShf5MpKHRbWvvzchP AYorWD53rJyOq3f0Wb8CJUmm4AZaSdajc+GHwAHdRRYooTfk6yovJuA6o+EU56SF1O vU12ghwthWYKTQbaDBhHFPf9Jyt/eaAuSLvhFcXQ= Received: by mail-yw0-f169.google.com with SMTP id b125-v6so1889567ywe.1; Thu, 21 Jun 2018 19:08:22 -0700 (PDT) X-Gm-Message-State: APt69E2POMSGBjMZMNnaDK/VLQBqjookdW7jFsmPvVed2P2PuJ2xOAz6 ZjY0piMIZqDn7S1+re36JGiXITIWlXx8DO2Dc2o= X-Received: by 2002:a81:94c5:: with SMTP id l188-v6mr13119536ywg.463.1529633302126; Thu, 21 Jun 2018 19:08:22 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a5b:b89:0:0:0:0:0 with HTTP; Thu, 21 Jun 2018 19:07:41 -0700 (PDT) In-Reply-To: <4617134.5euanDEBgJ@pcbe13614> References: <4617134.5euanDEBgJ@pcbe13614> From: Alan Tull Date: Thu, 21 Jun 2018 21:07:41 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: fpga: fpga_mgr_get() buggy ? To: federico.vaga@cern.ch Cc: Moritz Fischer , linux-fpga@vger.kernel.org, linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > 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. > 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? 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