mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: zhangfei <zhangfei.gao@linaro.org>
Cc: "zhangfei.gao@foxmail.com" <zhangfei.gao@foxmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-accelerators@lists.ozlabs.org,
	linux-kernel@vger.kernel.org,
	Kenneth Lee <liguozhu@hisilicon.com>,
	Zaibo Xu <xuzaibo@huawei.com>,
	Zhou Wang <wangzhou1@hisilicon.com>
Subject: Re: [PATCH 2/2] uacce: add uacce module
Date: Tue, 20 Aug 2019 07:33:41 -0700	[thread overview]
Message-ID: <20190820143341.GB1536@kroah.com> (raw)
In-Reply-To: <0f7c6241-2028-76e7-0314-8b99cd353bd6@linaro.org>

On Tue, Aug 20, 2019 at 08:36:50PM +0800, zhangfei wrote:
> Hi, Greg
> 
> On 2019/8/19 下午6:24, Greg Kroah-Hartman wrote:
> > > > > +static int uacce_create_chrdev(struct uacce *uacce)
> > > > > +{
> > > > > +	int ret;
> > > > > +
> > > > > +	ret = idr_alloc(&uacce_idr, uacce, 0, 0, GFP_KERNEL);
> > > > > +	if (ret < 0)
> > > > > +		return ret;
> > > > > +
> > > > Shouldn't this function create the memory needed for this structure?
> > > > You are relying ont he caller to do it for you, why?
> > > I think you mean uacce structure here.
> > > Yes, currently we count on caller to prepare uacce structure and call
> > > uacce_register(uacce).
> > > We still think this method is simpler, prepare uacce, register uacce.
> > > And there are other system using the same method, like crypto
> > > (crypto_register_acomp), nand, etc.
> > crypto is not a subsystem to ever try to emulate :)
> > 
> > You are creating a structure with a lifetime that you control, don't
> > have someone else create your memory, that's almost never what you want
> > to do.  Most all driver subsystems create their own memory chunks for
> > what they need to do, it's a much better pattern.
> > 
> > Especially when you get into pointer lifetime issues...
> OK, understand now, thanks for your patience.
> will use this instead.
> struct uacce_interface {
>         char name[32];
>         unsigned int flags;
>         struct uacce_ops *ops;
> };
> struct uacce *uacce_register(struct device *dev, struct uacce_interface
> *interface);

What?  Why do you need a structure?  A pointer to the name and the ops
should be all that is needed, right?

And 'dev' here is a pointer to the parent, right?  Might want to make
that explicit in the name of the variable :)

> > > > > +
> > > > > +static int uacce_dev_match(struct device *dev, void *data)
> > > > > +{
> > > > > +	if (dev->parent == data)
> > > > > +		return -EBUSY;
> > > > There should be in-kernel functions for this now, no need for you to
> > > > roll your own.
> > > Sorry, do not find this function.
> > > Only find class_find_device, which still require match.
> > It is in linux-next, look there...
> > 
> Suppose you mean the funcs: device_match_name,
> device_match_of_node,device_match_devt etc.
> Here we need dev->parent, there still no such func.

You should NEVER be matching on a parent.  If so, your use of the driver
model is wrong :)

Remind me to really review the use of the driver core code in your next
submission of this series please, I think it needs it.

thanks,

greg k-h

  reply	other threads:[~2019-08-20 14:33 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14  9:34 [PATCH 0/2] A General Accelerator Framework, WarpDrive Zhangfei Gao
2019-08-14  9:34 ` [PATCH 1/2] uacce: Add documents for WarpDrive/uacce Zhangfei Gao
2019-08-14  9:34 ` [PATCH 2/2] uacce: add uacce module Zhangfei Gao
2019-08-15 14:12   ` Greg Kroah-Hartman
     [not found]     ` <5d5a6757.1c69fb81.e0678.2ab2SMTPIN_ADDED_BROKEN@mx.google.com>
2019-08-19 10:22       ` Greg Kroah-Hartman
2019-08-20 12:38         ` zhangfei
2019-08-20 14:31           ` Greg Kroah-Hartman
2019-08-15 14:13   ` Greg Kroah-Hartman
2019-08-20 13:08     ` zhangfei
2019-08-20 16:59       ` Greg Kroah-Hartman
     [not found]         ` <5d5cf0fc.1c69fb81.ec57f.b853SMTPIN_ADDED_BROKEN@mx.google.com>
2019-08-21  9:17           ` Greg Kroah-Hartman
2019-08-21 14:30             ` zhangfei
2019-08-21 16:05               ` Greg Kroah-Hartman
2019-08-26  4:10                 ` Kenneth Lee
2019-08-26  4:29                   ` Greg Kroah-Hartman
2019-08-27 11:42                     ` Kenneth Lee
2019-08-27 18:48                       ` Greg Kroah-Hartman
2019-08-15 14:20   ` Greg Kroah-Hartman
     [not found]     ` <5d5a6f5b.1c69fb81.9d35e.5303SMTPIN_ADDED_BROKEN@mx.google.com>
2019-08-19 10:24       ` Greg Kroah-Hartman
2019-08-20 12:36         ` zhangfei
2019-08-20 14:33           ` Greg Kroah-Hartman [this message]
2019-08-24 12:53             ` zhangfei
2019-08-24 15:40               ` Greg Kroah-Hartman
2019-08-15 16:54   ` Jonathan Cameron
2019-08-23  9:21     ` zhangfei
2019-08-23 16:36       ` Jonathan Cameron
2019-08-23 16:42       ` Jonathan Cameron
2019-08-15 17:04 ` [PATCH 0/2] A General Accelerator Framework, WarpDrive Jerome Glisse
2019-08-20 14:26   ` zhangfei
2019-08-26  4:14   ` Kenneth Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190820143341.GB1536@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=arnd@arndb.de \
    --cc=liguozhu@hisilicon.com \
    --cc=linux-accelerators@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wangzhou1@hisilicon.com \
    --cc=xuzaibo@huawei.com \
    --cc=zhangfei.gao@foxmail.com \
    --cc=zhangfei.gao@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome